aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-08-15 19:48:14 -0400
committerGitHub <noreply@github.com>2017-08-15 19:48:14 -0400
commit565c670ca48ac636b3e7625aaba68a01e1d72f78 (patch)
treebea65a1b51c591c651a3f4de5bf2bc3f604ff040
parentaee4e4650b670af4c1c453f1fba28f77bcf27287 (diff)
parentb4be711af1794d2f5eeb4ce1a1db38a1b5d8fd6d (diff)
downloadqmk_firmware-565c670ca48ac636b3e7625aaba68a01e1d72f78.tar.gz
qmk_firmware-565c670ca48ac636b3e7625aaba68a01e1d72f78.zip
Merge pull request #1571 from BalzGuenat/grave-esc-fix
Fix for issue #1568
-rw-r--r--docs/faq_keymap.md2
-rw-r--r--quantum/quantum.c19
2 files changed, 16 insertions, 5 deletions
diff --git a/docs/faq_keymap.md b/docs/faq_keymap.md
index 3c2795816..0d24a7667 100644
--- a/docs/faq_keymap.md
+++ b/docs/faq_keymap.md
@@ -116,7 +116,7 @@ https://github.com/tekezo/Karabiner/issues/403
116 116
117## Esc and `~ on a key 117## Esc and `~ on a key
118 118
119Use `GRAVE_ESC` or `KC_GESC` in your keymap. `GUI`+`GRAVE_ESC` results in `\`` and `SHIFT`+`GRAVE_ESC` results in `~`. 119Use `GRAVE_ESC` or `KC_GESC` in your keymap. `GUI`+`GRAVE_ESC` results in `` ` `` and `SHIFT`+`GRAVE_ESC` results in `~`.
120 120
121Note that this will break the CTRL+SHIFT+ESC shortcut to the Windows task manager. Use `#define GRAVE_ESC_CTRL_OVERRIDE` in your `config.h` to get the shortcut back. With this option, `ESC_GRAVE` results in `ESC` if `CTRL` is held, even if `SHIFT` or `GUI` are also held. 121Note that this will break the CTRL+SHIFT+ESC shortcut to the Windows task manager. Use `#define GRAVE_ESC_CTRL_OVERRIDE` in your `config.h` to get the shortcut back. With this option, `ESC_GRAVE` results in `ESC` if `CTRL` is held, even if `SHIFT` or `GUI` are also held.
122 122
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) {
161static bool shift_interrupted[2] = {0, 0}; 161static bool shift_interrupted[2] = {0, 0};
162static uint16_t scs_timer[2] = {0, 0}; 162static 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 */
167static bool grave_esc_was_shifted = false;
168
164bool process_record_quantum(keyrecord_t *record) { 169bool 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;