aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c')
-rw-r--r--keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c b/keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c
new file mode 100644
index 000000000..b103c306f
--- /dev/null
+++ b/keyboards/dumbpad/v0x_dualencoder/keymaps/default/keymap.c
@@ -0,0 +1,135 @@
1/* Copyright 2020 imchipwood
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 BASE LAYER
21 /---------------------------------------`
22 | 7 | 8 | 9 | Bkspc |
23 |---------|---------|---------|---------|
24 | 4 | 5 | 6 | Esc |
25 |---------|---------|---------|---------|
26 | 1 | 2 | 3 | Tab |
27 |---------|---------|---------|---------|
28 | TT(1) | 0 | . | Enter |
29 \---------------------------------------'
30 */
31 [0] = LAYOUT(
32 KC_7, KC_8, KC_9, KC_BSPC,
33 KC_4, KC_5, KC_6, KC_ESC,
34 KC_1, KC_2, KC_3, KC_TAB,
35 TT(1), KC_0, KC_DOT, KC_ENTER
36 ),
37 /*
38 SUB LAYER
39 /---------------------------------------`
40 | | | | Reset |
41 |---------|---------|---------|---------|
42 | | | | + |
43 |---------|---------|---------|---------|
44 | | | | - |
45 |---------|---------|---------|---------|
46 | | | | = |
47 \---------------------------------------'
48 */
49 [1] = LAYOUT(
50 _______, _______, _______, RESET,
51 _______, _______, _______, KC_KP_PLUS,
52 _______, _______, _______, KC_KP_MINUS,
53 _______, _______, _______, KC_EQL
54 ),
55};
56
57bool process_record_user(uint16_t keycode, keyrecord_t *record) {
58 // If console is enabled, it will print the matrix position and status of each key pressed
59/*
60#ifdef CONSOLE_ENABLE
61 uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
62#endif
63*/
64 return true;
65}
66
67void keyboard_post_init_user(void) {
68 // Customise these values to desired behaviour
69 // debug_enable = true;
70 // debug_matrix = true;
71 // debug_keyboard = true;
72 // debug_mouse = true;
73}
74
75bool encoder_update_user(uint8_t index, bool clockwise) {
76 /* Custom encoder control - handles CW/CCW turning of encoder
77 * Default behavior:
78 * left encoder:
79 * main layer:
80 * CW: move mouse right
81 * CCW: move mouse left
82 * other layers:
83 * CW: = (equals/plus - increase slider in Adobe products)
84 * CCW: - (minus/underscore - decrease slider in adobe products)
85 * right encoder:
86 * main layer:
87 * CW: colume up
88 * CCW: volume down
89 * other layers:
90 * CW: right arrow
91 * CCW: left arrow
92 */
93 if (index == 0) {
94 switch (get_highest_layer(layer_state)) {
95 case 0:
96 // main layer - move mouse right (CW) and left (CCW)
97 if (clockwise) {
98 tap_code(KC_MS_R);
99 } else {
100 tap_code(KC_MS_L);
101 }
102 break;
103
104 default:
105 // other layers - =/+ (quals/plus) (CW) and -/_ (minus/underscore) (CCW)
106 if (clockwise) {
107 tap_code(KC_EQL);
108 } else {
109 tap_code(KC_MINS);
110 }
111 break;
112 }
113 } else if (index == 1) {
114 switch (get_highest_layer(layer_state)) {
115 case 0:
116 // main layer - volume up (CW) and down (CCW)
117 if (clockwise) {
118 tap_code(KC_VOLU);
119 } else {
120 tap_code(KC_VOLD);
121 }
122 break;
123
124 default:
125 // other layers - right (CW) and left (CCW)
126 if (clockwise) {
127 tap_code(KC_RIGHT);
128 } else {
129 tap_code(KC_LEFT);
130 }
131 break;
132 }
133 }
134 return true;
135}