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

ADB German Keyboard layout ^ and < reversed (Windows) #35

Closed
DOCaCola opened this issue May 24, 2013 · 28 comments
Closed

ADB German Keyboard layout ^ and < reversed (Windows) #35

DOCaCola opened this issue May 24, 2013 · 28 comments
Labels

Comments

@DOCaCola
Copy link

This is more or less a follow up on the older bug #22 that was fixed in the adb_usb converter.
I have now noticed something else. While these keys work as expected on my mac, They are reversed when the keyboard is plugged in on Windows (M3501 Extended II keyboard).
So when i press the ^ key (left of the 1 key), i get <.
If i press <, i get ^.
I thought it to be some kind of issue with Windows, so i googled and found this site (it is german though), but it might be helpful in analyzing this issue.
He describes some low level patch for the keyboard driver of Mac OS X.
http://snark.de/mac/usbkbpatch/
As it is already in the adb_usb code, he describes the adb keyboard codes as
0x32 <
0x0a ^

but he has an interesting note on the usb codes for these keys:
0x64 ^ (caret - on wintel-usb switched with < (smaller) )
0x35 < (smaller - on wintel-usb switched with ^ (caret) )

Not sure what this means though. But there seems some kind of difference how Mac OS X interpretes these keys.

Switching the ADB code in the keymap.c obviously did the trick, but i guess a better solution exists, since other keyboards do not have this issue.

@tmk
Copy link
Owner

tmk commented May 24, 2013

Hmm,
How does windows keyboard work on Mac? How does apple keyboard work on Windows(Not bootcamp)? Those keys work correctlly?

Actually I want to know what codes German keyboard sends for those keys. Though that'll be difficult or need some hassle...

@DOCaCola
Copy link
Author

yes, a windows keyboard (logitech) connected to my macbook -> keys work correct
apple aluminium keyboard connected to my windows pc -> keys also work correct. no special drivers loaded

if you explain what is required, i will try to help

@DOCaCola
Copy link
Author

i have loaded an usb monitor software on my windows machine
data transmitted from the apple keyboard AND logitech keyboard are both:
<
00 00 64 00 00 00 00 00

and
^
00 00 35 00 00 00 00 00

as expected, when having the adb_usb teensy connected, it behaves the other way round...
now it would be interesting to get this data on mac...

edit: i think i found the issue.....actually i was...
When you plug in a new keyboard to mac, the keyboard setup assistant appears and asks you to press the key right from the left shift key...however i never saw that dialog on my mac..
I just found another site where someone describes this very issue. So if i press the caret key (which is actually the < in adb_usb) the behaviour is switched (like it is wrong now under windows).

Those two keys should be interchanged in adb_usb. Sorry for reporting it wrong in the first place.

The keyboard layout can be reset by deleting the /Library/Preferences/com.apple.keyboardtype.plist file. Then restart. Mac OS X now brings up the keyboard assistant again. With the correct adb_usb keyboard layout, after using this assistant, the keys should also work correct then.

@tmk
Copy link
Owner

tmk commented May 25, 2013

I seemed to be confused about those keys, if I can get them correctlly they should be like following table, right?
ADB ISO(DE) keyboard has different code0A) for key left of 1 from US layout(32). This is very confusing.
I think we should have another KEYMAP macro for ISO in keymap.c.

                                        Code
                    -----------------------------------------------
Key Position        ADB-US      ADB-DE(ISO)        USB
-------------------------------------------------------------------
Left of 1           0x32        0x0A               0x35 Grave
Right of LShift     NONE        0x32               0x64 Non-US \

@tmk tmk closed this as completed May 25, 2013
@DOCaCola
Copy link
Author

i am really 100% sure. As it is now in the keycode.c file it is not correct for the german keyboard. It will work under OS X, but it will turn out wrong on Windows etc.

@tmk
Copy link
Owner

tmk commented Apr 30, 2014

Looks like two solutions can exist.

  1. adb_usb needs ISO keymap macro. US and ISO layout are incompatible due to two keys above.

  2. Or if we are able to know layout(US, ISO or JIS?) with ADB command firmware can handle the two keys especially and we can have one universal keymap. I don't know this command really exists.

French AZERTY has same problem.
http://geekhack.org/index.php?topic=14290.msg1312242#msg1312242

@tmk tmk reopened this Apr 30, 2014
@tmk tmk added the TODO label Apr 30, 2014
@tmk
Copy link
Owner

tmk commented May 1, 2014

OSX can recognize its layout(ANSI, ISO or JIS) automatically for Apple products only so that faithful users doens't need 'Keyboard Setup Assistant' to start using it. Meanwhile third party products including TMK are handled as ANSI layout by default unless user specified its layout in some way.

OSX checks only Apple USB vendor/product ID.(and ADB product ID, probably.) See IOHIDKeyboard::handlerID.
http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-503.1.13/IOHIDFamily/IOHIDKeyboard.cpp

OSX uses ADB scan codes as internal key codes and USB codes(usages) should be converted into ADB codes. This file defines USB-ADB code convert table.
http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-503.1.13/IOHIDFamily/Cosmo_USB2ADB.c

OSX checks only Apple USB vendor/product ID and ADB product ID, probably.(See IOHIDKeyboard::handlerID) And the table is patched when Apple ISO keyboard is using. This circumvents the key swap problem.(See IOHIDKeyboard::deviceType)
http://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-503.1.13/IOHIDFamily/IOHIDKeyboard.cpp

But our keyboard is handled as ANSI layout so we suffer from the key swap problem.

[DELETE]
YOU NEED TO SPECIFY LAYOUT UNLESS YOUR KEYBOARD IS APPLE PRODUCT OR ANSI.
Maybe you can use Keyboard Setup Assistant. This itself is not problem at all.
[/DELETE]

Problem is USB-ADB convert table to support both ISO and ANSI ADB keyboard layouts which are incompatile with eatch other. ANSI uses ADB code 0x32 to register '^'(left of '1') while ISO uses 0x32 for '<'(right of Left Shift) and 0x0A for '^'. How iMate resolves this? Maybe solution 2.

Methinks. Just two cents.

@tmk tmk closed this as completed May 1, 2014
@tmk tmk added the NOTE label May 13, 2014
@tmk
Copy link
Owner

tmk commented May 20, 2014

Use ISO keymap with make KEYMAP=iso to circumvent this problem.

ADB ISO keyboard has weird layout which swaps key on left of 1(_a) and key on right of Shift(_b). We need to use keymap for this ISO layout.

ADB ANSI/ISO Keymapping Note
============================
ANSI
,-----------    ----------.
| *a|  1|  2     =|Backspa|
|-----------    ----------|
|Tab  |  Q|     |  ]|   *c|
|-----------    ----------|
|CapsLo|  A|    '|Return  |
|-----------    ----------|
|Shift   |      Shift     |
`-----------    ----------'

ISO
,-----------    ----------.
| *a|  1|  2     =|Backspa|
|-----------    ----------|
|Tab  |  Q|     |  ]|Retur|
|-----------    -----`    |
|CapsLo|  A|    '| *c|    |
|-----------    ----------|
|Shif| *b|      Shift     |
`-----------    ----------'

ADB Keyboard scan code:
        ADB scan code   USB usage
        -------------   ---------
Key     ANSI    ISO     ANSI    ISO
---------------------------------------------
*a      0x32    0x0A    0x35    0x35
*b      ----    0x32    ----    0x64
*c      0x2A    0x2A    0x31    0x31(or 0x32)


TMK ADB-USB mapping:
ADB     USB(ANSI)   USB(ISO)
---------------------------------
0x32    0x35        0x64
0x0A    ----        0x35
0x2A    0x31        0x31(or 0x32)

argyakrivos added a commit to argyakrivos/tmk_keyboard that referenced this issue May 29, 2014
* upstream/master: (93 commits)
  Add ISO keymap(issue tmk#35) and use new keymap API
  Fix set LED for NKRO keyboard interface
  Unused endpoint of console OUT is commentout'd
  Add Makefiles for TMK converters.
  Fix remotewakeup of PJRC stack(Fix tmk#121)
  Check if LUFA-git really exists(Fix tmk#118)
  NKRO is disable when SET_PROTOCOL(boot)
  Make NKRO deafult when it is available
  Change MCU setting to ATmega32U2
  Fix description of pin usage
  Add LUFA git repository(release 140302)
  Move macro definitions from lufa.c to lufa.h
  Fix 'Shift Parentheses' example
  Change LUFA build options
  Return when ready check loop is timeouted(Fix tmk#115)
  Change PollingIntervalMS to 10ms(Fix tmk#114)
  New macro: ACTION_BACKLIGHT_LEVEL(level)
  Show correct function name for default layer set
  Added Lightsaber FN-layer
  Lightsaber clean ups
  ...
@tmk tmk removed the TODO label Apr 13, 2016
jiexi pushed a commit to jiexi/tmk_keyboard that referenced this issue Apr 28, 2016
@tmk
Copy link
Owner

tmk commented May 10, 2016

I found this post, seems 'Griffin iMate' and 'New Motion uKey' also have similar or worse problem with ISO keyboards.
https://geekhack.org/index.php?topic=4185.msg61270#msg61270

@tmk
Copy link
Owner

tmk commented May 19, 2016

how to determine keyboard layout with handler id.
http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L802

@tmk
Copy link
Owner

tmk commented May 19, 2016

Added auto detection of ISO layout and swap of the problematic scan codes.
f43a2df

I hope this works for ISO keyboards.

@tmk tmk reopened this May 19, 2016
@tmk
Copy link
Owner

tmk commented May 31, 2016

As for this ISO keyboard auto detection test and report from ISO users are required.

Informations like your OS version, keyboard layout setting on OS and etc would be uselful.

@scytho
Copy link

scytho commented Jan 28, 2017

I don’t know if this is still an issue.

I have an AEKII ISO German and use Pins 4 and 5 of a Teensy 2.0 for Data and Power. I didn’t change anything in the tmk code, so it should expect Data and Power on Pins 0 and 1 (in adb_usb/config.h). It works almost perfect with Linux Mint 17.3. Only »problem«: The equal sign on the Numpad generates an accent (»´«). I’d prefer a dot (».«, as alternative to the comma). < and ^ work as expected.

Same with Windows 8.1.

@scytho
Copy link

scytho commented Jan 28, 2017

I changed the code to Pins 4 and 5, now < and ^ are switched. I changed it back to 0 and 1, but the Teensy only would go into bootloops and make the mouse pointer jump. After several tries and with Pins 4 and 5 in config.h it’s working again, < and ^ not switched. Weird.

@scytho
Copy link

scytho commented Jan 28, 2017

After another programming of the Teensy < and ^ were switched again, plugging off and on the AEKII on the Teensy switched them back.

@kuerb
Copy link

kuerb commented Oct 23, 2017

I too have this issue with my German AEKII: NUBS and GRV are switched after programming the micro-controller. Once the keyboard is unplugged they are switched again, to whatever is defined in the keymap.

It seems like the auto detection only works if the keyboard is being programmed.

@tmk
Copy link
Owner

tmk commented Oct 24, 2017

@kuerb yes, you are right. It detects ISO keyboard only once.

Fix and improvement for this is welcomed.

EDIT: ADB conveter checks ISO keyboard only at startup, if you have ISO keyboard you will have to plug it into the converter before pluggin computer.

@egla89
Copy link

egla89 commented Oct 26, 2017

I have the same problem as a previous commentator where the EQUAL key on the numpad, registers as ‘ on an AEK2 iso. Mapped it as iso

@tmk
Copy link
Owner

tmk commented Oct 26, 2017

@egla89 did you try firmware got from keyboard editor?
what is your keyboard layout on your os?

@egla89
Copy link

egla89 commented Oct 27, 2017

I flashed a teensy in my iso-de aek2 with ‘make -f Makefile.teensy KEYMAP=iso‘. Os is macOS 10.13 and I ran the layout recognition (so the < and ^ are in the right spot). Every other key works correctly

@tmk
Copy link
Owner

tmk commented Oct 27, 2017

OK, then, key next to backspace(=) spits out equal correctly?
what character does key next to backspace spit out?

@tmk
Copy link
Owner

tmk commented Oct 27, 2017

And is this pic what you referred as 'iso-de aek2'?
https://deskthority.net/w/images/1/18/AEKII-front.jpg

if not can you post pic of your aek2?

@kuerb
Copy link

kuerb commented Oct 27, 2017

de_iso_aekii

Here is a picture of my German AEKII, which should be the same as the one egla89 is using.

In my own keymap I switched the numpads = key to PEQL. Maybe that's a simple fix for the general iso keymap?!

@tmk
Copy link
Owner

tmk commented Oct 27, 2017

thanks for the pic and it makes sense.
EQL is recognized as ' on german layout and numpad = key is defined as EQLin keymap_iso.c. PEQL may be less confused, in fact unimap_plain.c uses it.

anyway, you can change keymap as you want, there is no universal keymap for everyone.

@egla89
Copy link

egla89 commented Oct 27, 2017

Ok yes that makes sense. I‘ll change my layout accordingly. Thanks a lot!

@tmk
Copy link
Owner

tmk commented Oct 27, 2017

Just for future reference, PEQL is not recognized on Windows and which is reason why some keymap use EQL for numpad '=' instead of PEQL.
#238

@tmk
Copy link
Owner

tmk commented Jun 21, 2019

Open new issue if you have problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants