summaryrefslogtreecommitdiff
path: root/converter/adb_usb
diff options
context:
space:
mode:
Diffstat (limited to 'converter/adb_usb')
-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
5 files changed, 80 insertions, 80 deletions
diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile
index e9a90695b1..87b0f415b8 100644
--- a/converter/adb_usb/Makefile
+++ b/converter/adb_usb/Makefile
@@ -35,8 +35,7 @@ F_CPU = 16000000
# Build Options
# comment out to disable the options.
#
-MOUSEKEY_ENABLE = yes # Mouse keys
-#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
+#MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
#NKRO_ENABLE = yes # USB Nkey Rollover
diff --git a/converter/adb_usb/README b/converter/adb_usb/README.md
index 5d0e1bc86b..a41d84ebb0 100644
--- a/converter/adb_usb/README
+++ b/converter/adb_usb/README.md
@@ -1,34 +1,39 @@
ADB to USB keyboard converter
=============================
-http://geekhack.org/showwiki.php?title=Island:14290
-
This firmware converts ADB keyboard protocol to USB.
+You can use PJRC Teensy for this converter, though, other USB AVR(ATMega32U4, AT90USB64/128 or etc) should work.
+But binary size is about 10KB or more it doesn't fit into 8K flash like ATMega8U2.
+
+Discuss: http://geekhack.org/showwiki.php?title=Island:14290
Build
-----
-0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data).
- You need a external pull-up resistor on DATA line in most case,
- in particular when you want to use a long or coiled cable.
- This converter uses AVR's internal pull-up, but it seems to be too weak.
- The external pull-up resistor is strongly recommended.
- PSW line is optional. See ADB.txt for details.
-1. Define following macros for ADB connection in config.h:
- ADB_PORT
- ADB_PIN
- ADB_DDR
- ADB_DATA_BIT
- ADB_PSW_BIT
+0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data). By default Data line uses port F0.
+ 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.
+ The external pull-up resistor(1K-10K Ohm) on Data is strongly recommended.
+1. Define following macros for ADB connection in config.h if you use other than port F0.
+ ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT
2. make
-3. program Teensy.
+3. program Teensy
+
+
+LOCKING CAPSLOCK
+----------------
+Many old ADB keyboards have mechanical push-lock switch for Capslock key. This converter support the locking Capslock key by default.
+This feature will prevent you from remaping as normal key. You can disable the feature by *commenting out* a macro in config.h like this:
+
+ //#define MATRIX_HAS_LOCKING_CAPS
+
+Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch.
+http://www.youtube.com/watch?v=9wqnt2mGJ2Y
Keymap
------
You can change a keymap by editing code of keymap.c like following.
This is a keymap for AEK, however, also used for other keyboards.
-How to define the keymap is probably obvious. You can find key
-symbols in usb_keycodes.h.
+How to define the keymap is probably obvious. You can find key symbols in usb_keycodes.h.
If you want to define some keymaps than just one, see hhkb/keymap.c and
macway/keymap.c as examples. Keymap(layer) switching may needs a bit of
effort at this time.
@@ -59,6 +64,11 @@ effort at this time.
),
+Magic command
+-------------
+To get help press `h` holding Magic key. Magic key is `Power key`.
+
+
Notes
-----
Many 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.
Apple Extended Keyboard and Apple Extended Keyboard II are the examples.
Though ADB protocol itsef has the ability of distinction between right and left.
And most ADB keyboard has no NKRO functionality, though ADB protocol itsef has that.
+See protocol/adb.c for more info.
EOF
diff --git a/converter/adb_usb/config.h b/converter/adb_usb/config.h
index 52d5925a50..875c48ce84 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/>.
/* Locking Caps Lock support */
#define MATRIX_HAS_LOCKING_CAPS
-
-/* key combination for command */
-#define IS_COMMAND() ( \
- keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_LCTRL) | MOD_BIT(KB_LALT) | MOD_BIT(KB_LGUI)) || \
- keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) \
-)
+#define MATRIX_ROW(code) ((code)>>3&0x0F)
+#define MATRIX_COL(code) ((code)&0x07)
/* mouse keys */
@@ -49,19 +45,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
-/* PS/2 mouse */
-#ifdef PS2_MOUSE_ENABLE
-# define PS2_CLOCK_PORT PORTF
-# define PS2_CLOCK_PIN PINF
-# define PS2_CLOCK_DDR DDRF
-# define PS2_CLOCK_BIT 0
-# define PS2_DATA_PORT PORTF
-# define PS2_DATA_PIN PINF
-# define PS2_DATA_DDR DDRF
-# define PS2_DATA_BIT 1
-#endif
-
-
/* ADB port setting */
#define ADB_PORT PORTF
#define ADB_PIN PINF
@@ -69,4 +52,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ADB_DATA_BIT 0
//#define ADB_PSW_BIT 1 // optional
+/* key combination for command */
+#include "adb.h"
+#define IS_COMMAND() ( \
+ matrix_is_on(MATRIX_ROW(ADB_POWER), MATRIX_COL(ADB_POWER)) \
+)
+
#endif
diff --git a/converter/adb_usb/keymap.c b/converter/adb_usb/keymap.c
index 2d16579336..c6827f1d59 100644
--- a/converter/adb_usb/keymap.c
+++ b/converter/adb_usb/keymap.c
@@ -96,7 +96,7 @@ static const uint8_t PROGMEM fn_layer[] = {
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
- KB_NO, // Fn0
+ KB_BSLS, // Fn0
KB_NO, // Fn1
KB_NO, // Fn2
KB_NO, // Fn3
@@ -109,7 +109,7 @@ static const uint8_t PROGMEM fn_keycode[] = {
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Default Layer: plain keymap
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
- * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Fn0|
+ * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|
* `---' `---------------' `---------------' `---------------' `-----------' `---'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 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] = {
* `-----------------------------------------------------------' `-----------' `---------------'
*/
KEYMAP(
- ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, FN0,
+ ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO,
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST,
- TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS,
+ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,FN0, DEL, END, PGDN, P7, P8, P9, PMNS,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, LEFT,DOWN,RGHT, P0, PDOT,PENT
@@ -134,12 +134,12 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Default Layer: plain keymap
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---.
- * |` | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Fn0|
+ * |` | |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|Delete | |Ins|Hom|PgU| |NmL|Mb1|Mb2|Mb3|
* |-----------------------------------------------------------| |-----------| |---------------|
- * |Tab | Q| W| E| R| T| Y| U|PrS|ScL|Pau|Up |Ins| \| |Del|End|PgD| |MwD|McU|MwU|MwD|
+ * |Tab | Q| W| E| R| T| Y| U|PrS|ScL|Pau|Up |Ins| Fn0| |Del|End|PgD| |MwD|McU|MwU|MwD|
* |-----------------------------------------------------------| `-----------' |---------------|
* |CapsLo|VoD|VoU|Mut| F| G| H| J|Hom|PgU|Lef|Rig|Return | |McL|McD|McR|MwU|
* |-----------------------------------------------------------| ,---. |---------------|
@@ -149,9 +149,9 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `-----------------------------------------------------------' `-----------' `---------------'
*/
KEYMAP(
- GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, FN0,
+ GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO,
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3,
- 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,
+ 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,
CAPS,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U,
LSFT,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R,
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 4d1b9e9aa5..18e71aa497 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/>.
# error "MATRIX_ROWS must not exceed 255"
#endif
-#define CAPS 0x39
-#define CAPS_UP (CAPS | 0x80)
-#define ROW(key) ((key)>>3&0x0F)
-#define COL(key) ((key)&0x07)
+#define ADB_CAPS_UP (ADB_CAPS | 0x80)
-static bool _matrix_is_modified = false;
+static bool is_modified = false;
// matrix state buffer(1:on, 0:off)
#if (MATRIX_COLS <= 8)
-static uint8_t *matrix;
-static uint8_t _matrix0[MATRIX_ROWS];
+static uint8_t matrix[MATRIX_ROWS];
#else
-static uint16_t *matrix;
-static uint16_t _matrix0[MATRIX_ROWS];
+static uint16_t matrix[MATRIX_ROWS];
#endif
#ifdef MATRIX_HAS_GHOST
static bool matrix_has_ghost_in_row(uint8_t row);
#endif
-static void _register_key(uint8_t key);
+static void register_key(uint8_t key);
inline
@@ -78,8 +73,7 @@ void matrix_init(void)
adb_host_init();
// initialize matrix state: all keys off
- for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
- matrix = _matrix0;
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
print_enable = true;
debug_enable = true;
@@ -95,48 +89,53 @@ uint8_t matrix_scan(void)
uint16_t codes;
uint8_t key0, key1;
- _matrix_is_modified = false;
+ is_modified = false;
codes = adb_host_kbd_recv();
key0 = codes>>8;
key1 = codes&0xFF;
- if (debug_enable && codes) {
+ if (debug_matrix && codes) {
print("adb_host_kbd_recv: "); phex16(codes); print("\n");
}
#ifdef MATRIX_HAS_LOCKING_CAPS
// Send Caps key up event
- if (matrix_is_on(ROW(CAPS), COL(CAPS))) {
- _matrix_is_modified = true;
- _register_key(CAPS_UP);
+ if (matrix_is_on(MATRIX_ROW(ADB_CAPS), MATRIX_COL(ADB_CAPS))) {
+ register_key(ADB_CAPS_UP);
}
#endif
if (codes == 0) { // no keys
return 0;
- } else if (key0 == 0xFF && key1 != 0xFF) { // error
- return codes&0xFF;
+ } else if (codes == 0x7F7F) { // power key press
+ register_key(0x7F);
+ } else if (codes == 0xFFFF) { // power key release
+ register_key(0xFF);
+ } else if (key0 == 0xFF) { // error
+ if (debug_matrix) print("adb_host_kbd_recv: ERROR(matrix cleared.)\n");
+ // clear matrix to unregister all keys
+ for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
+ return key1;
} else {
#ifdef MATRIX_HAS_LOCKING_CAPS
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
// Ignore LockingCaps key down event when CAPS LOCK is on
- if (key0 == CAPS && (key1 == CAPS || key1 == 0xFF)) return 0;
- if (key0 == CAPS) key0 = key1;
- if (key1 == CAPS) key1 = 0xFF;
+ if (key0 == ADB_CAPS && (key1 == ADB_CAPS || key1 == 0xFF)) return 0;
+ if (key0 == ADB_CAPS) key0 = key1;
+ if (key1 == ADB_CAPS) key1 = 0xFF;
// Convert LockingCaps key up event into down event
- if (key0 == CAPS_UP) key0 = CAPS;
- if (key1 == CAPS_UP) key1 = CAPS;
+ if (key0 == ADB_CAPS_UP) key0 = ADB_CAPS;
+ if (key1 == ADB_CAPS_UP) key1 = ADB_CAPS;
} else {
- // CAPS LOCK off:
- // Ignore LockingCaps key up event when CAPS LOCK is off
- if (key0 == CAPS_UP && (key1 == CAPS_UP || key1 == 0xFF)) return 0;
- if (key0 == CAPS_UP) key0 = key1;
- if (key1 == CAPS_UP) key1 = 0xFF;
+ // ADB_CAPS LOCK off:
+ // Ignore LockingCaps key up event when ADB_CAPS LOCK is off
+ if (key0 == ADB_CAPS_UP && (key1 == ADB_CAPS_UP || key1 == 0xFF)) return 0;
+ if (key0 == ADB_CAPS_UP) key0 = key1;
+ if (key1 == ADB_CAPS_UP) key1 = 0xFF;
}
#endif
- _matrix_is_modified = true;
- _register_key(key0);
+ register_key(key0);
if (key1 != 0xFF) // key1 is 0xFF when no second key.
- _register_key(key1);
+ register_key(key1);
}
return 1;
@@ -144,7 +143,7 @@ uint8_t matrix_scan(void)
bool matrix_is_modified(void)
{
- return _matrix_is_modified;
+ return is_modified;
}
inline
@@ -177,6 +176,7 @@ uint16_t matrix_get_row(uint8_t row)
void matrix_print(void)
{
+ if (!debug_matrix) return;
#if (MATRIX_COLS <= 8)
print("r/c 01234567\n");
#else
@@ -229,7 +229,7 @@ static bool matrix_has_ghost_in_row(uint8_t row)
#endif
inline
-static void _register_key(uint8_t key)
+static void register_key(uint8_t key)
{
uint8_t col, row;
col = key&0x07;
@@ -239,4 +239,5 @@ static void _register_key(uint8_t key)
} else {
matrix[row] |= (1<<col);
}
+ is_modified = true;
}