Skip to content

Commit 674f4c9

Browse files
committed
Separate out keymaps definitions into their own file
Signed-off-by: Andrew Gallagher <[email protected]>
1 parent 03bee4b commit 674f4c9

File tree

2 files changed

+188
-186
lines changed

2 files changed

+188
-186
lines changed

Model01-Firmware.ino

Lines changed: 2 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -93,193 +93,9 @@ enum { MACRO_VERSION_INFO,
9393
};
9494

9595

96+
// Keymaps are defined in a separate file
97+
#include "keymaps.h"
9698

97-
/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three
98-
* keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad"
99-
* keymap.
100-
*
101-
* Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built
102-
* of first the left hand's layout, followed by the right hand's layout.
103-
*
104-
* Keymaps typically consist mostly of `Key_` definitions. There are many, many keys
105-
* defined as part of the USB HID Keyboard specification. You can find the names
106-
* (if not yet the explanations) for all the standard `Key_` defintions offered by
107-
* Kaleidoscope in these files:
108-
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keyboard.h
109-
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_consumerctl.h
110-
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_sysctl.h
111-
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/kaleidoscope/key_defs_keymaps.h
112-
*
113-
* Additional things that should be documented here include
114-
* using ___ to let keypresses fall through to the previously active layer
115-
* using XXX to mark a keyswitch as 'blocked' on this layer
116-
* using ShiftToLayer() and LockLayer() keys to change the active keymap.
117-
* keeping NUM and FN consistent and accessible on all layers
118-
*
119-
* The PROG key is special, since it is how you indicate to the board that you
120-
* want to flash the firmware. However, it can be remapped to a regular key.
121-
* When the keyboard boots, it first looks to see whether the PROG key is held
122-
* down; if it is, it simply awaits further flashing instructions. If it is
123-
* not, it continues loading the rest of the firmware and the keyboard
124-
* functions normally, with whatever binding you have set to PROG. More detail
125-
* here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8
126-
*
127-
* The "keymaps" data structure is a list of the keymaps compiled into the firmware.
128-
* The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)
129-
* macros switch to key layers based on this list.
130-
*
131-
*
132-
133-
* A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held.
134-
* Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped.
135-
*/
136-
137-
/**
138-
* Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1.
139-
* The third one is layer 2.
140-
* This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
141-
* the numbers 0, 1 and 2.
142-
*
143-
*/
144-
145-
enum { PRIMARY, NUMPAD, FUNCTION }; // layers
146-
147-
148-
/**
149-
* To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line
150-
*
151-
* #define PRIMARY_KEYMAP_QWERTY
152-
*
153-
* by changing it to
154-
*
155-
* // #define PRIMARY_KEYMAP_QWERTY
156-
*
157-
* Then uncomment the line corresponding to the layout you want to use.
158-
*
159-
*/
160-
161-
#define PRIMARY_KEYMAP_QWERTY
162-
// #define PRIMARY_KEYMAP_COLEMAK
163-
// #define PRIMARY_KEYMAP_DVORAK
164-
// #define PRIMARY_KEYMAP_CUSTOM
165-
166-
167-
168-
/* This comment temporarily turns off astyle's indent enforcement
169-
* so we can make the keymaps actually resemble the physical key layout better
170-
*/
171-
// *INDENT-OFF*
172-
173-
KEYMAPS(
174-
175-
#if defined (PRIMARY_KEYMAP_QWERTY)
176-
[PRIMARY] = KEYMAP_STACKED
177-
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
178-
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
179-
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
180-
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
181-
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
182-
ShiftToLayer(FUNCTION),
183-
184-
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
185-
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
186-
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
187-
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
188-
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
189-
ShiftToLayer(FUNCTION)),
190-
191-
#elif defined (PRIMARY_KEYMAP_DVORAK)
192-
193-
[PRIMARY] = KEYMAP_STACKED
194-
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
195-
Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab,
196-
Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I,
197-
Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape,
198-
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
199-
ShiftToLayer(FUNCTION),
200-
201-
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
202-
Key_Enter, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash,
203-
Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus,
204-
Key_RightAlt, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals,
205-
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
206-
ShiftToLayer(FUNCTION)),
207-
208-
#elif defined (PRIMARY_KEYMAP_COLEMAK)
209-
210-
[PRIMARY] = KEYMAP_STACKED
211-
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
212-
Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_G, Key_Tab,
213-
Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_D,
214-
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
215-
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
216-
ShiftToLayer(FUNCTION),
217-
218-
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
219-
Key_Enter, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals,
220-
Key_H, Key_N, Key_E, Key_I, Key_O, Key_Quote,
221-
Key_RightAlt, Key_K, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
222-
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
223-
ShiftToLayer(FUNCTION)),
224-
225-
#elif defined (PRIMARY_KEYMAP_CUSTOM)
226-
// Edit this keymap to make a custom layout
227-
[PRIMARY] = KEYMAP_STACKED
228-
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
229-
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
230-
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
231-
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
232-
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
233-
ShiftToLayer(FUNCTION),
234-
235-
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
236-
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
237-
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
238-
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
239-
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
240-
ShiftToLayer(FUNCTION)),
241-
242-
#else
243-
244-
#error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch"
245-
246-
#endif
247-
248-
249-
250-
[NUMPAD] = KEYMAP_STACKED
251-
(___, ___, ___, ___, ___, ___, ___,
252-
___, ___, ___, ___, ___, ___, ___,
253-
___, ___, ___, ___, ___, ___,
254-
___, ___, ___, ___, ___, ___, ___,
255-
___, ___, ___, ___,
256-
___,
257-
258-
M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___,
259-
___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___,
260-
___, Key_1, Key_2, Key_3, Key_Equals, ___,
261-
___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
262-
___, ___, ___, ___,
263-
___),
264-
265-
[FUNCTION] = KEYMAP_STACKED
266-
(___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock,
267-
Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
268-
Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
269-
Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE,
270-
___, Key_Delete, ___, ___,
271-
___,
272-
273-
Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
274-
Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12,
275-
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
276-
Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
277-
___, ___, Key_Enter, ___,
278-
___)
279-
) // KEYMAPS(
280-
281-
/* Re-enable astyle's indent enforcement */
282-
// *INDENT-ON*
28399

284100
/** versionInfoMacro handles the 'firmware version info' macro
285101
* When a key bound to the macro is pressed, this macro

keymaps.h

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/** The Model 01's key layouts are defined as 'keymaps'. By default, there are three
2+
* keymaps: The standard QWERTY keymap, the "Function layer" keymap and the "Numpad"
3+
* keymap.
4+
*
5+
* Each keymap is defined as a list using the 'KEYMAP_STACKED' macro, built
6+
* of first the left hand's layout, followed by the right hand's layout.
7+
*
8+
* Keymaps typically consist mostly of `Key_` definitions. There are many, many keys
9+
* defined as part of the USB HID Keyboard specification. You can find the names
10+
* (if not yet the explanations) for all the standard `Key_` defintions offered by
11+
* Kaleidoscope in these files:
12+
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keyboard.h
13+
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_consumerctl.h
14+
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_sysctl.h
15+
* https://github.com/keyboardio/Kaleidoscope/blob/master/src/key_defs_keymaps.h
16+
*
17+
* Additional things that should be documented here include
18+
* using ___ to let keypresses fall through to the previously active layer
19+
* using XXX to mark a keyswitch as 'blocked' on this layer
20+
* using ShiftToLayer() and LockLayer() keys to change the active keymap.
21+
* keeping NUM and FN consistent and accessible on all layers
22+
*
23+
* The PROG key is special, since it is how you indicate to the board that you
24+
* want to flash the firmware. However, it can be remapped to a regular key.
25+
* When the keyboard boots, it first looks to see whether the PROG key is held
26+
* down; if it is, it simply awaits further flashing instructions. If it is
27+
* not, it continues loading the rest of the firmware and the keyboard
28+
* functions normally, with whatever binding you have set to PROG. More detail
29+
* here: https://community.keyboard.io/t/how-the-prog-key-gets-you-into-the-bootloader/506/8
30+
*
31+
* The "keymaps" data structure is a list of the keymaps compiled into the firmware.
32+
* The order of keymaps in the list is important, as the ShiftToLayer(#) and LockLayer(#)
33+
* macros switch to key layers based on this list.
34+
*
35+
*
36+
37+
* A key defined as 'ShiftToLayer(FUNCTION)' will switch to FUNCTION while held.
38+
* Similarly, a key defined as 'LockLayer(NUMPAD)' will switch to NUMPAD when tapped.
39+
*/
40+
41+
/**
42+
* Layers are "0-indexed" -- That is the first one is layer 0. The second one is layer 1.
43+
* The third one is layer 2.
44+
* This 'enum' lets us use names like QWERTY, FUNCTION, and NUMPAD in place of
45+
* the numbers 0, 1 and 2.
46+
*
47+
*/
48+
49+
enum { PRIMARY, NUMPAD, FUNCTION }; // layers
50+
51+
52+
/**
53+
* To change your keyboard's layout from QWERTY to DVORAK or COLEMAK, comment out the line
54+
*
55+
* #define PRIMARY_KEYMAP_QWERTY
56+
*
57+
* by changing it to
58+
*
59+
* // #define PRIMARY_KEYMAP_QWERTY
60+
*
61+
* Then uncomment the line corresponding to the layout you want to use.
62+
*
63+
*/
64+
65+
#define PRIMARY_KEYMAP_QWERTY
66+
// #define PRIMARY_KEYMAP_COLEMAK
67+
// #define PRIMARY_KEYMAP_DVORAK
68+
// #define PRIMARY_KEYMAP_CUSTOM
69+
70+
71+
72+
/* This comment temporarily turns off astyle's indent enforcement
73+
* so we can make the keymaps actually resemble the physical key layout better
74+
*/
75+
// *INDENT-OFF*
76+
77+
KEYMAPS(
78+
79+
#if defined (PRIMARY_KEYMAP_QWERTY)
80+
[PRIMARY] = KEYMAP_STACKED
81+
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
82+
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
83+
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
84+
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
85+
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
86+
ShiftToLayer(FUNCTION),
87+
88+
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
89+
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
90+
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
91+
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
92+
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
93+
ShiftToLayer(FUNCTION)),
94+
95+
#elif defined (PRIMARY_KEYMAP_DVORAK)
96+
97+
[PRIMARY] = KEYMAP_STACKED
98+
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
99+
Key_Backtick, Key_Quote, Key_Comma, Key_Period, Key_P, Key_Y, Key_Tab,
100+
Key_PageUp, Key_A, Key_O, Key_E, Key_U, Key_I,
101+
Key_PageDown, Key_Semicolon, Key_Q, Key_J, Key_K, Key_X, Key_Escape,
102+
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
103+
ShiftToLayer(FUNCTION),
104+
105+
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
106+
Key_Enter, Key_F, Key_G, Key_C, Key_R, Key_L, Key_Slash,
107+
Key_D, Key_H, Key_T, Key_N, Key_S, Key_Minus,
108+
Key_RightAlt, Key_B, Key_M, Key_W, Key_V, Key_Z, Key_Equals,
109+
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
110+
ShiftToLayer(FUNCTION)),
111+
112+
#elif defined (PRIMARY_KEYMAP_COLEMAK)
113+
114+
[PRIMARY] = KEYMAP_STACKED
115+
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
116+
Key_Backtick, Key_Q, Key_W, Key_F, Key_P, Key_G, Key_Tab,
117+
Key_PageUp, Key_A, Key_R, Key_S, Key_T, Key_D,
118+
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
119+
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
120+
ShiftToLayer(FUNCTION),
121+
122+
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
123+
Key_Enter, Key_J, Key_L, Key_U, Key_Y, Key_Semicolon, Key_Equals,
124+
Key_H, Key_N, Key_E, Key_I, Key_O, Key_Quote,
125+
Key_RightAlt, Key_K, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
126+
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
127+
ShiftToLayer(FUNCTION)),
128+
129+
#elif defined (PRIMARY_KEYMAP_CUSTOM)
130+
// Edit this keymap to make a custom layout
131+
[PRIMARY] = KEYMAP_STACKED
132+
(___, Key_1, Key_2, Key_3, Key_4, Key_5, Key_LEDEffectNext,
133+
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
134+
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
135+
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,
136+
Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
137+
ShiftToLayer(FUNCTION),
138+
139+
M(MACRO_ANY), Key_6, Key_7, Key_8, Key_9, Key_0, LockLayer(NUMPAD),
140+
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
141+
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
142+
Key_RightAlt, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,
143+
Key_RightShift, Key_LeftAlt, Key_Spacebar, Key_RightControl,
144+
ShiftToLayer(FUNCTION)),
145+
146+
#else
147+
148+
#error "No default keymap defined. You should make sure that you have a line like '#define PRIMARY_KEYMAP_QWERTY' in your sketch"
149+
150+
#endif
151+
152+
153+
154+
[NUMPAD] = KEYMAP_STACKED
155+
(___, ___, ___, ___, ___, ___, ___,
156+
___, ___, ___, ___, ___, ___, ___,
157+
___, ___, ___, ___, ___, ___,
158+
___, ___, ___, ___, ___, ___, ___,
159+
___, ___, ___, ___,
160+
___,
161+
162+
M(MACRO_VERSION_INFO), ___, Key_7, Key_8, Key_9, Key_KeypadSubtract, ___,
163+
___, ___, Key_4, Key_5, Key_6, Key_KeypadAdd, ___,
164+
___, Key_1, Key_2, Key_3, Key_Equals, ___,
165+
___, ___, Key_0, Key_Period, Key_KeypadMultiply, Key_KeypadDivide, Key_Enter,
166+
___, ___, ___, ___,
167+
___),
168+
169+
[FUNCTION] = KEYMAP_STACKED
170+
(___, Key_F1, Key_F2, Key_F3, Key_F4, Key_F5, Key_CapsLock,
171+
Key_Tab, ___, Key_mouseUp, ___, Key_mouseBtnR, Key_mouseWarpEnd, Key_mouseWarpNE,
172+
Key_Home, Key_mouseL, Key_mouseDn, Key_mouseR, Key_mouseBtnL, Key_mouseWarpNW,
173+
Key_End, Key_PrintScreen, Key_Insert, ___, Key_mouseBtnM, Key_mouseWarpSW, Key_mouseWarpSE,
174+
___, Key_Delete, ___, ___,
175+
___,
176+
177+
Consumer_ScanPreviousTrack, Key_F6, Key_F7, Key_F8, Key_F9, Key_F10, Key_F11,
178+
Consumer_PlaySlashPause, Consumer_ScanNextTrack, Key_LeftCurlyBracket, Key_RightCurlyBracket, Key_LeftBracket, Key_RightBracket, Key_F12,
179+
Key_LeftArrow, Key_DownArrow, Key_UpArrow, Key_RightArrow, ___, ___,
180+
Key_PcApplication, Consumer_Mute, Consumer_VolumeDecrement, Consumer_VolumeIncrement, ___, Key_Backslash, Key_Pipe,
181+
___, ___, Key_Enter, ___,
182+
___)
183+
) // KEYMAPS(
184+
185+
/* Re-enable astyle's indent enforcement */
186+
// *INDENT-ON*

0 commit comments

Comments
 (0)