Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIA V3 - The Custom UI Update #18222

Merged
merged 31 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
054de5b
VIA V3
wilba Aug 30, 2022
65a6419
remove lib/ugfx
wilba Aug 30, 2022
a63c932
Formatting changes
wilba Aug 30, 2022
35fc1f1
Fix qmk lint
wilba Aug 30, 2022
ac6417a
Refactoring the command handlers, formatting
wilba Oct 10, 2022
87b79b9
Reduce the muddiness factor of the diffs
wilba Oct 10, 2022
be7aaf0
More reduction of muddiness
wilba Oct 10, 2022
24feae9
Merge branch 'develop' into via_v3_pr
wilba Oct 10, 2022
9a00599
Fix rebase
wilba Oct 10, 2022
739228a
Remove QMK_KEYS_PER_SCAN
wilba Oct 11, 2022
f9a8ead
Fix broken users code
wilba Oct 22, 2022
cac1e1e
Fix broken users code
wilba Oct 22, 2022
5249774
Fix broken keymap introspection
wilba Oct 22, 2022
3762883
Fix broken users code
wilba Oct 22, 2022
95707e0
Fix Iris firmware size
wilba Oct 22, 2022
eeeb16b
Merge branch 'develop' into via_v3_pr
wilba Oct 22, 2022
b844900
Merge branch 'develop' into via_v3_pr
wilba Oct 22, 2022
dfbc8cc
Fix broken users code
wilba Oct 22, 2022
ed847e4
Merge branch 'develop' into via_v3_pr
wilba Oct 28, 2022
2965ffa
Fix build error
wilba Oct 28, 2022
d87366a
Fix firmware size
wilba Oct 28, 2022
d71959d
Fix firmware size
wilba Oct 28, 2022
f39fe55
Fix firmware size
wilba Oct 28, 2022
0894924
Fix build error
wilba Oct 29, 2022
0f4b77a
Merge branch 'develop' into via_v3_pr
wilba Oct 29, 2022
8105f96
Fix build error
wilba Oct 29, 2022
dcb4c78
Revert changes to Work Louder Micro and Work Board
wilba Nov 2, 2022
fb17546
Merge branch 'develop' into via_v3_pr
wilba Nov 5, 2022
0ea8612
Rollback the build error fixes
wilba Nov 8, 2022
94b7efb
Review changes
wilba Nov 8, 2022
c8ca3ce
Merge branch 'develop' into via_v3_pr
wilba Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions keyboards/cannonkeys/satisfaction75/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
211 changes: 120 additions & 91 deletions keyboards/cannonkeys/satisfaction75/satisfaction75.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions keyboards/cannonkeys/satisfaction75/satisfaction75.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions keyboards/durgod/dgk6x/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
1 change: 0 additions & 1 deletion keyboards/frooastboard/walnut/keymaps/via/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@

#pragma once

#define VIA_CUSTOM_LIGHTING_ENABLE
#define DYNAMIC_KEYMAP_LAYER_COUNT 2
113 changes: 1 addition & 112 deletions keyboards/frooastboard/walnut/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
2 changes: 0 additions & 2 deletions keyboards/geekboards/macropad_v2/keymaps/via/config.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@
#pragma once

#define DYNAMIC_KEYMAP_LAYER_COUNT 2

#ifdef RGB_MATRIX_ENABLE
#define VIA_QMK_RGBLIGHT_ENABLE
#endif
Loading