diff --git a/internal/driver/input.go b/internal/driver/input.go new file mode 100644 index 000000000..ebf066692 --- /dev/null +++ b/internal/driver/input.go @@ -0,0 +1,22 @@ +// Copyright 2019 The Ebiten Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package driver + +// TODO: Remove this for API simplicity. +type Touch struct { + ID int + X int + Y int +} diff --git a/internal/input/input.go b/internal/input/input.go index 976fa5be8..022ad77ac 100644 --- a/internal/input/input.go +++ b/internal/input/input.go @@ -120,9 +120,3 @@ type gamePad struct { buttonNum int buttonPressed [256]bool } - -type Touch struct { - ID int - X int - Y int -} diff --git a/internal/input/input_mobile.go b/internal/input/input_mobile.go index eea6edb68..9694cfa1e 100644 --- a/internal/input/input_mobile.go +++ b/internal/input/input_mobile.go @@ -46,7 +46,7 @@ func (i *Input) IsMouseButtonPressed(key driver.MouseButton) bool { return false } -func (i *Input) SetTouches(touches []*Touch) { +func (i *Input) SetTouches(touches []*driver.Touch) { i.m.Lock() i.touches = map[int]pos{} for _, t := range touches { diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index ddf8e1f4d..6de054a5a 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -95,7 +95,7 @@ func getDeviceScale() float64 { // appMain is the main routine for gomobile-build mode. func appMain(a app.App) { var glctx gl.Context - touches := map[touch.Sequence]*input.Touch{} + touches := map[touch.Sequence]*driver.Touch{} for e := range a.Events() { switch e := a.Filter(e).(type) { case lifecycle.Event: @@ -128,7 +128,7 @@ func 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] = &input.Touch{ + touches[e.Sequence] = &driver.Touch{ ID: int(e.Sequence), X: int(x), Y: int(y), @@ -136,7 +136,7 @@ func appMain(a app.App) { case touch.TypeEnd: delete(touches, e.Sequence) } - ts := []*input.Touch{} + ts := []*driver.Touch{} for _, t := range touches { ts = append(ts, t) } diff --git a/mobile/touches_mobile.go b/mobile/touches_mobile.go index fba31d0c2..6651b9bae 100644 --- a/mobile/touches_mobile.go +++ b/mobile/touches_mobile.go @@ -17,6 +17,7 @@ package mobile import ( + "github.com/hajimehoshi/ebiten/internal/driver" "github.com/hajimehoshi/ebiten/internal/input" ) @@ -30,9 +31,9 @@ var ( ) func updateTouches() { - ts := []*input.Touch{} + ts := []*driver.Touch{} for id, position := range touches { - ts = append(ts, &input.Touch{ + ts = append(ts, &driver.Touch{ ID: id, X: position.x, Y: position.y,