]> git.gir.st - tmk_keyboard.git/blob - adb/keymap.c
ADB to USB keyboard converter
[tmk_keyboard.git] / adb / keymap.c
1 /*
2 * Keymap for ADB keyboard
3 */
4 #include <stdint.h>
5 #include <stdbool.h>
6 #include <avr/pgmspace.h>
7 #include "usb_keyboard.h"
8 #include "usb_keycodes.h"
9 #include "print.h"
10 #include "debug.h"
11 #include "util.h"
12 #include "keymap_skel.h"
13
14
15 // Convert physical keyboard layout to matrix array.
16 // This is a macro to define keymap easily in keyboard layout form.
17
18 // TODO: ADB to USB default keymap
19 // TODO: keymap macro template for m0116/m0115
20 /* Apple Keyboard m0116
21 K7F, \
22 K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, K47, K51, K4B, K43, \
23 K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, K59, K5B, K5C, K4E, \
24 K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, K56, K57, K58, K45, \
25 K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, K53, K54, K55, \
26 K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E, K52, K41, K4C \
27 */
28
29 /* no tenkey
30 K7F, \
31 K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, \
32 K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, \
33 K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, \
34 K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, \
35 K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E \
36 */
37 #define KEYMAP( \
38 K7F, \
39 K35, K12, K13, K14, K15, K17, K16, K1A, K1C, K19, K1D, K1B, K18, K33, \
40 K30, K0C, K0D, K0E, K0F, K10, K11, K20, K22, K1F, K23, K21, K1E, \
41 K36, K00, K01, K02, K03, K05, K04, K26, K28, K25, K29, K27, K24, \
42 K38, K06, K07, K08, K09, K0B, K2D, K2E, K2B, K2F, K2C, K7B, \
43 K39, K3A, K37, K32, K31, K2A, K3B, K3C, K3D, K3E \
44 ) { \
45 { K00, K01, K02, K03, K04, K05, K06, K07 }, \
46 { K08, K09, 000, K0B, K0C, K0D, K0E, K0F }, \
47 { K10, K11, K12, K13, K14, K15, K16, K17 }, \
48 { K18, K19, K1A, K1B, K1C, K1D, K1E, K1F }, \
49 { K20, K21, K22, K23, K24, K25, K26, K27 }, \
50 { K28, K29, K2A, K2B, K2C, K2D, K2E, K2F }, \
51 { K30, K31, K32, K33, 000, K35, K36, K37 }, \
52 { K38, K39, K3A, K3B, K3C, K3D, K3E, 000 }, \
53 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
54 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
55 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
56 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
57 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
58 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
59 { 000, 000, 000, 000, 000, 000, 000, 000 }, \
60 { 000, 000, 000, K7B, 000, 000, 000, K7F }, \
61 }
62
63 #define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
64
65
66 // Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
67 static const uint8_t PROGMEM fn_layer[] = {
68 0, // FN_0
69 0, // FN_1
70 0, // FN_2
71 0, // FN_3
72 0, // FN_4
73 0, // FN_5
74 0, // FN_6
75 0 // FN_7
76 };
77
78 // Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
79 // See layer.c for details.
80 static const uint8_t PROGMEM fn_keycode[] = {
81 KB_NO, // FN_0
82 KB_NO, // FN_1
83 KB_NO, // FN_2
84 KB_NO, // FN_3
85 KB_NO, // FN_4
86 KB_NO, // FN_5
87 KB_NO, // FN_6
88 KB_NO // FN_7
89 };
90
91 static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
92 /* Layer 0: Default Layer
93 * ,---------------------------------------------------------.
94 * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs|
95 * |---------------------------------------------------------|
96 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
97 * |-----------------------------------------------------' |
98 * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return|
99 * |---------------------------------------------------------|
100 * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
101 * |---------------------------------------------------------|
102 * |Shi|Alt|Gui l `| | \|Lef|Rig|Dow|Up |
103 * `---------------------------------------------------------'
104 */
105 KEYMAP(KB_PWR, \
106 KB_ESC, KB_1, KB_2, KB_3, KB_4, KB_5, KB_6, KB_7, KB_8, KB_9, KB_0, KB_MINS,KB_EQL, KB_BSPC, \
107 KB_TAB, KB_Q, KB_W, KB_E, KB_R, KB_T, KB_Y, KB_U, KB_I, KB_O, KB_P, KB_LBRC,KB_RBRC, \
108 KB_LCTL,KB_A, KB_S, KB_D, KB_F, KB_G, KB_H, KB_J, KB_K, KB_L, KB_SCLN,KB_QUOT,KB_ENT, \
109 KB_LSFT,KB_Z, KB_X, KB_C, KB_V, KB_B, KB_N, KB_M, KB_COMM,KB_DOT, KB_SLSH,KB_RSFT, \
110 KB_LSFT,KB_LALT,KB_LGUI,KB_GRV, KB_SPC, KB_BSLS,KB_LEFT,KB_RGHT,KB_DOWN,KB_UP),
111
112 };
113
114
115 uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
116 {
117 return KEYCODE(layer, row, col);
118 }
119
120 uint8_t keymap_fn_layer(uint8_t fn_bits)
121 {
122 return pgm_read_byte(&fn_layer[biton(fn_bits)]);
123 }
124
125 uint8_t keymap_fn_keycode(uint8_t fn_bits)
126 {
127 return pgm_read_byte(&fn_keycode[(biton(fn_bits))]);
128 }
129
130 // define a condition to enter special function mode
131 bool keymap_is_special_mode(uint8_t fn_bits)
132 {
133 //return (usb_keyboard_mods == (BIT_LCTRL | BIT_LSHIFT | BIT_LALT | BIT_LGUI));
134 return (usb_keyboard_mods == (BIT_RSHIFT));
135 }
Imprint / Impressum