summaryrefslogtreecommitdiff
path: root/quantum/action.c
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-10-01 06:29:24 +1000
committerGitHub <noreply@github.com>2022-09-30 16:29:24 -0400
commit2c96c7526356ba76400c6fa61bd0805e81c5aa31 (patch)
treef9902067d97a63b5c26f7a2ef0f09fffa9cb617d /quantum/action.c
parent8bd73d44555ecb50d0da9bb0e1e48c07b9764e35 (diff)
Small un/register_code() cleanups (#18544)
Diffstat (limited to 'quantum/action.c')
-rw-r--r--quantum/action.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 259c4349c3..78322e4a83 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -527,18 +527,10 @@ void process_action(keyrecord_t *record, action_t action) {
527 case ACT_USAGE: 527 case ACT_USAGE:
528 switch (action.usage.page) { 528 switch (action.usage.page) {
529 case PAGE_SYSTEM: 529 case PAGE_SYSTEM:
530 if (event.pressed) { 530 host_system_send(event.pressed ? action.usage.code : 0);
531 host_system_send(action.usage.code);
532 } else {
533 host_system_send(0);
534 }
535 break; 531 break;
536 case PAGE_CONSUMER: 532 case PAGE_CONSUMER:
537 if (event.pressed) { 533 host_consumer_send(event.pressed ? action.usage.code : 0);
538 host_consumer_send(action.usage.code);
539 } else {
540 host_consumer_send(0);
541 }
542 break; 534 break;
543 } 535 }
544 break; 536 break;
@@ -852,9 +844,9 @@ void process_action(keyrecord_t *record, action_t action) {
852__attribute__((weak)) void register_code(uint8_t code) { 844__attribute__((weak)) void register_code(uint8_t code) {
853 if (code == KC_NO) { 845 if (code == KC_NO) {
854 return; 846 return;
855 } 847
856#ifdef LOCKING_SUPPORT_ENABLE 848#ifdef LOCKING_SUPPORT_ENABLE
857 else if (KC_LOCKING_CAPS_LOCK == code) { 849 } else if (KC_LOCKING_CAPS_LOCK == code) {
858# ifdef LOCKING_RESYNC_ENABLE 850# ifdef LOCKING_RESYNC_ENABLE
859 // Resync: ignore if caps lock already is on 851 // Resync: ignore if caps lock already is on
860 if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return; 852 if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return;
@@ -864,9 +856,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
864 wait_ms(TAP_HOLD_CAPS_DELAY); 856 wait_ms(TAP_HOLD_CAPS_DELAY);
865 del_key(KC_CAPS_LOCK); 857 del_key(KC_CAPS_LOCK);
866 send_keyboard_report(); 858 send_keyboard_report();
867 }
868 859
869 else if (KC_LOCKING_NUM_LOCK == code) { 860 } else if (KC_LOCKING_NUM_LOCK == code) {
870# ifdef LOCKING_RESYNC_ENABLE 861# ifdef LOCKING_RESYNC_ENABLE
871 if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return; 862 if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
872# endif 863# endif
@@ -875,9 +866,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
875 wait_ms(100); 866 wait_ms(100);
876 del_key(KC_NUM_LOCK); 867 del_key(KC_NUM_LOCK);
877 send_keyboard_report(); 868 send_keyboard_report();
878 }
879 869
880 else if (KC_LOCKING_SCROLL_LOCK == code) { 870 } else if (KC_LOCKING_SCROLL_LOCK == code) {
881# ifdef LOCKING_RESYNC_ENABLE 871# ifdef LOCKING_RESYNC_ENABLE
882 if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return; 872 if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
883# endif 873# endif
@@ -886,10 +876,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
886 wait_ms(100); 876 wait_ms(100);
887 del_key(KC_SCROLL_LOCK); 877 del_key(KC_SCROLL_LOCK);
888 send_keyboard_report(); 878 send_keyboard_report();
889 }
890#endif 879#endif
891 880
892 else if IS_KEY (code) { 881 } else if IS_KEY (code) {
893 // TODO: should push command_proc out of this block? 882 // TODO: should push command_proc out of this block?
894 if (command_proc(code)) return; 883 if (command_proc(code)) return;
895 884
@@ -922,15 +911,15 @@ __attribute__((weak)) void register_code(uint8_t code) {
922 } else if IS_MOD (code) { 911 } else if IS_MOD (code) {
923 add_mods(MOD_BIT(code)); 912 add_mods(MOD_BIT(code));
924 send_keyboard_report(); 913 send_keyboard_report();
925 } 914
926#ifdef EXTRAKEY_ENABLE 915#ifdef EXTRAKEY_ENABLE
927 else if IS_SYSTEM (code) { 916 } else if IS_SYSTEM (code) {
928 host_system_send(KEYCODE2SYSTEM(code)); 917 host_system_send(KEYCODE2SYSTEM(code));
929 } else if IS_CONSUMER (code) { 918 } else if IS_CONSUMER (code) {
930 host_consumer_send(KEYCODE2CONSUMER(code)); 919 host_consumer_send(KEYCODE2CONSUMER(code));
931 }
932#endif 920#endif
933 else if IS_MOUSEKEY (code) { 921
922 } else if IS_MOUSEKEY (code) {
934 register_mouse(code, true); 923 register_mouse(code, true);
935 } 924 }
936} 925}
@@ -942,9 +931,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
942__attribute__((weak)) void unregister_code(uint8_t code) { 931__attribute__((weak)) void unregister_code(uint8_t code) {
943 if (code == KC_NO) { 932 if (code == KC_NO) {
944 return; 933 return;
945 } 934
946#ifdef LOCKING_SUPPORT_ENABLE 935#ifdef LOCKING_SUPPORT_ENABLE
947 else if (KC_LOCKING_CAPS_LOCK == code) { 936 } else if (KC_LOCKING_CAPS_LOCK == code) {
948# ifdef LOCKING_RESYNC_ENABLE 937# ifdef LOCKING_RESYNC_ENABLE
949 // Resync: ignore if caps lock already is off 938 // Resync: ignore if caps lock already is off
950 if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return; 939 if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return;
@@ -953,9 +942,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
953 send_keyboard_report(); 942 send_keyboard_report();
954 del_key(KC_CAPS_LOCK); 943 del_key(KC_CAPS_LOCK);
955 send_keyboard_report(); 944 send_keyboard_report();
956 }
957 945
958 else if (KC_LOCKING_NUM_LOCK == code) { 946 } else if (KC_LOCKING_NUM_LOCK == code) {
959# ifdef LOCKING_RESYNC_ENABLE 947# ifdef LOCKING_RESYNC_ENABLE
960 if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return; 948 if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
961# endif 949# endif
@@ -963,9 +951,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
963 send_keyboard_report(); 951 send_keyboard_report();
964 del_key(KC_NUM_LOCK); 952 del_key(KC_NUM_LOCK);
965 send_keyboard_report(); 953 send_keyboard_report();
966 }
967 954
968 else if (KC_LOCKING_SCROLL_LOCK == code) { 955 } else if (KC_LOCKING_SCROLL_LOCK == code) {
969# ifdef LOCKING_RESYNC_ENABLE 956# ifdef LOCKING_RESYNC_ENABLE
970 if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return; 957 if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
971# endif 958# endif
@@ -973,19 +960,22 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
973 send_keyboard_report(); 960 send_keyboard_report();
974 del_key(KC_SCROLL_LOCK); 961 del_key(KC_SCROLL_LOCK);
975 send_keyboard_report(); 962 send_keyboard_report();
976 }
977#endif 963#endif
978 964
979 else if IS_KEY (code) { 965 } else if IS_KEY (code) {
980 del_key(code); 966 del_key(code);
981 send_keyboard_report(); 967 send_keyboard_report();
982 } else if IS_MOD (code) { 968 } else if IS_MOD (code) {
983 del_mods(MOD_BIT(code)); 969 del_mods(MOD_BIT(code));
984 send_keyboard_report(); 970 send_keyboard_report();
971
972#ifdef EXTRAKEY_ENABLE
985 } else if IS_SYSTEM (code) { 973 } else if IS_SYSTEM (code) {
986 host_system_send(0); 974 host_system_send(0);
987 } else if IS_CONSUMER (code) { 975 } else if IS_CONSUMER (code) {
988 host_consumer_send(0); 976 host_consumer_send(0);
977#endif
978
989 } else if IS_MOUSEKEY (code) { 979 } else if IS_MOUSEKEY (code) {
990 register_mouse(code, false); 980 register_mouse(code, false);
991 } 981 }