summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action_util.c32
-rw-r--r--tmk_core/common/action_util.h14
-rw-r--r--tmk_core/common/report.c30
-rw-r--r--tmk_core/common/report.h4
4 files changed, 45 insertions, 35 deletions
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index 511649676f..f76398fb92 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -136,38 +136,6 @@ void send_keyboard_report(void) {
host_keyboard_send(keyboard_report);
}
-/* key */
-void add_key(uint8_t key)
-{
-#ifdef NKRO_ENABLE
- if (keyboard_protocol && keymap_config.nkro) {
- add_key_bit(keyboard_report, key);
- return;
- }
-#endif
- add_key_byte(keyboard_report, key);
-}
-
-void del_key(uint8_t key)
-{
-#ifdef NKRO_ENABLE
- if (keyboard_protocol && keymap_config.nkro) {
- del_key_bit(keyboard_report, key);
- return;
- }
-#endif
- del_key_byte(keyboard_report, key);
-}
-
-void clear_keys(void)
-{
- // not clear mods
- for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
- keyboard_report->raw[i] = 0;
- }
-}
-
-
/* modifier */
uint8_t get_mods(void) { return real_mods; }
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 8fb88c0f65..3458931514 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;
void send_keyboard_report(void);
/* key */
-void add_key(uint8_t key);
-void del_key(uint8_t key);
-void clear_keys(void);
+inline void add_key(uint8_t key) {
+ add_key_to_report(keyboard_report, key);
+}
+
+inline void del_key(uint8_t key) {
+ del_key_from_report(keyboard_report, key);
+}
+
+inline void clear_keys(void) {
+ clear_keys_from_report(keyboard_report);
+}
/* modifier */
uint8_t get_mods(void);
diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c
index 0a67b25344..74c6d3fdd4 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)
}
}
#endif
+
+void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key)
+{
+#ifdef NKRO_ENABLE
+ if (keyboard_protocol && keymap_config.nkro) {
+ add_key_bit(keyboard_report, key);
+ return;
+ }
+#endif
+ add_key_byte(keyboard_report, key);
+}
+
+void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key)
+{
+#ifdef NKRO_ENABLE
+ if (keyboard_protocol && keymap_config.nkro) {
+ del_key_bit(keyboard_report, key);
+ return;
+ }
+#endif
+ del_key_byte(keyboard_report, key);
+}
+
+void clear_keys_from_report(report_keyboard_t* keyboard_report)
+{
+ // not clear mods
+ for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
+ keyboard_report->raw[i] = 0;
+ }
+} \ No newline at end of file
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 30ce805420..899fc524cb 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);
void del_key_bit(report_keyboard_t* keyboard_report, uint8_t code);
#endif
+void add_key_to_report(report_keyboard_t* keyboard_report, int8_t key);
+void del_key_from_report(report_keyboard_t* keyboard_report, uint8_t key);
+void clear_keys_from_report(report_keyboard_t* keyboard_report);
+
#ifdef __cplusplus
}
#endif