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

Problem with german keyboardlayout #558

Closed
Retro1968 opened this issue Dec 16, 2019 · 39 comments
Closed

Problem with german keyboardlayout #558

Retro1968 opened this issue Dec 16, 2019 · 39 comments

Comments

@Retro1968
Copy link

Retro1968 commented Dec 16, 2019

Hello i use amiberry 3.0.11 on a Raspberry Pi 4. RetroPie 4.5.3 is installed manually on Raspbian Buster.

I use AmigaOS 3.1.4.1 with Kickrom 3.1.4.

Here i use the german keyboardlayout. In this there is an error while using amiberry. On a real Amiga 1200 this problem is not there: If i press the "#" key i get a backslash. There is no keycombination in the german keyboardlayout that results in the output of "#".

I need the "#" for the command: protect dh0:#? +wd all

Kind Regards
Retro1968

@midwan midwan self-assigned this Dec 16, 2019
@midwan
Copy link
Collaborator

midwan commented Dec 16, 2019

@Retro1968
Thanks for opening a separate issue regarding this :)

Could you please confirm if the german layout looks like the photo below?
s-l1600

What happens if you press Shift-3 in Amiga emulation?

@Retro1968
Copy link
Author

Retro1968 commented Dec 16, 2019

Pressing Shift-3 in amiberry puts "§" out, like it should be on the german keyboardlayout.
This is my Amiga 1200 with german keyboardlayout. Here the "#" - key works.
Click on the picture to see it in the right sight.

IMG_20191216_145640313

@midwan
Copy link
Collaborator

midwan commented Dec 16, 2019

Thanks for confirming.
Amiberry uses Scancodes for keyboard mapping, like WinUAE does. But some keys map differently in different keyboards, and this seems to be a known problem for WinUAE as well (check relevant thread here: http://eab.abime.net/showthread.php?t=97416).

Could you try running AmigaTestKit and try the keyboard tests there?
Take a photo of what key is registered when you press the # key, that might help look into what keycode gets sent.

@Retro1968
Copy link
Author

IMG_20191216_154542095

@midwan
Copy link
Collaborator

midwan commented Dec 16, 2019

@Retro1968
And to try and recreate this, what should I do on the host level? Just change my keyboard input preferences to German?

@Retro1968
Copy link
Author

Just load the german keyboard layout in Preferences->Input in Workbench 3.1.4.1. Then press "#" where it would be on the german keyboard. But i can test it for you too.

@Retro1968
Copy link
Author

It seems that the solution is no easy task.

@solskogen
Copy link
Collaborator

On the norwegian layout I have to press alt-gr+shift+3 - does that work for you?

@Retro1968
Copy link
Author

Yes that works. Thx.
Certainly its only a workout and no solution for this error.

@midwan
Copy link
Collaborator

midwan commented Nov 7, 2020

@Retro1968
Have you tried a German keymap, like the one included with WinUAE (under "Amiga Programs" in the archive)?

From the description I found there:

uae_german     (help also on Standard UAE (i hope ?))
This is a German keymap to reach @\~{[]} with ALT-GR like windows
Copy it in devs/keymaps and choose it in the keymap-prefs

@midwan
Copy link
Collaborator

midwan commented Nov 7, 2020

And there seems to be a newer one included there as well:
german_KeyMap_new.zip

There's a readme included in the archive, test with this and see if it helps?

@midwan midwan added the question label Nov 7, 2020
@midwan
Copy link
Collaborator

midwan commented Dec 9, 2020

I'm working on adding some support for the German layout, based on what I saw in WinUAE itself.
It's a bit ugly (it tries to detect the current keyboard layout, and guess what language you're using from that), but perhaps it will help some people. :)

@Retro1968
Copy link
Author

And there seems to be a newer one included there as well:
german_KeyMap_new.zip

There's a readme included in the archive, test with this and see if it helps?

RPi 4B, RetroPie 4.6.6, amiberry 3.3, AmigaOS 3.1.4.1.

Sorry for my late feedback. I was able to successfully test the keymap "WinUAE_D" from the file "german_KeyMap_new.zip" in amiberry. The # key now works correctly.

Thank you
Retro1968 :-)

@midwan
Copy link
Collaborator

midwan commented Dec 10, 2020

@Retro1968
Thanks for confirming!
I'll keep this open for a little more, so we can test the other approach I'm working on also, that will detect the keyboard layout and adapt accordingly.

@Retro1968
Copy link
Author

There is a problem. I am currently testing. The keymap setting was gone after a restart and # no longer worked. So I set and saved WinUAE_D again. After that, AmigaOS 3.1.4.1 crashes.

@Retro1968
Copy link
Author

OK. Here is the result. WinUAE_D corrects the # key. But if you start AmigaOS 3.1.4.1 again it crashes. So WinUAE_D cannot be used for amiberry.

@Retro1968
Copy link
Author

Retro1968 commented Dec 10, 2020

Raspberry Pi 4B, Manjaro Linux, amiberry 3.3 64-bit, Amiga OS 3.1.4.1.

Surprisingly, WinUAE_D works great with the 64 bit version of amiberry. I'll see if the 32-bit version crash is due to JIT.

@Retro1968
Copy link
Author

Yep.... its JIT that crashes WINUAE_D under amiberry 32-Bit.

@Retro1968
Copy link
Author

@Retro1968
Have you tried a German keymap, like the one included with WinUAE (under "Amiga Programs" in the archive)?

From the description I found there:

uae_german     (help also on Standard UAE (i hope ?))
This is a German keymap to reach @\~{[]} with ALT-GR like windows
Copy it in devs/keymaps and choose it in the keymap-prefs

The keymap "UAE_German" does not solve the error with the # key.

midwan added a commit that referenced this issue Feb 7, 2021
This is a hack coming from WinUAE, hopefully gets the job done however
@midwan
Copy link
Collaborator

midwan commented Feb 7, 2021

@Retro1968
Could you kindly test after the latest commit above?
I've implemented WinUAE's approach to automatically try and detect a German keyboard layout. If detected, then it should translate the keys for you automatically. I can't really test it here, so I'm curious if it works as expected or not.

@Retro1968
Copy link
Author

The "#" key now works. Thank you. :-)

@midwan
Copy link
Collaborator

midwan commented Feb 7, 2021

Awesome, thanks for confirming!

@Retro1968
Copy link
Author

Thank you for your great work, buddy. :-)

@agreppin
Copy link

Hello, reopening this as I have that problem.

With any Keymap, when pressing the key 0x2B, the blank key next to Return, I get Shift-Alt-3 key sequence.

AmigaTestKit screenshot:

Image

Using: amiberry 7.0.0, ubuntu 24.04

@giantclambake
Copy link

key 0x2B is NUMBERSIGN ..aka: the hash (#) key -- this isn't actually available on an Amiga keyboard (and with a US keymap, this would be Shift+3 on that kbd to get #...which is not recognized) ... odd one ...

@agreppin
Copy link

agreppin commented Jan 31, 2025

please see the pics of the A1200 above, this key is # on german kb and $ on swiss, etc, that key shouldn't be converted to some key combo.

investigating that case with gdb:
found scancode = 32 in inputdevice_translatekeycode when pressing that key

but ... SDL_scancode.h says:

    SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return
                                  *   key on ISO keyboards and at the right end
                                  *   of the QWERTY row on ANSI keyboards.
                                  *   Produces REVERSE SOLIDUS (backslash) and
                                  *   VERTICAL LINE in a US layout, REVERSE
                                  *   SOLIDUS and VERTICAL LINE in a UK Mac
                                  *   layout, NUMBER SIGN and TILDE in a UK
                                  *   Windows layout, DOLLAR SIGN and POUND SIGN
                                  *   in a Swiss German layout, NUMBER SIGN and
                                  *   APOSTROPHE in a German layout, GRAVE
                                  *   ACCENT and POUND SIGN in a French Mac
                                  *   layout, and ASTERISK and MICRO SIGN in a
                                  *   French Windows layout.
                                  */

Edit 1:
I understand that key does not exist on US, non-ISO keyboard ... but the point is that I can't have a $ sign in the CLI (anywhere in fact) 😂. Also tested WinUAE in Windows and no problem there.

@giantclambake
Copy link

Yeah, that looks like it ... midwan will have to dig into it =)

@agreppin
Copy link

the scancode is modified in function keyhack() ! introduced in PR #91

	if (!keyboard_german)
		return scancode;

	if (scancode == SDL_SCANCODE_BACKSLASH)
	{
...
  1. keyboard_german should be renamed keyboard_ISO
  2. or maybe invert that logic since I think that detecting an US keyboard vs rest of the world is easier

@midwan midwan reopened this Jan 31, 2025
@midwan
Copy link
Collaborator

midwan commented Jan 31, 2025

@agreppin
That's weird, this was tested and confirmed to be working when it was implemented, as you can see above.
I don't think anything changed in that area recently.

@midwan
Copy link
Collaborator

midwan commented Jan 31, 2025

The whole thing is rather ugly, perhaps it can be improved.
The detection mechanism is this:

keyboard_german = 0;
	if (SDL_GetKeyFromScancode(SDL_SCANCODE_Y) == SDLK_z)
		keyboard_german = 1;

Which matches the A1200 photo seen above. How does your keyboard layout look like?

@agreppin
Copy link

agreppin commented Jan 31, 2025

still investigating here ...

for sure, keyboard_german is true for all QWERTZ keyboard layouts, that is central europe.

my keyboard layout is Swiss (French)

bypassing that german hack reveal another problem down to the retroarch stuff

Edit 1:
suggestion: if scancode SDL_SCANCODE_BACKSLASH doesn't exists on ANSI keyboard, it should be translated to Amiga RAWKEY 2C, so that cover a majority.

Edit 2:
when bypassing that german hack, I get Amiga RAWKEY 0D

Edit 3: link to pictures with RAWKEYs

Edit 4: rectification, it's Amiga RAWKEY 2B, not 2C

@agreppin
Copy link

getting closer with those 2 changes:

diff --git a/src/osdep/amiberry_input.cpp b/src/osdep/amiberry_input.cpp
index 63f449bd..f8fcda2c 100644
--- a/src/osdep/amiberry_input.cpp
+++ b/src/osdep/amiberry_input.cpp
@@ -365,7 +365,7 @@ int keyhack (const int scancode, const int pressed, const int num)
                }
        }
 
-       if (!keyboard_german)
+       if (1 || !keyboard_german)
                return scancode;
 
        if (scancode == SDL_SCANCODE_BACKSLASH)
diff --git a/src/osdep/keyboard.cpp b/src/osdep/keyboard.cpp
index 4bd72c2c..3110a2f2 100644
--- a/src/osdep/keyboard.cpp
+++ b/src/osdep/keyboard.cpp
@@ -120,7 +120,7 @@ static struct uae_input_device_kbr_default keytrans_amiga[] = {
        { SDL_SCANCODE_APOSTROPHE, INPUTEVENT_KEY_SINGLEQUOTE },
        { SDL_SCANCODE_GRAVE, INPUTEVENT_KEY_BACKQUOTE },
 
-       { SDL_SCANCODE_BACKSLASH, INPUTEVENT_KEY_BACKSLASH },
+       { SDL_SCANCODE_BACKSLASH, INPUTEVENT_KEY_2B },
        { SDL_SCANCODE_COMMA, INPUTEVENT_KEY_COMMA },
        { SDL_SCANCODE_PERIOD, INPUTEVENT_KEY_PERIOD },
        { SDL_SCANCODE_SLASH, INPUTEVENT_KEY_DIV },

Status:

  • KEY 2B alone
  • KEY 2B SHIFT
  • KEY 2B SHIFT+ALT

SHIFT+KEY_2B generates not event ATM.

@midwan
Copy link
Collaborator

midwan commented Jan 31, 2025

WinUAE uses F11 for the Backslash key, which I always found weird (and that's the reason it's mapped to ...Backslash in Amiberry).

Besides that, WinUAE has the "keyboard_german" disabled completely, but I'm not sure how that translates regarding the German layout (as mentioned in the original post of this issue, above).

The problem here seems to be that Amiberry detects your layout as "german", due to it being QWERTZ, and enables the hack that changes those special scancodes on the fly. I think we either need a better detection for that hack (e.g. it's not enough that the layout is QWERTZ), or go the WinUAE way, removing that part completely and changing the mapping of Backslash.

However, in WinUAE's case, Backslash is not mapped to INPUTEVENT_KEY_2B but rather to INPUTEVENT_KEY_NUMBERSIGN in the keytrans_amiga array. It's mapped to 2B on the keytrans_pc1 array. Then there's a config option (input_keyboard_type) that controls which mapping will be used (only two options exist, amiga or pc).

How have you set things up in WinUAE to make it work? How was the host OS configured regarding this?
I'm guessing it's not enough to only have the relevant keyboard with the extra keys.

@agreppin
Copy link

agreppin commented Jan 31, 2025

the Amiga RAWKEY codes

#define AK_BACKSLASH 0x0D
#define AK_QUOTE 0x2A
#define AK_NUMBERSIGN 0x2B

0x0D is the key to the left of backspace on Amiga keyboard 2
0x2B/NUMBERSIGN is misleading us, this is SDL_SCANCODE_BACKSLASH (see SDL_scancode.h big comment)

On US ANSI, the backslash key, just above the enter key should also be SDL_SCANCODE_BACKSLASH but should be mapped to Amiga RAWKEY 0x0D, the dilemma for PC105 keyboards.

  1. if ANSI keyboard: SDL_SCANCODE_BACKSLASH -> 0x0D
  2. if ISO keyboard: SDL_SCANCODE_BACKSLASH -> 0x2B

Handling those is then made on Amiga side with keymaps.

WinUAE has no trace of SDL_SCANCODE_BACKSLASH in it's source code.

PS:
AmigaTestKit screen cap with my mod:
Image

@midwan
Copy link
Collaborator

midwan commented Jan 31, 2025

WinUAE does not use SDL2, but DirectInput

@agreppin
Copy link

Here is a little program I use for testing on Amiga side: ktest.tar.gz
ktest just dumps RAWKEY code + current keymap translation on the CLI/Shell

PS:
github doen't allow to attach .lha or even .c files

midwan added a commit that referenced this issue Feb 1, 2025
…558)

- Map the keys exactly like WinUAE (F11 for Backslash)
- Disable german keyboard hack
@midwan
Copy link
Collaborator

midwan commented Feb 1, 2025

With the commit above, the mapping is now identical to that of WinUAE. This includes disabling the "german keyboard" hack as well.

@agreppin / @Retro1968 kindly test after these changes and let me know if anything broke?

@agreppin
Copy link

agreppin commented Feb 1, 2025

That solution is fine !
F11 is key 0x0D on Amiga
SDL_SCANCODE_BACKSLASH / NUMBERSIGN is 0x2B
perfecto.

I can't test it fully as my Ubuntu 24.04 SDL2 refuses to act on some keys today 🐛.
I made a simple test using SDL2 to confirm it's not related to Amiberry.
Considering Upgrade to SDL3 #1618 as the same test is ok with it.

🐛 the 3 keys bottom left of Return

@midwan
Copy link
Collaborator

midwan commented Feb 2, 2025

Closing this again for now then, we'll see how it goes.

@midwan midwan closed this as completed Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants