mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
driver: Remove Touch struct
This commit is contained in:
parent
08308a7edf
commit
099c7bd5c9
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user