diff options
Diffstat (limited to 'keyboards/mwstudio/mw75r2/keymaps/via')
| -rw-r--r-- | keyboards/mwstudio/mw75r2/keymaps/via/keymap.c | 171 | ||||
| -rw-r--r-- | keyboards/mwstudio/mw75r2/keymaps/via/rules.mk | 2 |
2 files changed, 173 insertions, 0 deletions
diff --git a/keyboards/mwstudio/mw75r2/keymaps/via/keymap.c b/keyboards/mwstudio/mw75r2/keymaps/via/keymap.c new file mode 100644 index 000000000..0648ac7bf --- /dev/null +++ b/keyboards/mwstudio/mw75r2/keymaps/via/keymap.c | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | /* Copyright 2021 TW59420 <https://github.com/TW59420> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | |||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | |||
| 20 | typedef union { | ||
| 21 | uint32_t raw; | ||
| 22 | struct { | ||
| 23 | bool top_rgb_change :1; | ||
| 24 | bool bottom_rgb_change :1; | ||
| 25 | }; | ||
| 26 | } user_config_t; | ||
| 27 | |||
| 28 | user_config_t user_config; | ||
| 29 | |||
| 30 | #include QMK_KEYBOARD_H | ||
| 31 | |||
| 32 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 33 | |||
| 34 | [0] = LAYOUT( | ||
| 35 | KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, RGB_TOG, | ||
| 36 | KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, | ||
| 37 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, | ||
| 38 | KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, | ||
| 39 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, | ||
| 40 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPACE, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RIGHT | ||
| 41 | ), | ||
| 42 | |||
| 43 | [1] = LAYOUT( | ||
| 44 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, USER00, USER01, _______, | ||
| 45 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUI, | ||
| 46 | RGB_TOG, _______, _______, _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, | ||
| 47 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAI, | ||
| 48 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_VAI, RGB_SAD, | ||
| 49 | _______, _______, _______, _______, RGB_MOD, _______, RGB_SPD, RGB_VAD, RGB_SPI | ||
| 50 | ), | ||
| 51 | |||
| 52 | [2] = LAYOUT( | ||
| 53 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 54 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 55 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 56 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 57 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 58 | _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
| 59 | ), | ||
| 60 | |||
| 61 | [3] = LAYOUT( | ||
| 62 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 63 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 64 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 65 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 66 | _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, | ||
| 67 | _______, _______, _______, _______, _______, _______, _______, _______, _______ | ||
| 68 | ), | ||
| 69 | }; | ||
| 70 | |||
| 71 | |||
| 72 | void keyboard_post_init_user(void) { | ||
| 73 | // Read the user config from EEPROM | ||
| 74 | user_config.raw = eeconfig_read_user(); | ||
| 75 | } | ||
| 76 | |||
| 77 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 78 | switch (keycode) { | ||
| 79 | case USER00: | ||
| 80 | if (record->event.pressed) { | ||
| 81 | // Do something when pressed | ||
| 82 | user_config.top_rgb_change ^= 1; // Toggles the status | ||
| 83 | eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM | ||
| 84 | } else { | ||
| 85 | // Do something else when release | ||
| 86 | } | ||
| 87 | return false; // Skip all further processing of this key | ||
| 88 | case USER01: | ||
| 89 | if (record->event.pressed) { | ||
| 90 | // Do something when pressed | ||
| 91 | user_config.bottom_rgb_change ^= 1; // Toggles the status | ||
| 92 | eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM | ||
| 93 | } else { | ||
| 94 | // Do something else when release | ||
| 95 | } | ||
| 96 | return false; // Skip all further processing of this key | ||
| 97 | default: | ||
| 98 | return true; // Process all other keycodes normally | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | #ifdef ENCODER_ENABLE | ||
| 103 | #define ENCODERS 1 | ||
| 104 | static uint8_t encoder_state[ENCODERS] = {0}; | ||
| 105 | static keypos_t encoder_cw[ENCODERS] = {{3, 5}}; | ||
| 106 | static keypos_t encoder_ccw[ENCODERS] = {{4, 5}}; | ||
| 107 | |||
| 108 | |||
| 109 | void encoder_action_unregister(void) { | ||
| 110 | #ifdef ENCODERS | ||
| 111 | for (uint8_t index = 0; index < ENCODERS; ++index) { | ||
| 112 | if (encoder_state[index]) { | ||
| 113 | keyevent_t encoder_event = (keyevent_t) { | ||
| 114 | .key = encoder_state[index] >> 1 ? encoder_cw[index] : encoder_ccw[index], | ||
| 115 | .pressed = false, | ||
| 116 | .time = (timer_read() | 1) | ||
| 117 | }; | ||
| 118 | encoder_state[index] = 0; | ||
| 119 | action_exec(encoder_event); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | #endif | ||
| 123 | } | ||
| 124 | |||
| 125 | void encoder_action_register(uint8_t index, bool clockwise) { | ||
| 126 | keyevent_t encoder_event = (keyevent_t) { | ||
| 127 | .key = clockwise ? encoder_cw[index] : encoder_ccw[index], | ||
| 128 | .pressed = true, | ||
| 129 | .time = (timer_read() | 1) | ||
| 130 | }; | ||
| 131 | encoder_state[index] = (clockwise ^ 1) | (clockwise << 1); | ||
| 132 | action_exec(encoder_event); | ||
| 133 | } | ||
| 134 | |||
| 135 | void matrix_scan_user(void) { | ||
| 136 | encoder_action_unregister(); | ||
| 137 | } | ||
| 138 | |||
| 139 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 140 | encoder_action_register(index, clockwise); | ||
| 141 | return true; | ||
| 142 | }; | ||
| 143 | #endif | ||
| 144 | |||
| 145 | |||
| 146 | void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { | ||
| 147 | |||
| 148 | if (user_config.top_rgb_change) | ||
| 149 | { | ||
| 150 | for (size_t i = 14; i < 18; i++) | ||
| 151 | { | ||
| 152 | RGB_MATRIX_INDICATOR_SET_COLOR(i, 0, 0, 0); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | if (host_keyboard_led_state().caps_lock) { | ||
| 156 | for (size_t i = 14; i < 18; i++) | ||
| 157 | { | ||
| 158 | RGB_MATRIX_INDICATOR_SET_COLOR(i, 0, 255, 255); // assuming caps lock is at led #5 | ||
| 159 | } | ||
| 160 | } | ||
| 161 | if (user_config.bottom_rgb_change) | ||
| 162 | { | ||
| 163 | for (size_t i = 0; i < 21; i++) | ||
| 164 | { | ||
| 165 | if (i >= 14 && i <18) | ||
| 166 | continue; | ||
| 167 | |||
| 168 | RGB_MATRIX_INDICATOR_SET_COLOR(i, 0, 0, 0); | ||
| 169 | } | ||
| 170 | } | ||
| 171 | } | ||
diff --git a/keyboards/mwstudio/mw75r2/keymaps/via/rules.mk b/keyboards/mwstudio/mw75r2/keymaps/via/rules.mk new file mode 100644 index 000000000..36b7ba9cb --- /dev/null +++ b/keyboards/mwstudio/mw75r2/keymaps/via/rules.mk | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | VIA_ENABLE = yes | ||
| 2 | LTO_ENABLE = yes | ||
