aboutsummaryrefslogtreecommitdiff
path: root/keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c')
-rw-r--r--keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c b/keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c
new file mode 100644
index 000000000..650643399
--- /dev/null
+++ b/keyboards/mwstudio/mw65_rgb/keymaps/via/keymap.c
@@ -0,0 +1,128 @@
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#include QMK_KEYBOARD_H
18
19typedef union {
20 uint32_t raw;
21 struct {
22 bool top_rgb_change :1;
23 bool bottom_rgb_change :1;
24 };
25} user_config_t;
26
27user_config_t user_config;
28
29const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
30
31 [0] = LAYOUT(
32 KC_ESC, 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,
33 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,
34 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,
35 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, RGB_TOG,
36 KC_LCTL, KC_LGUI, KC_LALT, KC_VOLU, KC_VOLD, KC_SPACE, KC_RALT, MO(1), KC_LEFT, KC_DOWN, KC_RIGHT
37 ),
38
39 [1] = LAYOUT(
40 KC_GRV, 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_HUI,
41 RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_HUD,
42 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, USER00, RGB_SAI,
43 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, USER01, RGB_VAI, RGB_SAD,
44 _______, _______, _______, _______, _______, _______, RGB_MOD, _______, RGB_SPD, RGB_VAD, RGB_SPI
45 ),
46
47 [2] = LAYOUT(
48 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
49 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
50 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
51 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
52 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
53 ),
54
55 [3] = LAYOUT(
56 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
57 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
58 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
59 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
60 _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
61 ),
62};
63
64void keyboard_post_init_user(void) {
65 // Read the user config from EEPROM
66 user_config.raw = eeconfig_read_user();
67}
68
69bool process_record_user(uint16_t keycode, keyrecord_t *record) {
70 switch (keycode) {
71 case USER00:
72 if (record->event.pressed) {
73 // Do something when pressed
74 user_config.top_rgb_change ^= 1; // Toggles the status
75 eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
76 } else {
77 // Do something else when release
78 }
79 return false; // Skip all further processing of this key
80 case USER01:
81 if (record->event.pressed) {
82 // Do something when pressed
83 user_config.bottom_rgb_change ^= 1; // Toggles the status
84 eeconfig_update_user(user_config.raw); // Writes the new status to EEPROM
85 } else {
86 // Do something else when release
87 }
88 return false; // Skip all further processing of this key
89 default:
90 return true; // Process all other keycodes normally
91 }
92}
93
94#ifdef ENCODER_ENABLE
95bool encoder_update_user(uint8_t index, bool clockwise) {
96 if (index == 0) {
97 if (clockwise) {
98 tap_code(dynamic_keymap_get_keycode(biton32(layer_state), 4, 3));
99 } else {
100 tap_code(dynamic_keymap_get_keycode(biton32(layer_state), 4, 4));
101 }
102 }
103 return true;
104}
105#endif
106
107void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
108
109 if (user_config.top_rgb_change)
110 {
111 for (size_t i = 16; i < 83; i++)
112 {
113 RGB_MATRIX_INDICATOR_SET_COLOR(i, 0, 0, 0);
114 }
115 }
116
117 if (host_keyboard_led_state().caps_lock) {
118 RGB_MATRIX_INDICATOR_SET_COLOR(52, 0, 255, 255); // assuming caps lock is at led #5
119 }
120
121 if (user_config.bottom_rgb_change)
122 {
123 for (size_t i = 0; i < 16; i++)
124 {
125 RGB_MATRIX_INDICATOR_SET_COLOR(i, 0, 0, 0);
126 }
127 }
128}