Page 1 of 1

Raspberry Pi keyboard issue

Posted: Fri Nov 29, 2019 6:01 pm
by Count
I am running Hatari 2.0.0 on my BeePi machine which is a Pi 3B with pre-installed Hatari 2.0.0. I am using a German keyboard and pressing the "<>" key opens Hatari's menu instead of the character being printed. The key is is located next to the left Shift key and I know that it is missing in US layout. I tried several keyboards (each of them with German layout) and the issue is always the same.

Hotkey for opening the menu is RightAlt+F12. This works fine, but I would really like to type "<" and ">" using the designated key. The checkkeys tool shows the correct symbolic code for the key (0x3c=60). Hotkeys without modifiers are not defined.

When running Hatari with "--trace keymap" all key presses are logged to stderr, except the "<>" key. An entry in the keymap file doesn't help either. I could remap Help and Undo to F11 and F12, but remapping 60 has no effect.

Yesterday I got the recent SDL2 source (2.0.10) and compiled the library myself using no configure switches. After that I compiled Hatari 2.0.0 as well as 2.2.1 (also without configure switches), but the problem still remains.

Is it possible that 60 is hard-wired to open the menu?

This issue should also occur using other non-US keyboard layouts.


FYI, the lower left corner of the German layout:

Code: Select all

---------------------------
|Shift  |A  |S  |D  |F  |G
|Lock   |   |   |   |   |
---------------------------
|Shift|>  |Y  |X  |C  |V  |
|     |<  |   |   |   |   |
---------------------------
|Ctrl  |Win |Alt | Space
|      |    |    |
---------------------------

Re: Raspberry Pi keyboard issue

Posted: Fri Nov 29, 2019 10:28 pm
by rudis
Default ROM-Image in Hatari is english EmuTOS. Using German EmuTOS the Keyboard Layout is correct. Tried it right know.

Re: Raspberry Pi keyboard issue

Posted: Sat Nov 30, 2019 4:03 pm
by ThorstenOtto
The problem is caused by SDL2 not providing a default mapping for that key:

https://hg.libsdl.org/SDL/file/b393fb36 ... ard.c#l146

The "less" key on german keyboard gives scancode 100, and the entry in the table for that key is empty.

Aranym has special treatment for that key: https://github.com/aranym/aranym/blob/m ... t.cpp#L533

where 0x60 is the scancode that is send to the Atari.

Edit: there seems to be another bug: when the <sym> member of the event is 0, ShortCut_CheckKeys() returns true, and the Setup Menu pops up.

Re: Raspberry Pi keyboard issue

Posted: Sat Nov 30, 2019 5:37 pm
by Count
That's true, Thorsten. The keyboard event struct contains sym = 0 and scancode = 100. The scancode value is correct, but the mapping is missing. Hatari always assumes the key to be a shortcut if sym = 0 and opens the menu as 0 is no valid shortcut.

For me I could solve that issue by taking a sledgehammer approach:

I added three lines in Keymap_KeyDown() and Keymap_KeyUp() in src/keymap.c after the LOG_TRACE() call.

Code: Select all

if (symkey == 0 && sdlkey->scancode == 100) {
       symkey = sdlkey->sym = '<';
}

Re: Raspberry Pi keyboard issue

Posted: Wed Dec 04, 2019 1:16 am
by ThorstenOtto
Just checked the Hatari sources, and in fact they are doing the same as ARAnyM, mapping the key to atari scancode 0x60. Works for both SDL1 and SDL2 on linux.

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 7:32 am
by thothy
I think the proper fix should be this one:

https://git.tuxfamily.org/hatari/hatari ... 08794e9ae9

Could you please check whether that fixes your issue without your sledgehammer approach, too?

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 12:35 pm
by Count
That patch fixes the issue with the Hatari menu coming up, but the key is not recognized as what it is because the sym value remains 0.

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 12:57 pm
by ThorstenOtto
As already said in the german forum, that must have something to do with your fbcon device. You have to figure out which scancode SDL receives when pressing that key. The X11 device gives SCANCODE_NONUSBACKSLASH for SDL2, or SDLK_LESS for SDL1. I guess this is just a problem of the fbcon settings for german keyboards.

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 2:19 pm
by Count
SDL2 doesn't support the fbcon driver any more. RPI is used instead.

Running the patched hatari with "--trace keymap", these lines are shown when hitting the key:

Code: Select all

key down: sym=0 scan=100 mod=0x0 name=''
key map: sym=0x0 to ST-scan=0xff
key up: sym=0 scan=100 mod=0x0 name=''
Why is sym = 0 while the correct scan code is detected?

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 3:25 pm
by ThorstenOtto
Sym is 0 because SDL's keyboard table does not have an entry for it, as shown in the link above. Nevertheless Hatari should translate that to the correct scancode 0x60 before sending it to Atari.

Edit: at least when you have set the mapping in the config file to use scancodes:

Code: Select all

nKeymapType = 1

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 3:29 pm
by czietz
Well, for starters the default SDL keymap has no entry (= 0) for SDL_SCANCODE_NONUSBACKSLASH:
https://hg.libsdl.org/SDL/file/bc90ce38 ... ard.c#l147

SDL has quite complicated and platform-dependent algorithms to augment the default keymap. Which is why it works for me under Windows, where I get "key down: sym=60 scan=100 mod=0x0 name='<'". However, it seems this fails on your RPi. Since this is not strictly a Hatari issue it might be best discussed in the SDL bugtracker?

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 3:56 pm
by Count
Even changing the 0 in the SDL keymap to SDLK_LESS doesn't change anything of the behavior. And because I need do remap some keys, I cannot use the scancode mode in Hatari.

I think I will keep my sledgehammer. Nevertheless, thank you very much.

Re: Raspberry Pi keyboard issue

Posted: Sun Dec 08, 2019 4:19 pm
by ThorstenOtto
It works for the X11 & windows drivers, because they override the default keymap, depending on what they get from the OS: https://hg.libsdl.org/SDL/file/bc90ce38 ... ard.c#l471 and https://hg.libsdl.org/SDL/file/bc90ce38 ... ard.c#l149

The RPI driver does not do this. So this is an SDL2 bug, specific to the RPI driver (or fbcon in case of SDL1.x)

Re: Raspberry Pi keyboard issue

Posted: Mon Dec 09, 2019 7:58 pm
by Eero Tamminen
Count wrote:Even changing the 0 in the SDL keymap to SDLK_LESS doesn't change anything of the behavior. And because I need do remap some keys, I cannot use the scancode mode in Hatari.
SDL bug tracker is here: https://bugzilla.libsdl.org/

Re: Raspberry Pi keyboard issue

Posted: Tue Dec 10, 2019 7:03 pm
by Count
Eero Tamminen wrote:SDL bug tracker is here: https://bugzilla.libsdl.org/
Thank you. I submitted bug 4895 for that case.

Re: Raspberry Pi keyboard issue

Posted: Wed Dec 11, 2019 12:59 am
by ThorstenOtto
You should mention that this only happens with the frame buffer (RPI) driver, not the X11 driver.