-
Notifications
You must be signed in to change notification settings - Fork 3
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
Special keys no longer work after running cli #22
Comments
Thanks for the report. #17 - this might be responsible for overwriting the special keys on keyboard init. |
Happy to help with debugging, not much of a rustacean though, so I probably can't help with providing code :) |
Could be worth a try to comment out the state fetching and try to set the LEDs without this. This would tell us if it's really the state fetching that "removes" the keys. |
No change when removing the state fetching. |
You could try commenting out individual payloads in the function that sets the animation as a next step. I mean it's got to be somewhere. If that doesn't give us the result we want, I'm pretty much clueless. |
Confirmed. What is strange though: Also: A simple unplug/plug of the keyboard brings back those 4 keys to life. No special factory reset necessary. Cheers |
Mine is also german. |
Found it and fixed it here 😃 The reason is: In fact, instead of implicit calling
Expect a PR soon ... Cheers |
Auto-detach kernel driver (Fix #22)
Failed to check earlier, before merging the PR, but here the report comes:
Notice the
|
I see the additional KEY_UNKNOWN (240) here but I cannot reproduce any slowness. Note: The timestamps in column 3 are relative to the first displayed event. So if you see the following:
|
As you can see, the timestamp differences before running cherryrgb_cli and after are roughly the same (around 120ms). |
The additional key might be a side effect of detaching/attaching the kernel driver. |
I might have phrased it incorrectly - for me it appears like a buffering issue on keyevents. Will see how this behaviour can be logged/ evaluated in a proper fashion. |
I did play around some more:
So: short of writing a dedicated kernel driver, I'm afraid we hit a dead end here :-( |
Could it be that we need to explicitly release the interfaces? Haven't seen a line that releases them. Or should this be handled by re-attaching the kernel driver? When I wrote the program for the MX Board 3.0s I had similar issues regarding latency of the keys. I solved it with a factory reset. However one significant difference between the programs I see is the missing release of the interfaces. But that is just a wild guess. |
Nope. That is done by libusb. In fact, the re-attaching of the kernel driver is done in its realease function |
On more observation: The same KEY_UNKNOWN mess happens, if I fire up my Win10-VM, attach the Keyboard to it, let the CHERRY windows utility configure some colors and then revert the attachment. |
That means by specifying the auto attach, detach stuff, we shouldn't need to worry about this, right? |
Exactly |
Explanation for the slowness/sluggishness: libinbut does not display these (artificial key repeat events), but if you use Having arrived at this point, I think there are only 2 ways to solve this:
What do you guys think? |
Searching for linux HID driver filter keys, I stumbled over this: https://docs.kernel.org/hid/hid-bpf.html Apparently, this is very new (kernel 6.3.0-rc7) but it looks promising. So just out of curiosity: What kernel versions are you guys running right now? |
I'm on Kernel 6.2.11 |
Kernel 6.2.9 over here |
Oh and reading more of the HID kernel docs, there seems to be a way out of this without the need for a UHID (Userlevel HID transport drivers) - there is even a rust wrapper for those: https://crates.io/crates/uhid-virt |
This sounds very close to our scenario: https://lkml.org/lkml/2022/12/24/93
Currently testing this patch, which has not landed in mainline yet. |
Please note, that there is already a drivers/hid/cherry-hid.c which does similar things and is already in the kernel (even with older kernels back to at least 3.x). Maybe this just needs the relevant ProductIDs added and perhaps some small tweak in Regardless, I would prefer a userland (UHID) driver written in rust. Reasons:
Of course, if we want this, then the project needs some redesign:
Proposal: After that, you can decide which way we go in the future... What do you think? CU |
thanks for the thorough explaination. I can make the answer short: Your proposal sounds good, let's go this route! |
Well, I forgot something:
|
Imho, key -> key mapping should be the feature-scope here anyway. Pretty much every operating system provides key -> text mappings out-of-the-box.
Yeah thats interesting to look into for sure. I am still trying to find out the cause.. and especially: why is it causing a major slowdown in key processing for me but not anybody else. If it's a specific linux-issue, maybe we can get around it via userspace evdev / udev filtering. Got no hard evidence on that matter just yet tho.. |
On Fri Apr 21, 2023 at 7:59 PM CEST, Sebastian Kraus wrote:
> 1. Any future key remapping feature will only work on a key -> single key basis. Mapping of key -> text won't be available.
Imho, key -> key mapping should be the feature-scope here anyway. Pretty much every operating system provides key -> text mappings out-of-the-box.
I do not see it as a valuable feature tbh.
I agree. Since F13-F24 are a thing (and even more special keys), there is
certainly no shortage of key that can be used to trigger a macro.
> 2. This bug (Special keys no longer work after running cli) and my first solution leading to the KEY_UNKNOWN mess might be apply to MacOS as well. So somebody with a real Mac should probaly test v0.2.3 and current master. If this happens on MacOS as well, then we should decide, which of the two behaviors is the lesser evil, as without any driver implementation there cannot be any fix.
Yeah thats interesting to look into for sure. I am still trying to find out the cause.. and especially: why is it causing a major slowdown in key processing for me but not anybody else.
I have also seen a need to replug my keyboard after booting, as logins are not
possible in TTY as (what I assume to be) the unknown key is kept being pressed,
showing up as ^@ and being actually considered for username and password.
…--
Moritz Poldrack
https://moritz.sh
|
Ok lol, I should have done proper research earlier: Check this out: https://bbs.archlinux.org/viewtopic.php?id=267365 Apparently it's an acknowledged bug in the keyboard firmware! Temporary workaroundAdd this to
This just works around the sluggish input, it does not enable the special keys to work. Proper fixEmail Cherry support and request the test firmware for your model: https://www.cherry.de/service/kontakt |
Sorry but that is all wrong. I have seen this article too, but did not mention it, because there because it does NOT solve
|
BTW my UHID driver POC turned out to work very well. I was really amazed how easy it was to create an UHID driver in rust using the uhid-virt crate. I am now creating a real service daemon which does all I/O including the RGB stuff. As total rust-noob I currently struggling with parameterizing the thread handlers with the keyboard object of type CherryKeyboard. (The service daemon needs 2 threads (one worker for the UHID driver and another one for a UnixSocket server, which handles IPC from the cli to the service daemon and performs the RGB stuff when bein told so by the cli). In C++ this would be a std::shared_ptr and I experimented with std::rc:Rc but did not have any luck until now. Well, i learn more every minute ;-) |
Ok, I just pushed the branch uhid-service in my fork: This is WIP, but it works here nicely, so @mpldr perhaps you can give it a try. In order to keep backwards compatibility, I have NOT changed cherryrgb_cli. Instead, i have added 2 The service should run as root and provides the UHID driver as well as socket server, listening on The service has some related options. Run it with --help to get an overwiew. sudo cp target/debug/cherryrgb_service /usr/libexec/
sudo cp service/etc/systemd/system/cherryrgb.service /etc/systemd/system/
sudo cp service/etc/default/cherryrgb /etc/default/ Also, perhaps you want to edit
With this, I can use the cherryrgb_ncli as admin user on my Fedora system. After adjusting the config to your needs, run: sudo systemctl start cherryrgb.service and check for errors with: sudo systemctl status cherryrgb.service If the service is running, you should be able to run TODO (before considering a PR):
|
It seems the keys are "removed" from the keyboards firmware as no key events are sent at all.
After factory reset:
after running
cherryrgb_cli --product-id 223 --brightness full animation wave slow 500475
Used Keyboard: Cherry MX 10.0n RGB
The text was updated successfully, but these errors were encountered: