forked from drath/libratbag
steelseries: make settings unique to SteelSeries Sensei RAW a quirk
This commit is contained in:
committed by
Filipe Laíns
parent
66e44d76b9
commit
724d31c8fe
@@ -10,5 +10,4 @@ Buttons=8
|
||||
Leds=1
|
||||
DpiRange=90:5670@90
|
||||
MacroLength=1
|
||||
MonoLed=1
|
||||
ShortButton=1
|
||||
Quirk=SenseiRAW
|
||||
|
||||
@@ -277,7 +277,7 @@ steelseries_probe(struct ratbag_device *device)
|
||||
struct ratbag_resolution *resolution;
|
||||
struct ratbag_button *button;
|
||||
struct ratbag_led *led;
|
||||
int rc, button_count, led_count, device_version, mono_led, short_button;
|
||||
int rc, button_count, led_count, device_version, quirk;
|
||||
struct dpi_list *dpilist = NULL;
|
||||
struct dpi_range *dpirange = NULL;
|
||||
|
||||
@@ -298,8 +298,7 @@ steelseries_probe(struct ratbag_device *device)
|
||||
led_count = ratbag_device_data_steelseries_get_led_count(device->data);
|
||||
dpirange = ratbag_device_data_steelseries_get_dpi_range(device->data);
|
||||
dpilist = ratbag_device_data_steelseries_get_dpi_list(device->data);
|
||||
mono_led = ratbag_device_data_steelseries_get_mono_led(device->data);
|
||||
short_button = ratbag_device_data_steelseries_get_short_button(device->data);
|
||||
quirk = ratbag_device_data_steelseries_get_quirk(device->data);
|
||||
|
||||
ratbag_device_init_profiles(device,
|
||||
STEELSERIES_NUM_PROFILES,
|
||||
@@ -343,7 +342,7 @@ steelseries_probe(struct ratbag_device *device)
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_BUTTON);
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_SPECIAL);
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_KEY);
|
||||
if (short_button == 0) {
|
||||
if (quirk != STEELSERIES_QUIRK_SENSEIRAW) {
|
||||
ratbag_button_enable_action_type(button, RATBAG_BUTTON_ACTION_TYPE_MACRO);
|
||||
}
|
||||
|
||||
@@ -353,7 +352,7 @@ steelseries_probe(struct ratbag_device *device)
|
||||
ratbag_profile_for_each_led(profile, led) {
|
||||
led->type = led->index == 0 ? RATBAG_LED_TYPE_LOGO : RATBAG_LED_TYPE_WHEEL;
|
||||
led->mode = RATBAG_LED_ON;
|
||||
if (mono_led) {
|
||||
if (quirk == STEELSERIES_QUIRK_SENSEIRAW) {
|
||||
led->colordepth = RATBAG_LED_COLORDEPTH_MONOCHROME;
|
||||
led->brightness = 255;
|
||||
} else {
|
||||
@@ -499,10 +498,10 @@ steelseries_write_buttons(struct ratbag_profile *profile)
|
||||
if (ratbag_device_data_steelseries_get_macro_length(device->data) == 0)
|
||||
return 0;
|
||||
|
||||
int short_button = ratbag_device_data_steelseries_get_short_button(device->data);
|
||||
int button_size = (short_button == 0) ? 5 : 3;
|
||||
int report_size = (short_button == 0) ? STEELSERIES_REPORT_LONG_SIZE : STEELSERIES_REPORT_SIZE_SHORT;
|
||||
int max_modifiers = (short_button == 0) ? 3 : 0;
|
||||
const bool is_senseiraw = ratbag_device_data_steelseries_get_quirk(device->data) == STEELSERIES_QUIRK_SENSEIRAW;
|
||||
const int button_size = is_senseiraw ? 3 : 5;
|
||||
const int report_size = is_senseiraw ? STEELSERIES_REPORT_SIZE_SHORT : STEELSERIES_REPORT_LONG_SIZE;
|
||||
const int max_modifiers = is_senseiraw ? 0 : 3;
|
||||
|
||||
uint8_t buf[report_size];
|
||||
memset(buf, 0, report_size);
|
||||
@@ -537,7 +536,7 @@ steelseries_write_buttons(struct ratbag_profile *profile)
|
||||
code = ratbag_hidraw_get_keyboard_usage_from_keycode(
|
||||
device, key);
|
||||
if (code) {
|
||||
if (short_button) {
|
||||
if (is_senseiraw) {
|
||||
buf[idx] = STEELSERIES_BUTTON_KEY;
|
||||
} else {
|
||||
buf[idx] = STEELSERIES_BUTTON_KBD;
|
||||
@@ -645,9 +644,7 @@ steelseries_write_led_v1(struct ratbag_led *led)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
int mono_led = ratbag_device_data_steelseries_get_mono_led(device->data);
|
||||
|
||||
if (mono_led) {
|
||||
if (quirk == STEELSERIES_QUIRK_SENSEIRAW) {
|
||||
buf[0] = STEELSERIES_ID_LED_INTENSITY_SHORT;
|
||||
buf[1] = led->index + 1;
|
||||
if (led->mode == RATBAG_LED_OFF || led->brightness == 0) {
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
|
||||
enum steelseries_quirk {
|
||||
STEELSERIES_QURIK_NONE,
|
||||
STEELSERIES_QUIRK_SENSEIRAW,
|
||||
};
|
||||
|
||||
@@ -84,9 +84,7 @@ struct data_steelseries {
|
||||
struct dpi_list *dpi_list;
|
||||
struct dpi_range *dpi_range;
|
||||
int macro_length;
|
||||
int mono_led;
|
||||
enum steelseries_quirk quirk;
|
||||
int short_button;
|
||||
};
|
||||
|
||||
struct ratbag_device_data {
|
||||
@@ -214,9 +212,7 @@ init_data_steelseries(struct ratbag *ratbag,
|
||||
data->steelseries.led_count = -1;
|
||||
data->steelseries.dpi_list = NULL;
|
||||
data->steelseries.dpi_range = NULL;
|
||||
data->steelseries.mono_led = 0;
|
||||
data->steelseries.quirk = STEELSERIES_QURIK_NONE;
|
||||
data->steelseries.short_button = 0;
|
||||
|
||||
num = g_key_file_get_integer(keyfile, group, "Buttons", &error);
|
||||
if (num != 0 || !error)
|
||||
@@ -254,23 +250,11 @@ init_data_steelseries(struct ratbag *ratbag,
|
||||
if (error)
|
||||
g_error_free(error);
|
||||
|
||||
error = NULL;
|
||||
num = g_key_file_get_integer(keyfile, group, "MonoLed", &error);
|
||||
if (num > 0 || !error)
|
||||
data->steelseries.mono_led = num;
|
||||
if (error)
|
||||
g_error_free(error);
|
||||
|
||||
str = g_key_file_get_string(keyfile, group, "Quirk", NULL);
|
||||
if (str) {
|
||||
if (streq(str, "SenseiRAW"))
|
||||
data->steelseries.quirk = STEELSERIES_QUIRK_SENSEIRAW;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
num = g_key_file_get_integer(keyfile, group, "ShortButton", &error);
|
||||
if (num > 0 || !error)
|
||||
data->steelseries.short_button = num;
|
||||
if (error)
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
static const struct driver_map {
|
||||
@@ -687,14 +671,6 @@ ratbag_device_data_steelseries_get_macro_length(const struct ratbag_device_data
|
||||
return data->steelseries.macro_length;
|
||||
}
|
||||
|
||||
int
|
||||
ratbag_device_data_steelseries_get_mono_led(const struct ratbag_device_data *data)
|
||||
{
|
||||
assert(data->drivertype == STEELSERIES);
|
||||
|
||||
return data->steelseries.mono_led;
|
||||
}
|
||||
|
||||
enum steelseries_quirk
|
||||
ratbag_device_data_steelseries_get_quirk(const struct ratbag_device_data *data)
|
||||
{
|
||||
@@ -702,11 +678,3 @@ ratbag_device_data_steelseries_get_quirk(const struct ratbag_device_data *data)
|
||||
|
||||
return data->steelseries.quirk;
|
||||
}
|
||||
|
||||
int
|
||||
ratbag_device_data_steelseries_get_short_button(const struct ratbag_device_data *data)
|
||||
{
|
||||
assert(data->drivertype == STEELSERIES);
|
||||
|
||||
return data->steelseries.short_button;
|
||||
}
|
||||
|
||||
@@ -118,14 +118,8 @@ ratbag_device_data_steelseries_get_dpi_range(const struct ratbag_device_data *da
|
||||
int
|
||||
ratbag_device_data_steelseries_get_macro_length(const struct ratbag_device_data *data);
|
||||
|
||||
int
|
||||
ratbag_device_data_steelseries_get_mono_led(const struct ratbag_device_data *data);
|
||||
|
||||
/**
|
||||
* @return Quirk
|
||||
*/
|
||||
enum steelseries_quirk
|
||||
ratbag_device_data_steelseries_get_quirk(const struct ratbag_device_data *data);
|
||||
|
||||
int
|
||||
ratbag_device_data_steelseries_get_short_button(const struct ratbag_device_data *data);
|
||||
|
||||
Reference in New Issue
Block a user