Skip to content
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

Closed
larry104 opened this issue Nov 23, 2023 Discussed in #3565 · 61 comments
Closed

[rcore] IsKeyPressed() not working for some keys on RPI (PLATFORM DRM) #3569

larry104 opened this issue Nov 23, 2023 Discussed in #3565 · 61 comments
Labels
platform: DRM/RPI DRM/Raspberry Pi platform

Comments

@larry104
Copy link

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 ?

@larry104
Copy link
Author

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:

if (keysBuffer[i + 1] == 0x5b) // Special function key
{
if ((keysBuffer[i + 2] == 0x5b) || (keysBuffer[i + 2] == 0x31) || (keysBuffer[i + 2] == 0x32))
{
// Process special function keys (F1 - F12)
switch (keysBuffer[i + 3])
{
case 0x41: CORE.Input.Keyboard.currentKeyState[290] = 1; break; // raylib KEY_F1
case 0x42: CORE.Input.Keyboard.currentKeyState[291] = 1; break; // raylib KEY_F2
case 0x43: CORE.Input.Keyboard.currentKeyState[292] = 1; break; // raylib KEY_F3
case 0x44: CORE.Input.Keyboard.currentKeyState[293] = 1; break; // raylib KEY_F4
case 0x45: CORE.Input.Keyboard.currentKeyState[294] = 1; break; // raylib KEY_F5
case 0x37: CORE.Input.Keyboard.currentKeyState[295] = 1; break; // raylib KEY_F6
case 0x38: CORE.Input.Keyboard.currentKeyState[296] = 1; break; // raylib KEY_F7
case 0x39: CORE.Input.Keyboard.currentKeyState[297] = 1; break; // raylib KEY_F8
case 0x30: CORE.Input.Keyboard.currentKeyState[298] = 1; break; // raylib KEY_F9
case 0x31: CORE.Input.Keyboard.currentKeyState[299] = 1; break; // raylib KEY_F10
case 0x33: CORE.Input.Keyboard.currentKeyState[300] = 1; break; // raylib KEY_F11
case 0x34: CORE.Input.Keyboard.currentKeyState[301] = 1; break; // raylib KEY_F12
default: break;
}
if (keysBuffer[i + 2] == 0x5b) i += 4;
else if ((keysBuffer[i + 2] == 0x31) || (keysBuffer[i + 2] == 0x32)) i += 5;
}
else
{
switch (keysBuffer[i + 2])
{
case 0x41: CORE.Input.Keyboard.currentKeyState[265] = 1; break; // raylib KEY_UP
case 0x42: CORE.Input.Keyboard.currentKeyState[264] = 1; break; // raylib KEY_DOWN
case 0x43: CORE.Input.Keyboard.currentKeyState[262] = 1; break; // raylib KEY_RIGHT
case 0x44: CORE.Input.Keyboard.currentKeyState[263] = 1; break; // raylib KEY_LEFT
default: break;
}
i += 3; // Jump to next key
}
// NOTE: Some keys are not directly keymapped (CTRL, ALT, SHIFT)
}
}
}

only 3 byte and 5 byte scan codes for F keys and cursor keys are implemented: here are the missing 4 byte codes:

insert
^[[2~ 27 0033 0x1b
91 0133 0x5b
50 0062 0x32
126 0176 0x7e

delete
^[[3~ 27 0033 0x1b
91 0133 0x5b
51 0063 0x33
126 0176 0x7e

home
^[[1~ 27 0033 0x1b
91 0133 0x5b
49 0061 0x31
126 0176 0x7e

end
^[[4~ 27 0033 0x1b
91 0133 0x5b
52 0064 0x34
126 0176 0x7e

page up
^[[5~ 27 0033 0x1b
91 0133 0x5b
53 0065 0x35
126 0176 0x7e

page down
^[[6~ 27 0033 0x1b
91 0133 0x5b
54 0066 0x36
126 0176 0x7e

@raysan5 raysan5 changed the title IsKeyPressed for some keys not working on RPi (PLATFORM DRM) [rcore] IsKeyPressed() not working for some keys on RPI (PLATFORM DRM) Nov 23, 2023
@raysan5 raysan5 added the platform: DRM/RPI DRM/Raspberry Pi platform label Nov 23, 2023
@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 Took the time to review this and IsKeyPressed() and all those keys (KEY_INSERT, KEY_DELETE, KEY_HOME, KEY_END, KEY_PAGE_UP, KEY_PAGE_DOWN, full enum at L564-L679) are working correctly for me.

Code example

#include "raylib.h"

int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {
        
        if (IsKeyPressed(KEY_INSERT)) { TraceLog(LOG_INFO, "KEY_INSERT"); }
        if (IsKeyPressed(KEY_DELETE)) { TraceLog(LOG_INFO, "KEY_DELETE"); }
        if (IsKeyPressed(KEY_HOME)) { TraceLog(LOG_INFO, "KEY_HOME"); }
        if (IsKeyPressed(KEY_END)) { TraceLog(LOG_INFO, "KEY_END"); }
        if (IsKeyPressed(KEY_PAGE_UP)) { TraceLog(LOG_INFO, "KEY_PAGE_UP"); }
        if (IsKeyPressed(KEY_PAGE_DOWN)) { TraceLog(LOG_INFO, "KEY_PAGE_DOWN"); }

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

Log

INFO: Initializing raylib 5.1-dev
INFO: Platform backend: NATIVE DRM
INFO: Supported raylib modules:
[...]
INFO: KEY_INSERT
INFO: KEY_DELETE
INFO: KEY_HOME
INFO: KEY_END
INFO: KEY_PAGE_UP
INFO: KEY_PAGE_DOWN
[...]
INFO: Window closed successfully

Environment

Successfully tested on Raspberry Pi 3 Model B 1.2 with Linux (Raspberry Pi OS 11 Bullseye 32-bit armhf).

@larry104
Copy link
Author

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

./raylibtest1 INFO: Initializing raylib 4.5 INFO: Supported raylib modules: INFO: > rcore:..... loaded (mandatory) INFO: > rlgl:...... loaded (mandatory) INFO: > rshapes:... loaded (optional) INFO: > rtextures:. loaded (optional) INFO: > rtext:..... loaded (optional) INFO: > rmodels:... loaded (optional) INFO: > raudio:.... loaded (optional) INFO: DISPLAY: No graphic card set, trying platform-gpu-card INFO: DISPLAY: Failed to open platform-gpu-card, trying card1 INFO: DISPLAY: Failed to open graphic card1, trying card0 INFO: DISPLAY: Selected DRM connector mode 800x600 (800x600p@60) INFO: DISPLAY: Upscaling required: Screen size (800x450) smaller than display size (800x600) INFO: DISPLAY: Device initialized successfully INFO: > Display size: 800 x 600 INFO: > Screen size: 800 x 450 INFO: > Render size: 800 x 450 INFO: > Viewport offsets: 0, 150 INFO: GL: Supported extensions count: 52 INFO: GL: OpenGL device information: INFO: > Vendor: Broadcom INFO: > Renderer: VC4 V3D 2.1 INFO: > Version: OpenGL ES 2.0 Mesa 20.3.5 INFO: > GLSL: OpenGL ES GLSL ES 1.0.16 INFO: GL: VAO extension detected, VAO functions loaded successfully INFO: GL: NPOT textures extension detected, full NPOT textures supported INFO: GL: ETC1 compressed textures supported INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps) INFO: TEXTURE: [ID 1] Default texture loaded successfully INFO: SHADER: [ID 1] Vertex shader compiled successfully INFO: SHADER: [ID 2] Fragment shader compiled successfully INFO: SHADER: [ID 3] Program shader loaded successfully INFO: SHADER: [ID 3] Default shader loaded successfully INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU) INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU) INFO: RLGL: Default OpenGL state initialized successfully INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps) INFO: FONT: Default font loaded successfully (224 glyphs) WARNING: RPI: Failed to open Gamepad device, no gamepad available WARNING: RPI: Failed to change keyboard mode, an SSH keyboard is probably used INFO: TIMER: Target time per frame: 16.667 milliseconds INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU) INFO: SHADER: [ID 3] Default shader unloaded successfully INFO: TEXTURE: [ID 1] Default texture unloaded successfully INFO: Window closed successfully

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 4.5 is around 8 months old now. Since then, a substancial amount of changes and fixes were issued to PLATFORM_DRM. Please test it with the 5.0 release or the current master branch.

@raysan5
Copy link
Owner

raysan5 commented Nov 27, 2023

I'm closing this issue, it seems it refers to an old raylib version.

@raysan5 raysan5 closed this as completed Nov 27, 2023
@larry104
Copy link
Author

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
INFO: Initializing raylib 5.1-dev
INFO: Platform backend: NATIVE DRM
INFO: Supported raylib modules:
INFO: > rcore:..... loaded (mandatory)
INFO: > rlgl:...... loaded (mandatory)
INFO: > rshapes:... loaded (optional)
INFO: > rtextures:. loaded (optional)
INFO: > rtext:..... loaded (optional)
INFO: > rmodels:... loaded (optional)
INFO: > raudio:.... loaded (optional)
INFO: DISPLAY: No graphic card set, trying platform-gpu-card
INFO: DISPLAY: Failed to open platform-gpu-card, trying card1
INFO: DISPLAY: Failed to open graphic card1, trying card0
INFO: DISPLAY: Selected DRM connector mode 800x600 (800x600p@60)
INFO: DISPLAY: Upscaling required: Screen size (800x450) smaller than display size (800x600)
INFO: DISPLAY: Device initialized successfully
INFO: > Display size: 800 x 600
INFO: > Screen size: 800 x 450
INFO: > Render size: 800 x 450
INFO: > Viewport offsets: 0, 150
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorWidth() not implemented on target platform
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorHeight() not implemented on target platform
WARNING: SetWindowPosition() not available on target platform
INFO: GL: Supported extensions count: 52
INFO: GL: OpenGL device information:
INFO: > Vendor: Broadcom
INFO: > Renderer: VC4 V3D 2.1
INFO: > Version: OpenGL ES 2.0 Mesa 20.3.5
INFO: > GLSL: OpenGL ES GLSL ES 1.0.16
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: ETC1 compressed textures supported
INFO: RPI: Opening keyboard device: /dev/input/event2
WARNING: RPI: Failed to open Gamepad device, no gamepad available
WARNING: RPI: Failed to change keyboard mode, an SSH keyboard is probably used
INFO: PLATFORM: DRM: Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: KEY_BACKSPACE
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 I can't reproduce the issue. Tested it again right now and it's working correctly for me:

img

@larry104
Copy link
Author

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

@larry104
Copy link
Author

larry104 commented Nov 27, 2023

Keyboard is set correctly ...
cat /etc/default/keyboard
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 I'm using en (english), US (United States), UTF-8, everything stock from the Raspberry OS image. However, I'm accessing it directly.

If you're accessing it through SSH, then the keyboard handling is done by exclusively by ProcessKeyboard() (L1304), that's the part you mentioned previously (#3569 (comment)). And there, just for SSH, it's missing quite a lot of keys (specially the key cluster from the issue).

To have those on SSH you'd have to add them probably around at L1389-L1390 with another else if. But note that there's a lot more keys missing from the full enum (L564-L679), so it would be just a partial fix.

Side-note: I'm really not sure if the SSH input was ever meant to be actually fully supported, or just some shortcut for basic testing. @raysan5

@larry104
Copy link
Author

I connected a keyboard to the RPi, rebooted and tested again ... still same issue. Is there any compile flag needed other than
set(PLATFORM DRM)?

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 My exact steps here:

  1. Downloaded current master branch (811abcb) from the git repository, then:
~$ unzip raylib-master.zip
[...]
~$ cd raylib-master/src/
~$ make PLATFORM=PLATFORM_DRM
[...]
  1. Replaced the content of raylib-master/examples/core/core_basic_window.c with:
#include "raylib.h"

int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {
        
        if (IsKeyPressed(KEY_INSERT)) { TraceLog(LOG_INFO, "KEY_INSERT"); }
        if (IsKeyPressed(KEY_DELETE)) { TraceLog(LOG_INFO, "KEY_DELETE"); }
        if (IsKeyPressed(KEY_HOME)) { TraceLog(LOG_INFO, "KEY_HOME"); }
        if (IsKeyPressed(KEY_END)) { TraceLog(LOG_INFO, "KEY_END"); }
        if (IsKeyPressed(KEY_PAGE_UP)) { TraceLog(LOG_INFO, "KEY_PAGE_UP"); }
        if (IsKeyPressed(KEY_PAGE_DOWN)) { TraceLog(LOG_INFO, "KEY_PAGE_DOWN"); }

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}
  1. Then compiled and tested it with:
~$ cd ../examples/
~$ make PLATFORM=PLATFORM_DRM core/core_basic_window
[...]
~$ cd core/
~$ ./core_basic_window
[...]

Edit: formatting.

@larry104
Copy link
Author

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

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 I really don't know what could be causing that issue. Perhaps try another keyboard just to be sure?

@larry104
Copy link
Author

I just tried a different keyboard ... same exact issue ... and I added a control key BACKSPACE which works
the INFO message shows also correctly
INFO RPI: Opening keyboard device: /dev/input/event1

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 I honestly have no idea why that's happening. Here are my full logs:

user@pi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye
user@pi:~ $ cat /etc/default/keyboard 
XKBMODEL=pc105
XKBLAYOUT=us
XKBVARIANT=intl
XKBOPTIONS=
BACKSPACE=guess
user@pi:~ $ cd raylib-master/examples/core/
user@pi:~/raylib-master/examples/core $ ./core_basic_window 
INFO: Initializing raylib 5.1-dev
INFO: Platform backend: NATIVE DRM
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: No graphic card set, trying platform-gpu-card
INFO: DISPLAY: Failed to open platform-gpu-card, trying card1
INFO: DISPLAY: Failed to open graphic card1, trying card0
INFO: DISPLAY: Selected DRM connector mode 800x600 (800x600p@60)
INFO: DISPLAY: Upscaling required: Screen size (800x450) smaller than display size (800x600)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 800 x 600
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 150
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorWidth() not implemented on target platform
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorHeight() not implemented on target platform
WARNING: SetWindowPosition() not available on target platform
INFO: GL: Supported extensions count: 52
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Broadcom
INFO:     > Renderer: VC4 V3D 2.1
INFO:     > Version:  OpenGL ES 2.0 Mesa 20.3.5
INFO:     > GLSL:     OpenGL ES GLSL ES 1.0.16
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: ETC1 compressed textures supported
INFO: RPI: Opening input device: /dev/input/event4 (mouse )
INFO: RPI: Opening keyboard device: /dev/input/event1
WARNING: RPI: Failed to open Gamepad device, no gamepad available
INFO: PLATFORM: DRM: Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: KEY_INSERT
INFO: KEY_DELETE
INFO: KEY_HOME
INFO: KEY_END
INFO: KEY_PAGE_UP
INFO: KEY_PAGE_DOWN
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully

@larry104
Copy link
Author

larry104 commented Nov 27, 2023

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.

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 Sure thing. The keyboard polling for PLATFORM_DRM direct input happens on PollKeyboardEvents() (L1682) which is called by PollInputEvents() (L563).

Wild guess: try changing 255 to 512 or to MAX_KEYBOARD_KEYS at L1701.

Edit: editing.

@raysan5
Copy link
Owner

raysan5 commented Nov 27, 2023

@larry104 are you running PLATFORM_DRM in native mode, right? I mean, without any windowing system/desktop.

@larry104
Copy link
Author

larry104 commented Nov 27, 2023

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

while (read(fd, &event, sizeof(event)) == (int)sizeof(event))

Meaning no log messages inside the while loop but directly before the while there are log messages getting printed

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 Sorry, not sure I understand. I was able to log inside it:

img1
img2

@larry104
Copy link
Author

larry104 commented Nov 27, 2023

In my caser there are no prints happening ... platform.keyboardFd is 8. read() returns always -1

IMG_5479

@ghost
Copy link

ghost commented Nov 27, 2023

@larry104 Did exactly like your print and was able to print it:

img1
img2

@raysan5
Copy link
Owner

raysan5 commented Nov 27, 2023

Side-note: I'm really not sure if the SSH input was ever meant to be actually fully supported, or just some shortcut for basic testing.

@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 PollKeyboardEvents() is actually called? I'm afraid some printf-debugging is required on your side...

@larry104
Copy link
Author

Yes, PollKeyboardEvents() is called but

while (read(fd, &event, sizeof(event)) == (int)sizeof(event))

returns always -1 so it never enters the while loop

@raysan5
Copy link
Owner

raysan5 commented Nov 27, 2023

@larry104 could it be related to some kind of security reason? did you try running the example as root?

@larry104
Copy link
Author

I tried as root no difference ... what I don't understand why other keys work just these 6 not ... that is all really strange

@larry104
Copy link
Author

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?

@ghost
Copy link

ghost commented Nov 28, 2023

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.

@larry104
Copy link
Author

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 ...

@ghost
Copy link

ghost commented Nov 28, 2023

@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 SUPPORT_SSH_KEYBOARD_RPI disabled?

Edit: while recompiling raylib, could you please post the output so I can see the errors/warnings?

@raysan5
Copy link
Owner

raysan5 commented Nov 28, 2023

this is a really strange issue...

@larry104
Copy link
Author

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.

@ghost
Copy link

ghost commented Nov 28, 2023

@larry104 I'm going to reflash my Raspberry Pi right now. I'll use this exact image: 2023-05-03-raspios-bullseye-armhf.img.xz. I'll report back in a few minutes.

@ghost
Copy link

ghost commented Nov 29, 2023

@larry104 This was exactly what I did (with as much detail as possible):

Model: Raspberry Pi 3 Model B 1.2 (Raspberry Pi 2015)

MicroSD: Sandisk Ultra 16GB Class-10 MicroSD HC I

Keyboard: Corsair Strafe RGB Cherry Mx Silent

OS: Raspberry Pi OS (Legacy) with desktop
Release date: May 3rd 2023
System: 32-bit
Kernel version: 6.1
Debian version: 11 (bullseye)
Size: 872MB
Show SHA256 file integrity hash: 38a66ed777a1f4e4c07f7dcb2b2feadfda4503d5e139f675758e0e91d34ed75f
  1. On my host PC (Linux Mint 21.1 64-bit), downloaded the Raspberry Pi OS image from https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-legacy to my home folder, then did this:
~$ ls *.img.xz
2023-05-03-raspios-bullseye-armhf.img.x

~$ unxz 2023-05-03-raspios-bullseye-armhf.img.xz

~$ ls *.img
2023-05-03-raspios-bullseye-armhf.img

~$ lsblk | grep mmc
mmcblk0        179:0    0  14,8G  0 disk
└─mmcblk0p1    179:1    0  14,8G  0 part

~$ sudo dd bs=4M if=./2023-05-03-raspios-bullseye-armhf.img of=/dev/mmcblk0 conv=fsync
988+0 records in
988+0 records out
4143972352 bytes (4,1 GB, 3,9 GiB) copied, 441,902 s, 9,4 MB/s

~$ lsblk | grep mmc
mmcblk0        179:0    0  14,8G  0 disk
├─mmcblk0p1    179:1    0   256M  0 part
└─mmcblk0p2    179:2    0   3,6G  0 part
  1. Moved the MicroSD from my host PC to the Raspberry Pi.
  2. Powered the Raspberry Pi.
  3. On its first boot it automatically resized.
  4. It also automatically generated SSH keys.
  5. Then it automatically rebooted.
  6. On the welcome screen I clicked Next.
  7. On the next screen I selected Country, Language, Timezone, [x] Use english language, [x] use US keyboard, then clicked Next.
  8. On the next screen I filled user as username, then a password, then confirmed the password, then clicked Next.
  9. On the next screen I kept reduce the size of the desktop as off/disabled, then clicked Next.
  10. On the next screen I selected/connected to my wifi, then clicked Next.
  11. On the next screen that was about update software I clicked Skip.
  12. On the next screen that was setup complete, I clicked Restart.
  13. Then it rebooted.
  14. After the reboot, I opened the installed Chromium Web Browser.
  15. Opened https://github.com/raysan5/raylib
  16. Downloaded the current master branch zip.
  17. Opened a terminal and did the following:
user@raspberrypi:~ $ sudo apt-get update
Get:1 http://archive.raspberrypi.org/debian bullseye InRelease [23.6 kB]       
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye InRelease [15.0 kB]
Get:3 http://archive.raspberrypi.org/debian bullseye/main armhf Packages [313 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf Packages [13.2 MB]
Get:5 http://raspbian.raspberrypi.org/raspbian bullseye/non-free armhf Packages [106 kB]
Fetched 13.7 MB in 35s (390 kB/s)                                                                                                        
Reading package lists... Done
N: Repository 'http://archive.raspberrypi.org/debian bullseye InRelease' changed its 'Suite' value from 'stable' to 'oldstable'
N: Repository 'http://raspbian.raspberrypi.org/raspbian bullseye InRelease' changed its 'Suite' value from 'stable' to 'oldstable'

user@raspberrypi:~ $ sudo apt-get install libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfuse2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  libdrm-etnaviv1 libdrm-exynos1 libdrm-freedreno1 libdrm-tegra0 libegl-dev libgl-dev libgles-dev libglvnd-dev libglx-dev libopengl-dev libopengl0
  libpthread-stubs0-dev libx11-6 libx11-dev libx11-xcb1 libxau-dev libxcb1-dev libxdmcp-dev x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  libx11-doc libxcb-doc
The following NEW packages will be installed:
  libdrm-dev libdrm-etnaviv1 libdrm-exynos1 libdrm-freedreno1 libdrm-tegra0 libegl-dev libegl1-mesa-dev libgbm-dev libgl-dev libgles-dev libgles2-mesa-dev
  libglvnd-dev libglx-dev libopengl-dev libopengl0 libpthread-stubs0-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev x11proto-dev xorg-sgml-doctools
  xtrans-dev
The following packages will be upgraded:
  libx11-6 libx11-xcb1
2 upgraded, 23 newly installed, 0 to remove and 153 not upgraded.
Need to get 3,286 kB of archives.
After this operation, 9,048 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.raspberrypi.org/debian bullseye/main armhf libegl1-mesa-dev armhf 20.3.5-1+rpt5+rpi1 [54.4 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libdrm-freedreno1 armhf 2.4.104-1+rpi1 [26.9 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libdrm-exynos1 armhf 2.4.104-1+rpi1 [20.6 kB]
Get:4 http://archive.raspberrypi.org/debian bullseye/main armhf libgbm-dev armhf 20.3.5-1+rpt5+rpi1 [56.6 kB]          
Get:5 http://archive.raspberrypi.org/debian bullseye/main armhf libgles2-mesa-dev armhf 20.3.5-1+rpt5+rpi1 [53.0 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libdrm-tegra0 armhf 2.4.104-1+rpi1 [16.3 kB]
Get:7 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libdrm-etnaviv1 armhf 2.4.104-1+rpi1 [20.8 kB]
Get:8 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libdrm-dev armhf 2.4.104-1+rpi1 [149 kB]
Get:9 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libx11-6 armhf 2:1.7.2-1+deb11u2 [706 kB]
Get:11 http://raspbian.[...]/raspbian bullseye/main armhf xorg-sgml-doctools all 1:1.11-1.1 [22.1 kB]
Get:12 http://raspbian.[...]/raspbian bullseye/main armhf x11proto-dev all 2020.1-1 [594 kB]                                                 
Get:13 http://raspbian.[...]/raspbian bullseye/main armhf libxau-dev armhf 1:1.0.9-1 [22.3 kB]                                                        
Get:14 http://raspbian.[...]/raspbian bullseye/main armhf libxdmcp-dev armhf 1:1.1.2-3 [40.9 kB]                                                      
Get:15 http://raspbian.[...]/raspbian bullseye/main armhf xtrans-dev all 1.4.0-1 [98.7 kB]                                                            
Get:16 http://raspbian.[...]/raspbian bullseye/main armhf libpthread-stubs0-dev armhf 0.4-1 [5,344 B]                                                 
Get:17 http://raspbian.[...]/raspbian bullseye/main armhf libxcb1-dev armhf 1.14-3 [171 kB]                                                           
Get:19 http://raspbian.[...]/raspbian bullseye/main armhf libglx-dev armhf 1.3.2-1 [16.3 kB]                                                          
Get:10 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libx11-xcb1 armhf 2:1.7.2-1+deb11u2 [203 kB]                                             
Get:20 http://raspbian.[...]/raspbian bullseye/main armhf libgl-dev armhf 1.3.2-1 [100 kB]                                                            
Get:18 http://raspbian.raspberrypi.org/raspbian bullseye/main armhf libx11-dev armhf 2:1.7.2-1+deb11u2 [779 kB]                                              
Get:21 http://raspbian.[...]/raspbian bullseye/main armhf libegl-dev armhf 1.3.2-1 [19.6 kB]                                                          
Get:22 http://raspbian.[...]/raspbian bullseye/main armhf libgles-dev armhf 1.3.2-1 [50.3 kB]                                                         
Get:23 http://raspbian.[...]/raspbian bullseye/main armhf libopengl0 armhf 1.3.2-1 [38.8 kB]                                                          
Get:24 http://raspbian.[...]/raspbian bullseye/main armhf libopengl-dev armhf 1.3.2-1 [5,876 B]                                                       
Get:25 http://raspbian.[...]/raspbian bullseye/main armhf libglvnd-dev armhf 1.3.2-1 [13.9 kB]                                                        
Fetched 3,286 kB in 14s (241 kB/s)                                                                                                                           
Reading changelogs... Done
Selecting previously unselected package libdrm-freedreno1:armhf.
(Reading database ... 106529 files and directories currently installed.)
Preparing to unpack .../00-libdrm-freedreno1_2.4.104-1+rpi1_armhf.deb ...
Unpacking libdrm-freedreno1:armhf (2.4.104-1+rpi1) ...
Selecting previously unselected package libdrm-exynos1:armhf.
Preparing to unpack .../01-libdrm-exynos1_2.4.104-1+rpi1_armhf.deb ...
Unpacking libdrm-exynos1:armhf (2.4.104-1+rpi1) ...
Selecting previously unselected package libdrm-tegra0:armhf.
Preparing to unpack .../02-libdrm-tegra0_2.4.104-1+rpi1_armhf.deb ...
Unpacking libdrm-tegra0:armhf (2.4.104-1+rpi1) ...
Selecting previously unselected package libdrm-etnaviv1:armhf.
Preparing to unpack .../03-libdrm-etnaviv1_2.4.104-1+rpi1_armhf.deb ...
Unpacking libdrm-etnaviv1:armhf (2.4.104-1+rpi1) ...
Selecting previously unselected package libdrm-dev:armhf.
Preparing to unpack .../04-libdrm-dev_2.4.104-1+rpi1_armhf.deb ...
Unpacking libdrm-dev:armhf (2.4.104-1+rpi1) ...
Preparing to unpack .../05-libx11-6_2%3a1.7.2-1+deb11u2_armhf.deb ...
Unpacking libx11-6:armhf (2:1.7.2-1+deb11u2) over (2:1.7.2-1) ...
Preparing to unpack .../06-libx11-xcb1_2%3a1.7.2-1+deb11u2_armhf.deb ...
Unpacking libx11-xcb1:armhf (2:1.7.2-1+deb11u2) over (2:1.7.2-1) ...
Selecting previously unselected package xorg-sgml-doctools.
Preparing to unpack .../07-xorg-sgml-doctools_1%3a1.11-1.1_all.deb ...
Unpacking xorg-sgml-doctools (1:1.11-1.1) ...
Selecting previously unselected package x11proto-dev.
Preparing to unpack .../08-x11proto-dev_2020.1-1_all.deb ...
Unpacking x11proto-dev (2020.1-1) ...
Selecting previously unselected package libxau-dev:armhf.
Preparing to unpack .../09-libxau-dev_1%3a1.0.9-1_armhf.deb ...
Unpacking libxau-dev:armhf (1:1.0.9-1) ...
Selecting previously unselected package libxdmcp-dev:armhf.
Preparing to unpack .../10-libxdmcp-dev_1%3a1.1.2-3_armhf.deb ...
Unpacking libxdmcp-dev:armhf (1:1.1.2-3) ...
Selecting previously unselected package xtrans-dev.
Preparing to unpack .../11-xtrans-dev_1.4.0-1_all.deb ...
Unpacking xtrans-dev (1.4.0-1) ...
Selecting previously unselected package libpthread-stubs0-dev:armhf.
Preparing to unpack .../12-libpthread-stubs0-dev_0.4-1_armhf.deb ...
Unpacking libpthread-stubs0-dev:armhf (0.4-1) ...
Selecting previously unselected package libxcb1-dev:armhf.
Preparing to unpack .../13-libxcb1-dev_1.14-3_armhf.deb ...
Unpacking libxcb1-dev:armhf (1.14-3) ...
Selecting previously unselected package libx11-dev:armhf.
Preparing to unpack .../14-libx11-dev_2%3a1.7.2-1+deb11u2_armhf.deb ...
Unpacking libx11-dev:armhf (2:1.7.2-1+deb11u2) ...
Selecting previously unselected package libglx-dev:armhf.
Preparing to unpack .../15-libglx-dev_1.3.2-1_armhf.deb ...
Unpacking libglx-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libgl-dev:armhf.
Preparing to unpack .../16-libgl-dev_1.3.2-1_armhf.deb ...
Unpacking libgl-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libegl-dev:armhf.
Preparing to unpack .../17-libegl-dev_1.3.2-1_armhf.deb ...
Unpacking libegl-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libgles-dev:armhf.
Preparing to unpack .../18-libgles-dev_1.3.2-1_armhf.deb ...
Unpacking libgles-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libopengl0:armhf.
Preparing to unpack .../19-libopengl0_1.3.2-1_armhf.deb ...
Unpacking libopengl0:armhf (1.3.2-1) ...
Selecting previously unselected package libopengl-dev:armhf.
Preparing to unpack .../20-libopengl-dev_1.3.2-1_armhf.deb ...
Unpacking libopengl-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libglvnd-dev:armhf.
Preparing to unpack .../21-libglvnd-dev_1.3.2-1_armhf.deb ...
Unpacking libglvnd-dev:armhf (1.3.2-1) ...
Selecting previously unselected package libegl1-mesa-dev:armhf.
Preparing to unpack .../22-libegl1-mesa-dev_20.3.5-1+rpt5+rpi1_armhf.deb ...
Unpacking libegl1-mesa-dev:armhf (20.3.5-1+rpt5+rpi1) ...
Selecting previously unselected package libgbm-dev:armhf.
Preparing to unpack .../23-libgbm-dev_20.3.5-1+rpt5+rpi1_armhf.deb ...
Unpacking libgbm-dev:armhf (20.3.5-1+rpt5+rpi1) ...
Selecting previously unselected package libgles2-mesa-dev:armhf.
Preparing to unpack .../24-libgles2-mesa-dev_20.3.5-1+rpt5+rpi1_armhf.deb ...
Unpacking libgles2-mesa-dev:armhf (20.3.5-1+rpt5+rpi1) ...
Setting up libdrm-etnaviv1:armhf (2.4.104-1+rpi1) ...
Setting up libpthread-stubs0-dev:armhf (0.4-1) ...
Setting up libgbm-dev:armhf (20.3.5-1+rpt5+rpi1) ...
Setting up libopengl0:armhf (1.3.2-1) ...
Setting up xtrans-dev (1.4.0-1) ...
Setting up libdrm-freedreno1:armhf (2.4.104-1+rpi1) ...
Setting up libdrm-tegra0:armhf (2.4.104-1+rpi1) ...
Setting up libx11-6:armhf (2:1.7.2-1+deb11u2) ...
Setting up xorg-sgml-doctools (1:1.11-1.1) ...
Setting up libopengl-dev:armhf (1.3.2-1) ...
Setting up libdrm-exynos1:armhf (2.4.104-1+rpi1) ...
Setting up libx11-xcb1:armhf (2:1.7.2-1+deb11u2) ...
Setting up libdrm-dev:armhf (2.4.104-1+rpi1) ...
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u5) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for sgml-base (1.30) ...
Setting up x11proto-dev (2020.1-1) ...
Setting up libxau-dev:armhf (1:1.0.9-1) ...
Setting up libxdmcp-dev:armhf (1:1.1.2-3) ...
Setting up libxcb1-dev:armhf (1.14-3) ...
Setting up libx11-dev:armhf (2:1.7.2-1+deb11u2) ...
Setting up libglx-dev:armhf (1.3.2-1) ...
Setting up libgl-dev:armhf (1.3.2-1) ...
Setting up libegl-dev:armhf (1.3.2-1) ...
Setting up libgles-dev:armhf (1.3.2-1) ...
Setting up libglvnd-dev:armhf (1.3.2-1) ...
Setting up libegl1-mesa-dev:armhf (20.3.5-1+rpt5+rpi1) ...
Setting up libgles2-mesa-dev:armhf (20.3.5-1+rpt5+rpi1) ...

user@raspberrypi:~ $ cd Downloads/
user@raspberrypi:~/Downloads $ unzip raylib-master.zip
[...]

user@raspberrypi:~/Downloads $ cd raylib-master/src/

user@raspberrypi:~/Downloads/raylib-master/src $ make PLATFORM=PLATFORM_DRM
gcc -c rcore.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
In file included from rcore.c:491:
platforms/rcore_drm.c:1749:14: warning: ‘EventThread’ defined but not used [-Wunused-function]
 1749 | static void *EventThread(void *arg)
      |              ^~~~~~~~~~~
gcc -c rshapes.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
gcc -c rtextures.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
In file included from rtextures.c:216:
external/stb_image_resize2.h:2866:14: warning: ‘stbir__support_zero’ defined but not used [-Wunused-function]
 2866 | static float stbir__support_zero(float s, void * user_data)
      |              ^~~~~~~~~~~~~~~~~~~
gcc -c rtext.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
gcc -c utils.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
gcc -c rmodels.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
gcc -c raudio.c -Wall -D_GNU_SOURCE -DPLATFORM_DRM -DGRAPHICS_API_OPENGL_ES2 -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing  -std=c99 -fPIC -DEGL_NO_X11 -Werror=implicit-function-declaration -I.  -I/usr/include/libdrm
ar rcs ../src/libraylib.a rcore.o rshapes.o rtextures.o rtext.o utils.o rmodels.o raudio.o
raylib static library generated (libraylib.a) in ../src!

user@raspberrypi:~/Downloads/raylib-master/src $ cd ../examples/
user@raspberrypi:~/Downloads/raylib-master/examples $ vim.tiny core/core_basic_window.c
user@raspberrypi:~/Downloads/raylib-master/examples $ cat core/core_basic_window.c
#include "raylib.h"

int main(void) {
    InitWindow(800, 450, "test");
    SetTargetFPS(60);
    while (!WindowShouldClose()) {
        
        if (IsKeyPressed(KEY_INSERT)) { TraceLog(LOG_INFO, "KEY_INSERT"); }
        if (IsKeyPressed(KEY_DELETE)) { TraceLog(LOG_INFO, "KEY_DELETE"); }
        if (IsKeyPressed(KEY_HOME)) { TraceLog(LOG_INFO, "KEY_HOME"); }
        if (IsKeyPressed(KEY_END)) { TraceLog(LOG_INFO, "KEY_END"); }
        if (IsKeyPressed(KEY_PAGE_UP)) { TraceLog(LOG_INFO, "KEY_PAGE_UP"); }
        if (IsKeyPressed(KEY_PAGE_DOWN)) { TraceLog(LOG_INFO, "KEY_PAGE_DOWN"); }

        BeginDrawing();
        ClearBackground(RAYWHITE);
        EndDrawing();
    }
    CloseWindow();
    return 0;
}

user@raspberrypi:~/Downloads/raylib-master/examples $ make PLATFORM=PLATFORM_DRM core/core_basic_window
gcc -o core/core_basic_window core/core_basic_window.c -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result -O2 -std=gnu99 -DEGL_NO_X11 -I. -I../src -I../src/external -I/usr/local/include -I/usr/include/libdrm -L. -L../src -L../src -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic -DPLATFORM_DRM
  1. Closed all windows.
  2. Ctrl Alt F1 to leave X11 and get to TTY1.
  3. Then did the following:
user@raspberrypi:~ $ cd Downloads/raylib-master/examples/core/
user@raspberrypi:~/Downloads/raylib-master/examples/core/ $ ./core_basic_window > OUTPUT
  1. On the test screen pressed Insert, Delete, Home, End, PgUp, Pgdn, Esc in this exact order.
  2. Then did this:
user@raspberrypi:~/Downloads/raylib-master/examples/core/ $ cat OUTPUT
INFO: Initializing raylib 5.1-dev
INFO: Platform backend: NATIVE DRM
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: No graphic card set, trying platform-gpu-card
INFO: DISPLAY: Failed to open platform-gpu-card, trying card1
INFO: DISPLAY: Failed to open graphic card1, trying card0
INFO: DISPLAY: Selected DRM connector mode 800x600 (800x600p@60)
INFO: DISPLAY: Upscaling required: Screen size (800x450) smaller than display size (800x600)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 800 x 600
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 150
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorWidth() not implemented on target platform
WARNING: GetCurrentMonitor() not implemented on target platform
WARNING: GetMonitorHeight() not implemented on target platform
WARNING: SetWindowPosition() not available on target platform
INFO: GL: Supported extensions count: 52
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Broadcom
INFO:     > Renderer: VC4 V3D 2.1
INFO:     > Version:  OpenGL ES 2.0 Mesa 20.3.5
INFO:     > GLSL:     OpenGL ES GLSL ES 1.0.16
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: ETC1 compressed textures supported
INFO: RPI: Opening input device: /dev/input/event3 (mouse )
INFO: RPI: Opening keyboard device: /dev/input/event0
WARNING: RPI: Failed to open Gamepad device, no gamepad available
INFO: PLATFORM: DRM: Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: KEY_INSERT
INFO: KEY_DELETE
INFO: KEY_HOME
INFO: KEY_END
INFO: KEY_PAGE_UP
INFO: KEY_PAGE_DOWN
INFO: TEXTURE: [ID 2] Unloaded texture data from VRAM (GPU)
INFO: SHADER: [ID 3] Default shader unloaded successfully
INFO: TEXTURE: [ID 1] Default texture unloaded successfully
INFO: Window closed successfully
  1. Then I repeated everything (reflashed the Raspberry Pi and all that) with another keyboard: CMStorm Quickfire Stealth Cherry Mx Brown.
  2. Everything worked perfectly for me both times. I have absolutely no idea what could be going wrong there.

@larry104
Copy link
Author

Here might be the difference, can you try booting directly into CLI instead compiling it from X11?

@ghost
Copy link

ghost commented Nov 29, 2023

@larry104 Tested right now. It's also working correctly for me:

img

@larry104
Copy link
Author

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 ;-)

@ghost
Copy link

ghost commented Nov 29, 2023

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.

@larry104 Maybe that's the problem. Can you flash it some other way?

@larry104
Copy link
Author

I still used the Imager but didn't make any changes to settings ... flashing just done ...

@ghost
Copy link

ghost commented Nov 29, 2023

@larry104 Meanwhile I reflashed my Raspberry Pi with https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-32-bit

OS: Raspberry Pi OS Lite
Release date: October 10th 2023
System: 32-bit
Kernel version: 6.1
Debian version: 12 (bookworm)
Size: 568MB
Show SHA256 file integrity hash: 1f8a646b375b198ef9f48c940889ac9f61744d1c1105b36c578313edbc81a339

No X11 or anything, just CLI.

  1. Did the standard first boot and CLI basic setup.
  2. Connected to the wifi via raspi-conf.
  3. Then the usual sudo apt-get update.
  4. Then sudo apt-get install libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev
  5. Copied the raylib-master.zip and the test.c with a pendrive to the Raspberry Pi.
  6. Unzip the raylib-master.zip. Copied the test.c to examples/core/core_basic_window.c.
  7. Then make PLATFORM=PLATFORM_DRM.
  8. Then cd ../examples/ and make PLATFORM=PLAFTORM_DRM core/core_basic_window
  9. And it still worked for me:

img

@larry104
Copy link
Author

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.

@ghost
Copy link

ghost commented Nov 29, 2023

@larry104 I was able to replicate the issue!

Found a keyboard here that doesn't work (a Microsoft Confort Curve Keyboard 3000).

Edit:
My Corsair Strafe RGB Cherry Mx Silent works.
My CMStorm Quickfire Stealth Cherry Mx Brown works.
My Logitech K310 works.
My Dell SK-8115 works.
But the Microsoft Confort Curve Keyboard 3000 doesn't work. Same issue you're having.
Ok, now I have something to work with.

@larry104
Copy link
Author

larry104 commented Nov 29, 2023

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.

@ghost
Copy link

ghost commented Nov 29, 2023

@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

img1

Once you unbind the duplicated:

img2

Then everything works as expected:

img3

So, definitely not a raylib issue. :)

Edit: typo.

@larry104
Copy link
Author

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 ;-)

@ghost
Copy link

ghost commented Nov 29, 2023

@larry104 No problem. 👍

Haha, for sure. :)

@raysan5
Copy link
Owner

raysan5 commented Nov 29, 2023

@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)?

@michaelfiber
Copy link
Contributor

@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.

@raysan5
Copy link
Owner

raysan5 commented Nov 29, 2023

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... ;)

@larry104
Copy link
Author

larry104 commented Nov 29, 2023

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

@ghost
Copy link

ghost commented Nov 29, 2023

I think it's actually quite common with any keyboards that have any kind of nonstandard keys on them.

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.

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.

That would be an excellent solution.

@larry104
Copy link
Author

@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.

@ghost
Copy link

ghost commented Nov 29, 2023

@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. 👍

@jamesl-github
Copy link

this seems like a different issue with the 3000, but could it be related ?

[quote]
Windows 10 forces my Microsoft Comfort Curve 3000 keyboard to sleep after 5 seconds of inactivity, and it thinks keeping a key pressed down is inactivity. If it sleeps the keyboard with key down, the key is stuck, it doesn't register the key-up event, unless you press and release it again.

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".
[/quote]

https://www.youtube.com/watch?v=-DQC6-k72Rw

@ghost
Copy link

ghost commented Nov 30, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: DRM/RPI DRM/Raspberry Pi platform
Projects
None yet
Development

No branches or pull requests

4 participants