diff options
| author | Stefan Kerkmann <karlk90@pm.me> | 2022-12-17 15:06:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-17 14:06:27 +0000 |
| commit | 85984902cfcfd852daf335f67cb97d6520531def (patch) | |
| tree | 464ca8c4c1a4bb14e812fcd4b4aad5facd0ee2ea | |
| parent | dedc54a328ab900f47da8478bd9c6b7d14891e15 (diff) | |
Introduce IS_EVENT instead of !IS_NOEVENT (#19366)
| -rw-r--r-- | quantum/action.c | 6 | ||||
| -rw-r--r-- | quantum/action_tapping.c | 14 | ||||
| -rw-r--r-- | quantum/keyboard.h | 7 |
3 files changed, 15 insertions, 12 deletions
diff --git a/quantum/action.c b/quantum/action.c index 2634dff18c..f6fbb999c8 100644 --- a/quantum/action.c +++ b/quantum/action.c | |||
| @@ -70,7 +70,7 @@ __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { | |||
| 70 | * FIXME: Needs documentation. | 70 | * FIXME: Needs documentation. |
| 71 | */ | 71 | */ |
| 72 | void action_exec(keyevent_t event) { | 72 | void action_exec(keyevent_t event) { |
| 73 | if (!IS_NOEVENT(event)) { | 73 | if (IS_EVENT(event)) { |
| 74 | ac_dprintf("\n---- action_exec: start -----\n"); | 74 | ac_dprintf("\n---- action_exec: start -----\n"); |
| 75 | ac_dprintf("EVENT: "); | 75 | ac_dprintf("EVENT: "); |
| 76 | debug_event(event); | 76 | debug_event(event); |
| @@ -87,7 +87,7 @@ void action_exec(keyevent_t event) { | |||
| 87 | 87 | ||
| 88 | #ifdef SWAP_HANDS_ENABLE | 88 | #ifdef SWAP_HANDS_ENABLE |
| 89 | // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined. | 89 | // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined. |
| 90 | if (!IS_NOEVENT(event)) { | 90 | if (IS_EVENT(event)) { |
| 91 | process_hand_swap(&event); | 91 | process_hand_swap(&event); |
| 92 | } | 92 | } |
| 93 | #endif | 93 | #endif |
| @@ -125,7 +125,7 @@ void action_exec(keyevent_t event) { | |||
| 125 | if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) { | 125 | if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) { |
| 126 | process_record(&record); | 126 | process_record(&record); |
| 127 | } | 127 | } |
| 128 | if (!IS_NOEVENT(record.event)) { | 128 | if (IS_EVENT(record.event)) { |
| 129 | ac_dprintf("processed: "); | 129 | ac_dprintf("processed: "); |
| 130 | debug_record(record); | 130 | debug_record(record); |
| 131 | dprintln(); | 131 | dprintln(); |
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index 3a9bc549ac..821265d399 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | # endif | 17 | # endif |
| 18 | # endif | 18 | # endif |
| 19 | 19 | ||
| 20 | # define IS_TAPPING() !IS_NOEVENT(tapping_key.event) | 20 | # define IS_TAPPING() IS_EVENT(tapping_key.event) |
| 21 | # define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) | 21 | # define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed) |
| 22 | # define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) | 22 | # define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed) |
| 23 | # define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) | 23 | # define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k))) |
| @@ -85,7 +85,7 @@ static void debug_waiting_buffer(void); | |||
| 85 | */ | 85 | */ |
| 86 | void action_tapping_process(keyrecord_t record) { | 86 | void action_tapping_process(keyrecord_t record) { |
| 87 | if (process_tapping(&record)) { | 87 | if (process_tapping(&record)) { |
| 88 | if (!IS_NOEVENT(record.event)) { | 88 | if (IS_EVENT(record.event)) { |
| 89 | ac_dprintf("processed: "); | 89 | ac_dprintf("processed: "); |
| 90 | debug_record(record); | 90 | debug_record(record); |
| 91 | ac_dprintf("\n"); | 91 | ac_dprintf("\n"); |
| @@ -101,7 +101,7 @@ void action_tapping_process(keyrecord_t record) { | |||
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | // process waiting_buffer | 103 | // process waiting_buffer |
| 104 | if (!IS_NOEVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) { | 104 | if (IS_EVENT(record.event) && waiting_buffer_head != waiting_buffer_tail) { |
| 105 | ac_dprintf("---- action_exec: process waiting_buffer -----\n"); | 105 | ac_dprintf("---- action_exec: process waiting_buffer -----\n"); |
| 106 | } | 106 | } |
| 107 | for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { | 107 | for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { |
| @@ -113,7 +113,7 @@ void action_tapping_process(keyrecord_t record) { | |||
| 113 | break; | 113 | break; |
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | if (!IS_NOEVENT(record.event)) { | 116 | if (IS_EVENT(record.event)) { |
| 117 | ac_dprintf("\n"); | 117 | ac_dprintf("\n"); |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| @@ -316,7 +316,7 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 316 | debug_tapping_key(); | 316 | debug_tapping_key(); |
| 317 | return true; | 317 | return true; |
| 318 | } else { | 318 | } else { |
| 319 | if (!IS_NOEVENT(event)) { | 319 | if (IS_EVENT(event)) { |
| 320 | ac_dprintf("Tapping: key event while last tap(>0).\n"); | 320 | ac_dprintf("Tapping: key event while last tap(>0).\n"); |
| 321 | } | 321 | } |
| 322 | process_record(keyp); | 322 | process_record(keyp); |
| @@ -362,7 +362,7 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 362 | debug_tapping_key(); | 362 | debug_tapping_key(); |
| 363 | return true; | 363 | return true; |
| 364 | } else { | 364 | } else { |
| 365 | if (!IS_NOEVENT(event)) { | 365 | if (IS_EVENT(event)) { |
| 366 | ac_dprintf("Tapping: key event while last timeout tap(>0).\n"); | 366 | ac_dprintf("Tapping: key event while last timeout tap(>0).\n"); |
| 367 | } | 367 | } |
| 368 | process_record(keyp); | 368 | process_record(keyp); |
| @@ -402,7 +402,7 @@ bool process_tapping(keyrecord_t *keyp) { | |||
| 402 | return true; | 402 | return true; |
| 403 | } | 403 | } |
| 404 | } else { | 404 | } else { |
| 405 | if (!IS_NOEVENT(event)) ac_dprintf("Tapping: other key just after tap.\n"); | 405 | if (IS_EVENT(event)) ac_dprintf("Tapping: other key just after tap.\n"); |
| 406 | process_record(keyp); | 406 | process_record(keyp); |
| 407 | return true; | 407 | return true; |
| 408 | } | 408 | } |
diff --git a/quantum/keyboard.h b/quantum/keyboard.h index 86ce65aac1..d0b52dd13a 100644 --- a/quantum/keyboard.h +++ b/quantum/keyboard.h | |||
| @@ -53,6 +53,9 @@ typedef struct { | |||
| 53 | static inline bool IS_NOEVENT(keyevent_t event) { | 53 | static inline bool IS_NOEVENT(keyevent_t event) { |
| 54 | return event.time == 0 || (event.key.row == KEYLOC_TICK && event.key.col == KEYLOC_TICK); | 54 | return event.time == 0 || (event.key.row == KEYLOC_TICK && event.key.col == KEYLOC_TICK); |
| 55 | } | 55 | } |
| 56 | static inline bool IS_EVENT(keyevent_t event) { | ||
| 57 | return !IS_NOEVENT(event); | ||
| 58 | } | ||
| 56 | static inline bool IS_KEYEVENT(keyevent_t event) { | 59 | static inline bool IS_KEYEVENT(keyevent_t event) { |
| 57 | return event.key.row < MATRIX_ROWS && event.key.col < MATRIX_COLS; | 60 | return event.key.row < MATRIX_ROWS && event.key.col < MATRIX_COLS; |
| 58 | } | 61 | } |
| @@ -63,10 +66,10 @@ static inline bool IS_ENCODEREVENT(keyevent_t event) { | |||
| 63 | return event.key.row == KEYLOC_ENCODER_CW || event.key.row == KEYLOC_ENCODER_CCW; | 66 | return event.key.row == KEYLOC_ENCODER_CW || event.key.row == KEYLOC_ENCODER_CCW; |
| 64 | } | 67 | } |
| 65 | static inline bool IS_PRESSED(keyevent_t event) { | 68 | static inline bool IS_PRESSED(keyevent_t event) { |
| 66 | return !IS_NOEVENT(event) && event.pressed; | 69 | return IS_EVENT(event) && event.pressed; |
| 67 | } | 70 | } |
| 68 | static inline bool IS_RELEASED(keyevent_t event) { | 71 | static inline bool IS_RELEASED(keyevent_t event) { |
| 69 | return !IS_NOEVENT(event) && !event.pressed; | 72 | return IS_EVENT(event) && !event.pressed; |
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | /* Common keyevent object factory */ | 75 | /* Common keyevent object factory */ |
