Skip to content

Work around infrequent crash when pen enters proximity on Windows#6752

Merged
bdach merged 1 commit into
ppy:masterfrom
Susko3:work-around-pen-crash
May 20, 2026
Merged

Work around infrequent crash when pen enters proximity on Windows#6752
bdach merged 1 commit into
ppy:masterfrom
Susko3:work-around-pen-crash

Conversation

@Susko3
Copy link
Copy Markdown
Member

@Susko3 Susko3 commented May 14, 2026

This hard-codes the pen type on Windows to TabletPenDeviceType.Unknown. There is no change in functionality as SDL already reports all pens on Windows as SDL_PEN_DEVICE_TYPE_UNKNOWN.

The crash is fixed by not calling SDL_GetPenDeviceType(), which may sometimes error out with "Invalid pen instance ID".


I also considered storing the last pen type and using that in the error case, but I found it too hacky, it doesn't fix the underlying issue and increases complexity.

@smoogipoo smoogipoo requested a review from bdach May 20, 2026 09:58
Copy link
Copy Markdown
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claim that on Windows SDL_PEN_DEVICE_TYPE_UNKNOWN is always returned appears to check out against my sample size of one (1) osu!-branded XP-Pen Deco Fun XS.

Of particular note I could not even get SDL_EVENT_PEN_PROXIMITY_{IN,OUT} to trigger until XP-Pen drivers were present. So possibly this is due to errant drivers. We will likely never know.

@bdach bdach merged commit 7d1c16b into ppy:master May 20, 2026
13 of 14 checks passed
@Susko3 Susko3 deleted the work-around-pen-crash branch May 21, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

osu.Framework.Platform.SDL3.SDL3Exception: Invalid pen instance ID (at SDL_GetPenDeviceType(evtPenProximity.which))

3 participants