diff options
Diffstat (limited to 'keyboards/cannonkeys/satisfaction75')
5 files changed, 125 insertions, 99 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/keymaps/boy_314/keymap.c b/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/keymap.c index 38fdb8880e..256cdecd6a 100644 --- a/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/keymap.c +++ b/keyboards/cannonkeys/satisfaction75/keymaps/boy_314/keymap.c @@ -28,7 +28,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [1] = LAYOUT_2x2( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - NK_TOGG, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SLCK, KC_PAUS, _______, _______, _______, _______, OLED_TOGG, + NK_TOGG, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_SCRL, KC_PAUS, _______, _______, _______, _______, OLED_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS, KC_HOME, KC_PGUP, _______, _______, QK_BOOT, CLOCK_SET, KC_CAPS, _______, _______, _______, _______, _______, _______, _______, KC_DEL, KC_END, KC_PGDN, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, _______, 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 c6dbc31f1b..ec852eef6c 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction75.h +++ b/keyboards/cannonkeys/satisfaction75/satisfaction75.h @@ -25,13 +25,13 @@ typedef union { // Start these at the USER code range in VIA enum my_keycodes { - ENC_PRESS = 0x5F80, + ENC_PRESS = USER00, CLOCK_SET, 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/cannonkeys/satisfaction75/satisfaction_encoder.c b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c index 0d2fdc359c..c40815a8d8 100644 --- a/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c +++ b/keyboards/cannonkeys/satisfaction75/satisfaction_encoder.c @@ -144,7 +144,7 @@ uint16_t handle_encoder_ccw(){ mapped_code = KC_WH_U; break; case ENC_MODE_BACKLIGHT: - // mapped_code = BL_DEC; + // mapped_code = BL_DOWN; if(kb_backlight_config.level != 0){ kb_backlight_config.level = kb_backlight_config.level - 1; } |