mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 11:30:30 +08:00
Small un/register_code() cleanups (#18544)
This commit is contained in:
parent
8bd73d4455
commit
2c96c75263
|
@ -527,18 +527,10 @@ void process_action(keyrecord_t *record, action_t action) {
|
||||||
case ACT_USAGE:
|
case ACT_USAGE:
|
||||||
switch (action.usage.page) {
|
switch (action.usage.page) {
|
||||||
case PAGE_SYSTEM:
|
case PAGE_SYSTEM:
|
||||||
if (event.pressed) {
|
host_system_send(event.pressed ? action.usage.code : 0);
|
||||||
host_system_send(action.usage.code);
|
|
||||||
} else {
|
|
||||||
host_system_send(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PAGE_CONSUMER:
|
case PAGE_CONSUMER:
|
||||||
if (event.pressed) {
|
host_consumer_send(event.pressed ? action.usage.code : 0);
|
||||||
host_consumer_send(action.usage.code);
|
|
||||||
} else {
|
|
||||||
host_consumer_send(0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -852,9 +844,9 @@ void process_action(keyrecord_t *record, action_t action) {
|
||||||
__attribute__((weak)) void register_code(uint8_t code) {
|
__attribute__((weak)) void register_code(uint8_t code) {
|
||||||
if (code == KC_NO) {
|
if (code == KC_NO) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
#ifdef LOCKING_SUPPORT_ENABLE
|
#ifdef LOCKING_SUPPORT_ENABLE
|
||||||
else if (KC_LOCKING_CAPS_LOCK == code) {
|
} else if (KC_LOCKING_CAPS_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
// Resync: ignore if caps lock already is on
|
// Resync: ignore if caps lock already is on
|
||||||
if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return;
|
if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return;
|
||||||
|
@ -864,9 +856,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
||||||
wait_ms(TAP_HOLD_CAPS_DELAY);
|
wait_ms(TAP_HOLD_CAPS_DELAY);
|
||||||
del_key(KC_CAPS_LOCK);
|
del_key(KC_CAPS_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_NUM_LOCK == code) {
|
} else if (KC_LOCKING_NUM_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
|
if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
|
||||||
# endif
|
# endif
|
||||||
|
@ -875,9 +866,8 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
||||||
wait_ms(100);
|
wait_ms(100);
|
||||||
del_key(KC_NUM_LOCK);
|
del_key(KC_NUM_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_SCROLL_LOCK == code) {
|
} else if (KC_LOCKING_SCROLL_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
|
if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
|
||||||
# endif
|
# endif
|
||||||
|
@ -886,10 +876,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
||||||
wait_ms(100);
|
wait_ms(100);
|
||||||
del_key(KC_SCROLL_LOCK);
|
del_key(KC_SCROLL_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else if IS_KEY (code) {
|
} else if IS_KEY (code) {
|
||||||
// TODO: should push command_proc out of this block?
|
// TODO: should push command_proc out of this block?
|
||||||
if (command_proc(code)) return;
|
if (command_proc(code)) return;
|
||||||
|
|
||||||
|
@ -922,15 +911,15 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
||||||
} else if IS_MOD (code) {
|
} else if IS_MOD (code) {
|
||||||
add_mods(MOD_BIT(code));
|
add_mods(MOD_BIT(code));
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
#ifdef EXTRAKEY_ENABLE
|
#ifdef EXTRAKEY_ENABLE
|
||||||
else if IS_SYSTEM (code) {
|
} else if IS_SYSTEM (code) {
|
||||||
host_system_send(KEYCODE2SYSTEM(code));
|
host_system_send(KEYCODE2SYSTEM(code));
|
||||||
} else if IS_CONSUMER (code) {
|
} else if IS_CONSUMER (code) {
|
||||||
host_consumer_send(KEYCODE2CONSUMER(code));
|
host_consumer_send(KEYCODE2CONSUMER(code));
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
else if IS_MOUSEKEY (code) {
|
|
||||||
|
} else if IS_MOUSEKEY (code) {
|
||||||
register_mouse(code, true);
|
register_mouse(code, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -942,9 +931,9 @@ __attribute__((weak)) void register_code(uint8_t code) {
|
||||||
__attribute__((weak)) void unregister_code(uint8_t code) {
|
__attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
if (code == KC_NO) {
|
if (code == KC_NO) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
#ifdef LOCKING_SUPPORT_ENABLE
|
#ifdef LOCKING_SUPPORT_ENABLE
|
||||||
else if (KC_LOCKING_CAPS_LOCK == code) {
|
} else if (KC_LOCKING_CAPS_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
// Resync: ignore if caps lock already is off
|
// Resync: ignore if caps lock already is off
|
||||||
if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return;
|
if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return;
|
||||||
|
@ -953,9 +942,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
del_key(KC_CAPS_LOCK);
|
del_key(KC_CAPS_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_NUM_LOCK == code) {
|
} else if (KC_LOCKING_NUM_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
|
if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
|
||||||
# endif
|
# endif
|
||||||
|
@ -963,9 +951,8 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
del_key(KC_NUM_LOCK);
|
del_key(KC_NUM_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_SCROLL_LOCK == code) {
|
} else if (KC_LOCKING_SCROLL_LOCK == code) {
|
||||||
# ifdef LOCKING_RESYNC_ENABLE
|
# ifdef LOCKING_RESYNC_ENABLE
|
||||||
if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
|
if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
|
||||||
# endif
|
# endif
|
||||||
|
@ -973,19 +960,22 @@ __attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
del_key(KC_SCROLL_LOCK);
|
del_key(KC_SCROLL_LOCK);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
else if IS_KEY (code) {
|
} else if IS_KEY (code) {
|
||||||
del_key(code);
|
del_key(code);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
} else if IS_MOD (code) {
|
} else if IS_MOD (code) {
|
||||||
del_mods(MOD_BIT(code));
|
del_mods(MOD_BIT(code));
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
|
||||||
|
#ifdef EXTRAKEY_ENABLE
|
||||||
} else if IS_SYSTEM (code) {
|
} else if IS_SYSTEM (code) {
|
||||||
host_system_send(0);
|
host_system_send(0);
|
||||||
} else if IS_CONSUMER (code) {
|
} else if IS_CONSUMER (code) {
|
||||||
host_consumer_send(0);
|
host_consumer_send(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
} else if IS_MOUSEKEY (code) {
|
} else if IS_MOUSEKEY (code) {
|
||||||
register_mouse(code, false);
|
register_mouse(code, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,11 @@ enum mods_codes {
|
||||||
|
|
||||||
/** \brief Other Keys
|
/** \brief Other Keys
|
||||||
*/
|
*/
|
||||||
enum usage_pages { PAGE_SYSTEM, PAGE_CONSUMER };
|
enum usage_pages {
|
||||||
|
PAGE_SYSTEM,
|
||||||
|
PAGE_CONSUMER,
|
||||||
|
};
|
||||||
|
|
||||||
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM << 10 | (id))
|
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM << 10 | (id))
|
||||||
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER << 10 | (id))
|
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER << 10 | (id))
|
||||||
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
|
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
|
||||||
|
|
Loading…
Reference in a new issue