diff options
Diffstat (limited to 'keyboards/knops/mini/keymaps/mverteuil/keymap.c')
| -rw-r--r-- | keyboards/knops/mini/keymaps/mverteuil/keymap.c | 306 |
1 files changed, 306 insertions, 0 deletions
diff --git a/keyboards/knops/mini/keymaps/mverteuil/keymap.c b/keyboards/knops/mini/keymaps/mverteuil/keymap.c new file mode 100644 index 000000000..5ecba0d5a --- /dev/null +++ b/keyboards/knops/mini/keymaps/mverteuil/keymap.c | |||
| @@ -0,0 +1,306 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | |||
| 3 | #define MAXIMIZ A(G(KC_F)) | ||
| 4 | #define NXTDSPL C(A(G(KC_RIGHT))) | ||
| 5 | #define BTMHALF A(G(KC_DOWN)) | ||
| 6 | #define TOPHALF A(G(KC_UP)) | ||
| 7 | #define NXTTHRD SS_LCTL(SS_LALT(SS_TAP(X_RIGHT))) | ||
| 8 | #define PRVTHRD C(A(KC_LEFT)) | ||
| 9 | |||
| 10 | #define LT_MSTP LT(_LAYER_SELECT, KC_MSTP) | ||
| 11 | #define LT_ESC LT(_LAYER_SELECT, KC_ESC) | ||
| 12 | #define LT_NXTH TD(TD_SPEC) | ||
| 13 | |||
| 14 | #define writeLayerLedState(layer) writePin(layer) | ||
| 15 | #define layer_led_0_off B6, false | ||
| 16 | #define layer_led_1_off D5, true | ||
| 17 | #define layer_led_2_off B0, false | ||
| 18 | #define layer_led_0_on B6, true | ||
| 19 | #define layer_led_1_on D5, false | ||
| 20 | #define layer_led_2_on B0, true | ||
| 21 | |||
| 22 | void led_init_animation(void); | ||
| 23 | void led_set_layer(int layer); | ||
| 24 | void td_spectacles_finish(qk_tap_dance_state_t *state, void *user_data); | ||
| 25 | void td_spectacles_reset(qk_tap_dance_state_t *state, void *user_data); | ||
| 26 | |||
| 27 | enum layer_led_mode { | ||
| 28 | ALL_LAYERS_OFF = -1, | ||
| 29 | LAYER_0, | ||
| 30 | LAYER_1, | ||
| 31 | LAYER_2, | ||
| 32 | LAYER_3, | ||
| 33 | LAYER_4, | ||
| 34 | LAYER_5, | ||
| 35 | ALL_LAYERS_ON, | ||
| 36 | }; | ||
| 37 | |||
| 38 | enum mini_layers { | ||
| 39 | _MEDIA, | ||
| 40 | _COPYPASTA, | ||
| 41 | _SPECTACLES, | ||
| 42 | _LAYER_3, | ||
| 43 | _LAYER_4, | ||
| 44 | _LAYER_5, | ||
| 45 | _LAYER_SELECT, | ||
| 46 | }; | ||
| 47 | |||
| 48 | enum { TD_SPEC = 0 }; | ||
| 49 | |||
| 50 | qk_tap_dance_action_t tap_dance_actions[] = { | ||
| 51 | /* Tap once for spectacles macro, hold for layer toggle */ | ||
| 52 | [TD_SPEC] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, td_spectacles_finish, td_spectacles_reset), | ||
| 53 | }; | ||
| 54 | |||
| 55 | /* | ||
| 56 | * Key Layout | ||
| 57 | * _____ _____ _____ | ||
| 58 | * | | | | | | | ||
| 59 | * | 1 | | 2 | | 3 | | ||
| 60 | * |_____| |_____| |_____| | ||
| 61 | * _____ _____ _____ | ||
| 62 | * | | | | | | | ||
| 63 | * | 4 | | 5 | | 6 | | ||
| 64 | * |_____| |_____| |_____| | ||
| 65 | * | ||
| 66 | * Hold 1 and: | ||
| 67 | * - press 4, 5, or 6 to change layers | ||
| 68 | * - press 3 to reset, or press and hold 3 to enter DFU programming mode | ||
| 69 | * | ||
| 70 | * If something prevents you from using the above to reprogram, you can hold 3 while powering on as a fallback. | ||
| 71 | */ | ||
| 72 | |||
| 73 | /* clang-format off */ | ||
| 74 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 75 | /* | ||
| 76 | * Layer 0 (Media Keys) | ||
| 77 | * _____ _____ _____ | ||
| 78 | * | | | | | | | ||
| 79 | * |Stop | |VolUp| |Play | | ||
| 80 | * |_____| |_____| |_____| | ||
| 81 | * _____ _____ _____ | ||
| 82 | * | | | | | | | ||
| 83 | * |Prev | |VolDn| |Next | | ||
| 84 | * |_____| |_____| |_____| | ||
| 85 | * | ||
| 86 | */ | ||
| 87 | [_MEDIA] = LAYOUT( | ||
| 88 | LT_MSTP, KC_VOLU, KC_MPLY, | ||
| 89 | KC_MPRV, KC_VOLD, KC_MNXT | ||
| 90 | ), | ||
| 91 | |||
| 92 | /* | ||
| 93 | * Layer 1 (Copy and Paste Macros) | ||
| 94 | * _____ _____ _____ | ||
| 95 | * | | | | | | | ||
| 96 | * | ESC | |Ctl+Z| |CSf+Z| | ||
| 97 | * |_____| |_____| |_____| | ||
| 98 | * _____ _____ _____ | ||
| 99 | * | | | | | | | ||
| 100 | * |Ctl+X| |Ctl+C| |Ctl+V| | ||
| 101 | * |_____| |_____| |_____| | ||
| 102 | * | ||
| 103 | */ | ||
| 104 | |||
| 105 | [_COPYPASTA] = LAYOUT( | ||
| 106 | LT_ESC, C(KC_Z), C(S(KC_Z)), | ||
| 107 | C(KC_X), C(KC_C), C(KC_V) | ||
| 108 | ), | ||
| 109 | |||
| 110 | /* | ||
| 111 | * Layer 2 (Spectacles Macros) | ||
| 112 | * _LT&_ _____ _____ | ||
| 113 | * | Win | | Win | | Win | | ||
| 114 | * | Next| | Top | |Mximze | ||
| 115 | * |_1/3_| |_1/2_| |_____| | ||
| 116 | * _____ _____ _____ | ||
| 117 | * | Win | | Win | | Win | | ||
| 118 | * | Prev| | Bot | | Next| | ||
| 119 | * |_1/3_| |_1/2_| |Displ| | ||
| 120 | * | ||
| 121 | */ | ||
| 122 | [_SPECTACLES] = LAYOUT( | ||
| 123 | LT_NXTH,TOPHALF,MAXIMIZ, | ||
| 124 | PRVTHRD,BTMHALF,NXTDSPL | ||
| 125 | ), | ||
| 126 | |||
| 127 | /* | ||
| 128 | * Layer 6 (Layer Select/Reset) | ||
| 129 | * _____ _____ _____ | ||
| 130 | * | | | | | | | ||
| 131 | * |None | |None | |Reset| | ||
| 132 | * |_____| |_____| |_____| | ||
| 133 | * _____ _____ _____ | ||
| 134 | * |Layer| |Layer| |Layer| | ||
| 135 | * | 0 | | 1 | | 2 | | ||
| 136 | * |_____| |_____| |_____| | ||
| 137 | * | ||
| 138 | * Layers 0, 1, and 2 have the top left button held to activate this layer. | ||
| 139 | * Then press the specific layer to switch to it. | ||
| 140 | * | ||
| 141 | */ | ||
| 142 | [_LAYER_SELECT] = LAYOUT( | ||
| 143 | _______, _______, RESET, | ||
| 144 | TO(_MEDIA),TO(_COPYPASTA),TO(_SPECTACLES) | ||
| 145 | ) | ||
| 146 | }; | ||
| 147 | /* clang-format on */ | ||
| 148 | |||
| 149 | /* | ||
| 150 | * Knops Mini LED Numbers: | ||
| 151 | * _____ _____ _____ | ||
| 152 | * | | | | | | | ||
| 153 | * | 1 | | 2 | | 3 | <--- | ||
| 154 | * |_____| |_____| |_____| | These LEDs are called 'Switch LEDs' | ||
| 155 | * _____ _____ _____ |----- To turn on/off these leds, use: | ||
| 156 | * | | | | | | | set_switch_led( [1-6], [true/false]); | ||
| 157 | * | 4 | | 5 | | 6 | <--- | ||
| 158 | * |_____| |_____| |_____| | ||
| 159 | * | ||
| 160 | * < 0 > < 1 > < 2 > <--- These front-LEDs are called 'Layer LEDs' | ||
| 161 | * To turn on/off these leds, use: | ||
| 162 | * set_layer_led( [0-2], [true/false] ); | ||
| 163 | */ | ||
| 164 | |||
| 165 | void set_switch_led(int ledId, bool state) { | ||
| 166 | switch (ledId) { | ||
| 167 | case 1: | ||
| 168 | writePin(D7, state); | ||
| 169 | break; | ||
| 170 | case 2: | ||
| 171 | writePin(readPin(B7) ? C6 : C7, state); | ||
| 172 | break; | ||
| 173 | case 3: | ||
| 174 | writePin(D4, state); | ||
| 175 | break; | ||
| 176 | case 4: | ||
| 177 | writePin(E6, state); | ||
| 178 | break; | ||
| 179 | case 5: | ||
| 180 | writePin(B4, state); | ||
| 181 | break; | ||
| 182 | case 6: | ||
| 183 | writePin(D6, state); | ||
| 184 | break; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | void set_layer_led(int layerLedMode) { | ||
| 189 | writeLayerLedState(layer_led_0_off); | ||
| 190 | writeLayerLedState(layer_led_1_off); | ||
| 191 | writeLayerLedState(layer_led_2_off); | ||
| 192 | |||
| 193 | switch (layerLedMode) { | ||
| 194 | case ALL_LAYERS_OFF: | ||
| 195 | break; | ||
| 196 | case LAYER_0: | ||
| 197 | writeLayerLedState(layer_led_0_on); | ||
| 198 | break; | ||
| 199 | case LAYER_1: | ||
| 200 | writeLayerLedState(layer_led_1_on); | ||
| 201 | break; | ||
| 202 | case LAYER_2: | ||
| 203 | writeLayerLedState(layer_led_2_on); | ||
| 204 | break; | ||
| 205 | case LAYER_3: | ||
| 206 | writeLayerLedState(layer_led_0_on); | ||
| 207 | writeLayerLedState(layer_led_1_on); | ||
| 208 | break; | ||
| 209 | case LAYER_4: | ||
| 210 | writeLayerLedState(layer_led_1_on); | ||
| 211 | writeLayerLedState(layer_led_2_on); | ||
| 212 | break; | ||
| 213 | case LAYER_5: | ||
| 214 | writeLayerLedState(layer_led_0_on); | ||
| 215 | writeLayerLedState(layer_led_2_on); | ||
| 216 | break; | ||
| 217 | default: | ||
| 218 | writeLayerLedState(layer_led_0_on); | ||
| 219 | writeLayerLedState(layer_led_1_on); | ||
| 220 | writeLayerLedState(layer_led_2_on); | ||
| 221 | break; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 225 | void led_init_animation() { | ||
| 226 | for (int i = ALL_LAYERS_OFF; i <= ALL_LAYERS_ON; i++) { | ||
| 227 | led_set_layer(i); | ||
| 228 | } | ||
| 229 | |||
| 230 | led_set_layer(LAYER_0); | ||
| 231 | } | ||
| 232 | |||
| 233 | /* | ||
| 234 | * This function led_set_layer gets called when you switch between layers. | ||
| 235 | * It allows you to turn on and off leds for each different layer and do | ||
| 236 | * other cool stuff. | ||
| 237 | */ | ||
| 238 | void led_set_layer(int layer) { | ||
| 239 | switch (layer) { | ||
| 240 | case ALL_LAYERS_OFF: | ||
| 241 | set_switch_led(1, false); | ||
| 242 | set_switch_led(2, false); | ||
| 243 | set_switch_led(3, false); | ||
| 244 | set_switch_led(4, false); | ||
| 245 | set_switch_led(5, false); | ||
| 246 | set_switch_led(6, false); | ||
| 247 | |||
| 248 | case _LAYER_SELECT: | ||
| 249 | set_switch_led(1, false); | ||
| 250 | set_switch_led(2, false); | ||
| 251 | set_switch_led(3, false); | ||
| 252 | set_switch_led(4, true); | ||
| 253 | set_switch_led(5, true); | ||
| 254 | set_switch_led(6, true); | ||
| 255 | break; | ||
| 256 | |||
| 257 | default: | ||
| 258 | set_switch_led(1, true); | ||
| 259 | set_switch_led(2, true); | ||
| 260 | set_switch_led(3, true); | ||
| 261 | set_switch_led(4, true); | ||
| 262 | set_switch_led(5, true); | ||
| 263 | set_switch_led(6, true); | ||
| 264 | break; | ||
| 265 | } | ||
| 266 | |||
| 267 | set_layer_led(layer); | ||
| 268 | } | ||
| 269 | |||
| 270 | /* | ||
| 271 | * Prepare all LED ports for output | ||
| 272 | */ | ||
| 273 | void led_init_ports() { | ||
| 274 | setPinOutput(D7); // Switch 1 LED | ||
| 275 | setPinOutput(C6); // Switch 2 LED Pin1 | ||
| 276 | setPinOutput(C7); // Switch 2 LED Pin2 | ||
| 277 | setPinOutput(D4); // Switch 3 LED | ||
| 278 | setPinOutput(E6); // Switch 4 LED | ||
| 279 | setPinOutput(B4); // Switch 5 LED | ||
| 280 | setPinOutput(D6); // Switch 6 LED | ||
| 281 | setPinOutput(D5); // Layer 0 LED | ||
| 282 | setPinOutput(B6); // Layer 1 LED | ||
| 283 | setPinOutput(B0); // Layer 2 LED | ||
| 284 | } | ||
| 285 | |||
| 286 | // Runs on layer change, no matter where the change was initiated | ||
| 287 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 288 | set_layer_led(get_highest_layer(state)); | ||
| 289 | led_set_layer(get_highest_layer(state)); | ||
| 290 | return state; | ||
| 291 | } | ||
| 292 | |||
| 293 | void matrix_init_user(void) { | ||
| 294 | led_init_ports(); | ||
| 295 | led_init_animation(); | ||
| 296 | } | ||
| 297 | |||
| 298 | void td_spectacles_finish(qk_tap_dance_state_t *state, void *user_data) { | ||
| 299 | if (state->pressed) { | ||
| 300 | layer_on(_LAYER_SELECT); | ||
| 301 | } else { | ||
| 302 | SEND_STRING(NXTTHRD); | ||
| 303 | } | ||
| 304 | } | ||
| 305 | |||
| 306 | void td_spectacles_reset(qk_tap_dance_state_t *state, void *user_data) { layer_off(_LAYER_SELECT); } | ||
