$ diff -u keymap.c keymap-ref.c --- keymap.c 2024-08-20 12:21:12.000000000 +0200 +++ keymap-ref.c 2024-09-12 13:12:31.244798500 +0200 @@ -2,10 +2,18 @@ #include "version.h" #include "i18n.h" #define MOON_LED_LEVEL LED_LEVEL -#define ML_SAFE_RANGE SAFE_RANGE enum custom_keycodes { RGB_SLD = ML_SAFE_RANGE, + HSV_0_255_255, + HSV_86_255_128, + HSV_172_255_255, + DK_LSPO, + DK_RSPC, + CUSTOM_ALTGR1, // Map AltGr+1 to | + CUSTOM_SHIFT4, // Map Shift+4 to ' + CUSTOM_SHIFTBKSP, // Map Shift+Backspace to ? + CUSTOM_CTRLBKSP // Map Ctrl+Backspace to Delete }; @@ -15,7 +23,7 @@ }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_moonlander( - KC_ESCAPE, KC_1, KC_2, KC_3, KC_4, KC_5, DK_QUOT, DK_PLUS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, + KC_ESCAPE, CUSTOM_ALTGR1, KC_2, KC_3, CUSTOM_SHIFT4, KC_5, DK_QUOT, DK_PLUS, KC_6, KC_7, KC_8, KC_9, KC_0, CUSTOM_SHIFTBKSP, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, DK_LABK, DK_ACUT, KC_Y, KC_U, KC_I, KC_O, KC_P, DK_ARNG, LT(2,KC_LEFT_CTRL),KC_A, KC_S, KC_D, KC_F, KC_G, DK_DIAE, MT(MOD_RCTL, KC_INSERT),KC_H, KC_J, KC_K, KC_L, DK_AE, DK_OSTR, KC_LEFT_SHIFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, DK_COMM, DK_DOT, DK_MINS, KC_RIGHT_SHIFT, @@ -24,11 +32,11 @@ ), [1] = LAYOUT_moonlander( KC_ESCAPE, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRANSPARENT, KC_TRANSPARENT, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_PSCR, - KC_TRANSPARENT, KC_EXLM, DK_AT, DK_LCBR, DK_RCBR, KC_PIPE, KC_TRANSPARENT, KC_TRANSPARENT, KC_UP, KC_7, KC_8, KC_9, KC_KP_ASTERISK, KC_F11, + RGB_SAI, KC_EXLM, DK_AT, DK_LCBR, DK_RCBR, KC_PIPE, KC_TRANSPARENT, KC_TRANSPARENT, KC_UP, KC_7, KC_8, KC_9, KC_KP_ASTERISK, KC_F11, KC_TRANSPARENT, KC_HASH, KC_DLR, DK_LPRN, DK_RPRN, DK_ACUT, KC_TRANSPARENT, TO(5), KC_DOWN, KC_4, KC_5, KC_6, KC_KP_PLUS, KC_F12, - KC_TRANSPARENT, DK_PERC, DK_CIRC, DK_LBRC, DK_RBRC, KC_TILD, KC_AMPR, KC_1, KC_2, KC_3, KC_KP_SLASH, KC_PAGE_UP, - KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_LEFT, KC_TRANSPARENT, DK_COMM, KC_DOT, KC_0, DK_EQL, KC_PGDN, - RGB_VAD, RGB_VAI, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT + RGB_SPI, DK_PERC, DK_CIRC, DK_LBRC, DK_RBRC, KC_TILD, KC_AMPR, KC_1, KC_2, KC_3, KC_KP_SLASH, KC_PAGE_UP, + RGB_SPD, RGB_MODE_FORWARD,HSV_0_255_255, HSV_86_255_128, HSV_172_255_255,KC_TRANSPARENT, KC_TRANSPARENT, DK_COMM, KC_DOT, KC_0, DK_EQL, KC_PAGE_UP, + RGB_VAD, RGB_VAI, TOGGLE_LAYER_COLOR, RGB_SLD, RGB_HUD, RGB_HUI ), [2] = LAYOUT_moonlander( AU_TOGG, TO(0), TO(5), KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, QK_BOOT, @@ -139,6 +147,7 @@ } bool process_record_user(uint16_t keycode, keyrecord_t *record) { + static uint8_t saved_mods = 0; switch (keycode) { case RGB_SLD: @@ -149,7 +158,113 @@ rgblight_mode(1); } return false; - } + case HSV_0_255_255: + if (rawhid_state.rgb_control) { + return false; + } + if (record->event.pressed) { + rgblight_mode(1); + rgblight_sethsv(0,255,255); + } + return false; + case HSV_86_255_128: + if (rawhid_state.rgb_control) { + return false; + } + if (record->event.pressed) { + rgblight_mode(1); + rgblight_sethsv(86,255,128); + } + return false; + case HSV_172_255_255: + if (rawhid_state.rgb_control) { + return false; + } + if (record->event.pressed) { + rgblight_mode(1); + rgblight_sethsv(172,255,255); + } + return false; + + + /**********************/ + /* CUSTOM CODES BEGIN */ + /**********************/ + case CUSTOM_ALTGR1: + if (record->event.pressed) { + if ((get_mods() & MOD_BIT(KC_RALT)) == MOD_BIT(KC_RALT)) { + register_code16(DK_PIPE); + } + else { + register_code(DK_1); + } + } else { + unregister_code16(DK_PIPE); + unregister_code(DK_1); + } + return false; + case CUSTOM_SHIFT4: + if (record->event.pressed) { + saved_mods = get_mods() & MOD_MASK_SHIFT; + if ((get_mods() & MOD_MASK_SHIFT) == MOD_MASK_SHIFT) { + del_mods(saved_mods); + register_code(KC_NUHS); + add_mods(saved_mods); + } + else if (saved_mods) { + del_mods(saved_mods); + register_code(KC_NUHS); + add_mods(saved_mods); + } + else { + register_code(DK_4); + } + } else { + unregister_code(KC_NUHS); + unregister_code(DK_4); + } + return false; + + case CUSTOM_SHIFTBKSP: + if (record->event.pressed) { + saved_mods = get_mods() & MOD_MASK_SHIFT; + if ((saved_mods == MOD_MASK_SHIFT) || saved_mods ){ + register_code(DK_PLUS); + } + else { + register_code(KC_BSPC); + } + } else { + unregister_code(DK_PLUS); + unregister_code(KC_BSPC); + } + return false; + + case CUSTOM_CTRLBKSP: + if (record->event.pressed) { + saved_mods = get_mods() & MOD_BIT(KC_LEFT_CTRL); + if ((get_mods() & MOD_BIT(KC_LEFT_CTRL)) == MOD_BIT(KC_LEFT_CTRL)) { + del_mods(saved_mods); + register_code16(DK_PLUS); + add_mods(saved_mods); + } + else if (saved_mods) { + del_mods(saved_mods); + register_code16(DK_PLUS); + add_mods(saved_mods); + } + else { + register_code(KC_BSPC); + } + } else { + register_code16(DK_PLUS); + unregister_code(KC_BSPC); + } + return false; + /**********************/ + /* CUSTOM CODES END */ + /**********************/ + } return true; } @@ -209,3 +324,5 @@ tap_dance_action_t tap_dance_actions[] = { [DANCE_0] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_0_finished, dance_0_reset), }; + +/* vim: set sw=2 sts=2: */