The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Classifying touchscreen and trackpad fingerdown events
ace491


Joined: 07 Jun 2014
Posts: 24
I'm trying to support touchscreen laptops in my game. The user should be able to play with the keyboard and mouse and/or the touchscreen. The problem is that both the touchscreen and the trackpad produce SDL_FINGERDOWN events. This is problematic because if the user just wants to use the trackpad, they'll be causing SDL_FINGERDOWN events simply by touching the trackpad, not actually pushing any buttons.
They probably produce a different SDL_TouchID, but SDL_TouchID is not constant and changes on every program execution.I don't want the user to have to assign SDL_TouchIDs every time they start the game.
Is there any way to differentiate between types of touch devices?
mafik


Joined: 02 Nov 2014
Posts: 1
Code:
#ifdef __MACOS__
  // all fingerevents are coming from trackpad - ignore them (or not)
#else
  // fingerevents are coming from touchscreen
#endif


This will work until Apple starts installing touchscreens in their computers. By that time, SDL should have something like

Code:
int SDL_GetVideoDisplayForTouchDevice()


which would play nicely with devices such as 3DS or modern phones