From 593b8a724f34940a7ae9e06216d559fb60961fcd Mon Sep 17 00:00:00 2001 From: Frederik Baerentsen Date: Mon, 13 Jul 2020 13:48:10 +0200 Subject: [PATCH] Updated userspace frederik --- users/frederik/frederik.c | 266 ------------------- users/frederik/frederik.h | 72 ++--- users/frederik/rgb_stuff.c | 333 ------------------------ users/frederik/rgb_stuff.h | 22 -- users/frederik/rgblight_breathe_table.h | 118 --------- users/frederik/wrappers.h | 96 +++++++ 6 files changed, 135 insertions(+), 772 deletions(-) delete mode 100644 users/frederik/frederik.c delete mode 100644 users/frederik/rgb_stuff.c delete mode 100644 users/frederik/rgb_stuff.h delete mode 100644 users/frederik/rgblight_breathe_table.h create mode 100644 users/frederik/wrappers.h diff --git a/users/frederik/frederik.c b/users/frederik/frederik.c deleted file mode 100644 index 62864b59..00000000 --- a/users/frederik/frederik.c +++ /dev/null @@ -1,266 +0,0 @@ -/* -Copyright 2017 Christopher Courtney @drashna - -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 "frederik.h" - -userspace_config_t userspace_config; - -bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) { - static uint16_t this_timer; - if (pressed) { - this_timer = timer_read(); - } else { - if (timer_elapsed(this_timer) < TAPPING_TERM) { - tap_code(code); - } else { - register_code(mod_code); - tap_code(code); - unregister_code(mod_code); - } - } - return false; -} - -bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { - if (pressed) { - this_timer = timer_read(); - } else { - if (timer_elapsed(this_timer) < TAPPING_TERM) { - tap_code(code); - } else { - register_code(mod_code); - tap_code(code); - unregister_code(mod_code); - } - } - return false; -} - -void bootmagic_lite(void) { - matrix_scan(); -#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 - wait_ms(DEBOUNCING_DELAY * 2); -#elif defined(DEBOUNCE) && DEBOUNCE > 0 - wait_ms(DEBOUNCE * 2); -#else - wait_ms(30); -#endif - matrix_scan(); - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { - bootloader_jump(); - } -} - -__attribute__((weak)) void keyboard_pre_init_keymap(void) {} - -void keyboard_pre_init_user(void) { - userspace_config.raw = eeconfig_read_user(); - keyboard_pre_init_keymap(); -} -// Add reconfigurable functions here, for keymap customization -// This allows for a global, userspace functions, and continued -// customization of the keymap. Use _keymap instead of _user -// functions in the keymaps -__attribute__((weak)) void matrix_init_keymap(void) {} - -// Call user matrix init, set default RGB colors and then -// call the keymap's init function -void matrix_init_user(void) { -#if defined(BOOTLOADER_CATERINA) && defined(__AVR__) - DDRD &= ~(1 << 5); - PORTD &= ~(1 << 5); - - DDRB &= ~(1 << 0); - PORTB &= ~(1 << 0); -#endif - matrix_init_keymap(); -} - -__attribute__((weak)) void keyboard_post_init_keymap(void) {} - -void keyboard_post_init_user(void) { -#if defined(RGBLIGHT_ENABLE) - keyboard_post_init_rgb_light(); -#endif -#if defined(RGB_MATRIX_ENABLE) - keyboard_post_init_rgb_matrix(); -#endif - keyboard_post_init_keymap(); -} - -__attribute__((weak)) void shutdown_keymap(void) {} - -void rgb_matrix_update_pwm_buffers(void); - -void shutdown_user(void) { -#ifdef RGBLIGHT_ENABLE - rgblight_enable_noeeprom(); - rgblight_mode_noeeprom(1); - rgblight_setrgb_red(); -#endif // RGBLIGHT_ENABLE -#ifdef RGB_MATRIX_ENABLE -# ifdef __AVR__ - rgb_matrix_set_color_all(0xFF, 0x00, 0x00); - rgb_matrix_update_pwm_buffers(); -# else - rgb_matrix_sethsv_noeeprom(0, 255, 255); - rgb_matrix_mode_noeeprom(1); -# endif -#endif // RGB_MATRIX_ENABLE - shutdown_keymap(); -} - -__attribute__((weak)) void suspend_power_down_keymap(void) {} - -void suspend_power_down_user(void) { suspend_power_down_keymap(); } - -__attribute__((weak)) void suspend_wakeup_init_keymap(void) {} - -void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); } - -__attribute__((weak)) void matrix_scan_keymap(void) {} - -// No global matrix scan code, so just run keymap's matrix -// scan function -void matrix_scan_user(void) { - static bool has_ran_yet; - if (!has_ran_yet) { - has_ran_yet = true; - startup_user(); - } - -#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. - run_diablo_macro_check(); -#endif // TAP_DANCE_ENABLE - -#if defined(RGBLIGHT_ENABLE) - matrix_scan_rgb_light(); -#endif // RGBLIGHT_ENABLE -#if defined(RGB_MATRIX_ENABLE) - matrix_scan_rgb_matrix(); -#endif - - matrix_scan_keymap(); -} - -__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; } - -// on layer change, no matter where the change was initiated -// Then runs keymap's layer change check -layer_state_t layer_state_set_user(layer_state_t state) { - state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); -#if defined(RGBLIGHT_ENABLE) - state = layer_state_set_rgb_light(state); -#endif // RGBLIGHT_ENABLE - return layer_state_set_keymap(state); -} - -__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; } - -// Runs state check and changes underglow color and animation -layer_state_t default_layer_state_set_user(layer_state_t state) { - state = default_layer_state_set_keymap(state); -#if 0 -# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) - state = default_layer_state_set_rgb(state); -# endif // RGBLIGHT_ENABLE -#endif - return state; -} - -__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {} - -// Any custom LED code goes here. -// So far, I only have keyboard specific code, -// So nothing goes here. -void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); } - -__attribute__((weak)) void eeconfig_init_keymap(void) {} - -void eeconfig_init_user(void) { - userspace_config.raw = 0; - userspace_config.rgb_layer_change = true; - eeconfig_update_user(userspace_config.raw); - eeconfig_init_keymap(); - keyboard_init(); -} - -bool hasAllBitsInMask(uint8_t value, uint8_t mask) { - value &= 0xF; - mask &= 0xF; - - return (value & mask) == mask; -} - -void keyboard_post_init_rgb_light(void) { - rgblight_sethsv(HSV_GOLD); - rgblight_mode(RGBLIGHT_MODE_BREATHING); - // rgblight_mode(RGBLIGHT_MODE_KNIGHT+1); -} - -// Init stuff. -void keyboard_post_init_user(void) { -#if defined(RGBLIGHT_ENABLE) - keyboard_post_init_rgb_light(); -#endif - keyboard_post_init_user_keymap(); -} - - -void matrix_scan_rgb_light(void) { -#ifdef RGBLIGHT_ENABLE - -#endif -} - -void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) { - rgblight_sethsv_noeeprom(hue, sat, val); - wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly - rgblight_mode_noeeprom(mode); -} - -layer_state_t layer_state_set_rgb_light(layer_state_t state) { -#ifdef RGBLIGHT_ENABLE - - switch (get_highest_layer(state)) { - - case _RAISE: - rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_BREATHING + 3); - break; - case _LOWER: - rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3); - break; - case _ADJUST: - rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2); - break; - default: // for any other layers, or the default layer - { - switch (get_highest_layer(default_layer_state)) { - case _WoW: - rgblight_set_hsv_and_mode(HSV_MAGENTA, RGBLIGHT_MODE_STATIC_LIGHT); - break; - default: - rgblight_set_hsv_and_mode(HSV_CYAN, RGBLIGHT_MODE_STATIC_LIGHT); - break; - } - break; - } - } -#endif // RGBLIGHT_ENABLE - - return state; -} \ No newline at end of file diff --git a/users/frederik/frederik.h b/users/frederik/frederik.h index 07a00ea3..9ea104b4 100644 --- a/users/frederik/frederik.h +++ b/users/frederik/frederik.h @@ -1,48 +1,54 @@ +/* +Copyright 2017 Christopher Courtney @drashna + +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 . +*/ + #pragma once #include QMK_KEYBOARD_H #include "version.h" #include "eeprom.h" +#include "wrappers.h" -#include "rgb_stuff.h" +/* Define layer names */ enum userspace_layers { - _QWERTY = 0, + _QWERTY = 0, + _NUMLOCK = 0, + _WORKMAN, + _MODS, /* layer 8 */ + _GAMEPAD, + _DIABLO, + _WARCRAFT, + _MACROS, + _MEDIA, _LOWER, _RAISE, _NAV, _ADJUST, - _WoW }; -enum custom_keycodes { - KC_CCCV = SAFE_RANGE, - OE, - AA, - AE, - oe, - aa, - ae, -}; - -enum unicode_names { - u_ae, - u_oe, - u_aa -}; - -const uint32_t PROGMEM unicode_map[] = { - [u_ae] = 0x00E6, - [u_oe] = 0x00F8, - [u_aa] = 0x00E5, -}; - - -bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record); -void keyboard_post_init_rgb_light(void); -void matrix_scan_rgb_light(void); -layer_state_t layer_state_set_rgb_light(layer_state_t state); -layer_state_t default_layer_state_set_rgb_light(layer_state_t state); -void rgblight_sethsv_default_helper(uint8_t index); - +// clang-format off +typedef union { + uint32_t raw; + struct { + bool rgb_layer_change :1; + bool swapped_numbers :1; + bool rgb_matrix_idle_anim :1; + }; +} userspace_config_t; +// clang-format on +extern userspace_config_t userspace_config; diff --git a/users/frederik/rgb_stuff.c b/users/frederik/rgb_stuff.c deleted file mode 100644 index cfe98ec0..00000000 --- a/users/frederik/rgb_stuff.c +++ /dev/null @@ -1,333 +0,0 @@ -#include "frederik.h" -#include "rgb_stuff.h" -#include "eeprom.h" - -extern rgblight_config_t rgblight_config; -bool has_initialized; - -void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index); } - -/* Custom indicators for modifiers. - * This allows for certain lights to be lit up, based on what mods are active, giving some visual feedback. - * This is especially useful for One Shot Mods, since it's not always obvious if they're still lit up. - */ -#ifdef INDICATOR_LIGHTS -void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) { - if (userspace_config.rgb_layer_change && get_highest_layer(layer_state) == 0) { - if ((this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1 << USB_LED_CAPS_LOCK)) { -# ifdef SHFT_LED1 - rgblight_sethsv_at(120, 255, 255, SHFT_LED1); -# endif // SHFT_LED1 -# ifdef SHFT_LED2 - rgblight_sethsv_at(120, 255, 255, SHFT_LED2); -# endif // SHFT_LED2 - } else { -# ifdef SHFT_LED1 - rgblight_sethsv_default_helper(SHFT_LED1); -# endif // SHFT_LED1 -# ifdef SHFT_LED2 - rgblight_sethsv_default_helper(SHFT_LED2); -# endif // SHFT_LED2 - } - if ((this_mod | this_osm) & MOD_MASK_CTRL) { -# ifdef CTRL_LED1 - rgblight_sethsv_at(0, 255, 255, CTRL_LED1); -# endif // CTRL_LED1 -# ifdef CTRL_LED2 - rgblight_sethsv_at(0, 255, 255, CTRL_LED2); -# endif // CTRL_LED2 - } else { -# ifdef CTRL_LED1 - rgblight_sethsv_default_helper(CTRL_LED1); -# endif // CTRL_LED1 -# ifdef CTRL_LED2 - rgblight_sethsv_default_helper(CTRL_LED2); -# endif // CTRL_LED2 - } - if ((this_mod | this_osm) & MOD_MASK_GUI) { -# ifdef GUI_LED1 - rgblight_sethsv_at(51, 255, 255, GUI_LED1); -# endif // GUI_LED1 -# ifdef GUI_LED2 - rgblight_sethsv_at(51, 255, 255, GUI_LED2); -# endif // GUI_LED2 - } else { -# ifdef GUI_LED1 - rgblight_sethsv_default_helper(GUI_LED1); -# endif // GUI_LED1 -# ifdef GUI_LED2 - rgblight_sethsv_default_helper(GUI_LED2); -# endif // GUI_LED2 - } - if ((this_mod | this_osm) & MOD_MASK_ALT) { -# ifdef ALT_LED1 - rgblight_sethsv_at(240, 255, 255, ALT_LED1); -# endif // ALT_LED1 -# ifdef GUI_LED2 - rgblight_sethsv_at(240, 255, 255, ALT_LED2); -# endif // GUI_LED2 - } else { -# ifdef GUI_LED1 - rgblight_sethsv_default_helper(ALT_LED1); -# endif // GUI_LED1 -# ifdef GUI_LED2 - rgblight_sethsv_default_helper(ALT_LED2); -# endif // GUI_LED2 - } - } -} - -/* Function for the indicators */ -void matrix_scan_indicator(void) { - if (has_initialized) { - set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods()); - } -} -#endif // INDICATOR_LIGHTS - -#ifdef RGBLIGHT_TWINKLE -static rgblight_fadeout lights[RGBLED_NUM]; - -__attribute__((weak)) bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; } - -/* This function checks for used LEDs. This way, collisions don't occur and cause weird rendering */ -bool rgblight_twinkle_is_led_used(uint8_t index) { - switch (index) { -# ifdef INDICATOR_LIGHTS -# ifdef SHFT_LED1 - case SHFT_LED1: - return true; -# endif // SHFT_LED1 -# ifdef SHFT_LED2 - case SHFT_LED2: - return true; -# endif // SHFT_LED2 -# ifdef CTRL_LED1 - case CTRL_LED1: - return true; -# endif // CTRL_LED1 -# ifdef CTRL_LED2 - case CTRL_LED2: - return true; -# endif // CTRL_LED2 -# ifdef GUI_LED1 - case GUI_LED1: - return true; -# endif // GUI_LED1 -# ifdef GUI_LED2 - case GUI_LED2: - return true; -# endif // GUI_LED2 -# ifdef ALT_LED1 - case ALT_LED1: - return true; -# endif // ALT_LED1 -# ifdef ALT_LED2 - case ALT_LED2: - return true; -# endif // ALT_LED2 -# endif // INDICATOR_LIGHTS - default: - return rgblight_twinkle_is_led_used_keymap(index); - } -} - -/* Handler for fading/twinkling effect */ -void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive - bool litup = false; - - for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) { - if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) { - rgblight_fadeout *light = &lights[light_index]; - litup = true; - - if (light->life) { - light->life -= 1; - if (get_highest_layer(layer_state) == 0) { - sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]); - } - light->timer = timer_read(); - } else { - if (light->enabled && get_highest_layer(layer_state) == 0) { - rgblight_sethsv_default_helper(light_index); - } - litup = light->enabled = false; - } - } - } - if (litup && get_highest_layer(layer_state) == 0) { - rgblight_set(); - } -} - -/* Triggers a LED to fade/twinkle. - * This function handles the selection of the LED and prepres for it to be used. - */ -void start_rgb_light(void) { - uint8_t indices[RGBLED_NUM]; - uint8_t indices_count = 0; - uint8_t min_life = 0xFF; - uint8_t min_life_index = -1; - - for (uint8_t index = 0; index < RGBLED_NUM; ++index) { - if (rgblight_twinkle_is_led_used(index)) { - continue; - } - if (lights[index].enabled) { - if (min_life_index == -1 || lights[index].life < min_life) { - min_life = lights[index].life; - min_life_index = index; - } - continue; - } - - indices[indices_count] = index; - ++indices_count; - } - - uint8_t light_index; - if (!indices_count) { - light_index = min_life_index; - } else { - light_index = indices[rand() % indices_count]; - } - - rgblight_fadeout *light = &lights[light_index]; - light->enabled = true; - light->timer = timer_read(); - light->life = 0xC0 + rand() % 0x40; - - light->hue = rgblight_config.hue + (rand() % 0xB4) - 0x54; - - rgblight_sethsv_at(light->hue, 255, light->life, light_index); -} -#endif - -bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { - uint16_t temp_keycode = keycode; - // Filter out the actual keycode from MT and LT keys. - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { - temp_keycode &= 0xFF; - } - - switch (temp_keycode) { -#ifdef RGBLIGHT_TWINKLE - case KC_A ... KC_SLASH: - case KC_F1 ... KC_F12: - case KC_INSERT ... KC_UP: - case KC_KP_SLASH ... KC_KP_DOT: - case KC_F13 ... KC_F24: - case KC_AUDIO_MUTE ... KC_MEDIA_REWIND: - if (record->event.pressed) { - start_rgb_light(); - } - break; -#endif // RGBLIGHT_TWINKLE - } - return true; -} - -void keyboard_post_init_rgb_light(void) { -#if defined(RGBLIGHT_STARTUP_ANIMATION) - bool is_enabled = rgblight_config.enable; - if (userspace_config.rgb_layer_change) { - rgblight_enable_noeeprom(); - } - if (rgblight_config.enable) { - layer_state_set_rgb_light(layer_state); - uint16_t old_hue = rgblight_config.hue; - rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); - for (uint16_t i = 255; i > 0; i--) { - rgblight_sethsv_noeeprom((i + old_hue) % 255, 255, 255); - matrix_scan(); - wait_ms(10); - } - } - if (!is_enabled) { - rgblight_disable_noeeprom(); - } - -#endif - layer_state_set_rgb_light(layer_state); -} - -void matrix_scan_rgb_light(void) { -#ifdef RGBLIGHT_ENABLE -# ifdef RGBLIGHT_TWINKLE - scan_rgblight_fadeout(); -# endif // RGBLIGHT_ENABLE - -# ifdef INDICATOR_LIGHTS - matrix_scan_indicator(); -# endif -#endif -} - -void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) { - rgblight_sethsv_noeeprom(hue, sat, val); - wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly - rgblight_mode_noeeprom(mode); -} - -layer_state_t layer_state_set_rgb_light(layer_state_t state) { -#ifdef RGBLIGHT_ENABLE - if (userspace_config.rgb_layer_change) { - switch (get_highest_layer(state)) { - case _MACROS: - rgblight_set_hsv_and_mode(HSV_ORANGE, userspace_config.is_overwatch ? RGBLIGHT_MODE_SNAKE + 2 : RGBLIGHT_MODE_SNAKE + 3); - break; - case _MEDIA: - rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1); - break; - case _GAMEPAD: - rgblight_set_hsv_and_mode(HSV_ORANGE, RGBLIGHT_MODE_SNAKE + 2); - break; - case _DIABLO: - rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3); - break; - case _RAISE: - rgblight_set_hsv_and_mode(HSV_YELLOW, RGBLIGHT_MODE_BREATHING + 3); - break; - case _LOWER: - rgblight_set_hsv_and_mode(HSV_GREEN, RGBLIGHT_MODE_BREATHING + 3); - break; - case _ADJUST: - rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2); - break; - default: // for any other layers, or the default layer - { - uint8_t mode = get_highest_layer(state) == _MODS ? RGBLIGHT_MODE_BREATHING : RGBLIGHT_MODE_STATIC_LIGHT; - switch (get_highest_layer(default_layer_state)) { - case _COLEMAK: - rgblight_set_hsv_and_mode(HSV_MAGENTA, mode); - break; - case _DVORAK: - rgblight_set_hsv_and_mode(HSV_SPRINGGREEN, mode); - break; - case _WORKMAN: - rgblight_set_hsv_and_mode(HSV_GOLDENROD, mode); - break; - case _NORMAN: - rgblight_set_hsv_and_mode(HSV_CORAL, mode); - break; - case _MALTRON: - rgblight_set_hsv_and_mode(HSV_YELLOW, mode); - break; - case _EUCALYN: - rgblight_set_hsv_and_mode(HSV_PINK, mode); - break; - case _CARPLAX: - rgblight_set_hsv_and_mode(HSV_BLUE, mode); - break; - default: - rgblight_set_hsv_and_mode(HSV_CYAN, mode); - break; - } - break; - } - } - } -#endif // RGBLIGHT_ENABLE - - return state; -} diff --git a/users/frederik/rgb_stuff.h b/users/frederik/rgb_stuff.h deleted file mode 100644 index 98a552db..00000000 --- a/users/frederik/rgb_stuff.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "quantum.h" - -#if defined(RGBLIGHT_TWINKLE) -typedef struct { - bool enabled; - uint8_t hue; - uint16_t timer; - uint8_t life; -} rgblight_fadeout; -#endif - -bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record); -void keyboard_post_init_rgb_light(void); -void matrix_scan_rgb_light(void); -layer_state_t layer_state_set_rgb_light(layer_state_t state); -layer_state_t default_layer_state_set_rgb_light(layer_state_t state); -void rgblight_sethsv_default_helper(uint8_t index); - -#if defined(RGBLIGHT_TWINKLE) -void scan_rgblight_fadeout(void); -#endif diff --git a/users/frederik/rgblight_breathe_table.h b/users/frederik/rgblight_breathe_table.h deleted file mode 100644 index 4c6ae38f..00000000 --- a/users/frederik/rgblight_breathe_table.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE -#define RGBLIGHT_EFFECT_BREATHE_TABLE - -// clang-format off -const uint8_t rgblight_effect_breathe_table[] PROGMEM = { -/* #define RGBLIGHT_EFFECT_BREATHE_CENTER 0.00 */ -/* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */ - - #if RGBLIGHT_BREATHE_TABLE_SIZE == 256 - 0x44, 0x45, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x4e, - 0x4f, 0x51, 0x52, 0x54, 0x55, 0x57, 0x58, 0x5a, - 0x5c, 0x5d, 0x5f, 0x60, 0x62, 0x64, 0x65, 0x67, - 0x69, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x73, 0x75, - 0x77, 0x79, 0x7b, 0x7c, 0x7e, 0x80, 0x82, 0x84, - 0x86, 0x88, 0x8a, 0x8b, 0x8d, 0x8f, 0x91, 0x93, - 0x95, 0x97, 0x99, 0x9b, 0x9d, 0x9f, 0xa1, 0xa3, - 0xa5, 0xa7, 0xa9, 0xaa, 0xac, 0xae, 0xb0, 0xb2, - 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xbf, 0xc1, - 0xc3, 0xc5, 0xc7, 0xc9, 0xca, 0xcc, 0xce, 0xd0, - 0xd1, 0xd3, 0xd5, 0xd6, 0xd8, 0xda, 0xdb, 0xdd, - 0xde, 0xe0, 0xe1, 0xe3, 0xe4, 0xe5, 0xe7, 0xe8, - 0xe9, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, - 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf8, - 0xf9, 0xfa, 0xfa, 0xfb, 0xfc, 0xfc, 0xfc, 0xfd, - 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, - 0xfd, 0xfc, 0xfc, 0xfc, 0xfb, 0xfa, 0xfa, 0xf9, - 0xf8, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, - 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xe9, - 0xe8, 0xe7, 0xe5, 0xe4, 0xe3, 0xe1, 0xe0, 0xde, - 0xdd, 0xdb, 0xda, 0xd8, 0xd6, 0xd5, 0xd3, 0xd1, - 0xd0, 0xce, 0xcc, 0xca, 0xc9, 0xc7, 0xc5, 0xc3, - 0xc1, 0xbf, 0xbe, 0xbc, 0xba, 0xb8, 0xb6, 0xb4, - 0xb2, 0xb0, 0xae, 0xac, 0xaa, 0xa9, 0xa7, 0xa5, - 0xa3, 0xa1, 0x9f, 0x9d, 0x9b, 0x99, 0x97, 0x95, - 0x93, 0x91, 0x8f, 0x8d, 0x8b, 0x8a, 0x88, 0x86, - 0x84, 0x82, 0x80, 0x7e, 0x7c, 0x7b, 0x79, 0x77, - 0x75, 0x73, 0x72, 0x70, 0x6e, 0x6c, 0x6a, 0x69, - 0x67, 0x65, 0x64, 0x62, 0x60, 0x5f, 0x5d, 0x5c, - 0x5a, 0x58, 0x57, 0x55, 0x54, 0x52, 0x51, 0x4f, - 0x4e, 0x4c, 0x4b, 0x4a, 0x48, 0x47, 0x45, 0x44 - #endif /* 256 bytes table */ - - #if RGBLIGHT_BREATHE_TABLE_SIZE == 128 - 0x44, 0x47, 0x4a, 0x4c, - 0x4f, 0x52, 0x55, 0x58, - 0x5c, 0x5f, 0x62, 0x65, - 0x69, 0x6c, 0x70, 0x73, - 0x77, 0x7b, 0x7e, 0x82, - 0x86, 0x8a, 0x8d, 0x91, - 0x95, 0x99, 0x9d, 0xa1, - 0xa5, 0xa9, 0xac, 0xb0, - 0xb4, 0xb8, 0xbc, 0xbf, - 0xc3, 0xc7, 0xca, 0xce, - 0xd1, 0xd5, 0xd8, 0xdb, - 0xde, 0xe1, 0xe4, 0xe7, - 0xe9, 0xec, 0xee, 0xf0, - 0xf2, 0xf4, 0xf6, 0xf8, - 0xf9, 0xfa, 0xfc, 0xfc, - 0xfd, 0xfe, 0xfe, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfe, - 0xfd, 0xfc, 0xfb, 0xfa, - 0xf8, 0xf7, 0xf5, 0xf3, - 0xf1, 0xef, 0xed, 0xeb, - 0xe8, 0xe5, 0xe3, 0xe0, - 0xdd, 0xda, 0xd6, 0xd3, - 0xd0, 0xcc, 0xc9, 0xc5, - 0xc1, 0xbe, 0xba, 0xb6, - 0xb2, 0xae, 0xaa, 0xa7, - 0xa3, 0x9f, 0x9b, 0x97, - 0x93, 0x8f, 0x8b, 0x88, - 0x84, 0x80, 0x7c, 0x79, - 0x75, 0x72, 0x6e, 0x6a, - 0x67, 0x64, 0x60, 0x5d, - 0x5a, 0x57, 0x54, 0x51, - 0x4e, 0x4b, 0x48, 0x45 - #endif /* 128 bytes table */ - - #if RGBLIGHT_BREATHE_TABLE_SIZE == 64 - 0x44, 0x4a, - 0x4f, 0x55, - 0x5c, 0x62, - 0x69, 0x70, - 0x77, 0x7e, - 0x86, 0x8d, - 0x95, 0x9d, - 0xa5, 0xac, - 0xb4, 0xbc, - 0xc3, 0xca, - 0xd1, 0xd8, - 0xde, 0xe4, - 0xe9, 0xee, - 0xf2, 0xf6, - 0xf9, 0xfc, - 0xfd, 0xfe, - 0xfe, 0xfe, - 0xfd, 0xfb, - 0xf8, 0xf5, - 0xf1, 0xed, - 0xe8, 0xe3, - 0xdd, 0xd6, - 0xd0, 0xc9, - 0xc1, 0xba, - 0xb2, 0xaa, - 0xa3, 0x9b, - 0x93, 0x8b, - 0x84, 0x7c, - 0x75, 0x6e, - 0x67, 0x60, - 0x5a, 0x54, - 0x4e, 0x48 - #endif /* 64 bytes table */ -}; -// clang-format on - -static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table); - -#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */ diff --git a/users/frederik/wrappers.h b/users/frederik/wrappers.h new file mode 100644 index 00000000..a6e47335 --- /dev/null +++ b/users/frederik/wrappers.h @@ -0,0 +1,96 @@ +#pragma once + +/* +Since our quirky block definitions are basically a list of comma separated +arguments, we need a wrapper in order for these definitions to be +expanded before being used as arguments to the LAYOUT_xxx macro. +*/ +#if (!defined(LAYOUT) && defined(KEYMAP)) +# define LAYOUT KEYMAP +#endif + +// clang-format off +#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) +#define LAYOUT_ergodox_pretty_wrapper(...) LAYOUT_ergodox_pretty(__VA_ARGS__) +#define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) +#define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) +#define LAYOUT_ortho_4x12_wrapper(...) LAYOUT_ortho_4x12(__VA_ARGS__) +#define LAYOUT_ortho_5x12_wrapper(...) LAYOUT_ortho_5x12(__VA_ARGS__) +#define LAYOUT_gergo_wrapper(...) LAYOUT_gergo(__VA_ARGS__) +#define LAYOUT_ut472_wrapper(...) LAYOUT_ut472(__VA_ARGS__) +#define LAYOUT_dropALT_wrapper(...) LAYOUT_dropALT(__VA_ARGS__) + +/* +Blocks for each of the four major keyboard layouts +Organized so we can quickly adapt and modify all of them +at once, rather than for each keyboard, one at a time. +And this allows for much cleaner blocks in the keymaps. +For instance Tap/Hold for Control on all of the layouts + +NOTE: These are all the same length. If you do a search/replace + then you need to add/remove underscores to keep the + lengths consistent. +*/ + +#define _________________QWERTY_L1_________________ KC_Q, KC_W, KC_E, KC_R, KC_T +#define _________________QWERTY_L2_________________ KC_A, KC_S, KC_D, KC_F, KC_G +#define _________________QWERTY_L3_________________ KC_Z, KC_X, KC_C, KC_V, KC_B + +// #define _________________QWERTY_R1_________________ KC_Y, KC_U, KC_I, KC_O, TD_ae +// #define _________________QWERTY_R2_________________ KC_H, KC_J, KC_K, KC_L, TD_oe +// #define _________________QWERTY_R3_________________ KC_N, KC_M, KC_COMM, KC_DOT, TD_aa + +#define _________________QWERTY_R1_________________ KC_Y, KC_U, KC_I, KC_O, KC_P +#define _________________QWERTY_R2_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN +#define _________________QWERTY_R3_________________ KC_N, KC_M, KC_COMM, KC_DOT, KC_SLASH + +#define _________________WORKMAN_L1________________ KC_Q, KC_D, KC_R, KC_W, KC_B +#define _________________WORKMAN_L2________________ KC_A, KC_S, KC_H, KC_T, KC_G +#define _________________WORKMAN_L3________________ KC_Z, KC_X, KC_M, KC_C, KC_V + +#define _________________WORKMAN_R1________________ KC_J, KC_F, KC_U, KC_P, KC_SCLN +#define _________________WORKMAN_R2________________ KC_Y, KC_N, KC_E, KC_O, KC_I +#define _________________WORKMAN_R3________________ KC_K, KC_L, KC_COMM, KC_DOT, KC_SLASH + +#define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5 +#define ________________NUMBER_RIGHT_______________ KC_6, KC_7, KC_8, KC_9, KC_0 +#define _________________FUNC_LEFT_________________ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5 +#define _________________FUNC_RIGHT________________ KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 + +#define ___________________BLANK___________________ _______, _______, _______, _______, _______ + +#define _________________LOWER_L1__________________ ___________________BLANK___________________ +#define _________________LOWER_L2__________________ _______, KC_MPRV, KC_MPLY, KC_MNXT, _______ +#define _________________LOWER_L3__________________ ___________________BLANK___________________ + +#define _________________LOWER_R1__________________ KC_SLSH, KC_7, KC_8, KC_9, KC_MINS +#define _________________LOWER_R2__________________ KC_ASTR, KC_4, KC_5, KC_6, KC_COMM +#define _________________LOWER_R3__________________ KC_0, KC_1, KC_2, KC_3, KC_EQL + +#define _________________RAISE_L1__________________ KC_EXLM, KC_AT, KC_LPRN, KC_RPRN, KC_PIPE +#define _________________RAISE_L2__________________ KC_HASH, KC_DLR, KC_LBRC, KC_RBRC, KC_GRV +#define _________________RAISE_L3__________________ KC_PERC, KC_CIRC, KC_LCBR, KC_RCBR, KC_TILD + +#define _________________RAISE_R1__________________ _______, KC_UNDS, ALGR(KC_5),_______,KC_BSLS +#define _________________RAISE_R2__________________ KC_PLUS, KC_MINS, KC_SLSH, KC_ASTR, KC_PERC +#define _________________RAISE_R3__________________ KC_AMPR, KC_EQL, KC_COMM, KC_DOT, KC_SLSH + +#define _________________ADJUST_L1_________________ ___________________BLANK___________________ +#define _________________ADJUST_L2_________________ _______, RGB_SAI, RGB_HUI, RGB_VAI, _______ +#define _________________ADJUST_L3_________________ _______, RGB_SAD, RGB_HUD, RGB_VAD, _______ + +#define _________________ADJUST_R1_________________ RGB_TOG, KC_F7, KC_F8, KC_F9, KC_F10 +#define _________________ADJUST_R2_________________ _______, KC_F4, KC_F5, KC_F6, KC_F11 +#define _________________ADJUST_R3_________________ _______, KC_F1, KC_F2, KC_F3, KC_F12 + +#define ___________________NAV_L1__________________ DF(_QWERTY), DF(_WORKMAN), TG(_WARCRAFT), TG(_DIABLO), _______ +#define ___________________NAV_L2__________________ _______, _______, KC_UP , _______, _______ +#define ___________________NAV_L3__________________ _______, KC_LEFT, KC_DOWN, KC_RGHT, _______ + +#define ___________________NAV_R1__________________ KC_PGUP, KC_HOME, KC_UP, KC_END, _______ +#define ___________________NAV_R2__________________ KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, _______ +#define ___________________NAV_R3__________________ _______, _______, _______, _______, _______ + + +// clang-format on +