driver g-wolves fix

master
vhaudiquet 1 year ago
parent ee60060dc6
commit bd42c93fa2
  1. 33
      drivers/g-wolves/g-wolves.c

@ -83,7 +83,7 @@ device_capacity_t driver_get_capacity(void* handle)
struct libusb_device_descriptor desc; struct libusb_device_descriptor desc;
libusb_get_device_descriptor(dev, &desc); libusb_get_device_descriptor(dev, &desc);
uint8_t wireless = 0; device_capacity_t wireless = 0;
switch(desc.idProduct) switch(desc.idProduct)
{ {
case HTX_4K_PRODUCT_ID_WIRED: case HTX_4K_PRODUCT_ID_WIRED:
@ -242,13 +242,27 @@ int driver_mouse_get(void* handle, struct MOUSE* output)
return 0; return 0;
} }
int driver_wireless_connection_type_get(void* handle, bool* output) int driver_wireless_connection_type_get(void* handle, struct WIRELESS* output)
{ {
*output = is_connection_wireless(handle); output->connection_wireless = is_connection_wireless(handle);
return 0; return 0;
} }
int driver_wireless_battery_state_get(void* handle, int* battery_level, bool* charging) int driver_wireless_battery_state_get(void* handle, libusb_device_handle* hand, struct WIRELESS* output)
{
// Send command
struct REPORT_BATTERY report = {0};
int res = send_command(hand, COMMAND_BATTERY, REPORT_BATTERY_SIZE, &report, DEVICE_WIRELESS(handle));
if(res <= 0) return -1;
// Format output values
output->battery_level = report.battery_level;
output->charging = report.battery_status;
return 0;
}
int driver_wireless_get(void* handle, struct WIRELESS* output)
{ {
libusb_device* dev = handle; libusb_device* dev = handle;
@ -258,14 +272,9 @@ int driver_wireless_battery_state_get(void* handle, int* battery_level, bool* ch
if(openres) return -1; if(openres) return -1;
libusb_detach_kernel_driver(hand, 0x2); libusb_detach_kernel_driver(hand, 0x2);
// Send command // TODO : handle errors
struct REPORT_BATTERY report = {0}; driver_wireless_battery_state_get(handle, hand, output);
int res = send_command(hand, COMMAND_BATTERY, REPORT_BATTERY_SIZE, &report, DEVICE_WIRELESS(handle)); driver_wireless_connection_type_get(handle, output);
if(res <= 0) return -1;
// Format output values
*battery_level = report.battery_level;
*charging = report.battery_status;
// Close and return // Close and return
libusb_attach_kernel_driver(hand, 0x2); libusb_attach_kernel_driver(hand, 0x2);

Loading…
Cancel
Save