]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - converter/adb_usb/unimap_common.h
Merge remote-tracking branch 'tmk/master'
[max/tmk_keyboard.git] / converter / adb_usb / unimap_common.h
1 /*
2 Copyright 2016-19 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef UNIMAP_COMMON_H
18 #define UNIMAP_COMMON_H
19
20 #include <stdint.h>
21 #include <avr/pgmspace.h>
22 #include "unimap.h"
23
24
25 /* ADB Keyboard unified layout
26  * ,---.   .---------------. ,---------------. ,---------------. ,-----------.             ,---.
27  * |Esc|   |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|             |Pwr|
28  * `---'   `---------------' `---------------' `---------------' `-----------'             `---'
29  * ,-----------------------------------------------------------. ,-----------. ,---------------. ,---.
30  * |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backspa| |Ins|Hom|PgU| |NmL|  =|  /|  *| |VUp|
31  * |-----------------------------------------------------------| |-----------| |---------------| |---|
32  * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \| |Del|End|PgD| |  7|  8|  9|  -| |VDn|
33  * |-----------------------------------------------------------| `-----------' |---------------| |---|
34  * |CapsLo|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |               |  4|  5|  6|  +| |Mut|
35  * |-----------------------------------------------------------|     ,---.     |---------------| `---'
36  * |Shif|\  |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|Shift     |     |Up |     |  1|  2|  3|   |
37  * |-----------------------------------------------------------| ,-----------. |-----------|Ent| ,---.
38  * |Ctrl |Opt |Gui |         Space           |Gui* |Opt |Ctrl  | |Lef|Dow|Rig| |      0|  .|   | |Ply|
39  * `-----------------------------------------------------------' `-----------' `---------------' `---'
40  * NOTE: Not-extended ADB keyboards have no discrimination between left and right modifiers.
41  * Use left ones for mapping. Right modifier always sends same code as left one.
42  * Apple Extended Keyboard can discriminate the modifiers except for Command(GUI) key.
43  */
44 #define UNIMAP_ADB( \
45     K29,    K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45,      K46,K47,K48,              K73,      \
46     K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,    K2A,  K49,K4A,K4B,  K53,K54,K55,K56, K02, \
47     K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,    K31,  K4C,K4D,K4E,  K5F,K60,K61,K57, K01, \
48     K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,    K32,K28,                K5C,K5D,K5E,K66, K03, \
49     K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,        K7D,      K52,      K59,K5A,K5B,K58,      \
50     K78,K7A,K7B,            K2C,                        K7E,K7C,  K50,K51,K4F,      K62,K63,     K68  \
51 ) UNIMAP( \
52               K68, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, K73,                                           \
53     K29,      K3A, K3B, K3C, K3D, K3E, K3F, K40, K41, K42, K43, K44, K45,       K46, K47, K48,       K01, K02, K03, \
54     K35, K1E, K1F, K20, K21, K22, K23, K24, K25, K26, K27, K2D, K2E, JYEN,K2A,  K49, K4A, K4B,  K53, K54, K55, K56, \
55     K2B, K14, K1A, K08, K15, K17, K1C, K18, K0C, K12, K13, K2F, K30,      K31,  K4C, K4D, K4E,  K5F, K60, K61, K57, \
56     K39, K04, K16, K07, K09, K0A, K0B, K0D, K0E, K0F, K33, K34,      K32, K28,                  K5C, K5D, K5E, K66, \
57     K79, K64, K1D, K1B, K06, K19, K05, K11, K10, K36, K37, K38,      RO,  K7D,       K52,       K59, K5A, K5B, K58, \
58     K78, K7B, K7A, MHEN,          K2C,           HENK,KANA,K7E, RGUI,APP, K7C,  K50, K51, K4F,       K62, K63, PEQL \
59 )
60
61
62 // http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c
63 // http://opensource.apple.com//source/IOHIDFamily/IOHIDFamily-701.20.10/IOHIDFamily/Cosmo_USB2ADB.c
64 // http://m0115.web.fc2.com/m0115.jpg
65 const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
66         //  Position(unimap)        ADB scan code(matrix)
67         //  ---------------------------------------------
68         {
69             UNIMAP_A,               // 0x00
70             UNIMAP_S,               // 0x01
71             UNIMAP_D,               // 0x02
72             UNIMAP_F,               // 0x03
73             UNIMAP_H,               // 0x04
74             UNIMAP_G,               // 0x05
75             UNIMAP_Z,               // 0x06
76             UNIMAP_X,               // 0x07
77         },
78         {
79             UNIMAP_C,               // 0x08
80             UNIMAP_V,               // 0x09
81             UNIMAP_NONUS_BSLASH,    // 0x0A
82             UNIMAP_B,               // 0x0B
83             UNIMAP_Q,               // 0x0C
84             UNIMAP_W,               // 0x0D
85             UNIMAP_E,               // 0x0E
86             UNIMAP_R,               // 0x0F
87         },
88         {
89             UNIMAP_Y,               // 0x10
90             UNIMAP_T,               // 0x11
91             UNIMAP_1,               // 0x12
92             UNIMAP_2,               // 0x13
93             UNIMAP_3,               // 0x14
94             UNIMAP_4,               // 0x15
95             UNIMAP_6,               // 0x16
96             UNIMAP_5,               // 0x17
97         },
98         {
99             UNIMAP_EQUAL,           // 0x18
100             UNIMAP_9,               // 0x19
101             UNIMAP_7,               // 0x1A
102             UNIMAP_MINUS,           // 0x1B
103             UNIMAP_8,               // 0x1C
104             UNIMAP_0,               // 0x1D
105             UNIMAP_RBRACKET,        // 0x1E
106             UNIMAP_O,               // 0x1F
107         },
108         {
109             UNIMAP_U,               // 0x20
110             UNIMAP_LBRACKET,        // 0x21
111             UNIMAP_I,               // 0x22
112             UNIMAP_P,               // 0x23
113             UNIMAP_ENTER,           // 0x24
114             UNIMAP_L,               // 0x25
115             UNIMAP_J,               // 0x26
116             UNIMAP_QUOTE,           // 0x27
117         },
118         {
119             UNIMAP_K,               // 0x28
120             UNIMAP_SCOLON,          // 0x29
121             UNIMAP_BSLASH,          // 0x2A
122             UNIMAP_COMMA,           // 0x2B
123             UNIMAP_SLASH,           // 0x2C
124             UNIMAP_N,               // 0x2D
125             UNIMAP_M,               // 0x2E
126             UNIMAP_DOT,             // 0x2F
127         },
128         {
129             UNIMAP_TAB,             // 0x30
130             UNIMAP_SPACE,           // 0x31
131             UNIMAP_GRAVE,           // 0x32
132             UNIMAP_BSPACE,          // 0x33
133             UNIMAP_KP_ENTER,        // 0x34
134             UNIMAP_ESCAPE,          // 0x35
135             UNIMAP_LCTRL,           // 0x36
136             UNIMAP_LGUI,            // 0x37
137         },
138         {
139             UNIMAP_LSHIFT,          // 0x38
140             UNIMAP_CAPSLOCK,        // 0x39
141             UNIMAP_LALT,            // 0x3A
142             UNIMAP_LEFT,            // 0x3B
143             UNIMAP_RIGHT,           // 0x3C
144             UNIMAP_DOWN,            // 0x3D
145             UNIMAP_UP,              // 0x3E
146             UNIMAP_F23,             // 0x3F     FN?
147         },
148         {
149             UNIMAP_F17,             // 0x40
150             UNIMAP_KP_DOT,          // 0x41
151             UNIMAP_F13,             // 0x42     Mic(Adjustable keyboard)
152             UNIMAP_KP_MINUS,        // 0x43     ADB keypad asterisk(top right)
153             UNIMAP_NO,              // 0x44
154             UNIMAP_KP_COMMA,        // 0x45     ADB keypad plus
155             UNIMAP_NO,              // 0x46
156             UNIMAP_NUMLOCK,         // 0x47
157         },
158         {
159             UNIMAP_VOLUME_UP,       // 0x48     Vol Up(Adjustable keyboard)
160             UNIMAP_VOLUME_DOWN,     // 0x49     Vol Down(Adjustable keyboard)
161             UNIMAP_VOLUME_MUTE,     // 0x4A     Vol Mute(Adjustable keyboard)
162             UNIMAP_KP_ASTERISK,     // 0x4B     ADB keypad slash(between equal and asterisk)
163             UNIMAP_KP_ENTER,        // 0x4C
164             UNIMAP_NO,              // 0x4D
165             UNIMAP_KP_PLUS,         // 0x4E     ADB keypad minus
166             UNIMAP_F18,             // 0x4F
167         },
168         {
169             UNIMAP_F19,             // 0x50
170             UNIMAP_KP_SLASH,        // 0x51     ADB keypad equal(next to clear/numlock)
171             UNIMAP_KP_0,            // 0x52
172             UNIMAP_KP_1,            // 0x53
173             UNIMAP_KP_2,            // 0x54
174             UNIMAP_KP_3,            // 0x55
175             UNIMAP_KP_4,            // 0x56
176             UNIMAP_KP_5,            // 0x57
177         },
178         {
179             UNIMAP_KP_6,            // 0x58
180             UNIMAP_KP_7,            // 0x59
181             UNIMAP_F20,             // 0x5A
182             UNIMAP_KP_8,            // 0x5B
183             UNIMAP_KP_9,            // 0x5C
184             UNIMAP_JYEN,            // 0x5D
185             UNIMAP_RO,              // 0x5E
186             UNIMAP_KP_COMMA,        // 0x5F
187         },
188         {
189             UNIMAP_F5,              // 0x60
190             UNIMAP_F6,              // 0x61
191             UNIMAP_F7,              // 0x62
192             UNIMAP_F3,              // 0x63
193             UNIMAP_F8,              // 0x64
194             UNIMAP_F9,              // 0x65
195             UNIMAP_MHEN,            // 0x66
196             UNIMAP_F11,             // 0x67
197         },
198         {
199             UNIMAP_HENK,            // 0x68
200             UNIMAP_PSCREEN,         // 0x69
201             UNIMAP_F16,             // 0x6A
202             UNIMAP_SCROLLLOCK,      // 0x6B
203             UNIMAP_NO,              // 0x6C
204             UNIMAP_F10,             // 0x6D
205             UNIMAP_APPLICATION,     // 0x6E     compose
206             UNIMAP_F12,             // 0x6F
207         },
208         {
209             UNIMAP_NO,              // 0x70
210             UNIMAP_PAUSE,           // 0x71
211             UNIMAP_INSERT,          // 0x72
212             UNIMAP_HOME,            // 0x73
213             UNIMAP_PGUP,            // 0x74
214             UNIMAP_DELETE,          // 0x75
215             UNIMAP_F4,              // 0x76
216             UNIMAP_END,             // 0x77
217         },
218         {
219             UNIMAP_F2,              // 0x78
220             UNIMAP_PGDOWN,          // 0x79
221             UNIMAP_F1,              // 0x7A
222             UNIMAP_RSHIFT,          // 0x7B
223             UNIMAP_RALT,            // 0x7C
224             UNIMAP_RCTRL,           // 0x7D
225             UNIMAP_RGUI,            // 0x7E
226             UNIMAP_F24,             // 0x7F     power key
227         }
228 };
229
230 #endif