-
Notifications
You must be signed in to change notification settings - Fork 4
/
brain.c
124 lines (104 loc) · 2.53 KB
/
brain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// ObliviousGmn // Dokuu // October 2020 // Big Brain
#include "bongo.c"
#include "oleds.h"
extern keymap_config_t keymap_config;
// Has RGB?
#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
#endif
int RGB_current_mode;
uint16_t oled_timer;
bool oled_awake;
layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}
#ifdef OLED_ENABLE
// OLED Rotations
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (is_keyboard_master()) {
return OLED_ROTATION_270;
} else {
return OLED_ROTATION_180;
}
}
// Master OLED
void render_master(void) {
render_space();
render_layer_state();
render_space();
render_mod_status_gui_alt(get_mods()|get_oneshot_mods());
render_mod_status_ctrl_shift(get_mods()|get_oneshot_mods());
render_space();
render_logo();
render_space();
}
// Slave OLED
void render_slave(void) {
switch (get_highest_layer(layer_state)){
case _GAME:
//render_game_r();
testing_game();
break;
case _WEAPON:
//render_weapon_r();
break;
default:
render_anim();
}
}
// OLED Sleeps
bool oled_task_user(void) {
// Establishing Sides
if (is_keyboard_master()) {
if (!oled_awake || timer_elapsed(oled_timer) > OLED_TIMEOUT) {
oled_awake = false;
oled_off();
} else {
render_master();
}
} else {
render_slave();
}
return false;
}
#endif
// OLED Wakes
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed || get_current_wpm() != 000) {
oled_timer = timer_read();
oled_awake = true;
}
// RGB
switch (keycode) {
case RGBRST:
#ifdef RGBLIGHT_ENABLE
if (record->event.pressed) {
eeconfig_update_rgblight_default();
rgblight_enable();
RGB_current_mode = rgblight_config.mode;
}
#endif
#ifdef RGB_MATRIX_ENABLE
if (record->event.pressed) {
eeconfig_update_rgb_matrix_default();
rgb_matrix_enable();
}
#endif
break;
}
return true;
}
// RGB
void matrix_init_user(void) {
#ifdef RGBLIGHT_ENABLE
RGB_current_mode = rgblight_config.mode;
#endif
}
#ifdef RGB_MATRIX_ENABLE
void suspend_power_down_keymap(void) {
rgb_matrix_set_suspend_state(true);
}
void suspend_wakeup_init_keymap(void) {
rgb_matrix_set_suspend_state(false);
}
#endif