mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
uidriver/js: Implement touches on go2cpp
This commit is contained in:
parent
2a2866bf65
commit
b20f611058
@ -395,3 +395,23 @@ func (i *Input) updateTouchesFromEvent(e js.Value) {
|
||||
}
|
||||
i.touches = ts
|
||||
}
|
||||
|
||||
func (i *Input) updateForGo2Cpp() {
|
||||
if !go2cpp.Truthy() {
|
||||
return
|
||||
}
|
||||
|
||||
i.touches = map[driver.TouchID]pos{}
|
||||
maxID := go2cpp.Get("maxTouchId").Int()
|
||||
for id := 0; id < maxID; id++ {
|
||||
x := go2cpp.Call("getTouchPositionX", id)
|
||||
y := go2cpp.Call("getTouchPositionY", id)
|
||||
if x.Type() != js.TypeNumber || y.Type() != js.TypeNumber {
|
||||
continue
|
||||
}
|
||||
i.touches[driver.TouchID(id)] = pos{
|
||||
X: x.Int(),
|
||||
Y: y.Int(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,7 @@ func (u *UserInterface) update() error {
|
||||
hooks.ResumeAudio()
|
||||
|
||||
u.input.updateGamepads()
|
||||
u.input.updateForGo2Cpp()
|
||||
u.updateSize()
|
||||
if err := u.context.Update(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user