From: tmk Date: Mon, 4 Jan 2021 13:00:08 +0000 (+0900) Subject: adb_usb: Add Apple ISO key support X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=0518db68957e697beb70bfbe9f5642a9a4f93c65;p=max%2Ftmk_keyboard.git adb_usb: Add Apple ISO key support Scan code 2A of Apple ISO is translated to 70 and mapped to NUHS. And rewrite UNIMAP_ADB() based on ADB scan codes. --- diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index cf57295f..c3b3ab8b 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -479,9 +479,9 @@ uint8_t matrix_scan(void) * ------------- --------- * Key ANSI ISO ANSI ISO * --------------------------------------------- - * *a 0x32 0x0A 0x35 0x35 - * *b ---- 0x32 ---- 0x64 - * *c 0x2A 0x2A 0x31 0x31(or 0x32) + * *a 0x32 0x0A GRAVE GRAVE + * *b ---- 0x32 ---- NUBS + * *c 0x2A 0x70 BSLASH NUHS */ if (is_iso_layout) { if ((key0 & 0x7F) == 0x32) { @@ -489,6 +489,9 @@ uint8_t matrix_scan(void) } else if ((key0 & 0x7F) == 0x0A) { key0 = (key0 & 0x80) | 0x32; } + if ((key0 & 0x7F) == 0x2A) { + key0 = (key0 & 0x80) | 0x70; + } } register_key(key0); if (key1 != 0xFF) // key1 is 0xFF when no second key. diff --git a/converter/adb_usb/unimap_common.h b/converter/adb_usb/unimap_common.h index 71b69f05..58729fc3 100644 --- a/converter/adb_usb/unimap_common.h +++ b/converter/adb_usb/unimap_common.h @@ -24,44 +24,62 @@ along with this program. If not, see . /* ADB Keyboard unified layout * ,---. .---------------. ,---------------. ,---------------. ,-----------. ,---. - * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr| + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |F24| * `---' `---------------' `---------------' `---------------' `-----------' `---' * ,-----------------------------------------------------------. ,-----------. ,---------------. ,---. * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| |VUp| * |-----------------------------------------------------------| |-----------| |---------------| |---| - * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| |VDn| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| -| |VDn| * |-----------------------------------------------------------| `-----------' |---------------| |---| - * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| |Mut| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #| Ret| | 4| 5| 6| +| |Mut| * |-----------------------------------------------------------| ,---. |---------------| `---' - * |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |Shif| <| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | * |-----------------------------------------------------------| ,-----------. |-----------|Ent| ,---. - * |Ctrl |Opt |Gui | Space |Gui* |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | |Ply| + * |Ctrl |Opt |Gui | Space |Gui* |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | |F13| + * `-----------------------------------------------------------' `-----------' `---------------' `---' + * + * ,---. .---------------. ,---------------. ,---------------. ,-----------. ,---. + * | 35| | 7A| 78| 63| 76| | 60| 61| 62| 64| | 65| 6D| 67| 6F| | 69| 6B| 71| | 7F| + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. ,---. + * |*32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33 | | 72| 73| 74| | 47| 51| 4B| 43| | 48| + * |-----------------------------------------------------------| |-----------| |---------------| |---| + * | 30 | 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A | | 75| 77| 79| | 59| 5B| 5C| 4E| | 49| + * |-----------------------------------------------------------| `-----------' |---------------| |---| + * | 39 | 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27|*70| 24 | | 56| 57| 58| 45| | 4A| + * |-----------------------------------------------------------| ,---. |---------------| `---' + * | 38 |*0A| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 7B | | 3E| | 53| 54| 55| | + * |-----------------------------------------------------------| ,-----------. |-----------| 4C| ,---. + * | 36 | 3A | 37 | 31 | 37 | 7C | 7D | | 3B| 3D| 3C| | 52 | 41| | | 42| * `-----------------------------------------------------------' `-----------' `---------------' `---' * NOTE: Not-extended ADB keyboards have no discrimination between left and right modifiers. * Use left ones for mapping. Right modifier always sends same code as left one. * Apple Extended Keyboard can discriminate the modifiers except for Command(GUI) key. + * For Apple ISO keyboard scan code 0A and 32 are swapped and scan code 2A is translated to 70. */ #define UNIMAP_ADB( \ - K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, K73, \ - K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E, K2A, K49,K4A,K4B, K53,K54,K55,K56, K02, \ - K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, K01, \ - K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,K66, K03, \ - K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K7D, K52, K59,K5A,K5B,K58, \ - K78,K7A,K7B, K2C, K7E,K7C, K50,K51,K4F, K62,K63, K68 \ + K35, K7A,K78,K63,K76,K60,K61,K62,K64,K65,K6D,K67,K6F, K69,K6B,K71, K7F, \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18, K33, K72,K73,K74, K47,K51,K4B,K43, K48, \ + K30,K0C,K0D,K0E,K0F,K10,K11,K20,K22,K1F,K23,K21,K1E, K2A, K75,K77,K79, K59,K5B,K5C,K4E, K49, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K70,K24, K56,K57,K58,K45, K4A, \ + K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55,K4C, \ + K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52,K41, K42 \ ) UNIMAP( \ - K68, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, K73, \ - K29, K3A, K3B, K3C, K3D, K3E, K3F, K40, K41, K42, K43, K44, K45, K46, K47, K48, K01, K02, K03, \ - K35, K1E, K1F, K20, K21, K22, K23, K24, K25, K26, K27, K2D, K2E, JYEN,K2A, K49, K4A, K4B, K53, K54, K55, K56, \ - K2B, K14, K1A, K08, K15, K17, K1C, K18, K0C, K12, K13, K2F, K30, K31, K4C, K4D, K4E, K5F, K60, K61, K57, \ - K39, K04, K16, K07, K09, K0A, K0B, K0D, K0E, K0F, K33, K34, K32, K28, K5C, K5D, K5E, K66, \ - K79, K64, K1D, K1B, K06, K19, K05, K11, K10, K36, K37, K38, RO, K7D, K52, K59, K5A, K5B, K58, \ - K78, K7B, K7A, MHEN, K2C, HENK,KANA,K7E, RGUI,APP, K7C, K50, K51, K4F, K62, K63, PEQL \ + K42,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, K7F, \ + K35, K7A,K78,K63,K76,K60,K61,K62,K64,K65,K6D,K67,K6F, K69,K6B,K71, K49,K48,K4A, \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,NO, K33, K72,K73,K74, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K10,K11,K20,K22,K1F,K23,K21,K1E, K2A, K75,K77,K79, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K70,K24, K56,K57,K58,K45, \ + K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, NO, K7B, K3E, K53,K54,K55,K4C, \ + K36,K3A,K37,NO, K31, NO, NO, K7C,NO, NO, K7D, K3B,K3D,K3C, K52,K41,NO \ ) // http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c // http://opensource.apple.com//source/IOHIDFamily/IOHIDFamily-701.20.10/IOHIDFamily/Cosmo_USB2ADB.c // http://m0115.web.fc2.com/m0115.jpg +// Not used: UNIMAP_{F14, F15, F21, F22, KP_EQUAL} +// Not mapped: 0x46, 0x4D, 0x6C const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { // Position(unimap) ADB scan code(matrix) // --------------------------------------------- @@ -78,7 +96,7 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { { UNIMAP_C, // 0x08 UNIMAP_V, // 0x09 - UNIMAP_NONUS_BSLASH, // 0x0A + UNIMAP_NONUS_BSLASH, // 0x0A '<'(0x32) on ISO keyboard UNIMAP_B, // 0x0B UNIMAP_Q, // 0x0C UNIMAP_W, // 0x0D @@ -128,9 +146,9 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { { UNIMAP_TAB, // 0x30 UNIMAP_SPACE, // 0x31 - UNIMAP_GRAVE, // 0x32 + UNIMAP_GRAVE, // 0x32 '^'(0x0A) on ISO keyboard UNIMAP_BSPACE, // 0x33 - UNIMAP_KP_ENTER, // 0x34 + UNIMAP_KP_ENTER, // 0x34 dup UNIMAP_ESCAPE, // 0x35 UNIMAP_LCTRL, // 0x36 UNIMAP_LGUI, // 0x37 @@ -150,7 +168,7 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { UNIMAP_KP_DOT, // 0x41 UNIMAP_F13, // 0x42 Mic(Adjustable keyboard) UNIMAP_KP_MINUS, // 0x43 ADB keypad asterisk(top right) - UNIMAP_NO, // 0x44 + UNIMAP_F18, // 0x44 dup UNIMAP_KP_COMMA, // 0x45 ADB keypad plus UNIMAP_NO, // 0x46 UNIMAP_NUMLOCK, // 0x47 @@ -160,10 +178,10 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { UNIMAP_VOLUME_DOWN, // 0x49 Vol Down(Adjustable keyboard) UNIMAP_VOLUME_MUTE, // 0x4A Vol Mute(Adjustable keyboard) UNIMAP_KP_ASTERISK, // 0x4B ADB keypad slash(between equal and asterisk) - UNIMAP_KP_ENTER, // 0x4C + UNIMAP_KP_ENTER, // 0x4C dup UNIMAP_NO, // 0x4D UNIMAP_KP_PLUS, // 0x4E ADB keypad minus - UNIMAP_F18, // 0x4F + UNIMAP_F18, // 0x4F dup }, { UNIMAP_F19, // 0x50 @@ -197,17 +215,17 @@ const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { }, { UNIMAP_HENK, // 0x68 - UNIMAP_PSCREEN, // 0x69 + UNIMAP_PSCREEN, // 0x69 PrintScreen/F13 UNIMAP_F16, // 0x6A - UNIMAP_SCROLLLOCK, // 0x6B + UNIMAP_SCROLLLOCK, // 0x6B ScrollLock/F14 UNIMAP_NO, // 0x6C UNIMAP_F10, // 0x6D UNIMAP_APPLICATION, // 0x6E compose UNIMAP_F12, // 0x6F }, { - UNIMAP_NO, // 0x70 - UNIMAP_PAUSE, // 0x71 + UNIMAP_NONUS_HASH, // 0x70 '#'(0x2A) on ISO keyboard + UNIMAP_PAUSE, // 0x71 Pause/F15 UNIMAP_INSERT, // 0x72 UNIMAP_HOME, // 0x73 UNIMAP_PGUP, // 0x74