mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
mobile: UpdateTouchesOnIOS should take int64 ptrs
This commit is contained in:
parent
475d659459
commit
891ad34d88
@ -54,6 +54,6 @@ func UpdateTouchesOnAndroid(action int, id int, x, y int) {
|
|||||||
updateTouchesOnAndroid(action, id, x, y)
|
updateTouchesOnAndroid(action, id, x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
func UpdateTouchesOnIOS(phase int, ptr int, x, y int) {
|
func UpdateTouchesOnIOS(phase int, ptr int64, x, y int) {
|
||||||
updateTouchesOnIOSImpl(phase, ptr, x, y)
|
updateTouchesOnIOSImpl(phase, ptr, x, y)
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,6 @@ func updateTouchesOnAndroid(action int, id int, x, y int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTouchesOnIOSImpl(phase int, ptr int, x, y int) {
|
func updateTouchesOnIOSImpl(phase int, ptr int64, x, y int) {
|
||||||
panic("not reach")
|
panic("not reach")
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,5 @@ package mobile
|
|||||||
func updateTouchesOnAndroid(action int, id int, x, y int) {
|
func updateTouchesOnAndroid(action int, id int, x, y int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTouchesOnIOSImpl(phase int, ptr int, x, y int) {
|
func updateTouchesOnIOSImpl(phase int, ptr int64, x, y int) {
|
||||||
}
|
}
|
||||||
|
@ -22,17 +22,37 @@ package mobile
|
|||||||
// #import <UIKit/UIKit.h>
|
// #import <UIKit/UIKit.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
var ptrToID = map[int64]int{}
|
||||||
|
|
||||||
|
func getIDFromPtr(ptr int64) int {
|
||||||
|
if id, ok := ptrToID[ptr]; ok {
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
maxID := 0
|
||||||
|
for _, id := range ptrToID {
|
||||||
|
if maxID > id {
|
||||||
|
maxID = id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
id := maxID + 1
|
||||||
|
ptrToID[ptr] = id
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
func updateTouchesOnAndroid(action int, id int, x, y int) {
|
func updateTouchesOnAndroid(action int, id int, x, y int) {
|
||||||
panic("not reach")
|
panic("not reach")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateTouchesOnIOSImpl(phase int, ptr int, x, y int) {
|
func updateTouchesOnIOSImpl(phase int, ptr int64, x, y int) {
|
||||||
switch phase {
|
switch phase {
|
||||||
case C.UITouchPhaseBegan, C.UITouchPhaseMoved, C.UITouchPhaseStationary:
|
case C.UITouchPhaseBegan, C.UITouchPhaseMoved, C.UITouchPhaseStationary:
|
||||||
touches[ptr] = position{x, y}
|
id := getIDFromPtr(ptr)
|
||||||
|
touches[id] = position{x, y}
|
||||||
updateTouches()
|
updateTouches()
|
||||||
case C.UITouchPhaseEnded, C.UITouchPhaseCancelled:
|
case C.UITouchPhaseEnded, C.UITouchPhaseCancelled:
|
||||||
delete(touches, ptr)
|
id := getIDFromPtr(ptr)
|
||||||
|
delete(ptrToID, ptr)
|
||||||
|
delete(touches, id)
|
||||||
updateTouches()
|
updateTouches()
|
||||||
default:
|
default:
|
||||||
panic("not reach")
|
panic("not reach")
|
||||||
|
Loading…
Reference in New Issue
Block a user