Update to OpenRazer-Win32 API, device attribute pointers are now filled in by the driver during device probe, so we don't need to fill them in manually by device type anymore
This commit is contained in:
parent
0703bcd0a8
commit
427c635ed8
7 changed files with 295 additions and 306 deletions
|
|
@ -15,6 +15,91 @@
|
|||
#define OPENRAZERDLL "OpenRazer.dll"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct device_attribute* dev_attr_list[44];
|
||||
} device_fn_list_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| This is a table of device attribute names. It should |
|
||||
| always match the order of the entries in the structure |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* device_fn_names[] =
|
||||
{
|
||||
"device_type",
|
||||
"device_serial",
|
||||
"firmware_version",
|
||||
|
||||
"matrix_custom_frame",
|
||||
"matrix_brightness",
|
||||
|
||||
"matrix_effect_custom",
|
||||
"matrix_effect_none",
|
||||
"matrix_effect_static",
|
||||
"matrix_effect_breath",
|
||||
"matrix_effect_spectrum",
|
||||
"matrix_effect_reactive",
|
||||
"matrix_effect_wave",
|
||||
|
||||
"logo_led_brightness",
|
||||
"logo_matrix_effect_none",
|
||||
"logo_matrix_effect_static",
|
||||
"logo_matrix_effect_breath",
|
||||
"logo_matrix_effect_spectrum",
|
||||
"logo_matrix_effect_reactive",
|
||||
|
||||
"scroll_led_brightness",
|
||||
"scroll_matrix_effect_none",
|
||||
"scroll_matrix_effect_static",
|
||||
"scroll_matrix_effect_breath",
|
||||
"scroll_matrix_effect_spectrum",
|
||||
"scroll_matrix_effect_reactive",
|
||||
|
||||
"left_led_brightness",
|
||||
"left_matrix_effect_none",
|
||||
"left_matrix_effect_static",
|
||||
"left_matrix_effect_breath",
|
||||
"left_matrix_effect_spectrum",
|
||||
"left_matrix_effect_reactive",
|
||||
"left_matrix_effect_wave",
|
||||
|
||||
"right_led_brightness",
|
||||
"right_matrix_effect_none",
|
||||
"right_matrix_effect_static",
|
||||
"right_matrix_effect_breath",
|
||||
"right_matrix_effect_spectrum",
|
||||
"right_matrix_effect_reactive",
|
||||
"right_matrix_effect_wave",
|
||||
|
||||
"logo_led_effect",
|
||||
"logo_led_rgb",
|
||||
"logo_led_state",
|
||||
|
||||
"scroll_led_effect",
|
||||
"scroll_led_rgb",
|
||||
"scroll_led_state"
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| This function searches the device attribute list of a |
|
||||
| given device to fill in a device_fn_type structure |
|
||||
\*---------------------------------------------------------*/
|
||||
static void load_device_fn(device_fn_type* device_fn, device* dev)
|
||||
{
|
||||
memset(device_fn, 0, sizeof(device_fn_type));
|
||||
|
||||
for (int table_idx = 0; table_idx < 44; table_idx++)
|
||||
{
|
||||
for (int list_idx = 0; list_idx < dev->attr_count; list_idx++)
|
||||
{
|
||||
if (strcmp(device_fn_names[table_idx], dev->attr_list[list_idx]->name) == 0)
|
||||
{
|
||||
((device_fn_list_type*)device_fn)->dev_attr_list[table_idx] = dev->attr_list[list_idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
|
|
@ -32,105 +117,22 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
return;
|
||||
}
|
||||
|
||||
// map DLL calls
|
||||
/*---------------------------------------------------------*\
|
||||
| Map DLL functions |
|
||||
\*---------------------------------------------------------*/
|
||||
typedef unsigned int(*INITRAZERDRIVER)(struct hid_device** hdev);
|
||||
|
||||
INITRAZERDRIVER init_razer_kbd_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kbd_driver"));
|
||||
static struct device_attribute devkbd_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_type"));
|
||||
static struct device_attribute devkbd_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_serial"));
|
||||
static struct device_attribute devkbd_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_firmware_version"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devkbd_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devkbd_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_brightness"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_none"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_static"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devkbd_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_mousemat_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mousemat_driver"));
|
||||
static struct device_attribute devmousemat_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_type"));
|
||||
static struct device_attribute devmousemat_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_serial"));
|
||||
static struct device_attribute devmousemat_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_firmware_version"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devmousemat_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devmousemat_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_brightness"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_none"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_static"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devmousemat_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_mouse_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mouse_driver"));
|
||||
static struct device_attribute devmouse_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_type"));
|
||||
static struct device_attribute devmouse_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_serial"));
|
||||
static struct device_attribute devmouse_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_firmware_version"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devmouse_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devmouse_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_brightness"));
|
||||
static struct device_attribute devmouse_attr_logo_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_led_brightness"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_brightness"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_none"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_static"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_spectrum"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_logo_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_scroll_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_reactive"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_effect = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_effect"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_rgb = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_rgb"));
|
||||
static struct device_attribute devmouse_attr_scroll_led_state = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_state"));
|
||||
static struct device_attribute devmouse_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_accessory_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_accessory_driver"));
|
||||
static struct device_attribute devaccessory_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_type"));
|
||||
static struct device_attribute devaccessory_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_serial"));
|
||||
static struct device_attribute devaccessory_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_firmware_version"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devaccessory_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devaccessory_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_brightness"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_none"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_static"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_spectrum"));
|
||||
//static struct device_attribute devaccessory_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devaccessory_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_wave"));
|
||||
|
||||
INITRAZERDRIVER init_razer_kraken_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kraken_driver"));
|
||||
static struct device_attribute devkraken_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_type"));
|
||||
static struct device_attribute devkraken_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_serial"));
|
||||
static struct device_attribute devkraken_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_firmware_version"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_custom"));
|
||||
//static struct device_attribute devkraken_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_custom_frame"));
|
||||
//static struct device_attribute devkraken_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_brightness"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_none"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_static"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devkraken_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_spectrum"));
|
||||
|
||||
INITRAZERDRIVER init_razer_core_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_core_driver"));
|
||||
static struct device_attribute devcore_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_type"));
|
||||
static struct device_attribute devcore_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_serial"));
|
||||
static struct device_attribute devcore_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_firmware_version"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_custom"));
|
||||
static struct device_attribute devcore_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_custom_frame"));
|
||||
static struct device_attribute devcore_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_brightness"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_none"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_static"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_breath"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_spectrum"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_reactive"));
|
||||
static struct device_attribute devcore_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_wave"));
|
||||
|
||||
struct hid_device* hdev;
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize all OpenRazer driver modules and store devices |
|
||||
\*---------------------------------------------------------*/
|
||||
struct hid_device* hdev;
|
||||
unsigned int num;
|
||||
|
||||
hdev = NULL;
|
||||
|
|
@ -138,30 +140,8 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devkbd_attr_device_type;
|
||||
device_fn->device_serial = &devkbd_attr_device_serial;
|
||||
device_fn->firmware_version = &devkbd_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devkbd_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devkbd_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devkbd_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devkbd_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devkbd_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devkbd_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devkbd_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devkbd_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devkbd_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
if(razer_rgb->device_index != -1)
|
||||
|
|
@ -179,30 +159,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devmouse_attr_device_type;
|
||||
device_fn->device_serial = &devmouse_attr_device_serial;
|
||||
device_fn->firmware_version = &devmouse_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devmouse_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devmouse_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devmouse_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devmouse_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devmouse_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devmouse_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devmouse_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devmouse_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devmouse_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
|
@ -221,30 +178,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devmousemat_attr_device_type;
|
||||
device_fn->device_serial = &devmousemat_attr_device_serial;
|
||||
device_fn->firmware_version = &devmousemat_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devmousemat_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devmousemat_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devmousemat_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devmousemat_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devmousemat_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devmousemat_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devmousemat_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devmousemat_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devmousemat_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
|
@ -263,30 +197,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devaccessory_attr_device_type;
|
||||
device_fn->device_serial = &devaccessory_attr_device_serial;
|
||||
device_fn->firmware_version = &devaccessory_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devaccessory_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devaccessory_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devaccessory_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devaccessory_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devaccessory_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devaccessory_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devaccessory_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = NULL;//&devaccessory_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devaccessory_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
|
@ -305,30 +216,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devkraken_attr_device_type;
|
||||
device_fn->device_serial = &devkraken_attr_device_serial;
|
||||
device_fn->firmware_version = &devkraken_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devkraken_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = NULL;//&devkraken_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = NULL;//&devkraken_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devkraken_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devkraken_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devkraken_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devkraken_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = NULL;//&devkraken_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = NULL;//&devkraken_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
|
@ -347,30 +235,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
device_fn_type* device_fn = new device_fn_type;
|
||||
device_fn->device_type = &devcore_attr_device_type;
|
||||
device_fn->device_serial = &devcore_attr_device_serial;
|
||||
device_fn->firmware_version = &devcore_attr_firmware_version;
|
||||
device_fn->matrix_effect_custom = &devcore_attr_matrix_effect_custom;
|
||||
device_fn->matrix_custom_frame = &devcore_attr_matrix_custom_frame;
|
||||
device_fn->matrix_brightness = &devcore_attr_matrix_brightness;
|
||||
device_fn->matrix_effect_none = &devcore_attr_matrix_effect_none;
|
||||
device_fn->matrix_effect_static = &devcore_attr_matrix_effect_static;
|
||||
device_fn->matrix_effect_breath = &devcore_attr_matrix_effect_breath;
|
||||
device_fn->matrix_effect_spectrum = &devcore_attr_matrix_effect_spectrum;
|
||||
device_fn->matrix_effect_reactive = &devcore_attr_matrix_effect_reactive;
|
||||
device_fn->matrix_effect_wave = &devcore_attr_matrix_effect_wave;
|
||||
device_fn->logo_led_brightness = NULL;
|
||||
device_fn->logo_matrix_effect_none = NULL;
|
||||
device_fn->logo_matrix_effect_static = NULL;
|
||||
device_fn->logo_matrix_effect_spectrum = NULL;
|
||||
device_fn->logo_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_brightness = NULL;
|
||||
device_fn->scroll_matrix_effect_none = NULL;
|
||||
device_fn->scroll_matrix_effect_static = NULL;
|
||||
device_fn->scroll_matrix_effect_spectrum = NULL;
|
||||
device_fn->scroll_matrix_effect_reactive = NULL;
|
||||
device_fn->scroll_led_effect = NULL;
|
||||
device_fn->scroll_led_rgb = NULL;
|
||||
load_device_fn(device_fn, &hdev[i].dev);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,37 +17,58 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
struct device_attribute * device_type;
|
||||
struct device_attribute * device_serial;
|
||||
struct device_attribute * firmware_version;
|
||||
struct device_attribute* device_type;
|
||||
struct device_attribute* device_serial;
|
||||
struct device_attribute* firmware_version;
|
||||
|
||||
struct device_attribute * matrix_custom_frame;
|
||||
struct device_attribute * matrix_brightness;
|
||||
struct device_attribute* matrix_custom_frame;
|
||||
struct device_attribute* matrix_brightness;
|
||||
|
||||
struct device_attribute * matrix_effect_custom;
|
||||
struct device_attribute * matrix_effect_none;
|
||||
struct device_attribute * matrix_effect_static;
|
||||
struct device_attribute * matrix_effect_breath;
|
||||
struct device_attribute * matrix_effect_spectrum;
|
||||
struct device_attribute * matrix_effect_reactive;
|
||||
struct device_attribute * matrix_effect_wave;
|
||||
struct device_attribute* matrix_effect_custom;
|
||||
struct device_attribute* matrix_effect_none;
|
||||
struct device_attribute* matrix_effect_static;
|
||||
struct device_attribute* matrix_effect_breath;
|
||||
struct device_attribute* matrix_effect_spectrum;
|
||||
struct device_attribute* matrix_effect_reactive;
|
||||
struct device_attribute* matrix_effect_wave;
|
||||
|
||||
struct device_attribute * logo_led_brightness;
|
||||
struct device_attribute * logo_matrix_effect_none;
|
||||
struct device_attribute * logo_matrix_effect_static;
|
||||
struct device_attribute * logo_matrix_effect_breath;
|
||||
struct device_attribute * logo_matrix_effect_spectrum;
|
||||
struct device_attribute * logo_matrix_effect_reactive;
|
||||
struct device_attribute* logo_led_brightness;
|
||||
struct device_attribute* logo_matrix_effect_none;
|
||||
struct device_attribute* logo_matrix_effect_static;
|
||||
struct device_attribute* logo_matrix_effect_breath;
|
||||
struct device_attribute* logo_matrix_effect_spectrum;
|
||||
struct device_attribute* logo_matrix_effect_reactive;
|
||||
|
||||
struct device_attribute * scroll_led_brightness;
|
||||
struct device_attribute * scroll_matrix_effect_none;
|
||||
struct device_attribute * scroll_matrix_effect_static;
|
||||
struct device_attribute * scroll_matrix_effect_breath;
|
||||
struct device_attribute * scroll_matrix_effect_spectrum;
|
||||
struct device_attribute * scroll_matrix_effect_reactive;
|
||||
struct device_attribute* scroll_led_brightness;
|
||||
struct device_attribute* scroll_matrix_effect_none;
|
||||
struct device_attribute* scroll_matrix_effect_static;
|
||||
struct device_attribute* scroll_matrix_effect_breath;
|
||||
struct device_attribute* scroll_matrix_effect_spectrum;
|
||||
struct device_attribute* scroll_matrix_effect_reactive;
|
||||
|
||||
struct device_attribute * scroll_led_effect;
|
||||
struct device_attribute * scroll_led_rgb;
|
||||
struct device_attribute* left_led_brightness;
|
||||
struct device_attribute* left_matrix_effect_none;
|
||||
struct device_attribute* left_matrix_effect_static;
|
||||
struct device_attribute* left_matrix_effect_breath;
|
||||
struct device_attribute* left_matrix_effect_spectrum;
|
||||
struct device_attribute* left_matrix_effect_reactive;
|
||||
struct device_attribute* left_matrix_effect_wave;
|
||||
|
||||
struct device_attribute* right_led_brightness;
|
||||
struct device_attribute* right_matrix_effect_none;
|
||||
struct device_attribute* right_matrix_effect_static;
|
||||
struct device_attribute* right_matrix_effect_breath;
|
||||
struct device_attribute* right_matrix_effect_spectrum;
|
||||
struct device_attribute* right_matrix_effect_reactive;
|
||||
struct device_attribute* right_matrix_effect_wave;
|
||||
|
||||
struct device_attribute* logo_led_effect;
|
||||
struct device_attribute* logo_led_rgb;
|
||||
struct device_attribute* logo_led_state;
|
||||
|
||||
struct device_attribute* scroll_led_effect;
|
||||
struct device_attribute* scroll_led_rgb;
|
||||
struct device_attribute* scroll_led_state;
|
||||
} device_fn_type;
|
||||
|
||||
class RGBController_OpenRazer : public RGBController
|
||||
|
|
|
|||
BIN
dependencies/openrazer-win32/OpenRazer.dll
vendored
BIN
dependencies/openrazer-win32/OpenRazer.dll
vendored
Binary file not shown.
BIN
dependencies/openrazer-win32/OpenRazer64.dll
vendored
BIN
dependencies/openrazer-win32/OpenRazer64.dll
vendored
Binary file not shown.
140
dependencies/openrazer-win32/linux/hid.h
vendored
140
dependencies/openrazer-win32/linux/hid.h
vendored
|
|
@ -22,8 +22,12 @@
|
|||
#define HID_REQ_GET_REPORT 0x01
|
||||
#define HID_REQ_SET_REPORT 0x09
|
||||
|
||||
#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
|
||||
#define USB_INTERFACE_PROTOCOL_MOUSE 2
|
||||
//#define USB_INTERFACE_PROTOCOL_KEYBOARD 1
|
||||
//#define USB_INTERFACE_PROTOCOL_MOUSE 2
|
||||
|
||||
//Hack to make detection work without having to install WinUSB on the correct interface
|
||||
#define USB_INTERFACE_PROTOCOL_KEYBOARD 0
|
||||
#define USB_INTERFACE_PROTOCOL_MOUSE 0
|
||||
|
||||
static const GUID GUID_DEVINTERFACE = { 0xDEE824EF, 0x729B, 0x4A0E, 0x9C, 0x14, 0xB7, 0x11, 0x7D, 0x33, 0xA8, 0x17 };
|
||||
|
||||
|
|
@ -185,9 +189,18 @@ inline void close(struct device* dev) {
|
|||
|
||||
inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, struct hid_driver hdr) {
|
||||
|
||||
for (unsigned int i = 0; hdr.id_table[i].vendor != 0; i++) {
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all vendor IDs in ID table of header |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for (unsigned int i = 0; hdr.id_table[i].vendor != 0; i++)
|
||||
{
|
||||
/*-------------------------------------------------------------*\
|
||||
| Get device information set |
|
||||
\*-------------------------------------------------------------*/
|
||||
HDEVINFO hDevInfo = SetupDiGetClassDevs(&GUID_DEVINTERFACE, 0, 0, DIGCF_DEVICEINTERFACE);
|
||||
if (hDevInfo == INVALID_HANDLE_VALUE) {
|
||||
|
||||
if (hDevInfo == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("SetupDiGetClassDevs failed\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -195,33 +208,76 @@ inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, st
|
|||
SP_DEVINFO_DATA deviceData = { 0 };
|
||||
deviceData.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||
|
||||
for (unsigned int j = 0; SetupDiEnumDeviceInfo(hDevInfo, j, &deviceData); ++j) {
|
||||
/*-------------------------------------------------------------*\
|
||||
| Loop through all device information entries in set |
|
||||
\*-------------------------------------------------------------*/
|
||||
for (unsigned int j = 0; SetupDiEnumDeviceInfo(hDevInfo, j, &deviceData); ++j)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device ID string from device information |
|
||||
\*---------------------------------------------------------*/
|
||||
char deviceID[MAX_DEVICE_ID_LEN];
|
||||
|
||||
if (CM_Get_Device_ID(deviceData.DevInst, deviceID, MAX_DEVICE_ID_LEN, 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Parse USB VID out of device ID string |
|
||||
| Move on to the next device if the VID does not match |
|
||||
\*---------------------------------------------------------*/
|
||||
char* vid = strstr(deviceID, "VID_");
|
||||
if (!vid || hdr.id_table[i].vendor != strtoul(vid+4, NULL, 16))
|
||||
continue;
|
||||
|
||||
if (!vid || hdr.id_table[i].vendor != strtoul(vid + 4, NULL, 16))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Parse USB PID out of device ID string |
|
||||
| Move on to the next device if the PID does not match |
|
||||
\*---------------------------------------------------------*/
|
||||
char* pid = strstr(deviceID, "PID_");
|
||||
if (!pid || hdr.id_table[i].product != strtoul(pid+4, NULL, 16))
|
||||
continue;
|
||||
|
||||
if (!pid || hdr.id_table[i].product != strtoul(pid + 4, NULL, 16))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Enumerate device interface data for this device |
|
||||
\*---------------------------------------------------------*/
|
||||
SP_INTERFACE_DEVICE_DATA interfaceData = { 0 };
|
||||
interfaceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA);
|
||||
if (!SetupDiEnumDeviceInterfaces(hDevInfo, &deviceData, &GUID_DEVINTERFACE, 0, &interfaceData))
|
||||
continue;
|
||||
|
||||
if (!SetupDiEnumDeviceInterfaces(hDevInfo, &deviceData, &GUID_DEVINTERFACE, 0, &interfaceData))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device interface detail size |
|
||||
\*---------------------------------------------------------*/
|
||||
DWORD dwRequiredSize = 0;
|
||||
SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, 0, 0, &dwRequiredSize, 0);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a buffer of required size and load the device |
|
||||
| interface detail information into the buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
SP_INTERFACE_DEVICE_DETAIL_DATA* pData = (SP_INTERFACE_DEVICE_DETAIL_DATA*)malloc(dwRequiredSize);
|
||||
pData->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
|
||||
if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, pData, dwRequiredSize, 0, 0)) {
|
||||
|
||||
if (!SetupDiGetDeviceInterfaceDetail(hDevInfo, &interfaceData, pData, dwRequiredSize, 0, 0))
|
||||
{
|
||||
free(pData);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open a handle to the device |
|
||||
\*---------------------------------------------------------*/
|
||||
HANDLE hDevice = CreateFile(pData->DevicePath
|
||||
, GENERIC_READ | GENERIC_WRITE
|
||||
, FILE_SHARE_READ | FILE_SHARE_WRITE
|
||||
|
|
@ -229,29 +285,51 @@ inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, st
|
|||
, OPEN_EXISTING
|
||||
, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED
|
||||
, 0);
|
||||
if (hDevice == INVALID_HANDLE_VALUE) {
|
||||
|
||||
if (hDevice == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(pData);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Open a WinUSB handle from the device handle |
|
||||
\*---------------------------------------------------------*/
|
||||
WINUSB_INTERFACE_HANDLE hWinUSBHandle;
|
||||
if (!WinUsb_Initialize(hDevice, &hWinUSBHandle))
|
||||
continue;
|
||||
|
||||
if (!WinUsb_Initialize(hDevice, &hWinUSBHandle))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the device information set |
|
||||
\*---------------------------------------------------------*/
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Print debug message indicating device is opened |
|
||||
\*---------------------------------------------------------*/
|
||||
printf("CM_Get_Device_ID (%s)\n", deviceID);
|
||||
printf("device %04X:%04X opened!\n", hdr.id_table[i].vendor, hdr.id_table[i].product);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create or resize HID device struct buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
*hdev = (struct hid_device*)realloc(*hdev, (*numHdev+1) * sizeof(struct hid_device));
|
||||
if (!*hdev) {
|
||||
|
||||
if (!*hdev)
|
||||
{
|
||||
printf("out of memory\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If there are hdev entries from previous loop iterations, |
|
||||
| copy the data from the previous location to the new. |
|
||||
\*---------------------------------------------------------*/
|
||||
if (*numHdev > 0)
|
||||
{
|
||||
//Correct all previous pointers to their new locations
|
||||
for (int old_dev = 0; old_dev < *numHdev; old_dev++)
|
||||
{
|
||||
(*hdev)[old_dev].dev.parent = &((*hdev)[old_dev].dev);
|
||||
|
|
@ -260,11 +338,30 @@ inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, st
|
|||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Allocate buffer for USB interface and USB host interface |
|
||||
| structures |
|
||||
\*---------------------------------------------------------*/
|
||||
struct usb_interface* intf = (struct usb_interface*)malloc(sizeof(struct usb_interface));
|
||||
intf->cur_altsetting = (struct usb_host_interface*)malloc(sizeof(struct usb_host_interface));
|
||||
intf->cur_altsetting->desc.bInterfaceProtocol = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the interface protocol for this device |
|
||||
| Get this information from the interface descriptor |
|
||||
\*---------------------------------------------------------*/
|
||||
//USB_INTERFACE_DESCRIPTOR interface_descriptor;
|
||||
//WinUsb_QueryInterfaceSettings(hWinUSBHandle, 0, &interface_descriptor);
|
||||
|
||||
intf->cur_altsetting->desc.bInterfaceProtocol = 0;// interface_descriptor.bInterfaceProtocol;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Allocate buffer for USB device structure |
|
||||
\*---------------------------------------------------------*/
|
||||
struct usb_device *usbdevice = (struct usb_device*)malloc(sizeof(struct usb_device));
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up USB device and interface structures |
|
||||
\*---------------------------------------------------------*/
|
||||
usbdevice->descriptor.idVendor = hdr.id_table[i].vendor;
|
||||
usbdevice->descriptor.idProduct = hdr.id_table[i].product;
|
||||
|
||||
|
|
@ -276,11 +373,11 @@ inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, st
|
|||
(*hdev)[*numHdev].dev.p = hWinUSBHandle;
|
||||
(*hdev)[*numHdev].dev.parent_usb_interface = intf;
|
||||
(*hdev)[*numHdev].dev.init_name = hdr.name;
|
||||
(*hdev)[*numHdev].dev.attr_count = 0;
|
||||
|
||||
usbdevice->dev = &((*hdev)[*numHdev].dev);
|
||||
intf->dev = &((*hdev)[*numHdev].dev);
|
||||
|
||||
|
||||
(*hdev)[*numHdev].status = 2;
|
||||
(*hdev)[*numHdev].driver = &hdr;
|
||||
(*hdev)[*numHdev].ll_driver = (struct hid_ll_driver*)malloc(sizeof(struct hid_ll_driver));
|
||||
|
|
@ -288,12 +385,17 @@ inline void openChromaDevice(struct hid_device** hdev, unsigned int* numHdev, st
|
|||
(*hdev)[*numHdev].ll_driver->start = ll_start;
|
||||
(*hdev)[*numHdev].ll_driver->stop = ll_stop;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Call the OpenRazer driver probe function |
|
||||
\*---------------------------------------------------------*/
|
||||
(*hdev)[*numHdev].driver->probe(&((*hdev)[*numHdev]), &(hdr.id_table[i]));
|
||||
|
||||
(*numHdev)++;
|
||||
}
|
||||
if (!numHdev)
|
||||
{
|
||||
printf("device %04X:%04X NOT opened!\n", hdr.id_table[i].vendor, hdr.id_table[i].product);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
22
dependencies/openrazer-win32/linux/init.h
vendored
22
dependencies/openrazer-win32/linux/init.h
vendored
|
|
@ -1,28 +1,6 @@
|
|||
#ifndef INIT_H_
|
||||
#define INIT_H_
|
||||
|
||||
static inline int sprint_f(char* buf, const char* fmt, ...) {
|
||||
va_list args;
|
||||
int i;
|
||||
va_start(args, fmt);
|
||||
i = sprintf_s(buf, strlen(buf) - 1, fmt, args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
#define sprintf sprint_f
|
||||
|
||||
static inline int strncpy_f(char* dest, const char* source, const size_t sourceLen) {
|
||||
return strncpy_s(dest, strlen(dest) - 1, source, sourceLen);
|
||||
}
|
||||
#define strncpy strncpy_f
|
||||
|
||||
static inline int strcpy_f(char* dest, const char* source) {
|
||||
return strcpy_s(dest, strlen(dest) - 1, source);
|
||||
}
|
||||
#define strcpy strcpy_f
|
||||
|
||||
#define strdup _strdup
|
||||
|
||||
#define KERN_WARNING
|
||||
#define KERN_ALERT
|
||||
#define KERN_CRIT
|
||||
|
|
|
|||
33
dependencies/openrazer-win32/linux/module.h
vendored
33
dependencies/openrazer-win32/linux/module.h
vendored
|
|
@ -35,6 +35,8 @@ struct device {
|
|||
void *p;
|
||||
const char *init_name;
|
||||
void *driver_data;
|
||||
unsigned int attr_count;
|
||||
struct device_attribute * attr_list[64];
|
||||
struct usb_interface *parent_usb_interface;
|
||||
};
|
||||
|
||||
|
|
@ -65,6 +67,9 @@ inline int usb_control_msg(
|
|||
, unsigned char* buf, unsigned int size
|
||||
, unsigned int timeout)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy Linux API arguments into WinUSB format message |
|
||||
\*---------------------------------------------------------*/
|
||||
WINUSB_SETUP_PACKET packet;
|
||||
packet.RequestType = request_type;
|
||||
packet.Request = request;
|
||||
|
|
@ -72,14 +77,18 @@ inline int usb_control_msg(
|
|||
packet.Index = report_index;
|
||||
packet.Length = size;
|
||||
ULONG cbSent = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Perform WinUSB USB control transfer |
|
||||
\*---------------------------------------------------------*/
|
||||
if (!WinUsb_ControlTransfer(usb_dev->dev->p, packet, buf, size, &cbSent, 0))
|
||||
{
|
||||
printf("WinUsb_ControlTransfer failed\n");
|
||||
}
|
||||
|
||||
return cbSent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline struct usb_interface *to_usb_interface(struct device *dev) {
|
||||
return dev->parent_usb_interface;
|
||||
}
|
||||
|
|
@ -102,8 +111,18 @@ struct device_attribute {
|
|||
ssize_t(*store)(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
|
||||
};
|
||||
|
||||
inline int device_create_file(struct device *device, struct device_attribute *entry) {
|
||||
printf("device_create_file %s\n", entry->name);
|
||||
inline int device_create_file(struct device *device, struct device_attribute *entry)
|
||||
{
|
||||
if (device->attr_count < 64)
|
||||
{
|
||||
printf("device_create_file - Adding %s to list\n", entry->name);
|
||||
device->attr_list[device->attr_count] = entry;
|
||||
device->attr_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("device_create_file - List is full\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +139,11 @@ inline void device_remove_file(struct device *device, struct device_attribute *e
|
|||
|
||||
// Hack to turn Linux device macros into API calls
|
||||
#define DEVICE_ATTR1(_device,_name, _mode, _show, _store) \
|
||||
struct device_attribute dev_attr_##_name; \
|
||||
struct device_attribute dev_attr_##_name = { \
|
||||
.name = __stringify(_name) \
|
||||
, .show = _show \
|
||||
, .store = _store \
|
||||
}; \
|
||||
DLL_INTERNAL struct device_attribute dev##_device##_attr_##_name = { \
|
||||
.name = __stringify(_name) \
|
||||
, .show = _show \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue