From a758542b6eeb0d7fdb503c01a83e27ccb7fd0cd4 Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Tue, 26 Sep 2023 21:51:51 +0200 Subject: [PATCH] driver: g-wolves htx added wireless --- drivers/g-wolves/htx/htx.c | 15 ++++++++++++++- drivers/g-wolves/htx/htx.h | 13 ++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/g-wolves/htx/htx.c b/drivers/g-wolves/htx/htx.c index c69b1bd..7dd108a 100644 --- a/drivers/g-wolves/htx/htx.c +++ b/drivers/g-wolves/htx/htx.c @@ -1,10 +1,23 @@ #include "htx.h" -static int htx_send_command(libusb_device_handle* hand, uint8_t command, uint8_t size, void* report) +static int htx_send_command(libusb_device_handle* hand, uint8_t command, uint8_t size, void* report, bool wireless) { + if(wireless) + { + // If wireless, ask receiver for mouse command first + struct HTX_REPORT_WIRELESS w_report = {0}; + int res = htx_send_command(hand, COMMAND_WIRELESS_MOUSE, REPORT_WIRELESS_MOUSE_SIZE, &w_report, false); + if(res <= 0) return res; + + if(!w_report.mouse_connected) + return -1; + } + htx_report_header_t* head = report; head->report_size = size; head->command = command; + if(wireless) + head->wireless = 0x1; // Send command int res = libusb_control_transfer(hand, diff --git a/drivers/g-wolves/htx/htx.h b/drivers/g-wolves/htx/htx.h index 121cb6b..f63951a 100644 --- a/drivers/g-wolves/htx/htx.h +++ b/drivers/g-wolves/htx/htx.h @@ -5,6 +5,7 @@ #include #include #include +#include #define DEVICE_VENDOR_ID 0x33e4 #define DEVICE_PRODUCT_ID_WIRED 0x5708 @@ -25,6 +26,7 @@ #define REPORT_MOTION_SYNC_SIZE 0x1 #define REPORT_UNKNOWN_6_SIZE 0x5 #define REPORT_BATTERY_SIZE 0x2 +#define REPORT_WIRELESS_MOUSE_SIZE 0x1 #define COMMAND_UNKNOWN_0 0x82 #define COMMAND_DPI_SETTINGS 0x83 @@ -36,6 +38,7 @@ #define COMMAND_MOTION_SYNC 0x91 #define COMMAND_UNKNOWN_6 0x98 #define COMMAND_BATTERY 0x8F +#define COMMAND_WIRELESS_MOUSE 0x90 // -> send the next report to mouse, checking if mouse is connected typedef struct HTX_DPI_LEVEL { @@ -57,7 +60,7 @@ typedef struct HTX_REPORT_HEADER uint8_t report_size; // report size, after header uint8_t command; // COMMAND - uint8_t zero; // report ? other ? + uint8_t wireless; // 0 on wired, 1 on wireless } __attribute__((packed)) htx_report_header_t; struct HTX_REPORT_DPI_SETTINGS @@ -156,3 +159,11 @@ struct HTX_REPORT_BATTERY uint8_t zeros[REPORT_MAX_SIZE - sizeof(htx_report_header_t) - 2]; } __attribute__((packed)); + +struct HTX_REPORT_WIRELESS +{ + htx_report_header_t header; + + uint8_t mouse_connected; // 0 if disconnected, else 1 + uint8_t zeros[REPORT_MAX_SIZE - sizeof(htx_report_header_t) - 1]; +} __attribute__((packed));