From 052e616a2cc019b7c766821d151008e20da3e7c8 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Mon, 14 Dec 2015 15:49:09 +0900 Subject: [PATCH] redscarfII: Add triky esc for RedScarfII/II+ --- keyboard/RedScarfII/keymap_common.h | 1 + keyboard/RedScarfII/keymap_default.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/keyboard/RedScarfII/keymap_common.h b/keyboard/RedScarfII/keymap_common.h index d2a7fd5b..aeab7466 100644 --- a/keyboard/RedScarfII/keymap_common.h +++ b/keyboard/RedScarfII/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/RedScarfII/keymap_default.c b/keyboard/RedScarfII/keymap_default.c index 549b08a4..11945d62 100644 --- a/keyboard/RedScarfII/keymap_default.c +++ b/keyboard/RedScarfII/keymap_default.c @@ -174,7 +174,8 @@ enum function_id { AF_RGB_DECREASE, AF_RGB_FIXED, AF_RGB_VARIABLE, - AF_RGB_STEP + AF_RGB_STEP, + TRICKY_ESC }; /* @@ -227,6 +228,7 @@ uint16_t fn_actions_count(void) { } #endif +#define MODS_SHIFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)) void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { if (record->event.pressed) { @@ -257,6 +259,25 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) break; } } + 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; + } } /*