Add user horrortroll in userspace (#19769)

This commit is contained in:
HorrorTroll
2023-04-03 05:24:04 +07:00
committed by GitHub
parent 27e6e27d3a
commit d300811009
37 changed files with 258 additions and 1280 deletions

View File

@@ -1,4 +1,4 @@
/* Copyright 2021 HorrorTroll <https://github.com/HorrorTroll>
/* Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
*
* 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
@@ -19,11 +19,6 @@
// OLED animation
#include "oled/bongocat.h"
#include <string.h>
#include <math.h>
#include <lib/lib8tion/lib8tion.h>
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
@@ -34,22 +29,6 @@ enum layer_names {
_FN,
};
enum user_rgb_mode {
RGB_MODE_ALL,
RGB_MODE_KEYLIGHT,
RGB_MODE_UNDERGLOW,
RGB_MODE_NONE,
};
typedef union {
uint32_t raw;
struct {
uint8_t rgb_mode :8;
};
} user_config_t;
user_config_t user_config;
// enum layer_keycodes { };
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@@ -121,94 +100,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};
void keyboard_post_init_user(void) {
user_config.raw = eeconfig_read_user();
switch (user_config.rgb_mode) {
case RGB_MODE_ALL:
rgb_matrix_set_flags(LED_FLAG_ALL);
rgb_matrix_enable_noeeprom();
break;
case RGB_MODE_KEYLIGHT:
rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
rgb_matrix_set_color_all(0, 0, 0);
break;
case RGB_MODE_UNDERGLOW:
rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
rgb_matrix_set_color_all(0, 0, 0);
break;
case RGB_MODE_NONE:
rgb_matrix_set_flags(LED_FLAG_NONE);
rgb_matrix_set_color_all(0, 0, 0);
break;
}
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case RGB_TOG:
if (record->event.pressed) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
rgb_matrix_set_color_all(0, 0, 0);
user_config.rgb_mode = RGB_MODE_KEYLIGHT;
}
break;
case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
rgb_matrix_set_color_all(0, 0, 0);
user_config.rgb_mode = RGB_MODE_UNDERGLOW;
}
break;
case (LED_FLAG_UNDERGLOW): {
rgb_matrix_set_flags(LED_FLAG_NONE);
rgb_matrix_set_color_all(0, 0, 0);
user_config.rgb_mode = RGB_MODE_NONE;
}
break;
default: {
rgb_matrix_set_flags(LED_FLAG_ALL);
rgb_matrix_enable_noeeprom();
user_config.rgb_mode = RGB_MODE_ALL;
}
break;
}
eeconfig_update_user(user_config.raw);
}
return false;
}
return true;
}
bool rgb_matrix_indicators_user(void) {
HSV hsv = rgb_matrix_config.hsv;
uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
hsv.h = time;
RGB rgb = hsv_to_rgb(hsv);
if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) {
if (host_keyboard_led_state().caps_lock) {
rgb_matrix_set_color(25, rgb.r, rgb.g, rgb.b);
}
if (host_keyboard_led_state().scroll_lock) {
rgb_matrix_set_color(73, rgb.r, rgb.g, rgb.b);
}
} else {
if (host_keyboard_led_state().caps_lock) {
rgb_matrix_set_color(25, rgb.r, rgb.g, rgb.b);
} else {
rgb_matrix_set_color(25, 0, 0, 0);
}
if (host_keyboard_led_state().scroll_lock) {
rgb_matrix_set_color(73, rgb.r, rgb.g, rgb.b);
} else {
rgb_matrix_set_color(73, 0, 0, 0);
}
}
return false;
}
#ifdef OLED_ENABLE
bool oled_task_user(void) {
led_t led_usb_state = host_keyboard_led_state();