Fix for mouse input when using PDCursesMod backend#117
Merged
Conversation
…e using an incompatable bit mask for mouse events. Added new CursesMouseEventParser.Get API and marked the old one as obsolete. Updated tests related to CursesMouseEventParser
pavkam
reviewed
Sep 29, 2025
pavkam
left a comment
Owner
There was a problem hiding this comment.
Hi @jordan-hemming, great work and many thanks for the fixes -- just one ask for you -- please add your name to the copyright headers and bump the years in them as well. I will get some time to instrument the repo with better workflows hopefully this week and then it will become easier.
Contributor
Author
|
Will do. I assume you just want me to update the headers for the files I've modified, rather than for the whole project? |
Owner
The files you modified. I'll add a contributors file in another PR and make it cleaner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mouse movement events weren't working correctly on PDCursesMod. They would only occur when a button was pressed. Also pressing the Control key with a mouse button would report the Alt key being pressed (keyboard events were fine though).
It turns out that PDCurses uses different bits for the mouse event modifiers than either NCurses 5 or 6. PDCursesMod uses this same bitmask. Specifically:
These are left shifted by one compared to NCurses 6, with Shift and Control swapped. Since you already have different mouse event parsing for NCurses 5 and 6 I just added another one for PDCurses.
I took the liberty of adding a new overload to
CursesMouseEventParser.Getwhich takes an enum rather than an integer as I thought this was more clear with the new addition (the old API is still available, marked as deprecated). If you'd prefer to just stick with the old API I can revert this change.Tests have been updated as appropriate.
I've tested this with PDCursesMod-WinCon and PDCursesMod-WinGUI on Windows 11 x64, and it fixes mouse movement and the modifier keys.
PDCurses-WinCon still doesn't support the mouse correctly, but I think that's a problem upstream.
I've also tested NCurses 6 on Linux x64 to check that nothing is broken.