summaryrefslogtreecommitdiffstats
path: root/users/mattly/mattly.c
diff options
context:
space:
mode:
authorMatthew Lyon <matthew@lyonheart.us>2019-07-08 06:27:30 -0700
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-07-08 06:27:30 -0700
commit06ba968759041d8c6dfe1309888d21bdbc16cd24 (patch)
treede550b10caa37eeb344bbb65e957e10f63cd419a /users/mattly/mattly.c
parent75795186135e6d83de1ff3bb108f9c5471742ba4 (diff)
mattly's userspace and iris (#6279)
Diffstat (limited to 'users/mattly/mattly.c')
-rw-r--r--users/mattly/mattly.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/users/mattly/mattly.c b/users/mattly/mattly.c
new file mode 100644
index 0000000000..1e61e01265
--- /dev/null
+++ b/users/mattly/mattly.c
@@ -0,0 +1,70 @@
+#include "mattly.h"
+
+__attribute__ ((weak))
+layer_state_t layer_state_set_keymap (layer_state_t state) {
+ return state;
+}
+
+void set_lights_default(void) {
+ #ifdef RGBLIGHT_ENABLE
+ if (IS_HOST_LED_ON(USB_LED_CAPS_LOCK)) {
+ rgblight_sethsv_noeeprom(HSV_CAPS);
+ } else {
+ rgblight_sethsv_noeeprom(HSV_DEFAULT);
+ }
+ #endif
+}
+
+void layer_state_set_rgb(layer_state_t state) {
+#ifdef RGBLIGHT_ENABLE
+ switch (biton32(state)) {
+ case _QWERTY:
+ set_lights_default();
+ break;
+ case _SYMBOL:
+ rgblight_sethsv_noeeprom(HSV_SYMBOL);
+ break;
+ case _NAVNUM:
+ rgblight_sethsv_noeeprom(HSV_NAVNUM);
+ break;
+ case _FUNCT:
+ rgblight_sethsv_noeeprom(HSV_FUNCT);
+ break;
+ }
+#endif
+}
+
+
+layer_state_t layer_state_set_user (layer_state_t state) {
+ state = update_tri_layer_state(state, _SYMBOL, _NAVNUM, _FUNCT);
+ layer_state_set_rgb(state);
+ return layer_state_set_keymap (state);
+}
+
+void on_reset(void) {
+ #ifdef RGBLIGHT_ENABLE
+ rgblight_sethsv_noeeprom(HSV_RESET);
+ #endif
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case KC_CAPS:
+ #ifdef RGBLIGHT_ENABLE
+ set_lights_default();
+ #endif
+ return true;
+ case RESET:
+ on_reset();
+ return true;
+ default:
+ return true;
+ }
+}
+
+void keyboard_post_init_user(void) {
+#ifdef RGBLIGHT_ENABLE
+ rgblight_enable_noeeprom();
+ set_lights_default();
+#endif
+}