diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 14:52:18 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-10-27 14:52:18 -0400 |
commit | d311fd8d1a0af3b767d26b520d399bf0db22f058 (patch) | |
tree | b9de5704143ac205b4e26222f9d7551e9b161924 /converter/adb_usb | |
parent | a766918d5c48204375f4c207b30bbbf1389df14f (diff) | |
parent | 6f3141965e88c4ee0ebf7c18a243e4c2d9c5021b (diff) |
Merge pull request #34 from jackhumbert/tmk-master
merging from tmk, new_project script and template
Diffstat (limited to 'converter/adb_usb')
-rw-r--r-- | converter/adb_usb/Makefile | 16 | ||||
-rw-r--r-- | converter/adb_usb/Makefile.pjrc | 16 | ||||
-rw-r--r-- | converter/adb_usb/README.md | 105 | ||||
-rw-r--r-- | converter/adb_usb/keymap_ansi.c | 2 | ||||
-rw-r--r-- | converter/adb_usb/keymap_hasu.c | 4 | ||||
-rw-r--r-- | converter/adb_usb/keymap_iso.c | 2 | ||||
-rw-r--r-- | converter/adb_usb/matrix.c | 61 |
7 files changed, 141 insertions, 65 deletions
diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile index bbb7810eef..2369ee70ac 100644 --- a/converter/adb_usb/Makefile +++ b/converter/adb_usb/Makefile @@ -42,7 +42,7 @@ TARGET = adb_usb_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -122,6 +122,10 @@ CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #NKRO_ENABLE = yes # USB Nkey Rollover +ADB_MOUSE_ENABLE = yes + +# ADB Mice need acceleration for todays much bigger screens. +OPT_DEFS += -DADB_MOUSE_MAXACC=8 # Optimize size but this may cause error "relocation truncated to fit" @@ -129,9 +133,9 @@ COMMAND_ENABLE = yes # Commands for debug and configuration # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/adb_usb/Makefile.pjrc b/converter/adb_usb/Makefile.pjrc index 2eb41b34b4..c320c09d25 100644 --- a/converter/adb_usb/Makefile.pjrc +++ b/converter/adb_usb/Makefile.pjrc @@ -2,7 +2,7 @@ TARGET = adb_usb_pjrc # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core # Directory keyboard dependent files exist TARGET_DIR = . @@ -57,13 +57,17 @@ CONSOLE_ENABLE = yes # Console for debug COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #NKRO_ENABLE = yes # USB Nkey Rollover(+500) +ADB_MOUSE_ENABLE = yes + +# ADB Mice need acceleration for todays much bigger screens. +OPT_DEFS += -DADB_MOUSE_MAXACC=8 # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/pjrc.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/pjrc.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/adb_usb/README.md b/converter/adb_usb/README.md index 21ad318c1d..46082ff67f 100644 --- a/converter/adb_usb/README.md +++ b/converter/adb_usb/README.md @@ -7,70 +7,69 @@ But binary size is about 10KB or more it doesn't fit into 8K flash like ATMega8U Discuss: http://geekhack.org/showwiki.php?title=Island:14290 + +README FIRST +------------ +https://github.com/tmk/tmk_keyboard +https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb + +Also check these when you are in trouble. + +https://github.com/tmk/tmk_keyboard/wiki +https://github.com/tmk/tmk_keyboard/labels/NOTE + + Wiring ------ -0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data). By default Data line uses port PD0. - 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 PD0. - ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT -2. make -3. program Teensy +Connect ADB pins to controller just by 3 lines(Vcc, GND, Data). By default Data line uses port PD0. + +ADB female socket from the front: + + ,--_--. + / o4 3o \ 1: DATA + | o2 1o | 2: Power SW + - === - 3: VCC + `-___-' 4: GND + +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.(It is almost must!) +https://github.com/tmk/tmk_keyboard/wiki/FAQ#pull-up-resistor + +Pull-up resister: + + Keyboard Conveter + ,------. + 5V------+------|VCC | + | | | + [R] | | + | | | + Signal--+------|PD0 | + | | + GND------------|GND | + `------' + R: 1K Ohm resistor + + +Define following macros for ADB connection in config.h if you use other than port PD0. + + ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT Build ----- -Just make +See doc/build.md. In short, $ make clean $ make -If your keyboard is ISO layout +You can select keymap(ansi is default) like this: - $ make KEYMAP=iso - - -LOCKING CAPSLOCK ----------------- -Many of old ADB keyboards have mechanical push-lock switch for Capslock key and this converter supports the locking Capslock key by default. See README in top directory for more detail about this feature. - -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 + $ make KEYMAP=[ansi|iso|hasu] 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 keycode.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. - - /* Default Layer: plain keymap - * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. - * |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| =| /| *| - * |-----------------------------------------------------------| |-----------| |---------------| - * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| - * |-----------------------------------------------------------| `-----------' |---------------| - * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| - * |-----------------------------------------------------------| ,---. |---------------| - * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | - * |-----------------------------------------------------------| ,-----------. |-----------|Ent| - * |Ctrl |Alt |Gui | Space |Gui |Alt |Ctrl | |Lef|Dow|Rig| | 0| .| | - * `-----------------------------------------------------------' `-----------' `---------------' - */ - KEYMAP( - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, - 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, - LCAP,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 - ), +You can change a keymap by editing code of keymap_[ansi|iso|hasu|yours].c. +How to define the keymap is probably obvious. You can find key symbols in common/keycode.h. And see doc/keymap.md for more detail. Magic command @@ -78,6 +77,14 @@ Magic command To get help press `h` holding Magic key. Magic key is `Power key`. +Locking CapsLock +---------------- +Many of old ADB keyboards have mechanical push-lock switch for Capslock key and this converter supports the locking Capslock key by default. See README in top directory for more detail about this feature. +https://github.com/tmk/tmk_keyboard/blob/master/README.md#mechanical-locking-support + +Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch. + + Notes ----- Not-extended ADB keyboards have no discrimination between right modifier and left one, diff --git a/converter/adb_usb/keymap_ansi.c b/converter/adb_usb/keymap_ansi.c index 0d0bae99b5..4ea601be0a 100644 --- a/converter/adb_usb/keymap_ansi.c +++ b/converter/adb_usb/keymap_ansi.c @@ -3,7 +3,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP_EXT_ANSI( - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PWR, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS, LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, diff --git a/converter/adb_usb/keymap_hasu.c b/converter/adb_usb/keymap_hasu.c index f2e59b3e91..a0b3f1fc68 100644 --- a/converter/adb_usb/keymap_hasu.c +++ b/converter/adb_usb/keymap_hasu.c @@ -22,7 +22,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 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,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, + LCAP,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, RGUI,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT ), @@ -47,7 +47,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 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, 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, + LCAP,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, RGUI,RCTL, HOME,PGDN,END, BTN1, BTN2,BTN3 ), diff --git a/converter/adb_usb/keymap_iso.c b/converter/adb_usb/keymap_iso.c index 451d3d2c35..a1b1a5ebd3 100644 --- a/converter/adb_usb/keymap_iso.c +++ b/converter/adb_usb/keymap_iso.c @@ -3,7 +3,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KEYMAP_EXT_ISO( - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, PWR, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PEQL,PSLS,PAST, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,ENT, DEL, END, PGDN, P7, P8, P9, PMNS, LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6, PPLS, diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index 405391865f..6220ee6e1c 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -27,6 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "debug.h" #include "adb.h" #include "matrix.h" +#include "report.h" +#include "host.h" #if (MATRIX_COLS > 16) @@ -38,6 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. static bool is_modified = false; +static report_mouse_t mouse_report = {}; // matrix state buffer(1:on, 0:off) #if (MATRIX_COLS <= 8) @@ -86,6 +89,64 @@ void matrix_init(void) return; } +#ifdef ADB_MOUSE_ENABLE + +#ifdef MAX +#undef MAX +#endif +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) + +void adb_mouse_task(void) +{ + uint16_t codes; + int16_t x, y; + static int8_t mouseacc; + _delay_ms(12); // delay for preventing overload of poor ADB keyboard controller + codes = adb_host_mouse_recv(); + // If nothing received reset mouse acceleration, and quit. + if (!codes) { + mouseacc = 1; + return; + }; + // Bit sixteen is button. + if (~codes & (1 << 15)) + mouse_report.buttons |= MOUSE_BTN1; + if (codes & (1 << 15)) + mouse_report.buttons &= ~MOUSE_BTN1; + // lower seven bits are movement, as signed int_7. + // low byte is X-axis, high byte is Y. + y = (codes>>8 & 0x3F); + x = (codes>>0 & 0x3F); + // bit seven and fifteen is negative + // usb does not use int_8, but int_7 (measuring distance) with sign-bit. + if (codes & (1 << 6)) + x = (x-0x40); + if (codes & (1 << 14)) + y = (y-0x40); + // Accelerate mouse. (They weren't meant to be used on screens larger than 320x200). + x *= mouseacc; + y *= mouseacc; + // Cap our two bytes per axis to one byte. + // Easier with a MIN-function, but since -MAX(-a,-b) = MIN(a,b)... + // I.E. MIN(MAX(x,-127),127) = -MAX(-MAX(x, -127), -127) = MIN(-MIN(-x,127),127) + mouse_report.x = -MAX(-MAX(x, -127), -127); + mouse_report.y = -MAX(-MAX(y, -127), -127); + if (debug_mouse) { + print("adb_host_mouse_recv: "); print_bin16(codes); print("\n"); + print("adb_mouse raw: ["); + phex(mouseacc); print(" "); + phex(mouse_report.buttons); print("|"); + print_decs(mouse_report.x); print(" "); + print_decs(mouse_report.y); print("]\n"); + } + // Send result by usb. + host_mouse_send(&mouse_report); + // increase acceleration of mouse + mouseacc += ( mouseacc < ADB_MOUSE_MAXACC ? 1 : 0 ); + return; +} +#endif + uint8_t matrix_scan(void) { /* extra_key is volatile and more convoluted than necessary because gcc refused |