From 59cd7b1091ce86ee6afe4fd16ca8549bee20c9cd Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 14 Dec 2015 11:42:57 +0100 Subject: [PATCH] hidpp10drv: do not look for profile specifics when the device doesn't support them This prevents the M705 to shout that we need to set RATBAG_HIDPP10_DPI and also allows the mice with only 1 profile to be configured. Signed-off-by: Benjamin Tissoires --- src/driver-hidpp10.c | 56 ++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 208be3bc..67be65c1 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -222,6 +222,10 @@ static int hidpp10drv_has_capability(const struct ratbag_device *device, enum ratbag_device_capability cap) { + /* we force a non const device to shut up a warning, but we won't change anything */ + struct hidpp10drv_data *drv_data = ratbag_get_drv_data((struct ratbag_device *)device); + struct hidpp10_device *hidpp10 = drv_data->dev; + switch (cap) { case RATBAG_DEVICE_CAP_NONE: abort(); @@ -231,7 +235,7 @@ hidpp10drv_has_capability(const struct ratbag_device *device, case RATBAG_DEVICE_CAP_BUTTON_KEY: case RATBAG_DEVICE_CAP_BUTTON_MACROS: case RATBAG_DEVICE_CAP_DEFAULT_PROFILE: - return (device->num_profiles > 1); + return (hidpp10->profile_type != HIDPP10_PROFILE_UNKNOWN); } return 0; } @@ -447,33 +451,35 @@ hidpp10drv_probe(struct ratbag_device *device) goto err; } - prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_DPI"); - if (prop) { - rc = hidpp10_build_dpi_table_from_dpi_info(dev, prop); - if (rc) - log_error(device->ratbag, - "Error parsing RATBAG_HIDPP10_DPI: '%s' for %s\n", - prop, + if (type != HIDPP10_PROFILE_UNKNOWN) { + prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_DPI"); + if (prop) { + rc = hidpp10_build_dpi_table_from_dpi_info(dev, prop); + if (rc) + log_error(device->ratbag, + "Error parsing RATBAG_HIDPP10_DPI: '%s' for %s\n", + prop, + device->name); + } + + prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_DPI_LIST"); + if (prop) { + rc = hidpp10_build_dpi_table_from_list(dev, prop); + if (rc) + log_error(device->ratbag, + "Error parsing RATBAG_HIDPP10_DPI_LIST: '%s' for %s\n", + prop, + device->name); + } + + if (!dev->dpi_count) + log_info(device->ratbag, + "Device %s might have wrong dpi settings. " + "Please add RATBAG_HIDPP10_DPI or RATBAG_HIDPP10_DPI_LIST " + "to the udev properties.\n", device->name); } - prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_DPI_LIST"); - if (prop) { - rc = hidpp10_build_dpi_table_from_list(dev, prop); - if (rc) - log_error(device->ratbag, - "Error parsing RATBAG_HIDPP10_DPI_LIST: '%s' for %s\n", - prop, - device->name); - } - - if (!dev->dpi_count) - log_info(device->ratbag, - "Device %s might have wrong dpi settings. " - "Please add RATBAG_HIDPP10_DPI or RATBAG_HIDPP10_DPI_LIST " - "to the udev properties.\n", - device->name); - drv_data->dev = dev; ratbag_set_drv_data(device, drv_data);