diff options
| -rw-r--r-- | src/include/razercommon.h | 27 | ||||
| -rw-r--r-- | src/include/razermouse_driver.h | 1 | ||||
| -rwxr-xr-x | src/lib/razerdevice.c | 1 | ||||
| -rw-r--r-- | src/lib/razermouse_driver.c | 62 |
4 files changed, 74 insertions, 17 deletions
diff --git a/src/include/razercommon.h b/src/include/razercommon.h index d478aba..56a5211 100644 --- a/src/include/razercommon.h +++ b/src/include/razercommon.h @@ -26,18 +26,19 @@ #define ON 0x01 // LED definitions -#define ZERO_LED 0x00 -#define SCROLL_WHEEL_LED 0x01 -#define BATTERY_LED 0x03 -#define LOGO_LED 0x04 -#define BACKLIGHT_LED 0x05 -#define MACRO_LED 0x07 -#define GAME_LED 0x08 -#define RED_PROFILE_LED 0x0C -#define GREEN_PROFILE_LED 0x0D -#define BLUE_PROFILE_LED 0x0E -#define RIGHT_SIDE_LED 0x10 -#define LEFT_SIDE_LED 0x11 +#define ZERO_LED 0x00 +#define SCROLL_WHEEL_LED 0x01 +#define BATTERY_LED 0x03 +#define LOGO_LED 0x04 +#define BACKLIGHT_LED 0x05 +#define MACRO_LED 0x07 +#define GAME_LED 0x08 +#define BASILISK_V3_BASE_LED 0x0A +#define RED_PROFILE_LED 0x0C +#define GREEN_PROFILE_LED 0x0D +#define BLUE_PROFILE_LED 0x0E +#define RIGHT_SIDE_LED 0x10 +#define LEFT_SIDE_LED 0x11 // LED STORAGE Options #define NOSTORE 0x00 @@ -90,7 +91,7 @@ union command_id_union { * Protocol Type is always 0x00 * Data Size is the size of payload, cannot be greater than 80. 90 = header (8B) + data + CRC (1B) + Reserved (1B) * Command Class is the type of command being issued - * Command ID is the type of command being send. Direction 0 is Host->Device, Direction 1 is Device->Host. AKA Get LED 0x80, Set LED 0x00 + * Command ID is the type of command being sent. Direction 0 is Host->Device, Direction 1 is Device->Host. AKA Get LED 0x80, Set LED 0x00 * * */ diff --git a/src/include/razermouse_driver.h b/src/include/razermouse_driver.h index d2e6dd1..5e2831a 100644 --- a/src/include/razermouse_driver.h +++ b/src/include/razermouse_driver.h @@ -73,6 +73,7 @@ #define USB_DEVICE_ID_RAZER_VIPER_MINI 0x008A #define USB_DEVICE_ID_RAZER_BASILISK_V2 0x0085 #define USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020 0x008D +#define USB_DEVICE_ID_RAZER_BASILISK_V3 0x0099 /* Each keyboard report has 90 bytes*/ #define RAZER_REPORT_LEN 0x5A diff --git a/src/lib/razerdevice.c b/src/lib/razerdevice.c index 1c184b4..b5523f4 100755 --- a/src/lib/razerdevice.c +++ b/src/lib/razerdevice.c @@ -132,6 +132,7 @@ bool is_mouse(IOUSBDeviceInterface **usb_dev) case USB_DEVICE_ID_RAZER_DEATHADDER_V2_MINI: case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_ATHERIS_RECEIVER: + case USB_DEVICE_ID_RAZER_BASILISK_V3: return true; } diff --git a/src/lib/razermouse_driver.c b/src/lib/razermouse_driver.c index 80a1bb7..61af518 100644 --- a/src/lib/razermouse_driver.c +++ b/src/lib/razermouse_driver.c @@ -50,7 +50,9 @@ static int razer_get_report(IOUSBDeviceInterface **usb_dev, struct razer_report (*usb_dev)->GetDeviceProduct(usb_dev, &product); switch (product) { - // These devices require longer waits to read their firmware, serial, and other setting values + case USB_DEVICE_ID_RAZER_BASILISK_V3: + return razer_get_usb_response(usb_dev, 0x03, request_report, 0x00, response_report, RAZER_NEW_MOUSE_RECEIVER_WAIT_MIN_US); + break; case USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS_RECEIVER: case USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS_WIRED: case USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS: @@ -88,6 +90,7 @@ static struct razer_report razer_send_payload(IOUSBDeviceInterface **usb_dev, st retval = razer_get_report(usb_dev, request_report, &response_report); + if(retval == 0) { // Check the packet number, class and command are the same if(response_report.remaining_packets != request_report->remaining_packets || @@ -98,8 +101,10 @@ static struct razer_report razer_send_payload(IOUSBDeviceInterface **usb_dev, st //printf("Device is busy (mouse)\n"); } else if (response_report.status == RAZER_CMD_FAILURE) { printf("Command failed (mouse)\n"); + printf("Contents of request_report are:\ncommand_class: %#04X\ncommand_id: %#04X\ntransaction_id: %#04X\n\n", (unsigned int) request_report->command_class, (unsigned int) request_report->command_id.id, (unsigned int) request_report->transaction_id.id); } else if (response_report.status == RAZER_CMD_NOT_SUPPORTED) { printf("Command not supported (mouse)\n"); + printf("Contents of request_report are:\ncommand_class: %#04X\ncommand_id: %#04X\ntransaction_id: %#04X\n\n", (unsigned int) request_report->command_class, (unsigned int) request_report->command_id.id, (unsigned int) request_report->transaction_id.id); } else if (response_report.status == RAZER_CMD_TIMEOUT) { printf("Command timed out (mouse)\n"); } @@ -107,6 +112,7 @@ static struct razer_report razer_send_payload(IOUSBDeviceInterface **usb_dev, st printf("Invalid Report Length (mouse)\n"); } + return response_report; } @@ -134,7 +140,10 @@ ssize_t razer_attr_write_side_mode_wave(IOUSBDeviceInterface **usb_dev, const ch report = razer_chroma_extended_matrix_effect_wave(VARSTORE, side, direction, 0x28); report.transaction_id.id = 0x1f; break; - + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_effect_wave(VARSTORE, BASILISK_V3_BASE_LED, direction, 0x28); + report.transaction_id.id = 0x1f; + break; default: printf("razermouse: logo_mode_wave not supported for this model\n"); return count; @@ -194,6 +203,11 @@ ssize_t razer_attr_write_side_mode_static(IOUSBDeviceInterface **usb_dev, const report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_effect_static(VARSTORE, BASILISK_V3_BASE_LED, (struct razer_rgb*)&buf[0]); + report.transaction_id.id = 0x1f; + break; + default: printf("razermouse: logo_mode_static not supported for this model\n"); return count; @@ -256,6 +270,11 @@ ssize_t razer_attr_write_side_mode_static_no_store(IOUSBDeviceInterface **usb_de report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_effect_static(VARSTORE, BASILISK_V3_BASE_LED, (struct razer_rgb*)&buf[0]); + report.transaction_id.id = 0x1f; + break; + default: printf("razermouse: side_mode_static_no_store not supported for this model\n"); return count; @@ -315,6 +334,11 @@ ssize_t razer_attr_write_side_mode_spectrum(IOUSBDeviceInterface **usb_dev, cons report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_effect_spectrum(VARSTORE, BASILISK_V3_BASE_LED); + report.transaction_id.id = 0x1f; + break; + default: printf("razermouse: side_mode_spectrum not supported for this model\n"); return count; @@ -457,9 +481,13 @@ ssize_t razer_attr_write_side_mode_none(IOUSBDeviceInterface **usb_dev, const ch report = razer_chroma_extended_matrix_effect_none(VARSTORE, side); report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_effect_none(VARSTORE, BASILISK_V3_BASE_LED); + report.transaction_id.id = 0x1f; + break; default: - printf("razermouse: logo_mode_none not supported for this model\n"); + printf("razermouse: side_mode_none not supported for this model\n"); return count; } @@ -493,6 +521,7 @@ ssize_t razer_attr_write_logo_mode_wave(IOUSBDeviceInterface **usb_dev, const ch case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_wave(VARSTORE, LOGO_LED, direction, 0x28); report.transaction_id.id = 0x1f; break; @@ -532,6 +561,7 @@ ssize_t razer_attr_write_scroll_mode_wave(IOUSBDeviceInterface **usb_dev, const case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_wave(VARSTORE, SCROLL_WHEEL_LED, direction, 0x28); report.transaction_id.id = 0x1f; break; @@ -616,6 +646,7 @@ ssize_t razer_attr_write_logo_mode_static(IOUSBDeviceInterface **usb_dev, const case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_static(VARSTORE, LOGO_LED, (struct razer_rgb*)&buf[0]); report.transaction_id.id = 0x1f; break; @@ -686,6 +717,7 @@ ssize_t razer_attr_write_scroll_mode_static(IOUSBDeviceInterface **usb_dev, cons case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_static(VARSTORE, SCROLL_WHEEL_LED, (struct razer_rgb*)&buf[0]); report.transaction_id.id = 0x1f; break; @@ -781,6 +813,7 @@ ssize_t razer_attr_write_logo_mode_static_no_store(IOUSBDeviceInterface **usb_de case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_static(NOSTORE, LOGO_LED, (struct razer_rgb*)&buf[0]); report.transaction_id.id = 0x1f; break; @@ -854,6 +887,7 @@ ssize_t razer_attr_write_scroll_mode_static_no_store(IOUSBDeviceInterface **usb_ case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_static(NOSTORE, SCROLL_WHEEL_LED, (struct razer_rgb*)&buf[0]); report.transaction_id.id = 0x1f; break; @@ -943,6 +977,7 @@ ssize_t razer_attr_write_logo_mode_spectrum(IOUSBDeviceInterface **usb_dev, cons case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_spectrum(VARSTORE, LOGO_LED); report.transaction_id.id = 0x1f; break; @@ -1003,6 +1038,7 @@ ssize_t razer_attr_write_scroll_mode_spectrum(IOUSBDeviceInterface **usb_dev, co case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_spectrum(VARSTORE, SCROLL_WHEEL_LED); report.transaction_id.id = 0x1f; break; @@ -1286,6 +1322,7 @@ ssize_t razer_attr_write_logo_mode_none(IOUSBDeviceInterface **usb_dev, const ch case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_none(VARSTORE, LOGO_LED); report.transaction_id.id = 0x1f; break; @@ -1349,6 +1386,7 @@ ssize_t razer_attr_write_scroll_mode_none(IOUSBDeviceInterface **usb_dev, const case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_effect_none(VARSTORE, SCROLL_WHEEL_LED); report.transaction_id.id = 0x1f; break; @@ -1575,7 +1613,6 @@ ssize_t razer_attr_write_side_mode_reactive(IOUSBDeviceInterface **usb_dev, cons report = razer_chroma_extended_matrix_effect_reactive(VARSTORE, side, speed, (struct razer_rgb*)&buf[1]); report.transaction_id.id = 0x1f; break; - default: printf("razermouse: left/right mode_reactive not supported for this model\n"); return count; @@ -1613,6 +1650,7 @@ ushort razer_attr_read_dpi(IOUSBDeviceInterface **usb_dev) { struct razer_report report, response_report; report = razer_chroma_misc_get_dpi_xy(0x01); + response_report = razer_send_payload(usb_dev, &report); ushort dpi_x = (response_report.arguments[1] << 8) | (response_report.arguments[2] & 0xFF); return dpi_x; @@ -1734,6 +1772,7 @@ ushort razer_attr_read_poll_rate(IOUSBDeviceInterface **usb_dev) case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_ATHERIS_RECEIVER: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report.transaction_id.id = 0x1f; break; } @@ -1823,6 +1862,7 @@ void razer_attr_write_poll_rate(IOUSBDeviceInterface **usb_dev, ushort polling_r case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_ATHERIS_RECEIVER: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report.transaction_id.id = 0x1f; break; } @@ -1958,6 +1998,7 @@ ushort razer_attr_read_scroll_led_brightness(IOUSBDeviceInterface **usb_dev) case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_get_brightness(VARSTORE, SCROLL_WHEEL_LED); report.transaction_id.id = 0x1f; break; @@ -2008,6 +2049,7 @@ void razer_attr_write_scroll_led_brightness(IOUSBDeviceInterface **usb_dev, unsi case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_brightness(VARSTORE, SCROLL_WHEEL_LED, brightness); report.transaction_id.id = 0x1f; break; @@ -2055,6 +2097,7 @@ ushort razer_attr_read_logo_led_brightness(IOUSBDeviceInterface **usb_dev) case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_get_brightness(VARSTORE, LOGO_LED); report.transaction_id.id = 0x1f; break; @@ -2114,6 +2157,7 @@ void razer_attr_write_logo_led_brightness(IOUSBDeviceInterface **usb_dev, unsign case USB_DEVICE_ID_RAZER_NAGA_LEFT_HANDED_2020: case USB_DEVICE_ID_RAZER_MAMBA_ELITE: case USB_DEVICE_ID_RAZER_BASILISK_V2: + case USB_DEVICE_ID_RAZER_BASILISK_V3: report = razer_chroma_extended_matrix_brightness(VARSTORE, LOGO_LED, brightness); report.transaction_id.id = 0x1f; break; @@ -2173,6 +2217,11 @@ ushort razer_attr_read_side_led_brightness(IOUSBDeviceInterface **usb_dev, int s report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_get_brightness(VARSTORE, BASILISK_V3_BASE_LED); + report.transaction_id.id = 0x1f; + break; + default: report = razer_chroma_standard_get_led_brightness(VARSTORE, side); break; @@ -2207,6 +2256,11 @@ void razer_attr_write_side_led_brightness(IOUSBDeviceInterface **usb_dev, unsign report.transaction_id.id = 0x1f; break; + case USB_DEVICE_ID_RAZER_BASILISK_V3: + report = razer_chroma_extended_matrix_brightness(VARSTORE, BASILISK_V3_BASE_LED, brightness); + report.transaction_id.id = 0x1f; + break; + default: report = razer_chroma_standard_set_led_brightness(VARSTORE, side, brightness); break; |
