Skip to content

Commit

Permalink
Add ISO keymap(issue #35) and use new keymap API
Browse files Browse the repository at this point in the history
  • Loading branch information
yashikno committed May 20, 2014
1 parent abe5edc commit ed8cf12
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 128 deletions.
8 changes: 7 additions & 1 deletion converter/adb_usb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ TOP_DIR = ../..
TARGET_DIR = .

# project specific files
SRC = keymap.c \
SRC = keymap_common.c \
matrix.c \
led.c \
adb.c

ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_ansi.c $(SRC)
endif

CONFIG_H = config.h


Expand Down
8 changes: 7 additions & 1 deletion converter/adb_usb/Makefile.pjrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ TOP_DIR = ../..
TARGET_DIR = .

# keyboard dependent files
SRC = keymap.c \
SRC = keymap_common.c \
matrix.c \
led.c \
adb.c

ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_ansi.c $(SRC)
endif

CONFIG_H = config.h


Expand Down
38 changes: 28 additions & 10 deletions converter/adb_usb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,29 @@ 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


Build
-----
0. Connect ADB keyboard to Teensy by 3 lines(Vcc, GND, Data). By default Data line uses port D0.
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 D0.
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


Build
-----
Just make

$ make clean
$ make

If your keyboard is ISO layout

$ 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.
Expand Down Expand Up @@ -48,7 +60,7 @@ effort at this time.
* |-----------------------------------------------------------| ,---. |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
* |Ctrl |Gui |Alt | Space | | | | |Lef|Dow|Rig| | 0| .| |
* |Ctrl |Alt |Gui | Space |Gui |Alt |Ctrl | |Lef|Dow|Rig| | 0| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
*/
KEYMAP(
Expand All @@ -68,11 +80,17 @@ 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,
Not-extended ADB keyboards have no discrimination between right modifier and left one,
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 itself has the ability of distinction between right and left.
And most ADB keyboard has no NKRO functionality, though ADB protocol itself has that.
See protocol/adb.c for more info.
Apple Extended Keyboard and Apple Extended Keyboard II can discriminate both side
modifiers except for GUI key(Windows/Command).

And most ADB keyboard has no diodes in its matrix so they are not NKRO,
though ADB protocol itself supports it. See protocol/adb.c for more info.

If keyobard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI
keymap you will suffer from swapped keys problem.

https://github.com/tmk/tmk_keyboard/issues/35

EOF
16 changes: 16 additions & 0 deletions converter/adb_usb/keymap_ansi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "keymap_common.h"


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,
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,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
};

const uint16_t PROGMEM fn_actions[] = {
};
30 changes: 30 additions & 0 deletions converter/adb_usb/keymap_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "keymap_common.h"


/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}

/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}
Loading

0 comments on commit ed8cf12

Please sign in to comment.