uidriver/js: Update touch APIs for go2cpp

This commit is contained in:
Hajime Hoshi 2020-12-21 23:01:12 +09:00
parent e9d0b2e179
commit a6ade8f5cd

View File

@ -402,14 +402,12 @@ func (i *Input) updateForGo2Cpp() {
} }
i.touches = map[driver.TouchID]pos{} i.touches = map[driver.TouchID]pos{}
maxID := go2cpp.Get("maxTouchId").Int() maxID := go2cpp.Get("touchCount").Int()
for id := 0; id < maxID; id++ { for idx := 0; idx < maxID; idx++ {
x := go2cpp.Call("getTouchPositionX", id) id := go2cpp.Call("getTouchPositionId", idx)
y := go2cpp.Call("getTouchPositionY", id) x := go2cpp.Call("getTouchPositionX", idx)
if x.Type() != js.TypeNumber || y.Type() != js.TypeNumber { y := go2cpp.Call("getTouchPositionY", idx)
continue i.touches[driver.TouchID(id.Int())] = pos{
}
i.touches[driver.TouchID(id)] = pos{
X: x.Int(), X: x.Int(),
Y: y.Int(), Y: y.Int(),
} }