summaryrefslogtreecommitdiff
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 acc6b9f9ed..c1809dad0a 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/>.
userspace_config_t userspace_config;
#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
- #define DRASHNA_UNICODE_MODE UC_WIN
+# define DRASHNA_UNICODE_MODE UC_WIN
#else
- // set to 2 for UC_WIN, set to 4 for UC_WINC
- #define DRASHNA_UNICODE_MODE 2
+// set to 2 for UC_WIN, set to 4 for UC_WINC
+# define DRASHNA_UNICODE_MODE 2
#endif
-
// This block is for all of the gaming macros, as they were all doing
// the same thing, but with differring text sent.
bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
if (!record->event.pressed || override) {
uint16_t keycode;
if (userspace_config.is_overwatch) {
- keycode = KC_BSPC;
+ keycode = KC_BSPC;
} else {
- keycode = KC_ENTER;
+ keycode = KC_ENTER;
}
clear_keyboard();
tap_code(keycode);
@@ -47,12 +46,12 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) {
return false;
}
-bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) {
+bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
static uint16_t this_timer;
- if(pressed) {
- this_timer= timer_read();
+ if (pressed) {
+ this_timer = timer_read();
} else {
- if (timer_elapsed(this_timer) < TAPPING_TERM){
+ if (timer_elapsed(this_timer) < TAPPING_TERM) {
tap_code(code);
} else {
register_code(mod_code);
@@ -63,11 +62,11 @@ bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) {
return false;
}
-bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
- if(pressed) {
- this_timer= timer_read();
+bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
+ if (pressed) {
+ this_timer = timer_read();
} else {
- if (timer_elapsed(this_timer) < TAPPING_TERM){
+ if (timer_elapsed(this_timer) < TAPPING_TERM) {
tap_code(code);
} else {
register_code(mod_code);
@@ -80,13 +79,13 @@ bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t thi
void bootmagic_lite(void) {
matrix_scan();
- #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
- wait_ms(DEBOUNCING_DELAY * 2);
- #elif defined(DEBOUNCE) && DEBOUNCE > 0
- wait_ms(DEBOUNCE * 2);
- #else
- wait_ms(30);
- #endif
+#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
+ wait_ms(DEBOUNCING_DELAY * 2);
+#elif defined(DEBOUNCE) && DEBOUNCE > 0
+ wait_ms(DEBOUNCE * 2);
+#else
+ wait_ms(30);
+#endif
matrix_scan();
if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
bootloader_jump();
@@ -97,7 +96,7 @@ void bootmagic_lite(void) {
// This allows for a global, userspace functions, and continued
// customization of the keymap. Use _keymap instead of _user
// functions in the keymaps
-__attribute__ ((weak))
+__attribute__((weak))
void matrix_init_keymap(void) {}
// Call user matrix init, set default RGB colors and then
@@ -105,64 +104,63 @@ void matrix_init_keymap(void) {}
void matrix_init_user(void) {
userspace_config.raw = eeconfig_read_user();
- #ifdef BOOTLOADER_CATERINA
- DDRD &= ~(1<<5);
- PORTD &= ~(1<<5);
+#ifdef BOOTLOADER_CATERINA
+ DDRD &= ~(1 << 5);
+ PORTD &= ~(1 << 5);
- DDRB &= ~(1<<0);
- PORTB &= ~(1<<0);
- #endif
+ DDRB &= ~(1 << 0);
+ PORTB &= ~(1 << 0);
+#endif
- #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
- set_unicode_input_mode(DRASHNA_UNICODE_MODE);
- get_unicode_input_mode();
- #endif //UNICODE_ENABLE
+#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
+ set_unicode_input_mode(DRASHNA_UNICODE_MODE);
+ get_unicode_input_mode();
+#endif // UNICODE_ENABLE
matrix_init_keymap();
}
__attribute__((weak))
-void keyboard_post_init_keymap(void){ }
+void keyboard_post_init_keymap(void) {}
-void keyboard_post_init_user(void){
+void keyboard_post_init_user(void) {
#ifdef RGBLIGHT_ENABLE
keyboard_post_init_rgb();
#endif
keyboard_post_init_keymap();
}
-__attribute__ ((weak))
+__attribute__((weak))
void shutdown_keymap(void) {}
-void shutdown_user (void) {
- #ifdef RGBLIGHT_ENABLE
- rgblight_enable_noeeprom();
- rgblight_mode_noeeprom(1);
- rgblight_setrgb_red();
- #endif // RGBLIGHT_ENABLE
- #ifdef RGB_MATRIX_ENABLE
- // uint16_t timer_start = timer_read();
- // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 );
- // while(timer_elapsed(timer_start) < 250) { wait_ms(1); }
- #endif //RGB_MATRIX_ENABLE
+void shutdown_user(void) {
+#ifdef RGBLIGHT_ENABLE
+ rgblight_enable_noeeprom();
+ rgblight_mode_noeeprom(1);
+ rgblight_setrgb_red();
+#endif // RGBLIGHT_ENABLE
+#ifdef RGB_MATRIX_ENABLE
+ // uint16_t timer_start = timer_read();
+ // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 );
+ // while(timer_elapsed(timer_start) < 250) { wait_ms(1); }
+#endif // RGB_MATRIX_ENABLE
shutdown_keymap();
}
-__attribute__ ((weak))
+__attribute__((weak))
void suspend_power_down_keymap(void) {}
void suspend_power_down_user(void) {
suspend_power_down_keymap();
}
-__attribute__ ((weak))
+__attribute__((weak))
void suspend_wakeup_init_keymap(void) {}
void suspend_wakeup_init_user(void) {
suspend_wakeup_init_keymap();
}
-
-__attribute__ ((weak))
+__attribute__((weak))
void matrix_scan_keymap(void) {}
// No global matrix scan code, so just run keymap's matrix
@@ -176,20 +174,17 @@ void matrix_scan_user(void) {
#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
run_diablo_macro_check();
-#endif // TAP_DANCE_ENABLE
+#endif // TAP_DANCE_ENABLE
#ifdef RGBLIGHT_ENABLE
matrix_scan_rgb();
-#endif // RGBLIGHT_ENABLE
+#endif // RGBLIGHT_ENABLE
matrix_scan_keymap();
}
-
-__attribute__ ((weak))
-layer_state_t layer_state_set_keymap (layer_state_t state) {
- return state;
-}
+__attribute__((weak))
+layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
// on layer change, no matter where the change was initiated
// Then runs keymap's layer change check
@@ -197,28 +192,25 @@ layer_state_t layer_state_set_user(layer_state_t state) {
state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
#ifdef RGBLIGHT_ENABLE
state = layer_state_set_rgb(state);
-#endif // RGBLIGHT_ENABLE
- return layer_state_set_keymap (state);
+#endif // RGBLIGHT_ENABLE
+ return layer_state_set_keymap(state);
}
-
-__attribute__ ((weak))
-layer_state_t default_layer_state_set_keymap (layer_state_t state) {
- return state;
-}
+__attribute__((weak))
+layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
// Runs state check and changes underglow color and animation
layer_state_t default_layer_state_set_user(layer_state_t state) {
state = default_layer_state_set_keymap(state);
#if 0
-#ifdef RGBLIGHT_ENABLE
+# ifdef RGBLIGHT_ENABLE
state = default_layer_state_set_rgb(state);
-#endif // RGBLIGHT_ENABLE
+# endif // RGBLIGHT_ENABLE
#endif
return state;
}
-__attribute__ ((weak))
+__attribute__((weak))
void led_set_keymap(uint8_t usb_led) {}
// Any custom LED code goes here.
@@ -228,17 +220,19 @@ void led_set_user(uint8_t usb_led) {
led_set_keymap(usb_led);
}
-__attribute__ ((weak))
+__attribute__((weak))
void eeconfig_init_keymap(void) {}
void eeconfig_init_user(void) {
- userspace_config.raw = 0;
+ userspace_config.raw = 0;
userspace_config.rgb_layer_change = true;
eeconfig_update_user(userspace_config.raw);
- #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
+#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
set_unicode_input_mode(DRASHNA_UNICODE_MODE);
get_unicode_input_mode();
- #else
+#else
eeprom_update_byte(EECONFIG_UNICODEMODE, DRASHNA_UNICODE_MODE);
- #endif
+#endif
+ eeconfig_init_keymap();
+ keyboard_init();
}