-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[rcore] IsKeyPressed()
not working for some keys on RPI (PLATFORM DRM
)
#3569
Comments
Just to summarize: keys insert delete, home, end, page up, page down are not implemented in on the RPi (PLATFORM DRM in rcore_drm.c: raylib/src/platforms/rcore_drm.c Lines 1333 to 1375 in a3a73b9
only 3 byte and 5 byte scan codes for F keys and cursor keys are implemented: here are the missing 4 byte codes: insert delete home end page up page down |
IsKeyPressed()
not working for some keys on RPI (PLATFORM DRM
)
@larry104 Took the time to review this and Code example
Log
EnvironmentSuccessfully tested on Raspberry Pi 3 Model B 1.2 with Linux (Raspberry Pi OS 11 Bullseye 32-bit armhf). |
It doesn't work with raylib 4.5 ... is that something which might have been fixed in 5.x ?. I tired from ssh shell as well as native shell. (bullseye, raspberry pi zero
|
@larry104 |
I'm closing this issue, it seems it refers to an old raylib version. |
I compiled the test case using the master branch 5.1.-dev and it still does not work for those keys. I added a log for the BACKSPACE key and that works fine: ./raylibtest1 |
@larry104 I can't reproduce the issue. Tested it again right now and it's working correctly for me: |
This is super strange. I tested it on a RPi3 and RPi Zero and both don't work ... What locale do you have set on your RPi? I have no other idea why this does not work for these 6 keys |
Keyboard is set correctly ... |
@larry104 I'm using If you're accessing it through To have those on Side-note: I'm really not sure if the |
I connected a keyboard to the RPi, rebooted and tested again ... still same issue. Is there any compile flag needed other than |
@larry104 My exact steps here:
Edit: formatting. |
I am fetching it with cmake but just to make sure ... I did exactly what you did and it does not work. I even tried on bookworm . hmm |
@larry104 I really don't know what could be causing that issue. Perhaps try another keyboard just to be sure? |
I just tried a different keyboard ... same exact issue ... and I added a control key BACKSPACE which works |
@larry104 I honestly have no idea why that's happening. Here are my full logs:
|
The logs are pretty much identical ... I even changed XKBVARIANT="intl" since it wasn't set but there is no difference. Can you point me to the code where the key events are captured. I can add some debug prints in there to see what's going on. |
@larry104 are you running PLATFORM_DRM in native mode, right? I mean, without any windowing system/desktop. |
yes, I do. it says INFO: Platform backend: NATIVE DRM ... I boot directly into a terminal. It seems the code never enters the while loop in line raylib/src/platforms/rcore_drm.c Line 1691 in 811abcb
Meaning no log messages inside the while loop but directly before the while there are log messages getting printed |
@larry104 Sorry, not sure I understand. I was able to log inside it: |
@larry104 Did exactly like your print and was able to print it: |
@ubkp I created it for my convenience when I implemented RPI support first time, definitely not a priority and probably useless at this point. @larry104 Could you verify if |
Yes, PollKeyboardEvents() is called but raylib/src/platforms/rcore_drm.c Line 1691 in 811abcb
returns always -1 so it never enters the while loop |
@larry104 could it be related to some kind of security reason? did you try running the example as root? |
I tried as root no difference ... what I don't understand why other keys work just these 6 not ... that is all really strange |
ok you won't believe it but I installed a brand new OS (based on bullseye) exactly the one you had with desktop environment. Changed it to boot into CLI, updated packages and installed the list of packages needed to compile raylib. Compiled the example we had before. BUT, it still does not work. Now I am really puzzled ... I should mention I didn't uncomment the SUPPORT_SSH_KEYBOARD_RPI ... do you want me to try that too? |
@larry104 No need. It really should have worked like that. I'm afraid that only leaves hardware as the possible issue. Are you using some KVM switch? Or an USB hub? Or a mechanical keyboard? Or a wireless/bluetooth keyboard? Edit: typo. |
Since I did this test on a RPi Zero I used a USB hub. But, I tried it without the hub as well. I also tried swapping this standard Microsoft keyboard with a Bluetooth keyboard. Same issue. I can try to get some other keyboards as well but I'm not confident it solves the problem. It's a mystery ... |
@larry104 Yeah, probably not hardware then. Do you have SSH enabled? If yes, could you disable it, then try to recompile raylib and the example with Edit: while recompiling raylib, could you please post the output so I can see the errors/warnings? |
this is a really strange issue... |
I recompiled with SUPPORT_SSH_KEYBOARD_RPI disabled. There were no errors/warning during the compile. Now we are back to that no key at all works. What is super strange is I gave the code to a friend with a RPi 3 and he tested it but it was still based on the 4.5 version I was compiling against and he was having the same problems. That at least makes me believe it's not a HW problem. |
@larry104 I'm going to reflash my Raspberry Pi right now. I'll use this exact image: |
@larry104 This was exactly what I did (with as much detail as possible):
|
Here might be the difference, can you try booting directly into CLI instead compiling it from X11? |
@larry104 Tested right now. It's also working correctly for me: |
wow, now I am literally going insane. I have no more ideas ... If you use the RPi Imager on Windows you can set locale, ssh, wifi etc. before you actually flash the image and this is what I did. Let me do it all over again and do it later from X11 .. I try one more time and then I buy a new RPi ;-) |
@larry104 Maybe that's the problem. Can you flash it some other way? |
I still used the Imager but didn't make any changes to settings ... flashing just done ... |
@larry104 Meanwhile I reflashed my Raspberry Pi with https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-32-bit
No X11 or anything, just CLI.
|
ok ... that would really point to a HW issue. Let me finish that current setup and I try to find another keyboard, I think I have one more somewhere. If that doesn't work I order the latest RPi Zero 2 W. |
@larry104 I was able to replicate the issue! Found a keyboard here that doesn't work (a Edit: |
oh wow ... this is awsome ... so I am not insane after all!!!!! Mine is a Microsoft Wired Keyboard 600 and the other one a Microsoft Wireless Desktop 900 Keyboard. I will ask my friend what he was using. |
@larry104 It's honestly amazing how MS can't even make keyboards right. Why I am not surprised... Either way, the problem appears to be that this (these) keyboard(s) are registering twice on the /proc/bus/input/devices Once you unbind the duplicated: Then everything works as expected: So, definitely not a raylib issue. :) Edit: typo. |
I was about to say the same thing about MS ;-) Too bad I had two of them to test. Thank you so much for all your help to figure it out!!!! And people will find here now the best installation instructions of raylib on a RPi with bullseye or bookworm ;-) |
@larry104 No problem. 👍 Haha, for sure. :) |
@larry104 @ubkp Wow! Amazing research work! Congratulations! Really impressed you found the root of the issue! @michaelfiber Were you aware of this issue with those Microsoft keyboards? Is there any possible work-around for this issue? How do other libraries address it (SDL)? |
If I'm reading the thread right, I've encountered this. My microsoft keyboard shows up as 2 keyboards. My keychron shows up as 3 keyboards and 2 mice. And the built in keyboard of my dell rugged laptop shows up as 2 keyboards and 1 mouse even though it has a touchscreen AND a touchpad. I think it's actually quite common with any keyboards that have any kind of nonstandard keys on them. I believe my old SteelSeries did too as well as some of my other keyboards. But the input code I've been using doesn't have an issue with it because I poll all keyboard devices and combine their input into a single logical keyboard. But when I get back to working on the input stuff I'll be sure to see if my approach works here. It is possible I didn't test those keys because I don't press them a ton. |
@michaelfiber Oh! That sounds like a good approach. Please, let us know if you test it.... and feel free to open a PR for the inputs update when possible... ;) |
btw/ I confirmed on my side I get the MS keyboard twice in /proc/bus/input/devices and I confirmed that my friend also had a MS keyboard. How are the odds having 3 MS keyboards ;-). I further confirm that my Logitech MS keyboard works without any problems. The Logitech keyboard appears only once in /proc/bus/input/devices |
That's true. I've tested a few more keyboards and, indeed, many appear as more than one device and still work properly. So I guess the actual problem is probably related to that specific MS keyboard device-family. My best guess is either the device-family common firmware or somewhere between that and evdev.
That would be an excellent solution. |
@ubkp I found another issue with the keyboard. When using the keyboard through ssh the key repeat works without any problems. When using a keyboard connected directly to the RPi the key repeat does not work. |
@larry104 Nice catch! I'll send a PR fixing it shortly. 👍 |
this seems like a different issue with the 3000, but could it be related ? [quote] The fix is to go to Control Panel with Win-X menu, select Hardware and Sound, select Devices and Printers, right click on your keyboard, select Properties, click on Hardware, click on USB Input Device and then Properties, then Change settings, then Power Management and remove check mark from "Allow the computer to turn off this device to save power". |
@jamesl-github It's hard to tell. At first glance I don't think it's directly related. That looks like a driver issue and/or driver management issue by the Windows OS. |
Discussed in #3565
Originally posted by larry104 November 22, 2023
I notices that the block of keys (insert, delete home, end, pup, pdown) are not working. IsKeyPressed is not getting any event for these keys (I tried different keyboards and started the application from ssh terminal vs native terminal no difference). All other keys are working fine. Does anyone have an idea what is going wrong ?
The text was updated successfully, but these errors were encountered: