summaryrefslogtreecommitdiff
path: root/keyboards/cannonkeys/satisfaction75/satisfaction75.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/cannonkeys/satisfaction75/satisfaction75.c')
-rw-r--r--keyboards/cannonkeys/satisfaction75/satisfaction75.c211
1 files changed, 120 insertions, 91 deletions
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