diff options
| author | Balz Guenat <balz.guenat@gmail.com> | 2017-08-12 11:57:42 +0200 |
|---|---|---|
| committer | Balz Guenat <balz.guenat@gmail.com> | 2017-08-12 12:15:36 +0200 |
| commit | b4be711af1794d2f5eeb4ce1a1db38a1b5d8fd6d (patch) | |
| tree | 1050c65d0605ff2932677ffbb29e56431e5716d1 /quantum/quantum.c | |
| parent | 430151dd51b8b0d925850ad4d52c8bae41d3c154 (diff) | |
| download | qmk_firmware-b4be711af1794d2f5eeb4ce1a1db38a1b5d8fd6d.tar.gz qmk_firmware-b4be711af1794d2f5eeb4ce1a1db38a1b5d8fd6d.zip | |
fix for issue #1568
Diffstat (limited to 'quantum/quantum.c')
| -rw-r--r-- | quantum/quantum.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index aac1d07a9..65213eaea 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -161,6 +161,11 @@ void reset_keyboard(void) { | |||
| 161 | static bool shift_interrupted[2] = {0, 0}; | 161 | static bool shift_interrupted[2] = {0, 0}; |
| 162 | static uint16_t scs_timer[2] = {0, 0}; | 162 | static uint16_t scs_timer[2] = {0, 0}; |
| 163 | 163 | ||
| 164 | /* true if the last press of GRAVE_ESC was shifted (i.e. GUI or SHIFT were pressed), false otherwise. | ||
| 165 | * Used to ensure that the correct keycode is released if the key is released. | ||
| 166 | */ | ||
| 167 | static bool grave_esc_was_shifted = false; | ||
| 168 | |||
| 164 | bool process_record_quantum(keyrecord_t *record) { | 169 | bool process_record_quantum(keyrecord_t *record) { |
| 165 | 170 | ||
| 166 | /* This gets the keycode from the key pressed */ | 171 | /* This gets the keycode from the key pressed */ |
| @@ -475,10 +480,9 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 475 | // break; | 480 | // break; |
| 476 | } | 481 | } |
| 477 | case GRAVE_ESC: { | 482 | case GRAVE_ESC: { |
| 478 | void (*method)(uint8_t) = (record->event.pressed) ? &add_key : &del_key; | ||
| 479 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) | 483 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) |
| 480 | |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); | 484 | |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); |
| 481 | 485 | ||
| 482 | #ifdef GRAVE_ESC_CTRL_OVERRIDE | 486 | #ifdef GRAVE_ESC_CTRL_OVERRIDE |
| 483 | // if CTRL is pressed, ESC is always read as ESC, even if SHIFT or GUI is pressed. | 487 | // if CTRL is pressed, ESC is always read as ESC, even if SHIFT or GUI is pressed. |
| 484 | // this is handy for the ctrl+shift+esc shortcut on windows, among other things. | 488 | // this is handy for the ctrl+shift+esc shortcut on windows, among other things. |
| @@ -486,8 +490,15 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 486 | shifted = 0; | 490 | shifted = 0; |
| 487 | #endif | 491 | #endif |
| 488 | 492 | ||
| 489 | method(shifted ? KC_GRAVE : KC_ESCAPE); | 493 | if (record->event.pressed) { |
| 490 | send_keyboard_report(); | 494 | grave_esc_was_shifted = shifted; |
| 495 | add_key(shifted ? KC_GRAVE : KC_ESCAPE); | ||
| 496 | } | ||
| 497 | else { | ||
| 498 | del_key(grave_esc_was_shifted ? KC_GRAVE : KC_ESCAPE); | ||
| 499 | } | ||
| 500 | |||
| 501 | send_keyboard_report(); | ||
| 491 | } | 502 | } |
| 492 | default: { | 503 | default: { |
| 493 | shift_interrupted[0] = true; | 504 | shift_interrupted[0] = true; |
