aboutsummaryrefslogtreecommitdiff
path: root/users/badger/ortho.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/badger/ortho.c')
-rw-r--r--users/badger/ortho.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/users/badger/ortho.c b/users/badger/ortho.c
new file mode 100644
index 000000000..ff84e1706
--- /dev/null
+++ b/users/badger/ortho.c
@@ -0,0 +1,151 @@
1/*
2Copyright 2020 Dan White <opensource@bluetufa.com>
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.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15#include "ortho.h"
16#include "badger.h"
17
18int _currentLayer;
19bool _capsLock;
20
21#ifdef AUDIO_ENABLE
22float capsOnSong[][2] = SONG(CAPS_ON);
23float capsOffSong[][2] = SONG(CAPS_OFF);
24float defaultLayerSong[][2] = SONG(QWERTY_LAYER_SONG);
25float moveLayerSong[][2] = SONG(MOVE_LAYER_SONG);
26float macLayerSong[][2] = SONG(MAC_LAYER_SONG);
27float raiseLayerSong[][2] = SONG(RAISE_LAYER_SONG);
28float lowerLayerSong[][2] = SONG(LOWER_LAYER_SONG);
29float agSwapSong[][2] = SONG(LONG_AG_SWAP);
30float agNormSong[][2] = SONG(LONG_AG_NORM);
31#endif
32
33__attribute__ ((weak))
34void keyboard_post_init_user(void) {
35 _capsLock = false;
36 _currentLayer = _QWERTY_MAC_ORTHO;
37 layer_on(_currentLayer);
38}
39
40__attribute__ ((weak))
41bool process_record_user(uint16_t keycode, keyrecord_t *record) {
42 dprintf("Key event recorded. KEYCODE: %u , event: %u\n", keycode, record->event.pressed);
43 switch (keycode) {
44 case CS_RIGHT:
45 if (record->event.pressed) {
46 SEND_STRING(SS_LALT(SS_TAP(X_B)SS_TAP(X_ENTER)));
47 return false;
48 }
49 break;
50 case CS_DOWN:
51 if (record->event.pressed) {
52 SEND_STRING(SS_LALT(SS_TAP(X_V)SS_TAP(X_ENTER)));
53 return false;
54 }
55 break;
56 case KC_CAPS:
57 if (record->event.pressed) {
58 dprintf("CAPS_LOCK state: %u\n", _capsLock);
59 _capsLock = !_capsLock;
60 #ifdef AUDIO_ENABLE
61 _capsLock ? PLAY_SONG(capsOnSong) : PLAY_SONG(capsOffSong);
62 #endif
63 return true;
64 }
65 break;
66 case AG_SWAP:
67 #ifdef AUDIO_ENABLE
68 PLAY_SONG(agSwapSong);
69 #endif
70 return true;
71 break;
72 case AG_NORM:
73 #ifdef AUDIO_ENABLE
74 PLAY_SONG(agNormSong);
75 #endif
76 return true;
77 break;
78 case KC_MAC2:
79 if (record->event.pressed) {
80 SEND_STRING("ll\n");
81 return false;
82 }
83 break;
84 case KC_MAC1:
85 if (record->event.pressed) {
86 SEND_STRING("open https://www.reddit.com/r/mechanicalkeyboards\n");
87 return false;
88 }
89 break;
90 case KC_FIRST:
91 if (record->event.pressed) {
92 // don't turn off the QWERTY layer
93 if (_currentLayer != _QWERTY_MAC_ORTHO) {
94 layer_off(_currentLayer);
95 }
96 _currentLayer = _QWERTY_MAC_ORTHO;
97 layer_on(_currentLayer);
98 playSongForLayer(_currentLayer);
99 return false;
100 }
101 break;
102 case KC_LYRC:
103 if (record->event.pressed) {
104 dprintf("LYR CYCLE pressed %u, CURRENT_LAYER: %u\n", keycode, _currentLayer);
105 // don't turn off the QWERTY layer or the ADJUST layer
106 if (_currentLayer != _QWERTY_MAC_ORTHO) {
107 layer_off(_currentLayer);
108 }
109 // don't lock the ADJUST layer
110 // since this key is accessible via the ADJUST
111 // layer, as it will require tricky state management
112 if (++_currentLayer == _ADJUST_ORTHO) {
113 _currentLayer = _QWERTY_MAC_ORTHO;
114 } else {
115 layer_on(_currentLayer);
116 }
117
118 playSongForLayer(_currentLayer);
119 return false;
120 }
121 break;
122 }
123 return true;
124}
125
126void playSongForLayer(int currentLayer) {
127 #ifdef AUDIO_ENABLE
128 switch (currentLayer) {
129 case _QWERTY_LINUX:
130 PLAY_SONG(defaultLayerSong);
131 break;
132 case _MOVE_LINUX:
133 PLAY_SONG(moveLayerSong);
134 break;
135 case _QWERTY_MAC:
136 PLAY_SONG(macLayerSong);
137 break;
138 case _MOVE_MAC:
139 PLAY_SONG(moveLayerSong);
140 break;
141 case _RAISE:
142 PLAY_SONG(raiseLayerSong);
143 break;
144 case _LOWER:
145 PLAY_SONG(lowerLayerSong);
146 break;
147 default:
148 break;
149 }
150 #endif
151} \ No newline at end of file