diff options
| -rw-r--r-- | tmk_core/common/action_util.c | 32 | ||||
| -rw-r--r-- | tmk_core/common/action_util.h | 14 | ||||
| -rw-r--r-- | tmk_core/common/report.c | 30 | ||||
| -rw-r--r-- | tmk_core/common/report.h | 4 |
4 files changed, 45 insertions, 35 deletions
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 511649676..f76398fb9 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
| @@ -136,38 +136,6 @@ void send_keyboard_report(void) { | |||
| 136 | host_keyboard_send(keyboard_report); | 136 | host_keyboard_send(keyboard_report); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | /* key */ | ||
| 140 | void add_key(uint8_t key) | ||
| 141 | { | ||
| 142 | #ifdef NKRO_ENABLE | ||
| 143 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 144 | add_key_bit(keyboard_report, key); | ||
| 145 | return; | ||
| 146 | } | ||
| 147 | #endif | ||
| 148 | add_key_byte(keyboard_report, key); | ||
| 149 | } | ||
| 150 | |||
| 151 | void del_key(uint8_t key) | ||
| 152 | { | ||
| 153 | #ifdef NKRO_ENABLE | ||
| 154 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 155 | del_key_bit(keyboard_report, key); | ||
| 156 | return; | ||
| 157 | } | ||
| 158 | #endif | ||
| 159 | del_key_byte(keyboard_report, key); | ||
| 160 | } | ||
| 161 | |||
| 162 | void clear_keys(void) | ||
| 163 | { | ||
| 164 | // not clear mods | ||
| 165 | for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 166 | keyboard_report->raw[i] = 0; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | |||
| 171 | /* modifier */ | 139 | /* modifier */ |
| 172 | uint8_t get_mods(void) { return real_mods; } | 140 | uint8_t get_mods(void) { return real_mods; } |
| 173 | void add_mods(uint8_t mods) { real_mods |= mods; } | 141 | void add_mods(uint8_t mods) { real_mods |= mods; } |
diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h index 8fb88c0f6..345893151 100644 --- a/tmk_core/common/action_util.h +++ b/tmk_core/common/action_util.h | |||
| @@ -29,9 +29,17 @@ extern report_keyboard_t *keyboard_report; | |||
| 29 | void send_keyboard_report(void); | 29 | void send_keyboard_report(void); |
| 30 | 30 | ||
| 31 | /* key */ | 31 | /* key */ |
| 32 | void add_key(uint8_t key); | 32 | inline void add_key(uint8_t key) { |
| 33 | void del_key(uint8_t key); | 33 | add_key_to_report(keyboard_report, key); |
| 34 | void clear_keys(void); | 34 | } |
| 35 | |||
| 36 | inline void del_key(uint8_t key) { | ||
| 37 | del_key_from_report(keyboard_report, key); | ||
| 38 | } | ||
| 39 | |||
| 40 | inline void clear_keys(void) { | ||
| 41 | clear_keys_from_report(keyboard_report); | ||
| 42 | } | ||
| 35 | 43 | ||
| 36 | /* modifier */ | 44 | /* modifier */ |
| 37 | uint8_t get_mods(void); | 45 | uint8_t get_mods(void); |
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c index 0a67b2534..74c6d3fdd 100644 --- a/tmk_core/common/report.c +++ b/tmk_core/common/report.c | |||
| @@ -175,3 +175,33 @@ void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code) | |||
| 175 | } | 175 | } |
| 176 | } | 176 | } |
| 177 | #endif | 177 | #endif |
| 178 | |||
| 179 | void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key) | ||
| 180 | { | ||
| 181 | #ifdef NKRO_ENABLE | ||
| 182 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 183 | add_key_bit(keyboard_report, key); | ||
| 184 | return; | ||
| 185 | } | ||
| 186 | #endif | ||
| 187 | add_key_byte(keyboard_report, key); | ||
| 188 | } | ||
| 189 | |||
| 190 | void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key) | ||
| 191 | { | ||
| 192 | #ifdef NKRO_ENABLE | ||
| 193 | if (keyboard_protocol && keymap_config.nkro) { | ||
| 194 | del_key_bit(keyboard_report, key); | ||
| 195 | return; | ||
| 196 | } | ||
| 197 | #endif | ||
| 198 | del_key_byte(keyboard_report, key); | ||
| 199 | } | ||
| 200 | |||
| 201 | void clear_keys_from_report(report_keyboard_t* keyboard_report) | ||
| 202 | { | ||
| 203 | // not clear mods | ||
| 204 | for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) { | ||
| 205 | keyboard_report->raw[i] = 0; | ||
| 206 | } | ||
| 207 | } \ No newline at end of file | ||
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h index 30ce80542..899fc524c 100644 --- a/tmk_core/common/report.h +++ b/tmk_core/common/report.h | |||
| @@ -184,6 +184,10 @@ void add_key_bit(report_keyboard_t* keyboard_report, uint8_t code); | |||
| 184 | void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code); | 184 | void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code); |
| 185 | #endif | 185 | #endif |
| 186 | 186 | ||
| 187 | void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key); | ||
| 188 | void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key); | ||
| 189 | void clear_keys_from_report(report_keyboard_t* keyboard_report); | ||
| 190 | |||
| 187 | #ifdef __cplusplus | 191 | #ifdef __cplusplus |
| 188 | } | 192 | } |
| 189 | #endif | 193 | #endif |
