aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/drashna.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/drashna.c')
-rw-r--r--users/drashna/drashna.c138
1 files changed, 66 insertions, 72 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index acc6b9f9e..c1809dad0 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -19,22 +19,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20userspace_config_t userspace_config; 20userspace_config_t userspace_config;
21#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) 21#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
22 #define DRASHNA_UNICODE_MODE UC_WIN 22# define DRASHNA_UNICODE_MODE UC_WIN
23#else 23#else
24 // set to 2 for UC_WIN, set to 4 for UC_WINC 24// set to 2 for UC_WIN, set to 4 for UC_WINC
25 #define DRASHNA_UNICODE_MODE 2 25# define DRASHNA_UNICODE_MODE 2
26#endif 26#endif
27 27
28
29// This block is for all of the gaming macros, as they were all doing 28// This block is for all of the gaming macros, as they were all doing
30// the same thing, but with differring text sent. 29// the same thing, but with differring text sent.
31bool send_game_macro(const char *str, keyrecord_t *record, bool override) { 30bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
32 if (!record->event.pressed || override) { 31 if (!record->event.pressed || override) {
33 uint16_t keycode; 32 uint16_t keycode;
34 if (userspace_config.is_overwatch) { 33 if (userspace_config.is_overwatch) {
35 keycode = KC_BSPC; 34 keycode = KC_BSPC;
36 } else { 35 } else {
37 keycode = KC_ENTER; 36 keycode = KC_ENTER;
38 } 37 }
39 clear_keyboard(); 38 clear_keyboard();
40 tap_code(keycode); 39 tap_code(keycode);
@@ -47,12 +46,12 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
47 return false; 46 return false;
48} 47}
49 48
50bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { 49bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
51 static uint16_t this_timer; 50 static uint16_t this_timer;
52 if(pressed) { 51 if (pressed) {
53 this_timer= timer_read(); 52 this_timer = timer_read();
54 } else { 53 } else {
55 if (timer_elapsed(this_timer) < TAPPING_TERM){ 54 if (timer_elapsed(this_timer) < TAPPING_TERM) {
56 tap_code(code); 55 tap_code(code);
57 } else { 56 } else {
58 register_code(mod_code); 57 register_code(mod_code);
@@ -63,11 +62,11 @@ bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) {
63 return false; 62 return false;
64} 63}
65 64
66bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { 65bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
67 if(pressed) { 66 if (pressed) {
68 this_timer= timer_read(); 67 this_timer = timer_read();
69 } else { 68 } else {
70 if (timer_elapsed(this_timer) < TAPPING_TERM){ 69 if (timer_elapsed(this_timer) < TAPPING_TERM) {
71 tap_code(code); 70 tap_code(code);
72 } else { 71 } else {
73 register_code(mod_code); 72 register_code(mod_code);
@@ -80,13 +79,13 @@ bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t thi
80 79
81void bootmagic_lite(void) { 80void bootmagic_lite(void) {
82 matrix_scan(); 81 matrix_scan();
83 #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 82#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
84 wait_ms(DEBOUNCING_DELAY * 2); 83 wait_ms(DEBOUNCING_DELAY * 2);
85 #elif defined(DEBOUNCE) && DEBOUNCE > 0 84#elif defined(DEBOUNCE) && DEBOUNCE > 0
86 wait_ms(DEBOUNCE * 2); 85 wait_ms(DEBOUNCE * 2);
87 #else 86#else
88 wait_ms(30); 87 wait_ms(30);
89 #endif 88#endif
90 matrix_scan(); 89 matrix_scan();
91 if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { 90 if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
92 bootloader_jump(); 91 bootloader_jump();
@@ -97,7 +96,7 @@ void bootmagic_lite(void) {
97// This allows for a global, userspace functions, and continued 96// This allows for a global, userspace functions, and continued
98// customization of the keymap. Use _keymap instead of _user 97// customization of the keymap. Use _keymap instead of _user
99// functions in the keymaps 98// functions in the keymaps
100__attribute__ ((weak)) 99__attribute__((weak))
101void matrix_init_keymap(void) {} 100void matrix_init_keymap(void) {}
102 101
103// Call user matrix init, set default RGB colors and then 102// Call user matrix init, set default RGB colors and then
@@ -105,64 +104,63 @@ void matrix_init_keymap(void) {}
105void matrix_init_user(void) { 104void matrix_init_user(void) {
106 userspace_config.raw = eeconfig_read_user(); 105 userspace_config.raw = eeconfig_read_user();
107 106
108 #ifdef BOOTLOADER_CATERINA 107#ifdef BOOTLOADER_CATERINA
109 DDRD &= ~(1<<5); 108 DDRD &= ~(1 << 5);
110 PORTD &= ~(1<<5); 109 PORTD &= ~(1 << 5);
111 110
112 DDRB &= ~(1<<0); 111 DDRB &= ~(1 << 0);
113 PORTB &= ~(1<<0); 112 PORTB &= ~(1 << 0);
114 #endif 113#endif
115 114
116 #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) 115#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
117 set_unicode_input_mode(DRASHNA_UNICODE_MODE); 116 set_unicode_input_mode(DRASHNA_UNICODE_MODE);
118 get_unicode_input_mode(); 117 get_unicode_input_mode();
119 #endif //UNICODE_ENABLE 118#endif // UNICODE_ENABLE
120 matrix_init_keymap(); 119 matrix_init_keymap();
121} 120}
122 121
123__attribute__((weak)) 122__attribute__((weak))
124void keyboard_post_init_keymap(void){ } 123void keyboard_post_init_keymap(void) {}
125 124
126void keyboard_post_init_user(void){ 125void keyboard_post_init_user(void) {
127#ifdef RGBLIGHT_ENABLE 126#ifdef RGBLIGHT_ENABLE
128 keyboard_post_init_rgb(); 127 keyboard_post_init_rgb();
129#endif 128#endif
130 keyboard_post_init_keymap(); 129 keyboard_post_init_keymap();
131} 130}
132 131
133__attribute__ ((weak)) 132__attribute__((weak))
134void shutdown_keymap(void) {} 133void shutdown_keymap(void) {}
135 134
136void shutdown_user (void) { 135void shutdown_user(void) {
137 #ifdef RGBLIGHT_ENABLE 136#ifdef RGBLIGHT_ENABLE
138 rgblight_enable_noeeprom(); 137 rgblight_enable_noeeprom();
139 rgblight_mode_noeeprom(1); 138 rgblight_mode_noeeprom(1);
140 rgblight_setrgb_red(); 139 rgblight_setrgb_red();
141 #endif // RGBLIGHT_ENABLE 140#endif // RGBLIGHT_ENABLE
142 #ifdef RGB_MATRIX_ENABLE 141#ifdef RGB_MATRIX_ENABLE
143 // uint16_t timer_start = timer_read(); 142 // uint16_t timer_start = timer_read();
144 // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); 143 // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 );
145 // while(timer_elapsed(timer_start) < 250) { wait_ms(1); } 144 // while(timer_elapsed(timer_start) < 250) { wait_ms(1); }
146 #endif //RGB_MATRIX_ENABLE 145#endif // RGB_MATRIX_ENABLE
147 shutdown_keymap(); 146 shutdown_keymap();
148} 147}
149 148
150__attribute__ ((weak)) 149__attribute__((weak))
151void suspend_power_down_keymap(void) {} 150void suspend_power_down_keymap(void) {}
152 151
153void suspend_power_down_user(void) { 152void suspend_power_down_user(void) {
154 suspend_power_down_keymap(); 153 suspend_power_down_keymap();
155} 154}
156 155
157__attribute__ ((weak)) 156__attribute__((weak))
158void suspend_wakeup_init_keymap(void) {} 157void suspend_wakeup_init_keymap(void) {}
159 158
160void suspend_wakeup_init_user(void) { 159void suspend_wakeup_init_user(void) {
161 suspend_wakeup_init_keymap(); 160 suspend_wakeup_init_keymap();
162} 161}
163 162
164 163__attribute__((weak))
165__attribute__ ((weak))
166void matrix_scan_keymap(void) {} 164void matrix_scan_keymap(void) {}
167 165
168// No global matrix scan code, so just run keymap's matrix 166// No global matrix scan code, so just run keymap's matrix
@@ -176,20 +174,17 @@ void matrix_scan_user(void) {
176 174
177#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. 175#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
178 run_diablo_macro_check(); 176 run_diablo_macro_check();
179#endif // TAP_DANCE_ENABLE 177#endif // TAP_DANCE_ENABLE
180 178
181#ifdef RGBLIGHT_ENABLE 179#ifdef RGBLIGHT_ENABLE
182 matrix_scan_rgb(); 180 matrix_scan_rgb();
183#endif // RGBLIGHT_ENABLE 181#endif // RGBLIGHT_ENABLE
184 182
185 matrix_scan_keymap(); 183 matrix_scan_keymap();
186} 184}
187 185
188 186__attribute__((weak))
189__attribute__ ((weak)) 187layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
190layer_state_t layer_state_set_keymap (layer_state_t state) {
191 return state;
192}
193 188
194// on layer change, no matter where the change was initiated 189// on layer change, no matter where the change was initiated
195// Then runs keymap's layer change check 190// Then runs keymap's layer change check
@@ -197,28 +192,25 @@ layer_state_t layer_state_set_user(layer_state_t state) {
197 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); 192 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
198#ifdef RGBLIGHT_ENABLE 193#ifdef RGBLIGHT_ENABLE
199 state = layer_state_set_rgb(state); 194 state = layer_state_set_rgb(state);
200#endif // RGBLIGHT_ENABLE 195#endif // RGBLIGHT_ENABLE
201 return layer_state_set_keymap (state); 196 return layer_state_set_keymap(state);
202} 197}
203 198
204 199__attribute__((weak))
205__attribute__ ((weak)) 200layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
206layer_state_t default_layer_state_set_keymap (layer_state_t state) {
207 return state;
208}
209 201
210// Runs state check and changes underglow color and animation 202// Runs state check and changes underglow color and animation
211layer_state_t default_layer_state_set_user(layer_state_t state) { 203layer_state_t default_layer_state_set_user(layer_state_t state) {
212 state = default_layer_state_set_keymap(state); 204 state = default_layer_state_set_keymap(state);
213#if 0 205#if 0
214#ifdef RGBLIGHT_ENABLE 206# ifdef RGBLIGHT_ENABLE
215 state = default_layer_state_set_rgb(state); 207 state = default_layer_state_set_rgb(state);
216#endif // RGBLIGHT_ENABLE 208# endif // RGBLIGHT_ENABLE
217#endif 209#endif
218 return state; 210 return state;
219} 211}
220 212
221__attribute__ ((weak)) 213__attribute__((weak))
222void led_set_keymap(uint8_t usb_led) {} 214void led_set_keymap(uint8_t usb_led) {}
223 215
224// Any custom LED code goes here. 216// Any custom LED code goes here.
@@ -228,17 +220,19 @@ void led_set_user(uint8_t usb_led) {
228 led_set_keymap(usb_led); 220 led_set_keymap(usb_led);
229} 221}
230 222
231__attribute__ ((weak)) 223__attribute__((weak))
232void eeconfig_init_keymap(void) {} 224void eeconfig_init_keymap(void) {}
233 225
234void eeconfig_init_user(void) { 226void eeconfig_init_user(void) {
235 userspace_config.raw = 0; 227 userspace_config.raw = 0;
236 userspace_config.rgb_layer_change = true; 228 userspace_config.rgb_layer_change = true;
237 eeconfig_update_user(userspace_config.raw); 229 eeconfig_update_user(userspace_config.raw);
238 #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) 230#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
239 set_unicode_input_mode(DRASHNA_UNICODE_MODE); 231 set_unicode_input_mode(DRASHNA_UNICODE_MODE);
240 get_unicode_input_mode(); 232 get_unicode_input_mode();
241 #else 233#else
242 eeprom_update_byte(EECONFIG_UNICODEMODE, DRASHNA_UNICODE_MODE); 234 eeprom_update_byte(EECONFIG_UNICODEMODE, DRASHNA_UNICODE_MODE);
243 #endif 235#endif
236 eeconfig_init_keymap();
237 keyboard_init();
244} 238}