Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differentiate between Windows Ink (pen) and regular touch input #5926

Merged
merged 2 commits into from
Nov 23, 2022

Conversation

Susko3
Copy link
Contributor

@Susko3 Susko3 commented Jul 17, 2022

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)

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/

@flibitijibibo
Copy link
Collaborator

Might be related: #5481

@slouken slouken added this to the 3.2.0 milestone Nov 23, 2022
@slouken slouken merged commit 8f991d7 into libsdl-org:main Nov 23, 2022
@Susko3 Susko3 deleted the differentiate_windows_pen_touch_input branch November 23, 2022 18:10
Susko3 added a commit to Susko3/SDL that referenced this pull request Dec 16, 2023
slouken pushed a commit that referenced this pull request Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants