diff --git a/internal/driver/input.go b/internal/driver/input.go index b79fc0aa2..ddbe0deb6 100644 --- a/internal/driver/input.go +++ b/internal/driver/input.go @@ -29,10 +29,3 @@ type Input interface { TouchPosition(id int) (x, y int) Wheel() (xoff, yoff float64) } - -// TODO: Remove this for API simplicity. -type Touch struct { - ID int - X int - Y int -} diff --git a/internal/uidriver/mobile/input.go b/internal/uidriver/mobile/input.go index b5c5c5b44..9e8e6266b 100644 --- a/internal/uidriver/mobile/input.go +++ b/internal/uidriver/mobile/input.go @@ -104,7 +104,7 @@ func (i *Input) IsMouseButtonPressed(key driver.MouseButton) bool { return false } -func (i *Input) update(touches []*driver.Touch) { +func (i *Input) update(touches []*Touch) { i.m.Lock() i.touches = map[int]pos{} for _, t := range touches { diff --git a/internal/uidriver/mobile/ui.go b/internal/uidriver/mobile/ui.go index b2f5cf4cb..4ca72bd81 100644 --- a/internal/uidriver/mobile/ui.go +++ b/internal/uidriver/mobile/ui.go @@ -104,7 +104,7 @@ func getDeviceScale() float64 { // appMain is the main routine for gomobile-build mode. func (u *UserInterface) appMain(a app.App) { var glctx gl.Context - touches := map[touch.Sequence]*driver.Touch{} + touches := map[touch.Sequence]*Touch{} for e := range a.Events() { switch e := a.Filter(e).(type) { case lifecycle.Event: @@ -137,7 +137,7 @@ func (u *UserInterface) appMain(a app.App) { s := getDeviceScale() x, y := float64(e.X)/s, float64(e.Y)/s // TODO: Is it ok to cast from int64 to int here? - touches[e.Sequence] = &driver.Touch{ + touches[e.Sequence] = &Touch{ ID: int(e.Sequence), X: int(x), Y: int(y), @@ -145,7 +145,7 @@ func (u *UserInterface) appMain(a app.App) { case touch.TypeEnd: delete(touches, e.Sequence) } - ts := []*driver.Touch{} + ts := []*Touch{} for _, t := range touches { ts = append(ts, t) } @@ -409,6 +409,12 @@ func (u *UserInterface) Input() driver.Input { return &u.input } -func (u *UserInterface) UpdateInput(touches []*driver.Touch) { +type Touch struct { + ID int + X int + Y int +} + +func (u *UserInterface) UpdateInput(touches []*Touch) { u.input.update(touches) } diff --git a/mobile/touches_mobile.go b/mobile/touches_mobile.go index b8f5b875f..b2eb3edae 100644 --- a/mobile/touches_mobile.go +++ b/mobile/touches_mobile.go @@ -17,7 +17,6 @@ package mobile import ( - "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/uidriver/mobile" ) @@ -31,9 +30,9 @@ var ( ) func updateTouches() { - ts := []*driver.Touch{} + ts := []*mobile.Touch{} for id, position := range touches { - ts = append(ts, &driver.Touch{ + ts = append(ts, &mobile.Touch{ ID: id, X: position.x, Y: position.y,