aboutsummaryrefslogtreecommitdiff
path: root/common/action.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/action.c')
-rw-r--r--common/action.c172
1 files changed, 6 insertions, 166 deletions
diff --git a/common/action.c b/common/action.c
index 07a3a64d6..ef04851b1 100644
--- a/common/action.c
+++ b/common/action.c
@@ -56,7 +56,6 @@ void process_action(keyrecord_t *record)
56 56
57 action_t action = layer_switch_get_action(event.key); 57 action_t action = layer_switch_get_action(event.key);
58 debug("ACTION: "); debug_action(action); 58 debug("ACTION: "); debug_action(action);
59 debug(" overlays: "); overlay_debug();
60 debug(" keymaps: "); keymap_debug(); 59 debug(" keymaps: "); keymap_debug();
61 debug(" default_layer: "); debug_dec(default_layer); debug("\n"); 60 debug(" default_layer: "); debug_dec(default_layer); debug("\n");
62 61
@@ -199,31 +198,28 @@ void process_action(keyrecord_t *record)
199 } 198 }
200 break; 199 break;
201#endif 200#endif
202#ifndef NO_ACTION_KEYMAP 201#ifndef NO_ACTION_LAYER
203 case ACT_KEYMAP: 202 case ACT_LAYER:
203 case ACT_LAYER1:
204 switch (action.layer.code) { 204 switch (action.layer.code) {
205 /* Keymap clear */ 205 /* Keymap clear */
206 case OP_RESET: 206 case OP_RESET:
207 switch (action.layer.val & 0x03) { 207 switch (action.layer.val & 0x03) {
208 case 0: 208 case 0:
209 // NOTE: reserved 209 // NOTE: reserved
210 overlay_clear();
211 keymap_clear(); 210 keymap_clear();
212 break; 211 break;
213 case ON_PRESS: 212 case ON_PRESS:
214 if (event.pressed) { 213 if (event.pressed) {
215 overlay_clear();
216 keymap_clear(); 214 keymap_clear();
217 } 215 }
218 break; 216 break;
219 case ON_RELEASE: 217 case ON_RELEASE:
220 if (!event.pressed) { 218 if (!event.pressed) {
221 overlay_clear();
222 keymap_clear(); 219 keymap_clear();
223 } 220 }
224 break; 221 break;
225 case ON_BOTH: 222 case ON_BOTH:
226 overlay_clear();
227 keymap_clear(); 223 keymap_clear();
228 break; 224 break;
229 /* NOTE: 4-7 rserved */ 225 /* NOTE: 4-7 rserved */
@@ -362,161 +358,6 @@ void process_action(keyrecord_t *record)
362 } 358 }
363 break; 359 break;
364#endif 360#endif
365#ifndef NO_ACTION_OVERLAY
366 case ACT_OVERLAY:
367 switch (action.layer.code) {
368 // Overlay Invert bit4
369 case OP_INV4 | 0:
370 if (action.layer.val == 0) {
371 // NOTE: reserved for future use
372 overlay_clear();
373 } else {
374 overlay_set(overlay_stat ^ action.layer.val);
375 }
376 break;
377 case OP_INV4 | 1:
378 if (action.layer.val == 0) {
379 // on pressed
380 if (event.pressed) overlay_clear();
381 } else {
382 overlay_set(overlay_stat ^ action.layer.val<<4);
383 }
384 break;
385 case OP_INV4 | 2:
386 if (action.layer.val == 0) {
387 // on released
388 if (!event.pressed) overlay_clear();
389 } else {
390 overlay_set(overlay_stat ^ action.layer.val<<8);
391 }
392 break;
393 case OP_INV4 | 3:
394 if (action.layer.val == 0) {
395 // on both
396 overlay_clear();
397 } else {
398 overlay_set(overlay_stat ^ action.layer.val<<12);
399 }
400 break;
401
402 /* Overlay Bit invert */
403 case OP_INV:
404 /* with tap toggle */
405 if (event.pressed) {
406 if (tap_count < TAPPING_TOGGLE) {
407 debug("OVERLAY_INV: tap toggle(press).\n");
408 overlay_invert(action.layer.val);
409 }
410 } else {
411 if (tap_count <= TAPPING_TOGGLE) {
412 debug("OVERLAY_INV: tap toggle(release).\n");
413 overlay_invert(action.layer.val);
414 }
415 }
416 break;
417 case (OP_INV | ON_PRESS):
418 if (event.pressed) {
419 overlay_invert(action.layer.val);
420 }
421 break;
422 case (OP_INV | ON_RELEASE):
423 if (!event.pressed) {
424 overlay_invert(action.layer.val);
425 }
426 break;
427 case (OP_INV | ON_BOTH):
428 overlay_invert(action.layer.val);
429 break;
430
431 /* Overlay Bit on */
432 case OP_ON:
433 if (event.pressed) {
434 overlay_on(action.layer.val);
435 } else {
436 overlay_off(action.layer.val);
437 }
438 break;
439 case (OP_ON | ON_PRESS):
440 if (event.pressed) {
441 overlay_on(action.layer.val);
442 }
443 break;
444 case (OP_ON | ON_RELEASE):
445 if (!event.pressed) {
446 overlay_on(action.layer.val);
447 }
448 break;
449 case (OP_ON | ON_BOTH):
450 overlay_on(action.layer.val);
451 break;
452
453 /* Overlay Bit off */
454 case OP_OFF:
455 if (event.pressed) {
456 overlay_off(action.layer.val);
457 } else {
458 overlay_on(action.layer.val);
459 }
460 break;
461 case (OP_OFF | ON_PRESS):
462 if (event.pressed) {
463 overlay_off(action.layer.val);
464 }
465 break;
466 case (OP_OFF | ON_RELEASE):
467 if (!event.pressed) {
468 overlay_off(action.layer.val);
469 }
470 break;
471 case (OP_OFF | ON_BOTH):
472 overlay_off(action.layer.val);
473 break;
474
475 /* Overlay Bit set */
476 case OP_SET:
477 if (event.pressed) {
478 overlay_move(action.layer.val);
479 } else {
480 overlay_clear();
481 }
482 break;
483 case (OP_SET | ON_PRESS):
484 if (event.pressed) {
485 overlay_move(action.layer.val);
486 }
487 break;
488 case (OP_SET | ON_RELEASE):
489 if (!event.pressed) {
490 overlay_move(action.layer.val);
491 }
492 break;
493 case (OP_SET | ON_BOTH):
494 overlay_move(action.layer.val);
495 break;
496
497 /* Overlay Bit invert with tap key */
498 default:
499 if (event.pressed) {
500 if (tap_count > 0) {
501 debug("OVERLAY_TAP_KEY: Tap: register_code\n");
502 register_code(action.layer.code);
503 } else {
504 debug("OVERLAY_TAP_KEY: No tap: On on press\n");
505 overlay_on(action.layer.val);
506 }
507 } else {
508 if (tap_count > 0) {
509 debug("OVERLAY_TAP_KEY: Tap: unregister_code\n");
510 unregister_code(action.layer.code);
511 } else {
512 debug("OVERLAY_TAP_KEY: No tap: Off on release\n");
513 overlay_off(action.layer.val);
514 }
515 }
516 break;
517 }
518 break;
519#endif
520 /* Extentions */ 361 /* Extentions */
521#ifndef NO_ACTION_MACRO 362#ifndef NO_ACTION_MACRO
522 case ACT_MACRO: 363 case ACT_MACRO:
@@ -668,8 +509,7 @@ bool is_tap_key(key_t key)
668 case ACT_LMODS_TAP: 509 case ACT_LMODS_TAP:
669 case ACT_RMODS_TAP: 510 case ACT_RMODS_TAP:
670 return true; 511 return true;
671 case ACT_KEYMAP: 512 case ACT_LAYER:
672 case ACT_OVERLAY:
673 switch (action.layer.code) { 513 switch (action.layer.code) {
674 case 0x04 ... 0xEF: /* tap key */ 514 case 0x04 ... 0xEF: /* tap key */
675 case OP_INV: 515 case OP_INV:
@@ -714,8 +554,8 @@ void debug_action(action_t action)
714 case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break; 554 case ACT_RMODS_TAP: debug("ACT_RMODS_TAP"); break;
715 case ACT_USAGE: debug("ACT_USAGE"); break; 555 case ACT_USAGE: debug("ACT_USAGE"); break;
716 case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break; 556 case ACT_MOUSEKEY: debug("ACT_MOUSEKEY"); break;
717 case ACT_KEYMAP: debug("ACT_KEYMAP"); break; 557 case ACT_LAYER: debug("ACT_LAYER"); break;
718 case ACT_OVERLAY: debug("ACT_OVERLAY"); break; 558 case ACT_LAYER_BITOP: debug("ACT_LAYER_BITOP"); break;
719 case ACT_MACRO: debug("ACT_MACRO"); break; 559 case ACT_MACRO: debug("ACT_MACRO"); break;
720 case ACT_COMMAND: debug("ACT_COMMAND"); break; 560 case ACT_COMMAND: debug("ACT_COMMAND"); break;
721 case ACT_FUNCTION: debug("ACT_FUNCTION"); break; 561 case ACT_FUNCTION: debug("ACT_FUNCTION"); break;