]>
git.gir.st - tmk_keyboard.git/blob - keyboard/hhkb/keymap.c
2 Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
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.
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.
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/>.
19 * Keymap for PFU HHKB Pro
23 #include <avr/pgmspace.h>
26 #include "action_macro.h"
34 K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \
35 K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \
36 K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \
37 K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \
38 K35, K36, K37, K57, K56 \
41 { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
42 { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
43 { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
44 { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
45 { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
46 { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
47 { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \
48 { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \
51 #ifdef KEYMAP_SECTION_ENABLE
52 const uint8_t keymaps
[][MATRIX_ROWS
][MATRIX_COLS
] __attribute__ ((section (".keymap.keymaps"))) = {
54 static const uint8_t keymaps
[][MATRIX_ROWS
][MATRIX_COLS
] PROGMEM
= {
56 /* Layer 0: Default Layer
57 * ,-----------------------------------------------------------.
58 * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
59 * |-----------------------------------------------------------|
60 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
61 * |-----------------------------------------------------------|
62 * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn4 |
63 * |-----------------------------------------------------------|
64 * |Fn5 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1|
65 * `-----------------------------------------------------------'
66 * |Gui|Alt | Fn6 |Alt |Fn7|
67 * `-------------------------------------------'
69 KEYMAP(ESC
, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS
,EQL
, BSLS
,GRV
, \
70 TAB
, Q
, W
, E
, R
, T
, Y
, U
, I
, O
, P
, LBRC
,RBRC
,BSPC
, \
71 LCTL
,A
, S
, D
, F
, G
, H
, J
, K
, L
, FN3
, QUOT
,FN4
, \
72 FN5
,Z
, X
, C
, V
, B
, N
, M
, COMM
,DOT
, FN2
, RSFT
,FN1
, \
73 LGUI
,LALT
, FN6
, RALT
,RGUI
),
75 /* Layer 1: HHKB mode (HHKB Fn)
76 * ,-----------------------------------------------------------.
77 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
78 * |-----------------------------------------------------------|
79 * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
80 * |-----------------------------------------------------------|
81 * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
82 * |-----------------------------------------------------------|
83 * |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
84 * `-----------------------------------------------------------'
85 * |Gui|Alt | Space |Alt |Gui|
86 * `-------------------------------------------'
88 KEYMAP(GRV
, F1
, F2
, F3
, F4
, F5
, F6
, F7
, F8
, F9
, F10
, F11
, F12
, INS
, DEL
, \
89 CAPS
,NO
, NO
, NO
, NO
, NO
, NO
, NO
, PSCR
,SLCK
,PAUS
, UP
, NO
, BSPC
, \
90 LCTL
,VOLD
,VOLU
,MUTE
,NO
, NO
, PAST
,PSLS
,HOME
,PGUP
,LEFT
,RGHT
,ENT
, \
91 LSFT
,NO
, NO
, NO
, NO
, NO
, PPLS
,PMNS
,END
, PGDN
,DOWN
,RSFT
,TRNS
, \
92 LGUI
,LALT
, SPC
, RALT
,RGUI
),
94 /* Layer 2: Vi mode (Slash)
95 * ,-----------------------------------------------------------.
96 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
97 * |-----------------------------------------------------------|
98 * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs|
99 * |-----------------------------------------------------------|
100 * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
101 * |-----------------------------------------------------------|
102 * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | |
103 * `-----------------------------------------------------------'
104 * |Gui|Alt | Space |Alt |Gui|
105 * `-------------------------------------------'
107 KEYMAP(GRV
, F1
, F2
, F3
, F4
, F5
, F6
, F7
, F8
, F9
, F10
, F11
, F12
, INS
, DEL
, \
108 TAB
, HOME
,PGDN
,UP
, PGUP
,END
, HOME
,PGDN
,PGUP
,END
, NO
, NO
, NO
, BSPC
, \
109 LCTL
,NO
, LEFT
,DOWN
,RGHT
,NO
, LEFT
,DOWN
,UP
, RGHT
,NO
, NO
, ENT
, \
110 LSFT
,NO
, NO
, NO
, NO
, NO
, HOME
,PGDN
,PGUP
,END
, TRNS
,RSFT
,NO
, \
111 LGUI
,LALT
, SPC
, RALT
,RGUI
),
113 /* Layer 3: Mouse mode (Semicolon)
114 * ,-----------------------------------------------------------.
115 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
116 * |-----------------------------------------------------------|
117 * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
118 * |-----------------------------------------------------------|
119 * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
120 * |-----------------------------------------------------------|
121 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
122 * `-----------------------------------------------------------'
123 * |Gui |Alt | Mb1 |Alt |Fn0|
124 * `--------------------------------------------'
125 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
127 KEYMAP(GRV
, F1
, F2
, F3
, F4
, F5
, F6
, F7
, F8
, F9
, F10
, F11
, F12
, INS
, DEL
, \
128 TAB
, NO
, NO
, NO
, NO
, NO
, WH_L
,WH_D
,WH_U
,WH_R
,NO
, NO
, NO
, BSPC
, \
129 LCTL
,NO
, ACL0
,ACL1
,ACL2
,NO
, MS_L
,MS_D
,MS_U
,MS_R
,TRNS
,QUOT
,ENT
, \
130 LSFT
,NO
, NO
, NO
, NO
, BTN3
,BTN2
,BTN1
,BTN4
,BTN5
,SLSH
,RSFT
,NO
, \
131 LGUI
,LALT
, BTN1
, RALT
,TRNS
),
133 /* Layer 4: Matias half-qwerty keyboard style (Space)
134 * ,-----------------------------------------------------------.
135 * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc|
136 * |-----------------------------------------------------------|
137 * |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab |
138 * |-----------------------------------------------------------|
139 * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control |
140 * |-----------------------------------------------------------|
141 * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | |
142 * `-----------------------------------------------------------'
143 * |Gui |Alt | Fn0 |Alt |Gui|
144 * `--------------------------------------------'
146 KEYMAP(MINS
,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO
, NO
, NO
, ESC
, \
147 BSPC
,P
, O
, I
, U
, Y
, T
, R
, E
, W
, Q
, NO
, NO
, TAB
, \
148 LCTL
,SCLN
,L
, K
, J
, H
, G
, F
, D
, S
, A
, RCTL
,RCTL
, \
149 LSFT
,SLSH
,DOT
, COMM
,M
, N
, B
, V
, C
, X
, Z
, RSFT
,NO
, \
150 LGUI
,LALT
, TRNS
, RALT
,RGUI
),
152 /* Layer5: another Mouse mode (Space)
153 * ,-----------------------------------------------------------.
154 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
155 * |-----------------------------------------------------------|
156 * |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Close|
157 * |-----------------------------------------------------------|
158 * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return |
159 * |-----------------------------------------------------------|
160 * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
161 * `-----------------------------------------------------------'
162 * |Gui |Alt | Fn0 |Alt |Fn0|
163 * `--------------------------------------------'
164 * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
166 KEYMAP(ESC
, F1
, F2
, F3
, F4
, F5
, F6
, F7
, F8
, F9
, F10
, F11
, F12
, INS
, DEL
, \
167 TAB
, NO
, NO
, NO
, NO
, NO
, WH_L
,WH_D
,WH_U
,WH_R
,WSTP
,WBAK
,WFWD
,FN8
, \
168 LCTL
,NO
, ACL0
,ACL1
,ACL2
,NO
, MS_L
,MS_D
,MS_U
,MS_R
,NO
, NO
, ENT
, \
169 LSFT
,NO
, NO
, NO
, NO
, BTN3
,BTN2
,BTN1
,BTN4
,BTN5
,NO
, RSFT
,NO
, \
170 LGUI
,LALT
, TRNS
, RALT
,RGUI
),
175 /* id for user defined functions */
190 * Fn action definition
192 #ifdef KEYMAP_SECTION_ENABLE
193 const uint16_t fn_actions
[] __attribute__ ((section (".keymap.fn_actions"))) = {
195 static const uint16_t fn_actions
[] PROGMEM
= {
197 [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
198 [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
199 [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH
), // Cursor layer with Slash*
200 [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN
), // Mousekey layer with Semicolon*
201 [4] = ACTION_MODS_TAP_KEY(MOD_RCTL
, KC_ENT
), // RControl with tap Enter*
202 [5] = ACTION_MODS_ONESHOT(MOD_LSFT
), // Oneshot Shift*
203 [6] = ACTION_LAYER_TAP_KEY(5, KC_SPC
), // Mousekey layer with Space
204 [7] = ACTION_LAYER_TOGGLE(3), // Mousekey layer(toggle)
205 [8] = ACTION_MODS_KEY(MOD_LCTL
, KC_W
), // Close Tab
207 // [8] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace
208 // [9] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc
209 // [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '('
210 // [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // Function: RShift with tap ')'
211 // [13] = ACTION_MACRO_TAP(LSHIFT_PAREN), // Macro: LShift with tap '('
212 // [14] = ACTION_MACRO_TAP(RSHIFT_PAREN), // Macro: RShift with tap ')'
213 // [15] = ACTION_MACRO(HELLO), // Macro: say hello
214 // [9] = ACTION_MACRO(VOLUP), // Macro: media key
221 const macro_t
*action_get_macro(keyrecord_t
*record
, uint8_t id
, uint8_t opt
)
223 keyevent_t event
= record
->event
;
224 tap_t tap
= record
->tap
;
228 if (tap
.count
> 0 && !tap
.interrupted
) {
229 return (event
.pressed
?
230 MACRO( D(LSHIFT
), D(9), U(9), U(LSHIFT
), END
) : MACRO_NONE
);
232 return (event
.pressed
?
233 MACRO( D(LSHIFT
), END
) : MACRO( U(LSHIFT
), END
) );
236 if (tap
.count
> 0 && !tap
.interrupted
) {
237 return (event
.pressed
?
238 MACRO( D(RSHIFT
), D(0), U(0), U(RSHIFT
), END
) : MACRO_NONE
);
240 return (event
.pressed
?
241 MACRO( D(RSHIFT
), END
) : MACRO( U(RSHIFT
), END
) );
244 return (event
.pressed
?
245 MACRO( I(0), T(H
), T(E
), T(L
), T(L
), W(255), T(O
), END
) :
248 return (event
.pressed
?
249 MACRO( D(VOLU
), U(VOLU
), END
) :
258 * user defined action function
260 void action_function(keyrecord_t
*record
, uint8_t id
, uint8_t opt
)
262 keyevent_t event
= record
->event
;
263 tap_t tap
= record
->tap
;
268 // NOTE: cant use register_code to avoid conflicting with magic key bind
270 if (tap
.count
== 0 || tap
.interrupted
) {
271 add_mods(MOD_BIT(KC_LSHIFT
));
273 host_add_mods(MOD_BIT(KC_LSHIFT
));
275 host_send_keyboard_report();
276 host_del_mods(MOD_BIT(KC_LSHIFT
));
278 host_send_keyboard_report();
281 if (tap
.count
== 0 || tap
.interrupted
) {
282 del_mods(MOD_BIT(KC_LSHIFT
));
289 if (tap
.count
== 0 || tap
.interrupted
) {
290 add_mods(MOD_BIT(KC_RSHIFT
));
292 host_add_mods(MOD_BIT(KC_RSHIFT
));
294 host_send_keyboard_report();
295 host_del_mods(MOD_BIT(KC_RSHIFT
));
297 host_send_keyboard_report();
300 if (tap
.count
== 0 || tap
.interrupted
) {
301 del_mods(MOD_BIT(KC_RSHIFT
));
310 /* translates key to keycode */
311 uint8_t keymap_key_to_keycode(uint8_t layer
, key_t key
)
313 return pgm_read_byte(&keymaps
[(layer
)][(key
.row
)][(key
.col
)]);
316 /* translates Fn index to action */
317 action_t
keymap_fn_to_action(uint8_t keycode
)
320 action
.code
= pgm_read_word(&fn_actions
[FN_INDEX(keycode
)]);