SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Differentiate between Windows Ink (pen) and regular touch input

Open Susko3 opened this issue 3 years ago • 1 comments

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/

Susko3 avatar Jul 17 '22 14:07 Susko3

Might be related: #5481

flibitijibibo avatar Jul 17 '22 15:07 flibitijibibo