Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix process_combo which assign -1 to uint16_t #3697

Merged
merged 1 commit into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions quantum/process_keycode/process_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#include "print.h"


#define COMBO_TIMER_ELAPSED -1


__attribute__ ((weak))
combo_t key_combos[COMBO_COUNT] = {

Expand Down Expand Up @@ -65,17 +62,18 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
if (-1 == (int8_t)index) return false;

/* The combos timer is used to signal whether the combo is active */
bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true;
bool is_combo_active = combo->is_active;

if (record->event.pressed) {
KEY_STATE_DOWN(index);

if (is_combo_active) {
if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
send_combo(combo->keycode, true);
combo->timer = COMBO_TIMER_ELAPSED;
combo->is_active = false;
} else { /* Combo key was pressed */
combo->timer = timer_read();
combo->is_active = true;
#ifdef COMBO_ALLOW_ACTION_KEYS
combo->prev_record = *record;
#else
Expand All @@ -99,13 +97,15 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
send_keyboard_report();
unregister_code16(keycode);
#endif
combo->is_active = false;
combo->timer = 0;
}

KEY_STATE_UP(index);
}

if (NO_COMBO_KEYS_ARE_DOWN) {
combo->is_active = true;
combo->timer = 0;
}

Expand All @@ -132,14 +132,14 @@ void matrix_scan_combo(void)
#pragma GCC diagnostic ignored "-Warray-bounds"
combo_t *combo = &key_combos[i];
#pragma GCC diagnostic pop
if (combo->timer &&
combo->timer != COMBO_TIMER_ELAPSED &&
if (combo->is_active &&
combo->timer &&
timer_elapsed(combo->timer) > COMBO_TERM) {

/* This disables the combo, meaning key events for this
* combo will be handled by the next processors in the chain
*/
combo->timer = COMBO_TIMER_ELAPSED;
combo->is_active = false;

#ifdef COMBO_ALLOW_ACTION_KEYS
process_action(&combo->prev_record,
Expand Down
1 change: 1 addition & 0 deletions quantum/process_keycode/process_combo.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct
uint8_t state;
#endif
uint16_t timer;
bool is_active;
#ifdef COMBO_ALLOW_ACTION_KEYS
keyrecord_t prev_record;
#else
Expand Down