mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-08 07:33:53 +01:00
hidpp20: add quirk system
Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
committed by
Filipe Laíns
parent
8ae995b72d
commit
edb054c6f8
@@ -169,7 +169,7 @@ def check_section_hidpp10(section):
|
||||
|
||||
|
||||
def check_section_hidpp20(section):
|
||||
permitted = ['DeviceIndex']
|
||||
permitted = ['DeviceIndex', 'Quirk']
|
||||
for key in section.keys():
|
||||
assertIn(key, permitted)
|
||||
|
||||
|
||||
@@ -1560,10 +1560,15 @@ hidpp20drv_probe(struct ratbag_device *device)
|
||||
goto err;
|
||||
}
|
||||
|
||||
dev->quirk = ratbag_device_data_hidpp20_get_quirk(device->data);
|
||||
|
||||
drv_data->dev = dev;
|
||||
|
||||
log_debug(device->ratbag, "'%s' is using protocol v%d.%d\n", ratbag_device_get_name(device), dev->proto_major, dev->proto_minor);
|
||||
|
||||
if(dev->quirk != HIDPP20_QUIRK_NONE)
|
||||
log_debug(device->ratbag, "'%s' is quirked (%s)\n", ratbag_device_get_name(device), hidpp20_get_quirk_string(dev->quirk));
|
||||
|
||||
/* add some defaults that will be overwritten by the device */
|
||||
drv_data->num_profiles = 1;
|
||||
drv_data->num_resolutions = 1;
|
||||
|
||||
@@ -48,7 +48,6 @@ hidpp20_feature_get_name(uint16_t feature)
|
||||
{
|
||||
static char numeric[8];
|
||||
const char *str;
|
||||
#define CASE_RETURN_STRING(a) case a: return #a; break
|
||||
|
||||
switch(feature)
|
||||
{
|
||||
@@ -99,11 +98,21 @@ hidpp20_sw_led_control_get_mode_string(const enum hidpp20_led_sw_ctrl_led_mode m
|
||||
str = numeric;
|
||||
break;
|
||||
}
|
||||
#undef CASE_RETURN_STRING
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
const char*
|
||||
hidpp20_get_quirk_string(enum hidpp20_quirk quirk)
|
||||
{
|
||||
switch (quirk) {
|
||||
CASE_RETURN_STRING(HIDPP20_QUIRK_NONE);
|
||||
CASE_RETURN_STRING(HIDPP20_QUIRK_G305);
|
||||
}
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp20_request_command_allow_error(struct hidpp20_device *device, union hidpp20_message *msg,
|
||||
bool allow_error)
|
||||
|
||||
@@ -51,6 +51,10 @@ struct hidpp20_feature {
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
enum hidpp20_quirk {
|
||||
HIDPP20_QUIRK_NONE,
|
||||
};
|
||||
|
||||
struct hidpp20_device {
|
||||
struct hidpp_device base;
|
||||
unsigned int index;
|
||||
@@ -58,12 +62,17 @@ struct hidpp20_device {
|
||||
unsigned proto_minor;
|
||||
unsigned feature_count;
|
||||
struct hidpp20_feature *feature_list;
|
||||
enum hidpp20_quirk quirk;
|
||||
};
|
||||
|
||||
int hidpp20_request_command(struct hidpp20_device *dev, union hidpp20_message *msg);
|
||||
|
||||
#define CASE_RETURN_STRING(a) case a: return #a; break
|
||||
|
||||
const char *hidpp20_feature_get_name(uint16_t feature);
|
||||
|
||||
const char *hidpp20_get_quirk_string(enum hidpp20_quirk quirk);
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* generic hidpp20 device operations */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "libratbag.h"
|
||||
#include "libratbag-private.h"
|
||||
#include "libratbag-data.h"
|
||||
#include "hidpp20.h"
|
||||
|
||||
#define GROUP_DEVICE "Device"
|
||||
|
||||
@@ -54,6 +55,7 @@ enum driver {
|
||||
|
||||
struct data_hidpp20 {
|
||||
int index;
|
||||
enum hidpp20_quirk quirk;
|
||||
};
|
||||
|
||||
struct data_hidpp10 {
|
||||
@@ -152,6 +154,7 @@ init_data_hidpp20(struct ratbag *ratbag,
|
||||
const char *group = "Driver/hidpp20";
|
||||
GError *error = NULL;
|
||||
int num;
|
||||
char *str;
|
||||
|
||||
data->hidpp20.index = -1;
|
||||
|
||||
@@ -160,6 +163,8 @@ init_data_hidpp20(struct ratbag *ratbag,
|
||||
data->hidpp20.index = num;
|
||||
if (error)
|
||||
g_error_free(error);
|
||||
|
||||
data->hidpp20.quirk = HIDPP20_QUIRK_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -562,6 +567,14 @@ ratbag_device_data_hidpp20_get_index(const struct ratbag_device_data *data)
|
||||
return data->hidpp20.index;
|
||||
}
|
||||
|
||||
enum hidpp20_quirk
|
||||
ratbag_device_data_hidpp20_get_quirk(const struct ratbag_device_data *data)
|
||||
{
|
||||
assert(data->drivertype == HIDPP20);
|
||||
|
||||
return data->hidpp20.quirk;
|
||||
}
|
||||
|
||||
/* SteelSeries */
|
||||
|
||||
int
|
||||
|
||||
@@ -80,6 +80,9 @@ ratbag_device_data_hidpp10_get_led_count(const struct ratbag_device_data *data);
|
||||
int
|
||||
ratbag_device_data_hidpp20_get_index(const struct ratbag_device_data *data);
|
||||
|
||||
enum hidpp20_quirk
|
||||
ratbag_device_data_hidpp20_get_quirk(const struct ratbag_device_data *data);
|
||||
|
||||
/* SteelSeries */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user