diff --git a/converter/ibmpc_usb/config.h b/converter/ibmpc_usb/config.h index 2489d4da..bf61aa6d 100644 --- a/converter/ibmpc_usb/config.h +++ b/converter/ibmpc_usb/config.h @@ -38,6 +38,10 @@ along with this program. If not, see . keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \ ) + +// CS2 80-prefixed codes support +#define CS2_80CODE_SUPPORT + // G80-2551 terminal keyboard support #define G80_2551_SUPPORT diff --git a/converter/ibmpc_usb/ibmpc_usb.cpp b/converter/ibmpc_usb/ibmpc_usb.cpp index 89c3a71f..dba6c3d4 100644 --- a/converter/ibmpc_usb/ibmpc_usb.cpp +++ b/converter/ibmpc_usb/ibmpc_usb.cpp @@ -928,6 +928,37 @@ uint8_t IBMPCConverter::cs2_e0code(uint8_t code) { } } +#ifdef CS2_80CODE_SUPPORT +// 80-prefixed codes +uint8_t IBMPCConverter::cs2_80code(uint8_t code) { + // Tandberg TDV 5020 + // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#tandberg-tdv-5020 + switch (code) { + case 0x2B: return 0x08; // TDV:MERK (mark) -> F13 + case 0x34: return 0x10; // TDV:ANGRE (undo) -> F14 + case 0x33: return 0x18; // TDV:SKRIV (print) -> F15 + case 0x42: return 0x20; // TDV:SLUTT (end) -> F16 + case 0x2C: return 0x28; // TDV:STRYK (cut) -> F17 + case 0x3C: return 0x30; // TDV:KOPI (copy) -> F18 + case 0x43: return 0x38; // TDV:FLYTT (move) -> F19 + case 0x4B: return 0x40; // TDV:FELT (cell) -> F20 + case 0x2A: return 0x48; // TDV:AVSN (paragraph) -> F21 + case 0x32: return 0x50; // TDV:SETN (sentence) -> F22 + case 0x3A: return 0x57; // TDV:ORD (word) -> F23 + case 0x61: return 0x6A; // TDV:⮎ (?) -> JYEN Japanese Yen + case 0x1D: return 0x5F; // TDV:HJELP (help) -> F24 + case 0x24: return 0x17; // TDV:^^^ (?) -> LGUI + case 0x44: return 0x65; // TDV:>>/<< (left/right adjust) -> VOLD Volume Down + case 0x4D: return 0x6E; // TDV:JUST (adjust) -> VOLU Volume Up + case 0x1C: return 0x6F; // TDV:>< <> (center/block) -> MUTE + case 0x2D: return 0x51; // TDV:⇟ (three lines down) -> RO Japanese Ro + case 0x1B: return 0x1F; // TDV:⇤ (start of line) -> RGUI + case 0x23: return 0x27; // TDV:⇥ (end of line) -> APP + } + return code; +} +#endif + // IBM 5576-002/003 Scan code translation // https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-5576-code-set-82h uint8_t IBMPCConverter::translate_5576_cs2(uint8_t code) { @@ -969,6 +1000,11 @@ int8_t IBMPCConverter::process_cs2(uint8_t code) case 0xE1: state_cs2 = CS2_E1; break; +#ifdef CS2_80CODE_SUPPORT + case 0x80: + state_cs2 = CS2_80; + break; +#endif case 0x83: // F7 matrix_make(0x02); state_cs2 = CS2_INIT; @@ -1110,6 +1146,25 @@ int8_t IBMPCConverter::process_cs2(uint8_t code) state_cs2 = CS2_INIT; } break; +#ifdef CS2_80CODE_SUPPORT + case CS2_80: + switch (code) { + case 0xF0: + state_cs2 = CS2_80_F0; + break; + default: + state_cs2 = CS2_INIT; + matrix_make(cs2_80code(code)); + } + break; + case CS2_80_F0: + switch (code) { + default: + state_cs2 = CS2_INIT; + matrix_break(cs2_80code(code)); + } + break; +#endif default: state_cs2 = CS2_INIT; } diff --git a/converter/ibmpc_usb/ibmpc_usb.hpp b/converter/ibmpc_usb/ibmpc_usb.hpp index 9d924069..acb6d1fa 100644 --- a/converter/ibmpc_usb/ibmpc_usb.hpp +++ b/converter/ibmpc_usb/ibmpc_usb.hpp @@ -95,6 +95,10 @@ class IBMPCConverter { CS2_E1_F0, CS2_E1_F0_14, CS2_E1_F0_14_F0, +#ifdef CS2_80CODE_SUPPORT + CS2_80, + CS2_80_F0, +#endif } state_cs2 = CS2_INIT; enum CS3_state { @@ -112,6 +116,9 @@ class IBMPCConverter { int8_t process_cs3(uint8_t code); uint8_t cs1_e0code(uint8_t code); uint8_t cs2_e0code(uint8_t code); +#ifdef CS2_80CODE_SUPPORT + uint8_t cs2_80code(uint8_t code); +#endif uint8_t translate_5576_cs2(uint8_t code); uint8_t translate_5576_cs2_e0(uint8_t code); uint8_t translate_5576_cs3(uint8_t code);