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

Add support for the DEC layout Televideo Linear Space Invader keyboards to ibmpc_usb. #711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions converter/ibmpc_usb/ibmpc_usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,31 @@ uint8_t IBMPCConverter::process_interface(void)
keyboard_kind = PC_AT;
}
} else if (0xAB90 == keyboard_id || // IBM 5576-002
0xAB91 == keyboard_id) { // IBM 5576-003
0xAB91 == keyboard_id) { // IBM 5576-003 or Televideo DEC
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ab90
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ab91

xprintf("\n5576_CS82h:");
keyboard_kind = PC_AT;
if ((0xFA == ibmpc.host_send(0xF0)) &&
(0xFA == ibmpc.host_send(0x82))) {
// switch to code set 82h
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#ibm-5576-scan-codes-set
xprintf("OK ");
} else {
xprintf("NG ");
if (0xAB91 == keyboard_id) {
// This must be a Televideo DEC keyboard, which piggybacks on the same keyboard_id as IBM 5576-003
// This keyboard normally starts up using code set 1, but we request code set 2 here:
if ((0xFA == ibmpc.host_send(0xF0)) &&
(0xFA == ibmpc.host_send(0x03))) {
xprintf("OK ");
keyboard_kind = PC_TERMINAL;
} else {
xprintf("NG ");
}
}
}
keyboard_kind = PC_AT;
} else if (0xBFB0 == keyboard_id) { // IBM RT Keyboard
// https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#bfb0
// TODO: LED indicator fix
Expand Down Expand Up @@ -1116,6 +1127,38 @@ uint8_t IBMPCConverter::translate_5576_cs3(uint8_t code) {
return code;
}

// Televideo DEC Scan code translation
uint8_t IBMPCConverter::translate_televideo_dec_cs3(uint8_t code) {
switch (code) {
case 0x08: return 0x76; // Esc
case 0x8D: return 0x77; // Num Lock
case 0x8E: return 0x67; // Numeric Keypad Slash
case 0x8F: return 0x7F; // Numeric Keypad Asterisk
case 0x90: return 0x7B; // Numeric Keypad Minus
case 0x6E: return 0x65; // Insert
case 0x65: return 0x6d; // Delete
case 0x67: return 0x62; // Home
case 0x6d: return 0x64; // End
case 0x64: return 0x6e; // PageUp
case 0x84: return 0x7c; // Numeric Keypad Plus (Legend says minus)
case 0x87: return 0x02; // Print Screen
case 0x88: return 0x7e; // Scroll Lock
case 0x89: return 0x0c; // Pause
case 0x8A: return 0x03; // VOLD
case 0x8B: return 0x04; // VOLU
case 0x8C: return 0x05; // MUTE
case 0x85: return 0x08; // F13
case 0x86: return 0x10; // F14
case 0x91: return 0x01; // LGUI
case 0x92: return 0x09; // RGUI
case 0x77: return 0x58; // RCTRL
case 0x57: return 0x66; // Backspace
case 0x66: return 0x5D; // JPY
case 0x7c: return 0x68; // Kp Comma
}
return code;
}

int8_t IBMPCConverter::process_cs3(uint8_t code)
{
switch (code) {
Expand All @@ -1133,6 +1176,10 @@ int8_t IBMPCConverter::process_cs3(uint8_t code)
if (0xAB92 == keyboard_id) {
code = translate_5576_cs3(code);
}
if (0xAB91 == keyboard_id) {
// This must be the Televideo DEC keyboard. (For 5576-003 we don't use scan code set 3)
code = translate_televideo_dec_cs3(code);
}
switch (code) {
case 0xF0:
state_cs3 = CS3_F0;
Expand Down Expand Up @@ -1179,6 +1226,10 @@ int8_t IBMPCConverter::process_cs3(uint8_t code)
if (0xAB92 == keyboard_id) {
code = translate_5576_cs3(code);
}
if (0xAB91 == keyboard_id) {
// This must be the Televideo DEC keyboard. (For 5576-003 we don't use scan code set 3)
code = translate_televideo_dec_cs3(code);
}
switch (code) {
case 0x83: // PrintScreen
matrix_break(0x02);
Expand Down
1 change: 1 addition & 0 deletions converter/ibmpc_usb/ibmpc_usb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class IBMPCConverter {
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);
uint8_t translate_televideo_dec_cs3(uint8_t code);

int16_t read_wait(uint16_t wait_ms);
uint16_t read_keyboard_id(void);
Expand Down