aboutsummaryrefslogtreecommitdiff
path: root/keyboards/custommk/genesis/rev2/keymaps/via/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/custommk/genesis/rev2/keymaps/via/keymap.c')
-rw-r--r--keyboards/custommk/genesis/rev2/keymaps/via/keymap.c167
1 files changed, 167 insertions, 0 deletions
diff --git a/keyboards/custommk/genesis/rev2/keymaps/via/keymap.c b/keyboards/custommk/genesis/rev2/keymaps/via/keymap.c
new file mode 100644
index 000000000..eb0f7772c
--- /dev/null
+++ b/keyboards/custommk/genesis/rev2/keymaps/via/keymap.c
@@ -0,0 +1,167 @@
1/* Copyright 2020 customMK
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
19//#define GENESIS_LAYER_COLORS
20#define GENESIS_LAYER1_COLOR HSV_CYAN
21#define GENESIS_LAYER2_COLOR HSV_GREEN
22#define GENESIS_LAYER3_COLOR HSV_WHITE
23
24
25const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
26
27 [0] = LAYOUT_via_6x4(
28 KC_VOLD, KC_VOLU, KC_VOLD, KC_VOLU,
29 MO(1), KC_PSLS, KC_PAST, KC_PMNS,
30 KC_P7, KC_P8, KC_P9, KC_PGUP,
31 KC_P4, KC_P5, KC_P6, KC_PPLS,
32 KC_P1, KC_P2, KC_P3, KC_PGDN,
33 KC_P0, KC_SPC, KC_PDOT, KC_PENT),
34
35 [1] = LAYOUT_via_6x4(
36 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
37 KC_TRNS, RGB_TOG, RGB_MOD, KC_TRNS,
38 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
39 RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD,
40 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
41 RGB_HUI, RGB_HUD, KC_TRNS, KC_TRNS),
42
43 [2] = LAYOUT_via_6x4(
44 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
45 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
46 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
47 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
48 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
49 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
50
51 [3] = LAYOUT_via_6x4(
52 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
53 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
54 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
55 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
56 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
57 KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
58
59};
60
61#ifdef GENESIS_LAYER_COLORS
62const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
63 {0,13,GENESIS_LAYER1_COLOR}
64 );
65
66const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
67 {0,13,GENESIS_LAYER2_COLOR}
68 );
69
70const rgblight_segment_t PROGMEM my_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(
71 {0,13,GENESIS_LAYER3_COLOR}
72 );
73
74
75const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
76 my_layer1_layer,
77 my_layer2_layer,
78 my_layer3_layer
79 );
80
81//Set the appropriate layer color
82layer_state_t layer_state_set_user(layer_state_t state) {
83 rgblight_set_layer_state(0, layer_state_cmp(state, 1));
84 rgblight_set_layer_state(1, layer_state_cmp(state, 2));
85 rgblight_set_layer_state(2, layer_state_cmp(state, 3));
86 return state;
87}
88
89void keyboard_post_init_user(void) {
90 //Enable the LED layers
91 rgblight_layers = my_rgb_layers;
92}
93#endif
94
95
96keyevent_t encoder_left_ccw = {
97 .key = (keypos_t){.row = 5, .col = 0},
98 .pressed = false
99};
100
101keyevent_t encoder_left_cw = {
102 .key = (keypos_t){.row = 5, .col = 1},
103 .pressed = false
104};
105
106keyevent_t encoder_right_ccw = {
107 .key = (keypos_t){.row = 5, .col = 2},
108 .pressed = false
109};
110
111keyevent_t encoder_right_cw = {
112 .key = (keypos_t){.row = 5, .col = 3},
113 .pressed = false
114};
115
116void matrix_scan_user(void) {
117 if (IS_PRESSED(encoder_left_ccw)) {
118 encoder_left_ccw.pressed = false;
119 encoder_left_ccw.time = (timer_read() | 1);
120 action_exec(encoder_left_ccw);
121 }
122
123 if (IS_PRESSED(encoder_left_cw)) {
124 encoder_left_cw.pressed = false;
125 encoder_left_cw.time = (timer_read() | 1);
126 action_exec(encoder_left_cw);
127 }
128
129 if (IS_PRESSED(encoder_right_ccw)) {
130 encoder_right_ccw.pressed = false;
131 encoder_right_ccw.time = (timer_read() | 1);
132 action_exec(encoder_right_ccw);
133 }
134
135 if (IS_PRESSED(encoder_right_cw)) {
136 encoder_right_cw.pressed = false;
137 encoder_right_cw.time = (timer_read() | 1);
138 action_exec(encoder_right_cw);
139 }
140
141}
142
143
144bool encoder_update_user(uint8_t index, bool clockwise) {
145 if (index == 0) {
146 if (clockwise) {
147 encoder_left_cw.pressed = true;
148 encoder_left_cw.time = (timer_read() | 1);
149 action_exec(encoder_left_cw);
150 } else {
151 encoder_left_ccw.pressed = true;
152 encoder_left_ccw.time = (timer_read() | 1);
153 action_exec(encoder_left_ccw);
154 }
155 } else {
156 if (clockwise) {
157 encoder_right_cw.pressed = true;
158 encoder_right_cw.time = (timer_read() | 1);
159 action_exec(encoder_right_cw);
160 } else {
161 encoder_right_ccw.pressed = true;
162 encoder_right_ccw.time = (timer_read() | 1);
163 action_exec(encoder_right_ccw);
164 }
165 }
166 return false;
167}