SDL
SDL copied to clipboard
Differentiate between Windows Ink (pen) and regular touch input
Description
Allows consumers to differentiate pen from touch input.
Windows will send WM_TOUCH messages for both regular touch input, and for pen/tablet PC/Windows Ink input.
Pen events will have the TOUCHEVENTF_PEN flag is set in TOUCHINPUT.dwFlags.
Consumers can use SDL_GetTouchName to get the device type ("pen" or "touch") for a SDL_TouchFingerEvent:
SDL_Event event; // from event loop
int index = -1;
for (int i = 0; i < SDL_GetNumTouchDevices(); i++) {
if (event.tfinger.touchId == SDL_GetTouchDevice(i)) {
index = i;
break;
}
}
if (SDL_strncmp(SDL_GetTouchName(index), "pen", 3) == 0) {
// pen/tablet handling
} else {
// touchscreen handling
}
Existing Issue(s)
- https://github.com/ppy/osu/issues/19150
Testing
I've tested this on a Windows Ink compatible drawing tablet. Not tested on a touchscreen, but I have faith in the flags set by windows.
Wiki
If this goes trough, I will add the above code and a short description to https://wiki.libsdl.org/SDL_TouchFingerEvent/
Might be related: #5481