From f59510aea8404ef922c6ff11f23cb623a243d61b Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 18 Nov 2014 18:36:29 +0900 Subject: [PATCH] Implement a tricky esc function for GH60 --- keyboard/gh60/keymap_common.h | 1 + keyboard/gh60/keymap_poker2.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h index 5f808023..12ebae16 100644 --- a/keyboard/gh60/keymap_common.h +++ b/keyboard/gh60/keymap_common.h @@ -22,6 +22,7 @@ along with this program. If not, see . #include #include "keycode.h" #include "action.h" +#include "action_util.h" #include "action_macro.h" #include "report.h" #include "host.h" diff --git a/keyboard/gh60/keymap_poker2.c b/keyboard/gh60/keymap_poker2.c index f6e560d1..3d22553d 100644 --- a/keyboard/gh60/keymap_poker2.c +++ b/keyboard/gh60/keymap_poker2.c @@ -70,3 +70,31 @@ uint16_t fn_actions_count(void) { return sizeof(fn_actions) / sizeof(fn_actions[0]); } #endif + +enum { + TRICKY_ESC = 0, +}; + +#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + static uint8_t tricky_esc_registered; + switch (id) { + case TRICKY_ESC: + if (record->event.pressed) { + if (get_mods() & MODS_SHIFT_MASK) { + tricky_esc_registered = KC_GRV; + } + else { + tricky_esc_registered = KC_ESC; + } + register_code(tricky_esc_registered); + send_keyboard_report(); + } + else { + unregister_code(tricky_esc_registered); + send_keyboard_report(); + } + break; + } +}