summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilba <wilba@wilba.tech>2022-11-10 07:46:44 +1100
committerGitHub <noreply@github.com>2022-11-10 07:46:44 +1100
commitbc6f8dc8b0822e5e03893eacffa42a7badb4c2fa (patch)
treeb1e8a219803f30b7347e479734a5c6e7352a5f30
parent575b0e33fa47034f5cfaf6f7cd98570268efa0a2 (diff)
VIA V3 - The Custom UI Update (#18222)
-rw-r--r--keyboards/cannonkeys/satisfaction75/config.h3
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c211
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.h4
-rw-r--r--keyboards/durgod/dgk6x/config.h3
-rw-r--r--keyboards/frooastboard/walnut/keymaps/via/config.h1
-rw-r--r--keyboards/frooastboard/walnut/keymaps/via/keymap.c113
-rw-r--r--keyboards/geekboards/macropad_v2/keymaps/via/config.h2
-rw-r--r--keyboards/horrortroll/handwired_k552/keymaps/via/config.h4
-rw-r--r--keyboards/hs60/v2/ansi/config.h3
-rw-r--r--keyboards/hs60/v2/hhkb/config.h3
-rw-r--r--keyboards/hs60/v2/iso/config.h3
-rw-r--r--keyboards/keebio/iris/keymaps/via/rules.mk1
-rwxr-xr-xkeyboards/keebwerk/mega/ansi/config.h3
-rw-r--r--keyboards/keychron/q1/config.h10
-rw-r--r--keyboards/keychron/q2/config.h5
-rw-r--r--keyboards/mechlovin/infinity875/keymaps/via/config.h24
-rw-r--r--keyboards/ml/gas75/keymaps/via/config.h23
-rw-r--r--keyboards/monstargear/xo87/rgb/keymaps/via/config.h17
-rw-r--r--keyboards/monstargear/xo87/solderable/keymaps/via/config.h18
-rw-r--r--keyboards/mss_studio/m63_rgb/keymaps/via/config.h4
-rwxr-xr-xkeyboards/novelkeys/nk65/config.h3
-rwxr-xr-xkeyboards/novelkeys/nk87/config.h3
-rw-r--r--keyboards/rgbkb/mun/keymaps/via/config.h2
-rw-r--r--keyboards/rgbkb/sol3/keymaps/kageurufu/config.h2
-rw-r--r--keyboards/rgbkb/sol3/keymaps/via/config.h2
-rwxr-xr-xkeyboards/spaceholdings/nebula12/config.h4
-rwxr-xr-xkeyboards/spaceholdings/nebula68/config.h4
-rwxr-xr-xkeyboards/spaceholdings/nebula68b/config.h3
-rwxr-xr-xkeyboards/spaceholdings/nebula68b/nebula68b.c69
-rw-r--r--keyboards/tkc/portico/config.h2
-rw-r--r--keyboards/tkc/portico68v2/keymaps/via/config.h19
-rw-r--r--keyboards/tkc/portico68v2/keymaps/via/keymap.c72
-rw-r--r--keyboards/tkc/portico75/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_kara/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_koyu/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m10_c/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m50_a/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m60_a/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m65_b/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m65_bx/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m6_a/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_m6_b/config.h3
-rw-r--r--keyboards/wilba_tech/rama_works_u80_a/config.h3
-rw-r--r--keyboards/wilba_tech/via_test.c133
-rw-r--r--keyboards/wilba_tech/wt60_a/config.h3
-rw-r--r--keyboards/wilba_tech/wt60_b/config.h3
-rw-r--r--keyboards/wilba_tech/wt60_bx/config.h3
-rw-r--r--keyboards/wilba_tech/wt60_c/config.h3
-rw-r--r--keyboards/wilba_tech/wt60_xt/wt60_xt.c7
-rw-r--r--keyboards/wilba_tech/wt65_a/config.h3
-rw-r--r--keyboards/wilba_tech/wt65_b/config.h3
-rw-r--r--keyboards/wilba_tech/wt75_a/config.h3
-rw-r--r--keyboards/wilba_tech/wt75_b/config.h3
-rw-r--r--keyboards/wilba_tech/wt75_c/config.h3
-rw-r--r--keyboards/wilba_tech/wt80_a/config.h3
-rw-r--r--keyboards/wilba_tech/wt_main.c61
-rw-r--r--keyboards/wilba_tech/zeal60/config.h3
-rw-r--r--keyboards/wilba_tech/zeal65/config.h3
-rw-r--r--keyboards/winry/winry315/keymaps/via/config.h9
-rw-r--r--keyboards/winry/winry315/winry315.c54
-rw-r--r--keyboards/xelus/dawn60/rev1/config.h3
-rw-r--r--keyboards/xelus/la_plus/keymaps/via/config.h20
-rw-r--r--keyboards/xelus/pachi/rgb/keymaps/via/config.h3
-rw-r--r--keyboards/xelus/valor/rev2/keymaps/via/config.h3
-rw-r--r--quantum/dynamic_keymap.c56
-rw-r--r--quantum/dynamic_keymap.h6
-rw-r--r--quantum/via.c479
-rw-r--r--quantum/via.h94
68 files changed, 751 insertions, 886 deletions
diff --git a/keyboards/cannonkeys/satisfaction75/config.h b/keyboards/cannonkeys/satisfaction75/config.h
index 615ad1d056..a650a362c0 100644
--- a/keyboards/cannonkeys/satisfaction75/config.h
+++ b/keyboards/cannonkeys/satisfaction75/config.h
@@ -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)
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 21
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
-
/*
* Feature disable options
* These options are also useful to firmware size reduction.
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.c b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
index 3cd52d5f23..13b44b85db 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.c
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.c
@@ -102,113 +102,142 @@ void backlight_set_value( uint8_t *data )
}
}
-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_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]){
+void custom_set_value(uint8_t *data) {
+ uint8_t *value_id = &(data[0]);
+ uint8_t *value_data = &(data[1]);
+
+ switch ( *value_id ) {
case id_oled_default_mode:
{
- eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, command_data[1]);
- break;
+ eeprom_update_byte((uint8_t*)EEPROM_DEFAULT_OLED, value_data[0]);
+ break;
}
case id_oled_mode:
{
- oled_mode = command_data[1];
- oled_request_wakeup();
- break;
+ oled_mode = value_data[0];
+ oled_request_wakeup();
+ break;
}
case id_encoder_modes:
{
- enabled_encoder_modes = command_data[1];
- eeprom_update_byte((uint8_t*)EEPROM_ENABLED_ENCODER_MODES, enabled_encoder_modes);
- break;
+ uint8_t index = value_data[0];
+ uint8_t enable = value_data[1];
+ 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:
{
- uint8_t custom_encoder_idx = command_data[1];
- uint8_t encoder_behavior = command_data[2];
- uint16_t keycode = (command_data[3] << 8) | command_data[4];
- set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode);
- break;
+ uint8_t custom_encoder_idx = value_data[0];
+ uint8_t encoder_behavior = value_data[1];
+ uint16_t keycode = (value_data[2] << 8) | value_data[3];
+ set_custom_encoder_config(custom_encoder_idx, encoder_behavior, keycode);
+ 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;
- break;
+ uint8_t default_oled = eeprom_read_byte((uint8_t*)EEPROM_DEFAULT_OLED);
+ 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);
- break;
- }
- case id_lighting_get_value:
- {
- backlight_get_value(command_data);
- break;
- }
- case id_lighting_save:
- {
- backlight_config_save();
- break;
}
- default:
- {
- // Unhandled message.
- *command_id = id_unhandled;
- break;
+}
+
+// TODO
+// 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;
}
- }
- // DO NOT call raw_hid_send(data,length) here, let caller do this
+
+ *command_id = id_unhandled;
+
+ // DO NOT call raw_hid_send(data,length) here, let caller do this
}
#endif
diff --git a/keyboards/cannonkeys/satisfaction75/satisfaction75.h b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
index ea71345a38..ec852eef6c 100644
--- a/keyboards/cannonkeys/satisfaction75/satisfaction75.h
+++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.h
@@ -30,8 +30,8 @@ enum my_keycodes {
OLED_TOGG
};
-enum s75_keyboard_value_id {
- id_encoder_modes = 0x80,
+enum s75_custom_value_id {
+ id_encoder_modes = 1,
id_oled_default_mode,
id_encoder_custom,
id_oled_mode
diff --git a/keyboards/durgod/dgk6x/config.h b/keyboards/durgod/dgk6x/config.h
index 70247fd745..fe4ca58072 100644
--- a/keyboards/durgod/dgk6x/config.h
+++ b/keyboards/durgod/dgk6x/config.h
@@ -130,7 +130,4 @@
# define ENABLE_RGB_MATRIX_SOLID_SPLASH
# 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 */
diff --git a/keyboards/frooastboard/walnut/keymaps/via/config.h b/keyboards/frooastboard/walnut/keymaps/via/config.h
index 0ef255fb51..e1f0fc0db6 100644
--- a/keyboards/frooastboard/walnut/keymaps/via/config.h
+++ b/keyboards/frooastboard/walnut/keymaps/via/config.h
@@ -3,5 +3,4 @@
#pragma once
-#define VIA_CUSTOM_LIGHTING_ENABLE
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
diff --git a/keyboards/frooastboard/walnut/keymaps/via/keymap.c b/keyboards/frooastboard/walnut/keymaps/via/keymap.c
index 84b73e2186..f502205761 100644
--- a/keyboards/frooastboard/walnut/keymaps/via/keymap.c
+++ b/keyboards/frooastboard/walnut/keymaps/via/keymap.c
@@ -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, 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)
-};
-
-#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)
+}; \ No newline at end of file
diff --git a/keyboards/geekboards/macropad_v2/keymaps/via/config.h b/keyboards/geekboards/macropad_v2/keymaps/via/config.h
deleted file mode 100644
index 9d75edbe74..0000000000
--- a/keyboards/geekboards/macropad_v2/keymaps/via/config.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define DYNAMIC_KEYMAP_LAYER_COUNT 4
-#define VIA_QMK_RGBLIGHT_ENABLE
diff --git a/keyboards/horrortroll/handwired_k552/keymaps/via/config.h b/keyboards/horrortroll/handwired_k552/keymaps/via/config.h
index ba3e8e9a03..a36ce468bc 100644
--- a/keyboards/horrortroll/handwired_k552/keymaps/via/config.h
+++ b/keyboards/horrortroll/handwired_k552/keymaps/via/config.h
@@ -17,7 +17,3 @@
#pragma once
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
-
-#ifdef RGB_MATRIX_ENABLE
- #define VIA_QMK_RGBLIGHT_ENABLE
-#endif
diff --git a/keyboards/hs60/v2/ansi/config.h b/keyboards/hs60/v2/ansi/config.h
index 509661db8d..4211e7ce94 100644
--- a/keyboards/hs60/v2/ansi/config.h
+++ b/keyboards/hs60/v2/ansi/config.h
@@ -135,6 +135,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/hs60/v2/hhkb/config.h b/keyboards/hs60/v2/hhkb/config.h
index 46090673db..ac1e9aa012 100644
--- a/keyboards/hs60/v2/hhkb/config.h
+++ b/keyboards/hs60/v2/hhkb/config.h
@@ -135,6 +135,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/hs60/v2/iso/config.h b/keyboards/hs60/v2/iso/config.h
index cf43e3dd94..22e2c3fbfe 100644
--- a/keyboards/hs60/v2/iso/config.h
+++ b/keyboards/hs60/v2/iso/config.h
@@ -133,6 +133,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/keebio/iris/keymaps/via/rules.mk b/keyboards/keebio/iris/keymaps/via/rules.mk
index 1189f4ad19..873ff6cdfc 100644
--- a/keyboards/keebio/iris/keymaps/via/rules.mk
+++ b/keyboards/keebio/iris/keymaps/via/rules.mk
@@ -1,3 +1,4 @@
VIA_ENABLE = yes
LTO_ENABLE = yes
ENCODER_MAP_ENABLE = yes
+CONSOLE_ENABLE = no
diff --git a/keyboards/keebwerk/mega/ansi/config.h b/keyboards/keebwerk/mega/ansi/config.h
index 43bc368925..0322bf3e64 100755
--- a/keyboards/keebwerk/mega/ansi/config.h
+++ b/keyboards/keebwerk/mega/ansi/config.h
@@ -133,6 +133,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/keychron/q1/config.h b/keyboards/keychron/q1/config.h
index cda8799a79..669e9ef7ba 100644
--- a/keyboards/keychron/q1/config.h
+++ b/keyboards/keychron/q1/config.h
@@ -43,11 +43,6 @@
/* Disable RGB lighting when PC is in suspend */
#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
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
@@ -96,8 +91,3 @@
#define ENABLE_RGB_MATRIX_MULTISPLASH
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
-
-/* Allow VIA to edit lighting */
-#ifdef VIA_ENABLE
-#define VIA_QMK_RGBLIGHT_ENABLE
-#endif
diff --git a/keyboards/keychron/q2/config.h b/keyboards/keychron/q2/config.h
index 511cc4f5ac..5961b62929 100644
--- a/keyboards/keychron/q2/config.h
+++ b/keyboards/keychron/q2/config.h
@@ -110,8 +110,3 @@
#define ENABLE_RGB_MATRIX_MULTISPLASH
#define ENABLE_RGB_MATRIX_SOLID_SPLASH
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
-
-/* Allow VIA to edit lighting */
-#ifdef VIA_ENABLE
-# define VIA_QMK_RGBLIGHT_ENABLE
-#endif
diff --git a/keyboards/mechlovin/infinity875/keymaps/via/config.h b/keyboards/mechlovin/infinity875/keymaps/via/config.h
deleted file mode 100644
index 74ee03f3f9..0000000000
--- a/keyboards/mechlovin/infinity875/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/ml/gas75/keymaps/via/config.h b/keyboards/ml/gas75/keymaps/via/config.h
deleted file mode 100644
index 18d8c180ba..0000000000
--- a/keyboards/ml/gas75/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/monstargear/xo87/rgb/keymaps/via/config.h b/keyboards/monstargear/xo87/rgb/keymaps/via/config.h
deleted file mode 100644
index 45b4ab9d22..0000000000
--- a/keyboards/monstargear/xo87/rgb/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/monstargear/xo87/solderable/keymaps/via/config.h b/keyboards/monstargear/xo87/solderable/keymaps/via/config.h
deleted file mode 100644
index 54dda96c49..0000000000
--- a/keyboards/monstargear/xo87/solderable/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/mss_studio/m63_rgb/keymaps/via/config.h b/keyboards/mss_studio/m63_rgb/keymaps/via/config.h
index db20f3b87b..188407396a 100644
--- a/keyboards/mss_studio/m63_rgb/keymaps/via/config.h
+++ b/keyboards/mss_studio/m63_rgb/keymaps/via/config.h
@@ -18,7 +18,3 @@
#pragma once
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
-
-#ifdef RGB_MATRIX_ENABLE
- #define VIA_QMK_RGBLIGHT_ENABLE
-#endif
diff --git a/keyboards/novelkeys/nk65/config.h b/keyboards/novelkeys/nk65/config.h
index 9640704b48..e1597c9da6 100755
--- a/keyboards/novelkeys/nk65/config.h
+++ b/keyboards/novelkeys/nk65/config.h
@@ -134,9 +134,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#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
* both 128kb and 256kb versions of F303.
* Register 0x1FFFF7CC holds the size of the flash memory.
diff --git a/keyboards/novelkeys/nk87/config.h b/keyboards/novelkeys/nk87/config.h
index 0320f35d84..4481f6283f 100755
--- a/keyboards/novelkeys/nk87/config.h
+++ b/keyboards/novelkeys/nk87/config.h
@@ -134,6 +134,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 32
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/rgbkb/mun/keymaps/via/config.h b/keyboards/rgbkb/mun/keymaps/via/config.h
index 01dc6f1c7d..002081a1c8 100644
--- a/keyboards/rgbkb/mun/keymaps/via/config.h
+++ b/keyboards/rgbkb/mun/keymaps/via/config.h
@@ -25,6 +25,4 @@
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
-#define VIA_QMK_RGBLIGHT_ENABLE
-
#define STM32_ONBOARD_EEPROM_SIZE 2048
diff --git a/keyboards/rgbkb/sol3/keymaps/kageurufu/config.h b/keyboards/rgbkb/sol3/keymaps/kageurufu/config.h
index b1a8fce865..b6416d9bf8 100644
--- a/keyboards/rgbkb/sol3/keymaps/kageurufu/config.h
+++ b/keyboards/rgbkb/sol3/keymaps/kageurufu/config.h
@@ -26,7 +26,5 @@
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
-#define VIA_QMK_RGBLIGHT_ENABLE
-
#define STM32_ONBOARD_EEPROM_SIZE 2048
diff --git a/keyboards/rgbkb/sol3/keymaps/via/config.h b/keyboards/rgbkb/sol3/keymaps/via/config.h
index e6aa2bd87b..ff1ff77472 100644
--- a/keyboards/rgbkb/sol3/keymaps/via/config.h
+++ b/keyboards/rgbkb/sol3/keymaps/via/config.h
@@ -26,7 +26,5 @@
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047
-#define VIA_QMK_RGBLIGHT_ENABLE
-
#define STM32_ONBOARD_EEPROM_SIZE 2048
diff --git a/keyboards/spaceholdings/nebula12/config.h b/keyboards/spaceholdings/nebula12/config.h
index 73cc391726..abda9af7af 100755
--- a/keyboards/spaceholdings/nebula12/config.h
+++ b/keyboards/spaceholdings/nebula12/config.h
@@ -174,7 +174,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#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
diff --git a/keyboards/spaceholdings/nebula68/config.h b/keyboards/spaceholdings/nebula68/config.h
index 8bae468783..14a4eedb90 100755
--- a/keyboards/spaceholdings/nebula68/config.h
+++ b/keyboards/spaceholdings/nebula68/config.h
@@ -158,7 +158,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#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
diff --git a/keyboards/spaceholdings/nebula68b/config.h b/keyboards/spaceholdings/nebula68b/config.h
index b95adb0508..30bf59e7dc 100755
--- a/keyboards/spaceholdings/nebula68b/config.h
+++ b/keyboards/spaceholdings/nebula68b/config.h
@@ -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_SOLID_SPLASH
#define ENABLE_RGB_MATRIX_SOLID_MULTISPLASH
-
-// // VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/spaceholdings/nebula68b/nebula68b.c b/keyboards/spaceholdings/nebula68b/nebula68b.c
index 4d4f878c6b..f7b292ded9 100755
--- a/keyboards/spaceholdings/nebula68b/nebula68b.c
+++ b/keyboards/spaceholdings/nebula68b/nebula68b.c
@@ -42,72 +42,3 @@ led_config_t g_led_config = { {
// clang-format on
#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
diff --git a/keyboards/tkc/portico/config.h b/keyboards/tkc/portico/config.h
index a0ad0c1652..3268b3511b 100644
--- a/keyboards/tkc/portico/config.h
+++ b/keyboards/tkc/portico/config.h
@@ -114,6 +114,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
#endif
diff --git a/keyboards/tkc/portico68v2/keymaps/via/config.h b/keyboards/tkc/portico68v2/keymaps/via/config.h
deleted file mode 100644
index 39b11550cf..0000000000
--- a/keyboards/tkc/portico68v2/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/tkc/portico68v2/keymaps/via/keymap.c b/keyboards/tkc/portico68v2/keymaps/via/keymap.c
index 1b3cfa0f99..9ab3d016ca 100644
--- a/keyboards/tkc/portico68v2/keymaps/via/keymap.c
+++ b/keyboards/tkc/portico68v2/keymaps/via/keymap.c
@@ -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;
- }
-}
diff --git a/keyboards/tkc/portico75/config.h b/keyboards/tkc/portico75/config.h
index 36bd7b3ed5..57089653e1 100644
--- a/keyboards/tkc/portico75/config.h
+++ b/keyboards/tkc/portico75/config.h
@@ -161,7 +161,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
# define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-# define VIA_CUSTOM_LIGHTING_ENABLE
#endif
diff --git a/keyboards/wilba_tech/rama_works_kara/config.h b/keyboards/wilba_tech/rama_works_kara/config.h
index 7c9489e922..d713c41bb9 100644
--- a/keyboards/wilba_tech/rama_works_kara/config.h
+++ b/keyboards/wilba_tech/rama_works_kara/config.h
@@ -108,6 +108,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_koyu/config.h b/keyboards/wilba_tech/rama_works_koyu/config.h
index 9b5048d11a..de2d4aafba 100644
--- a/keyboards/wilba_tech/rama_works_koyu/config.h
+++ b/keyboards/wilba_tech/rama_works_koyu/config.h
@@ -109,6 +109,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m10_c/config.h b/keyboards/wilba_tech/rama_works_m10_c/config.h
index 456023d414..9c893ac1b3 100644
--- a/keyboards/wilba_tech/rama_works_m10_c/config.h
+++ b/keyboards/wilba_tech/rama_works_m10_c/config.h
@@ -103,6 +103,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 51
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m50_a/config.h b/keyboards/wilba_tech/rama_works_m50_a/config.h
index 6284a4027a..47d47fae18 100644
--- a/keyboards/wilba_tech/rama_works_m50_a/config.h
+++ b/keyboards/wilba_tech/rama_works_m50_a/config.h
@@ -101,6 +101,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m60_a/config.h b/keyboards/wilba_tech/rama_works_m60_a/config.h
index 22abe6ee60..05f12caaf2 100644
--- a/keyboards/wilba_tech/rama_works_m60_a/config.h
+++ b/keyboards/wilba_tech/rama_works_m60_a/config.h
@@ -108,6 +108,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m65_b/config.h b/keyboards/wilba_tech/rama_works_m65_b/config.h
index 1982b2e8e1..ba99a20f97 100644
--- a/keyboards/wilba_tech/rama_works_m65_b/config.h
+++ b/keyboards/wilba_tech/rama_works_m65_b/config.h
@@ -101,6 +101,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m65_bx/config.h b/keyboards/wilba_tech/rama_works_m65_bx/config.h
index 83c2be2001..7e2a0ce122 100644
--- a/keyboards/wilba_tech/rama_works_m65_bx/config.h
+++ b/keyboards/wilba_tech/rama_works_m65_bx/config.h
@@ -101,6 +101,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m6_a/config.h b/keyboards/wilba_tech/rama_works_m6_a/config.h
index d77613628e..e964bcf21b 100644
--- a/keyboards/wilba_tech/rama_works_m6_a/config.h
+++ b/keyboards/wilba_tech/rama_works_m6_a/config.h
@@ -100,6 +100,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_m6_b/config.h b/keyboards/wilba_tech/rama_works_m6_b/config.h
index d6978c8a16..9f29bcb38a 100644
--- a/keyboards/wilba_tech/rama_works_m6_b/config.h
+++ b/keyboards/wilba_tech/rama_works_m6_b/config.h
@@ -143,6 +143,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 43
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/rama_works_u80_a/config.h b/keyboards/wilba_tech/rama_works_u80_a/config.h
index 4653556190..9cfc23c8f8 100644
--- a/keyboards/wilba_tech/rama_works_u80_a/config.h
+++ b/keyboards/wilba_tech/rama_works_u80_a/config.h
@@ -153,6 +153,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/via_test.c b/keyboards/wilba_tech/via_test.c
new file mode 100644
index 0000000000..6a74df5164
--- /dev/null
+++ b/keyboards/wilba_tech/via_test.c
@@ -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 \ No newline at end of file
diff --git a/keyboards/wilba_tech/wt60_a/config.h b/keyboards/wilba_tech/wt60_a/config.h
index c2b85fee76..c9079bcb83 100644
--- a/keyboards/wilba_tech/wt60_a/config.h
+++ b/keyboards/wilba_tech/wt60_a/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt60_b/config.h b/keyboards/wilba_tech/wt60_b/config.h
index 43a10844da..2ae153b13f 100644
--- a/keyboards/wilba_tech/wt60_b/config.h
+++ b/keyboards/wilba_tech/wt60_b/config.h
@@ -104,6 +104,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt60_bx/config.h b/keyboards/wilba_tech/wt60_bx/config.h
index d26b3a02ba..75d0bfbf42 100644
--- a/keyboards/wilba_tech/wt60_bx/config.h
+++ b/keyboards/wilba_tech/wt60_bx/config.h
@@ -104,6 +104,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt60_c/config.h b/keyboards/wilba_tech/wt60_c/config.h
index 489207d56c..85beba49c7 100644
--- a/keyboards/wilba_tech/wt60_c/config.h
+++ b/keyboards/wilba_tech/wt60_c/config.h
@@ -105,6 +105,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt60_xt/wt60_xt.c b/keyboards/wilba_tech/wt60_xt/wt60_xt.c
index f575b032df..4413140513 100644
--- a/keyboards/wilba_tech/wt60_xt/wt60_xt.c
+++ b/keyboards/wilba_tech/wt60_xt/wt60_xt.c
@@ -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_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
+float tone_device_indication[][2] = SONG(FANTASIE_IMPROMPTU);
#endif
@@ -95,3 +96,9 @@ bool led_update_kb(led_t led_state) {
return true;
}
+
+void via_set_device_indication(uint8_t value) {
+ if ( value == 0 ) {
+ PLAY_SONG(tone_device_indication);
+ }
+} \ No newline at end of file
diff --git a/keyboards/wilba_tech/wt65_a/config.h b/keyboards/wilba_tech/wt65_a/config.h
index 062e2d8564..0d8dd5a0d1 100644
--- a/keyboards/wilba_tech/wt65_a/config.h
+++ b/keyboards/wilba_tech/wt65_a/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt65_b/config.h b/keyboards/wilba_tech/wt65_b/config.h
index 8320daef0a..4bfbcdcb08 100644
--- a/keyboards/wilba_tech/wt65_b/config.h
+++ b/keyboards/wilba_tech/wt65_b/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt75_a/config.h b/keyboards/wilba_tech/wt75_a/config.h
index 415774aa17..627069ca09 100644
--- a/keyboards/wilba_tech/wt75_a/config.h
+++ b/keyboards/wilba_tech/wt75_a/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt75_b/config.h b/keyboards/wilba_tech/wt75_b/config.h
index 98b3d937f9..6d2c9fa17c 100644
--- a/keyboards/wilba_tech/wt75_b/config.h
+++ b/keyboards/wilba_tech/wt75_b/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt75_c/config.h b/keyboards/wilba_tech/wt75_c/config.h
index d8cf5a1a95..fcaa9622d4 100644
--- a/keyboards/wilba_tech/wt75_c/config.h
+++ b/keyboards/wilba_tech/wt75_c/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt80_a/config.h b/keyboards/wilba_tech/wt80_a/config.h
index 2bc81b2fa5..500d4bc797 100644
--- a/keyboards/wilba_tech/wt80_a/config.h
+++ b/keyboards/wilba_tech/wt80_a/config.h
@@ -121,6 +121,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 7
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/wt_main.c b/keyboards/wilba_tech/wt_main.c
index bc1a1d3c87..3f89066a6c 100644
--- a/keyboards/wilba_tech/wt_main.c
+++ b/keyboards/wilba_tech/wt_main.c
@@ -132,36 +132,45 @@ void suspend_wakeup_init_kb(void)
// Moving this to the bottom of this source file is a workaround
// for an intermittent compiler error for Atmel compiler.
#ifdef 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 )
- {
+void via_custom_value_command_kb(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 RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
- case id_lighting_set_value:
- {
- backlight_config_set_value(command_data);
- break;
- }
- case id_lighting_get_value:
- {
- backlight_config_get_value(command_data);
- break;
- }
- case id_lighting_save:
- {
- backlight_config_save();
- break;
- }
-#endif // RGB_BACKLIGHT_ENABLED || MONO_BACKLIGHT_ENABLED
- default:
+ if ( *channel_id == id_custom_channel ) {
+ switch ( *command_id )
{
- // Unhandled message.
- *command_id = id_unhandled;
- *command_data = *command_data; // force use of variable
- break;
+ case id_custom_set_value:
+ {
+ backlight_config_set_value(value_id_and_data);
+ break;
+ }
+ case id_custom_get_value:
+ {
+ backlight_config_get_value(value_id_and_data);
+ break;
+ }
+ case id_custom_save:
+ {
+ backlight_config_save();
+ break;
+ }
+ default:
+ {
+ // Unhandled message.
+ *command_id = id_unhandled;
+ 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
}
#endif // VIA_ENABLE
diff --git a/keyboards/wilba_tech/zeal60/config.h b/keyboards/wilba_tech/zeal60/config.h
index eaf7b76504..94a8a599f4 100644
--- a/keyboards/wilba_tech/zeal60/config.h
+++ b/keyboards/wilba_tech/zeal60/config.h
@@ -107,6 +107,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/wilba_tech/zeal65/config.h b/keyboards/wilba_tech/zeal65/config.h
index d5e83a11e3..4cbd12c0a5 100644
--- a/keyboards/wilba_tech/zeal65/config.h
+++ b/keyboards/wilba_tech/zeal65/config.h
@@ -107,6 +107,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/winry/winry315/keymaps/via/config.h b/keyboards/winry/winry315/keymaps/via/config.h
index 5fc0e02531..de1f70c160 100644
--- a/keyboards/winry/winry315/keymaps/via/config.h
+++ b/keyboards/winry/winry315/keymaps/via/config.h
@@ -4,12 +4,3 @@
#pragma once
#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
diff --git a/keyboards/winry/winry315/winry315.c b/keyboards/winry/winry315/winry315.c
index d8042606c0..e7901a2e00 100644
--- a/keyboards/winry/winry315/winry315.c
+++ b/keyboards/winry/winry315/winry315.c
@@ -164,60 +164,6 @@ uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t
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)
void winry315_set_orientation(uint8_t orientation) {
diff --git a/keyboards/xelus/dawn60/rev1/config.h b/keyboards/xelus/dawn60/rev1/config.h
index af4c31e478..6aeef780bb 100644
--- a/keyboards/xelus/dawn60/rev1/config.h
+++ b/keyboards/xelus/dawn60/rev1/config.h
@@ -128,6 +128,3 @@
// Backlight config starts after VIA's EEPROM usage,
// dynamic keymaps start after this.
#define VIA_EEPROM_CUSTOM_CONFIG_SIZE 31
-
-// VIA lighting is handled by the keyboard-level code
-#define VIA_CUSTOM_LIGHTING_ENABLE
diff --git a/keyboards/xelus/la_plus/keymaps/via/config.h b/keyboards/xelus/la_plus/keymaps/via/config.h
deleted file mode 100644
index 43760bd281..0000000000
--- a/keyboards/xelus/la_plus/keymaps/via/config.h
+++ /dev/null
@@ -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
diff --git a/keyboards/xelus/pachi/rgb/keymaps/via/config.h b/keyboards/xelus/pachi/rgb/keymaps/via/config.h
index 0e34ad2c1a..47bbf2bf81 100644
--- a/keyboards/xelus/pachi/rgb/keymaps/via/config.h
+++ b/keyboards/xelus/pachi/rgb/keymaps/via/config.h
@@ -18,6 +18,3 @@
// 3 layers or else it will not fit in EEPROM
#define DYNAMIC_KEYMAP_LAYER_COUNT 3
-
-// Enable RGB Matrix
-#define VIA_QMK_RGBLIGHT_ENABLE
diff --git a/keyboards/xelus/valor/rev2/keymaps/via/config.h b/keyboards/xelus/valor/rev2/keymaps/via/config.h
index e7fb31cb23..8c0ed0c6e3 100644
--- a/keyboards/xelus/valor/rev2/keymaps/via/config.h
+++ b/keyboards/xelus/valor/rev2/keymaps/via/config.h
@@ -15,8 +15,5 @@
*/
#pragma once
-// RGB Matrix
-#define VIA_QMK_RGBLIGHT_ENABLE
-
// More layers
#define DYNAMIC_KEYMAP_LAYER_COUNT 8
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index e9529ed14e..c406be4585 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -279,9 +279,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR);
void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE);
while (id > 0) {
- // If we are past the end of the buffer, then the buffer
- // contents are garbage, i.e. there were not DYNAMIC_KEYMAP_MACRO_COUNT
- // nulls in the buffer.
+ // If we are past the end of the buffer, then there is
+ // no Nth macro in the buffer.
if (p == end) {
return;
}
@@ -291,9 +290,8 @@ void dynamic_keymap_macro_send(uint8_t id) {
++p;
}
- // Send the macro string one or three chars at a time
- // by making temporary 1 or 3 char strings
- char data[4] = {0, 0, 0, 0};
+ // Send the macro string by making a temporary string.
+ char data[8] = {0};
// We already checked there was a null at the end of
// the buffer, so this cannot go past the end
while (1) {
@@ -303,14 +301,44 @@ void dynamic_keymap_macro_send(uint8_t id) {
if (data[0] == 0) {
break;
}
- // If the char is magic (tap, down, up),
- // add the next char (key to use) and send a 3 char string.
- if (data[0] == SS_TAP_CODE || data[0] == SS_DOWN_CODE || data[0] == SS_UP_CODE) {
- data[1] = data[0];
- data[0] = SS_QMK_PREFIX;
- data[2] = eeprom_read_byte(p++);
- if (data[2] == 0) {
- break;
+ if (data[0] == SS_QMK_PREFIX) {
+ // Get the code
+ data[1] = eeprom_read_byte(p++);
+ // Unexpected null, abort.
+ if (data[1] == 0) {
+ return;
+ }
+ 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);
diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h
index 459b48d07a..806342efa3 100644
--- a/quantum/dynamic_keymap.h
+++ b/quantum/dynamic_keymap.h
@@ -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,
// and it not being null means the buffer can be considered in an
// 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);
uint16_t dynamic_keymap_macro_get_buffer_size(void);
diff --git a/quantum/via.c b/quantum/via.c
index 5afbee5a30..12ef6c6b2f 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -22,26 +22,6 @@
# error "DYNAMIC_KEYMAP_ENABLE is not enabled"
#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 "via.h"
@@ -51,22 +31,8 @@
#include "eeprom.h"
#include "version.h" // for QMK_BUILDDATE used in EEPROM magic
-// Forward declare some helpers.
-#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)
+#if defined(RGB_MATRIX_ENABLE)
# 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
// 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.
bool process_record_via(uint16_t keycode, keyrecord_t *record) {
// Handle macros
@@ -194,24 +188,96 @@ bool process_record_via(uint16_t keycode, keyrecord_t *record) {
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.
-__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]);
- *command_id = id_unhandled;
+ // Return the unhandled state
+ *command_id = id_unhandled;
}
-// VIA handles received HID messages first, and will route to
-// raw_hid_receive_kb() for command IDs that are not handled here.
-// This gives the keyboard code level the ability to handle the command
-// specifically.
+// This is the default handler for custom value commands.
+// It routes commands with channel IDs to command handlers as such:
//
-// raw_hid_send() is called at the end, with the same buffer, which was
-// possibly modified with returned values.
+// id_qmk_backlight_channel -> via_qmk_backlight_command()
+// 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) {
uint8_t *command_id = &(data[0]);
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) {
case id_get_protocol_version: {
command_data[0] = VIA_PROTOCOL_VERSION >> 8;
@@ -237,7 +303,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
break;
}
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;
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
matrix_row_t value = matrix_get_row(row);
@@ -255,8 +324,18 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
#endif
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: {
- raw_hid_receive_kb(data, length);
+ // The value ID is not known
+ // Return the unhandled state
+ *command_id = id_unhandled;
break;
}
}
@@ -269,8 +348,15 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
via_set_layout_options(value);
break;
}
+ case id_device_indication: {
+ uint8_t value = command_data[1];
+ via_set_device_indication(value);
+ break;
+ }
default: {
- raw_hid_receive_kb(data, length);
+ // The value ID is not known
+ // Return the unhandled state
+ *command_id = id_unhandled;
break;
}
}
@@ -290,61 +376,10 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
dynamic_keymap_reset();
break;
}
- case id_lighting_set_value: {
-#if defined(VIA_QMK_BACKLIGHT_ENABLE)
- via_qmk_backlight_set_value(command_data);
-#endif
-#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
+ case id_custom_set_value:
+ case id_custom_get_value:
+ case id_custom_save: {
+ via_custom_value_command(data, length);
break;
}
#ifdef VIA_EEPROM_ALLOW_RESET
@@ -421,13 +456,39 @@ void raw_hid_receive(uint8_t *data, uint8_t 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
# error BACKLIGHT_LEVELS == 0
# endif
void via_qmk_backlight_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) {
@@ -448,6 +509,7 @@ void via_qmk_backlight_get_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_data = &(data[1]);
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();
+}
+
+#endif // BACKLIGHT_ENABLE
-#if defined(VIA_QMK_RGBLIGHT_ENABLE)
+#if defined(RGBLIGHT_ENABLE)
# ifndef RGBLIGHT_LIMIT_VAL
# define RGBLIGHT_LIMIT_VAL 255
# 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) {
+ // data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
@@ -485,7 +577,7 @@ void via_qmk_rgblight_get_value(uint8_t *data) {
break;
}
case id_qmk_rgblight_effect: {
- value_data[0] = rgblight_get_mode();
+ value_data[0] = rgblight_is_enabled() ? rgblight_get_mode() : 0;
break;
}
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) {
+ // data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
@@ -509,11 +602,11 @@ void via_qmk_rgblight_set_value(uint8_t *data) {
break;
}
case id_qmk_rgblight_effect: {
- rgblight_mode_noeeprom(value_data[0]);
if (value_data[0] == 0) {
rgblight_disable_noeeprom();
} else {
rgblight_enable_noeeprom();
+ rgblight_mode_noeeprom(value_data[0]);
}
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();
+}
+
+#endif // QMK_RGBLIGHT_ENABLE
-#if defined(VIA_QMK_RGB_MATRIX_ENABLE)
+#if defined(RGB_MATRIX_ENABLE)
# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
# endif
-// 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;
- }
-}
+void via_qmk_rgb_matrix_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]);
-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;
+ switch (*command_id) {
+ case id_custom_set_value: {
+ via_qmk_rgb_matrix_set_value(value_id_and_data);
+ break;
+ }
+ case id_custom_get_value: {
+ via_qmk_rgb_matrix_get_value(value_id_and_data);
+ break;
+ }
+ case id_custom_save: {
+ via_qmk_rgb_matrix_save();
+ break;
+ }
+ default: {
+ *command_id = id_unhandled;
+ break;
+ }
}
}
void via_qmk_rgb_matrix_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_rgblight_brightness:
+ case id_qmk_rgb_matrix_brightness: {
value_data[0] = ((uint16_t)rgb_matrix_get_val() * UINT8_MAX) / RGB_MATRIX_MAXIMUM_BRIGHTNESS;
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;
- 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;
- case id_qmk_rgblight_color:
+ }
+ case id_qmk_rgb_matrix_color: {
value_data[0] = rgb_matrix_get_hue();
value_data[1] = rgb_matrix_get_sat();
break;
+ }
}
}
void via_qmk_rgb_matrix_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_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));
break;
- case id_qmk_rgblight_effect:
- rgb_matrix_mode_noeeprom(value_data[0]);
+ }
+ case id_qmk_rgb_matrix_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]));
+ }
+ case id_qmk_rgb_matrix_effect_speed: {
+ rgblight_set_speed_noeeprom(value_data[0]);
+ break;
+ }
+ case id_qmk_rgb_matrix_color: {
+ rgblight_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val());
+ break;
+ }
+ }
+}
+
+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_rgblight_color:
- rgb_matrix_sethsv_noeeprom(value_data[0], value_data[1], rgb_matrix_get_val());
+ }
+ case id_qmk_audio_clicky_enable: {
+ value_data[0] = audio_config.clicky_enable ? 1 : 0;
break;
+ }
}
}
-#endif // #if defined(VIA_QMK_RGB_MATRIX_ENABLE)
+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
diff --git a/quantum/via.h b/quantum/via.h
index 84b264903f..eca0733525 100644
--- a/quantum/via.h
+++ b/quantum/via.h
@@ -60,6 +60,16 @@
// so VIA Configurator can detect compatible firmware.
#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 {
id_get_protocol_version = 0x01, // always 0x01
id_get_keyboard_value = 0x02,
@@ -67,9 +77,9 @@ enum via_command_id {
id_dynamic_keymap_get_keycode = 0x04,
id_dynamic_keymap_set_keycode = 0x05,
id_dynamic_keymap_reset = 0x06,
- id_lighting_set_value = 0x07,
- id_lighting_get_value = 0x08,
- id_lighting_save = 0x09,
+ id_custom_set_value = 0x07,
+ id_custom_get_value = 0x08,
+ id_custom_save = 0x09,
id_eeprom_reset = 0x0A,
id_bootloader_jump = 0x0B,
id_dynamic_keymap_macro_get_count = 0x0C,
@@ -86,21 +96,43 @@ enum via_command_id {
};
enum via_keyboard_value_id {
- id_uptime = 0x01, //
+ id_uptime = 0x01,
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 {
- // QMK BACKLIGHT
- id_qmk_backlight_brightness = 0x09,
- id_qmk_backlight_effect = 0x0A,
+enum via_channel_id {
+ id_custom_channel = 0,
+ id_qmk_backlight_channel = 1,
+ id_qmk_rgblight_channel = 2,
+ id_qmk_rgb_matrix_channel = 3,
+ id_qmk_audio_channel = 4,
+};
+
+enum via_qmk_backlight_value {
+ id_qmk_backlight_brightness = 1,
+ id_qmk_backlight_effect = 2,
+};
+
+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,
+};
- // QMK RGBLIGHT
- id_qmk_rgblight_brightness = 0x80,
- id_qmk_rgblight_effect = 0x81,
- id_qmk_rgblight_effect_speed = 0x82,
- id_qmk_rgblight_color = 0x83,
+enum via_qmk_audio_value {
+ id_qmk_audio_enable = 1,
+ id_qmk_audio_clicky_enable = 2,
};
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_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.
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 \ No newline at end of file