Merge pull request #1571 from BalzGuenat/grave-esc-fix

Fix for issue #1568
master
Jack Humbert 2017-08-15 19:48:14 -04:00 committed by GitHub
commit 565c670ca4
2 changed files with 16 additions and 5 deletions

View File

@ -116,7 +116,7 @@ https://github.com/tekezo/Karabiner/issues/403
## Esc and `~ on a key ## Esc and `~ on a key
Use `GRAVE_ESC` or `KC_GESC` in your keymap. `GUI`+`GRAVE_ESC` results in `\`` and `SHIFT`+`GRAVE_ESC` results in `~`. Use `GRAVE_ESC` or `KC_GESC` in your keymap. `GUI`+`GRAVE_ESC` results in `` ` `` and `SHIFT`+`GRAVE_ESC` results in `~`.
Note 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. Note 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.

View File

@ -161,6 +161,11 @@ void reset_keyboard(void) {
static bool shift_interrupted[2] = {0, 0}; static bool shift_interrupted[2] = {0, 0};
static uint16_t scs_timer[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) { bool process_record_quantum(keyrecord_t *record) {
/* This gets the keycode from the key pressed */ /* This gets the keycode from the key pressed */
@ -475,10 +480,9 @@ bool process_record_quantum(keyrecord_t *record) {
// break; // break;
} }
case GRAVE_ESC: { 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) uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)
|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI))); |MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)));
#ifdef GRAVE_ESC_CTRL_OVERRIDE #ifdef GRAVE_ESC_CTRL_OVERRIDE
// if CTRL is pressed, ESC is always read as ESC, even if SHIFT or GUI is pressed. // 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. // 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) {
shifted = 0; shifted = 0;
#endif #endif
method(shifted ? KC_GRAVE : KC_ESCAPE); if (record->event.pressed) {
send_keyboard_report(); 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: { default: {
shift_interrupted[0] = true; shift_interrupted[0] = true;