aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--converter/adb_usb/Makefile3
-rw-r--r--converter/adb_usb/README.md (renamed from converter/adb_usb/README)45
-rw-r--r--converter/adb_usb/config.h27
-rw-r--r--converter/adb_usb/keymap.c16
-rw-r--r--converter/adb_usb/matrix.c69
-rw-r--r--converter/ps2_usb/Makefile42
-rw-r--r--converter/ps2_usb/Makefile.jis (renamed from converter/ps2_usb/Makefile.pjrc_usart)42
-rw-r--r--converter/ps2_usb/Makefile.vusb16
-rw-r--r--converter/ps2_usb/README116
-rw-r--r--converter/ps2_usb/README.vusb37
-rw-r--r--converter/ps2_usb/config.h (renamed from converter/ps2_usb/config_vusb.h)107
-rw-r--r--converter/ps2_usb/config_pjrc.h59
-rw-r--r--converter/ps2_usb/config_pjrc_usart.h91
-rw-r--r--converter/ps2_usb/keymap_jis.c297
-rw-r--r--converter/ps2_usb/usbconfig.h1
-rw-r--r--protocol/adb.c6
-rw-r--r--protocol/adb.h5
-rw-r--r--protocol/ps2.c15
18 files changed, 594 insertions, 400 deletions
diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile
index e9a90695b..87b0f415b 100644
--- a/converter/adb_usb/Makefile
+++ b/converter/adb_usb/Makefile
@@ -35,8 +35,7 @@ F_CPU = 16000000
35# Build Options 35# Build Options
36# comment out to disable the options. 36# comment out to disable the options.
37# 37#
38MOUSEKEY_ENABLE = yes # Mouse keys 38#MOUSEKEY_ENABLE = yes # Mouse keys
39#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
40EXTRAKEY_ENABLE = yes # Audio control and System control 39EXTRAKEY_ENABLE = yes # Audio control and System control
41#NKRO_ENABLE = yes # USB Nkey Rollover 40#NKRO_ENABLE = yes # USB Nkey Rollover
42 41
diff --git a/converter/adb_usb/README b/converter/adb_usb/README.md
index 5d0e1bc86..a41d84ebb 100644
--- a/converter/adb_usb/README
+++ b/converter/adb_usb/README.md
@@ -1,34 +1,39 @@
1ADB to USB keyboard converter 1ADB to USB keyboard converter
2============================= 2=============================
3http://geekhack.org/showwiki.php?title=Island:14290
4
5This firmware converts ADB keyboard protocol to USB. 3This firmware converts ADB keyboard protocol to USB.
4You can use PJRC Teensy for this converter, though, other USB AVR(ATMega32U4, AT90USB64/128 or etc) should work.
5But binary size is about 10KB or more it doesn't fit into 8K flash like ATMega8U2.
6
7Discuss: http://geekhack.org/showwiki.php?title=Island:14290
6 8
7 9
8Build 10Build
9----- 11-----
100. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data). 120. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data). By default Data line uses port F0.
11 You need a external pull-up resistor on DATA line in most case, 13 This converter uses AVR's internal pull-up, but it seems to be too weak, in particular when you want to use a long or coiled cable.
12 in particular when you want to use a long or coiled cable. 14 The external pull-up resistor(1K-10K Ohm) on Data is strongly recommended.
13 This converter uses AVR's internal pull-up, but it seems to be too weak. 151. Define following macros for ADB connection in config.h if you use other than port F0.
14 The external pull-up resistor is strongly recommended. 16 ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT
15 PSW line is optional. See ADB.txt for details.
161. Define following macros for ADB connection in config.h:
17 ADB_PORT
18 ADB_PIN
19 ADB_DDR
20 ADB_DATA_BIT
21 ADB_PSW_BIT
222. make 172. make
233. program Teensy. 183. program Teensy
19
20
21LOCKING CAPSLOCK
22----------------
23Many old ADB keyboards have mechanical push-lock switch for Capslock key. This converter support the locking Capslock key by default.
24This feature will prevent you from remaping as normal key. You can disable the feature by *commenting out* a macro in config.h like this:
25
26 //#define MATRIX_HAS_LOCKING_CAPS
27
28Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch.
29http://www.youtube.com/watch?v=9wqnt2mGJ2Y
24 30
25 31
26Keymap 32Keymap
27------ 33------
28You can change a keymap by editing code of keymap.c like following. 34You can change a keymap by editing code of keymap.c like following.
29This is a keymap for AEK, however, also used for other keyboards. 35This is a keymap for AEK, however, also used for other keyboards.
30How to define the keymap is probably obvious. You can find key 36How to define the keymap is probably obvious. You can find key symbols in usb_keycodes.h.
31symbols in usb_keycodes.h.
32If you want to define some keymaps than just one, see hhkb/keymap.c and 37If you want to define some keymaps than just one, see hhkb/keymap.c and
33macway/keymap.c as examples. Keymap(layer) switching may needs a bit of 38macway/keymap.c as examples. Keymap(layer) switching may needs a bit of
34effort at this time. 39effort at this time.
@@ -59,6 +64,11 @@ effort at this time.
59 ), 64 ),
60 65
61 66
67Magic command
68-------------
69To get help press `h` holding Magic key. Magic key is `Power key`.
70
71
62Notes 72Notes
63----- 73-----
64Many ADB keyboards has no discrimination between right modifier and left one, 74Many ADB keyboards has no discrimination between right modifier and left one,
@@ -66,5 +76,6 @@ you will always see left control even if you press right control key.
66Apple Extended Keyboard and Apple Extended Keyboard II are the examples. 76Apple Extended Keyboard and Apple Extended Keyboard II are the examples.
67Though ADB protocol itsef has the ability of distinction between right and left. 77Though ADB protocol itsef has the ability of distinction between right and left.
68And most ADB keyboard has no NKRO functionality, though ADB protocol itsef has that. 78And most ADB keyboard has no NKRO functionality, though ADB protocol itsef has that.
79See protocol/adb.c for more info.
69 80
70EOF 81EOF
diff --git a/converter/adb_usb/config.h b/converter/adb_usb/config.h
index 52d5925a5..875c48ce8 100644
--- a/converter/adb_usb/config.h
+++ b/converter/adb_usb/config.h
@@ -35,12 +35,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
35/* Locking Caps Lock support */ 35/* Locking Caps Lock support */
36#define MATRIX_HAS_LOCKING_CAPS 36#define MATRIX_HAS_LOCKING_CAPS
37 37
38 38#define MATRIX_ROW(code) ((code)>>3&0x0F)
39/* key combination for command */ 39#define MATRIX_COL(code) ((code)&0x07)
40#define IS_COMMAND() ( \
41 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_LCTRL) | MOD_BIT(KB_LALT) | MOD_BIT(KB_LGUI)) || \
42 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) \
43)
44 40
45 41
46/* mouse keys */ 42/* mouse keys */
@@ -49,19 +45,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
49#endif 45#endif
50 46
51 47
52/* PS/2 mouse */
53#ifdef PS2_MOUSE_ENABLE
54# define PS2_CLOCK_PORT PORTF
55# define PS2_CLOCK_PIN PINF
56# define PS2_CLOCK_DDR DDRF
57# define PS2_CLOCK_BIT 0
58# define PS2_DATA_PORT PORTF
59# define PS2_DATA_PIN PINF
60# define PS2_DATA_DDR DDRF
61# define PS2_DATA_BIT 1
62#endif
63
64
65/* ADB port setting */ 48/* ADB port setting */
66#define ADB_PORT PORTF 49#define ADB_PORT PORTF
67#define ADB_PIN PINF 50#define ADB_PIN PINF
@@ -69,4 +52,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
69#define ADB_DATA_BIT 0 52#define ADB_DATA_BIT 0
70//#define ADB_PSW_BIT 1 // optional 53//#define ADB_PSW_BIT 1 // optional
71 54
55/* key combination for command */
56#include "adb.h"
57#define IS_COMMAND() ( \
58 matrix_is_on(MATRIX_ROW(ADB_POWER), MATRIX_COL(ADB_POWER)) \
59)
60
72#endif 61#endif
diff --git a/converter/adb_usb/keymap.c b/converter/adb_usb/keymap.c
index 2d1657933..c6827f1d5 100644
--- a/converter/adb_usb/keymap.c
+++ b/converter/adb_usb/keymap.c
@@ -96,7 +96,7 @@ static const uint8_t PROGMEM fn_layer[] = {
96// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. 96// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
97// See layer.c for details. 97// See layer.c for details.
98static const uint8_t PROGMEM fn_keycode[] = { 98static const uint8_t PROGMEM fn_keycode[] = {
99 KB_NO, // Fn0 99 KB_BSLS, // Fn0
100 KB_NO, // Fn1 100 KB_NO, // Fn1
101 KB_NO, // Fn2 101 KB_NO, // Fn2
102 KB_NO, // Fn3 102 KB_NO, // Fn3
@@ -109,7 +109,7 @@ static const uint8_t PROGMEM fn_keycode[] = {
109static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 109static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
110 /* Default Layer: plain keymap 110 /* Default Layer: plain keymap
111 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. 111 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
112 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Fn0| 112 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
113 * `---' `---------------' `---------------' `---------------' `-----------' `---' 113 * `---' `---------------' `---------------' `---------------' `-----------' `---'
114 * ,-----------------------------------------------------------. ,-----------. ,---------------. 114 * ,-----------------------------------------------------------. ,-----------. ,---------------.
115 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| 115 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *|
@@ -124,9 +124,9 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
124 * `-----------------------------------------------------------' `-----------' `---------------' 124 * `-----------------------------------------------------------' `-----------' `---------------'
125 */ 125 */
126 KEYMAP( 126 KEYMAP(
127 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, FN0, 127 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO,
128 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, 128 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST,
129 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS, 129 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,FN0, DEL, END, PGDN, P7, P8, P9, PMNS,
130 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, 130 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
131 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, 131 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
132 LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT 132 LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT
@@ -134,12 +134,12 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
134 134
135 /* Default Layer: plain keymap 135 /* Default Layer: plain keymap
136 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. 136 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
137 * |` | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Fn0| 137 * |` | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
138 * `---' `---------------' `---------------' `---------------' `-----------' `---' 138 * `---' `---------------' `---------------' `---------------' `-----------' `---'
139 * ,-----------------------------------------------------------. ,-----------. ,---------------. 139 * ,-----------------------------------------------------------. ,-----------. ,---------------.
140 * |Esc|F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Delete | |Ins|Hom|PgU| |NmL|Mb1|Mb2|Mb3| 140 * |Esc|F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Delete | |Ins|Hom|PgU| |NmL|Mb1|Mb2|Mb3|
141 * |-----------------------------------------------------------| |-----------| |---------------| 141 * |-----------------------------------------------------------| |-----------| |---------------|
142 * |Tab | Q| W| E| R| T| Y| U|PrS|ScL|Pau|Up |Ins| \| |Del|End|PgD| |MwD|McU|MwU|MwD| 142 * |Tab | Q| W| E| R| T| Y| U|PrS|ScL|Pau|Up |Ins| Fn0| |Del|End|PgD| |MwD|McU|MwU|MwD|
143 * |-----------------------------------------------------------| `-----------' |---------------| 143 * |-----------------------------------------------------------| `-----------' |---------------|
144 * |CapsLo|VoD|VoU|Mut| F| G| H| J|Hom|PgU|Lef|Rig|Return | |McL|McD|McR|MwU| 144 * |CapsLo|VoD|VoU|Mut| F| G| H| J|Hom|PgU|Lef|Rig|Return | |McL|McD|McR|MwU|
145 * |-----------------------------------------------------------| ,---. |---------------| 145 * |-----------------------------------------------------------| ,---. |---------------|
@@ -149,9 +149,9 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
149 * `-----------------------------------------------------------' `-----------' `---------------' 149 * `-----------------------------------------------------------' `-----------' `---------------'
150 */ 150 */
151 KEYMAP( 151 KEYMAP(
152 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, FN0, 152 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO,
153 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3, 153 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3,
154 TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, BSLS, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_D, 154 TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, FN0, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_D,
155 CAPS,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U, 155 CAPS,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U,
156 LSFT,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R, 156 LSFT,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R,
157 LCTL,LGUI,LALT, SPC, HOME,PGDN,END, BTN1, BTN2,BTN3 157 LCTL,LGUI,LALT, SPC, HOME,PGDN,END, BTN1, BTN2,BTN3
diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c
index 4d1b9e9aa..18e71aa49 100644
--- a/converter/adb_usb/matrix.c
+++ b/converter/adb_usb/matrix.c
@@ -38,27 +38,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
38# error "MATRIX_ROWS must not exceed 255" 38# error "MATRIX_ROWS must not exceed 255"
39#endif 39#endif
40 40
41#define CAPS 0x39 41#define ADB_CAPS_UP (ADB_CAPS | 0x80)
42#define CAPS_UP (CAPS | 0x80)
43#define ROW(key) ((key)>>3&0x0F)
44#define COL(key) ((key)&0x07)
45 42
46 43
47static bool _matrix_is_modified = false; 44static bool is_modified = false;
48 45
49// matrix state buffer(1:on, 0:off) 46// matrix state buffer(1:on, 0:off)
50#if (MATRIX_COLS <= 8) 47#if (MATRIX_COLS <= 8)
51static uint8_t *matrix; 48static uint8_t matrix[MATRIX_ROWS];
52static uint8_t _matrix0[MATRIX_ROWS];
53#else 49#else
54static uint16_t *matrix; 50static uint16_t matrix[MATRIX_ROWS];
55static uint16_t _matrix0[MATRIX_ROWS];
56#endif 51#endif
57 52
58#ifdef MATRIX_HAS_GHOST 53#ifdef MATRIX_HAS_GHOST
59static bool matrix_has_ghost_in_row(uint8_t row); 54static bool matrix_has_ghost_in_row(uint8_t row);
60#endif 55#endif
61static void _register_key(uint8_t key); 56static void register_key(uint8_t key);
62 57
63 58
64inline 59inline
@@ -78,8 +73,7 @@ void matrix_init(void)
78 adb_host_init(); 73 adb_host_init();
79 74
80 // initialize matrix state: all keys off 75 // initialize matrix state: all keys off
81 for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; 76 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
82 matrix = _matrix0;
83 77
84 print_enable = true; 78 print_enable = true;
85 debug_enable = true; 79 debug_enable = true;
@@ -95,48 +89,53 @@ uint8_t matrix_scan(void)
95 uint16_t codes; 89 uint16_t codes;
96 uint8_t key0, key1; 90 uint8_t key0, key1;
97 91
98 _matrix_is_modified = false; 92 is_modified = false;
99 codes = adb_host_kbd_recv(); 93 codes = adb_host_kbd_recv();
100 key0 = codes>>8; 94 key0 = codes>>8;
101 key1 = codes&0xFF; 95 key1 = codes&0xFF;
102 96
103 if (debug_enable && codes) { 97 if (debug_matrix && codes) {
104 print("adb_host_kbd_recv: "); phex16(codes); print("\n"); 98 print("adb_host_kbd_recv: "); phex16(codes); print("\n");
105 } 99 }
106 100
107#ifdef MATRIX_HAS_LOCKING_CAPS 101#ifdef MATRIX_HAS_LOCKING_CAPS
108 // Send Caps key up event 102 // Send Caps key up event
109 if (matrix_is_on(ROW(CAPS), COL(CAPS))) { 103 if (matrix_is_on(MATRIX_ROW(ADB_CAPS), MATRIX_COL(ADB_CAPS))) {
110 _matrix_is_modified = true; 104 register_key(ADB_CAPS_UP);
111 _register_key(CAPS_UP);
112 } 105 }
113#endif 106#endif
114 if (codes == 0) { // no keys 107 if (codes == 0) { // no keys
115 return 0; 108 return 0;
116 } else if (key0 == 0xFF && key1 != 0xFF) { // error 109 } else if (codes == 0x7F7F) { // power key press
117 return codes&0xFF; 110 register_key(0x7F);
111 } else if (codes == 0xFFFF) { // power key release
112 register_key(0xFF);
113 } else if (key0 == 0xFF) { // error
114 if (debug_matrix) print("adb_host_kbd_recv: ERROR(matrix cleared.)\n");
115 // clear matrix to unregister all keys
116 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
117 return key1;
118 } else { 118 } else {
119#ifdef MATRIX_HAS_LOCKING_CAPS 119#ifdef MATRIX_HAS_LOCKING_CAPS
120 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { 120 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
121 // Ignore LockingCaps key down event when CAPS LOCK is on 121 // Ignore LockingCaps key down event when CAPS LOCK is on
122 if (key0 == CAPS && (key1 == CAPS || key1 == 0xFF)) return 0; 122 if (key0 == ADB_CAPS && (key1 == ADB_CAPS || key1 == 0xFF)) return 0;
123 if (key0 == CAPS) key0 = key1; 123 if (key0 == ADB_CAPS) key0 = key1;
124 if (key1 == CAPS) key1 = 0xFF; 124 if (key1 == ADB_CAPS) key1 = 0xFF;
125 // Convert LockingCaps key up event into down event 125 // Convert LockingCaps key up event into down event
126 if (key0 == CAPS_UP) key0 = CAPS; 126 if (key0 == ADB_CAPS_UP) key0 = ADB_CAPS;
127 if (key1 == CAPS_UP) key1 = CAPS; 127 if (key1 == ADB_CAPS_UP) key1 = ADB_CAPS;
128 } else { 128 } else {
129 // CAPS LOCK off: 129 // ADB_CAPS LOCK off:
130 // Ignore LockingCaps key up event when CAPS LOCK is off 130 // Ignore LockingCaps key up event when ADB_CAPS LOCK is off
131 if (key0 == CAPS_UP && (key1 == CAPS_UP || key1 == 0xFF)) return 0; 131 if (key0 == ADB_CAPS_UP && (key1 == ADB_CAPS_UP || key1 == 0xFF)) return 0;
132 if (key0 == CAPS_UP) key0 = key1; 132 if (key0 == ADB_CAPS_UP) key0 = key1;
133 if (key1 == CAPS_UP) key1 = 0xFF; 133 if (key1 == ADB_CAPS_UP) key1 = 0xFF;
134 } 134 }
135#endif 135#endif
136 _matrix_is_modified = true; 136 register_key(key0);
137 _register_key(key0);
138 if (key1 != 0xFF) // key1 is 0xFF when no second key. 137 if (key1 != 0xFF) // key1 is 0xFF when no second key.
139 _register_key(key1); 138 register_key(key1);
140 } 139 }
141 140
142 return 1; 141 return 1;
@@ -144,7 +143,7 @@ uint8_t matrix_scan(void)
144 143
145bool matrix_is_modified(void) 144bool matrix_is_modified(void)
146{ 145{
147 return _matrix_is_modified; 146 return is_modified;
148} 147}
149 148
150inline 149inline
@@ -177,6 +176,7 @@ uint16_t matrix_get_row(uint8_t row)
177 176
178void matrix_print(void) 177void matrix_print(void)
179{ 178{
179 if (!debug_matrix) return;
180#if (MATRIX_COLS <= 8) 180#if (MATRIX_COLS <= 8)
181 print("r/c 01234567\n"); 181 print("r/c 01234567\n");
182#else 182#else
@@ -229,7 +229,7 @@ static bool matrix_has_ghost_in_row(uint8_t row)
229#endif 229#endif
230 230
231inline 231inline
232static void _register_key(uint8_t key) 232static void register_key(uint8_t key)
233{ 233{
234 uint8_t col, row; 234 uint8_t col, row;
235 col = key&0x07; 235 col = key&0x07;
@@ -239,4 +239,5 @@ static void _register_key(uint8_t key)
239 } else { 239 } else {
240 matrix[row] |= (1<<col); 240 matrix[row] |= (1<<col);
241 } 241 }
242 is_modified = true;
242} 243}
diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile
index 1278a74be..0c6442374 100644
--- a/converter/ps2_usb/Makefile
+++ b/converter/ps2_usb/Makefile
@@ -1,10 +1,5 @@
1#
2# Makefile for PJRC Teensy
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_pjrc 2TARGET = ps2_usb
8 3
9# Directory common source filess exist 4# Directory common source filess exist
10TOP_DIR = ../.. 5TOP_DIR = ../..
@@ -12,14 +7,6 @@ TOP_DIR = ../..
12# Directory keyboard dependent files exist 7# Directory keyboard dependent files exist
13TARGET_DIR = . 8TARGET_DIR = .
14 9
15# keyboard dependent files
16SRC = keymap.c \
17 matrix.c \
18 led.c \
19 ps2.c
20
21CONFIG_H = config_pjrc.h
22
23 10
24# MCU name, you MUST set this to match the board you are using 11# MCU name, you MUST set this to match the board you are using
25# type "make clean" after changing this, so all files will be rebuilt 12# type "make clean" after changing this, so all files will be rebuilt
@@ -44,6 +31,33 @@ MOUSEKEY_ENABLE = yes # Mouse keys
44EXTRAKEY_ENABLE = yes # Audio control and System control 31EXTRAKEY_ENABLE = yes # Audio control and System control
45NKRO_ENABLE = yes # USB Nkey Rollover 32NKRO_ENABLE = yes # USB Nkey Rollover
46 33
34PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
35#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
36#PS2_USE_BUSYWAIT = yes # uses primitive reference code
37
38
39# keyboard dependent files
40SRC = keymap.c \
41 matrix.c \
42 led.c
43
44
45ifdef PS2_USE_USART
46 SRC += protocol/ps2_usart.c
47 OPT_DEFS += -DPS2_USE_USART
48endif
49ifdef PS2_USE_INT
50 SRC += protocol/ps2.c
51 OPT_DEFS += -DPS2_USE_INT
52endif
53ifdef PS2_USE_BUSYWAIT
54 SRC += protocol/ps2.c
55 OPT_DEFS += -DPS2_USE_BUSYWAIT
56endif
57
58
59#CONFIG_H = config_pjrc_usart.h
60CONFIG_H = config.h
47 61
48 62
49#---------------- Programming Options -------------------------- 63#---------------- Programming Options --------------------------
diff --git a/converter/ps2_usb/Makefile.pjrc_usart b/converter/ps2_usb/Makefile.jis
index dd74712e4..4e091e8e2 100644
--- a/converter/ps2_usb/Makefile.pjrc_usart
+++ b/converter/ps2_usb/Makefile.jis
@@ -1,10 +1,5 @@
1#
2# Makefile for PJRC Teensy
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_pjrc_usart 2TARGET = ps2_usb_jis
8 3
9# Directory common source filess exist 4# Directory common source filess exist
10TOP_DIR = ../.. 5TOP_DIR = ../..
@@ -12,14 +7,6 @@ TOP_DIR = ../..
12# Directory keyboard dependent files exist 7# Directory keyboard dependent files exist
13TARGET_DIR = . 8TARGET_DIR = .
14 9
15# keyboard dependent files
16SRC = keymap.c \
17 matrix.c \
18 led.c \
19 ps2_usart.c
20
21CONFIG_H = config_pjrc_usart.h
22
23 10
24# MCU name, you MUST set this to match the board you are using 11# MCU name, you MUST set this to match the board you are using
25# type "make clean" after changing this, so all files will be rebuilt 12# type "make clean" after changing this, so all files will be rebuilt
@@ -44,6 +31,33 @@ MOUSEKEY_ENABLE = yes # Mouse keys
44EXTRAKEY_ENABLE = yes # Audio control and System control 31EXTRAKEY_ENABLE = yes # Audio control and System control
45NKRO_ENABLE = yes # USB Nkey Rollover 32NKRO_ENABLE = yes # USB Nkey Rollover
46 33
34#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
35#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
36PS2_USE_BUSYWAIT = yes # uses primitive reference code
37
38
39# keyboard dependent files
40SRC = keymap_jis.c \
41 matrix.c \
42 led.c
43
44
45ifdef PS2_USE_USART
46 SRC += protocol/ps2_usart.c
47 OPT_DEFS += -DPS2_USE_USART
48endif
49ifdef PS2_USE_INT
50 SRC += protocol/ps2.c
51 OPT_DEFS += -DPS2_USE_INT
52endif
53ifdef PS2_USE_BUSYWAIT
54 SRC += protocol/ps2.c
55 OPT_DEFS += -DPS2_USE_BUSYWAIT
56endif
57
58
59#CONFIG_H = config_pjrc_usart.h
60CONFIG_H = config.h
47 61
48 62
49#---------------- Programming Options -------------------------- 63#---------------- Programming Options --------------------------
diff --git a/converter/ps2_usb/Makefile.vusb b/converter/ps2_usb/Makefile.vusb
index b08d30d57..d449e1e40 100644
--- a/converter/ps2_usb/Makefile.vusb
+++ b/converter/ps2_usb/Makefile.vusb
@@ -1,8 +1,3 @@
1#
2# Makefile for V-USB
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_vusb 2TARGET = ps2_usb_vusb
8 3
@@ -15,15 +10,18 @@ TARGET_DIR = .
15# keyboard dependent files 10# keyboard dependent files
16SRC = keymap.c \ 11SRC = keymap.c \
17 matrix.c \ 12 matrix.c \
18 led.c \ 13 led.c
19 ps2_usart.c 14
15# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful.
16SRC += protocol/ps2_usart.c
17OPT_DEFS += -DPS2_USE_USART
20 18
21CONFIG_H = config_vusb.h 19CONFIG_H = config.h
22 20
23 21
24# V-USB debug level: To use ps2_usart.c level must be 0 22# V-USB debug level: To use ps2_usart.c level must be 0
25# ps2_usart.c requires USART to receive PS/2 signal. 23# ps2_usart.c requires USART to receive PS/2 signal.
26OPT_DEFS = -DDEBUG_LEVEL=0 24OPT_DEFS += -DDEBUG_LEVEL=0
27 25
28 26
29# MCU name, you MUST set this to match the board you are using 27# MCU name, you MUST set this to match the board you are using
diff --git a/converter/ps2_usb/README b/converter/ps2_usb/README
index c10393e5e..cb7ba5555 100644
--- a/converter/ps2_usb/README
+++ b/converter/ps2_usb/README
@@ -1,7 +1,7 @@
1PS/2 to USB keyboard converter 1PS/2 to USB keyboard converter
2============================== 2==============================
3This firmware converts PS/2 keyboard protocol to USB and for now supports only Scan Code Set 2. 3This firmware converts PS/2 keyboard protocol to USB and supports only Scan Code Set 2.
4This will works on USB AVR(ATMega32U4, AT90USB) or V-USB. 4This will works on USB AVR(ATMega32U4, AT90USB) or V-USB(ATMega168, 328...).
5 5
6 6
7Features 7Features
@@ -19,25 +19,29 @@ Keymap customization
19PS/2 signal handling implementations 19PS/2 signal handling implementations
20------------------------------------ 20------------------------------------
21Following three methods are used to implement PS/2 signal handling. 21Following three methods are used to implement PS/2 signal handling.
22a. Simple and stupid wait & read loop(intensive use of cycles) 22a. Simple and stupid busy-wait(ps2.c)
23 This is implemented with (expected) portable C code for reference. See ps2.c. 23 This is expected to implemented with portable C code for reference.
24b. Interrupt driven 24b. Interrupt driven(ps2.c)
25 See ps2_intr.c 25 Uses external interrupt to detect falling edge of clock line.
26c. Using USART hardware module(no cycle needed) 26c. USART hardware module(ps2_usart.c)
27 This uses AVR USART function to recevie PS/2 signal and be used in V-USB converter. 27 Uses AVR USART engine to recevie PS/2 signal. Recomended and default.
28 See ps2_usart.c. 28 This is required to work with V-USB, preceding two methods tend to
29 29 miss signal edges while V-USB handles USB.
30 30
31Build Converter 31To select method edit Makefile.
32--------------- 32
33Connect PS/2 keyboard into Teensy with 4 lines(Vcc, GND, Data, Clock). 33
34For a. Simple and stupid and b. Interrupt implementaion: 34Connect Wires
35 By default Clock is on PF0 and Data on PF1. 35-------------
36 You can change this pin configuration by editing config_pjrc.h. 36In case of Teensy2.0(ATMega32U4):
37 In this photo Vcc is yellow, GND is green, Data is red and Clock is black. 370. Connect Vcc and GND.
38 http://img17.imageshack.us/img17/7243/201101181933.jpg 381. Connect Clock and Data line.
39For c. USART implementation: 39 For a. Clock is on PF0 and Data on PF1.
40 In case of Teensny(ATMega32u4) CLock is on PD5 and Data on PD2. 40 For b. Clock is on PD1 and Data on PD2.
41 For c. Clock is on PD5 and Data on PD2.
422. Optionally you need pull-up register. 1K-10K Ohm is OK.
43
44To change pin configuration edit config.h.
41 45
42 46
43Build Frimware 47Build Frimware
@@ -45,12 +49,12 @@ Build Frimware
451. Edit Makefile for build options and MCU setting. 491. Edit Makefile for build options and MCU setting.
46 Use 'atmega32u4' for Teensy 2.0 or 'at90usb1286' for Teensy++ 2.0. 50 Use 'atmega32u4' for Teensy 2.0 or 'at90usb1286' for Teensy++ 2.0.
472. make 512. make
48 Just type 'make' in a terminal. 52 Just type `make` in a terminal.
49 Use '-f Makefile.pjrc_intr' option to use b. Interrupt. 53 Use `-f Makefile.vusb` option to build V-USB converter.
50 Use '-f Makefile.pjrc_usart' option to use c. USART. 54 Use `-f Makefile.jis` option to use JIS keyboard.
51 Use '-f Makefile.vusb' option to build V-USB converter. 553. program MCU.
523. program with Teensy Loader. 56 In case of Teensy use `Teensy Loader`.(http://www.pjrc.com/teensy/loader.html)
53 http://www.pjrc.com/teensy/loader.html 57 Otherwise you want to use `avrdude` or `dfu-programmer`.
54 58
55 59
56Demonstration of Features 60Demonstration of Features
@@ -83,34 +87,36 @@ Fn layer function:
83 87
84Keymap 88Keymap
85------ 89------
86You can change a keymap by editing code of keymap.c like following. 90You can change a keymap by editing code of keymap. See common/keycode.h for key symbols.
87How to define the keymap is probably obvious. You can find key symbols in usb_keycodes.h. 91
88To define keymap layer switching may needs a bit of your effort at this time. 92
89 93V-USB Support
90 /* Default Layer: plain keymap 94-------------
91 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. 95You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
92 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| 96The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
93 * `---' `---------------' `---------------' `---------------' `-----------' `-----------' 97
94 * ,-----------------------------------------------------------. ,-----------. ,---------------. 98Circuit
95 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| 99-------
96 * |-----------------------------------------------------------| |-----------| |---------------| 100 +---+ +---------------+
97 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | 101USB GND | | ATmega168 |
98 * |-----------------------------------------------------------| `-----------' |-----------| +| 102=== C3 | |
99 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | 1035V <-------+--------+---|Vcc,AVCC | PS/2
100 * |-----------------------------------------------------------| ,---. |---------------| 104 R1 | | ====
101 * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | 105D- <----+--+-----R2-----|INT1 RXD|------->DATA
102 * |-----------------------------------------------------------| ,-----------. |-----------|Ent| 106D+ <----|---+----R3-----|INT0 XCK|------->CLOCK
103 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | 107 Z1 Z2 | | ->5V
104 * `-----------------------------------------------------------' `-----------' `---------------' 108GND<----+---+--+--+-----|GND | ->GND
105 */ 109 | | | |
106 KEYMAP( 110 | C2-+--|XTAL1 |
107 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, 111 | X1 | |
108 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, 112 +--C3-+--|XTAL2 |
109 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, 113 +---------------+
110 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, 114R1: 1.5K Ohm
111 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, 115R2,R3: 68 Ohm
112 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT 116Z1,Z2: Zenner 3.6V
113 ), 117C1,C2: 22pF
118C3: 0.1uF
119X1: Crystal 20MHz(16MHz/12MHz)
114 120
115 121
116EOF 122EOF
diff --git a/converter/ps2_usb/README.vusb b/converter/ps2_usb/README.vusb
deleted file mode 100644
index c92871bcd..000000000
--- a/converter/ps2_usb/README.vusb
+++ /dev/null
@@ -1,37 +0,0 @@
1V-USB Support
2=============
3You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
4The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
5
6To build a firmware use Makefile.vusb instead of Makefile.
7
8
9Circuit
10-------
11 +---+ +---------------+
12USB GND | | ATmega168 |
13=== C3 | |
145V <-------+--------+---|Vcc,AVCC | PS/2
15 R1 | | ====
16D- <----+--+-----R2-----|INT1 RXD|------->DATA
17D+ <----|---+----R3-----|INT0 XCK|------->CLOCK
18 Z1 Z2 | | ->5V
19GND<----+---+--+--+-----|GND | ->GND
20 | | | |
21 | C2-+--|XTAL1 |
22 | X1 | |
23 +--C3-+--|XTAL2 |
24 +---------------+
25R1: 1.5K Ohm
26R2,R3: 68 Ohm
27Z1,Z2: Zenner 3.6V
28C1,C2: 22pF
29C3: 0.1uF
30X1: Crystal 20MHz(16MHz/12MHz)
31
32
33This is my V-USB converter on breadboard.
34[IMG]http://i.imgur.com/8jJCZl.jpg[/IMG]
35
36
37EOF
diff --git a/converter/ps2_usb/config_vusb.h b/converter/ps2_usb/config.h
index afd2f7911..e5d37e429 100644
--- a/converter/ps2_usb/config_vusb.h
+++ b/converter/ps2_usb/config.h
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2012 Jun Wako <wakojun@gmail.com>
3 3
4This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -18,11 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef CONFIG_H 18#ifndef CONFIG_H
19#define CONFIG_H 19#define CONFIG_H
20 20
21#include <avr/interrupt.h>
22/* controller configuration */
23#include "controller_teensy.h"
21 24
22#define VENDOR_ID 0xFEED 25#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x2233 26#define PRODUCT_ID 0x6512
24// TODO: share these strings with usbconfig.h
25// Edit usbconfig.h to change these.
26#define MANUFACTURER t.m.k. 27#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter 28#define PRODUCT PS/2 keyboard converter
28#define DESCRIPTION convert PS/2 keyboard to USB 29#define DESCRIPTION convert PS/2 keyboard to USB
@@ -46,30 +47,62 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
46#endif 47#endif
47 48
48 49
49/* PS/2 lines */ 50#ifdef PS2_USE_USART
51#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
52/* XCK for clock line and RXD for data line */
50#define PS2_CLOCK_PORT PORTD 53#define PS2_CLOCK_PORT PORTD
51#define PS2_CLOCK_PIN PIND 54#define PS2_CLOCK_PIN PIND
52#define PS2_CLOCK_DDR DDRD 55#define PS2_CLOCK_DDR DDRD
53#define PS2_CLOCK_BIT 4 56#define PS2_CLOCK_BIT 5
54#define PS2_DATA_PORT PORTD 57#define PS2_DATA_PORT PORTD
55#define PS2_DATA_PIN PIND 58#define PS2_DATA_PIN PIND
56#define PS2_DATA_DDR DDRD 59#define PS2_DATA_DDR DDRD
57#define PS2_DATA_BIT 0 60#define PS2_DATA_BIT 2
58 61
62/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
63/* set DDR of CLOCK as input to be slave */
64#define PS2_USART_INIT() do { \
65 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
66 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
67 UCSR1C = ((1 << UMSEL10) | \
68 (3 << UPM10) | \
69 (0 << USBS1) | \
70 (3 << UCSZ10) | \
71 (0 << UCPOL1)); \
72 UCSR1A = 0; \
73 UBRR1H = 0; \
74 UBRR1L = 0; \
75} while (0)
76#define PS2_USART_RX_INT_ON() do { \
77 UCSR1B = ((1 << RXCIE1) | \
78 (1 << RXEN1)); \
79} while (0)
80#define PS2_USART_RX_POLL_ON() do { \
81 UCSR1B = (1 << RXEN1); \
82} while (0)
83#define PS2_USART_OFF() do { \
84 UCSR1C = 0; \
85 UCSR1B &= ~((1 << RXEN1) | \
86 (1 << TXEN1)); \
87} while (0)
88#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
89#define PS2_USART_RX_DATA UDR1
90#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
91#define PS2_USART_RX_VECT USART1_RX_vect
59 92
60// Synchronous USART is used to receive data from keyboard. 93#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
61// Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK. 94/* XCK for clock line and RXD for data line */
62// NOTE: This is recomended strongly if you use V-USB library. 95#define PS2_CLOCK_PORT PORTD
63#define PS2_USE_USART 96#define PS2_CLOCK_PIN PIND
64 97#define PS2_CLOCK_DDR DDRD
65// External or Pin Change Interrupt is used to receive data from keyboard. 98#define PS2_CLOCK_BIT 4
66// Use INT1 or PCINTxx for PS/2 CLOCK line. see below. 99#define PS2_DATA_PORT PORTD
67//#define PS2_USE_INT 100#define PS2_DATA_PIN PIND
68 101#define PS2_DATA_DDR DDRD
102#define PS2_DATA_BIT 0
69 103
70#ifdef PS2_USE_USART 104/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
71// synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge 105/* set DDR of CLOCK as input to be slave */
72// set DDR of CLOCK as input to be slave
73#define PS2_USART_INIT() do { \ 106#define PS2_USART_INIT() do { \
74 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ 107 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
75 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ 108 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
@@ -99,10 +132,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
99#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0))) 132#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0)))
100#define PS2_USART_RX_VECT USART_RX_vect 133#define PS2_USART_RX_VECT USART_RX_vect
101#endif 134#endif
135#endif
102 136
103 137
104#ifdef PS2_USE_INT 138#ifdef PS2_USE_INT
105/* INT1 139/* uses INT1 for clock line(ATMega32U4) */
140#define PS2_CLOCK_PORT PORTD
141#define PS2_CLOCK_PIN PIND
142#define PS2_CLOCK_DDR DDRD
143#define PS2_CLOCK_BIT 1
144#define PS2_DATA_PORT PORTD
145#define PS2_DATA_PIN PIND
146#define PS2_DATA_DDR DDRD
147#define PS2_DATA_BIT 2
148
106#define PS2_INT_INIT() do { \ 149#define PS2_INT_INIT() do { \
107 EICRA |= ((1<<ISC11) | \ 150 EICRA |= ((1<<ISC11) | \
108 (0<<ISC10)); \ 151 (0<<ISC10)); \
@@ -114,20 +157,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
114 EIMSK &= ~(1<<INT1); \ 157 EIMSK &= ~(1<<INT1); \
115} while (0) 158} while (0)
116#define PS2_INT_VECT INT1_vect 159#define PS2_INT_VECT INT1_vect
117*/ 160#endif
118 161
119/* PCINT20 */ 162
120#define PS2_INT_INIT() do { \ 163#ifdef PS2_USE_BUSYWAIT
121 PCICR |= (1<<PCIE2); \ 164#define PS2_CLOCK_PORT PORTF
122} while (0) 165#define PS2_CLOCK_PIN PINF
123#define PS2_INT_ON() do { \ 166#define PS2_CLOCK_DDR DDRF
124 PCMSK2 |= (1<<PCINT20); \ 167#define PS2_CLOCK_BIT 0
125} while (0) 168#define PS2_DATA_PORT PORTF
126#define PS2_INT_OFF() do { \ 169#define PS2_DATA_PIN PINF
127 PCMSK2 &= ~(1<<PCINT20); \ 170#define PS2_DATA_DDR DDRF
128 PCICR &= ~(1<<PCIE2); \ 171#define PS2_DATA_BIT 1
129} while (0)
130#define PS2_INT_VECT PCINT2_vect
131#endif 172#endif
132 173
133#endif 174#endif
diff --git a/converter/ps2_usb/config_pjrc.h b/converter/ps2_usb/config_pjrc.h
deleted file mode 100644
index 883ffab27..000000000
--- a/converter/ps2_usb/config_pjrc.h
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21/* controller configuration */
22#include "controller_teensy.h"
23
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6512
26#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter
28#define DESCRIPTION convert PS/2 keyboard to USB
29
30
31/* matrix size */
32#define MATRIX_ROWS 32 // keycode bit: 3-0
33#define MATRIX_COLS 8 // keycode bit: 6-4
34
35
36/* key combination for command */
37#define IS_COMMAND() ( \
38 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) || \
39 keyboard_report->mods == (MOD_BIT(KB_LCTRL) | MOD_BIT(KB_RSHIFT)) \
40)
41
42
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48
49/* PS/2 lines */
50#define PS2_CLOCK_PORT PORTF
51#define PS2_CLOCK_PIN PINF
52#define PS2_CLOCK_DDR DDRF
53#define PS2_CLOCK_BIT 0
54#define PS2_DATA_PORT PORTF
55#define PS2_DATA_PIN PINF
56#define PS2_DATA_DDR DDRF
57#define PS2_DATA_BIT 1
58
59#endif
diff --git a/converter/ps2_usb/config_pjrc_usart.h b/converter/ps2_usb/config_pjrc_usart.h
deleted file mode 100644
index 83ddbf770..000000000
--- a/converter/ps2_usb/config_pjrc_usart.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21/* controller configuration */
22#include "controller_teensy.h"
23
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6513
26#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter(USART)
28#define DESCRIPTION convert PS/2 keyboard to USB
29
30
31/* matrix size */
32#define MATRIX_ROWS 32 // keycode bit: 3-0
33#define MATRIX_COLS 8 // keycode bit: 6-4
34
35
36/* key combination for command */
37#define IS_COMMAND() ( \
38 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) || \
39 keyboard_report->mods == (MOD_BIT(KB_LCTRL) | MOD_BIT(KB_RSHIFT)) \
40)
41
42
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48
49/* PS/2 lines */
50#define PS2_CLOCK_PORT PORTD
51#define PS2_CLOCK_PIN PIND
52#define PS2_CLOCK_DDR DDRD
53#define PS2_CLOCK_BIT 5
54#define PS2_DATA_PORT PORTD
55#define PS2_DATA_PIN PIND
56#define PS2_DATA_DDR DDRD
57#define PS2_DATA_BIT 2
58
59
60// synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge
61// set DDR of CLOCK as input to be slave
62#define PS2_USART_INIT() do { \
63 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
64 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
65 UCSR1C = ((1 << UMSEL10) | \
66 (3 << UPM10) | \
67 (0 << USBS1) | \
68 (3 << UCSZ10) | \
69 (0 << UCPOL1)); \
70 UCSR1A = 0; \
71 UBRR1H = 0; \
72 UBRR1L = 0; \
73} while (0)
74#define PS2_USART_RX_INT_ON() do { \
75 UCSR1B = ((1 << RXCIE1) | \
76 (1 << RXEN1)); \
77} while (0)
78#define PS2_USART_RX_POLL_ON() do { \
79 UCSR1B = (1 << RXEN1); \
80} while (0)
81#define PS2_USART_OFF() do { \
82 UCSR1C = 0; \
83 UCSR1B &= ~((1 << RXEN1) | \
84 (1 << TXEN1)); \
85} while (0)
86#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
87#define PS2_USART_RX_DATA UDR1
88#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
89#define PS2_USART_RX_VECT USART1_RX_vect
90
91#endif
diff --git a/converter/ps2_usb/keymap_jis.c b/converter/ps2_usb/keymap_jis.c
new file mode 100644
index 000000000..787c9558a
--- /dev/null
+++ b/converter/ps2_usb/keymap_jis.c
@@ -0,0 +1,297 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * Keymap for PS/2 keyboard
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <avr/pgmspace.h>
24#include "usb_keycodes.h"
25#include "print.h"
26#include "debug.h"
27#include "util.h"
28#include "keymap.h"
29
30
31
32
33// Following macros help you to define a keymap with the form of actual keyboard layout.
34
35/* US layout plus all other various keys */
36#define KEYMAP_ALL( \
37 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
38 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
39 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
40 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
41 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
42 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
43 \
44 K61, /* for European ISO */ \
45 K51, K13, K6A, K64, K67, /* for Japanese JIS */ \
46 K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \
47 KB7, KBF, KDE, /* System Power, Sleep, Wake */ \
48 KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \
49 KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \
50 KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \
51 K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \
52 KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \
53) { \
54 { KB_NO, KB_##K01, KB_NO, KB_##K03, KB_##K04, KB_##K05, KB_##K06, KB_##K07 }, \
55 { KB_##K08, KB_##K09, KB_##K0A, KB_##K0B, KB_##K0C, KB_##K0D, KB_##K0E, KB_NO }, \
56 { KB_##K10, KB_##K11, KB_##K12, KB_##K13, KB_##K14, KB_##K15, KB_##K16, KB_NO }, \
57 { KB_##K18, KB_NO, KB_##K1A, KB_##K1B, KB_##K1C, KB_##K1D, KB_##K1E, KB_NO }, \
58 { KB_##K20, KB_##K21, KB_##K22, KB_##K23, KB_##K24, KB_##K25, KB_##K26, KB_NO }, \
59 { KB_##K28, KB_##K29, KB_##K2A, KB_##K2B, KB_##K2C, KB_##K2D, KB_##K2E, KB_NO }, \
60 { KB_##K30, KB_##K31, KB_##K32, KB_##K33, KB_##K34, KB_##K35, KB_##K36, KB_NO }, \
61 { KB_##K38, KB_NO, KB_##K3A, KB_##K3B, KB_##K3C, KB_##K3D, KB_##K3E, KB_NO }, \
62 { KB_##K40, KB_##K41, KB_##K42, KB_##K43, KB_##K44, KB_##K45, KB_##K46, KB_NO }, \
63 { KB_##K48, KB_##K49, KB_##K4A, KB_##K4B, KB_##K4C, KB_##K4D, KB_##K4E, KB_NO }, \
64 { KB_##K50, KB_##K51, KB_##K52, KB_NO, KB_##K54, KB_##K55, KB_NO, KB_##K57 }, \
65 { KB_##K58, KB_##K59, KB_##K5A, KB_##K5B, KB_NO, KB_##K5D, KB_NO, KB_##K5F }, \
66 { KB_NO, KB_##K61, KB_NO, KB_NO, KB_##K64, KB_NO, KB_##K66, KB_##K67 }, \
67 { KB_NO, KB_##K69, KB_##K6A, KB_##K6B, KB_##K6C, KB_NO, KB_NO, KB_NO }, \
68 { KB_##K70, KB_##K71, KB_##K72, KB_##K73, KB_##K74, KB_##K75, KB_##K76, KB_##K77 }, \
69 { KB_##K78, KB_##K79, KB_##K7A, KB_##K7B, KB_##K7C, KB_##K7D, KB_##K7E, KB_NO }, \
70 { KB_NO, KB_NO, KB_NO, KB_##K83, KB_NO, KB_NO, KB_NO, KB_NO }, \
71 { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
72 { KB_##K90, KB_##K91, KB_NO, KB_NO, KB_##K94, KB_##K95, KB_NO, KB_NO }, \
73 { KB_##K98, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##K9F }, \
74 { KB_##KA0, KB_##KA1, KB_NO, KB_##KA3, KB_NO, KB_NO, KB_NO, KB_##KA7 }, \
75 { KB_##KA8, KB_NO, KB_NO, KB_##KAB, KB_NO, KB_NO, KB_NO, KB_##KAF }, \
76 { KB_##KB0, KB_NO, KB_##KB2, KB_NO, KB_##KB4, KB_NO, KB_NO, KB_##KB7 }, \
77 { KB_##KB8, KB_NO, KB_##KBA, KB_##KBB, KB_NO, KB_NO, KB_NO, KB_##KBF }, \
78 { KB_##KC0, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
79 { KB_##KC8, KB_NO, KB_##KCA, KB_NO, KB_NO, KB_##KCD, KB_NO, KB_NO }, \
80 { KB_##KD0, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
81 { KB_NO, KB_NO, KB_##KDA, KB_NO, KB_NO, KB_NO, KB_##KDE, KB_NO }, \
82 { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
83 { KB_NO, KB_##KE9, KB_NO, KB_##KEB, KB_##KEC, KB_NO, KB_NO, KB_NO }, \
84 { KB_##KF0, KB_##KF1, KB_##KF2, KB_NO, KB_##KF4, KB_##KF5, KB_NO, KB_NO }, \
85 { KB_NO, KB_NO, KB_##KFA, KB_NO, KB_##KFC, KB_##KFD, KB_##KFE, KB_NO }, \
86}
87
88/* JIS layout */
89#define KEYMAP_JIS( \
90 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
91 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
92 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
93 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
94 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
95 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
96) \
97KEYMAP_ALL( \
98 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
99 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
100 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
101 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
102 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
103 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
104 \
105 NUBS, \
106 K51, K13, K6A, K64, K67, \
107 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
108 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
109 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
110 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
111 MAIL, CALCULATOR, MY_COMPUTER, \
112 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
113 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
114)
115
116#define KEYMAP_JIS_COMPACT( \
117 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, \
118 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, \
119 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, \
120 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, \
121 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94 \
122) \
123KEYMAP_ALL( \
124 ESC,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10,F11,F12, PSCR,SLCK,BRK, \
125 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
126 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, DEL, END, PGDN, P7, P8, P9, \
127 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, P4, P5, P6, PPLS, \
128 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, UP, P1, P2, P3, \
129 K14,K9F,K11, K29, K91,KA7,KAF,K94, LEFT,DOWN,RGHT, P0, PDOT,PENT, \
130 \
131 NUBS, \
132 K51, K13, K6A, K64, K67, \
133 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
134 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
135 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
136 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
137 MAIL, CALCULATOR, MY_COMPUTER, \
138 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
139 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
140)
141
142
143// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
144static const uint8_t PROGMEM fn_layer[] = {
145 1, // Fn0
146 2, // Fn1
147 1, // Fn2
148 2, // Fn3
149 3, // Fn4
150 4, // Fn5
151 0, // Fn6
152 0 // Fn7
153};
154
155// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
156// See layer.c for details.
157static const uint8_t PROGMEM fn_keycode[] = {
158 KB_SCLN, // Fn0
159 KB_SLSH, // Fn1
160 KB_BSPC, // Fn2
161 KB_NO, // Fn3
162 KB_NO, // Fn4
163 KB_SPC, // Fn5
164 KB_NO, // Fn6
165 KB_NO // Fn7
166};
167
168
169// The keymap is a 32*8 byte array which convert a PS/2 scan code into a USB keycode.
170// See usb_keycodes.h for USB keycodes. You should omit a 'KB_' prefix of USB keycodes in keymap macro.
171// Use KEYMAP_ISO() or KEYMAP_JIS() instead of KEYMAP() if your keyboard is ISO or JIS.
172static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
173 /* 0: JIS LAYOUT
174 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
175 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak|
176 * `---' `---------------' `---------------' `---------------' `-----------' `-----------'
177 * ,-----------------------------------------------------------. ,-----------. ,---------------.
178 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| JY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
179 * |-----------------------------------------------------------| |-----------| |---------------|
180 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Ret | |Del|End|PgD| | 7| 8| 9| |
181 * |------------------------------------------------------` | `-----------' |-----------| +|
182 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| :| \| | | 4| 5| 6| |
183 * |-----------------------------------------------------------| ,---. |---------------|
184 * |Shift | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3| |
185 * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
186 * |Ctrl |Gui |Alt |MHEN| Space |HENK|KANA|Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| |
187 * `-----------------------------------------------------------' `-----------' `---------------'
188 */
189/*
190 KEYMAP_JIS(
191 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
192 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
193 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, END, PGDN, P7, P8, P9,
194 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS, ENT, P4, P5, P6, PPLS,
195 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, RSFT, UP, P1, P2, P3,
196 LCTL,LGUI,LALT, MHEN,SPC, HENK,KANA, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
197 ),
198*/
199 /* 0: HHKB-wise
200 * ,-----------------------------------------------------------.
201 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
202 * |-----------------------------------------------------------|
203 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Bsp |
204 * |------------------------------------------------------` |
205 * |Ctrl | A| S| D| F| G| H| J| K| L| ;| :|Ret| |
206 * |-----------------------------------------------------------|
207 * |Shift | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift |
208 * |-----------------------------------------------------------|
209 * |Ctrl |Gui |Alt |MHEN| Space |HENK|KANA|Alt |Gui |Menu|Ctrl|
210 * `-----------------------------------------------------------'
211 */
212 KEYMAP_JIS_COMPACT(
213 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC,
214 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,
215 LCTL,A, S, D, F, G, H, J, K, L, FN0, QUOT,GRV, ENT,
216 LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, FN4,
217 LCTL,LGUI,LALT, LALT,FN5, FN2, FN3, RALT,RGUI,APP, LGUI
218 ),
219
220 /* 1: Mouse keys
221 * ,-----------------------------------------------------------.
222 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
223 * |-----------------------------------------------------------|
224 * |Tab |MwL|MwU|McU|WwU|WwR|MwL|MwD|MwU|MwR| | | | \|
225 * |-----------------------------------------------------------|
226 * |CapsLo| |McL|McD|McR| |McL|McD|McU|McR|Fn0| |Return |
227 * |-----------------------------------------------------------|
228 * |Shift |VoD|VoU|Mut|Mb2|Mb3|Mb2|Mb1|VoD|VoU|Mut|Shift |
229 * |-----------------------------------------------------------|
230 * |Ctrl |Gui |Alt | Mb1 |Alt |Gui |Menu|Ctrl|
231 * `-----------------------------------------------------------'
232 * Mc = mouse cursor, Mw = mouse wheel, Mb = mouse button
233 * Vo = Volume, Mut = Mute
234 */
235 KEYMAP_JIS_COMPACT(
236 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
237 TAB, WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO,
238 LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, NO, ENT,
239 LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,BTN2,BTN3,NO, RSFT, RSFT,
240 LCTL,LGUI,LALT, LALT,BTN1,FN2, RALT, RALT,RGUI,APP, LGUI
241 ),
242
243 /* 2: Cursor keys
244 * ,-----------------------------------------------------------.
245 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
246 * |-----------------------------------------------------------|
247 * |Tab |Hom|PgU| Up|PgU|End|Hom|PgD|PgU|End| | | | \|
248 * |-----------------------------------------------------------|
249 * |CapsLo| |Lef|Dow|Rig| |Lef|Dow| Up|Rig| | |Return |
250 * |-----------------------------------------------------------|
251 * |Shift | | | | | |Hom|PgD|PgU|End|Fn1|Shift |
252 * |-----------------------------------------------------------|
253 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
254 * `-----------------------------------------------------------'
255 */
256 KEYMAP_JIS_COMPACT(
257 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
258 TAB, HOME,PGUP,UP, PGDN,END, HOME,PGDN,PGUP,END, NO, NO, NO,
259 LCTL,HOME,LEFT,DOWN,RGHT,END, LEFT,DOWN,UP, RGHT,NO, NO, NO, ENT,
260 LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN1, RSFT, RSFT,
261 LCTL,LGUI,LALT, LALT,BTN1,BSPC,FN3, RALT,RGUI,APP, LGUI
262 ),
263
264 /* 3: HHKB Fn layer */
265 KEYMAP_JIS_COMPACT(
266 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
267 CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO,
268 LCTL,VOLD,VOLU,MUTE,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT,NO, ENT,
269 LSFT,NO, NO, NO, NO, NO, NO, NO, END, PGDN,DOWN,RSFT, FN4,
270 LCTL,LGUI,LALT, LALT,SPC, BSPC,NO, RALT,RGUI,APP, LGUI
271 ),
272
273 /* 4: Number */
274 KEYMAP_JIS_COMPACT(
275 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
276 TAB, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
277 LCTL,1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, ENT,
278 LSFT,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, RSFT, RSFT,
279 LCTL,LGUI,LALT, LALT,FN5, BSPC,NO, RALT,RGUI,APP, LGUI
280 ),
281};
282
283
284uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
285{
286 return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
287}
288
289uint8_t keymap_fn_layer(uint8_t fn_bits)
290{
291 return pgm_read_byte(&fn_layer[biton(fn_bits)]);
292}
293
294uint8_t keymap_fn_keycode(uint8_t fn_bits)
295{
296 return pgm_read_byte(&fn_keycode[(biton(fn_bits))]);
297}
diff --git a/converter/ps2_usb/usbconfig.h b/converter/ps2_usb/usbconfig.h
index 9038f1eb8..d0ca4c717 100644
--- a/converter/ps2_usb/usbconfig.h
+++ b/converter/ps2_usb/usbconfig.h
@@ -11,7 +11,6 @@
11#ifndef __usbconfig_h_included__ 11#ifndef __usbconfig_h_included__
12#define __usbconfig_h_included__ 12#define __usbconfig_h_included__
13 13
14#include "config_vusb.h"
15 14
16/* 15/*
17General Description: 16General Description:
diff --git a/protocol/adb.c b/protocol/adb.c
index d60b8608b..d7105b3a9 100644
--- a/protocol/adb.c
+++ b/protocol/adb.c
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
38#include <stdbool.h> 38#include <stdbool.h>
39#include <util/delay.h> 39#include <util/delay.h>
40#include <avr/io.h> 40#include <avr/io.h>
41#include <avr/interrupt.h>
41#include "adb.h" 42#include "adb.h"
42 43
43 44
@@ -85,8 +86,13 @@ uint16_t adb_host_kbd_recv(void)
85 return 0; // No data to send 86 return 0; // No data to send
86 if (!read_bit()) // Startbit(1) 87 if (!read_bit()) // Startbit(1)
87 return -2; 88 return -2;
89
90 // ad hoc fix: without block inerrupt read wrong bit occasionally and get keys stuck
91 cli();
88 data = read_byte(); 92 data = read_byte();
89 data = (data<<8) | read_byte(); 93 data = (data<<8) | read_byte();
94 sei();
95
90 if (read_bit()) // Stopbit(0) 96 if (read_bit()) // Stopbit(0)
91 return -3; 97 return -3;
92 return data; 98 return data;
diff --git a/protocol/adb.h b/protocol/adb.h
index 177f41394..1e4ca4013 100644
--- a/protocol/adb.h
+++ b/protocol/adb.h
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
38#ifndef ADB_H 38#ifndef ADB_H
39#define ADB_H 39#define ADB_H
40 40
41#include <stdint.h>
41#include <stdbool.h> 42#include <stdbool.h>
42 43
43#if !(defined(ADB_PORT) && \ 44#if !(defined(ADB_PORT) && \
@@ -47,6 +48,10 @@ POSSIBILITY OF SUCH DAMAGE.
47# error "ADB port setting is required in config.h" 48# error "ADB port setting is required in config.h"
48#endif 49#endif
49 50
51#define ADB_POWER 0x7F
52#define ADB_CAPS 0x39
53
54
50// ADB host 55// ADB host
51void adb_host_init(void); 56void adb_host_init(void);
52bool adb_host_psw(void); 57bool adb_host_psw(void);
diff --git a/protocol/ps2.c b/protocol/ps2.c
index 8a0591621..cf7b1f43c 100644
--- a/protocol/ps2.c
+++ b/protocol/ps2.c
@@ -89,8 +89,9 @@ uint8_t ps2_error = PS2_ERR_NONE;
89 89
90void ps2_host_init(void) 90void ps2_host_init(void)
91{ 91{
92#ifdef PS2_INT_ENABLE 92#ifdef PS2_USE_INT
93 PS2_INT_ENABLE(); 93 PS2_INT_INIT();
94 PS2_INT_ON();
94 idle(); 95 idle();
95#else 96#else
96 inhibit(); 97 inhibit();
@@ -103,8 +104,8 @@ uint8_t ps2_host_send(uint8_t data)
103 uint8_t res = 0; 104 uint8_t res = 0;
104 bool parity = true; 105 bool parity = true;
105 ps2_error = PS2_ERR_NONE; 106 ps2_error = PS2_ERR_NONE;
106#ifdef PS2_INT_DISABLE 107#ifdef PS2_USE_INT
107 PS2_INT_DISABLE(); 108 PS2_INT_OFF();
108#endif 109#endif
109 /* terminate a transmission if we have */ 110 /* terminate a transmission if we have */
110 inhibit(); 111 inhibit();
@@ -144,8 +145,8 @@ uint8_t ps2_host_send(uint8_t data)
144 145
145 res = ps2_host_recv_response(); 146 res = ps2_host_recv_response();
146ERROR: 147ERROR:
147#ifdef PS2_INT_ENABLE 148#ifdef PS2_USE_INT
148 PS2_INT_ENABLE(); 149 PS2_INT_ON();
149 idle(); 150 idle();
150#else 151#else
151 inhibit(); 152 inhibit();
@@ -173,7 +174,7 @@ uint8_t ps2_host_recv_response(void)
173 return data; 174 return data;
174} 175}
175 176
176#ifndef PS2_INT_VECT 177#ifndef PS2_USE_INT
177uint8_t ps2_host_recv(void) 178uint8_t ps2_host_recv(void)
178{ 179{
179 return ps2_host_recv_response(); 180 return ps2_host_recv_response();