mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
hidpp10: add mandatory udev prop RATBAG_HIDPP10_PROFILE
Allows to specify a type of profile and speed up the discovery of hidpp10 devices when they are not actual gaming with a known profile. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This commit is contained in:
@@ -96,12 +96,14 @@ mouse:usb:v046dpc249:name:*:
|
||||
mouse:usb:v046dpc068:name:*:
|
||||
RATBAG_DRIVER=hidpp10
|
||||
RATBAG_HIDPP10_DPI=0:5700@23.53
|
||||
RATBAG_HIDPP10_PROFILE=G500
|
||||
|
||||
# G500s
|
||||
mouse:usb:v046dpc24e:name:*:
|
||||
RATBAG_DRIVER=hidpp10
|
||||
RATBAG_SVG=logitech-g500s.svg
|
||||
RATBAG_HIDPP10_DPI=0:8200@50
|
||||
RATBAG_HIDPP10_PROFILE=G500
|
||||
|
||||
# G502 over USB
|
||||
mouse:usb:v046dpc07d:name:*:
|
||||
|
||||
@@ -218,6 +218,7 @@ hidpp10drv_probe(struct ratbag_device *device)
|
||||
struct hidpp10drv_data *drv_data = NULL;
|
||||
struct hidpp10_device *dev = NULL;
|
||||
struct hidpp_device base;
|
||||
enum hidpp10_profile_type type = HIDPP10_PROFILE_UNKNOWN;
|
||||
const char *prop;
|
||||
|
||||
rc = ratbag_find_hidraw(device, hidpp10drv_test_hidraw);
|
||||
@@ -236,12 +237,17 @@ hidpp10drv_probe(struct ratbag_device *device)
|
||||
hidpp_device_init(&base, device->hidraw.fd);
|
||||
hidpp_device_set_log_handler(&base, hidpp10_log, HIDPP_LOG_PRIORITY_RAW, device);
|
||||
|
||||
prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_PROFILE");
|
||||
if (prop) {
|
||||
if (strcasecmp("G500", prop) == 0)
|
||||
type = HIDPP10_PROFILE_G500;
|
||||
}
|
||||
/* We can treat all devices as wired devices here. If we talk to the
|
||||
* correct hidraw device the kernel adjusts the device index for us,
|
||||
* so even for unifying receiver devices we can just 0x00 as device
|
||||
* index.
|
||||
*/
|
||||
dev = hidpp10_device_new(&base, HIDPP_WIRED_DEVICE_IDX);
|
||||
dev = hidpp10_device_new(&base, HIDPP_WIRED_DEVICE_IDX, type);
|
||||
|
||||
if (!dev) {
|
||||
log_error(device->ratbag,
|
||||
|
||||
@@ -633,6 +633,11 @@ hidpp10_get_profile_directory(struct hidpp10_device *dev,
|
||||
struct hidpp10_directory *directory = (struct hidpp10_directory *)bytes;
|
||||
size_t count;
|
||||
|
||||
if (dev->profile_type == HIDPP10_PROFILE_UNKNOWN) {
|
||||
hidpp_log_debug(&dev->base, "no profile type given\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dev->profile_directory) {
|
||||
count = 0;
|
||||
while (dev->profile_directory[count].page) {
|
||||
@@ -751,6 +756,9 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr
|
||||
if (count < 0)
|
||||
return count;
|
||||
|
||||
if (count == 0 || dev->profile_type == HIDPP10_PROFILE_UNKNOWN)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (number >= count) {
|
||||
hidpp_log_error(&dev->base, "Profile number %d not in the directory.\n", number);
|
||||
return -EINVAL;
|
||||
@@ -1497,7 +1505,8 @@ hidpp10_get_device_info(struct hidpp10_device *dev)
|
||||
}
|
||||
|
||||
struct hidpp10_device*
|
||||
hidpp10_device_new(const struct hidpp_device *base, int idx)
|
||||
hidpp10_device_new(const struct hidpp_device *base, int idx,
|
||||
enum hidpp10_profile_type type)
|
||||
{
|
||||
struct hidpp10_device *dev;
|
||||
|
||||
@@ -1505,6 +1514,7 @@ hidpp10_device_new(const struct hidpp_device *base, int idx)
|
||||
|
||||
dev->index = idx;
|
||||
dev->base = *base;
|
||||
dev->profile_type = type;
|
||||
|
||||
if (hidpp10_get_device_info(dev) != 0) {
|
||||
hidpp10_device_destroy(dev);
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
#define HIDPP10_MAX_PAGE_NUMBER 31
|
||||
|
||||
enum hidpp10_profile_type {
|
||||
HIDPP10_PROFILE_UNKNOWN = -1,
|
||||
HIDPP10_PROFILE_G500,
|
||||
};
|
||||
|
||||
struct hidpp10_directory;
|
||||
|
||||
struct hidpp10_dpi_mapping {
|
||||
@@ -53,10 +58,12 @@ struct hidpp10_device {
|
||||
uint8_t dpi_count;
|
||||
struct hidpp10_dpi_mapping *dpi_table; /* must be null terminated */
|
||||
struct hidpp10_directory *profile_directory; /* must be null terminated */
|
||||
enum hidpp10_profile_type profile_type;
|
||||
};
|
||||
|
||||
struct hidpp10_device*
|
||||
hidpp10_device_new(const struct hidpp_device *base, int idx);
|
||||
hidpp10_device_new(const struct hidpp_device *base, int idx,
|
||||
enum hidpp10_profile_type type);
|
||||
|
||||
void
|
||||
hidpp10_device_destroy(struct hidpp10_device *dev);
|
||||
|
||||
@@ -98,7 +98,7 @@ main(int argc, char **argv)
|
||||
error(1, errno, "Failed to open path %s", path);
|
||||
|
||||
hidpp_device_init(&base, fd);
|
||||
dev = hidpp10_device_new(&base, HIDPP_WIRED_DEVICE_IDX);
|
||||
dev = hidpp10_device_new(&base, HIDPP_WIRED_DEVICE_IDX, HIDPP10_PROFILE_UNKNOWN);
|
||||
|
||||
if (argc == 2)
|
||||
rc = dump_all_pages(dev);
|
||||
|
||||
Reference in New Issue
Block a user