Merge remote-tracking branch 'tmk/master'

This commit is contained in:
Mark Sikora 2021-03-23 13:19:56 -04:00
commit 7544754df4
27 changed files with 12016 additions and 10653 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -387,10 +387,12 @@ uint8_t matrix_scan(void)
tick_ms = timer_read();
codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD);
if (codes) xprintf("%04X ", codes);
// Adjustable keybaord media keys
if (codes == 0 && has_media_keys &&
(codes = adb_host_kbd_recv(ADB_ADDR_APPLIANCE))) {
xprintf("m:%04X ", codes);
// key1
switch (codes & 0x7f ) {
case 0x00: // Mic
@ -434,10 +436,6 @@ uint8_t matrix_scan(void)
key0 = codes>>8;
key1 = codes&0xFF;
if (debug_matrix && codes) {
print("adb_host_kbd_recv: "); phex16(codes); print("\n");
}
if (codes == 0) { // no keys
return 0;
} else if (codes == 0x7F7F) { // power key press
@ -481,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) {
@ -491,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.

View file

@ -24,44 +24,62 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* 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,K37,K3A,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

View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define AC_FN0 ACTION_LAYER_TAP_KEY(1, KC_GRV)
#define AC_FN1 ACTION_LAYER_TAP_KEY(2, KC_BSLS)
#define AC_PKEY ACTION_MODS_TAP_KEY(MOD_NONE, KC_POWER)
#define AC_PKEY ACTION_MODS_TAP_KEY(MOD_NONE, KC_PWR)
#ifdef KEYMAP_SECTION_ENABLE
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
@ -47,7 +47,7 @@ const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
*/
[0] = UNIMAP_ADB(
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PKEY,
FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, VOLU,
FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, VOLU,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, FN1, DEL, END, PGDN, P7, P8, P9, PMNS, VOLD,
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PPLS, MUTE,
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -55,6 +55,9 @@ static uint16_t read_keyboard_id(void)
uint16_t id = 0;
int16_t code = 0;
// temporary fix Z-150 AT should response with ID
if (ibmpc_protocol == IBMPC_PROTOCOL_AT_Z150) return 0xFFFD;
// Disable
//code = ibmpc_host_send(0xF5);
@ -171,6 +174,7 @@ uint8_t matrix_scan(void)
xprintf("I%u ", timer_read());
keyboard_kind = NONE;
keyboard_id = 0x0000;
current_protocol = 0;
matrix_clear();
clear_keyboard();
@ -276,6 +280,8 @@ uint8_t matrix_scan(void)
keyboard_kind = PC_XT;
} else if (0xFFFE == keyboard_id) { // CodeSet2 PS/2 fails to response?
keyboard_kind = PC_AT;
} else if (0xFFFD == keyboard_id) { // Zenith Z-150 AT
keyboard_kind = PC_AT_Z150;
} else if (0x00FF == keyboard_id) { // Mouse is not supported
xprintf("Mouse: not supported\n");
keyboard_kind = NONE;
@ -306,7 +312,7 @@ uint8_t matrix_scan(void)
keyboard_kind = PC_AT;
}
xprintf("\nID:%04X(%d) ", keyboard_id, keyboard_kind);
xprintf("\nID:%04X(%s) ", keyboard_id, KEYBOARD_KIND_STR(keyboard_kind));
state = SETUP;
break;
@ -318,6 +324,9 @@ uint8_t matrix_scan(void)
case PC_AT:
led_set(host_keyboard_leds());
break;
case PC_AT_Z150:
// TODO: do not set indicators temporarily for debug
break;
case PC_TERMINAL:
// Set all keys to make/break type
ibmpc_host_send(0xF8);
@ -355,6 +364,7 @@ uint8_t matrix_scan(void)
if (process_cs1(code) == -1) state = INIT;
break;
case PC_AT:
case PC_AT_Z150:
if (process_cs2(code) == -1) state = INIT;
break;
case PC_TERMINAL:
@ -522,7 +532,7 @@ static int8_t process_cs1(uint8_t code)
static enum {
INIT,
E0,
// Pause: E1 1D 45, E1 9D C5 [a] (TODO: test)
// Pause: E1 1D 45, E1 9D C5 [a]
E1,
E1_1D,
E1_9D,
@ -579,7 +589,8 @@ static int8_t process_cs1(uint8_t code)
case E1_1D:
switch (code) {
case 0x45:
matrix_make(0x55);
matrix_make(0x55); // Pause
state = INIT;
break;
default:
state = INIT;
@ -588,8 +599,9 @@ static int8_t process_cs1(uint8_t code)
break;
case E1_9D:
switch (code) {
case 0x45:
matrix_break(0x55);
case 0xC5:
matrix_break(0x55); // Pause
state = INIT;
break;
default:
state = INIT;

View file

@ -1,7 +1,14 @@
#ifndef IBMPC_USB_H
#define IBMPC_USB_H
typedef enum { NONE, PC_XT, PC_AT, PC_TERMINAL } keyboard_kind_t;
typedef enum { NONE, PC_XT, PC_AT, PC_TERMINAL, PC_AT_Z150 } keyboard_kind_t;
#define KEYBOARD_KIND_STR(kind) \
(kind == PC_XT ? "XT" : \
kind == PC_AT ? "AT" : \
kind == PC_TERMINAL ? "TERMINAL" : \
kind == PC_AT_Z150 ? "AT_Z150" : \
"NONE")
extern uint16_t keyboard_id;
extern keyboard_kind_t keyboard_kind;

View file

@ -25,30 +25,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Mapping to Universal keyboard layout
*
* Universal keyboard layout
* ,-----------------------------------------------.
* |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
* ,---. |-----------------------------------------------| ,-----------. ,-----------.
* |Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|
* `---' `-----------------------------------------------' `-----------' `-----------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
* |-----------------------------------------------------------| |-----------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
* |-----------------------------------------------------------| `-----------' |---------------|
* |CapsL | A| S| D| F| G| H| J| K| L| ;| '| ^a|Retn| | 4| 5| 6|KP,|
* |-----------------------------------------------------------| ,---. |---------------|
* |Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|KP=|
* |-----------------------------------------------------------| ,-----------. |---------------|
* |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | #| 0| .|Ent|
* `-----------------------------------------------------------' `-----------' `---------------'
*/
/*
* Scan Code Set 1:
* 83-key:
* ,-------. ,--------------------------------------------------------------------------.
* | F1| F2| |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| BS |NumLck |ScrLck |
* |-------| |--------------------------------------------------------------------------|
@ -72,8 +51,44 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* |-------| |----------------------------------------------------------------------| |
* | 43| 44| | 38 | 39 | 3A | 52 | 53 | |
* `-------' `--------------------------------------------------------------------------'
* [3], [a]
* unused: UNIMAP_NUBS
* Full-key:
* ,-----------------------------------------------.
* |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
* ,---. |-----------------------------------------------| ,-----------. ,-----------.
* |Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|
* `---' `-----------------------------------------------' `-----------' `-----------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
* |-----------------------------------------------------------| |-----------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
* |-----------------------------------------------------------| `-----------' |---------------|
* |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Entr| | 4| 5| 6|KP,|
* |-----------------------------------------------------------| ,---. |---------------|
* |Shft| ^a| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|Ent|
* |-----------------------------------------------------------| ,-----------. |---------------|
* |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .|KP=|
* `-----------------------------------------------------------' `-----------' `---------------'
* ,-----------------------------------------------.
* | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D| 6E| 76|
* ,---. |-----------------------------------------------| ,-----------. ,-----------.
* | 01| | 3B| 3C| 3D| 3E| 3F| 40| 41| 42| 43| 44| 57| 58| |*37| 46|*46| |*2E|*30|*20|
* `---' `-----------------------------------------------' `-----------' `-----------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | 29| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 7D| 0E| |*52|*47|*49| | 45|*35| 37| 4A|
* |-----------------------------------------------------------| |-----------| |---------------|
* | 0F | 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 2B | |*53|*4F|*51| | 47| 48| 49| 4E|
* |-----------------------------------------------------------| `-----------' |---------------|
* | 3A | 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 56| 1C | | 4B| 4C| 4D| 7E|
* |-----------------------------------------------------------| ,---. |---------------|
* | 2A | ^a| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35| 73| 36 | |*48| | 4F| 50| 51|*1C|
* |-----------------------------------------------------------| ,-----------. |---------------|
* | 1D|*5B| 38| 7B | 39 | 79 | 70 |*38|*5C|*5D|*1D| |*4B|*50|*4D| | 52| 53| 59|
* `-----------------------------------------------------------' `-----------' `---------------'
* *: E0-prefixed codes. See cs1_e0code() for remapping to unimap array.
* PrintScreen: E0 37 or 54(with Alt) -> 54
* Pause: E1 1D 45 or E0 46(with Ctrl) -> 55
* ^a: ISO backslash and US backslash use identical code 2B. [3], [a]
* Unsupported codes or error -> 00. UNIMAP_NUBS is unused.
*/
const uint8_t PROGMEM unimap_cs1[MATRIX_ROWS][MATRIX_COLS] = {
{ UNIMAP_NO, UNIMAP_ESC, UNIMAP_1, UNIMAP_2, UNIMAP_3, UNIMAP_4, UNIMAP_5, UNIMAP_6 }, /* 00-07 */
@ -130,9 +145,9 @@ const uint8_t PROGMEM unimap_cs1[MATRIX_ROWS][MATRIX_COLS] = {
* |-----------------------------------------------------------| ,-----------. |---------------|
* | 14|*1F| 11| 67 | 29 | 64 | 13 |*11|*27|*2F|*14| |*6B|*72|*74| | 68| 70| 71| 63|
* `-----------------------------------------------------------' `-----------' `---------------'
* *: E0-prefixed codes
* *: E0-prefixed codes. See cs2_e0code() for remapping to unimap array.
* +: Special codes sequence
* ^a: ISO hash key uses identical scancode 5D to US backslash.
* ^a: ISO hash key and US backslash use identical code 5D.
* 51, 63, 68, 6A, 6D: Hidden keys in IBM model M [6]
*/
const uint8_t PROGMEM unimap_cs2[MATRIX_ROWS][MATRIX_COLS] = {
@ -163,16 +178,16 @@ const uint8_t PROGMEM unimap_cs2[MATRIX_ROWS][MATRIX_COLS] = {
* |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|
* `-----------------------------------------------'
* ,-------. ,-----------------------------------------------------------. ,-----------. ,---------------.
* |Mut|Hkn| | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY| BS| | /|PgU|PgD| |Esc|NmL|ScL| *|
* |Mut|HEN| | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY| BS| | /|PgU|PgD| |Esc|NmL|ScL| *|
* |-------| |-----------------------------------------------------------| |-----------| |---------------|
* |VoU|Pau| |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |End|Ins|Del| | 7| 8| 9| +|
* |VUp|Pau| |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |End|Ins|Del| | 7| 8| 9| +|
* |-------| |-----------------------------------------------------------| `-----------' |-----------|---|
* |VoD|Mhk| |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #| Ret| |Up | | 4| 5| 6| -|
* |VDn|MHE| |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #| Ret| |JPY|Up | #| | 4| 5| 6| -|
* |-------| |-----------------------------------------------------------| ,-----------. |---------------|
* |Psc|App| |Shif| \| Z| X| C| V| B| N| M| ,| ,| /| RO| Shift| |Lef|Hom|Rig| | 1| 2| 3|Ent|
* |PrS|App| |Shif| \| Z| X| C| V| B| N| M| ,| ,| /| RO| Shift| |Lef|Hom|Rig| | 1| 2| 3|Ent|
* |-------| |-----------------------------------------------------------| `-----------' |-----------|---|
* |Gui|Gui| |Ctrl| |Alt | Space |Alt | |Ctrl| |Dow| | ,| 0| .| =|
* `-------' `----' `---------------------------------------' `----' `---' `---------------'
* |Gui|Gui| |Ctrl| |Alt | Space |Alt | |Ctrl| | RO|Dow|KAN| | ,| 0| .| =|
* `-------' `----' `---------------------------------------' `----' ---`---'--- `---------------'
*
* ,-----------------------------------------------.
* | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F|
@ -184,13 +199,14 @@ const uint8_t PROGMEM unimap_cs2[MATRIX_ROWS][MATRIX_COLS] = {
* |-------| |-----------------------------------------------------------| |-----------| |---------------|
* | 04| 0C| | 0D | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| 5C | | 64| 65| 6D| | 6C| 75| 7D| 7C|
* |-------| |-----------------------------------------------------------| `-----------' |---------------|
* | 03| 0B| | 14 | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A | | 63| | 6B| 73| 74| 7B|
* | 03| 0B| | 14 | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 53| 5A | |-26| 63|-25| | 6B| 73| 74| 7B|
* |-------| |-----------------------------------------------------------| ,-----------. |---------------|
* |*83| 0A| | 12 | 13| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51| 59 | | 61| 62| 6A| | 69| 72| 7A| 79|
* |-------| |-----------------------------------------------------------| `-----------' |---------------|
* | 01| 09| | 11 | |19 | 29 |39 | | 58 | | 60| | 68| 70| 71| 78|
* `-------' `-----' `---------------------------------------' `-----' `---' `---------------'
* *: remapped 83->02, 84->7F
* | 01| 09| | 11 | |19 | 29 |39 | | 58 | |-16| 60|-1E| | 68| 70| 71| 78|
* `-------' `-----' `---------------------------------------' `-----' ---`---'--- `---------------'
* *: Special codes remapped 83->02, 84->7F
* -: G80-2551 specific 80-prefixed codes remapped: 26->5D, 25->53, 16->51, 1E->00
* 51, 5C, 5D, 68, 78: Hidden keys in IBM 122-key terminal keyboard [7]
*/
const uint8_t PROGMEM unimap_cs3[MATRIX_ROWS][MATRIX_COLS] = {

View file

@ -1,5 +1,5 @@
# Target file name (without extension).
TARGET ?= pc98_usb
TARGET ?= pc98_usb_atmega32u2
# Directory common source filess exist
TMK_DIR ?= ../../tmk_core

View file

@ -1,4 +1,4 @@
TARGET ?= pc98_usb_32u4
TARGET ?= pc98_usb_atmega32u4
MCU ?= atmega32u4
include Makefile

View file

@ -2,6 +2,9 @@ PC98 to USB keyboard protocol converter
=======================================
Target MCU is ATMega32u2 but other USB capable AVR will also work.
To initialize keyboard correctly you have to connect keyboard with converter first and then plug them into USB port.
Otherwise, keyboard may not work.
Connector
---------
@ -40,24 +43,31 @@ Frame format: 1-Start bit(Lo), 8-Data bits, Odd-Parity, 1-Stop bit
Prebilt Firmware
----------------
Prebuilt firmware HEX files are available under 'binary' directory.
Build Firmware
--------------
Just use 'make' to bild firmware for TMK PC98 converter.
Just use 'make' to bild firmware for TMK PC98 converter(ATMega32u2).
$ make clean
$ make
To flash firmware
To flash firmware run this command
$ make dfu
then push button on converter to flash firmware.
If you are using ATMega32u4 based board instead of premade TMK PC98 converter(ATMega32u2) use following commands.
If you are using ATMega32u4 based board use following commands to get firmware HEX file.
$ make -f Makefile.32u4 clean
$ make -f Makefile.32u4
$ make -f Makefile.32u4 dfu
And flash it on your board using specific program method.
@ -186,5 +196,10 @@ Dboard has LEDs but replys with FA to 9D command but ignore it. The LED indicate
PC-9801V has no LEDs and doesn't accept LED command. It replys with 9D to 9D command. PC-9801V doesn't accept repeat setting command. It replys with 9C to 9C command.
## PC-9801V
### PC-9801V
Note that you have to connect this keyboard with converter before plug in USB port. It seems this keyboard requires for host to send any command before starting to send scan code.
### Connection order
Converter doesn't support hotplugging due to limitation of PC-9801 keyboard.
You will have to plug keyboard into converter during without power first, and then plug them into USB port.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -50,6 +50,7 @@ static uint8_t matrix[MATRIX_ROWS];
static void pc98_send(uint8_t data)
{
xprintf("s%02X ", data);
PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
_delay_ms(1);
serial_send(data);
@ -62,6 +63,14 @@ static int16_t pc98_wait_response(void)
int16_t code = -1;
uint8_t timeout = 255;
while (timeout-- && (code = serial_recv2()) == -1) _delay_ms(1);
// Keyboards require RDY pulse >=37us to send next data
// https://archive.org/stream/PC9800TechnicalDataBookHARDWARE1993/PC-9800TechnicalDataBook_HARDWARE1993#page/n157
PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
_delay_us(40);
PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
xprintf("r%04X ", code);
return code;
}
@ -80,6 +89,22 @@ RETRY:
if (code != 0xFA) goto RETRY;
}
static bool pc98_is_newtype(void)
{
uint16_t code;
pc98_send(0x9F);
code = pc98_wait_response();
if (code != 0xFA) return false;
code = pc98_wait_response();
if (code != 0xA0) return false;
code = pc98_wait_response();
if (code != 0x80) return false;
return true;
}
static uint8_t pc98_led = 0;
static void pc98_led_set(void)
{
@ -116,6 +141,7 @@ void matrix_init(void)
PC98_RST_PORT |= (1<<PC98_RST_BIT); // RST: high
_delay_ms(50);
if (pc98_is_newtype()) xprintf("new type\n"); else xprintf("old type\n");
pc98_inhibit_repeat();
// initialize matrix state: all keys off
@ -143,7 +169,7 @@ uint8_t matrix_scan(void)
return 0;
}
dprintf("%02X ", code);
xprintf("r%02X ", code);
if (code&0x80) {
// break code
@ -157,11 +183,12 @@ uint8_t matrix_scan(void)
}
}
// PC-9801V keyboard requires RDY pulse.
// This is not optimal place though, it works.
PC98_RDY_PORT |= (1<<PC98_RDY_BIT); // RDY: high
_delay_us(20);
PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT); // RDY: low
// Keyboards require RDY pulse >=37us to send next data
// https://archive.org/stream/PC9800TechnicalDataBookHARDWARE1993/PC-9800TechnicalDataBook_HARDWARE1993#page/n157
PC98_RDY_PORT |= (1<<PC98_RDY_BIT);
_delay_us(40);
PC98_RDY_PORT &= ~(1<<PC98_RDY_BIT);
return code;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -144,6 +144,7 @@ uint8_t matrix_scan(void)
switch (code) {
case 0x45:
matrix_make(0x55);
state = INIT;
break;
default:
state = INIT;
@ -152,8 +153,9 @@ uint8_t matrix_scan(void)
break;
case E1_9D:
switch (code) {
case 0x45:
case 0xC5:
matrix_break(0x55);
state = INIT;
break;
default:
state = INIT;

View file

@ -555,18 +555,19 @@ bool is_tap_key(keyevent_t event)
switch (action.key.code) {
case MODS_ONESHOT:
case MODS_TAP_TOGGLE:
case KC_A ... KC_EXSEL: // tap key
case KC_LCTRL ... KC_RGUI: // tap key
default: // tap key
return true;
}
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
case OP_ON_OFF:
case OP_OFF_ON:
case OP_SET_CLEAR:
case 0xc0 ... 0xdf: // with modifiers
return false;
case KC_A ... KC_EXSEL: // tap key
case KC_LCTRL ... KC_RGUI: // tap key
case OP_TAP_TOGGLE:
default: // tap key
return true;
}
return false;

View file

@ -36,8 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* 001r|mods|0000 0000 Modifiers with OneShot[TAP]
* 001r|mods|0000 0001 Modifiers with tap toggle[TAP]
* 001r|mods|0000 00xx (reserved) (0x02-03)
* 001r|mods| keycode Modifiers with tap key(0x04-A4, E0-E7)[TAP]
* (reserved) (0xA5-DF, E8-FF)
* 001r|mods| keycode Modifiers with tap key[TAP]
*
*
* Other Keys(01xx)
@ -71,10 +70,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* 1001|oopp|BBBB BBBB 8-bit Bitwise Operation???
*
* ACT_LAYER_TAP(101x):
* 101E|LLLL| keycode On/Off with tap key (0x04-A4, E0-E7)[TAP]
* 101E|LLLL| keycode On/Off with tap key [TAP]
* 101E|LLLL|110r mods On/Off with modifiers (0xC0-DF)[NOT TAP]
* r: Left/Right flag(Left:0, Right:1)
* (reserved) (0xA5-BF, E8-EF)
* 101E|LLLL|1111 0000 Invert with tap toggle (0xF0) [TAP]
* 101E|LLLL|1111 0001 On/Off (0xF1) [NOT TAP]
* 101E|LLLL|1111 0010 Off/On (0xF2) [NOT TAP]

View file

@ -26,7 +26,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF)
#ifndef ACTIONMAP_ENABLE
// Use original HID usages on B0-DD instead of TMK specific codes
#ifndef USE_ORIGINAL_HID_USAGE
#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL)
#else
#define IS_KEY(code) ((KC_A <= (code) && (code) <= KC_EXSEL) || \
@ -186,325 +187,324 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* USB HID Keyboard/Keypad Usage(0x07) */
enum hid_keyboard_keypad_usage {
KC_NO = 0x00,
KC_ROLL_OVER,
KC_POST_FAIL,
KC_UNDEFINED,
KC_A, /* 0x04 */
KC_B,
KC_C,
KC_D,
KC_E,
KC_F,
KC_G,
KC_H,
KC_I,
KC_J,
KC_K,
KC_L,
KC_M, /* 0x10 */
KC_N,
KC_O,
KC_P,
KC_Q,
KC_R,
KC_S,
KC_T,
KC_U,
KC_V,
KC_W,
KC_X,
KC_Y,
KC_Z,
KC_1,
KC_2,
KC_3, /* 0x20 */
KC_4,
KC_5,
KC_6,
KC_7,
KC_8,
KC_9,
KC_0,
KC_ENTER,
KC_ESCAPE,
KC_BSPACE,
KC_TAB,
KC_SPACE,
KC_MINUS,
KC_EQUAL,
KC_LBRACKET,
KC_RBRACKET, /* 0x30 */
KC_BSLASH, /* \ (and |) */
KC_NONUS_HASH, /* Non-US # and ~ (Typically near the Enter key) */
KC_SCOLON, /* ; (and :) */
KC_QUOTE, /* ' and " */
KC_GRAVE, /* Grave accent and tilde */
KC_COMMA, /* , and < */
KC_DOT, /* . and > */
KC_SLASH, /* / and ? */
KC_CAPSLOCK,
KC_F1,
KC_F2,
KC_F3,
KC_F4,
KC_F5,
KC_F6,
KC_F7, /* 0x40 */
KC_F8,
KC_F9,
KC_F10,
KC_F11,
KC_F12,
KC_PSCREEN,
KC_SCROLLLOCK,
KC_PAUSE,
KC_INSERT,
KC_HOME,
KC_PGUP,
KC_DELETE,
KC_END,
KC_PGDOWN,
KC_RIGHT,
KC_LEFT, /* 0x50 */
KC_DOWN,
KC_UP,
KC_NUMLOCK,
KC_KP_SLASH,
KC_KP_ASTERISK,
KC_KP_MINUS,
KC_KP_PLUS,
KC_KP_ENTER,
KC_KP_1,
KC_KP_2,
KC_KP_3,
KC_KP_4,
KC_KP_5,
KC_KP_6,
KC_KP_7,
KC_KP_8, /* 0x60 */
KC_KP_9,
KC_KP_0,
KC_KP_DOT,
KC_NONUS_BSLASH, /* Non-US \ and | (Typically near the Left-Shift key) */
KC_APPLICATION,
KC_POWER,
KC_KP_EQUAL,
KC_F13,
KC_F14,
KC_F15,
KC_F16,
KC_F17,
KC_F18,
KC_F19,
KC_F20,
KC_F21, /* 0x70 */
KC_F22,
KC_F23,
KC_F24,
KC_EXECUTE,
KC_HELP,
KC_MENU,
KC_SELECT,
KC_STOP,
KC_AGAIN,
KC_UNDO,
KC_CUT,
KC_COPY,
KC_PASTE,
KC_FIND,
KC__MUTE,
KC__VOLUP, /* 0x80 */
KC__VOLDOWN,
KC_LOCKING_CAPS, /* locking Caps Lock */
KC_LOCKING_NUM, /* locking Num Lock */
KC_LOCKING_SCROLL, /* locking Scroll Lock */
KC_KP_COMMA,
KC_KP_EQUAL_AS400, /* equal sign on AS/400 */
KC_INT1,
KC_INT2,
KC_INT3,
KC_INT4,
KC_INT5,
KC_INT6,
KC_INT7,
KC_INT8,
KC_INT9,
KC_LANG1, /* 0x90 */
KC_LANG2,
KC_LANG3,
KC_LANG4,
KC_LANG5,
KC_LANG6,
KC_LANG7,
KC_LANG8,
KC_LANG9,
KC_ALT_ERASE,
KC_SYSREQ,
KC_CANCEL,
KC_CLEAR,
KC_PRIOR,
KC_RETURN,
KC_SEPARATOR,
KC_OUT, /* 0xA0 */
KC_OPER,
KC_CLEAR_AGAIN,
KC_CRSEL,
KC_EXSEL, /* 0xA4 */
KC_NO = 0x00,
KC_ROLL_OVER, // 01
KC_POST_FAIL, // 02
KC_UNDEFINED, // 03
KC_A, // 04
KC_B, // 05
KC_C, // 06
KC_D, // 07
KC_E, // 08
KC_F, // 09
KC_G, // 0A
KC_H, // 0B
KC_I, // 0C
KC_J, // 0D
KC_K, // 0E
KC_L, // 0F
KC_M, // 10
KC_N, // 11
KC_O, // 12
KC_P, // 13
KC_Q, // 14
KC_R, // 15
KC_S, // 16
KC_T, // 17
KC_U, // 18
KC_V, // 19
KC_W, // 1A
KC_X, // 1B
KC_Y, // 1C
KC_Z, // 1D
KC_1, // 1E
KC_2, // 1F
KC_3, // 20
KC_4, // 21
KC_5, // 22
KC_6, // 23
KC_7, // 24
KC_8, // 25
KC_9, // 26
KC_0, // 27
KC_ENTER, // 28
KC_ESCAPE, // 29
KC_BSPACE, // 2A
KC_TAB, // 2B
KC_SPACE, // 2C
KC_MINUS, // 2D
KC_EQUAL, // 2E
KC_LBRACKET, // 2F
KC_RBRACKET, // 30
KC_BSLASH, // 31 \ (and |)
KC_NONUS_HASH, // 32 Non-US # and ~ (Typically near the Enter key)
KC_SCOLON, // 33 ; (and :)
KC_QUOTE, // 34 ' and "
KC_GRAVE, // 35 Grave accent and tilde
KC_COMMA, // 36 , and <
KC_DOT, // 37 . and >
KC_SLASH, // 38 / and ?
KC_CAPSLOCK, // 39
KC_F1, // 3A
KC_F2, // 3B
KC_F3, // 3C
KC_F4, // 3D
KC_F5, // 3E
KC_F6, // 3F
KC_F7, // 40
KC_F8, // 41
KC_F9, // 42
KC_F10, // 43
KC_F11, // 44
KC_F12, // 45
KC_PSCREEN, // 46
KC_SCROLLLOCK, // 47
KC_PAUSE, // 48
KC_INSERT, // 49
KC_HOME, // 4A
KC_PGUP, // 4B
KC_DELETE, // 4C
KC_END, // 4D
KC_PGDOWN, // 4E
KC_RIGHT, // 4F
KC_LEFT, // 50
KC_DOWN, // 51
KC_UP, // 52
KC_NUMLOCK, // 53
KC_KP_SLASH, // 54
KC_KP_ASTERISK, // 55
KC_KP_MINUS, // 56
KC_KP_PLUS, // 57
KC_KP_ENTER, // 58
KC_KP_1, // 59
KC_KP_2, // 5A
KC_KP_3, // 5B
KC_KP_4, // 5C
KC_KP_5, // 5D
KC_KP_6, // 5E
KC_KP_7, // 5F
KC_KP_8, // 60
KC_KP_9, // 61
KC_KP_0, // 62
KC_KP_DOT, // 63
KC_NONUS_BSLASH, // 64 Non-US \ and | (Typically near the Left-Shift key) */
KC_APPLICATION, // 65
KC_POWER, // 66
KC_KP_EQUAL, // 67
KC_F13, // 68
KC_F14, // 69
KC_F15, // 6A
KC_F16, // 6B
KC_F17, // 6C
KC_F18, // 6D
KC_F19, // 6E
KC_F20, // 6F
KC_F21, // 70
KC_F22, // 71
KC_F23, // 72
KC_F24, // 73
KC_EXECUTE, // 74
KC_HELP, // 75
KC_MENU, // 76
KC_SELECT, // 77
KC_STOP, // 78
KC_AGAIN, // 79
KC_UNDO, // 7A
KC_CUT, // 7B
KC_COPY, // 7C
KC_PASTE, // 7D
KC_FIND, // 7E
KC__MUTE, // 7F
KC__VOLUP, // 80
KC__VOLDOWN, // 81
KC_LOCKING_CAPS, // 82 locking Caps Lock */
KC_LOCKING_NUM, // 83 locking Num Lock */
KC_LOCKING_SCROLL, // 84 locking Scroll Lock */
KC_KP_COMMA, // 85
KC_KP_EQUAL_AS400, // 86 equal sign on AS/400 */
KC_INT1, // 87
KC_INT2, // 88
KC_INT3, // 89
KC_INT4, // 8A
KC_INT5, // 8B
KC_INT6, // 8C
KC_INT7, // 8D
KC_INT8, // 8E
KC_INT9, // 8F
KC_LANG1, // 90
KC_LANG2, // 91
KC_LANG3, // 92
KC_LANG4, // 93
KC_LANG5, // 94
KC_LANG6, // 95
KC_LANG7, // 96
KC_LANG8, // 97
KC_LANG9, // 98
KC_ALT_ERASE, // 99
KC_SYSREQ, // 9A
KC_CANCEL, // 9B
KC_CLEAR, // 9C
KC_PRIOR, // 9D
KC_RETURN, // 9E
KC_SEPARATOR, // 9F
KC_OUT, // A0
KC_OPER, // A1
KC_CLEAR_AGAIN, // A2
KC_CRSEL, // A3
KC_EXSEL, // A4
/* NOTE: Following code range(0xB0-DD) are shared with special codes of 8-bit keymap */
KC_KP_00 = 0xB0,
KC_KP_000,
KC_THOUSANDS_SEPARATOR,
KC_DECIMAL_SEPARATOR,
KC_CURRENCY_UNIT,
KC_CURRENCY_SUB_UNIT,
KC_KP_LPAREN,
KC_KP_RPAREN,
KC_KP_LCBRACKET, /* { */
KC_KP_RCBRACKET, /* } */
KC_KP_TAB,
KC_KP_BSPACE,
KC_KP_A,
KC_KP_B,
KC_KP_C,
KC_KP_D,
KC_KP_E, /* 0xC0 */
KC_KP_F,
KC_KP_XOR,
KC_KP_HAT,
KC_KP_PERC,
KC_KP_LT,
KC_KP_GT,
KC_KP_AND,
KC_KP_LAZYAND,
KC_KP_OR,
KC_KP_LAZYOR,
KC_KP_COLON,
KC_KP_HASH,
KC_KP_SPACE,
KC_KP_ATMARK,
KC_KP_EXCLAMATION,
KC_KP_MEM_STORE, /* 0xD0 */
KC_KP_MEM_RECALL,
KC_KP_MEM_CLEAR,
KC_KP_MEM_ADD,
KC_KP_MEM_SUB,
KC_KP_MEM_MUL,
KC_KP_MEM_DIV,
KC_KP_PLUS_MINUS,
KC_KP_CLEAR,
KC_KP_CLEAR_ENTRY,
KC_KP_BINARY,
KC_KP_OCTAL,
KC_KP_DECIMAL,
KC_KP_HEXADECIMAL, /* 0xDD */
KC_KP_00 = 0xB0,
KC_KP_000, // B1
KC_THOUSANDS_SEPARATOR, // B2
KC_DECIMAL_SEPARATOR, // B3
KC_CURRENCY_UNIT, // B4
KC_CURRENCY_SUB_UNIT, // B5
KC_KP_LPAREN, // B6
KC_KP_RPAREN, // B7
KC_KP_LCBRACKET, // B8 {
KC_KP_RCBRACKET, // B9 }
KC_KP_TAB, // BA
KC_KP_BSPACE, // BB
KC_KP_A, // BC
KC_KP_B, // BD
KC_KP_C, // BE
KC_KP_D, // BF
KC_KP_E, // C0
KC_KP_F, // C1
KC_KP_XOR, // C2
KC_KP_HAT, // C3
KC_KP_PERC, // C4
KC_KP_LT, // C5
KC_KP_GT, // C6
KC_KP_AND, // C7
KC_KP_LAZYAND, // C8
KC_KP_OR, // C9
KC_KP_LAZYOR, // CA
KC_KP_COLON, // CB
KC_KP_HASH, // CC
KC_KP_SPACE, // CD
KC_KP_ATMARK, // CE
KC_KP_EXCLAMATION, // CF
KC_KP_MEM_STORE, // D0
KC_KP_MEM_RECALL, // D1
KC_KP_MEM_CLEAR, // D2
KC_KP_MEM_ADD, // D3
KC_KP_MEM_SUB, // D4
KC_KP_MEM_MUL, // D5
KC_KP_MEM_DIV, // D6
KC_KP_PLUS_MINUS, // D7
KC_KP_CLEAR, // D8
KC_KP_CLEAR_ENTRY, // D9
KC_KP_BINARY, // DA
KC_KP_OCTAL, // DB
KC_KP_DECIMAL, // DC
KC_KP_HEXADECIMAL, // DD
/* Modifiers */
KC_LCTRL = 0xE0,
KC_LSHIFT,
KC_LALT,
KC_LGUI,
KC_RCTRL,
KC_RSHIFT,
KC_RALT,
KC_RGUI, /* 0xE7 */
KC_LCTRL = 0xE0,
KC_LSHIFT, // E1
KC_LALT, // E2
KC_LGUI, // E3
KC_RCTRL, // E4
KC_RSHIFT, // E5
KC_RALT, // E6
KC_RGUI, // E7
};
/* Special keycodes for 8-bit keymap
NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */
enum internal_special_keycodes {
/* System Control */
KC_SYSTEM_POWER = 0xA5,
KC_SYSTEM_SLEEP,
KC_SYSTEM_WAKE,
KC_SYSTEM_POWER = 0xA5,
KC_SYSTEM_SLEEP, // A6
KC_SYSTEM_WAKE, // A7
/* Media Control */
KC_AUDIO_MUTE,
KC_AUDIO_VOL_UP,
KC_AUDIO_VOL_DOWN,
KC_MEDIA_NEXT_TRACK,
KC_MEDIA_PREV_TRACK,
KC_MEDIA_FAST_FORWARD,
KC_MEDIA_REWIND,
KC_MEDIA_STOP,
KC_MEDIA_PLAY_PAUSE,
KC_MEDIA_EJECT,
KC_MEDIA_SELECT,
KC_MAIL,
KC_CALCULATOR,
KC_MY_COMPUTER,
KC_WWW_SEARCH,
KC_WWW_HOME,
KC_WWW_BACK,
KC_WWW_FORWARD,
KC_WWW_STOP,
KC_WWW_REFRESH,
KC_WWW_FAVORITES,
KC_BRIGHTNESS_INC,
KC_BRIGHTNESS_DEC, /* 0xBE */
KC_AUDIO_MUTE, // A8
KC_AUDIO_VOL_UP, // A9
KC_AUDIO_VOL_DOWN, // AA
KC_MEDIA_NEXT_TRACK, // AB
KC_MEDIA_PREV_TRACK, // AC
KC_MEDIA_FAST_FORWARD, // AD
KC_MEDIA_REWIND, // AE
KC_MEDIA_STOP, // AF
KC_MEDIA_PLAY_PAUSE, // B0
KC_MEDIA_EJECT, // B1
KC_MEDIA_SELECT, // B2
KC_MAIL, // B3
KC_CALCULATOR, // B4
KC_MY_COMPUTER, // B5
KC_WWW_SEARCH, // B6
KC_WWW_HOME, // B7
KC_WWW_BACK, // B8
KC_WWW_FORWARD, // B9
KC_WWW_STOP, // BA
KC_WWW_REFRESH, // BB
KC_WWW_FAVORITES, // BC
KC_BRIGHTNESS_INC, // BD
KC_BRIGHTNESS_DEC, // BE
/* Jump to bootloader */
KC_BOOTLOADER = 0xBF,
KC_BOOTLOADER, // BF
/* Fn key */
KC_FN0 = 0xC0,
KC_FN1,
KC_FN2,
KC_FN3,
KC_FN4,
KC_FN5,
KC_FN6,
KC_FN7,
KC_FN8,
KC_FN9,
KC_FN10,
KC_FN11,
KC_FN12,
KC_FN13,
KC_FN14,
KC_FN15,
KC_FN16 = 0xD0,
KC_FN17,
KC_FN18,
KC_FN19,
KC_FN20,
KC_FN21,
KC_FN22,
KC_FN23,
KC_FN24,
KC_FN25,
KC_FN26,
KC_FN27,
KC_FN28,
KC_FN29,
KC_FN30,
KC_FN31, /* 0xDF */
KC_FN0, // C0
KC_FN1, // C1
KC_FN2, // C2
KC_FN3, // C3
KC_FN4, // C4
KC_FN5, // C5
KC_FN6, // C6
KC_FN7, // C7
KC_FN8, // C8
KC_FN9, // C9
KC_FN10, // CA
KC_FN11, // CB
KC_FN12, // CC
KC_FN13, // CD
KC_FN14, // CE
KC_FN15, // CF
KC_FN16, // D0
KC_FN17, // D1
KC_FN18, // D2
KC_FN19, // D3
KC_FN20, // D4
KC_FN21, // D5
KC_FN22, // D6
KC_FN23, // D7
KC_FN24, // D8
KC_FN25, // D9
KC_FN26, // DA
KC_FN27, // DB
KC_FN28, // DC
KC_FN29, // DD
KC_FN30, // DE
KC_FN31, // DF
/**************************************/
/* 0xE0-E7 for Modifiers. DO NOT USE. */
/**************************************/
/* Mousekey */
KC_MS_UP = 0xF0,
KC_MS_DOWN,
KC_MS_LEFT,
KC_MS_RIGHT,
KC_MS_BTN1,
KC_MS_BTN2,
KC_MS_BTN3,
KC_MS_BTN4,
KC_MS_BTN5, /* 0xF8 */
KC_MS_UP = 0xF0,
KC_MS_DOWN, // F1
KC_MS_LEFT, // F2
KC_MS_RIGHT, // F3
KC_MS_BTN1, // F4
KC_MS_BTN2, // F5
KC_MS_BTN3, // F6
KC_MS_BTN4, // F7
KC_MS_BTN5, // F8
/* Mousekey wheel */
KC_MS_WH_UP,
KC_MS_WH_DOWN,
KC_MS_WH_LEFT,
KC_MS_WH_RIGHT, /* 0xFC */
KC_MS_WH_UP, // F9
KC_MS_WH_DOWN, // FA
KC_MS_WH_LEFT, // FB
KC_MS_WH_RIGHT, // FC
/* Mousekey accel */
KC_MS_ACCEL0,
KC_MS_ACCEL1,
KC_MS_ACCEL2 /* 0xFF */
KC_MS_ACCEL0, // FD
KC_MS_ACCEL1, // FE
KC_MS_ACCEL2 // FF
};
#endif /* KEYCODE_H */

View file

@ -10,33 +10,33 @@ Download and Install
2. **Programmer** Install [dfu-programmer][dfu-prog]. GUI tool [Atmel FLIP][flip] also can be used on Windows.
3. **Driver** On Windows when you start DFU bootloader on the chip first time you will see **Found New Hardware Wizard** to install driver. If you install device driver properly you will find chip name like **ATmega32U4** under **LibUSB-Win32 Devices** tree on **Device Manager**. If not you shall need to update its driver on **Device Manager**. You will find the driver in `FLIP` install directory like: `C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\`. In case of `dfu-programmer` install driver distributed with it.
3. **Driver** On Windows when you start DFU bootloader on the chip for the first time you will see **Found New Hardware Wizard** to install driver. If you install the device driver properly you will find a chip name like **ATmega32U4** under the **LibUSB-Win32 Devices** tree in **Device Manager**. If not you will need to update its driver in **Device Manager**. You will find the driver in the `FLIP` install directory, something like this: `C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\`. For `dfu-programmer` install the driver distributed with it.
If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader].
If you use a PJRC Teensy you don't need step 2 and 3 above, just get the [Teensy loader][teensy-loader].
### 2. Download source
You can find firmware source at github:
### 2. Download Source
You can find the firmware source on github:
- <https://github.com/tmk/tmk_keyboard>
If you are familiar with [`git`][git] tools you are recommended to use it but you can also download zip archive from:
If you are familiar with [`git`][git] tools you can use that; otherwise you can download the zip archive from:
- <https://github.com/tmk/tmk_keyboard/archive/master.zip>
Build firmware
Build Firmware
--------------
### 1. Open terminal
Open terminal window to get access to commands. Use Cygwin(or MingGW) shell terminal in Windows or `Terminal.app` on Mac OSX.
### 1. Open Terminal
Open a terminal window. Use the Cygwin (or MingGW) shell terminal on Windows, the `Terminal.app` on Mac OSX, and whatever terminal you like on Linux.
### 2. Change directory
Move to project directory in the firmware source.
### 2. Change Directory
Move to the project directory in the firmware source.
cd tmk_keyboard/{'keyboard' or 'converter'}/<project>
### 3. Make
Build firmware using GNU `make` command. You'll see `<project>_<variant>.hex` file in that directory unless something unexpected occurs in build process.
Build the firmware using the GNU `make` command. You'll see a `<project>_<variant>.hex` file in that directory unless something unexpected occurs in build process.
make -f Makefile.<variant> clean
@ -47,16 +47,17 @@ Build firmware using GNU `make` command. You'll see `<project>_<variant>.hex` fi
Program Controller
------------------
Now you have **hex** file to program on current directory. This **hex** is only needed to program your controller, other files are used for development and you may leave and forget them.
Now you have a **hex** file in the current directory. This **hex** file is only needed to program your controller, other files are used for development and you may leave and forget them.
### 1. Start bootloader
How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual.
### 1. Start Bootloader
How you program the controller depends on the controller chip and its board design. To program an AVR USB chip you'll need to start it up in bootloader mode. Most boards have a push-button to load the bootloader. Consult with your controller board's manual.
<!--PROGRESS-->
### 2. Program with DFU bootloader
Stock AVR USB chips have DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. `FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below. Open source alternative `dfu-programmer` also supports AVR chips, it is command line tool and runs on Linux, Mac OSX and even Windows.
Stock AVR USB chips have the DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. `FLIP` has two version of the tool, a GUI app and a command line program. If you want the GUI see the tutorial below. An open source alternative, `dfu-programmer`, also supports AVR chips; it is a command line tool and runs on Linux, Mac OSX and even Windows.
To program with command of `FLIP` run this. Note that you need to set PATH variable properly.
To program with the command line version of `FLIP` run this. Note that you need to set the PATH variable properly.
$ make -f Makefile.<variant> flip
@ -70,16 +71,16 @@ Or you can execute the command directly as the following.
$ dfu-programmer <controller> flash <your_firmware.hex>
$ dfu-programmer <controller> reset
`<controller>` part will be `atmega32u4` or `atmega32u2` in most cases. See manual of the command for the detail. On Linux and Mac OSX you will need proper permission to program a controller and you can use `sudo` command for this purpose probably. On Linux you also can configure `udev` rules to set permission.
The `<controller>` part will be `atmega32u4` or `atmega32u2` in most cases. See the manual of the command for details. On Linux and Mac OSX you will need proper permissions to program a controller and you can probably use `sudo` command for this purpose. On Linux you also can configure `udev` rules to set permissions.
#### FLIP GUI tutorial
1. On menu bar click **Device** -> **Select**, then choose your chip name. (In most cases **ATmega32U2** or **ATmega32U4**)
2. On menu bar click **Settings** -> **Communication** -> **USB**, then click **Open** button on **USB Port Connection** dialog. At this point you'll have to plug into USB and start bootloader.
#### FLIP GUI Tutorial
1. In the menu bar click **Device** -> **Select**, then choose your chip name. (In most cases **ATmega32U2** or **ATmega32U4**)
2. In the menu bar click **Settings** -> **Communication** -> **USB**, then click the **Open** button in the **USB Port Connection** dialog. At this point you'll have to plug into USB and start the bootloader.
3. On menu bar click **File** -> **Load HEX File**, then select your firmware hex file on File Selector dialog.
4. On **Operations Flow** panel click **Run** button to load the firmware binary to the chip. Note that you should keep **Erase**, **Blank Check**, **Program** and **Verify** check boxes selected.
5. Re-plug USB cord or click **Start Application** button to restart your controller.
3. In the menu bar click **File** -> **Load HEX File**, then select your firmware hex file in the File Selector dialog.
4. In the **Operations Flow** panel click the **Run** button to load the firmware binary to the chip. Note that you should keep the **Erase**, **Blank Check**, **Program** and **Verify** check boxes selected.
5. Re-connect the USB cord or click the **Start Application** button to restart your controller.
Done.
See also these instructions if needed.
@ -88,17 +89,17 @@ See also these instructions if needed.
- <http://www.atmel.com/Images/doc7769.pdf>
##### Troubleshoot
##### Troubleshooting
* **FLIP: AtLibUsbDfu.dll not found**
Remove current driver and re-install one FLIP provides from DeviceManager of WIndows. See <http://imgur.com/a/bnwzy>
Remove the current driver and re-install the one FLIP provides from DeviceManager of Windows. See <http://imgur.com/a/bnwzy>
### 3. Program with Other programmer
If you are using PJRC Teensy consult with instruction of [Teensy Loader][teensy-loader]. Or run this target with `make` after you install command line version of it.
### 3. Program with Another Programmer
If you are using a PJRC Teensy consult with the instructions for [Teensy Loader][teensy-loader]. Or run this target with `make` after you install the command line version of it.
$ make -f Makefile.<variant> teensy
You may want to use other programmer like [`avrdude`][avrdude]. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile. See below.
You may want to use another programmer like [`avrdude`][avrdude]. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in the Makefile. See below.
$ make -f Makefile.<variant> program
@ -132,10 +133,10 @@ Set your MCU and its clock in Hz.
# LUFA bootloader 4096
OPT_DEFS += -DBOOTLOADER_SIZE=4096
If you are using PJRC Teensy use `512` for `BOOTLOADER_SIZE`, otherwise use `4096` unless you are sure.
If you are using a PJRC Teensy use `512` for `BOOTLOADER_SIZE`, otherwise use `4096` unless you are sure.
### 2. Features
Optional. Note that ***comment out*** with `#` to disable them.
Optional. Note that you can ***comment out*** lines with `#` to disable them.
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
@ -147,7 +148,7 @@ Optional. Note that ***comment out*** with `#` to disable them.
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
### 3. Programmer
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`.
Optional. Set the proper command for your controller, bootloader, and programmer. This command can be used with `make program`.
# avrdude with AVRISPmkII
PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex
@ -162,7 +163,7 @@ Optional. Set proper command for your controller, bootloader and programmer. Thi
Config.h Options
----------------
### 1. Magic command key combination
### 1. Magic Command Key Combination
#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)))

View file

@ -136,6 +136,7 @@ int16_t ibmpc_host_send(uint8_t data)
wait_us(15);
data_hi();
WAIT(clock_hi, 50, 6);
if (ibmpc_protocol == IBMPC_PROTOCOL_AT_Z150) { goto RECV; }
WAIT(clock_lo, 50, 7);
/* Ack */
@ -145,6 +146,7 @@ int16_t ibmpc_host_send(uint8_t data)
WAIT(clock_hi, 50, 9);
WAIT(data_hi, 50, 10);
RECV:
// clear buffer to get response correctly
recv_data = 0xFFFF;
ibmpc_host_isr_clear();

@ -1 +1 @@
Subproject commit ab4b4400a429942b9215905ef7702d1d7a33f18b
Subproject commit b6128f252700a8dd2d12400c55680ef67cdcac86