From 81c7b42bec6fb7cf0a7dda368aae345b1dcdf72b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Wed, 31 Jul 2019 09:07:46 +0100 Subject: [PATCH] hidpp20/data: add the G305 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Filipe LaĆ­ns --- data/devices/logitech-g305.device | 7 +++++++ meson.build | 1 + src/hidpp20.c | 10 ++++++++++ src/hidpp20.h | 1 + src/libratbag-data.c | 5 +++++ 5 files changed, 24 insertions(+) create mode 100644 data/devices/logitech-g305.device diff --git a/data/devices/logitech-g305.device b/data/devices/logitech-g305.device new file mode 100644 index 00000000..ac836597 --- /dev/null +++ b/data/devices/logitech-g305.device @@ -0,0 +1,7 @@ +[Device] +Name=Logitech Gaming Mouse G305 +DeviceMatch=usb:046d:4074 +Driver=hidpp20 + +[Driver/hidpp20] +Quirk=G305 diff --git a/meson.build b/meson.build index 502c3bb8..f4ba932b 100644 --- a/meson.build +++ b/meson.build @@ -294,6 +294,7 @@ data_files = files( 'data/devices/logitech-g300.device', 'data/devices/logitech-g302.device', 'data/devices/logitech-g303.device', + 'data/devices/logitech-g305.device', 'data/devices/logitech-g402.device', 'data/devices/logitech-g403-hero.device', 'data/devices/logitech-g403-wireless.device', diff --git a/src/hidpp20.c b/src/hidpp20.c index 12ce268d..36d6db45 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -2611,6 +2611,15 @@ hidpp20_onboard_profiles_initialize(struct hidpp20_device *device, HIDPP20_USER_PROFILES_G402, profiles->sector_size, data); + + if (rc && device->quirk != HIDPP20_QUIRK_G305) { + /* The G305 has a bug where it throws an ERR_INVALID_ARGUMENT + if the sector has not been written to yet. If this happens + we will read the ROM profiles.*/ + read_userdata = false; + goto read_profiles; + } + if (rc < 0) return rc; // ignore_clang_sa_mem_leak @@ -2644,6 +2653,7 @@ hidpp20_onboard_profiles_initialize(struct hidpp20_device *device, read_userdata = false; } +read_profiles: for (i = 0; i < profiles->num_profiles; i++) { if (read_userdata) { hidpp_log_debug(&device->base, "Parsing profile %u\n", i); diff --git a/src/hidpp20.h b/src/hidpp20.h index 6bdd3bc7..aeea99a8 100644 --- a/src/hidpp20.h +++ b/src/hidpp20.h @@ -53,6 +53,7 @@ struct hidpp20_feature { enum hidpp20_quirk { HIDPP20_QUIRK_NONE, + HIDPP20_QUIRK_G305, }; struct hidpp20_device { diff --git a/src/libratbag-data.c b/src/libratbag-data.c index d5656255..c9589a95 100644 --- a/src/libratbag-data.c +++ b/src/libratbag-data.c @@ -164,7 +164,12 @@ init_data_hidpp20(struct ratbag *ratbag, if (error) g_error_free(error); + str = g_key_file_get_string(keyfile, group, "Quirk", NULL); data->hidpp20.quirk = HIDPP20_QUIRK_NONE; + if (str) { + if (streq(str, "G305")) + data->hidpp20.quirk = HIDPP20_QUIRK_G305; + } } static void