Last active
March 24, 2022 16:28
-
-
Save drashna/e042df8b7cfec8189c928bcf300af7c7 to your computer and use it in GitHub Desktop.
How to emulate wilba_tech rgb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ENABLE_RGB_MATRIX_ALPHAS_MODS | |
#define ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN | |
#define ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT | |
#define ENABLE_RGB_MATRIX_CYCLE_ALL | |
#define ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT | |
#define ENABLE_RGB_MATRIX_CYCLE_UP_DOWN | |
#define ENABLE_RGB_MATRIX_RAINDROPS | |
#define ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS | |
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN | |
#define ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL | |
#define VIA_CUSTOM_LIGHTING_ENABLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef union { | |
uint32_t raw; | |
struct { | |
bool layout_split_backspace :1; | |
bool another_layout_config :1; | |
} | |
} via_layout_options_t; | |
via_layout_options_t via_layout_options; | |
/** | |
* @brief blank out leds based on layout | |
* | |
* Disable certain leds based on the layout. Could use flags here, but doesn't matter. | |
*/ | |
void rgb_matrix_indicators_user(void) { | |
# ifdef VIA_ENABLE | |
if (via_layout_options.layout_split_backspace) { | |
rgb_matrix_set_color(5, 0, 0, 0); | |
rgb_matrix_set_color(7, 0, 0, 0); | |
} else { | |
rgb_matrix_set_color(6, 0, 0, 0); | |
} | |
#endif | |
} | |
/** | |
* @brief grab layout options at in interval | |
* | |
* Because VIA doesn't offer the keyboard code any way to get this information normally, | |
* we have to use an ugly fucking hack to read the information frequently. | |
*/ | |
# ifdef VIA_ENABLE | |
void via_set_layout_options_kb(uint32_t value) { | |
via_layout_options.raw = value; | |
} | |
#endif | |
void via_qmk_rgblight_get_value(uint8_t *data) { | |
uint8_t *value_id = &(data[0]); | |
uint8_t *value_data = &(data[1]); | |
switch (*value_id) { | |
case id_qmk_rgblight_brightness: { | |
value_data[0] = rgb_matrix_get_val(); | |
break; | |
} | |
case id_qmk_rgblight_effect: { | |
value_data[0] = rgb_matrix_is_enabled() ? rgb_matrix_get_mode() : 0; | |
break; | |
} | |
case id_qmk_rgblight_effect_speed: { | |
value_data[0] = rgb_matrix_get_speed(); | |
break; | |
} | |
case id_qmk_rgblight_color: { | |
value_data[0] = rgb_matrix_get_hue(); | |
value_data[1] = rgb_matrix_get_sat(); | |
break; | |
} | |
} | |
} | |
void via_qmk_rgblight_set_value(uint8_t *data) { | |
uint8_t *value_id = &(data[0]); | |
uint8_t *value_data = &(data[1]); | |
switch (*value_id) { | |
case id_qmk_rgblight_brightness: { | |
rgb_matrix_sethsv_noeeprom(rgblight_get_hue(), rgblight_get_sat(), value_data[0]); | |
break; | |
} | |
case id_qmk_rgblight_effect: { | |
if (value_data[0] == 0) { | |
rgb_matrix_disable_noeeprom(); | |
} else { | |
rgb_matrix_enable_noeeprom(); | |
rgb_matrix_mode_noeeprom(value_data[0]); | |
} | |
break; | |
} | |
case id_qmk_rgblight_effect_speed: { | |
rgb_matrix_set_speed_noeeprom(value_data[0]); | |
break; | |
} | |
case id_qmk_rgblight_color: { | |
rgb_matrix_sethsv_noeeprom(value_data[0], value_data[1], rgblight_get_val()); | |
break; | |
} | |
} | |
} | |
void raw_hid_receive_kb(uint8_t *data, uint8_t length) { | |
uint8_t *command_id = &(data[0]); | |
uint8_t *command_data = &(data[1]); | |
switch (*command_id) { | |
case id_lighting_set_value: | |
via_qmk_rgblight_set_value(command_data); | |
break; | |
case id_lighting_get_value: | |
via_qmk_rgblight_get_value(command_data); | |
break; | |
case id_lighting_save: | |
eeconfig_update_rgb_matrix(); | |
break; | |
default: | |
// Unhandled message. | |
*command_id = id_unhandled; | |
break; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"lighting": { | |
"extends": "qmk_rgblight", | |
"keycodes": "qmk", | |
"underglowEffects": [ | |
["Off", 0], | |
["Solid Color", 1], | |
["Alpha Mods", 1], | |
["Gradient Up-Down", 1], | |
["Gradient Left-Right", 1], | |
["Gradient Cycle", 1], | |
["Gradient Cycle Left-Right", 1], | |
["Gradient Cycle Up-Down", 1], | |
["Cycle In", 1], | |
["Cycle In (Dual)", 1], | |
["Raindrops", 1], | |
["Jellybean Raindrops", 1], | |
] | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment