diff options
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/razeraccessory_driver.h | 38 | ||||
| -rw-r--r-- | src/include/razerchromacommon.h | 127 | ||||
| -rw-r--r-- | src/include/razercommon.h | 122 | ||||
| -rwxr-xr-x | src/include/razerdevice.h | 53 | ||||
| -rw-r--r-- | src/include/razeregpu_driver.h | 29 | ||||
| -rwxr-xr-x | src/include/razerheadphone_driver.h | 26 | ||||
| -rw-r--r-- | src/include/razerkbd_driver.h | 158 | ||||
| -rw-r--r-- | src/include/razerkraken_driver.h | 176 | ||||
| -rw-r--r-- | src/include/razermouse_driver.h | 201 | ||||
| -rw-r--r-- | src/include/razermousedock_driver.h | 33 | ||||
| -rw-r--r-- | src/include/razermousemat_driver.h | 43 |
11 files changed, 1006 insertions, 0 deletions
diff --git a/src/include/razeraccessory_driver.h b/src/include/razeraccessory_driver.h new file mode 100644 index 0000000..95f721b --- /dev/null +++ b/src/include/razeraccessory_driver.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Terry Cain <terrys-home.co.uk> + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_ACCESSORY_H +#define __HID_RAZER_ACCESSORY_H + +#define USB_DEVICE_ID_RAZER_NOMMO_CHROMA 0x0517 +#define USB_DEVICE_ID_RAZER_NOMMO_PRO 0x0518 +#define USB_DEVICE_ID_RAZER_CHROMA_MUG 0x0F07 +#define USB_DEVICE_ID_RAZER_CHROMA_BASE 0x0F08 +#define USB_DEVICE_ID_RAZER_CHROMA_HDK 0x0F09 +#define USB_DEVICE_ID_RAZER_MOUSE_BUNGEE_V3_CHROMA 0x0F1D +#define USB_DEVICE_ID_RAZER_BASE_STATION_V2_CHROMA 0x0F20 + +#define RAZER_ACCESSORY_WAIT_MIN_US 600 +#define RAZER_ACCESSORY_WAIT_MAX_US 1000 + +ssize_t razer_accessory_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_accessory_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_accessory_attr_write_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count, int speed); +ssize_t razer_accessory_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_accessory_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ushort razer_accessory_attr_read_set_brightness(IOUSBDeviceInterface **usb_dev); +ssize_t razer_accessory_attr_write_set_brightness(IOUSBDeviceInterface **usb_dev, ushort brightness, size_t count); + + +#endif
\ No newline at end of file diff --git a/src/include/razerchromacommon.h b/src/include/razerchromacommon.h new file mode 100644 index 0000000..11dc18b --- /dev/null +++ b/src/include/razerchromacommon.h @@ -0,0 +1,127 @@ +#ifndef DRIVER_RAZERCHROMACOMMON_H_ +#define DRIVER_RAZERCHROMACOMMON_H_ +#include <string.h> +#include "razercommon.h" + +/* + * Standard Device Functions + */ +struct razer_report razer_chroma_standard_set_device_mode(unsigned char mode, unsigned char param); +struct razer_report razer_chroma_standard_get_device_mode(void); + +struct razer_report razer_chroma_standard_get_serial(void); + +struct razer_report razer_chroma_standard_get_firmware_version(void); + + +/* + * Standard LED Functions + */ +struct razer_report razer_chroma_standard_set_led_state(unsigned char variable_storage, unsigned char led_id, unsigned char led_state); +struct razer_report razer_chroma_standard_get_led_state(unsigned char variable_storage, unsigned char led_id); + +struct razer_report razer_chroma_standard_set_led_blinking(unsigned char variable_storage, unsigned char led_id); + +struct razer_report razer_chroma_standard_set_led_rgb(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_standard_get_led_rgb(unsigned char variable_storage, unsigned char led_id); + +struct razer_report razer_chroma_standard_set_led_effect(unsigned char variable_storage, unsigned char led_id, unsigned char led_effect); +struct razer_report razer_chroma_standard_get_led_effect(unsigned char variable_storage, unsigned char led_id); + +struct razer_report razer_chroma_standard_set_led_brightness(unsigned char variable_storage, unsigned char led_id, ushort brightness); +struct razer_report razer_chroma_standard_get_led_brightness(unsigned char variable_storage, unsigned char led_id); + +/* + * Standard Matrix Effects Functions + */ +struct razer_report razer_chroma_standard_matrix_effect_none(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_standard_matrix_effect_wave(unsigned char variable_storage, unsigned char led_id, unsigned char wave_direction); +struct razer_report razer_chroma_standard_matrix_effect_spectrum(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_standard_matrix_effect_reactive(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1); +struct razer_report razer_chroma_standard_matrix_effect_static(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_standard_matrix_effect_starlight_single(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1); +struct razer_report razer_chroma_standard_matrix_effect_starlight_dual(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1, struct razer_rgb *rgb2); +struct razer_report razer_chroma_standard_matrix_effect_starlight_random(unsigned char variable_storage, unsigned char led_id, unsigned char speed); + +struct razer_report razer_chroma_standard_matrix_effect_breathing_random(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_standard_matrix_effect_breathing_single(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_standard_matrix_effect_breathing_dual(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1, struct razer_rgb *rgb2); +struct razer_report razer_chroma_standard_matrix_effect_custom_frame(unsigned char variable_storage); +struct razer_report razer_chroma_standard_matrix_set_custom_frame(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char *rgb_data); + + +/* + * Extended Matrix Effects Functions + * + * Class 0x0F + * Trans 0x3F (Dev 0b001 Game Controller 1, Trans 0b11111) + */ +struct razer_report razer_chroma_extended_matrix_effect_none(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_extended_matrix_effect_static(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb); +struct razer_report razer_chroma_extended_matrix_effect_wave(unsigned char variable_storage, unsigned char led_id, unsigned char direction, int speed); +struct razer_report razer_chroma_extended_matrix_effect_starlight_random(unsigned char variable_storage, unsigned char led_id, unsigned char speed); +struct razer_report razer_chroma_extended_matrix_effect_starlight_single(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1); +struct razer_report razer_chroma_extended_matrix_effect_starlight_dual(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1, struct razer_rgb *rgb2); +struct razer_report razer_chroma_extended_matrix_effect_spectrum(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_extended_matrix_effect_reactive(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1); +struct razer_report razer_chroma_extended_matrix_effect_breathing_random(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_extended_matrix_effect_breathing_single(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_extended_matrix_effect_breathing_dual(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1, struct razer_rgb *rgb2); +struct razer_report razer_chroma_extended_matrix_effect_custom_frame(void); +struct razer_report razer_chroma_extended_matrix_brightness(unsigned char variable_storage, unsigned char led_id, unsigned char brightness); +struct razer_report razer_chroma_extended_matrix_get_brightness(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_extended_matrix_set_custom_frame(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char *rgb_data); +struct razer_report razer_chroma_extended_matrix_set_custom_frame2(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char *rgb_data, size_t packetLength); + +/* + * Extended Matrix Effects (Mouse) Functions + * + * Class 0x0D + * Trans 0x3F (not set) (Dev 0b001 Game Controller 1, Trans 0b11111) + */ +struct razer_report razer_chroma_mouse_extended_matrix_effect_none(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_mouse_extended_matrix_effect_static(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_mouse_extended_matrix_effect_spectrum(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_mouse_extended_matrix_effect_reactive(unsigned char variable_storage, unsigned char led_id, unsigned char speed, struct razer_rgb *rgb1); +struct razer_report razer_chroma_mouse_extended_matrix_effect_breathing_random(unsigned char variable_storage, unsigned char led_id); +struct razer_report razer_chroma_mouse_extended_matrix_effect_breathing_single(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1); +struct razer_report razer_chroma_mouse_extended_matrix_effect_breathing_dual(unsigned char variable_storage, unsigned char led_id, struct razer_rgb *rgb1, struct razer_rgb *rgb2); + + +/* + * Misc Functions + */ +struct razer_report razer_chroma_misc_fn_key_toggle(unsigned char state); + +struct razer_report razer_chroma_misc_set_blade_brightness(unsigned char brightness); +struct razer_report razer_chroma_misc_get_blade_brightness(void); + +struct razer_report razer_chroma_misc_one_row_set_custom_frame(unsigned char start_col, unsigned char stop_col, unsigned char *rgb_data); +struct razer_report razer_chroma_misc_matrix_reactive_trigger(void); + +struct razer_report razer_chroma_misc_get_battery_level(void); +struct razer_report razer_chroma_misc_get_charging_status(void); + +struct razer_report razer_chroma_misc_set_dock_charge_type(unsigned char charge_type); + +struct razer_report razer_chroma_misc_get_polling_rate(void); +struct razer_report razer_chroma_misc_set_polling_rate(unsigned short polling_rate); + +struct razer_report razer_chroma_misc_get_dock_brightness(void); +struct razer_report razer_chroma_misc_set_dock_brightness(unsigned char brightness); + +struct razer_report razer_chroma_misc_set_dpi_xy(unsigned char variable_storage, unsigned short dpi_x,unsigned short dpi_y); +struct razer_report razer_chroma_misc_get_dpi_xy(unsigned char variable_storage); + +struct razer_report razer_chroma_misc_set_dpi_xy_byte(unsigned char dpi_x,unsigned char dpi_y); +struct razer_report razer_chroma_misc_get_dpi_xy_byte(void); + +struct razer_report razer_chroma_misc_set_idle_time(unsigned short idle_time); +struct razer_report razer_chroma_misc_set_low_battery_threshold(unsigned char battery_threshold); + +struct razer_report razer_chroma_misc_set_orochi2011_led(unsigned char led_bitfield); +struct razer_report razer_chroma_misc_set_orochi2011_poll_dpi(unsigned short poll_rate, unsigned char dpi_x, unsigned char dpi_y); + +struct razer_report razer_naga_trinity_effect_static(struct razer_rgb* rgb); + +#endif diff --git a/src/include/razercommon.h b/src/include/razercommon.h new file mode 100644 index 0000000..d478aba --- /dev/null +++ b/src/include/razercommon.h @@ -0,0 +1,122 @@ +// +// razercommon.h +// RazerBlade +// +// + +#ifndef DRIVER_RAZERCOMMON_H_ +#define DRIVER_RAZERCOMMON_H_ + +#include <IOKit/usb/IOUSBLib.h> + +// Linux pre-process defintions +#define HID_REQ_GET_REPORT 0x01 +#define HID_REQ_SET_REPORT 0x09 + +#define USB_TYPE_CLASS (0x01 << 5) +#define USB_RECIP_INTERFACE 0x01 +#define USB_DIR_OUT 0 +#define USB_DIR_IN 0x80 + +/* Each USB report has 90 bytes*/ +#define RAZER_USB_REPORT_LEN 0x5A + +// LED STATE +#define OFF 0x00 +#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 + +// LED STORAGE Options +#define NOSTORE 0x00 +#define VARSTORE 0x01 + +// LED Effect definitions +#define LED_STATIC 0x00 +#define LED_BLINKING 0x01 +#define LED_PULSATING 0x02 +#define LED_SPECTRUM_CYCLING 0x04 + + +// Report Responses +#define RAZER_CMD_BUSY 0x01 +#define RAZER_CMD_SUCCESSFUL 0x02 +#define RAZER_CMD_FAILURE 0x03 +#define RAZER_CMD_TIMEOUT 0x04 +#define RAZER_CMD_NOT_SUPPORTED 0x05 + +struct razer_rgb { + unsigned char r,g,b; +}; + +union transaction_id_union { + unsigned char id; + struct transaction_parts { + unsigned char device : 3; + unsigned char id : 5; + } parts; +}; + +union command_id_union { + unsigned char id; + struct command_id_parts { + unsigned char direction : 1; + unsigned char id : 7; + } parts; +}; + +/* Status: + * 0x00 New Command + * 0x01 Command Busy + * 0x02 Command Successful + * 0x03 Command Failure + * 0x04 Command No Response / Command Timeout + * 0x05 Command Not Support + * + * Transaction ID used to group request-response, device useful when multiple devices are on one usb + * Remaining Packets is the number of remaining packets in the sequence + * 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 + * + * */ + +struct razer_report { + unsigned char status; + union transaction_id_union transaction_id; /* */ + unsigned short remaining_packets; /* Big Endian */ + unsigned char protocol_type; /*0x0*/ + unsigned char data_size; + unsigned char command_class; + union command_id_union command_id; + unsigned char arguments[80]; + unsigned char crc;/*xor'ed bytes of report*/ + unsigned char reserved; /*0x0*/ +}; + +IOReturn razer_send_control_msg(IOUSBDeviceInterface **dev, void const *data, uint report_index); +IOReturn razer_send_control_msg_old_device(IOUSBDeviceInterface **dev, void const *data, uint report_value, uint report_index, uint report_size); +IOReturn razer_get_usb_response(IOUSBDeviceInterface **dev, uint report_index, struct razer_report* request_report, uint response_index, struct razer_report* response_report, int wait_us); +unsigned char razer_calculate_crc(struct razer_report *report); +struct razer_report get_razer_report(unsigned char command_class, unsigned char command_id, unsigned char data_size); +struct razer_report get_empty_razer_report(void); + + +// Convenience functions +unsigned char clamp_u8(unsigned char value, unsigned char min, unsigned char max); +unsigned short clamp_u16(unsigned short value, unsigned short min, unsigned short max); + +#endif
\ No newline at end of file diff --git a/src/include/razerdevice.h b/src/include/razerdevice.h new file mode 100755 index 0000000..02dec29 --- /dev/null +++ b/src/include/razerdevice.h @@ -0,0 +1,53 @@ +// +// razerdevice.h +// Razer device query functions +// +// + +#ifndef DRIVER_RAZERDEVICE_H_ +#define DRIVER_RAZERDEVICE_H_ + +#include <IOKit/usb/IOUSBLib.h> +#include <IOKit/IOCFPlugIn.h> +#include <stdio.h> + +#include "razerkbd_driver.h" +#include "razermouse_driver.h" +#include "razermousedock_driver.h" +#include "razermousemat_driver.h" +#include "razerheadphone_driver.h" +#include "razeregpu_driver.h" +#include "razerkraken_driver.h" +#include "razeraccessory_driver.h" + +#define TYPE_KEYBOARD 0 +#define TYPE_BLADE 1 +#define TYPE_MOUSE 2 +#define TYPE_MOUSE_DOCK 3 +#define TYPE_MOUSE_MAT 4 +#define TYPE_EGPU 5 +#define TYPE_HEADPHONE 6 +#define TYPE_ACCESSORY 7 + +#ifndef USB_VENDOR_ID_RAZER +#define USB_VENDOR_ID_RAZER 0x1532 +#endif + +typedef struct { + IOUSBDeviceInterface **usbDevice; + UInt16 productId; + int internalDeviceId; +} RazerDevice; + +typedef struct { + RazerDevice *devices; + int size; +} RazerDevices; + +IOUSBDeviceInterface **getRazerUSBDeviceInterface(int type); +void closeRazerUSBDeviceInterface(IOUSBDeviceInterface **dev); + +RazerDevices getAllRazerDevices(); +void closeAllRazerDevices(RazerDevices devices); + +#endif
\ No newline at end of file diff --git a/src/include/razeregpu_driver.h b/src/include/razeregpu_driver.h new file mode 100644 index 0000000..1af0b93 --- /dev/null +++ b/src/include/razeregpu_driver.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Tim Theede <[email protected]> + * 2015 Terry Cain <[email protected]> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_EGPU_H +#define __HID_RAZER_EGPU_H + +#define USB_DEVICE_ID_RAZER_CORE_X_CHROMA 0x0f1a + +#define RAZER_EGPU_WAIT_MIN_US 900 +#define RAZER_EGPU_WAIT_MAX_US 1000 + +ssize_t razer_egpu_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_egpu_attr_write_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_egpu_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_egpu_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_egpu_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_egpu_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +#endif
\ No newline at end of file diff --git a/src/include/razerheadphone_driver.h b/src/include/razerheadphone_driver.h new file mode 100755 index 0000000..4505079 --- /dev/null +++ b/src/include/razerheadphone_driver.h @@ -0,0 +1,26 @@ +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_HEADPHONE_H +#define __HID_RAZER_HEADPHONE_H + +#define USB_DEVICE_ID_RAZER_KRAKEN_KITTY_EDITION 0x0F19 + +#define RAZER_HEADPHONE_WAIT_MIN_US 600 +#define RAZER_HEADPHONE_WAIT_MAX_US 1000 + +struct razer_headphone_device { + struct usb_device *usbdev; + struct hid_device *hiddev; + unsigned char effect; + char name[128]; + char phys[64]; +}; + +ssize_t razer_headphone_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_headphone_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_headphone_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_headphone_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_headphone_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +#endif diff --git a/src/include/razerkbd_driver.h b/src/include/razerkbd_driver.h new file mode 100644 index 0000000..fcb4706 --- /dev/null +++ b/src/include/razerkbd_driver.h @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2015 Tim Theede <[email protected]> + * 2015 Terry Cain <terrys-home.co.uk> + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_KBD_H +#define __HID_RAZER_KBD_H + +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2012 0x010D +// 2011 or so edition, see https://web.archive.org/web/20111113132427/http://store.razerzone.com:80/store/razerusa/en_US/pd/productID.235228400/categoryId.49136200/parentCategoryId.35156900 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_STEALTH_EDITION 0x010E +#define USB_DEVICE_ID_RAZER_ANANSI 0x010F +#define USB_DEVICE_ID_RAZER_NOSTROMO 0x0111 +#define USB_DEVICE_ID_RAZER_ORBWEAVER 0x0113 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2013 0x011A +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_STEALTH 0x011B +#define USB_DEVICE_ID_RAZER_TARTARUS 0x0201 +#define USB_DEVICE_ID_RAZER_DEATHSTALKER_EXPERT 0x0202 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA 0x0203 +#define USB_DEVICE_ID_RAZER_DEATHSTALKER_CHROMA 0x0204 +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH 0x0205 +#define USB_DEVICE_ID_RAZER_ORBWEAVER_CHROMA 0x0207 +#define USB_DEVICE_ID_RAZER_TARTARUS_CHROMA 0x0208 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA_TE 0x0209 +#define USB_DEVICE_ID_RAZER_BLADE_QHD 0x020F +#define USB_DEVICE_ID_RAZER_BLADE_PRO_LATE_2016 0x0210 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_OVERWATCH 0x0211 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_ULTIMATE_2016 0x0214 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_X_CHROMA 0x0216 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_X_ULTIMATE 0x0217 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_X_CHROMA_TE 0x021A +#define USB_DEVICE_ID_RAZER_ORNATA_CHROMA 0x021E +#define USB_DEVICE_ID_RAZER_ORNATA 0x021F +#define USB_DEVICE_ID_RAZER_ORNATA_CHROMA_V2 0x025D +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH_LATE_2016 0x0220 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_CHROMA_V2 0x0221 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_V3 0x024e +#define USB_DEVICE_ID_RAZER_BLADE_LATE_2016 0x0224 +#define USB_DEVICE_ID_RAZER_BLADE_PRO_2017 0x0225 +#define USB_DEVICE_ID_RAZER_HUNTSMAN_ELITE 0x0226 +#define USB_DEVICE_ID_RAZER_HUNTSMAN 0x0227 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_ELITE 0x0228 +#define USB_DEVICE_ID_RAZER_CYNOSA_CHROMA 0x022A +#define USB_DEVICE_ID_RAZER_TARTARUS_V2 0x022B +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH_MID_2017 0x022D +#define USB_DEVICE_ID_RAZER_BLADE_PRO_2017_FULLHD 0x022F +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH_LATE_2017 0x0232 +#define USB_DEVICE_ID_RAZER_BLADE_2018 0x0233 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_LITE 0x0235 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_ESSENTIAL 0x0237 +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH_2019 0x0239 +#define USB_DEVICE_ID_RAZER_BLADE_2019_ADV 0x023a +#define USB_DEVICE_ID_RAZER_BLADE_2018_BASE 0x023b +#define USB_DEVICE_ID_RAZER_BLADE_2018_MERCURY 0x0240 +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_2019 0x0241 +#define USB_DEVICE_ID_RAZER_HUNTSMAN_TE 0x0243 +#define USB_DEVICE_ID_RAZER_BLADE_MID_2019_MERCURY 0x0245 +#define USB_DEVICE_ID_RAZER_BLADE_2019_BASE 0x0246 +#define USB_DEVICE_ID_RAZER_BLADE_STEALTH_LATE_2019 0x024a +#define USB_DEVICE_ID_RAZER_BLADE_STUDIO_EDITION_2019 0x024d +#define USB_DEVICE_ID_RAZER_CYNOSA_V2 0x025E +#define USB_DEVICE_ID_RAZER_CYNOSA_LITE 0x023F +#define USB_DEVICE_ID_RAZER_BLACKWIDOW_V3_TK 0x0a24 +#define USB_DEVICE_ID_RAZER_HUNTSMAN_MINI 0x0257 + +/* Each keyboard report has 90 bytes*/ +#define RAZER_BLACKWIDOW_REPORT_LEN 0x5A + +#define RAZER_BLACKWIDOW_CHROMA_WAVE_DIRECTION_LEFT 2 +#define RAZER_BLACKWIDOW_CHROMA_WAVE_DIRECTION_RIGHT 1 + +#define RAZER_BLACKWIDOW_CHROMA_CHANGE_EFFECT 0x0A + +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_NONE 0 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_WAVE 1 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_REACTIVE 2 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_BREATH 3 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_SPECTRUM 4 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_CUSTOM 5 // draw frame +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_STATIC 6 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_CLEAR_ROW 8 + +#define RAZER_BLACKWIDOW_ULTIMATE_2016_EFFECT_STARLIGHT 0x19 + + +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_SET_KEYS 9 //update profile needs to be called after setting keys to reflect changes +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_RESET 10 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN 11 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN2 12 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN3 13 +#define RAZER_BLACKWIDOW_CHROMA_EFFECT_UNKNOWN4 14 + + +#define RAZER_BLACKWIDOW_CHROMA_ROW_LEN 0x16 +#define RAZER_BLACKWIDOW_CHROMA_ROWS_NUM 6 + + +#define RAZER_STEALTH_ROW_LEN 0x10 +#define RAZER_STEALTH_ROWS_NUM 6 + + + +#define RAZER_BLACKWIDOW_CHROMA_WAIT_MS 1 +#define RAZER_BLACKWIDOW_CHROMA_WAIT_MIN_US 600 +#define RAZER_BLACKWIDOW_CHROMA_WAIT_MAX_US 800 + +#define RAZER_FIREFLY_WAIT_MIN_US 900 +#define RAZER_FIREFLY_WAIT_MAX_US 1000 + + +// struct razer_kbd_device { +// IOUSBDeviceInterface **usbdev; +// unsigned int fn_on; +// char name[128]; +// char phys[64]; + +// unsigned char block_keys[3]; +// unsigned char left_alt_on; +// }; + +bool is_blade_laptop(IOUSBDeviceInterface **usb_dev); + +ssize_t razer_attr_read_mode_game(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_write_mode_macro(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_macro_effect(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_read_mode_macro_effect(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_write_mode_pulsate(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_read_mode_pulsate(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_read_tartarus_profile_led_red(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_read_tartarus_profile_led_green(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_read_tartarus_profile_led_blue(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_read_get_firmware_version(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, int count, int speed); +ssize_t razer_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_starlight(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_read_set_logo(IOUSBDeviceInterface **usb_dev, char *buf, int count); +ssize_t razer_attr_write_set_logo(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_mode_custom(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_set_fn_toggle(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +ssize_t razer_attr_write_set_brightness(IOUSBDeviceInterface **usb_dev, ushort brightness, int count); +ushort razer_attr_read_set_brightness(IOUSBDeviceInterface **usb_dev); +ssize_t razer_attr_write_matrix_custom_frame(IOUSBDeviceInterface **usb_dev, const char *buf, int count); +#endif diff --git a/src/include/razerkraken_driver.h b/src/include/razerkraken_driver.h new file mode 100644 index 0000000..bcf4431 --- /dev/null +++ b/src/include/razerkraken_driver.h @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2015 Terry Cain <terrys-home.co.uk> + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_KRAKEN_H +#define __HID_RAZER_KRAKEN_H + + +#define USB_DEVICE_ID_RAZER_KRAKEN_CLASSIC 0x0501 +// Codename Rainie +#define USB_DEVICE_ID_RAZER_KRAKEN 0x0504 +// Codename Unknown +#define USB_DEVICE_ID_RAZER_KRAKEN_CLASSIC_ALT 0x0506 +// Codename Kylie +#define USB_DEVICE_ID_RAZER_KRAKEN_V2 0x0510 +// Codename Unknown +#define USB_DEVICE_ID_RAZER_KRAKEN_ULTIMATE 0x0527 + +#define USB_INTERFACE_PROTOCOL_NONE 0 + +// #define RAZER_KRAKEN_V2_REPORT_LEN ? + +struct razer_kraken_device { + unsigned char usb_interface_protocol; + unsigned short usb_pid; + unsigned short usb_vid; + + // Will be set with the correct address for setting LED mode for each device + unsigned short led_mode_address; + unsigned short custom_address; + unsigned short breathing_address[3]; + + char serial[23]; + // 3 Bytes, first byte is whether fw version is collected, 2nd byte is major version, 3rd is minor, should be printed out in hex form as are bcd + unsigned char firmware_version[3]; + + char data[33]; + +}; + +union razer_kraken_effect_byte { + unsigned char value; + struct razer_kraken_effect_byte_bits { + unsigned char on_off_static :1; + unsigned char single_colour_breathing :1; + unsigned char spectrum_cycling :1; + unsigned char sync :1; + unsigned char two_colour_breathing :1; + unsigned char three_colour_breathing :1; + } bits; +}; + +/* + * Should wait 15ms per write to EEPROM + * + * Report ID: + * 0x04 - Output ID for memory access + * 0x05 - Input ID for memory access result + * + * Destination: + * 0x20 - Read data from EEPROM + * 0x40 - Write data to RAM + * 0x00 - Read data from RAM + * + * Address: + * RAM - Both + * 0x1189 - Custom effect Colour1 Red + * 0x118A - Custom effect Colour1 Green + * 0x118B - Custom effect Colour1 Blue + * 0x118C - Custom effect Colour1 Intensity + * + * RAM - Kylie + * 0x172D - Set LED Effect, see note 1 + * 0x1741 - Static/Breathing1 Colour1 Red + * 0x1742 - Static/Breathing1 Colour1 Green + * 0x1743 - Static/Breathing1 Colour1 Blue + * 0x1744 - Static/Breathing1 Colour1 Intensity + * + * 0x1745 - Breathing2 Colour1 Red + * 0x1746 - Breathing2 Colour1 Green + * 0x1747 - Breathing2 Colour1 Blue + * 0x1748 - Breathing2 Colour1 Intensity + * 0x1749 - Breathing2 Colour2 Red + * 0x174A - Breathing2 Colour2 Green + * 0x174B - Breathing2 Colour2 Blue + * 0x174C - Breathing2 Colour2 Intensity + * + * 0x174D - Breathing3 Colour1 Red + * 0x174E - Breathing3 Colour1 Green + * 0x174F - Breathing3 Colour1 Blue + * 0x1750 - Breathing3 Colour1 Intensity + * 0x1751 - Breathing3 Colour2 Red + * 0x1752 - Breathing3 Colour2 Green + * 0x1753 - Breathing3 Colour2 Blue + * 0x1754 - Breathing3 Colour2 Intensity + * 0x1755 - Breathing3 Colour3 Red + * 0x1756 - Breathing3 Colour3 Green + * 0x1757 - Breathing3 Colour3 Blue + * 0x1758 - Breathing3 Colour3 Intensity + * + * RAM - Rainie + * 0x1008 - Set LED Effect, see note 1 + * 0x15DE - Static/Breathing1 Colour1 Red + * 0x15DF - Static/Breathing1 Colour1 Green + * 0x15E0 - Static/Breathing1 Colour1 Blue + * 0x15E1 - Static/Breathing1 Colour1 Intensity + * + * EEPROM + * 0x0030 - Firmware version, 2 byted BCD + * 0x7f00 - Serial Number - 22 Bytes + * + * + * Note 1: + * Takes one byte which is a bitfield (0 being the rightmost byte 76543210) + * - Bit 0 = LED ON/OFF = 1/0 Static + * - Bit 1 = Single Colour Breathing ON/OFF, 1/0 + * - Bit 2 = Spectrum Cycling + * - Bit 3 = Sync = 1 + * - Bit 4 = 2 Colour breathing ON/OFF = 1/0 + * - Bit 5 = 3 Colour breathing ON/OFF = 1/0 + * E.g. + * 7 6 5 4 3 2 1 0 + * 128 64 32 16 8 4 2 1 + * ===================================================== + * 0 0 0 0 0 1 0 1 0x05 Spectrum Cycling on + * + * Note 2: + * Razer Kraken Classic uses 0x1008 for Logo LED on off. + * */ + +#define KYLIE_SET_LED_ADDRESS 0x172D +#define RAINIE_SET_LED_ADDRESS 0x1008 + +#define KYLIE_CUSTOM_ADDRESS_START 0x1189 +#define RAINIE_CUSTOM_ADDRESS_START 0x1189 + +#define KYLIE_BREATHING1_ADDRESS_START 0x1741 +#define RAINIE_BREATHING1_ADDRESS_START 0x15DE + +#define KYLIE_BREATHING2_ADDRESS_START 0x1745 +#define KYLIE_BREATHING3_ADDRESS_START 0x174D + + +struct razer_kraken_request_report { + unsigned char report_id; + unsigned char destination; + unsigned char length; + unsigned char addr_h; + unsigned char addr_l; + unsigned char arguments[32]; +}; + +struct razer_kraken_response_report { + unsigned char report_id; + unsigned char arguments[36]; +}; + + + +ssize_t razer_kraken_attr_write_mode_none(IOUSBDeviceInterface **dev, const char *buf, size_t count); +ssize_t razer_kraken_attr_write_mode_static(IOUSBDeviceInterface **dev, const char *buf, size_t count); +ssize_t razer_kraken_attr_write_mode_custom(IOUSBDeviceInterface **dev, const char *buf, size_t count); +ssize_t razer_kraken_attr_write_mode_breath(IOUSBDeviceInterface **dev, const char *buf, size_t count); +ssize_t razer_kraken_attr_write_mode_spectrum(IOUSBDeviceInterface **dev, const char *buf, size_t count); + +#endif
\ No newline at end of file diff --git a/src/include/razermouse_driver.h b/src/include/razermouse_driver.h new file mode 100644 index 0000000..992de3a --- /dev/null +++ b/src/include/razermouse_driver.h @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2015 Terry Cain <[email protected]> + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_MOUSE_H +#define __HID_RAZER_MOUSE_H + +#define USB_DEVICE_ID_RAZER_OROCHI_2011 0x0013 +#define USB_DEVICE_ID_RAZER_DEATHADDER_3_5G 0x0016 +#define USB_DEVICE_ID_RAZER_ABYSSUS_1800 0x0020 +#define USB_DEVICE_ID_RAZER_MAMBA_2012_WIRED 0x0024 +#define USB_DEVICE_ID_RAZER_MAMBA_2012_WIRELESS 0x0025 +#define USB_DEVICE_ID_RAZER_NAGA_2012 0x002E +#define USB_DEVICE_ID_RAZER_IMPERATOR 0x002F +#define USB_DEVICE_ID_RAZER_OUROBOROS 0x0032 +#define USB_DEVICE_ID_RAZER_TAIPAN 0x0034 +#define USB_DEVICE_ID_RAZER_NAGA_HEX_RED 0x0036 +#define USB_DEVICE_ID_RAZER_DEATHADDER_2013 0x0037 +#define USB_DEVICE_ID_RAZER_DEATHADDER_1800 0x0038 +#define USB_DEVICE_ID_RAZER_OROCHI_2013 0x0039 +#define USB_DEVICE_ID_RAZER_NAGA_2014 0x0040 +#define USB_DEVICE_ID_RAZER_NAGA_HEX 0x0041 +#define USB_DEVICE_ID_RAZER_ABYSSUS 0x0042 +#define USB_DEVICE_ID_RAZER_DEATHADDER_CHROMA 0x0043 +#define USB_DEVICE_ID_RAZER_MAMBA_WIRED 0x0044 +#define USB_DEVICE_ID_RAZER_MAMBA_WIRELESS 0x0045 +#define USB_DEVICE_ID_RAZER_MAMBA_TE_WIRED 0x0046 +#define USB_DEVICE_ID_RAZER_OROCHI_CHROMA 0x0048 +#define USB_DEVICE_ID_RAZER_DIAMONDBACK_CHROMA 0x004C +#define USB_DEVICE_ID_RAZER_NAGA_HEX_V2 0x0050 +#define USB_DEVICE_ID_RAZER_NAGA_CHROMA 0x0053 +#define USB_DEVICE_ID_RAZER_DEATHADDER_3500 0x0054 +#define USB_DEVICE_ID_RAZER_LANCEHEAD_WIRED 0x0059 +#define USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS 0x005A +#define USB_DEVICE_ID_RAZER_ABYSSUS_V2 0x005B +#define USB_DEVICE_ID_RAZER_DEATHADDER_ELITE 0x005C +#define USB_DEVICE_ID_RAZER_ABYSSUS_2000 0x005E +#define USB_DEVICE_ID_RAZER_LANCEHEAD_TE_WIRED 0x0060 +#define USB_DEVICE_ID_RAZER_ATHERIS_RECEIVER 0x0062 +#define USB_DEVICE_ID_RAZER_BASILISK 0x0064 +#define USB_DEVICE_ID_RAZER_BASILISK_ULTIMATE 0x0086 +#define USB_DEVICE_ID_RAZER_BASILISK_ULTIMATE_RECEIVER 0x0088 +#define USB_DEVICE_ID_RAZER_NAGA_TRINITY 0x0067 +#define USB_DEVICE_ID_RAZER_ABYSSUS_ELITE_DVA_EDITION 0x006A +#define USB_DEVICE_ID_RAZER_ABYSSUS_ESSENTIAL 0x006B +#define USB_DEVICE_ID_RAZER_MAMBA_ELITE 0x006C +#define USB_DEVICE_ID_RAZER_DEATHADDER_ESSENTIAL 0x006E +#define USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS_RECEIVER 0x006F +#define USB_DEVICE_ID_RAZER_LANCEHEAD_WIRELESS_WIRED 0x0070 +#define USB_DEVICE_ID_RAZER_DEATHADDER_ESSENTIAL_WHITE_EDITION 0x0071 +#define USB_DEVICE_ID_RAZER_MAMBA_WIRELESS_RECEIVER 0x0072 +#define USB_DEVICE_ID_RAZER_MAMBA_WIRELESS_WIRED 0x0073 +#define USB_DEVICE_ID_RAZER_VIPER 0x0078 +#define USB_DEVICE_ID_RAZER_VIPER_8KHZ 0x0091 +#define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRED 0x007A +#define USB_DEVICE_ID_RAZER_VIPER_ULTIMATE_WIRELESS 0x007B +#define USB_DEVICE_ID_RAZER_DEATHADDER_V2_PRO_WIRED 0x007C +#define USB_DEVICE_ID_RAZER_DEATHADDER_V2_PRO_WIRELESS 0x007D +#define USB_DEVICE_ID_RAZER_DEATHADDER_V2 0x0084 +#define USB_DEVICE_ID_RAZER_DEATHADDER_V2_MINI 0x008C +#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 + +/* Each keyboard report has 90 bytes*/ +#define RAZER_REPORT_LEN 0x5A + +#define RAZER_MAMBA_ROW_LEN 15 // 0 => 14 +#define RAZER_MAMBA_TE_ROW_LEN 16 // 0 => 15 +#define RAZER_DIAMONDBACK_ROW_LEN 21 // 0 => 20 + +#define RAZER_MOUSE_WAIT_MIN_US 600 +#define RAZER_MOUSE_WAIT_MAX_US 800 + +#define RAZER_NEW_MOUSE_RECEIVER_WAIT_MIN_US 31000 +#define RAZER_NEW_MOUSE_RECEIVER_WAIT_MAX_US 31100 + +#define RAZER_VIPER_MOUSE_RECEIVER_WAIT_MIN_US 59900 +#define RAZER_VIPER_MOUSE_RECEIVER_WAIT_MAX_US 60000 + +// struct razer_mouse_device { +// IOUSBDeviceInterface **usbdev; +// // Need to use macOS kernel lock +// // struct mutex lock; +// unsigned char usb_interface_protocol; +// unsigned char usb_interface_subclass; + +// unsigned short usb_vid; +// unsigned short usb_pid; + +// char serial[23]; // Now storing a random serial to be used with old devices that don't support it + +// unsigned char orochi2011_led; +// unsigned char orochi2011_dpi; +// unsigned short orochi2011_poll; + +// // The DeathAdder 3.5G, uses OR logic so need to remember last values. Part of a 4byte payload +// struct { +// unsigned char poll; +// unsigned char dpi; +// unsigned char profile; +// unsigned char leds; +// } da3_5g; +// }; + +// Mamba Key Location +// 0 => 6 ---> top left => bottom left +// 7 => 13 ---> top right => bottom right +// 14 ---> Scroll LED + +// Mamba TE Key Location +// 0 => 6 ---> top left => bottom left +// 7 => 13 ---> top right => bottom right +// 14 ---> Logo LED +// 15 ---> Scroll LED + +typedef struct { + unsigned char poll; + unsigned char dpi; + unsigned char profile; + unsigned char leds; +} DeathAdder3_5g; + +ssize_t razer_attr_write_logo_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_left_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_write_logo_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_side_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count, int side); +ssize_t razer_attr_write_left_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_right_mode_reactive(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ushort razer_attr_read_dpi(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_dpi(IOUSBDeviceInterface **usb_dev, ushort dpi_x, ushort dpi_y); + +// Poll +ushort razer_attr_read_poll_rate(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_poll_rate(IOUSBDeviceInterface **usb_dev, ushort polling_rate); + +// Brightness +ushort razer_attr_read_matrix_brightness(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_matrix_brightness(IOUSBDeviceInterface **usb_dev, unsigned char brightness); + +ushort razer_attr_read_scroll_led_brightness(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_scroll_led_brightness(IOUSBDeviceInterface **usb_dev, unsigned char brightness); + +ushort razer_attr_read_logo_led_brightness(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_logo_led_brightness(IOUSBDeviceInterface **usb_dev, unsigned char brightness); + +ushort razer_attr_read_left_led_brightness(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_left_led_brightness(IOUSBDeviceInterface **usb_dev, unsigned char brightness); + +ushort razer_attr_read_right_led_brightness(IOUSBDeviceInterface **usb_dev); +void razer_attr_write_right_led_brightness(IOUSBDeviceInterface **usb_dev, unsigned char brightness); + +// Older mouse +ssize_t razer_attr_write_logo_led_effect(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_scroll_led_effect(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_attr_write_logo_led_rgb(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +ssize_t razer_attr_read_get_battery(IOUSBDeviceInterface **usb_dev, char *buf); +ssize_t razer_attr_read_is_charging(IOUSBDeviceInterface **usb_dev, char *buf); + +#endif
\ No newline at end of file diff --git a/src/include/razermousedock_driver.h b/src/include/razermousedock_driver.h new file mode 100644 index 0000000..9b4a4d8 --- /dev/null +++ b/src/include/razermousedock_driver.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Terry Cain <[email protected]> + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_MOUSE_DOCK_H +#define __HID_RAZER_MOUSE_DOCK_H + +#define USB_DEVICE_ID_RAZER_MOUSE_CHARGING_DOCK 0x007E + +/* Each report has 90 bytes*/ +#define RAZER_REPORT_LEN 0x5A + +#define RAZER_MOUSE_DOCK_WAIT_MIN_US 600 +#define RAZER_MOUSE_DOCK_WAIT_MAX_US 800 + + +ssize_t razer_mouse_dock_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_dock_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_dock_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_dock_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_dock_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); + +#endif
\ No newline at end of file diff --git a/src/include/razermousemat_driver.h b/src/include/razermousemat_driver.h new file mode 100644 index 0000000..faed11a --- /dev/null +++ b/src/include/razermousemat_driver.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015 Tim Theede <[email protected]> + * 2015 Terry Cain <[email protected]> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include <IOKit/IOKitLib.h> +#include <IOKit/usb/IOUSBLib.h> + +#ifndef __HID_RAZER_MOUSEMAT_H +#define __HID_RAZER_MOUSEMAT_H + +#define USB_DEVICE_ID_RAZER_FIREFLY_HYPERFLUX 0x0068 +#define USB_DEVICE_ID_RAZER_FIREFLY 0x0C00 +#define USB_DEVICE_ID_RAZER_FIREFLY_V2 0x0c04 +#define USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA 0x0C01 +#define USB_DEVICE_ID_RAZER_GOLIATHUS_CHROMA_EXTENDED 0x0C02 + +#define RAZER_MOUSEMAT_WAIT_MIN_US 900 +#define RAZER_MOUSEMAT_WAIT_MAX_US 1000 + +struct razer_mousemat_device { + struct usb_device *usbdev; + struct hid_device *hiddev; + unsigned char effect; + char name[128]; + char phys[64]; +}; + +ssize_t razer_mouse_mat_attr_write_mode_none(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_mode_wave(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_mode_breath(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_mode_static(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_mode_static_no_store(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_mode_spectrum(IOUSBDeviceInterface **usb_dev, const char *buf, size_t count); +ssize_t razer_mouse_mat_attr_write_set_brightness(IOUSBDeviceInterface **usb_dev, ushort brightness, size_t count); +ushort razer_mouse_mat_attr_read_set_brightness(IOUSBDeviceInterface **usb_dev); + +#endif
\ No newline at end of file |
