aboutsummaryrefslogtreecommitdiff
path: root/users/curry/curry.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/curry/curry.c')
-rw-r--r--users/curry/curry.c131
1 files changed, 131 insertions, 0 deletions
diff --git a/users/curry/curry.c b/users/curry/curry.c
new file mode 100644
index 000000000..b6afa5ef2
--- /dev/null
+++ b/users/curry/curry.c
@@ -0,0 +1,131 @@
1#include "curry.h"
2
3userspace_config_t userspace_config;
4
5#define CURRY_UNICODE_MODE 1
6
7void bootmagic_lite(void) {
8 matrix_scan();
9#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0
10 wait_ms(DEBOUNCING_DELAY * 2);
11#elif defined(DEBOUNCE) && DEBOUNCE > 0
12 wait_ms(DEBOUNCE * 2);
13#else
14 wait_ms(30);
15#endif
16 matrix_scan();
17 if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) {
18 bootloader_jump();
19 }
20}
21
22__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
23
24void keyboard_pre_init_user(void) {
25 userspace_config.raw = eeconfig_read_user();
26 keyboard_pre_init_keymap();
27}
28
29__attribute__((weak)) void matrix_init_keymap(void) {}
30
31// Call user matrix init, set default RGB colors and then
32// call the keymap's init function
33void matrix_init_user(void) {
34#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
35 set_unicode_input_mode(CURRY_UNICODE_MODE);
36 get_unicode_input_mode();
37#endif // UNICODE_ENABLE
38 matrix_init_keymap();
39}
40
41__attribute__((weak)) void keyboard_post_init_keymap(void) {}
42
43void keyboard_post_init_user(void) {
44#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
45 keyboard_post_init_rgb();
46#endif
47 keyboard_post_init_keymap();
48}
49
50__attribute__((weak)) void shutdown_keymap(void) {}
51
52void rgb_matrix_update_pwm_buffers(void);
53
54// On RESET, set all RGB to red, shutdown the keymap.
55void shutdown_user(void) {
56#ifdef RGBLIGHT_ENABLE
57 rgblight_enable_noeeprom();
58 rgblight_mode_noeeprom(1);
59 rgblight_setrgb_red();
60#endif // RGBLIGHT_ENABLE
61#ifdef RGB_MATRIX_ENABLE
62 rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
63 rgb_matrix_update_pwm_buffers();
64#endif // RGB_MATRIX_ENABLE
65 shutdown_keymap();
66}
67
68__attribute__((weak)) void suspend_power_down_keymap(void) {}
69
70void suspend_power_down_user(void) { suspend_power_down_keymap(); }
71
72__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
73
74void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); }
75
76__attribute__((weak)) void matrix_scan_keymap(void) {}
77
78// No global matrix scan code, so just run keymap's matrix
79// scan function
80void matrix_scan_user(void) {
81 static bool has_ran_yet;
82 if (!has_ran_yet) {
83 has_ran_yet = true;
84 startup_user();
85 }
86
87#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
88 matrix_scan_rgb();
89#endif // RGBLIGHT_ENABLE
90
91 matrix_scan_keymap();
92}
93
94__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
95
96// On Layer change, run keymap's layer change check
97layer_state_t layer_state_set_user(layer_state_t state) {
98 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
99#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
100 state = layer_state_set_rgb(state);
101#endif // RGBLIGHT_ENABLE
102 return layer_state_set_keymap(state);
103}
104
105__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
106
107// Runs state check and changes underglow color and animation
108layer_state_t default_layer_state_set_user(layer_state_t state) {
109 return default_layer_state_set_keymap(state);
110}
111
112__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
113
114// Any custom LED code goes here.
115void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
116
117__attribute__((weak)) void eeconfig_init_keymap(void) {}
118
119void eeconfig_init_user(void) {
120 userspace_config.raw = 0;
121 userspace_config.rgb_layer_change = true;
122 eeconfig_update_user(userspace_config.raw);
123#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE))
124 set_unicode_input_mode(CURRY_UNICODE_MODE);
125 get_unicode_input_mode();
126#else
127 eeprom_update_byte(EECONFIG_UNICODEMODE, CURRY_UNICODE_MODE);
128#endif
129 eeconfig_init_keymap();
130 keyboard_init();
131}