From c745cbb77a66a44549ee1ab3b1998c495c1a1ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20G=C3=A9rard?= <1322081+GreatWizard@users.noreply.github.com> Date: Wed, 28 Oct 2020 18:20:06 +0100 Subject: [Keymap] greatwizard userspace and ortho 4x12 and 5x12 keymaps (#9584) --- users/greatwizard/underglow.c | 109 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 users/greatwizard/underglow.c (limited to 'users/greatwizard/underglow.c') diff --git a/users/greatwizard/underglow.c b/users/greatwizard/underglow.c new file mode 100644 index 0000000000..db31290acd --- /dev/null +++ b/users/greatwizard/underglow.c @@ -0,0 +1,109 @@ +/* Copyright 2020 Guillaume GĂ©rard + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include "underglow.h" + +void keyboard_post_init_rgb(void) { + user_config_t user_config; + user_config.raw = eeconfig_read_user(); + if (!user_config.rgb_layer_change) { + return; + } + rgblight_enable_noeeprom(); + rgblight_sethsv_noeeprom_orange(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); +} + +bool process_record_rgb(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_LAYER: + if (record->event.pressed) { + user_config_t user_config; + user_config.raw = eeconfig_read_user(); + user_config.rgb_layer_change ^= 1; + eeconfig_update_user(user_config.raw); + if (user_config.rgb_layer_change) { + layer_state_set(layer_state); + } + } + return false; + case RGB_MODE_FORWARD ... RGB_MODE_RGBTEST: + if (record->event.pressed) { + user_config_t user_config; + user_config.raw = eeconfig_read_user(); + if (user_config.rgb_layer_change) { + user_config.rgb_layer_change = false; + eeconfig_update_user(user_config.raw); + } + } + return true; + } + return true; +} + +layer_state_t layer_state_set_rgb(layer_state_t state) { + user_config_t user_config; + user_config.raw = eeconfig_read_user(); + if (!user_config.rgb_layer_change) { + return state; + } + switch (get_highest_layer(state)) { + case _QWERTY: +#ifdef LAYERS_PROGRAMMER + case _PROGRAMMER_SHIFTED: +#endif + rgblight_sethsv_noeeprom_orange(); + break; +#ifdef LAYERS_ORTHO + case _LOWER: + rgblight_sethsv_noeeprom_red(); + break; + case _RAISE: + rgblight_sethsv_noeeprom_blue(); + break; + case _ADJUST: + rgblight_sethsv_noeeprom_purple(); + break; +#endif +#ifdef LAYER_FN + case _FN: + rgblight_sethsv_noeeprom_chartreuse(); + break; +#endif +#ifdef LAYER_GIT + case _GIT: + rgblight_sethsv_noeeprom_teal(); + break; +#endif + default: + rgblight_sethsv_noeeprom_white(); + break; + } + return state; +} + +bool led_update_rgb(led_t led_state) { + user_config_t user_config; + user_config.raw = eeconfig_read_user(); + if (!user_config.rgb_layer_change) { + return true; + } + if (led_state.caps_lock) { + rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); + } else { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + } + return true; +} -- cgit v1.2.3