Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
On Fri, May 13, 2022 at 01:26:34AM +, Emmanuel Dreyfus wrote: > I am also a bit puzzled that in our historical code, ANSI ADB > scancode 42, which is supposed to be backslash (the key is between > backspace and return), is converted into USB scancode 50, which > is non US hash. I did not change it, but here again, input from > someone that has access to that keyboard would help. I committed the code with a comment about that, thank for Michael van Elst for making it clear: USB scancodes 49 and 50 have the same translation in most encodings. Exceptions are pt and hu (and uk for altgr). I retained the wrong but usual value. The JIS case is more troublesome: ADB scancode 93 used to be emulated as USB scan code 100, which in backslash/bar in our jp encoding. The change is supposed to turn it into USB scancode 137, which should be the Yen but is backslash/bar in jp encoding. At least it does not change. ADB scancode 94 used to be emulated as USB scan code 45, which is minus/equal in our jp encoding. The change is supposed to turn it into USB scan code 135, which should be RO but is backslash/underscore in jp encoding. I disabled the autoconfiguration to JIS layout until someone can test it. One need to sysctl -w machdep.adbkbd0.emulate_usb=3 in order to enable it. Feecback welcome. -- Emmanuel Dreyfus m...@netbsd.org
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
On Fri, 13 May 2022 13:19:07 +0200 Rhialto wrote: > On Thu 12 May 2022 at 22:54:44 -0400, Michael wrote: > > Emmanuel Dreyfus wrote: > > > > > I am also a bit puzzled that in our historical code, ANSI ADB > > > scancode 42, which is supposed to be backslash (the key is between > > > backspace and return), is converted into USB scancode 50, which > > > is non US hash. I did not change it, but here again, input from > > > someone that has access to that keyboard would help. > > > > It's there because hidkbdmap.c has > > KC(50), KS_backslash, KS_bar, > > Could that have something to do with UK layout? It's from Static const keysym_t hidkbd_keydesc_us[] = { > The key near ENTER (but not as described between enter and backspace) > is #/~. See e.g. > https://en.wikipedia.org/wiki/British_and_American_keyboards The only UK keyboard I have here ( a 1993 IBM model M... ) has a backslash / pipe key between left shift and z. When I wrote adb_usb_map.c I just tried to get something that would produce (as close as possible to) the same keys when translated again through the USB map as the ADB map. Since all my ADB keyboard are US variants a good bit of it is untested, at least by me. have fun Michael
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
Emmanuel Dreyfus wrote: >On Fri, May 13, 2022 at 01:44:31PM +0100, Robert Swindells wrote: >> I have a UK keyboard, can try something with it. > >Just to make sure: my change is only for ADB keyboards. Yes, you even put "ADB" in the thread title.
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
On Fri, May 13, 2022 at 01:44:31PM +0100, Robert Swindells wrote: > I have a UK keyboard, can try something with it. Just to make sure: my change is only for ADB keyboards. -- Emmanuel Dreyfus m...@netbsd.org
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
Rhialto wrote: >On Thu 12 May 2022 at 22:54:44 -0400, Michael wrote: >> Emmanuel Dreyfus wrote: >> >> > I am also a bit puzzled that in our historical code, ANSI ADB >> > scancode 42, which is supposed to be backslash (the key is between >> > backspace and return), is converted into USB scancode 50, which >> > is non US hash. I did not change it, but here again, input from >> > someone that has access to that keyboard would help. >> >> It's there because hidkbdmap.c has >> KC(50), KS_backslash, KS_bar, > >Could that have something to do with UK layout? The key near ENTER >(but not as described between enter and backspace) is #/~. I have a UK keyboard, can try something with it.
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
On Thu 12 May 2022 at 22:54:44 -0400, Michael wrote: > Emmanuel Dreyfus wrote: > > > I am also a bit puzzled that in our historical code, ANSI ADB > > scancode 42, which is supposed to be backslash (the key is between > > backspace and return), is converted into USB scancode 50, which > > is non US hash. I did not change it, but here again, input from > > someone that has access to that keyboard would help. > > It's there because hidkbdmap.c has > KC(50), KS_backslash, KS_bar, Could that have something to do with UK layout? The key near ENTER (but not as described between enter and backspace) is #/~. See e.g. https://en.wikipedia.org/wiki/British_and_American_keyboards -Olaf. -- ___ "Buying carbon credits is a bit like a serial killer paying someone else to \X/ have kids to make his activity cost neutral." -The BOFHfalu.nl@rhialto signature.asc Description: PGP signature
Re: [PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
Hello, On Fri, 13 May 2022 01:26:34 + Emmanuel Dreyfus wrote: > I am also a bit puzzled that in our historical code, ANSI ADB > scancode 42, which is supposed to be backslash (the key is between > backspace and return), is converted into USB scancode 50, which > is non US hash. I did not change it, but here again, input from > someone that has access to that keyboard would help. It's there because hidkbdmap.c has KC(50), KS_backslash, KS_bar, have fun Michael
[PATCH] ISO abd JIS for ADB (Was: two keys with same keycode on ADB)
Here is my proposed patch to proprely handle ISO and JIS keyboard layouts for ADB. Wee change sysctl machdep.adbkbdX.emulate_usb from boolean to int: 0: no emulation (like with false previously) 1: ANSI emulation (like with true previously) 2: ISO emulation 3: JIS emulation The value is automatically set from keyboard handler id but can be modified afterwards. I have been able to test ISO, but input would be welcome from someone that has access from a japanese keyboard. I am also a bit puzzled that in our historical code, ANSI ADB scancode 42, which is supposed to be backslash (the key is between backspace and return), is converted into USB scancode 50, which is non US hash. I did not change it, but here again, input from someone that has access to that keyboard would help. -- Emmanuel Dreyfus m...@netbsd.org Index: sys/dev/adb/adb_kbd.c === RCS file: /cvsroot/src/sys/dev/adb/adb_kbd.c,v retrieving revision 1.32 diff -U4 -r1.32 adb_kbd.c --- sys/dev/adb/adb_kbd.c 7 Aug 2021 16:19:09 - 1.32 +++ sys/dev/adb/adb_kbd.c 13 May 2022 01:10:05 - @@ -92,9 +92,9 @@ uint32_t sc_timestamp; #ifdef WSDISPLAY_COMPAT_RAWKBD int sc_rawkbd; #endif - bool sc_emul_usb; + int sc_emul_usb; bool sc_power_dbg; uint32_t sc_power; uint8_t sc_buffer[16]; @@ -234,9 +234,9 @@ * needs it */ sc->sc_power = 0x; sc->sc_timestamp = 0; - sc->sc_emul_usb = FALSE; + sc->sc_emul_usb = ADB_EMUL_USB_NONE; #ifdef ADBKBD_POWER_DDB sc->sc_power_dbg = TRUE; #else sc->sc_power_dbg = FALSE; @@ -385,10 +385,56 @@ sc->sc_wskbddev = config_found(self, &a, wskbddevprint, CFARGS(.iattr = "wskbddev")); #ifdef ADBKBD_EMUL_USB - sc->sc_emul_usb = TRUE; - wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb, 128); + /* Values from Linux's drivers/macintosh/adbhud.c */ +switch (sc->sc_adbdev->handler_id) { + case ADB_ISOKBD: /* FALLTHROUGH */ + case ADB_EXTISOKBD: /* FALLTHROUGH */ + case 0x07: /* FALLTHROUGH */ + case ADB_ISOKBDII: /* FALLTHROUGH */ + case ADB_PBISOKBD: /* FALLTHROUGH */ + case ADB_ADJISOKBD: /* FALLTHROUGH */ + case ADB_PBEXTISOKBD: /* FALLTHROUGH */ + case 0x19: /* FALLTHROUGH */ + case 0x1d: /* FALLTHROUGH */ + case 0xc1: /* FALLTHROUGH */ + case ADB_IBOOKKBD: /* FALLTHROUGH */ + case 0xc7: + sc->sc_emul_usb = ADB_EMUL_USB_ISO; + wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_iso, 128); + break; + case ADB_ADJJAPKBD: /* FALLTHROUGH */ + case ADB_PBEXTJAPKBD: /* FALLTHROUGH */ + case ADB_JPKBDII: /* FALLTHROUGH */ + case 0x17: /* FALLTHROUGH */ + case 0x1a: /* FALLTHROUGH */ + case ADB_PBJPKBD: /* FALLTHROUGH */ + case 0xc2: /* FALLTHROUGH */ + case 0xc5: /* FALLTHROUGH */ + case 0xc8: /* FALLTHROUGH */ + case 0xc9: + sc->sc_emul_usb = ADB_EMUL_USB_JIS; + wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_jis, 128); + break; + case ADB_STDKBD: /* FALLTHROUGH */ + case ADB_EXTKBD: /* FALLTHROUGH */ + case 0x03: /* FALLTHROUGH */ + case 0x06: /* FALLTHROUGH */ + case ADB_KBDII: /* FALLTHROUGH */ + case ADB_PBKBD: /* FALLTHROUGH */ + case ADB_ADJKBD: /* FALLTHROUGH */ + case ADB_PBEXTKBD: /* FALLTHROUGH */ + case ADB_DESIGNKBD: /* FALLTHROUGH */ + case 0x1c: /* FALLTHROUGH */ + case 0xc0: /* FALLTHROUGH */ + case ADB_PBG3KBD: /* FALLTHROUGH */ + case 0xc6: /* FALLTHROUGH */ + default: /* default to ANSI for unknown values */ + sc->sc_emul_usb = ADB_EMUL_USB_ANSI; + wskbd_set_evtrans(sc->sc_wskbddev, adb_to_usb_ansi, 128); + break; + } #endif /* ADBKBD_EMUL_USB */ #if NWSMOUSE > 0 /* attach the mouse device */ @@ -632,9 +678,9 @@ switch (cmd) { case WSKBDIO_GTYPE: - if (sc->sc_emul_usb) { + if (sc->sc_emul_usb != ADB_EMUL_USB_NONE) { *(int *)data = WSKBD_TYPE_USB; } else { *(int *)data = WSKBD_TYPE_ADB; } @@ -797,23 +843,37 @@ { struct sysctlnode node = *rnode; struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data; const int *np = newp; - bool reg; + int reg; DPRINTF("%s\n", __func__); reg = sc->sc_emul_usb; if (np) { /* we're asked to write */ node.sysctl_data = ® if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) { - sc->sc_emul_usb = *(bool *)node.sysctl_data; - if (sc->sc_emul_usb) { -wskbd_set_evtrans(sc->sc_wskbddev, -adb_to_usb, 128); - } else { + sc->sc_emul_usb = *(int *)node.sysctl_data; + switch (sc->sc_emul_usb) { + case ADB_EMUL_USB_NONE: wskbd_set_evtrans(sc->sc_wskbddev, NULL, 0); +break; + case ADB_EMUL_USB_ANSI: +wskbd_set_evtrans(sc->sc_wskbddev, +adb_to_usb_ansi, 128); +break; + case ADB_EMUL_USB_ISO: +wskbd_set_evtrans(sc->sc_wskbddev, +adb_to_usb_iso, 128); +break; + case ADB_EMUL_USB_JIS: +wskbd_set_evtrans(sc->sc_wskbddev, +adb_to_usb_jis, 128); +break; + default: +return EINVAL; +break; } return 0; } return EINVAL; @@ -864,9 +924,9 @@ CTL_MACHDEP, CTL_CREATE, CTL_EOL); ret = sysctl_createv(NULL,