From 18118645a622c3677fe78be9b36e8fa05a3abf26 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 14:03:17 +0100 Subject: [PATCH 1/7] Update device_registry.c Add G Pro X 2 support --- src/device_registry.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/device_registry.c b/src/device_registry.c index 0cf1758..279d629 100644 --- a/src/device_registry.c +++ b/src/device_registry.c @@ -10,6 +10,7 @@ #include "devices/logitech_g633_g933_935.h" #include "devices/logitech_g930.h" #include "devices/logitech_gpro.h" +#include "devices/logitech_gpro_x2.h" #include "devices/logitech_zone_wired.h" #include "devices/roccat_elo_7_1_air.h" #include "devices/roccat_elo_7_1_usb.h" @@ -23,7 +24,7 @@ #include -#define NUMDEVICES 20 +#define NUMDEVICES 21 // array of pointers to device static struct device*(devicelist[NUMDEVICES]); @@ -50,6 +51,7 @@ void init_devices() arctis_nova_7_init(&devicelist[17]); calphaw_init(&devicelist[18]); arctis_nova_pro_wireless_init(&devicelist[19]); + gpro_x2_init(&devicelist[20]); } int get_device(struct device* device_found, uint16_t idVendor, uint16_t idProduct) From b0c79768cfeacaa273fa716b1ad3c2698cfe5a70 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 14:04:55 +0100 Subject: [PATCH 2/7] Update CMakeLists.txt Add G Pro X 2 support --- src/devices/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/devices/CMakeLists.txt b/src/devices/CMakeLists.txt index 2673bf2..427cd73 100644 --- a/src/devices/CMakeLists.txt +++ b/src/devices/CMakeLists.txt @@ -39,4 +39,6 @@ set(SOURCE_FILES ${SOURCE_FILES} ${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro.h ${CMAKE_CURRENT_SOURCE_DIR}/logitech_zone_wired.c ${CMAKE_CURRENT_SOURCE_DIR}/logitech_zone_wired.h + ${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro_x2.c + ${CMAKE_CURRENT_SOURCE_DIR}/logitech_gpro_x2.h PARENT_SCOPE) From 1e0255409ee73cccce32bb75a358cd9e7891f4b1 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 14:07:24 +0100 Subject: [PATCH 3/7] Add files via upload Add G Pro X 2 support --- src/devices/logitech_gpro_x2.c | 43 ++++++++++++++++++++++++++++++++++ src/devices/logitech_gpro_x2.h | 3 +++ 2 files changed, 46 insertions(+) create mode 100644 src/devices/logitech_gpro_x2.c create mode 100644 src/devices/logitech_gpro_x2.h diff --git a/src/devices/logitech_gpro_x2.c b/src/devices/logitech_gpro_x2.c new file mode 100644 index 0000000..9c52cba --- /dev/null +++ b/src/devices/logitech_gpro_x2.c @@ -0,0 +1,43 @@ +#include + +#include +#include +#include + +#include "../device.h" +#include "../utility.h" +#include "logitech.h" + +static struct device device_gpro_x2; + +#define ID_LOGITECH_PRO_X2 0x0af7 + +static const uint16_t PRODUCT_IDS[] = { + ID_LOGITECH_PRO_X2, +}; + +static int gpro_x2_send_sidetone(hid_device* device_handle, uint8_t num); + +void gpro_x2_init(struct device** device) +{ + device_gpro_x2.idVendor = VENDOR_LOGITECH; + device_gpro_x2.idProductsSupported = PRODUCT_IDS; + device_gpro_x2.numIdProducts = sizeof(PRODUCT_IDS) / sizeof(PRODUCT_IDS[0]); + + strncpy(device_gpro_x2.device_name, "Logitech G PRO X2", sizeof(device_gpro_x2.device_name)); + + device_gpro_x2.capabilities = B(CAP_SIDETONE); + + device_gpro_x2.send_sidetone = &gpro_x2_send_sidetone; + + *device = &device_gpro_x2; +} + +static int gpro_x2_send_sidetone(hid_device* device_handle, uint8_t num) +{ + num = map(num, 0, 128, 0, 100); + + uint8_t sidetone_data[HIDPP_LONG_MESSAGE_LENGTH] = { HIDPP_LONG_MESSAGE, HIDPP_DEVICE_RECEIVER, 0x51, 0x0a, 0x00, 0x03, 0x1b, 0x00, 0x05, 0x00, 0x07, 0x1b, 0x01, num}; + + return hid_write(device_handle, sidetone_data, sizeof(sidetone_data) / sizeof(sidetone_data[0])); +} diff --git a/src/devices/logitech_gpro_x2.h b/src/devices/logitech_gpro_x2.h new file mode 100644 index 0000000..21652ac --- /dev/null +++ b/src/devices/logitech_gpro_x2.h @@ -0,0 +1,3 @@ +#pragma once + +void gpro_x2_init(struct device** device); From 4cf17198d90ab6a28e008cd7aa7f6a2ba43ba50c Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 16:16:48 +0100 Subject: [PATCH 4/7] Update logitech_gpro_x2.c sidetone setting corrected. usagepage and usageid added. --- src/devices/logitech_gpro_x2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/devices/logitech_gpro_x2.c b/src/devices/logitech_gpro_x2.c index 9c52cba..fee2e90 100644 --- a/src/devices/logitech_gpro_x2.c +++ b/src/devices/logitech_gpro_x2.c @@ -27,7 +27,8 @@ void gpro_x2_init(struct device** device) strncpy(device_gpro_x2.device_name, "Logitech G PRO X2", sizeof(device_gpro_x2.device_name)); device_gpro_x2.capabilities = B(CAP_SIDETONE); - + device_gpro_x2.capability_details[CAP_SIDETONE] = (struct capability_detail) { .usagepage = 0xffa0, .usageid = 0x1, .interface = 3 }; + device_gpro_x2.send_sidetone = &gpro_x2_send_sidetone; *device = &device_gpro_x2; @@ -37,7 +38,7 @@ static int gpro_x2_send_sidetone(hid_device* device_handle, uint8_t num) { num = map(num, 0, 128, 0, 100); - uint8_t sidetone_data[HIDPP_LONG_MESSAGE_LENGTH] = { HIDPP_LONG_MESSAGE, HIDPP_DEVICE_RECEIVER, 0x51, 0x0a, 0x00, 0x03, 0x1b, 0x00, 0x05, 0x00, 0x07, 0x1b, 0x01, num}; + uint8_t sidetone_data[12] = { 0x51, 0x0a, 0x00, 0x03, 0x1b, 0x00, 0x05, 0x00, 0x07, 0x1b, 0x01, num}; return hid_write(device_handle, sidetone_data, sizeof(sidetone_data) / sizeof(sidetone_data[0])); } From 6aca188723e42ec6aa795c2e5b107f41474fe9b9 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 16:19:24 +0100 Subject: [PATCH 5/7] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e92e182..cc12c9b 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ talking. This differs from a simple loopback via PulseAudio as you won't have an - Sidetone, Battery, Inactive time - Logitech G PRO - Sidetone, Battery, Inactive time +- Logitech G PRO X 2 + - Sidetone - Logitech Zone Wired/Zone 750 - Sidetone, Voice prompts, Rotate to mute - Roccat Elo 7.1 Air From b46de5f7caeb30acaba230eed7d43fe5b553bd25 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Wed, 20 Dec 2023 22:23:28 +0100 Subject: [PATCH 6/7] Update logitech_gpro_x2.c Add inactive time parameter --- src/devices/logitech_gpro_x2.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/devices/logitech_gpro_x2.c b/src/devices/logitech_gpro_x2.c index fee2e90..d166646 100644 --- a/src/devices/logitech_gpro_x2.c +++ b/src/devices/logitech_gpro_x2.c @@ -17,6 +17,7 @@ static const uint16_t PRODUCT_IDS[] = { }; static int gpro_x2_send_sidetone(hid_device* device_handle, uint8_t num); +static int gpro_x2_send_inactive_time(hid_device* device_handle, uint8_t num); void gpro_x2_init(struct device** device) { @@ -24,12 +25,14 @@ void gpro_x2_init(struct device** device) device_gpro_x2.idProductsSupported = PRODUCT_IDS; device_gpro_x2.numIdProducts = sizeof(PRODUCT_IDS) / sizeof(PRODUCT_IDS[0]); - strncpy(device_gpro_x2.device_name, "Logitech G PRO X2", sizeof(device_gpro_x2.device_name)); + strncpy(device_gpro_x2.device_name, "Logitech G PRO X 2", sizeof(device_gpro_x2.device_name)); - device_gpro_x2.capabilities = B(CAP_SIDETONE); + device_gpro_x2.capabilities = B(CAP_SIDETONE) | B(CAP_INACTIVE_TIME); device_gpro_x2.capability_details[CAP_SIDETONE] = (struct capability_detail) { .usagepage = 0xffa0, .usageid = 0x1, .interface = 3 }; - + device_gpro_x2.capability_details[CAP_INACTIVE_TIME] = (struct capability_detail) { .usagepage = 0xffa0, .usageid = 0x1, .interface = 3 }; + device_gpro_x2.send_sidetone = &gpro_x2_send_sidetone; + device_gpro_x2.send_inactive_time = &gpro_x2_send_inactive_time; *device = &device_gpro_x2; } @@ -38,7 +41,14 @@ static int gpro_x2_send_sidetone(hid_device* device_handle, uint8_t num) { num = map(num, 0, 128, 0, 100); - uint8_t sidetone_data[12] = { 0x51, 0x0a, 0x00, 0x03, 0x1b, 0x00, 0x05, 0x00, 0x07, 0x1b, 0x01, num}; + uint8_t sidetone_data[12] = { 0x51, 0x0a, 0x00, 0x03, 0x1b, 0x00, 0x05, 0x00, 0x07, 0x1b, 0x01, num }; return hid_write(device_handle, sidetone_data, sizeof(sidetone_data) / sizeof(sidetone_data[0])); } + +static int gpro_x2_send_inactive_time(hid_device* device_handle, uint8_t num) +{ + uint8_t inactive_time_data[11] = { 0x51, 0x09, 0x00, 0x03, 0x1c, 0x00, 0x04, 0x00, 0x06, 0x1d, num }; + + return hid_write(device_handle, inactive_time_data, sizeof(inactive_time_data) / sizeof(inactive_time_data[0])); +} From bea29080f99af41e738e5e8def360136d2a06346 Mon Sep 17 00:00:00 2001 From: darkymtp Date: Thu, 21 Dec 2023 20:45:47 +0100 Subject: [PATCH 7/7] Update README.md Add Inactive time for G Pro X 2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc12c9b..97e2bfa 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ talking. This differs from a simple loopback via PulseAudio as you won't have an - Logitech G PRO - Sidetone, Battery, Inactive time - Logitech G PRO X 2 - - Sidetone + - Sidetone, Inactive time - Logitech Zone Wired/Zone 750 - Sidetone, Voice prompts, Rotate to mute - Roccat Elo 7.1 Air