diff options
| author | Pablo MartÃnez <58857054+elpekenin@users.noreply.github.com> | 2025-09-30 16:52:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-30 15:52:43 +0100 |
| commit | bbd6e8ab340bb4b3f25671fea59fd608397e8a34 (patch) | |
| tree | 0e23e03f465054450bc4a950e427622b881ef9e8 /quantum/action_util.h | |
| parent | 24bc4aef03ea3aec8cdb515ffe0942e4f6939c4a (diff) | |
[Feature] Implement `mod_t` packed struct (#25168)
Diffstat (limited to 'quantum/action_util.h')
| -rw-r--r-- | quantum/action_util.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/quantum/action_util.h b/quantum/action_util.h index d2ecb145be..8b1974cd32 100644 --- a/quantum/action_util.h +++ b/quantum/action_util.h | |||
| @@ -18,6 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 18 | #pragma once | 18 | #pragma once |
| 19 | 19 | ||
| 20 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | |||
| 22 | #include "compiler_support.h" | ||
| 21 | #include "report.h" | 23 | #include "report.h" |
| 22 | #include "modifiers.h" | 24 | #include "modifiers.h" |
| 23 | 25 | ||
| @@ -25,6 +27,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 25 | extern "C" { | 27 | extern "C" { |
| 26 | #endif | 28 | #endif |
| 27 | 29 | ||
| 30 | typedef union { | ||
| 31 | uint8_t raw; | ||
| 32 | struct { | ||
| 33 | bool left_ctrl : 1; | ||
| 34 | bool left_shift : 1; | ||
| 35 | bool left_alt : 1; | ||
| 36 | bool left_gui : 1; | ||
| 37 | bool right_ctrl : 1; | ||
| 38 | bool right_shift : 1; | ||
| 39 | bool right_alt : 1; | ||
| 40 | bool right_gui : 1; | ||
| 41 | }; | ||
| 42 | } PACKED mod_t; | ||
| 43 | STATIC_ASSERT(sizeof(mod_t) == sizeof(uint8_t), "Invalid size for 'mod_t'"); | ||
| 44 | |||
| 28 | extern report_keyboard_t *keyboard_report; | 45 | extern report_keyboard_t *keyboard_report; |
| 29 | #ifdef NKRO_ENABLE | 46 | #ifdef NKRO_ENABLE |
| 30 | extern report_nkro_t *nkro_report; | 47 | extern report_nkro_t *nkro_report; |
| @@ -47,6 +64,7 @@ inline void clear_keys(void) { | |||
| 47 | 64 | ||
| 48 | /* modifier */ | 65 | /* modifier */ |
| 49 | uint8_t get_mods(void); | 66 | uint8_t get_mods(void); |
| 67 | mod_t get_mod_state(void); | ||
| 50 | void add_mods(uint8_t mods); | 68 | void add_mods(uint8_t mods); |
| 51 | void del_mods(uint8_t mods); | 69 | void del_mods(uint8_t mods); |
| 52 | void set_mods(uint8_t mods); | 70 | void set_mods(uint8_t mods); |
| @@ -54,6 +72,7 @@ void clear_mods(void); | |||
| 54 | 72 | ||
| 55 | /* weak modifier */ | 73 | /* weak modifier */ |
| 56 | uint8_t get_weak_mods(void); | 74 | uint8_t get_weak_mods(void); |
| 75 | mod_t get_weak_mod_state(void); | ||
| 57 | void add_weak_mods(uint8_t mods); | 76 | void add_weak_mods(uint8_t mods); |
| 58 | void del_weak_mods(uint8_t mods); | 77 | void del_weak_mods(uint8_t mods); |
| 59 | void set_weak_mods(uint8_t mods); | 78 | void set_weak_mods(uint8_t mods); |
| @@ -61,6 +80,7 @@ void clear_weak_mods(void); | |||
| 61 | 80 | ||
| 62 | /* oneshot modifier */ | 81 | /* oneshot modifier */ |
| 63 | uint8_t get_oneshot_mods(void); | 82 | uint8_t get_oneshot_mods(void); |
| 83 | mod_t get_oneshot_mod_state(void); | ||
| 64 | void add_oneshot_mods(uint8_t mods); | 84 | void add_oneshot_mods(uint8_t mods); |
| 65 | void del_oneshot_mods(uint8_t mods); | 85 | void del_oneshot_mods(uint8_t mods); |
| 66 | void set_oneshot_mods(uint8_t mods); | 86 | void set_oneshot_mods(uint8_t mods); |
| @@ -68,6 +88,7 @@ void clear_oneshot_mods(void); | |||
| 68 | bool has_oneshot_mods_timed_out(void); | 88 | bool has_oneshot_mods_timed_out(void); |
| 69 | 89 | ||
| 70 | uint8_t get_oneshot_locked_mods(void); | 90 | uint8_t get_oneshot_locked_mods(void); |
| 91 | mod_t get_oneshot_locked_mod_state(void); | ||
| 71 | void add_oneshot_locked_mods(uint8_t mods); | 92 | void add_oneshot_locked_mods(uint8_t mods); |
| 72 | void set_oneshot_locked_mods(uint8_t mods); | 93 | void set_oneshot_locked_mods(uint8_t mods); |
| 73 | void clear_oneshot_locked_mods(void); | 94 | void clear_oneshot_locked_mods(void); |
