Skip to content

Commit

Permalink
Add magic capable (un)register functions
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed May 18, 2020
1 parent e55d55e commit e3de49f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
33 changes: 33 additions & 0 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,39 @@ void tap_code16(uint16_t code) {
unregister_code16(code);
}

void register_magic_code(uint8_t code) {
register_code(keycode_config(code));
}

void register_magic_code16(uint16_t keycode) {
if (keycode >= QK_MODS && keycode <= QK_MODS_MAX) {
keycode = (mod_config((keycode >> 8) & 0x1F) << 8|keycode_config(keycode & 0xFF));
}
register_code16(keycode_config(keycode));
}

void unregister_magic_code(uint8_t code) {
unregister_code(keycode_config(code));
}

void unregister_magic_code16(uint16_t keycode) {
if (keycode >= QK_MODS && keycode <= QK_MODS_MAX) {
keycode = (mod_config((keycode >> 8) & 0x1F) << 8|keycode_config(keycode & 0xFF));
}
unregister_code16(keycode_config(keycode));
}

void tap_magic_code(uint8_t keycode) {
tap_code(keycode_config(keycode));
}

void tap_magic_code16(uint16_t keycode) {
if (keycode >= QK_MODS && keycode <= QK_MODS_MAX) {
keycode = (mod_config((keycode >> 8) & 0x1F) << 8|keycode_config(keycode & 0xFF));
}
tap_code16(keycode_config(keycode));
}

__attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }

__attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); }
Expand Down
6 changes: 6 additions & 0 deletions quantum/quantum.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,12 @@ void shutdown_user(void);
void register_code16(uint16_t code);
void unregister_code16(uint16_t code);
void tap_code16(uint16_t code);
void register_magic_code(uint8_t code);
void register_magic_code16(uint16_t keycode);
void unregister_magic_code(uint8_t code);
void unregister_magic_code16(uint16_t keycode);
void tap_magic_code(uint8_t keycode);
void tap_magic_code16(uint16_t keycode);

void send_dword(uint32_t number);
void send_word(uint16_t number);
Expand Down

0 comments on commit e3de49f

Please sign in to comment.