Moved UI from C to Vala
Multiple changes coming with that Massive cleanup
This commit is contained in:
@@ -168,16 +168,8 @@ static bool is_connection_wireless(void* handle)
|
||||
return false;
|
||||
}
|
||||
|
||||
int driver_mouse_dpi_get(void* handle, struct MOUSE_DPI_LEVELS* output)
|
||||
int driver_mouse_dpi_get(void* handle, libusb_device_handle* hand, struct MOUSE* output)
|
||||
{
|
||||
libusb_device* dev = handle;
|
||||
|
||||
// Prepare usb device for transfer
|
||||
libusb_device_handle* hand;
|
||||
int openres = libusb_open(dev, &hand);
|
||||
if(openres) return -1;
|
||||
libusb_detach_kernel_driver(hand, 0x2);
|
||||
|
||||
// Send command
|
||||
struct REPORT_DPI_SETTINGS report = {0};
|
||||
int res = send_command(hand, COMMAND_DPI_SETTINGS, REPORT_DPI_SETTINGS_SIZE, &report, DEVICE_WIRELESS(handle));
|
||||
@@ -191,28 +183,18 @@ int driver_mouse_dpi_get(void* handle, struct MOUSE_DPI_LEVELS* output)
|
||||
output->xy_available = false;
|
||||
for(size_t i = 0; i < report.level_count; i++)
|
||||
{
|
||||
output->level[i].dpi_x = report.levels[i].dpi_x_high << 8 | report.levels[i].dpi_x_low;
|
||||
output->level[i].dpi_y = report.levels[i].dpi_y_high << 8 | report.levels[i].dpi_y_low;
|
||||
output->level[i].r = report.levels[i].led_r;
|
||||
output->level[i].g = report.levels[i].led_g;
|
||||
output->level[i].b = report.levels[i].led_b;
|
||||
output->dpi_x[i] = report.levels[i].dpi_x_high << 8 | report.levels[i].dpi_x_low;
|
||||
output->dpi_y[i] = report.levels[i].dpi_y_high << 8 | report.levels[i].dpi_y_low;
|
||||
output->r[i] = report.levels[i].led_r;
|
||||
output->g[i] = report.levels[i].led_g;
|
||||
output->b[i] = report.levels[i].led_b;
|
||||
}
|
||||
|
||||
libusb_attach_kernel_driver(hand, 0x2);
|
||||
libusb_close(hand);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int driver_mouse_motion_sync_get(void* handle, bool* output)
|
||||
int driver_mouse_motion_sync_get(void* handle, libusb_device_handle* hand, bool* output)
|
||||
{
|
||||
libusb_device* dev = handle;
|
||||
|
||||
// Prepare usb device for transfer
|
||||
libusb_device_handle* hand;
|
||||
int openres = libusb_open(dev, &hand);
|
||||
if(openres) return -1;
|
||||
libusb_detach_kernel_driver(hand, 0x2);
|
||||
|
||||
// Send command
|
||||
struct REPORT_MOTION_SYNC report = {0};
|
||||
int res = send_command(hand, COMMAND_MOTION_SYNC, REPORT_MOTION_SYNC_SIZE, &report, DEVICE_WIRELESS(handle));
|
||||
@@ -220,23 +202,11 @@ int driver_mouse_motion_sync_get(void* handle, bool* output)
|
||||
|
||||
// Format output boolean
|
||||
*output = report.motion_sync;
|
||||
|
||||
// Close and return
|
||||
libusb_attach_kernel_driver(hand, 0x2);
|
||||
libusb_close(hand);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int driver_mouse_angle_snap_get(void* handle, bool* output)
|
||||
int driver_mouse_angle_snap_get(void* handle, libusb_device_handle* hand, bool* output)
|
||||
{
|
||||
libusb_device* dev = handle;
|
||||
|
||||
// Prepare usb device for transfer
|
||||
libusb_device_handle* hand;
|
||||
int openres = libusb_open(dev, &hand);
|
||||
if(openres) return -1;
|
||||
libusb_detach_kernel_driver(hand, 0x2);
|
||||
|
||||
// Send command
|
||||
struct REPORT_ANGLE_SNAP report = {0};
|
||||
int res = send_command(hand, COMMAND_ANGLE_SNAP, REPORT_ANGLE_SNAP_SIZE, &report, DEVICE_WIRELESS(handle));
|
||||
@@ -244,8 +214,29 @@ int driver_mouse_angle_snap_get(void* handle, bool* output)
|
||||
|
||||
// Format output boolean
|
||||
*output = report.angle_snap;
|
||||
|
||||
// Close and return
|
||||
return 0;
|
||||
}
|
||||
|
||||
int driver_mouse_polling_rate_get(void* handle, libusb_device_handle* hand, struct MOUSE* output)
|
||||
{
|
||||
output->polling_rate_count = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int driver_mouse_get(void* handle, struct MOUSE* output)
|
||||
{
|
||||
// Prepare usb device for transfer
|
||||
libusb_device_handle* hand;
|
||||
int openres = libusb_open((libusb_device*) handle, &hand);
|
||||
if(openres) return -1;
|
||||
libusb_detach_kernel_driver(hand, 0x2);
|
||||
|
||||
// TODO : handle errors
|
||||
driver_mouse_dpi_get(handle, hand, output);
|
||||
driver_mouse_polling_rate_get(handle, hand, output);
|
||||
driver_mouse_motion_sync_get(handle, hand, output);
|
||||
driver_mouse_angle_snap_get(handle, hand, output);
|
||||
|
||||
libusb_attach_kernel_driver(hand, 0x2);
|
||||
libusb_close(hand);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user