|
|
|
@ -2,12 +2,187 @@ |
|
|
|
|
#include <stdint.h> |
|
|
|
|
#include <stddef.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include <libusb.h> |
|
|
|
|
#include <wchar.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
#define DEVICE_NAME "HTX 4K" |
|
|
|
|
#define DEVICE_VENDOR_ID 0x33e4 |
|
|
|
|
#define DEVICE_PRODUCT_ID_WIRED 0x5708 |
|
|
|
|
#define DEVICE_PRODUCT_ID_WIRELESS 0x5707 |
|
|
|
|
|
|
|
|
|
#define REPORT_MAX_SIZE 0x40 // 64 Bytes
|
|
|
|
|
|
|
|
|
|
#define REPORT_UNKNOWN_0_SIZE 0x2 |
|
|
|
|
#define REPORT_DPI_SETTINGS_SIZE 0x39 // 2b with old software, 5 profiles to 7 ?
|
|
|
|
|
#define REPORT_UNKNOWN_1_SIZE 0x2 |
|
|
|
|
#define REPORT_UNKNOWN_2_SIZE 0x24 |
|
|
|
|
#define REPORT_CLICK_DEBOUNCE_SETTINGS_SIZE 0x4 |
|
|
|
|
#define REPORT_LIFT_OFF_SIZE 0x1 |
|
|
|
|
#define REPORT_ANGLE_SNAP_SIZE 0x1 |
|
|
|
|
#define REPORT_MOTION_SYNC_SIZE 0x1 |
|
|
|
|
#define REPORT_UNKNOWN_6_SIZE 0x5 |
|
|
|
|
#define REPORT_BATTERY_SIZE 0x2 |
|
|
|
|
|
|
|
|
|
#define COMMAND_UNKNOWN_0 0x82 |
|
|
|
|
#define COMMAND_DPI_SETTINGS 0x83 |
|
|
|
|
#define COMMAND_UNKNOWN_1 0x92 |
|
|
|
|
#define COMMAND_UNKNOWN_2 0x84 |
|
|
|
|
#define COMMAND_CLICK_DEBOUNCE_SETTINGS 0x85 |
|
|
|
|
#define COMMAND_LIFT_OFF 0x86 |
|
|
|
|
#define COMMAND_ANGLE_SNAP 0x87 |
|
|
|
|
#define COMMAND_MOTION_SYNC 0x91 |
|
|
|
|
#define COMMAND_UNKNOWN_6 0x98 |
|
|
|
|
#define COMMAND_BATTERY 0x8F |
|
|
|
|
|
|
|
|
|
typedef struct HTX_DPI_LEVEL |
|
|
|
|
{ |
|
|
|
|
uint8_t dpi_x_high; |
|
|
|
|
uint8_t dpi_x_low; |
|
|
|
|
|
|
|
|
|
uint8_t dpi_y_high; |
|
|
|
|
uint8_t dpi_y_low; |
|
|
|
|
|
|
|
|
|
// LED color when this dpi level is selected
|
|
|
|
|
uint8_t led_r; |
|
|
|
|
uint8_t led_g; |
|
|
|
|
uint8_t led_b; |
|
|
|
|
} __attribute__((packed)) htx_dpi_level_t; |
|
|
|
|
|
|
|
|
|
typedef struct HTX_REPORT_HEADER |
|
|
|
|
{ |
|
|
|
|
uint8_t a1; // 0xa1: request_type on receive, 0x00 on set
|
|
|
|
|
|
|
|
|
|
uint8_t report_size; // report size, after header
|
|
|
|
|
uint8_t command; // COMMAND
|
|
|
|
|
uint8_t zero; // report ? other ?
|
|
|
|
|
} __attribute__((packed)) htx_report_header_t; |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_DPI_SETTINGS |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t level_current; // current dpi level
|
|
|
|
|
uint8_t level_count; // count of dpi levels
|
|
|
|
|
|
|
|
|
|
htx_dpi_level_t levels[5]; |
|
|
|
|
uint8_t zeros[23]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_UNKNOWN_0 |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t value0; |
|
|
|
|
uint8_t value1; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 2]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_UNKNOWN_1 |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t value0; |
|
|
|
|
uint8_t value1; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 2]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_CLICK_DEBOUNCE_SETTINGS |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
// A = 0ms B = 1 ms C = 2 ms D = 3 ms E = 4 ms
|
|
|
|
|
uint8_t debounce_preset; // 0x00 = A, 0x01 = B, 0x02 = C, 0x03 = D, 0x04 = E, AUTO = 0x00
|
|
|
|
|
uint8_t unknown_value; // 30d, 40d, or 50d (30 for A/B/C/AUTO) (40 for D) (50 for E)
|
|
|
|
|
uint8_t auto_high; // 0x23 for manual, 0x3C for auto
|
|
|
|
|
uint8_t auto_low; // 0x14 for manual, 0x28 for auto
|
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - 8]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_LIFT_OFF |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
// 1 = Low, 2 = High
|
|
|
|
|
uint8_t lift_off; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 1]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_ANGLE_SNAP |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
// 0 = disabled, 1 = enabled
|
|
|
|
|
uint8_t angle_snap; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 1]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_MOTION_SYNC |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t motion_sync; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 1]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_UNKNOWN_6 |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t value0; |
|
|
|
|
uint8_t value1; |
|
|
|
|
uint8_t value2; |
|
|
|
|
uint8_t value3; |
|
|
|
|
uint8_t value4; |
|
|
|
|
uint8_t value5; |
|
|
|
|
|
|
|
|
|
uint8_t zeros[64 - sizeof(htx_report_header_t) - 5]; |
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
struct HTX_REPORT_BATTERY |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t header; |
|
|
|
|
|
|
|
|
|
uint8_t battery_status; // 0 : not charging, 1 : charging
|
|
|
|
|
uint8_t battery_level; // in %
|
|
|
|
|
} __attribute__((packed)); |
|
|
|
|
|
|
|
|
|
static int htx_send_command(libusb_device_handle* hand, uint8_t command, uint8_t size, void* report) |
|
|
|
|
{ |
|
|
|
|
htx_report_header_t* head = report; |
|
|
|
|
head->report_size = size; |
|
|
|
|
head->command = command; |
|
|
|
|
|
|
|
|
|
// Send command
|
|
|
|
|
int res = libusb_control_transfer(hand, |
|
|
|
|
0x21, // request type
|
|
|
|
|
0x09, // request (SET_REPORT)
|
|
|
|
|
0x300, // wValue (FEATURE << 8 | REPORT(0))
|
|
|
|
|
0x2, // wIndex = 0x2 : interface
|
|
|
|
|
report, |
|
|
|
|
64, // wLength = 64
|
|
|
|
|
0 /* timeout*/); |
|
|
|
|
|
|
|
|
|
if(res <= 0) return res; |
|
|
|
|
|
|
|
|
|
// Get response report
|
|
|
|
|
res = libusb_control_transfer(hand, |
|
|
|
|
0xa1, // request type
|
|
|
|
|
0x01, // request (GET_REPORT)
|
|
|
|
|
0x300, // wValue (FEATURE << 8 | REPORT(0))
|
|
|
|
|
0x2, // wIndex = 0x2 : interface
|
|
|
|
|
report, |
|
|
|
|
64, // wLength = 64
|
|
|
|
|
0); |
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void driver_init(void) {} |
|
|
|
|
|
|
|
|
|
uint32_t driver_getkey(void) |
|
|
|
@ -23,12 +198,24 @@ uint32_t driver_getkey(void) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char* driver_get_name(void) |
|
|
|
|
char* driver_get_name(void* handle) |
|
|
|
|
{ |
|
|
|
|
return DEVICE_NAME; |
|
|
|
|
libusb_device* dev = handle; |
|
|
|
|
|
|
|
|
|
struct libusb_device_descriptor desc; |
|
|
|
|
libusb_get_device_descriptor(dev, &desc); |
|
|
|
|
|
|
|
|
|
switch(desc.idProduct) |
|
|
|
|
{ |
|
|
|
|
case 0x5708: |
|
|
|
|
case 0x5707: |
|
|
|
|
return "HTX 4K"; |
|
|
|
|
default: |
|
|
|
|
return "HTX ACE"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
char* driver_get_image(void) |
|
|
|
|
char* driver_get_image(void* handle) |
|
|
|
|
{ |
|
|
|
|
return "drivers/g-wolves/htx/htx_0.png"; |
|
|
|
|
} |
|
|
|
|