aboutsummaryrefslogtreecommitdiff
path: root/keyboards/handwired/snatchpad/snatchpad.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/handwired/snatchpad/snatchpad.c')
-rw-r--r--keyboards/handwired/snatchpad/snatchpad.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/keyboards/handwired/snatchpad/snatchpad.c b/keyboards/handwired/snatchpad/snatchpad.c
new file mode 100644
index 000000000..621ba1112
--- /dev/null
+++ b/keyboards/handwired/snatchpad/snatchpad.c
@@ -0,0 +1,66 @@
1// Copyright 2022 xia0 (@xia0)
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "snatchpad.h"
5
6#ifdef ENCODER_ENABLE
7bool encoder_update_kb(uint8_t index, bool clockwise) {
8 if (!encoder_update_user(index, clockwise)) {
9 return false;
10 }
11
12 uint8_t layer = get_highest_layer(layer_state);
13
14 if (index == 0) { /* First encoder */
15 switch (layer) {
16 case 0:
17 if (clockwise) {
18 tap_code_delay(KC_VOLU, 10);
19 } else {
20 tap_code_delay(KC_VOLD, 10);
21 }
22 break;
23 case 2:
24 if (clockwise) {
25 tap_code16(LCTL(KC_MINUS));
26 } else {
27 tap_code16(LCTL(KC_EQUAL));
28 }
29 break;
30 default:
31 if (clockwise) {
32 tap_code(KC_MS_L);
33 } else {
34 tap_code(KC_MS_R);
35 }
36 break;
37 }
38
39 } else if (index == 1) { /* Second encoder */
40 switch (layer) {
41 case 0:
42 if (clockwise) {
43 tap_code(KC_MFFD);
44 } else {
45 tap_code(KC_MRWD);
46 }
47 break;
48 case 2:
49 if (clockwise) {
50 tap_code16(LCTL(KC_Y));
51 } else {
52 tap_code16(LCTL(KC_Z));
53 }
54 break;
55 default:
56 if (clockwise) {
57 tap_code(KC_MS_D);
58 } else {
59 tap_code(KC_MS_U);
60 }
61 break;
62 }
63 }
64 return true;
65}
66#endif