doodle/pkg/native/touch_screen.go
Noah Petherbridge 5b3121171e Fix touchscreen mode detection
* Touchscreen mode used to be detected based on SDL2 GetNumTouchDevices
  but on a Macbook, the trackpad registers as a touch device - worse,
  GetNumTouchDevices will only start returning 1 the first time some
  devices are touched.
* The result was that on macOS the custom mouse cursor was drawn by
  default, but on the first trackpad touch, would disappear in favor of
  assuming the game is running on a touch screen device (which is not
  the case).
* New method: the render engine has an IsFingerDown boolean which will
  be true as long as at least one finger has registered a FingerDown
  event, but not yet a FingerUp event.
* So as long as one finger is down, the mouse cursor can disappear and
  then it comes back on release. This isn't perfectly ideal for pure
  touch devices (ideally the cursor remains hidden until a mouse
  movement without touch occurs).
2024-04-19 22:01:33 -07:00

13 lines
499 B
Go

package native
// Common code to handle basic touch screen detection.
/*
IsTouchScreenMode is set to true when the user has touched the screen, and false when the mouse is moved.
This informs the game's control scheme: if the user has a touch screen and they've touched it,
the custom mouse cursor is hidden (as it becomes distracting) and if they then move a real mouse
over the window, the custom cursor appears again and we assume non-touchscreen mode once more.
*/
var IsTouchScreenMode bool