mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
internal/ui: update touches after the layout is determined on mobiles
Closes #2763
This commit is contained in:
parent
07d2706e63
commit
8a0aba45f5
@ -37,19 +37,27 @@ func (u *userInterfaceImpl) updateInputStateFromOutside(keys map[Key]struct{}, r
|
|||||||
|
|
||||||
u.inputState.Runes = append(u.inputState.Runes, runes...)
|
u.inputState.Runes = append(u.inputState.Runes, runes...)
|
||||||
|
|
||||||
u.inputState.Touches = u.inputState.Touches[:0]
|
u.touches = u.touches[:0]
|
||||||
for _, t := range touches {
|
for _, t := range touches {
|
||||||
x, y := u.context.clientPositionToLogicalPosition(t.X, t.Y, u.DeviceScaleFactor())
|
u.touches = append(u.touches, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *userInterfaceImpl) updateInputState() error {
|
||||||
|
u.m.Lock()
|
||||||
|
defer u.m.Unlock()
|
||||||
|
|
||||||
|
s := u.DeviceScaleFactor()
|
||||||
|
|
||||||
|
u.inputState.Touches = u.inputState.Touches[:0]
|
||||||
|
for _, t := range u.touches {
|
||||||
|
x, y := u.context.clientPositionToLogicalPosition(t.X, t.Y, s)
|
||||||
u.inputState.Touches = append(u.inputState.Touches, Touch{
|
u.inputState.Touches = append(u.inputState.Touches, Touch{
|
||||||
ID: t.ID,
|
ID: t.ID,
|
||||||
X: int(x),
|
X: int(x),
|
||||||
Y: int(y),
|
Y: int(y),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func (u *userInterfaceImpl) updateInputState() error {
|
|
||||||
// TODO: Adjust cursor and touch positions based on the latest layout (#2763).
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ type userInterfaceImpl struct {
|
|||||||
context *context
|
context *context
|
||||||
|
|
||||||
inputState InputState
|
inputState InputState
|
||||||
|
touches []TouchForInput
|
||||||
|
|
||||||
fpsMode FPSModeType
|
fpsMode FPSModeType
|
||||||
renderRequester RenderRequester
|
renderRequester RenderRequester
|
||||||
|
Loading…
Reference in New Issue
Block a user