Raspberry Pi keyboard issue

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.2.1

Moderators: simonsunnyboy, thothy, Moderator Team

Post Reply
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Raspberry Pi keyboard issue

Post 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
|      |    |    |
---------------------------
User avatar
rudis
Captain Atari
Captain Atari
Posts: 168
Joined: Mon Feb 14, 2011 9:41 am

Re: Raspberry Pi keyboard issue

Post by rudis »

Default ROM-Image in Hatari is english EmuTOS. Using German EmuTOS the Keyboard Layout is correct. Tried it right know.
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post 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.
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Re: Raspberry Pi keyboard issue

Post 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 = '<';
}
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post 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.
User avatar
thothy
Hatari Developer
Hatari Developer
Posts: 428
Joined: Fri Jul 25, 2003 9:36 am
Location: Germany
Contact:

Re: Raspberry Pi keyboard issue

Post 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?
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Re: Raspberry Pi keyboard issue

Post 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.
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post 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.
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Re: Raspberry Pi keyboard issue

Post 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?
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post 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
czietz
Hardware Guru
Hardware Guru
Posts: 1246
Joined: Tue May 24, 2016 6:47 pm

Re: Raspberry Pi keyboard issue

Post 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?
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Re: Raspberry Pi keyboard issue

Post 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.
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post 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)
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2189
Joined: Sun Jul 31, 2011 1:11 pm

Re: Raspberry Pi keyboard issue

Post 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/
User avatar
Count
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Sep 16, 2017 9:15 am
Location: Germany

Re: Raspberry Pi keyboard issue

Post by Count »

Eero Tamminen wrote:SDL bug tracker is here: https://bugzilla.libsdl.org/
Thank you. I submitted bug 4895 for that case.
ThorstenOtto
Atari God
Atari God
Posts: 1196
Joined: Sun Aug 03, 2014 5:54 pm

Re: Raspberry Pi keyboard issue

Post by ThorstenOtto »

You should mention that this only happens with the frame buffer (RPI) driver, not the X11 driver.
Post Reply

Return to “Hatari”