2 * Hasu: my personal keymap
4 #include "keymap_common.h"
7 #ifdef KEYMAP_SECTION_ENABLE
8 const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
10 const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
12 /* Layer 0: Default Layer
13 * ,-----------------------------------------------------------.
14 * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
15 * |-----------------------------------------------------------|
16 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
17 * |-----------------------------------------------------------|
18 * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 |
19 * |-----------------------------------------------------------|
20 * |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1|
21 * `-----------------------------------------------------------'
22 * |Gui|Alt | Fn4 |Fn5 |Gui|
23 * `-------------------------------------------'
26 KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
27 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
28 LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \
29 FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \
30 LGUI,LALT, FN4, FN5, RGUI),
32 /* Layer 1: HHKB mode[HHKB Fn]
33 * ,-----------------------------------------------------------.
34 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
35 * |-----------------------------------------------------------|
36 * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
37 * |-----------------------------------------------------------|
38 * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
39 * |-----------------------------------------------------------|
40 * |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
41 * `-----------------------------------------------------------'
42 * |Gui|Alt | Space |Alt |Gui|
43 * `-------------------------------------------'
46 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
47 CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \
48 LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
49 LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
50 LGUI,LALT, TRNS, RALT,RGUI),
52 /* Layer 2: Vi mode[Slash]
53 * ,-----------------------------------------------------------.
54 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
55 * |-----------------------------------------------------------|
56 * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs|
57 * |-----------------------------------------------------------|
58 * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
59 * |-----------------------------------------------------------|
60 * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | |
61 * `-----------------------------------------------------------'
62 * |Gui|Alt | Space |Alt |Gui|
63 * `-------------------------------------------'
66 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
67 TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \
68 LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
69 LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
70 LGUI,LALT, SPC, RALT,RGUI),
72 /* Layer 3: Mouse mode(IJKL)[Semicolon]
73 * ,-----------------------------------------------------------.
74 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
75 * |-----------------------------------------------------------|
76 * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
77 * |-----------------------------------------------------------|
78 * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return |
79 * |-----------------------------------------------------------|
80 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
81 * `-----------------------------------------------------------'
82 * |Gui |Alt | Mb1 |Fn |Fn |
83 * `--------------------------------------------'
84 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
87 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
88 FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
89 LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \
90 LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
91 LGUI,LALT, BTN1, TRNS,TRNS),
93 /* Layer 4: Mouse mode(IJKL)[Space]
94 * ,-----------------------------------------------------------.
95 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
96 * |-----------------------------------------------------------|
97 * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
98 * |-----------------------------------------------------------|
99 * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return |
100 * |-----------------------------------------------------------|
101 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
102 * `-----------------------------------------------------------'
103 * |Gui |Alt | Mb1 |Fn |Fn |
104 * `--------------------------------------------'
105 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
108 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
109 FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
110 LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \
111 LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \
112 LGUI,LALT, TRNS, TRNS,TRNS),
115 /* Layer 3: Mouse mode(HJKL)[Semicolon]
116 * ,-----------------------------------------------------------.
117 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
118 * |-----------------------------------------------------------|
119 * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
120 * |-----------------------------------------------------------|
121 * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
122 * |-----------------------------------------------------------|
123 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
124 * `-----------------------------------------------------------'
125 * |Gui |Alt | Mb1 |Alt |Fn0|
126 * `--------------------------------------------'
127 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
129 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
130 TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \
131 LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
132 LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
133 LGUI,LALT, BTN1, RALT,TRNS),
135 /* Layer4: Mouse mode(HJKL)[Space]
136 * ,-----------------------------------------------------------.
137 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
138 * |-----------------------------------------------------------|
139 * |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Alt-T|
140 * |-----------------------------------------------------------|
141 * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
142 * |-----------------------------------------------------------|
143 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
144 * `-----------------------------------------------------------'
145 * |Gui |Alt | Fn0 |Alt |Fn0|
146 * `--------------------------------------------'
147 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
149 KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
150 FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \
151 LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \
152 LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \
153 LGUI,LALT, TRNS, RALT,RGUI),
156 /* Layer x: Matias half-qwerty keyboard style[Space]
157 * ,-----------------------------------------------------------.
158 * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc|
159 * |-----------------------------------------------------------|
160 * |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
161 * |-----------------------------------------------------------|
162 * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
163 * |-----------------------------------------------------------|
164 * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | |
165 * `-----------------------------------------------------------'
166 * |Gui |Alt | Fn0 |Alt |Gui|
167 * `--------------------------------------------'
169 KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \
170 BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \
171 LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \
172 LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \
173 LGUI,LALT, TRNS, RALT,RGUI),
179 /* id for user defined functions */
192 * Fn action definition
194 #ifdef KEYMAP_SECTION_ENABLE
195 const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
197 const uint16_t fn_actions[] PROGMEM = {
199 [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
200 [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
201 [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
202 [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
203 [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space
204 [5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL)
205 [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter
206 [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
207 [8] = ACTION_MACRO(ALT_TAB), // Application switching
208 [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
209 [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
211 // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
212 // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
213 // [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '('
214 // [x] = ACTION_MACRO(HELLO), // Macro: say hello
215 // [x] = ACTION_MACRO(VOLUP), // Macro: media key
222 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
226 return (record->event.pressed ?
227 MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
230 return (record->event.pressed ?
231 MACRO( D(VOLU), U(VOLU), END ) :
234 return (record->event.pressed ?
235 MACRO( D(LALT), D(TAB), END ) :
236 MACRO( U(TAB), END ));
244 * user defined action function
246 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
248 if (record->event.pressed) dprint("P"); else dprint("R");
249 dprintf("%d", record->tap.count);
250 if (record->tap.interrupted) dprint("i");
255 // Shift parentheses example: LShft + tap '('
256 // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
257 // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
258 if (record->event.pressed) {
259 if (record->tap.count > 0 && !record->tap.interrupted) {
260 if (record->tap.interrupted) {
261 dprint("tap interrupted\n");
262 register_mods(MOD_BIT(KC_LSHIFT));
265 register_mods(MOD_BIT(KC_LSHIFT));
268 if (record->tap.count > 0 && !(record->tap.interrupted)) {
269 add_weak_mods(MOD_BIT(KC_LSHIFT));
270 send_keyboard_report();
272 unregister_code(KC_9);
273 del_weak_mods(MOD_BIT(KC_LSHIFT));
274 send_keyboard_report();
275 record->tap.count = 0; // ad hoc: cancel tap
277 unregister_mods(MOD_BIT(KC_LSHIFT));