diff --git a/keyboards/hineybush/h60/keymaps/tacahiroy/keymap.c b/keyboards/hineybush/h60/keymaps/tacahiroy/keymap.c index 9354515a804b..4b3bb50980a4 100644 --- a/keyboards/hineybush/h60/keymaps/tacahiroy/keymap.c +++ b/keyboards/hineybush/h60/keymaps/tacahiroy/keymap.c @@ -44,10 +44,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [_LOWER] = LAYOUT_60_tsangan_hhkb( - W_IME, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MUTE, KC_MPLY, - _______, _______, XX_TAB, _______, _______, _______, TM_SLST, TM_PREV, TM_WLST, TM_NEXT, KC_PIPE, KC_VOLD, KC_VOLU, KC_DEL, - _______, _______, MOUS, W_SNIP, KC_F5, KC_F3, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, TM_SSH, _______, _______, - _______, _______, CUT, COPY2, PASTE2, TOP, BOTTOM, KC_HOME, KC_END, _______, TM_LASS, _______, _______, + W_IME, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, + _______, _______, XX_TAB, _______, _______, _______, TM_SLST, TM_PREV, TM_WLST, TM_NEXT, KC_PIPE, KC_VOLD, KC_VOLU, KC_MPLY, + _______, _______, MOUS, W_SNIP, KC_F5, KC_F3, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, TM_SSH, TM_LASS, _______, + _______, _______, CUT, COPY2, PASTE2, TOP, BOTTOM, KC_HOME, KC_END, _______, _______, _______, _______, _______, _______, _______, JP_HENK, _______, _______, _______ ), diff --git a/users/tacahiroy/tacahiroy.c b/users/tacahiroy/tacahiroy.c index 1330b38e2a60..3320be403fa7 100644 --- a/users/tacahiroy/tacahiroy.c +++ b/users/tacahiroy/tacahiroy.c @@ -15,6 +15,12 @@ */ #include "tacahiroy.h" +// Initialize variable holding the binary +// representation of active modifiers. +uint8_t mod_state; + +static bool lower_pressed = false; +static bool raise_pressed = false; void toggle_ime(bool is_on) { if (is_on) { @@ -26,9 +32,6 @@ void toggle_ime(bool is_on) { } } -static bool lower_pressed = false; -static bool raise_pressed = false; - bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case COLEMAK: @@ -123,6 +126,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; + // https://docs.qmk.fm/#/feature_advanced_keycodes?id=shift-backspace-for-delete + case KC_BSPC: + // Store the current modifier state in the variable for later reference + mod_state = get_mods(); + return shift_backspace_for_delete(record); + default: if (record->event.pressed) { lower_pressed = false; @@ -132,3 +141,34 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +bool shift_backspace_for_delete(keyrecord_t *record) { + // Initialize a boolean variable that keeps track + // of the delete key status: registered or not? + static bool delkey_registered; + if (record->event.pressed) { + // Detect the activation of either shift keys + if (mod_state & MOD_MASK_SHIFT) { + // First temporarily canceling both shifts so that + // shift isn't applied to the KC_DEL keycode + del_mods(MOD_MASK_SHIFT); + register_code(KC_DEL); + // Update the boolean variable to reflect the status of KC_DEL + delkey_registered = true; + // Reapplying modifier state so that the held shift key(s) + // still work even after having tapped the Backspace/Delete key. + set_mods(mod_state); + return false; + } + } else { // on release of KC_BSPC + // In case KC_DEL is still being sent even after the release of KC_BSPC + if (delkey_registered) { + unregister_code(KC_DEL); + delkey_registered = false; + return false; + } + } + + // Let QMK process the KC_BSPC keycode as usual outside of shift + return true; +} diff --git a/users/tacahiroy/tacahiroy.h b/users/tacahiroy/tacahiroy.h index 0b9bd05cb4d7..20c44b2daa30 100644 --- a/users/tacahiroy/tacahiroy.h +++ b/users/tacahiroy/tacahiroy.h @@ -46,6 +46,7 @@ enum tacahiroy_keycodes { }; void toggle_ime(bool is_on); +bool shift_backspace_for_delete(keyrecord_t *record); #define LOWER LT(_LOWER, JP_MHEN) #define RAISE LT(_RAISE, JP_HENK)