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

Fix for issue #1568
This commit is contained in:
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,7 +480,6 @@ 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)));
@ -486,7 +490,14 @@ bool process_record_quantum(keyrecord_t *record) {
shifted = 0; shifted = 0;
#endif #endif
method(shifted ? KC_GRAVE : KC_ESCAPE); 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(); send_keyboard_report();
} }
default: { default: {