Skip to content

Add selection list for Keyboard selection when on Linux in uinput#1815

Open
NijeboerFrank wants to merge 7 commits intoopensteno:mainfrom
NijeboerFrank:fix-mouse-capture
Open

Add selection list for Keyboard selection when on Linux in uinput#1815
NijeboerFrank wants to merge 7 commits intoopensteno:mainfrom
NijeboerFrank:fix-mouse-capture

Conversation

@NijeboerFrank
Copy link

@NijeboerFrank NijeboerFrank commented Jan 19, 2026

Summary of changes

Add a Regex field which can be used to filter some keyboards. This prevents e.g. the situation where a mouse with a Logitech Unifying receiver is incorrectly captured on Linux in Wayland (that was bothering me).

I currently don't have access to other operating systems, so this PR only works for the uinput keyboard capture.

I will try to add some tests later. I'm also not very familiar with qt, so all feedback is appreciated.

Closes #1767

Pull Request Checklist

  • Changes have tests
  • News fragment added in news.d. See documentation for details

@NijeboerFrank
Copy link
Author

In my case, I would add ^(?!Logitech) to the Keyboard Regex field to exclude the unifying receiver with my mouse from being captured by Plover.

@mkrnr
Copy link
Contributor

mkrnr commented Jan 20, 2026

Thanks a lot @NijeboerFrank for working on this!

I now approved the GitHub actions run. Some tests will need the new parameter to be included.

Regarding the GUI: It would be good to make it more clear that this option is Linux only. Adding this to the tooltip is probably not enough because most people don't read that. You could either add "Linux only" to the option name or, even better, only show this option on Linux. See config_window.py:

        if PLATFORM != "linux":
            # Keyboard layout is only relevant on Linux
            keyboard_layout_option = option_by_name.get("keyboard_layout")
            if keyboard_layout_option is not None:
                keyboard_layout_option.label.hide()
                keyboard_layout_option.widget.hide()

@NijeboerFrank
Copy link
Author

Thanks for the tips @mkrnr! I'm trying to find some time this week to fix the tests and improve the GUI.

@user202729
Copy link
Member

user202729 commented Jan 21, 2026

I've a more fancy UI suggestion in #1187 (comment) (in my case it was for X implementation), but haven't found the time to properly integrate and upstream it. Having just a regex field works too (kind of).

only for Linux uinput though. Having it silently do nothing might not be such a good idea.

For the specific issue #1767:

In principle, uinput shouldn't be used when X is available, but maybe depends on certain environment variables it may not be correctly selected. Relying on the user to manually provide a regex is certainly a hack instead of a proper fix.

More proper fix would be

  • Distinguish between keyboard and mouse, and don't capture mice (mouses?). I think it's possible for a device to show up as both a keyboard and a mouse, maybe this is the case here.
  • More reliable way to see if X works.

@mkrnr actually I don't think hiding the option is a particularly good idea, might be better to gray it out (with a tooltip explaining why it's disabled on hover). Otherwise there may be some users who check a screenshot online, see the feature, not seeing it in their local install, and get confused.

@NijeboerFrank
Copy link
Author

NijeboerFrank commented Jan 21, 2026

@user202729 I was also thinking of something like that as well today. I could try to implement something like that to properly fix it, because I also think that the Regex version might be too hacky for non-technical users who run into this issue. I'm thinking of something like a dropdown if I can get it working.

My initial reasoning for Regex was that if you leave the field empty it will just work as it did previously and it won't interfere with the current way that uinput works for the people that don't have similar issues as the one that I had.

@NijeboerFrank
Copy link
Author

I changed the implementation to a list selection. Currently you can only select 1 keyboard from the list, because I also don't really see the usecase for selecting multiple as @user202729 mentioned in #118.

So now if you have the "Keyboard" option selected, you can select which Keyboard will be captured with uinput.

Let me know what you think, I'm happy to implement any feedback when I have the time.

@NijeboerFrank NijeboerFrank changed the title Add regex field to keyboard capture to prevent mouse capture Add selection list for Keyboard selection when on Linux in uinput Jan 23, 2026
Changed the implementation of the keyboard selection when using Linux to
a QComboBox. You can now select the keyboard you wish to use from a list
in the UI.

Also fixed the errors in the tests.
This environment variable was not passed with tox, meaning that it wasn't
exposed to the environment in Python. Now it is, and now you can use it
to determine x11 from Wayland.
@user202729
Copy link
Member

user202729 commented Jan 23, 2026

Actually, after thinking about it, a use case is if if you have multiple steno keyboards and may use one of them.

Anyway, I think the current implementation breaks the oslayer abstraction layer. Not to mention #1742 . And in X, you "need" the keyboard capture object to get the list of keyboards.

(up to @mkrnr what to do with it. On one hand there's the above, on the other hand there's the "the perfect is the enemy of the good" saying.)

@NijeboerFrank
Copy link
Author

@user202729 do you mean that you think that the implementation in this PR breaks the oslayer abstraction layer? Because I think I only changed the keyboardcontrol_uinput.py KeyboardCapture class. I didn't change anything in or related to keyboardcontrol_x11 AFAIK. I also added if-statements around the parts so that this code is only carried out on Wayland and not X11.

So if there's anything in this PR that needs fixing, let me know.

In the future I can also try to get multi-selection working so that people with multiple steno keyboards can use both and if there's need for such a feature.

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.

Logitech MX Master mouse is stuck when upgrading Plover from 4 to 5

3 participants