aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredric Silberberg <frsilb@microsoft.com>2018-12-13 11:06:41 -0800
committerDrashna Jaelre <drashna@live.com>2018-12-13 18:30:15 -0800
commit89b80b79d50b2193830a961b0ab3ea398ae1d6f1 (patch)
tree98a7f2b908d9d371870f99f1a36e6c814c24a007
parent9e6ee4777995a1ac3dfd7aa4454b0a4ed825d663 (diff)
downloadqmk_firmware-89b80b79d50b2193830a961b0ab3ea398ae1d6f1.tar.gz
qmk_firmware-89b80b79d50b2193830a961b0ab3ea398ae1d6f1.zip
Add big switch layout
-rw-r--r--keyboards/bigswitch/keymaps/333fred/config.h20
-rw-r--r--keyboards/bigswitch/keymaps/333fred/keymap.c123
-rw-r--r--keyboards/bigswitch/keymaps/333fred/rules.mk5
3 files changed, 148 insertions, 0 deletions
diff --git a/keyboards/bigswitch/keymaps/333fred/config.h b/keyboards/bigswitch/keymaps/333fred/config.h
new file mode 100644
index 000000000..76f13f08b
--- /dev/null
+++ b/keyboards/bigswitch/keymaps/333fred/config.h
@@ -0,0 +1,20 @@
1/*
2Copyright 2018 Fredric Silberberg (333fred)
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19// Long tapping term on the big switch, because it takes so long to press
20#define TAPPING_TERM 500
diff --git a/keyboards/bigswitch/keymaps/333fred/keymap.c b/keyboards/bigswitch/keymaps/333fred/keymap.c
new file mode 100644
index 000000000..791fb435f
--- /dev/null
+++ b/keyboards/bigswitch/keymaps/333fred/keymap.c
@@ -0,0 +1,123 @@
1#include QMK_KEYBOARD_H
2
3typedef enum {
4 SINGLE_TAP, SINGLE_HOLD, DOUBLE, TRIPLE, QUAD
5} tap_dance_state_enum;
6
7enum {
8 TD_KEY = 0
9};
10
11static tap_dance_state_enum tap_dance_state;
12static bool tap_dance_active = false;
13static uint16_t timer;
14
15void dance_cycle(bool override_timer) {
16 if (tap_dance_active)
17 {
18 if (timer_elapsed(timer) > 100 || override_timer)
19 {
20 switch (tap_dance_state)
21 {
22 case SINGLE_HOLD:
23 {
24 rgblight_increase_hue_noeeprom();
25 break;
26 }
27
28 case DOUBLE:
29 {
30 rgblight_step_noeeprom();
31 break;
32 }
33
34 case TRIPLE:
35 {
36 rgblight_toggle_noeeprom();
37 break;
38 }
39
40 default:
41 // Not needed
42 break;
43 }
44
45 timer = timer_read();
46 }
47 }
48}
49
50void dance_finished(qk_tap_dance_state_t *state, void* user_data) {
51 // Determine the current state
52 switch (state->count)
53 {
54 case 1:
55 {
56 if (state->interrupted || state->pressed == 0) tap_dance_state = SINGLE_TAP;
57 else tap_dance_state = SINGLE_HOLD;
58 break;
59 }
60 case 2:
61 {
62 tap_dance_state = DOUBLE;
63 break;
64 }
65 case 3:
66 {
67 tap_dance_state = TRIPLE;
68 break;
69 }
70 default:
71 {
72 tap_dance_state = QUAD;
73 break;
74 }
75 }
76
77 switch (tap_dance_state)
78 {
79 case SINGLE_TAP:
80 {
81 // VS Build: CTRL+SHIFT+B
82 SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) "b" SS_UP(X_LALT) SS_UP(X_LCTRL));
83 tap_dance_active = false;
84 break;
85 }
86
87 case SINGLE_HOLD:
88 case DOUBLE:
89 case TRIPLE:
90 {
91 // These are handled by the matrix_scan, which will register the appropriate rgb
92 // functions every scan
93 tap_dance_active = true;
94 timer = timer_read();
95 dance_cycle(true);
96 break;
97 }
98
99 case QUAD:
100 {
101 // Reprogram
102 reset_keyboard();
103 break;
104 }
105 }
106}
107
108void dance_reset(qk_tap_dance_state_t *state, void* user_data)
109{
110 tap_dance_active = false;
111}
112
113qk_tap_dance_action_t tap_dance_actions[] = {
114 [TD_KEY] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, dance_finished, dance_reset)
115};
116
117const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
118 [0] = LAYOUT(TD(TD_KEY))
119};
120
121void matrix_scan_user(void) {
122 dance_cycle(false);
123}
diff --git a/keyboards/bigswitch/keymaps/333fred/rules.mk b/keyboards/bigswitch/keymaps/333fred/rules.mk
new file mode 100644
index 000000000..20aaadacb
--- /dev/null
+++ b/keyboards/bigswitch/keymaps/333fred/rules.mk
@@ -0,0 +1,5 @@
1# I'm not using things from my userpace in this one
2USER_NAME = disable
3
4RGBLIGHT_ENABLE = yes
5TAP_DANCE_ENABLE = yes