Skip to content

Commit

Permalink
fix for issue #1568
Browse files Browse the repository at this point in the history
  • Loading branch information
BalzGuenat committed Aug 12, 2017
1 parent 430151d commit b4be711
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ void reset_keyboard(void) {
static bool shift_interrupted[2] = {0, 0};
static uint16_t scs_timer[2] = {0, 0};

/* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise.
* Used to ensure that the correct keycode is released if the key is released.
*/
static bool grave_esc_was_shifted = false;

bool process_record_quantum(keyrecord_t *record) {

/* This gets the keycode from the key pressed */
Expand Down Expand Up @@ -475,19 +480,25 @@ bool process_record_quantum(keyrecord_t *record) {
// break;
}
case GRAVE_ESC: {
void (*method)(uint8_t) = (record->event.pressed) ? &add_key : &del_key;
uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)
|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)));

#ifdef GRAVE_ESC_CTRL_OVERRIDE
// if CTRL is pressed, ESC is always read as ESC, even if SHIFT or GUI is pressed.
// this is handy for the ctrl+shift+esc shortcut on windows, among other things.
if (get_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)))
shifted = 0;
#endif

method(shifted ? KC_GRAVE : KC_ESCAPE);
send_keyboard_report();
if (record->event.pressed) {
grave_esc_was_shifted = shifted;
add_key(shifted ? KC_GRAVE : KC_ESCAPE);
}
else {
del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE);
}

send_keyboard_report();
}
default: {
shift_interrupted[0] = true;
Expand Down

0 comments on commit b4be711

Please sign in to comment.