aboutsummaryrefslogtreecommitdiff
path: root/keyboards/swiftrax/retropad/keymaps/default/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/swiftrax/retropad/keymaps/default/keymap.c')
-rw-r--r--keyboards/swiftrax/retropad/keymaps/default/keymap.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/keyboards/swiftrax/retropad/keymaps/default/keymap.c b/keyboards/swiftrax/retropad/keymaps/default/keymap.c
new file mode 100644
index 000000000..8b9992e1d
--- /dev/null
+++ b/keyboards/swiftrax/retropad/keymaps/default/keymap.c
@@ -0,0 +1,69 @@
1 /* Copyright 2020 swiftrax
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#include QMK_KEYBOARD_H
17
18const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
19
20[0] = LAYOUT(
21 TO(1), //windows
22 KC_MSTP, KC_MPLY,
23 KC_MPRV, KC_MNXT),
24
25[1] = LAYOUT( //macOS
26 TO(2),
27 KC_MSTP, KC_MPLY,
28 KC_MRWD, KC_MFFD),
29
30[2] = LAYOUT(
31 TO(0),
32 KC_HOME, KC_PGUP,
33 KC_END, KC_PGDN),
34};
35
36void encoder_update_user(uint8_t index, bool clockwise) {
37 if(IS_LAYER_ON(2)){
38 if (clockwise)
39 tap_code(KC_LEFT);
40 else
41 tap_code(KC_RGHT);
42 }
43 else{
44 if(clockwise)
45 tap_code(KC_VOLU);
46 else
47 tap_code(KC_VOLD);
48 }
49}
50
51void matrix_init_user(void) {
52 // set top LED to output and off (active low)
53 setPinOutput(D5);
54 writePinHigh(D5);
55 // set middle LED to output and off (active low)
56 setPinOutput(D4);
57 writePinHigh(D4);
58 // set bottom LED to output and off (active low)
59 setPinOutput(D3);
60 writePinHigh(D3);
61}
62
63// write to above indicators in a binary fashion based on current layer
64layer_state_t layer_state_set_user(layer_state_t state) {
65 writePin(D5, get_highest_layer(state));
66 writePin(D4, !layer_state_cmp(state, 1));
67 writePin(D3, !layer_state_cmp(state, 2));
68 return state;
69} \ No newline at end of file