keymap.c (12032B)
1#include "keymap.h" 2#include "hid/keyboard.h" 3#include "keysym.h" 4#include "keysym/consumer.h" 5#include "keysym/keyboard_de.h" 6#include "keysym/keyboard_us.h" 7#include "hid.h" 8#include "board.h" 9#include "util.h" 10 11#define KEYMAP( \ 12 K11, K12, K13, K14, K15, K16, \ 13 K21, K22, K23, K24, K25, K26, \ 14 K31, K32, K33, K34, K35, K36, \ 15 K44, K45, K46, \ 16 K51, K52, K53, K54, K55, K56, \ 17 K61, K62, K63, K64, K65, K66, \ 18 K71, K72, K73, K74, K75, K76, \ 19 K81, K82, K83 \ 20 ) { \ 21 { K11, K12, K13, K14, K15, K16 }, \ 22 { K21, K22, K23, K24, K25, K26 }, \ 23 { K31, K32, K33, K34, K35, K36 }, \ 24 { 0x0, 0x0, 0x0, K44, K45, K46 }, \ 25 { K56, K55, K54, K53, K52, K51 }, \ 26 { K66, K65, K64, K63, K62, K61 }, \ 27 { K76, K75, K74, K73, K72, K71 }, \ 28 { 0x0, 0x0, 0x0, K83, K82, K81 } \ 29 } 30 31/* KEY INDEX LOOKUP: 32 * x0y0 , x1y0 , x2y0 , x3y0 , x4y0 , x5y0 , 33 * x0y1 , x1y1 , x2y1 , x3y1 , x4y1 , x5y1 , 34 * x0y2 , x1y2 , x2y2 , x3y2 , x4y2 , x5y2 , 35 * x3y3 , x4y3 , x5y3 , 36 * 37 * x5y4 , x4y4 , x3y4 , x2y4 , x1y4 , x0y4 , 38 * x5y5 , x4y5 , x3y5 , x2y5 , x1y5 , x0y5 , 39 * x5y6 , x4y6 , x3y6 , x2y6 , x1y6 , x0y6 , 40 * x5y7 , x4y7 , x3y7 41 */ 42 43 44#define LAYER_BASE_DE KEYMAP( \ 45 KC_ESC , DE_Q , DE_W , DE_F , DE_P , DE_B , \ 46 SX(QUSW), DE_A , DE_R , DE_S , DE_T , DE_G , \ 47 KC_LSFT , DE_Z , DE_X , DE_C , DE_D , DE_V , \ 48 KC_LGUI , KC_LALT , SW(SHRT), \ 49 \ 50 DE_J , DE_L , DE_U , DE_Y , DE_HASH , DE_SS , \ 51 DE_M , DE_N , DE_E , DE_I , DE_O , SW(SPEC), \ 52 DE_K , DE_H , DE_COMM , DE_DOT , DE_MINS , SW(MISC), \ 53 SW(NUMS), KC_SPC , KC_LCTL \ 54) 55 56#define LAYER_QUIK_DE KEYMAP( \ 57 SW(META), KC_PGDN , KC_PGUP , KC_UP , DE_DLR , DE_QUOT , \ 58 _______ , _______ , KC_LEFT , KC_DOWN , KC_RGHT , DE_EXLM , \ 59 _______ , _______ , DE_PIPE , DE_LESS , DE_GRTR , DE_BSLS , \ 60 _______ , _______ , CS(BASE), \ 61 \ 62 DE_TILD , DE_LPRN , DE_RPRN , DE_DQUO , DE_GRV , DE_QUES , \ 63 KC_BSPC , KC_ENT , DE_SLSH , DE_SCLN , DE_ASTR , DE_CIRC , \ 64 DE_PERC , DE_AMPR , DE_MINS , DE_PLUS , DE_EQL , _______ , \ 65 KC_TAB , _______ , SW(QUIX) \ 66) 67 68#define LAYER_QUIX_DE KEYMAP( \ 69 _______ , _______ , _______ , _______ , _______ , _______ , \ 70 _______ , _______ , DE_LCBR , _______ , DE_RCBR , _______ , \ 71 _______ , _______ , _______ , DE_LBRC , DE_RBRC , _______ , \ 72 _______ , _______ , _______ , \ 73 \ 74 _______ , _______ , _______ , _______ , _______ , _______ , \ 75 _______ , _______ , _______ , _______ , _______ , _______ , \ 76 _______ , _______ , _______ , _______ , _______ , _______ , \ 77 _______ , _______ , _______ \ 78) 79 80#define LAYER_SHRT_DE KEYMAP( \ 81 _______ , G(KC_1) , G(KC_2) , G(KC_3) , G(KC_4) , G(KC_5) , \ 82 CS(BASE), A(KC_1) , A(KC_2) , A(KC_3) , A(KC_4) , A(KC_5) , \ 83 _______ ,G(KC_TAB),G(DE_DOT), A(DE_B) , A(DE_F) , KC_SPC , \ 84 _______ , _______ , _______ , \ 85 \ 86 G(KC_6) , G(KC_7) , G(KC_8) , G(KC_9) , G(KC_0) , _______ , \ 87 A(KC_6) , A(KC_7) , A(KC_8) , A(KC_9) , A(KC_0) , _______ , \ 88 _______ , _______ , _______ , _______ , _______ , _______ , \ 89 _______ , _______ , _______ \ 90) 91 92#define LAYER_NUMS_DE KEYMAP( \ 93 _______ , DE_1 , DE_2 , DE_3 , DE_4 , DE_5 , \ 94 KC_TAB , _______ , DE_A , DE_B , DE_C , _______ , \ 95 _______ , _______ , _______ , _______ , _______ , _______ , \ 96 _______ , _______ , _______ , \ 97 \ 98 DE_6 , DE_7 , DE_8 , DE_9 , DE_0 , _______ , \ 99 _______ , DE_D , DE_E , DE_F , _______ , _______ , \ 100 _______ , _______ , _______ , _______ , _______ , _______ , \ 101 _______ , _______ , _______ \ 102) 103 104#define LAYER_SPEC_DE KEYMAP( \ 105 _______ , _______ , DE_AT , _______ , _______ , _______ , \ 106 _______ , DE_ADIA , _______ , _______ , _______ , _______ , \ 107 _______ , _______ , _______ , _______ , _______ , _______ , \ 108 _______ , _______ , _______ , \ 109 \ 110 _______ , _______ , DE_UDIA , DE_ACUT , _______ , KC_DEL , \ 111 _______ , _______ , _______ , _______ , DE_ODIA , _______ , \ 112 _______ , _______ , _______ , _______ , _______ , _______ , \ 113 _______ , _______ , _______ \ 114) 115 116#define LAYER_META_DE KEYMAP( \ 117 _______ , SX(KVM1), SX(KVM2), SX(KVM3), SX(KVM4), SX(QMSW), \ 118 _______ , _______ , _______ , _______ , _______ , _______ , \ 119 KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , \ 120 RB(BASE), RB(GM1B), RB(GM2B), \ 121 \ 122 _______ , KS_VOLD , KS_VOLU , KS_MUTE , _______ , _______ , \ 123 _______ , KS_MPRV , KS_MNXT , KS_MPLY , _______ , _______ , \ 124 KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , \ 125 _______ , _______ , _______ \ 126) 127 128#define LAYER_MISC_DE KEYMAP( \ 129 XXXXXXX , SX(TTY1), SX(TTY2), SX(TTY3), SX(TTY4), SX(TTY5), \ 130 XXXXXXX , SX(TTY6), SX(TTY7), SX(TTY8), SX(TTY9),SX(TTY10), \ 131 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 132 XXXXXXX , XXXXXXX , XXXXXXX , \ 133 \ 134 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 135 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 136 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 137 XXXXXXX , XXXXXXX , XXXXXXX \ 138) 139 140#define LAYER_GM1B_DE KEYMAP( \ 141 KC_ESC , DE_Q , DE_W , DE_E , DE_R , DE_T , \ 142 SW(GM1N), DE_A , DE_S , DE_D , DE_F , DE_G , \ 143 KC_LCTL , DE_Z , DE_X , DE_C , DE_V , DE_B , \ 144 KC_LSFT , KC_LALT , KC_SPC , \ 145 \ 146 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 147 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 148 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 149 XXXXXXX , XXXXXXX , XXXXXXX \ 150) 151 152#define LAYER_GM1N_DE KEYMAP( \ 153 SW(META), KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , \ 154 XXXXXXX , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , \ 155 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 156 XXXXXXX , KC_TAB , XXXXXXX , \ 157 \ 158 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 159 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 160 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 161 XXXXXXX , XXXXXXX , XXXXXXX \ 162) 163 164#define LAYER_GM2B_DE KEYMAP( \ 165 KC_ESC , DE_Q , DE_W , DE_E , DE_R , DE_T , \ 166 SW(GM2N), DE_A , DE_S , DE_D , DE_F , DE_G , \ 167 KC_LCTL , DE_Z , DE_X , DE_C , DE_V , DE_B , \ 168 SW(GM2E), KC_LALT , KC_SPC , \ 169 \ 170 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 171 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 172 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 173 XXXXXXX , XXXXXXX , XXXXXXX \ 174) 175 176#define LAYER_GM2N_DE KEYMAP( \ 177 SW(META), KC_1 , DE_W , KC_2 , KC_3 , DE_6 , \ 178 XXXXXXX , DE_A , DE_S , DE_D , KC_4 , DE_7 , \ 179 XXXXXXX , KC_LSFT , DE_9 , DE_0 , KC_5 , DE_8 , \ 180 XXXXXXX , KC_TAB , XXXXXXX , \ 181 \ 182 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 183 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 184 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 185 XXXXXXX , XXXXXXX , XXXXXXX \ 186) 187 188#define LAYER_GM2E_DE KEYMAP( \ 189 DE_J , DE_L , DE_W , DE_Y , DE_HASH , DE_SS , \ 190 DE_M , DE_A , DE_S , DE_D , DE_O , DE_U , \ 191 DE_K , DE_H , DE_COMM , DE_DOT , DE_MINS , DE_N , \ 192 XXXXXXX , XXXXXXX , XXXXXXX , \ 193 \ 194 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 195 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 196 XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , \ 197 XXXXXXX , XXXXXXX , XXXXXXX \ 198) 199 200enum { 201 BASE, /* base */ 202 QUIK, /* symbols + nav */ 203 QUIX, /* quick xtras */ 204 SHRT, /* shortcuts */ 205 LCTL, /* left ctrl */ 206 NUMS, /* numbers */ 207 SPEC, /* specials */ 208 META, /* functions */ 209 MISC, 210 GM1B, /* gaming 1 base */ 211 GM1N, /* gaming 1 nums */ 212 GM2B, /* gaming 2 base */ 213 GM2N, /* gaming 2 nums */ 214 GM2E, /* gaming 2 extended */ 215}; 216 217enum { 218 KVM1, 219 KVM2, 220 KVM3, 221 KVM4, 222 QMSW, 223 QUSW, 224 TTY1, 225 TTY2, 226 TTY3, 227 TTY4, 228 TTY5, 229 TTY6, 230 TTY7, 231 TTY8, 232 TTY9, 233 TTY10, 234}; 235 236const uint32_t keymap_layers_de[][KEY_ROWS][KEY_COLS] = { 237 [BASE] = LAYER_BASE_DE, 238 [QUIK] = LAYER_QUIK_DE, 239 [QUIX] = LAYER_QUIX_DE, 240 [SHRT] = LAYER_SHRT_DE, 241 [NUMS] = LAYER_NUMS_DE, 242 [SPEC] = LAYER_SPEC_DE, 243 [META] = LAYER_META_DE, 244 [MISC] = LAYER_MISC_DE, 245 [GM1B] = LAYER_GM1B_DE, 246 [GM1N] = LAYER_GM1N_DE, 247 [GM2B] = LAYER_GM2B_DE, 248 [GM2N] = LAYER_GM2N_DE, 249 [GM2E] = LAYER_GM2E_DE, 250 251}; 252const uint32_t keymap_layers_de_count = ARRLEN(keymap_layers_de); 253 254const uint32_t (*keymap_layers)[KEY_ROWS][KEY_COLS] = keymap_layers_de; 255uint32_t keymap_layers_count = keymap_layers_de_count; 256 257static const uint32_t macro_kvm1[] = { 258 KC_LEFT_CTRL, KC_LEFT_CTRL, KC_1 259}; 260 261static const uint32_t macro_kvm2[] = { 262 KC_LEFT_CTRL, KC_LEFT_CTRL, KC_2 263}; 264 265static const uint32_t macro_kvm3[] = { 266 KC_HOME 267}; 268 269static const uint32_t macro_kvm4[] = { 270 HOLD(KC_LEFT_SHIFT), KC_HOME 271}; 272 273static const uint32_t macro_qemu_switch[] = { 274 HOLD(KC_LEFT_CTRL), KC_RIGHT_CTRL 275}; 276 277static const uint32_t ttysw_lut[] = { 278 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, 279 KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 280}; 281static uint32_t macro_ttysw[] = { 282 HOLD(KC_LEFT_CTRL), HOLD(KC_LEFT_ALT), KC_F1, 283}; 284 285void 286process_user_keypress(uint8_t sym, uint x, uint y) 287{ 288 switch (sym) { 289 case KVM1: 290 hid_send_macro(macro_kvm1, ARRLEN(macro_kvm1)); 291 break; 292 case KVM2: 293 hid_send_macro(macro_kvm2, ARRLEN(macro_kvm2)); 294 break; 295 case KVM3: 296 hid_send_macro(macro_kvm3, ARRLEN(macro_kvm3)); 297 break; 298 case KVM4: 299 hid_send_macro(macro_kvm4, ARRLEN(macro_kvm4)); 300 break; 301 case QMSW: 302 hid_send_macro(macro_qemu_switch, ARRLEN(macro_qemu_switch)); 303 break; 304 case QUSW: 305 if (keymat[7][3]) { 306 hid_force_release(3, 7); 307 hid_switch_layer_with_key(QUIX, x, y); 308 } else { 309 hid_switch_layer_with_key(QUIK, x, y); 310 } 311 break; 312 case TTY1...TTY10: 313 macro_ttysw[2] = ttysw_lut[sym - TTY1]; 314 hid_send_macro(macro_ttysw, ARRLEN(macro_ttysw)); 315 break; 316 } 317 318} 319 320void 321process_user_keyrelease(uint8_t sym, uint x, uint y) 322{ 323 324}