VIA V3 - The Custom UI Update (#18222)
parent
575b0e33fa
commit
bc6f8dc8b0
|
@ -82,9 +82,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
|
// 6 for 3x custom encoder settings, left, right, and press (18 bytes)
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Feature disable options
|
* Feature disable options
|
||||||
* These options are also useful to firmware size reduction.
|
* These options are also useful to firmware size reduction.
|
||||||
|
|
|
@ -102,113 +102,142 @@ void backlight_set_value( uint8_t *data )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_hid_receive_kb( uint8_t *data, uint8_t length )
|
void custom_set_value(uint8_t *data) {
|
||||||
{
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *command_id = &(data[0]);
|
uint8_t *value_data = &(data[1]);
|
||||||
uint8_t *command_data = &(data[1]);
|
|
||||||
switch ( *command_id )
|
switch ( *value_id ) {
|
||||||
{
|
|
||||||
case id_get_keyboard_value:
|
|
||||||
{
|
|
||||||
switch( command_data[0])
|
|
||||||
{
|
|
||||||
case id_oled_default_mode:
|
|
||||||
{
|
|
||||||
uint8_t default_oled = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
|
|
||||||
command_data[1] = default_oled;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_oled_mode:
|
|
||||||
{
|
|
||||||
command_data[1] = oled_mode;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_encoder_modes:
|
|
||||||
{
|
|
||||||
command_data[1] = enabled_encoder_modes;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_encoder_custom:
|
|
||||||
{
|
|
||||||
uint8_t custom_encoder_idx = command_data[1];
|
|
||||||
uint16_t keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CW);
|
|
||||||
command_data[2] = keycode >> 8;
|
|
||||||
command_data[3] = keycode & 0xFF;
|
|
||||||
keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_CCW);
|
|
||||||
command_data[4] = keycode >> 8;
|
|
||||||
command_data[5] = keycode & 0xFF;
|
|
||||||
keycode = retrieve_custom_encoder_config(custom_encoder_idx, ENC_CUSTOM_PRESS);
|
|
||||||
command_data[6] = keycode >> 8;
|
|
||||||
command_data[7] = keycode & 0xFF;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_set_keyboard_value:
|
|
||||||
{
|
|
||||||
switch(command_data[0]){
|
|
||||||
case id_oled_default_mode:
|
case id_oled_default_mode:
|
||||||
{
|
{
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, command_data[1]);
|
eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, value_data[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_oled_mode:
|
case id_oled_mode:
|
||||||
{
|
{
|
||||||
oled_mode = command_data[1];
|
oled_mode = value_data[0];
|
||||||
oled_request_wakeup();
|
oled_request_wakeup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_encoder_modes:
|
case id_encoder_modes:
|
||||||
{
|
{
|
||||||
enabled_encoder_modes = command_data[1];
|
uint8_t index = value_data[0];
|
||||||
eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
|
uint8_t enable = value_data[1];
|
||||||
break;
|
enabled_encoder_modes = (enabled_encoder_modes & ~(1<<index)) | (enable<<index);
|
||||||
|
eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case id_encoder_custom:
|
case id_encoder_custom:
|
||||||
{
|
{
|
||||||
uint8_t custom_encoder_idx = command_data[1];
|
uint8_t custom_encoder_idx = value_data[0];
|
||||||
uint8_t encoder_behavior = command_data[2];
|
uint8_t encoder_behavior = value_data[1];
|
||||||
uint16_t keycode = (command_data[3] << 8) | command_data[4];
|
uint16_t keycode = (value_data[2] << 8) | value_data[3];
|
||||||
set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode);
|
set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_get_value(uint8_t *data) {
|
||||||
|
uint8_t *value_id = &(data[0]);
|
||||||
|
uint8_t *value_data = &(data[1]);
|
||||||
|
|
||||||
|
switch ( *value_id ) {
|
||||||
|
case id_oled_default_mode:
|
||||||
{
|
{
|
||||||
*command_id = id_unhandled;
|
uint8_t default_oled = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
|
||||||
break;
|
value_data[0] = default_oled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_oled_mode:
|
||||||
|
{
|
||||||
|
value_data[0] = oled_mode;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_encoder_modes:
|
||||||
|
{
|
||||||
|
uint8_t index = value_data[0];
|
||||||
|
value_data[1] = (enabled_encoder_modes & (1<<index)) ? 1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_encoder_custom:
|
||||||
|
{
|
||||||
|
uint8_t custom_encoder_idx = value_data[0];
|
||||||
|
uint8_t encoder_behavior = value_data[1];
|
||||||
|
uint16_t keycode = retrieve_custom_encoder_config(custom_encoder_idx, encoder_behavior);
|
||||||
|
value_data[2] = keycode >> 8;
|
||||||
|
value_data[3] = keycode & 0xFF;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case id_lighting_set_value:
|
}
|
||||||
{
|
|
||||||
backlight_set_value(command_data);
|
// TODO
|
||||||
break;
|
// Refactor so this keyboard uses QMK Core backlight code,
|
||||||
|
// then change this to via_custom_value_command_kb() so it
|
||||||
|
// only handles the custom values not the backlight
|
||||||
|
// (i.e. use QMK Core default handler for backlight values).
|
||||||
|
//
|
||||||
|
void via_custom_value_command(uint8_t *data, uint8_t length) {
|
||||||
|
uint8_t *command_id = &(data[0]);
|
||||||
|
uint8_t *channel_id = &(data[1]);
|
||||||
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
|
|
||||||
|
if ( *channel_id == id_qmk_backlight_channel ) {
|
||||||
|
switch ( *command_id )
|
||||||
|
{
|
||||||
|
case id_custom_set_value:
|
||||||
|
{
|
||||||
|
backlight_set_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value:
|
||||||
|
{
|
||||||
|
backlight_get_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save:
|
||||||
|
{
|
||||||
|
backlight_config_save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Unhandled message.
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ( *channel_id == id_custom_channel ) {
|
||||||
|
switch ( *command_id )
|
||||||
|
{
|
||||||
|
case id_custom_set_value:
|
||||||
|
{
|
||||||
|
custom_set_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value:
|
||||||
|
{
|
||||||
|
custom_get_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save:
|
||||||
|
{
|
||||||
|
// values are saved in custom_set_value()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Unhandled message.
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case id_lighting_get_value:
|
|
||||||
{
|
*command_id = id_unhandled;
|
||||||
backlight_get_value(command_data);
|
|
||||||
break;
|
// DO NOT call raw_hid_send(data,length) here, let caller do this
|
||||||
}
|
|
||||||
case id_lighting_save:
|
|
||||||
{
|
|
||||||
backlight_config_save();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
// Unhandled message.
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// DO NOT call raw_hid_send(data,length) here, let caller do this
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ enum my_keycodes {
|
||||||
OLED_TOGG
|
OLED_TOGG
|
||||||
};
|
};
|
||||||
|
|
||||||
enum s75_keyboard_value_id {
|
enum s75_custom_value_id {
|
||||||
id_encoder_modes = 0x80,
|
id_encoder_modes = 1,
|
||||||
id_oled_default_mode,
|
id_oled_default_mode,
|
||||||
id_encoder_custom,
|
id_encoder_custom,
|
||||||
id_oled_mode
|
id_oled_mode
|
||||||
|
|
|
@ -130,7 +130,4 @@
|
||||||
# define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
# define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||||
# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
# define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||||
|
|
||||||
// This allows VIA to control RGB Matrix settings in the 'Lighting' section.
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
#endif /* RGB_MATRIX_ENABLE */
|
#endif /* RGB_MATRIX_ENABLE */
|
||||||
|
|
|
@ -3,5 +3,4 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
|
||||||
|
|
|
@ -17,115 +17,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG,
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_TOG,
|
||||||
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI,
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAI,
|
||||||
KC_TRNS, GUI_TOG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_RMOD,RGB_VAD, RGB_MOD)
|
KC_TRNS, GUI_TOG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_RMOD,RGB_VAD, RGB_MOD)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE) && defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
|
|
||||||
// VIA supports only 4 discrete values for effect speed; map these to some
|
|
||||||
// useful speed values for RGB Matrix.
|
|
||||||
enum speed_values {
|
|
||||||
RGBLIGHT_SPEED_0 = UINT8_MAX / 16, // not 0 to avoid really slow effects
|
|
||||||
RGBLIGHT_SPEED_1 = UINT8_MAX / 4,
|
|
||||||
RGBLIGHT_SPEED_2 = UINT8_MAX / 2, // matches the default value
|
|
||||||
RGBLIGHT_SPEED_3 = UINT8_MAX / 4 * 3, // UINT8_MAX is really fast
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t speed_from_rgblight(uint8_t rgblight_speed) {
|
|
||||||
switch (rgblight_speed) {
|
|
||||||
case 0:
|
|
||||||
return RGBLIGHT_SPEED_0;
|
|
||||||
case 1:
|
|
||||||
return RGBLIGHT_SPEED_1;
|
|
||||||
case 2:
|
|
||||||
default:
|
|
||||||
return RGBLIGHT_SPEED_2;
|
|
||||||
case 3:
|
|
||||||
return RGBLIGHT_SPEED_3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t speed_to_rgblight(uint8_t rgb_matrix_speed) {
|
|
||||||
if (rgb_matrix_speed < ((RGBLIGHT_SPEED_0 + RGBLIGHT_SPEED_1) / 2)) {
|
|
||||||
return 0;
|
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_1 + RGBLIGHT_SPEED_2) / 2)) {
|
|
||||||
return 1;
|
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_2 + RGBLIGHT_SPEED_3) / 2)) {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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] = speed_to_rgblight(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(speed_from_rgblight(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // defined(RGB_MATRIX_ENABLE) && defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
|
@ -1,2 +0,0 @@
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 4
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
|
@ -17,7 +17,3 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -135,6 +135,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -135,6 +135,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -133,6 +133,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
VIA_ENABLE = yes
|
VIA_ENABLE = yes
|
||||||
LTO_ENABLE = yes
|
LTO_ENABLE = yes
|
||||||
ENCODER_MAP_ENABLE = yes
|
ENCODER_MAP_ENABLE = yes
|
||||||
|
CONSOLE_ENABLE = no
|
||||||
|
|
|
@ -133,6 +133,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -43,11 +43,6 @@
|
||||||
/* Disable RGB lighting when PC is in suspend */
|
/* Disable RGB lighting when PC is in suspend */
|
||||||
#define RGB_DISABLE_WHEN_USB_SUSPENDED
|
#define RGB_DISABLE_WHEN_USB_SUSPENDED
|
||||||
|
|
||||||
/* Allow VIA to edit lighting */
|
|
||||||
#ifdef VIA_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// RGB Matrix Animation modes. Explicitly enabled
|
// RGB Matrix Animation modes. Explicitly enabled
|
||||||
// For full list of effects, see:
|
// For full list of effects, see:
|
||||||
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
|
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
|
||||||
|
@ -96,8 +91,3 @@
|
||||||
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||||
|
|
||||||
/* Allow VIA to edit lighting */
|
|
||||||
#ifdef VIA_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -110,8 +110,3 @@
|
||||||
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||||
|
|
||||||
/* Allow VIA to edit lighting */
|
|
||||||
#ifdef VIA_ENABLE
|
|
||||||
# define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2021 Mechlovin' Studio
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
|
||||||
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,23 +0,0 @@
|
||||||
/* Copyright 2022 ML
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
|
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
|
@ -1,17 +0,0 @@
|
||||||
/* Copyright 2021 datafx
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
|
@ -1,18 +0,0 @@
|
||||||
/* Copyright 2021 datafx
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
|
@ -18,7 +18,3 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
|
||||||
|
|
||||||
#ifdef RGB_MATRIX_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -134,9 +134,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
||||||
/* Custom EEPROM start addressing. This is to support
|
/* Custom EEPROM start addressing. This is to support
|
||||||
* both 128kb and 256kb versions of F303.
|
* both 128kb and 256kb versions of F303.
|
||||||
* Register 0x1FFFF7CC holds the size of the flash memory.
|
* Register 0x1FFFF7CC holds the size of the flash memory.
|
||||||
|
|
|
@ -134,6 +134,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -25,6 +25,4 @@
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
||||||
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
||||||
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
||||||
|
|
|
@ -26,7 +26,5 @@
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
||||||
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
||||||
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,5 @@
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
||||||
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
|
||||||
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
#define STM32_ONBOARD_EEPROM_SIZE 2048
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
|
@ -158,7 +158,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
|
@ -122,6 +122,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_MULTISPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
|
||||||
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
|
||||||
|
|
||||||
// // VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -42,72 +42,3 @@ led_config_t g_led_config = { {
|
||||||
// clang-format on
|
// clang-format on
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE) && defined(VIA_ENABLE)
|
|
||||||
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: {
|
|
||||||
uint8_t *value_id = &(command_data[0]);
|
|
||||||
uint8_t *value_data = &(command_data[1]);
|
|
||||||
switch (*value_id) {
|
|
||||||
case id_qmk_rgblight_brightness: {
|
|
||||||
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_effect: {
|
|
||||||
rgb_matrix_mode_noeeprom(value_data[0]);
|
|
||||||
if (value_data[0] == 0) {
|
|
||||||
rgb_matrix_disable_noeeprom();
|
|
||||||
} else {
|
|
||||||
rgb_matrix_enable_noeeprom();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_effect_speed: {
|
|
||||||
rgb_matrix_set_speed_noeeprom(value_data[0] * 85);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_color: {
|
|
||||||
rgb_matrix_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_lighting_get_value: {
|
|
||||||
uint8_t *value_id = &(command_data[0]);
|
|
||||||
uint8_t *value_data = &(command_data[1]);
|
|
||||||
switch (*value_id) {
|
|
||||||
case id_qmk_rgblight_brightness: {
|
|
||||||
value_data[0] = ((uint16_t)rgb_matrix_get_val() * 255) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_effect: {
|
|
||||||
value_data[0] = rgb_matrix_get_mode();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_effect_speed: {
|
|
||||||
value_data[0] = rgb_matrix_get_speed() / 85;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_qmk_rgblight_color: {
|
|
||||||
value_data[0] = rgb_matrix_get_hue();
|
|
||||||
value_data[1] = rgb_matrix_get_sat();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_lighting_save: {
|
|
||||||
eeconfig_update_rgb_matrix();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -114,6 +114,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2022 Terry Mathews
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
|
@ -47,75 +47,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
_______, _______, _______, _______, _______, _______, _______, _______, _______
|
_______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
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_get_flags() ? 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_set_flags(LED_FLAG_NONE);
|
|
||||||
} else {
|
|
||||||
rgb_matrix_mode_noeeprom(value_data[0]);
|
|
||||||
rgb_matrix_set_flags(LED_FLAG_MODIFIER|LED_FLAG_UNDERGLOW|LED_FLAG_KEYLIGHT);
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -161,7 +161,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
# define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -108,6 +108,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -109,6 +109,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -103,6 +103,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 51
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 51
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -101,6 +101,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -108,6 +108,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -101,6 +101,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -101,6 +101,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -100,6 +100,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -143,6 +143,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -153,6 +153,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
// Copyright 2022 Jason Williams (@wilba)
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
// This is a test harness for VIA custom UI.
|
||||||
|
//
|
||||||
|
// It handles channel IDs 0-7, value IDs 0-7.
|
||||||
|
//
|
||||||
|
// It's useful for testing custom UI on a PCB without compiling in
|
||||||
|
// features, especially features that will cause firmware to freeze
|
||||||
|
// if the PCB doesn't have support.
|
||||||
|
//
|
||||||
|
// To use:
|
||||||
|
// - add `SRC = keyboards/wilba_tech/via_test.c` to rules.mk
|
||||||
|
// - add `#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 128` to config.h
|
||||||
|
// (or change to match CHANNELS*VALUES*2)
|
||||||
|
|
||||||
|
#include "quantum.h"
|
||||||
|
#include "via.h"
|
||||||
|
|
||||||
|
#ifdef VIA_ENABLE
|
||||||
|
|
||||||
|
#define CHANNELS 8
|
||||||
|
#define VALUES 8
|
||||||
|
uint8_t g_value[CHANNELS][VALUES][2];
|
||||||
|
|
||||||
|
void values_init(void)
|
||||||
|
{
|
||||||
|
for ( uint8_t channel_id = 0; channel_id < CHANNELS; channel_id++ ) {
|
||||||
|
for ( uint8_t value_id = 0; value_id < VALUES; value_id++ ) {
|
||||||
|
g_value[channel_id][value_id][0] = 0x00;
|
||||||
|
g_value[channel_id][value_id][1] = 0x00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void values_load(void)
|
||||||
|
{
|
||||||
|
eeprom_read_block( g_value, ((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR), VIA_EEPROM_CUSTOM_CONFIG_SIZE );
|
||||||
|
}
|
||||||
|
|
||||||
|
void values_save(void)
|
||||||
|
{
|
||||||
|
eeprom_update_block( g_value, ((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR), VIA_EEPROM_CUSTOM_CONFIG_SIZE );
|
||||||
|
}
|
||||||
|
|
||||||
|
// We do this to test if VIA is sending save commands per channel
|
||||||
|
// Not relevant for real situations
|
||||||
|
void values_save_on_channel(uint8_t channel_id)
|
||||||
|
{
|
||||||
|
uint16_t offset = channel_id * VALUES * 2;
|
||||||
|
eeprom_update_block( ((void*)g_value) + offset,
|
||||||
|
((void*)VIA_EEPROM_CUSTOM_CONFIG_ADDR) + offset,
|
||||||
|
VALUES * 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void via_init_kb(void)
|
||||||
|
{
|
||||||
|
values_init();
|
||||||
|
|
||||||
|
// If the EEPROM has the magic, the data is good.
|
||||||
|
// OK to load from EEPROM
|
||||||
|
if (via_eeprom_is_valid()) {
|
||||||
|
values_load();
|
||||||
|
} else {
|
||||||
|
values_save();
|
||||||
|
// DO NOT set EEPROM valid here, let caller do this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_value( uint8_t channel_id, uint8_t *data )
|
||||||
|
{
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
|
uint8_t *value_id = &(data[0]);
|
||||||
|
uint8_t *value_data = &(data[1]);
|
||||||
|
if ( *value_id >= 0 && *value_id < VALUES ) {
|
||||||
|
g_value[channel_id][*value_id][0] = value_data[0];
|
||||||
|
g_value[channel_id][*value_id][1] = value_data[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void get_value( uint8_t channel_id, uint8_t *data )
|
||||||
|
{
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
|
uint8_t *value_id = &(data[0]);
|
||||||
|
uint8_t *value_data = &(data[1]);
|
||||||
|
if ( *value_id >= 0 && *value_id < VALUES ) {
|
||||||
|
value_data[0] = g_value[channel_id][*value_id][0];
|
||||||
|
value_data[1] = g_value[channel_id][*value_id][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void via_custom_value_command(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
|
uint8_t *command_id = &(data[0]);
|
||||||
|
uint8_t *channel_id = &(data[1]);
|
||||||
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
|
|
||||||
|
if ( *channel_id >= 0 && *channel_id < CHANNELS ) {
|
||||||
|
switch ( *command_id )
|
||||||
|
{
|
||||||
|
case id_custom_set_value:
|
||||||
|
{
|
||||||
|
set_value(*channel_id,value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value:
|
||||||
|
{
|
||||||
|
get_value(*channel_id,value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save:
|
||||||
|
{
|
||||||
|
//for ( uint8_t i=0; i<CHANNELS; i++) {
|
||||||
|
values_save_on_channel(*channel_id);
|
||||||
|
//}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Unhandled message.
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DO NOT call raw_hid_send(data,length) here, let caller do this
|
||||||
|
}
|
||||||
|
#endif // VIA_ENABLE
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -104,6 +104,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -104,6 +104,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -105,6 +105,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
|
||||||
float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
|
float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
|
||||||
float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
|
float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
|
||||||
float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
|
float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
|
||||||
|
float tone_device_indication[][2] = SONG(FANTASIE_IMPROMPTU);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -95,3 +96,9 @@ bool led_update_kb(led_t led_state) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void via_set_device_indication(uint8_t value) {
|
||||||
|
if ( value == 0 ) {
|
||||||
|
PLAY_SONG(tone_device_indication);
|
||||||
|
}
|
||||||
|
}
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -121,6 +121,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -132,36 +132,45 @@ void suspend_wakeup_init_kb(void)
|
||||||
// Moving this to the bottom of this source file is a workaround
|
// Moving this to the bottom of this source file is a workaround
|
||||||
// for an intermittent compiler error for Atmel compiler.
|
// for an intermittent compiler error for Atmel compiler.
|
||||||
#ifdef VIA_ENABLE
|
#ifdef VIA_ENABLE
|
||||||
void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
|
||||||
uint8_t *command_id = &(data[0]);
|
uint8_t *command_id = &(data[0]);
|
||||||
uint8_t *command_data = &(data[1]);
|
uint8_t *channel_id = &(data[1]);
|
||||||
switch ( *command_id )
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
{
|
|
||||||
#if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
|
#if RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
|
||||||
case id_lighting_set_value:
|
if ( *channel_id == id_custom_channel ) {
|
||||||
|
switch ( *command_id )
|
||||||
{
|
{
|
||||||
backlight_config_set_value(command_data);
|
case id_custom_set_value:
|
||||||
break;
|
{
|
||||||
}
|
backlight_config_set_value(value_id_and_data);
|
||||||
case id_lighting_get_value:
|
break;
|
||||||
{
|
}
|
||||||
backlight_config_get_value(command_data);
|
case id_custom_get_value:
|
||||||
break;
|
{
|
||||||
}
|
backlight_config_get_value(value_id_and_data);
|
||||||
case id_lighting_save:
|
break;
|
||||||
{
|
}
|
||||||
backlight_config_save();
|
case id_custom_save:
|
||||||
break;
|
{
|
||||||
}
|
backlight_config_save();
|
||||||
#endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
|
break;
|
||||||
default:
|
}
|
||||||
{
|
default:
|
||||||
// Unhandled message.
|
{
|
||||||
*command_id = id_unhandled;
|
// Unhandled message.
|
||||||
*command_data = *command_data; // force use of variable
|
*command_id = id_unhandled;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
*channel_id = *channel_id; // force use of variable
|
||||||
|
*value_id_and_data = *value_id_and_data; // force use of variable
|
||||||
|
#endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
|
||||||
|
|
||||||
// DO NOT call raw_hid_send(data,length) here, let caller do this
|
// DO NOT call raw_hid_send(data,length) here, let caller do this
|
||||||
}
|
}
|
||||||
#endif // VIA_ENABLE
|
#endif // VIA_ENABLE
|
||||||
|
|
|
@ -107,6 +107,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -107,6 +107,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -4,12 +4,3 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
||||||
|
|
||||||
// Enable a limited form of RGB Matrix support in VIA (requires redefining the
|
|
||||||
// effect list in the VIA JSON, which then becomes not 100% compatible with the
|
|
||||||
// RGBLIGHT firmwares).
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
// Enable the workaround for the speed parameter mismatch between RGBLIGHT and
|
|
||||||
// RGB Matrix, so that the speed slider in VIA behaves in a more useful way.
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -164,60 +164,6 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
# if defined(VIA_ENABLE) && defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
|
|
||||||
// VIA supports only 4 discrete values for effect speed; map these to some
|
|
||||||
// useful speed values for RGB Matrix.
|
|
||||||
enum speed_values {
|
|
||||||
RGBLIGHT_SPEED_0 = UINT8_MAX / 16, // not 0 to avoid really slow effects
|
|
||||||
RGBLIGHT_SPEED_1 = UINT8_MAX / 4,
|
|
||||||
RGBLIGHT_SPEED_2 = UINT8_MAX / 2, // matches the default value
|
|
||||||
RGBLIGHT_SPEED_3 = UINT8_MAX / 4 * 3, // UINT8_MAX is really fast
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t speed_from_rgblight(uint8_t rgblight_speed) {
|
|
||||||
switch (rgblight_speed) {
|
|
||||||
case 0:
|
|
||||||
return RGBLIGHT_SPEED_0;
|
|
||||||
case 1:
|
|
||||||
return RGBLIGHT_SPEED_1;
|
|
||||||
case 2:
|
|
||||||
default:
|
|
||||||
return RGBLIGHT_SPEED_2;
|
|
||||||
case 3:
|
|
||||||
return RGBLIGHT_SPEED_3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t speed_to_rgblight(uint8_t rgb_matrix_speed) {
|
|
||||||
if (rgb_matrix_speed < ((RGBLIGHT_SPEED_0 + RGBLIGHT_SPEED_1) / 2)) {
|
|
||||||
return 0;
|
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_1 + RGBLIGHT_SPEED_2) / 2)) {
|
|
||||||
return 1;
|
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_2 + RGBLIGHT_SPEED_3) / 2)) {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
|
||||||
switch (data[0]) {
|
|
||||||
case id_lighting_get_value:
|
|
||||||
if (data[1] == id_qmk_rgblight_effect_speed) {
|
|
||||||
data[2] = speed_to_rgblight(rgb_matrix_get_speed());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case id_lighting_set_value:
|
|
||||||
if (data[1] == id_qmk_rgblight_effect_speed) {
|
|
||||||
rgb_matrix_set_speed_noeeprom(speed_from_rgblight(data[2]));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif // defined(VIA_ENABLE) && defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
|
|
||||||
#endif // defined(RGB_MATRIX_ENABLE)
|
#endif // defined(RGB_MATRIX_ENABLE)
|
||||||
|
|
||||||
void winry315_set_orientation(uint8_t orientation) {
|
void winry315_set_orientation(uint8_t orientation) {
|
||||||
|
|
|
@ -128,6 +128,3 @@
|
||||||
// Backlight config starts after VIA's EEPROM usage,
|
// Backlight config starts after VIA's EEPROM usage,
|
||||||
// dynamic keymaps start after this.
|
// dynamic keymaps start after this.
|
||||||
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
|
||||||
|
|
||||||
// VIA lighting is handled by the keyboard-level code
|
|
||||||
#define VIA_CUSTOM_LIGHTING_ENABLE
|
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
/* Copyright 2021 Harrison Chan (Xelus)
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// Enable RGB Matrix
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
|
@ -18,6 +18,3 @@
|
||||||
|
|
||||||
// 3 layers or else it will not fit in EEPROM
|
// 3 layers or else it will not fit in EEPROM
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
|
||||||
|
|
||||||
// Enable RGB Matrix
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
|
@ -15,8 +15,5 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// RGB Matrix
|
|
||||||
#define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
|
|
||||||
// More layers
|
// More layers
|
||||||
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
|
||||||
|
|
|
@ -279,9 +279,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
|
||||||
p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
|
p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
|
||||||
void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
|
void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
|
||||||
while (id > 0) {
|
while (id > 0) {
|
||||||
// If we are past the end of the buffer, then the buffer
|
// If we are past the end of the buffer, then there is
|
||||||
// contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT
|
// no Nth macro in the buffer.
|
||||||
// nulls in the buffer.
|
|
||||||
if (p == end) {
|
if (p == end) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -291,9 +290,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the macro string one or three chars at a time
|
// Send the macro string by making a temporary string.
|
||||||
// by making temporary 1 or 3 char strings
|
char data[8] = {0};
|
||||||
char data[4] = {0, 0, 0, 0};
|
|
||||||
// We already checked there was a null at the end of
|
// We already checked there was a null at the end of
|
||||||
// the buffer, so this cannot go past the end
|
// the buffer, so this cannot go past the end
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -303,14 +301,44 @@ void dynamic_keymap_macro_send(uint8_t id) {
|
||||||
if (data[0] == 0) {
|
if (data[0] == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If the char is magic (tap, down, up),
|
if (data[0] == SS_QMK_PREFIX) {
|
||||||
// add the next char (key to use) and send a 3 char string.
|
// Get the code
|
||||||
if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) {
|
data[1] = eeprom_read_byte(p++);
|
||||||
data[1] = data[0];
|
// Unexpected null, abort.
|
||||||
data[0] = SS_QMK_PREFIX;
|
if (data[1] == 0) {
|
||||||
data[2] = eeprom_read_byte(p++);
|
return;
|
||||||
if (data[2] == 0) {
|
}
|
||||||
break;
|
if (data[1] == SS_TAP_CODE || data[1] == SS_DOWN_CODE || data[1] == SS_UP_CODE) {
|
||||||
|
// Get the keycode
|
||||||
|
data[2] = eeprom_read_byte(p++);
|
||||||
|
// Unexpected null, abort.
|
||||||
|
if (data[2] == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Null terminate
|
||||||
|
data[3] = 0;
|
||||||
|
} else if (data[1] == SS_DELAY_CODE) {
|
||||||
|
// Get the number and '|'
|
||||||
|
// At most this is 4 digits plus '|'
|
||||||
|
uint8_t i = 2;
|
||||||
|
while (1) {
|
||||||
|
data[i] = eeprom_read_byte(p++);
|
||||||
|
// Unexpected null, abort
|
||||||
|
if (data[i] == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Found '|', send it
|
||||||
|
if (data[i] == '|') {
|
||||||
|
data[i + 1] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// If haven't found '|' by i==6 then
|
||||||
|
// number too big, abort
|
||||||
|
if (i == 6) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY);
|
send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY);
|
||||||
|
|
|
@ -54,6 +54,12 @@ void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data);
|
||||||
// strings, the last byte must be a null when at maximum capacity,
|
// strings, the last byte must be a null when at maximum capacity,
|
||||||
// and it not being null means the buffer can be considered in an
|
// and it not being null means the buffer can be considered in an
|
||||||
// invalid state.
|
// invalid state.
|
||||||
|
//
|
||||||
|
// The buffer *may* contain less macro strings than the maximum.
|
||||||
|
// This allows a higher maximum number of macros without requiring that
|
||||||
|
// number of nulls to be in the buffer.
|
||||||
|
// Note: dynamic_keymap_macro_get_count() returns the maximum that *can* be
|
||||||
|
// stored, not the current count of macros in the buffer.
|
||||||
|
|
||||||
uint8_t dynamic_keymap_macro_get_count(void);
|
uint8_t dynamic_keymap_macro_get_count(void);
|
||||||
uint16_t dynamic_keymap_macro_get_buffer_size(void);
|
uint16_t dynamic_keymap_macro_get_buffer_size(void);
|
||||||
|
|
479
quantum/via.c
479
quantum/via.c
|
@ -22,26 +22,6 @@
|
||||||
# error "DYNAMIC_KEYMAP_ENABLE is not enabled"
|
# error "DYNAMIC_KEYMAP_ENABLE is not enabled"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_BACKLIGHT_ENABLE is set
|
|
||||||
// if BACKLIGHT_ENABLE is set, so handling of QMK Backlight values happens here by default.
|
|
||||||
// if VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_BACKLIGHT_ENABLE must be explicitly
|
|
||||||
// set in keyboard-level config.h, so handling of QMK Backlight values happens here
|
|
||||||
#if defined(BACKLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
# define VIA_QMK_BACKLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If VIA_CUSTOM_LIGHTING_ENABLE is not defined, then VIA_QMK_RGBLIGHT_ENABLE is set
|
|
||||||
// if RGBLIGHT_ENABLE is set, so handling of QMK RGBLIGHT values happens here by default.
|
|
||||||
// If VIA_CUSTOM_LIGHTING_ENABLE is defined, then VIA_QMK_RGBLIGHT_ENABLE must be explicitly
|
|
||||||
// set in keyboard-level config.h, so handling of QMK RGBLIGHT values happens here
|
|
||||||
#if defined(RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
# define VIA_QMK_RGBLIGHT_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(RGB_MATRIX_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
# define VIA_QMK_RGB_MATRIX_ENABLE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
#include "via.h"
|
#include "via.h"
|
||||||
|
@ -51,22 +31,8 @@
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
|
||||||
|
|
||||||
// Forward declare some helpers.
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
|
||||||
void via_qmk_backlight_set_value(uint8_t *data);
|
|
||||||
void via_qmk_backlight_get_value(uint8_t *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
|
||||||
void via_qmk_rgblight_set_value(uint8_t *data);
|
|
||||||
void via_qmk_rgblight_get_value(uint8_t *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
# include <lib/lib8tion/lib8tion.h>
|
# include <lib/lib8tion/lib8tion.h>
|
||||||
void via_qmk_rgb_matrix_set_value(uint8_t *data);
|
|
||||||
void via_qmk_rgb_matrix_get_value(uint8_t *data);
|
|
||||||
void eeconfig_update_rgb_matrix(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
// Can be called in an overriding via_init_kb() to test if keyboard level code usage of
|
||||||
|
@ -155,6 +121,34 @@ void via_set_layout_options(uint32_t value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(AUDIO_ENABLE)
|
||||||
|
float via_device_indication_song[][2] = SONG(STARTUP_SOUND);
|
||||||
|
#endif // AUDIO_ENABLE
|
||||||
|
|
||||||
|
// Used by VIA to tell a device to flash LEDs (or do something else) when that
|
||||||
|
// device becomes the active device being configured, on startup or switching
|
||||||
|
// between devices. This function will be called six times, at 200ms interval,
|
||||||
|
// with an incrementing value starting at zero. Since this function is called
|
||||||
|
// an even number of times, it can call a toggle function and leave things in
|
||||||
|
// the original state.
|
||||||
|
__attribute__((weak)) void via_set_device_indication(uint8_t value) {
|
||||||
|
#if defined(BACKLIGHT_ENABLE)
|
||||||
|
backlight_toggle();
|
||||||
|
#endif // BACKLIGHT_ENABLE
|
||||||
|
#if defined(RGBLIGHT_ENABLE)
|
||||||
|
rgblight_toggle_noeeprom();
|
||||||
|
#endif // RGBLIGHT_ENABLE
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
rgb_matrix_toggle_noeeprom();
|
||||||
|
#endif // RGB_MATRIX_ENABLE
|
||||||
|
#if defined(AUDIO_ENABLE)
|
||||||
|
if (value == 0) {
|
||||||
|
wait_ms(10);
|
||||||
|
PLAY_SONG(via_device_indication_song);
|
||||||
|
}
|
||||||
|
#endif // AUDIO_ENABLE
|
||||||
|
}
|
||||||
|
|
||||||
// Called by QMK core to process VIA-specific keycodes.
|
// Called by QMK core to process VIA-specific keycodes.
|
||||||
bool process_record_via(uint16_t keycode, keyrecord_t *record) {
|
bool process_record_via(uint16_t keycode, keyrecord_t *record) {
|
||||||
// Handle macros
|
// Handle macros
|
||||||
|
@ -194,24 +188,96 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard level code can override this to handle custom messages from VIA.
|
//
|
||||||
// See raw_hid_receive() implementation.
|
// via_custom_value_command() has the default handling of custom values for Core modules.
|
||||||
|
// If a keyboard is using the default Core modules, it does not need to be overridden,
|
||||||
|
// the VIA keyboard definition will have matching channel/IDs.
|
||||||
|
//
|
||||||
|
// If a keyboard has some extra custom values, then via_custom_value_command_kb() can be
|
||||||
|
// overridden to handle the extra custom values, leaving via_custom_value_command() to
|
||||||
|
// handle the custom values for Core modules.
|
||||||
|
//
|
||||||
|
// If a keyboard has custom values and code that are overlapping with Core modules,
|
||||||
|
// then via_custom_value_command() can be overridden and call the same functions
|
||||||
|
// as the default implementation, or do whatever else is required.
|
||||||
|
//
|
||||||
// DO NOT call raw_hid_send() in the override function.
|
// DO NOT call raw_hid_send() in the override function.
|
||||||
__attribute__((weak)) void raw_hid_receive_kb(uint8_t *data, uint8_t length) {
|
//
|
||||||
|
|
||||||
|
// This is the default handler for "extra" custom values, i.e. keyboard-specific custom values
|
||||||
|
// that are not handled by via_custom_value_command().
|
||||||
|
__attribute__((weak)) void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
uint8_t *command_id = &(data[0]);
|
uint8_t *command_id = &(data[0]);
|
||||||
*command_id = id_unhandled;
|
// Return the unhandled state
|
||||||
|
*command_id = id_unhandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// VIA handles received HID messages first, and will route to
|
// This is the default handler for custom value commands.
|
||||||
// raw_hid_receive_kb() for command IDs that are not handled here.
|
// It routes commands with channel IDs to command handlers as such:
|
||||||
// This gives the keyboard code level the ability to handle the command
|
|
||||||
// specifically.
|
|
||||||
//
|
//
|
||||||
// raw_hid_send() is called at the end, with the same buffer, which was
|
// id_qmk_backlight_channel -> via_qmk_backlight_command()
|
||||||
// possibly modified with returned values.
|
// id_qmk_rgblight_channel -> via_qmk_rgblight_command()
|
||||||
|
// id_qmk_rgb_matrix_channel -> via_qmk_rgb_matrix_command()
|
||||||
|
// id_qmk_audio_channel -> via_qmk_audio_command()
|
||||||
|
//
|
||||||
|
__attribute__((weak)) void via_custom_value_command(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
|
uint8_t *channel_id = &(data[1]);
|
||||||
|
|
||||||
|
#if defined(BACKLIGHT_ENABLE)
|
||||||
|
if (*channel_id == id_qmk_backlight_channel) {
|
||||||
|
via_qmk_backlight_command(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // BACKLIGHT_ENABLE
|
||||||
|
|
||||||
|
#if defined(RGBLIGHT_ENABLE)
|
||||||
|
if (*channel_id == id_qmk_rgblight_channel) {
|
||||||
|
via_qmk_rgblight_command(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // RGBLIGHT_ENABLE
|
||||||
|
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
if (*channel_id == id_qmk_rgb_matrix_channel) {
|
||||||
|
via_qmk_rgb_matrix_command(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // RGBLIGHT_ENABLE
|
||||||
|
|
||||||
|
#if defined(AUDIO_ENABLE)
|
||||||
|
if (*channel_id == id_qmk_audio_channel) {
|
||||||
|
via_qmk_audio_command(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif // AUDIO_ENABLE
|
||||||
|
|
||||||
|
(void)channel_id; // force use of variable
|
||||||
|
|
||||||
|
// If we haven't returned before here, then let the keyboard level code
|
||||||
|
// handle this, if it is overridden, otherwise by default, this will
|
||||||
|
// return the unhandled state.
|
||||||
|
via_custom_value_command_kb(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keyboard level code can override this, but shouldn't need to.
|
||||||
|
// Controlling custom features should be done by overriding
|
||||||
|
// via_custom_value_command_kb() instead.
|
||||||
|
__attribute__((weak)) bool via_command_kb(uint8_t *data, uint8_t length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
uint8_t *command_id = &(data[0]);
|
uint8_t *command_id = &(data[0]);
|
||||||
uint8_t *command_data = &(data[1]);
|
uint8_t *command_data = &(data[1]);
|
||||||
|
|
||||||
|
// If via_command_kb() returns true, the command was fully
|
||||||
|
// handled, including calling raw_hid_send()
|
||||||
|
if (via_command_kb(data, length)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (*command_id) {
|
switch (*command_id) {
|
||||||
case id_get_protocol_version: {
|
case id_get_protocol_version: {
|
||||||
command_data[0] = VIA_PROTOCOL_VERSION >> 8;
|
command_data[0] = VIA_PROTOCOL_VERSION >> 8;
|
||||||
|
@ -237,7 +303,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_switch_matrix_state: {
|
case id_switch_matrix_state: {
|
||||||
#if ((MATRIX_COLS / 8 + 1) * MATRIX_ROWS <= 28)
|
// Round up to the nearest number of bytes required to hold row state.
|
||||||
|
// Multiply by number of rows to get the required size in bytes.
|
||||||
|
// Guard against this being too big for the HID message.
|
||||||
|
#if (((MATRIX_COLS + 7) / 8) * MATRIX_ROWS <= 28)
|
||||||
uint8_t i = 1;
|
uint8_t i = 1;
|
||||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||||
matrix_row_t value = matrix_get_row(row);
|
matrix_row_t value = matrix_get_row(row);
|
||||||
|
@ -255,8 +324,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case id_firmware_version: {
|
||||||
|
uint32_t value = VIA_FIRMWARE_VERSION;
|
||||||
|
command_data[1] = (value >> 24) & 0xFF;
|
||||||
|
command_data[2] = (value >> 16) & 0xFF;
|
||||||
|
command_data[3] = (value >> 8) & 0xFF;
|
||||||
|
command_data[4] = value & 0xFF;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
raw_hid_receive_kb(data, length);
|
// The value ID is not known
|
||||||
|
// Return the unhandled state
|
||||||
|
*command_id = id_unhandled;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,8 +348,15 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
via_set_layout_options(value);
|
via_set_layout_options(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case id_device_indication: {
|
||||||
|
uint8_t value = command_data[1];
|
||||||
|
via_set_device_indication(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
raw_hid_receive_kb(data, length);
|
// The value ID is not known
|
||||||
|
// Return the unhandled state
|
||||||
|
*command_id = id_unhandled;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,61 +376,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
dynamic_keymap_reset();
|
dynamic_keymap_reset();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_lighting_set_value: {
|
case id_custom_set_value:
|
||||||
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
case id_custom_get_value:
|
||||||
via_qmk_backlight_set_value(command_data);
|
case id_custom_save: {
|
||||||
#endif
|
via_custom_value_command(data, length);
|
||||||
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
|
||||||
via_qmk_rgblight_set_value(command_data);
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
via_qmk_rgb_matrix_set_value(command_data);
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
raw_hid_receive_kb(data, length);
|
|
||||||
#endif
|
|
||||||
#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
// Return the unhandled state
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_lighting_get_value: {
|
|
||||||
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
|
||||||
via_qmk_backlight_get_value(command_data);
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
|
||||||
via_qmk_rgblight_get_value(command_data);
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
via_qmk_rgb_matrix_get_value(command_data);
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
raw_hid_receive_kb(data, length);
|
|
||||||
#endif
|
|
||||||
#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
// Return the unhandled state
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case id_lighting_save: {
|
|
||||||
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
|
||||||
eeconfig_update_backlight_current();
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
|
||||||
eeconfig_update_rgblight_current();
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
eeconfig_update_rgb_matrix();
|
|
||||||
#endif
|
|
||||||
#if defined(VIA_CUSTOM_LIGHTING_ENABLE)
|
|
||||||
raw_hid_receive_kb(data, length);
|
|
||||||
#endif
|
|
||||||
#if !defined(VIA_QMK_BACKLIGHT_ENABLE) && !defined(VIA_QMK_RGBLIGHT_ENABLE) && !defined(VIA_CUSTOM_LIGHTING_ENABLE) && !defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
|
||||||
// Return the unhandled state
|
|
||||||
*command_id = id_unhandled;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef VIA_EEPROM_ALLOW_RESET
|
#ifdef VIA_EEPROM_ALLOW_RESET
|
||||||
|
@ -421,13 +456,39 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
|
||||||
raw_hid_send(data, length);
|
raw_hid_send(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
#if defined(BACKLIGHT_ENABLE)
|
||||||
|
|
||||||
|
void via_qmk_backlight_command(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
|
uint8_t *command_id = &(data[0]);
|
||||||
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
|
|
||||||
|
switch (*command_id) {
|
||||||
|
case id_custom_set_value: {
|
||||||
|
via_qmk_backlight_set_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value: {
|
||||||
|
via_qmk_backlight_get_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save: {
|
||||||
|
via_qmk_backlight_save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# if BACKLIGHT_LEVELS == 0
|
# if BACKLIGHT_LEVELS == 0
|
||||||
# error BACKLIGHT_LEVELS == 0
|
# error BACKLIGHT_LEVELS == 0
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
void via_qmk_backlight_get_value(uint8_t *data) {
|
void via_qmk_backlight_get_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
|
@ -448,6 +509,7 @@ void via_qmk_backlight_get_value(uint8_t *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void via_qmk_backlight_set_value(uint8_t *data) {
|
void via_qmk_backlight_set_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
|
@ -469,14 +531,44 @@ void via_qmk_backlight_set_value(uint8_t *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(VIA_QMK_BACKLIGHT_ENABLE)
|
void via_qmk_backlight_save(void) {
|
||||||
|
eeconfig_update_backlight_current();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
#endif // BACKLIGHT_ENABLE
|
||||||
|
|
||||||
|
#if defined(RGBLIGHT_ENABLE)
|
||||||
# ifndef RGBLIGHT_LIMIT_VAL
|
# ifndef RGBLIGHT_LIMIT_VAL
|
||||||
# define RGBLIGHT_LIMIT_VAL 255
|
# define RGBLIGHT_LIMIT_VAL 255
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
void via_qmk_rgblight_command(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
|
uint8_t *command_id = &(data[0]);
|
||||||
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
|
|
||||||
|
switch (*command_id) {
|
||||||
|
case id_custom_set_value: {
|
||||||
|
via_qmk_rgblight_set_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value: {
|
||||||
|
via_qmk_rgblight_get_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save: {
|
||||||
|
via_qmk_rgblight_save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void via_qmk_rgblight_get_value(uint8_t *data) {
|
void via_qmk_rgblight_get_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
|
@ -485,7 +577,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_qmk_rgblight_effect: {
|
case id_qmk_rgblight_effect: {
|
||||||
value_data[0] = rgblight_get_mode();
|
value_data[0] = rgblight_is_enabled() ? rgblight_get_mode() : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_qmk_rgblight_effect_speed: {
|
case id_qmk_rgblight_effect_speed: {
|
||||||
|
@ -501,6 +593,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void via_qmk_rgblight_set_value(uint8_t *data) {
|
void via_qmk_rgblight_set_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
|
@ -509,11 +602,11 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case id_qmk_rgblight_effect: {
|
case id_qmk_rgblight_effect: {
|
||||||
rgblight_mode_noeeprom(value_data[0]);
|
|
||||||
if (value_data[0] == 0) {
|
if (value_data[0] == 0) {
|
||||||
rgblight_disable_noeeprom();
|
rgblight_disable_noeeprom();
|
||||||
} else {
|
} else {
|
||||||
rgblight_enable_noeeprom();
|
rgblight_enable_noeeprom();
|
||||||
|
rgblight_mode_noeeprom(value_data[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -528,92 +621,168 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(VIA_QMK_RGBLIGHT_ENABLE)
|
void via_qmk_rgblight_save(void) {
|
||||||
|
eeconfig_update_rgblight_current();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
#endif // QMK_RGBLIGHT_ENABLE
|
||||||
|
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
|
||||||
# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
|
# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
|
||||||
# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
|
# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
|
||||||
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
|
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// VIA supports only 4 discrete values for effect speed; map these to some
|
void via_qmk_rgb_matrix_command(uint8_t *data, uint8_t length) {
|
||||||
// useful speed values for RGB Matrix.
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
enum speed_values {
|
uint8_t *command_id = &(data[0]);
|
||||||
RGBLIGHT_SPEED_0 = UINT8_MAX / 16, // not 0 to avoid really slow effects
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
RGBLIGHT_SPEED_1 = UINT8_MAX / 4,
|
|
||||||
RGBLIGHT_SPEED_2 = UINT8_MAX / 2, // matches the default value
|
|
||||||
RGBLIGHT_SPEED_3 = UINT8_MAX / 4 * 3, // UINT8_MAX is really fast
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint8_t speed_from_rgblight(uint8_t rgblight_speed) {
|
switch (*command_id) {
|
||||||
switch (rgblight_speed) {
|
case id_custom_set_value: {
|
||||||
case 0:
|
via_qmk_rgb_matrix_set_value(value_id_and_data);
|
||||||
return RGBLIGHT_SPEED_0;
|
break;
|
||||||
case 1:
|
}
|
||||||
return RGBLIGHT_SPEED_1;
|
case id_custom_get_value: {
|
||||||
case 2:
|
via_qmk_rgb_matrix_get_value(value_id_and_data);
|
||||||
default:
|
break;
|
||||||
return RGBLIGHT_SPEED_2;
|
}
|
||||||
case 3:
|
case id_custom_save: {
|
||||||
return RGBLIGHT_SPEED_3;
|
via_qmk_rgb_matrix_save();
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
static uint8_t speed_to_rgblight(uint8_t rgb_matrix_speed) {
|
*command_id = id_unhandled;
|
||||||
if (rgb_matrix_speed < ((RGBLIGHT_SPEED_0 + RGBLIGHT_SPEED_1) / 2)) {
|
break;
|
||||||
return 0;
|
}
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_1 + RGBLIGHT_SPEED_2) / 2)) {
|
|
||||||
return 1;
|
|
||||||
} else if (rgb_matrix_speed < ((RGBLIGHT_SPEED_2 + RGBLIGHT_SPEED_3) / 2)) {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
return 3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void via_qmk_rgb_matrix_get_value(uint8_t *data) {
|
void via_qmk_rgb_matrix_get_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
|
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
case id_qmk_rgblight_brightness:
|
case id_qmk_rgb_matrix_brightness: {
|
||||||
value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_effect:
|
}
|
||||||
value_data[0] = rgb_matrix_get_mode();
|
case id_qmk_rgb_matrix_effect: {
|
||||||
|
value_data[0] = rgb_matrix_is_enabled() ? rgb_matrix_get_mode() : 0;
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_effect_speed:
|
}
|
||||||
value_data[0] = speed_to_rgblight(rgb_matrix_get_speed());
|
case id_qmk_rgb_matrix_effect_speed: {
|
||||||
|
value_data[0] = rgb_matrix_get_speed();
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_color:
|
}
|
||||||
|
case id_qmk_rgb_matrix_color: {
|
||||||
value_data[0] = rgb_matrix_get_hue();
|
value_data[0] = rgb_matrix_get_hue();
|
||||||
value_data[1] = rgb_matrix_get_sat();
|
value_data[1] = rgb_matrix_get_sat();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void via_qmk_rgb_matrix_set_value(uint8_t *data) {
|
void via_qmk_rgb_matrix_set_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
uint8_t *value_id = &(data[0]);
|
uint8_t *value_id = &(data[0]);
|
||||||
uint8_t *value_data = &(data[1]);
|
uint8_t *value_data = &(data[1]);
|
||||||
switch (*value_id) {
|
switch (*value_id) {
|
||||||
case id_qmk_rgblight_brightness:
|
case id_qmk_rgb_matrix_brightness: {
|
||||||
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS));
|
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), scale8(value_data[0], RGB_MATRIX_MAXIMUM_BRIGHTNESS));
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_effect:
|
}
|
||||||
rgb_matrix_mode_noeeprom(value_data[0]);
|
case id_qmk_rgb_matrix_effect: {
|
||||||
if (value_data[0] == 0) {
|
if (value_data[0] == 0) {
|
||||||
rgb_matrix_disable_noeeprom();
|
rgb_matrix_disable_noeeprom();
|
||||||
} else {
|
} else {
|
||||||
rgb_matrix_enable_noeeprom();
|
rgb_matrix_enable_noeeprom();
|
||||||
|
rgb_matrix_mode_noeeprom(value_data[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_effect_speed:
|
}
|
||||||
rgb_matrix_set_speed_noeeprom(speed_from_rgblight(value_data[0]));
|
case id_qmk_rgb_matrix_effect_speed: {
|
||||||
|
rgblight_set_speed_noeeprom(value_data[0]);
|
||||||
break;
|
break;
|
||||||
case id_qmk_rgblight_color:
|
}
|
||||||
rgb_matrix_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val());
|
case id_qmk_rgb_matrix_color: {
|
||||||
|
rgblight_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val());
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(VIA_QMK_RGB_MATRIX_ENABLE)
|
void via_qmk_rgb_matrix_save(void) {
|
||||||
|
eeconfig_update_rgb_matrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // RGB_MATRIX_ENABLE
|
||||||
|
|
||||||
|
#if defined(AUDIO_ENABLE)
|
||||||
|
|
||||||
|
extern audio_config_t audio_config;
|
||||||
|
|
||||||
|
void via_qmk_audio_command(uint8_t *data, uint8_t length) {
|
||||||
|
// data = [ command_id, channel_id, value_id, value_data ]
|
||||||
|
uint8_t *command_id = &(data[0]);
|
||||||
|
uint8_t *value_id_and_data = &(data[2]);
|
||||||
|
|
||||||
|
switch (*command_id) {
|
||||||
|
case id_custom_set_value: {
|
||||||
|
via_qmk_audio_set_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_get_value: {
|
||||||
|
via_qmk_audio_get_value(value_id_and_data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_custom_save: {
|
||||||
|
via_qmk_audio_save();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
*command_id = id_unhandled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void via_qmk_audio_get_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
|
uint8_t *value_id = &(data[0]);
|
||||||
|
uint8_t *value_data = &(data[1]);
|
||||||
|
switch (*value_id) {
|
||||||
|
case id_qmk_audio_enable: {
|
||||||
|
value_data[0] = audio_config.enable ? 1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_qmk_audio_clicky_enable: {
|
||||||
|
value_data[0] = audio_config.clicky_enable ? 1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void via_qmk_audio_set_value(uint8_t *data) {
|
||||||
|
// data = [ value_id, value_data ]
|
||||||
|
uint8_t *value_id = &(data[0]);
|
||||||
|
uint8_t *value_data = &(data[1]);
|
||||||
|
switch (*value_id) {
|
||||||
|
case id_qmk_audio_enable: {
|
||||||
|
audio_config.enable = value_data[0] ? 1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case id_qmk_audio_clicky_enable: {
|
||||||
|
audio_config.clicky_enable = value_data[0] ? 1 : 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void via_qmk_audio_save(void) {
|
||||||
|
eeconfig_update_audio(audio_config.raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QMK_AUDIO_ENABLE
|
||||||
|
|
|
@ -60,6 +60,16 @@
|
||||||
// so VIA Configurator can detect compatible firmware.
|
// so VIA Configurator can detect compatible firmware.
|
||||||
#define VIA_PROTOCOL_VERSION 0x000B
|
#define VIA_PROTOCOL_VERSION 0x000B
|
||||||
|
|
||||||
|
// This is a version number for the firmware for the keyboard.
|
||||||
|
// It can be used to ensure the VIA keyboard definition and the firmware
|
||||||
|
// have the same version, especially if there are changes to custom values.
|
||||||
|
// Define this in config.h to override and bump this number.
|
||||||
|
// This is *not* required if the keyboard is only using basic functionality
|
||||||
|
// and not using custom values for lighting, rotary encoders, etc.
|
||||||
|
#ifndef VIA_FIRMWARE_VERSION
|
||||||
|
# define VIA_FIRMWARE_VERSION 0x00000000
|
||||||
|
#endif
|
||||||
|
|
||||||
enum via_command_id {
|
enum via_command_id {
|
||||||
id_get_protocol_version = 0x01, // always 0x01
|
id_get_protocol_version = 0x01, // always 0x01
|
||||||
id_get_keyboard_value = 0x02,
|
id_get_keyboard_value = 0x02,
|
||||||
|
@ -67,9 +77,9 @@ enum via_command_id {
|
||||||
id_dynamic_keymap_get_keycode = 0x04,
|
id_dynamic_keymap_get_keycode = 0x04,
|
||||||
id_dynamic_keymap_set_keycode = 0x05,
|
id_dynamic_keymap_set_keycode = 0x05,
|
||||||
id_dynamic_keymap_reset = 0x06,
|
id_dynamic_keymap_reset = 0x06,
|
||||||
id_lighting_set_value = 0x07,
|
id_custom_set_value = 0x07,
|
||||||
id_lighting_get_value = 0x08,
|
id_custom_get_value = 0x08,
|
||||||
id_lighting_save = 0x09,
|
id_custom_save = 0x09,
|
||||||
id_eeprom_reset = 0x0A,
|
id_eeprom_reset = 0x0A,
|
||||||
id_bootloader_jump = 0x0B,
|
id_bootloader_jump = 0x0B,
|
||||||
id_dynamic_keymap_macro_get_count = 0x0C,
|
id_dynamic_keymap_macro_get_count = 0x0C,
|
||||||
|
@ -86,21 +96,43 @@ enum via_command_id {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum via_keyboard_value_id {
|
enum via_keyboard_value_id {
|
||||||
id_uptime = 0x01, //
|
id_uptime = 0x01,
|
||||||
id_layout_options = 0x02,
|
id_layout_options = 0x02,
|
||||||
id_switch_matrix_state = 0x03
|
id_switch_matrix_state = 0x03,
|
||||||
|
id_firmware_version = 0x04,
|
||||||
|
id_device_indication = 0x05,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum via_lighting_value {
|
enum via_channel_id {
|
||||||
// QMK BACKLIGHT
|
id_custom_channel = 0,
|
||||||
id_qmk_backlight_brightness = 0x09,
|
id_qmk_backlight_channel = 1,
|
||||||
id_qmk_backlight_effect = 0x0A,
|
id_qmk_rgblight_channel = 2,
|
||||||
|
id_qmk_rgb_matrix_channel = 3,
|
||||||
|
id_qmk_audio_channel = 4,
|
||||||
|
};
|
||||||
|
|
||||||
// QMK RGBLIGHT
|
enum via_qmk_backlight_value {
|
||||||
id_qmk_rgblight_brightness = 0x80,
|
id_qmk_backlight_brightness = 1,
|
||||||
id_qmk_rgblight_effect = 0x81,
|
id_qmk_backlight_effect = 2,
|
||||||
id_qmk_rgblight_effect_speed = 0x82,
|
};
|
||||||
id_qmk_rgblight_color = 0x83,
|
|
||||||
|
enum via_qmk_rgblight_value {
|
||||||
|
id_qmk_rgblight_brightness = 1,
|
||||||
|
id_qmk_rgblight_effect = 2,
|
||||||
|
id_qmk_rgblight_effect_speed = 3,
|
||||||
|
id_qmk_rgblight_color = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum via_qmk_rgb_matrix_value {
|
||||||
|
id_qmk_rgb_matrix_brightness = 1,
|
||||||
|
id_qmk_rgb_matrix_effect = 2,
|
||||||
|
id_qmk_rgb_matrix_effect_speed = 3,
|
||||||
|
id_qmk_rgb_matrix_color = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum via_qmk_audio_value {
|
||||||
|
id_qmk_audio_enable = 1,
|
||||||
|
id_qmk_audio_clicky_enable = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum via_keycodes {
|
enum via_keycodes {
|
||||||
|
@ -160,5 +192,39 @@ uint32_t via_get_layout_options(void);
|
||||||
void via_set_layout_options(uint32_t value);
|
void via_set_layout_options(uint32_t value);
|
||||||
void via_set_layout_options_kb(uint32_t value);
|
void via_set_layout_options_kb(uint32_t value);
|
||||||
|
|
||||||
|
// Used by VIA to tell a device to flash LEDs (or do something else) when that
|
||||||
|
// device becomes the active device being configured, on startup or switching
|
||||||
|
// between devices.
|
||||||
|
void via_set_device_indication(uint8_t value);
|
||||||
|
|
||||||
// Called by QMK core to process VIA-specific keycodes.
|
// Called by QMK core to process VIA-specific keycodes.
|
||||||
bool process_record_via(uint16_t keycode, keyrecord_t *record);
|
bool process_record_via(uint16_t keycode, keyrecord_t *record);
|
||||||
|
|
||||||
|
// These are made external so that keyboard level custom value handlers can use them.
|
||||||
|
#if defined(BACKLIGHT_ENABLE)
|
||||||
|
void via_qmk_backlight_command(uint8_t *data, uint8_t length);
|
||||||
|
void via_qmk_backlight_set_value(uint8_t *data);
|
||||||
|
void via_qmk_backlight_get_value(uint8_t *data);
|
||||||
|
void via_qmk_backlight_save(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(RGBLIGHT_ENABLE)
|
||||||
|
void via_qmk_rgblight_command(uint8_t *data, uint8_t length);
|
||||||
|
void via_qmk_rgblight_set_value(uint8_t *data);
|
||||||
|
void via_qmk_rgblight_get_value(uint8_t *data);
|
||||||
|
void via_qmk_rgblight_save(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(RGB_MATRIX_ENABLE)
|
||||||
|
void via_qmk_rgb_matrix_command(uint8_t *data, uint8_t length);
|
||||||
|
void via_qmk_rgb_matrix_set_value(uint8_t *data);
|
||||||
|
void via_qmk_rgb_matrix_get_value(uint8_t *data);
|
||||||
|
void via_qmk_rgb_matrix_save(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(AUDIO_ENABLE)
|
||||||
|
void via_qmk_audio_command(uint8_t *data, uint8_t length);
|
||||||
|
void via_qmk_audio_set_value(uint8_t *data);
|
||||||
|
void via_qmk_audio_get_value(uint8_t *data);
|
||||||
|
void via_qmk_audio_save(void);
|
||||||
|
#endif
|
Loading…
Reference in New Issue