diff --git a/input.go b/input.go index 0dd8e212e..0ff5b0711 100644 --- a/input.go +++ b/input.go @@ -119,7 +119,7 @@ type Touch interface { // // Touches always returns nil on desktops. func Touches() []Touch { - t := input.Get().Touches() + t := ui.AdjustedTouches() tt := make([]Touch, len(t)) for i := 0; i < len(tt); i++ { tt[i] = t[i] diff --git a/internal/ui/ui_glfw.go b/internal/ui/ui_glfw.go index 422cdd690..1474acf10 100644 --- a/internal/ui/ui_glfw.go +++ b/internal/ui/ui_glfw.go @@ -366,6 +366,11 @@ func adjustCursorPosition(x, y int) (int, int) { return x - int(ox/s), y - int(oy/s) } +func AdjustedTouches() []*input.Touch { + // TODO: Apply adjustCursorPosition + return input.Get().Touches() +} + func IsCursorVisible() bool { u := currentUI if !u.isRunning() { diff --git a/internal/ui/ui_js.go b/internal/ui/ui_js.go index d5b70b7d7..0bd8ced8f 100644 --- a/internal/ui/ui_js.go +++ b/internal/ui/ui_js.go @@ -86,6 +86,11 @@ func AdjustedCursorPosition() (x, y int) { return int(float64(x) / scale), int(float64(y) / scale) } +func AdjustedTouches() []*input.Touch { + // TODO: Apply adjustment here + return input.Get().Touches() +} + func IsCursorVisible() bool { // The initial value is an empty string, so don't compare with "auto" here. return canvas.Get("style").Get("cursor").String() != "none" diff --git a/internal/ui/ui_mobile.go b/internal/ui/ui_mobile.go index c670c0850..fc0edc963 100644 --- a/internal/ui/ui_mobile.go +++ b/internal/ui/ui_mobile.go @@ -242,6 +242,11 @@ func AdjustedCursorPosition() (x, y int) { return currentUI.adjustCursorPosition(input.Get().CursorPosition()) } +func AdjustedTouches() []*input.Touch { + // TODO: Apply adjustment here + return input.Get().Touches() +} + func (u *userInterface) adjustCursorPosition(x, y int) (int, int) { u.m.Lock() ox, oy, _, _ := u.screenPaddingImpl()