Make (un)register code functions weak (#15285)
parent
f9cf09ebd1
commit
672c6b4721
|
@ -794,7 +794,7 @@ void process_action(keyrecord_t *record, action_t action) {
|
||||||
*
|
*
|
||||||
* FIXME: Needs documentation.
|
* FIXME: Needs documentation.
|
||||||
*/
|
*/
|
||||||
void register_code(uint8_t code) {
|
__attribute__((weak)) void register_code(uint8_t code) {
|
||||||
if (code == KC_NO) {
|
if (code == KC_NO) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -890,7 +890,7 @@ void register_code(uint8_t code) {
|
||||||
*
|
*
|
||||||
* FIXME: Needs documentation.
|
* FIXME: Needs documentation.
|
||||||
*/
|
*/
|
||||||
void unregister_code(uint8_t code) {
|
__attribute__((weak)) void unregister_code(uint8_t code) {
|
||||||
if (code == KC_NO) {
|
if (code == KC_NO) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -955,7 +955,7 @@ void unregister_code(uint8_t code) {
|
||||||
* \param code The basic keycode to tap.
|
* \param code The basic keycode to tap.
|
||||||
* \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
|
* \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
|
||||||
*/
|
*/
|
||||||
void tap_code_delay(uint8_t code, uint16_t delay) {
|
__attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
|
||||||
register_code(code);
|
register_code(code);
|
||||||
for (uint16_t i = delay; i > 0; i--) {
|
for (uint16_t i = delay; i > 0; i--) {
|
||||||
wait_ms(1);
|
wait_ms(1);
|
||||||
|
@ -967,13 +967,13 @@ void tap_code_delay(uint8_t code, uint16_t delay) {
|
||||||
*
|
*
|
||||||
* \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
|
* \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
|
||||||
*/
|
*/
|
||||||
void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); }
|
__attribute__((weak)) void tap_code(uint8_t code) { tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY); }
|
||||||
|
|
||||||
/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
|
/** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
|
||||||
*
|
*
|
||||||
* \param mods A bitfield of modifiers to register.
|
* \param mods A bitfield of modifiers to register.
|
||||||
*/
|
*/
|
||||||
void register_mods(uint8_t mods) {
|
__attribute__((weak)) void register_mods(uint8_t mods) {
|
||||||
if (mods) {
|
if (mods) {
|
||||||
add_mods(mods);
|
add_mods(mods);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
@ -984,7 +984,7 @@ void register_mods(uint8_t mods) {
|
||||||
*
|
*
|
||||||
* \param mods A bitfield of modifiers to unregister.
|
* \param mods A bitfield of modifiers to unregister.
|
||||||
*/
|
*/
|
||||||
void unregister_mods(uint8_t mods) {
|
__attribute__((weak)) void unregister_mods(uint8_t mods) {
|
||||||
if (mods) {
|
if (mods) {
|
||||||
del_mods(mods);
|
del_mods(mods);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
@ -995,7 +995,7 @@ void unregister_mods(uint8_t mods) {
|
||||||
*
|
*
|
||||||
* \param mods A bitfield of modifiers to register.
|
* \param mods A bitfield of modifiers to register.
|
||||||
*/
|
*/
|
||||||
void register_weak_mods(uint8_t mods) {
|
__attribute__((weak)) void register_weak_mods(uint8_t mods) {
|
||||||
if (mods) {
|
if (mods) {
|
||||||
add_weak_mods(mods);
|
add_weak_mods(mods);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
@ -1006,7 +1006,7 @@ void register_weak_mods(uint8_t mods) {
|
||||||
*
|
*
|
||||||
* \param mods A bitfield of modifiers to unregister.
|
* \param mods A bitfield of modifiers to unregister.
|
||||||
*/
|
*/
|
||||||
void unregister_weak_mods(uint8_t mods) {
|
__attribute__((weak)) void unregister_weak_mods(uint8_t mods) {
|
||||||
if (mods) {
|
if (mods) {
|
||||||
del_weak_mods(mods);
|
del_weak_mods(mods);
|
||||||
send_keyboard_report();
|
send_keyboard_report();
|
||||||
|
|
|
@ -76,9 +76,9 @@ uint8_t extract_mod_bits(uint16_t code) {
|
||||||
return mods_to_send;
|
return mods_to_send;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
|
void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
|
||||||
|
|
||||||
void register_code16(uint16_t code) {
|
__attribute__((weak)) void register_code16(uint16_t code) {
|
||||||
if (IS_MOD(code) || code == KC_NO) {
|
if (IS_MOD(code) || code == KC_NO) {
|
||||||
do_code16(code, register_mods);
|
do_code16(code, register_mods);
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,7 +87,7 @@ void register_code16(uint16_t code) {
|
||||||
register_code(code);
|
register_code(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_code16(uint16_t code) {
|
__attribute__((weak)) void unregister_code16(uint16_t code) {
|
||||||
unregister_code(code);
|
unregister_code(code);
|
||||||
if (IS_MOD(code) || code == KC_NO) {
|
if (IS_MOD(code) || code == KC_NO) {
|
||||||
do_code16(code, unregister_mods);
|
do_code16(code, unregister_mods);
|
||||||
|
@ -96,7 +96,7 @@ void unregister_code16(uint16_t code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tap_code16(uint16_t code) {
|
__attribute__((weak)) void tap_code16(uint16_t code) {
|
||||||
register_code16(code);
|
register_code16(code);
|
||||||
#if TAP_CODE_DELAY > 0
|
#if TAP_CODE_DELAY > 0
|
||||||
wait_ms(TAP_CODE_DELAY);
|
wait_ms(TAP_CODE_DELAY);
|
||||||
|
|
Loading…
Reference in New Issue