-
Notifications
You must be signed in to change notification settings - Fork 76
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
Uppercase keys no longer working #264
Comments
Hi @lkesteloot the keyboard and mouse functionality on the later Raspberry Pus definitely needs sorting out. What OS are you using, and are you using the SDL2 system. Sounds like you're using X rather than Wayland. Definitely sounds like a bug if the modifier always return 0 Paddy |
Hi! My current setup:
With (BTW the project is PiSlide, which uses uppercase letters for dangerous operations like quitting and enabling debugging mode.) Thank you for responding! I'm happy to do whatever tests you'd like. |
Hi @lkesteloot I've just had a quick look at this (pi3d.Keyboard) The curses keyboard will only available if pi3d thinks it's running on an older raspberry pi using the libbcm.so graphics driver rather than the newer mesa ones. Line 307 in df0cc84
I think this same issue came up in the past when running pi3d on different platforms and the way round it was to use the import pi3d
DISPLAY = pi3d.Display.create(w=100, h=100, frames_per_second=30)
keyboard = pi3d.Keyboard(use_curses=True)
print(f"actual type of keyboard running here={type(keyboard)}")
shifted = False
caps = False
while DISPLAY.loop_running():
kc = keyboard.read_code()
if len(kc) > 0:
is_char = (type(kc) == str and len(kc) == 1)
if kc == chr(27) or kc == "Escape":
break
if "Shift" in kc:
shifted = True
elif "Caps" in kc:
caps = not caps
elif is_char:
if shifted or caps:
resultant_char = kc.upper()
else:
resultant_char = kc
print(f"{kc} {ord(kc) if is_char else ''} resulting in {resultant_char}")
shifted = False
else:
print(kc) # an non char key other than Shift.. or Caps..
DISPLAY.destroy() |
For the self.KEYBOARD = {}
for k in dir(sdl2): # sift through for key codes
if "SDLK_" in k:
key_num = getattr(sdl2, k)
if type(key_num) == int:
key_code = k.split("_")[-1]
self.KEYBOARD[key_num] = key_code
...
def _update_event(self):
...
self.key_code = self.KEYBOARD[k] SDL has the extra info in the |
I tried your test code from this comment. The type of the class is It didn't show any keys at all! Secondly, if the user holds Shift, then presses the A key twice, the first one is uppercase but the second is lowercase. The keyboard class doesn't pass on releases, so we can't know when the shift key is released. Want me to give it a go to modify the |
Also note that |
Hi, that's a bit weird: the display dimensions disrupt the key reading! As you can probably tell, the code has evolved in a rather nonlinear way as the hardware changed. PLATFORM_PI means early models, with various closed source Broadcom software required and a reasonable probability that no X11 server would be running. The aim of the RPi foundation has been to align themselves with standard Linux so software can be ported with the minimum of low level hacking. Hence later Pi models are identified as PLATFORM_LINUX Also, yes, it would be great if you had the time and inclination to look at the Keyboard code. |
Just unlurking to say that this is a big surprise! ...and also, "I'm still around". I'd help except I don't even have an RPi here, we recently moved to Rouen and our stuff is in storage in Amsterdam. Thanks for all your work on this, Paddy, and come and visit some time! |
I was using v2.22 of pi3d (on RPi 2), and the keyboard's
read()
function was properly returning uppercase letters (shift-A was returning 65). I've upgraded to the latest version (v2.52) and all letters now return the lowercase value (97 for shift-A). The shift key itself returns 0 (as does other modifier keys). I triedread_code()
and it's the same.I checked the sample programs and they all only ever use lowercase commands.
This is on Linux on Raspberry Pi 5, console mode (via xinit). I tried with and without curses.
The text was updated successfully, but these errors were encountered: