From ccb85b981d2da758e20608acbd3d2df550feb362 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 6 Jun 2023 17:06:04 -0500 Subject: [PATCH] Initial commit from JSAUX GitHub PR --- .../RGBController_WushiL50USB.cpp | 212 ++++++++++++++++ .../RGBController_WushiL50USB.h | 37 +++ Controllers/WushiController/WushiDevices.h | 52 ++++ Controllers/WushiController/WushiDevicesL50.h | 233 ++++++++++++++++++ .../WushiController/WushiL50USBController.cpp | 90 +++++++ .../WushiController/WushiL50USBController.h | 63 +++++ .../WushiController/WushiL50USBDetect.cpp | 39 +++ 7 files changed, 726 insertions(+) create mode 100644 Controllers/WushiController/RGBController_WushiL50USB.cpp create mode 100644 Controllers/WushiController/RGBController_WushiL50USB.h create mode 100644 Controllers/WushiController/WushiDevices.h create mode 100644 Controllers/WushiController/WushiDevicesL50.h create mode 100644 Controllers/WushiController/WushiL50USBController.cpp create mode 100644 Controllers/WushiController/WushiL50USBController.h create mode 100644 Controllers/WushiController/WushiL50USBDetect.cpp diff --git a/Controllers/WushiController/RGBController_WushiL50USB.cpp b/Controllers/WushiController/RGBController_WushiL50USB.cpp new file mode 100644 index 00000000..f2dc09fe --- /dev/null +++ b/Controllers/WushiController/RGBController_WushiL50USB.cpp @@ -0,0 +1,212 @@ +#include "WushiL50USBController.h" +#include "WushiDevicesL50.h" +#include "RGBController_WushiL50USB.h" +#include "LogManager.h" + +#include +#include +#include +#include +#include +#include + +#define WUSHI_L50_NUM_LEDS 4 + +RGBController_WushiL50USB::RGBController_WushiL50USB(WushiL50USBController* controller_ptr) +{ + controller = controller_ptr; + + name = controller->getName(); + type = DEVICE_TYPE_KEYBOARD; + vendor = "Wushi"; + + location = controller->getLocation(); + version = controller->GetFirmwareVersion(); + serial = controller->GetSerialString(); + + description = "Wushi L50 device"; + + mode Direct; + Direct.name = "Direct"; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS; + Direct.color_mode = MODE_COLORS_PER_LED; + Direct.brightness_min = 1; + Direct.brightness_max = 2; + + modes.push_back(Direct); + + mode Breath; + Breath.name = "Breathing"; + Breath.flags = MODE_FLAG_HAS_RANDOM_COLOR| MODE_FLAG_HAS_SPEED;//MODE_FLAG_HAS_PER_LED_COLOR + Breath.color_mode = MODE_COLORS_RANDOM;//;MODE_COLORS_PER_LED;// + Breath.brightness_min = 1; + Breath.brightness_max = 2; + Breath.speed_min = 1; + Breath.speed_max = 4; + + modes.push_back(Breath); + + mode Wave; + Wave.name = "Rainbow Wave"; + Wave.flags = MODE_FLAG_HAS_RANDOM_COLOR |MODE_FLAG_HAS_SPEED |MODE_FLAG_HAS_DIRECTION_LR; + Wave.color_mode = MODE_COLORS_RANDOM; + Wave.speed_min = 1; + Wave.speed_max = 4; + Wave.direction = MODE_DIRECTION_LEFT | MODE_DIRECTION_RIGHT; + modes.push_back(Wave); + + mode Smooth; + Smooth.name = "Spectrum Cycle"; + Smooth.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED; + Smooth.color_mode = MODE_COLORS_RANDOM; + Smooth.brightness_min = 1; + Smooth.brightness_max = 2; + Smooth.speed_min = 1; + Smooth.speed_max = 4; + modes.push_back(Smooth); //添加mode列表 + + mode Race; + Race.name = "Race Cycle"; + Race.flags = MODE_FLAG_HAS_RANDOM_COLOR |MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_SPEED; + Race.color_mode = MODE_COLORS_RANDOM; + Race.brightness_min = 1; + Race.brightness_max = 2; + Race.speed_min = 1; + Race.speed_max = 4; + Race.direction = MODE_DIRECTION_LEFT | MODE_DIRECTION_RIGHT; + modes.push_back(Race); //添加mode列表 + + mode Stack; + Stack.name = "Stacking"; + Stack.flags = MODE_FLAG_HAS_RANDOM_COLOR |MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_SPEED| MODE_FLAG_HAS_BRIGHTNESS ; + Stack.color_mode = MODE_COLORS_RANDOM; + Stack.brightness_min = 1; + Stack.brightness_max = 2; + Stack.speed_min = 1; + Stack.direction = MODE_DIRECTION_LEFT | MODE_DIRECTION_RIGHT; + Stack.speed_max = 4; + modes.push_back(Stack); //添加mode列表 + + mode Off; + Off.name = "Off"; + Off.flags = MODE_FLAG_HAS_RANDOM_COLOR; + Off.color_mode = MODE_COLORS_RANDOM; + modes.push_back(Off); //添加mode列表 + + SetupZones(); + + // Reset colors to white + for(unsigned int led_idx = 0; led_idx < WUSHI_L50_NUM_LEDS; led_idx++ ) + { + colors[led_idx] = 0xFFFFFFFF; + } +} + +RGBController_WushiL50USB::~RGBController_WushiL50USB() +{ + controller->setDeviceHardwareMode(); + + delete controller; +} + +void RGBController_WushiL50USB::SetupZones() +{ + zone new_zone; + new_zone.name = WUSHI_L50.name; + new_zone.type = ZONE_TYPE_LINEAR; + new_zone.leds_count = WUSHI_L50_NUM_LEDS; + new_zone.leds_max = new_zone.leds_count; + new_zone.leds_min = new_zone.leds_count; + + new_zone.matrix_map = NULL; + + + zones.push_back(new_zone); + + for(unsigned int led_idx = 0; led_idx < WUSHI_L50_NUM_LEDS; led_idx++ ) + { + led new_led; //添加LEDZONE列表 + new_led.name = WUSHI_L50_leds[led_idx].name; + new_led.value = WUSHI_L50_leds[led_idx].led_num; + leds.push_back(new_led); + } + + SetupColors(); +} + +void RGBController_WushiL50USB::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_WushiL50USB::UpdateSingleLED(int /*led*/) +{ +} + +void RGBController_WushiL50USB::UpdateZoneLEDs(int /*zone*/) +{ +} + +void RGBController_WushiL50USB::DeviceUpdateLEDs() +{ + state.SetColors(colors); + controller->setMode(state); +} + +void RGBController_WushiL50USB::DeviceUpdateMode() +{ + state.Reset(); + state.SetColors(colors); + + switch (active_mode) + { + case 0: + state.effect = WUSHI_L50_EFFECT_STATIC; + break; + case 1: + state.effect = WUSHI_L50_EFFECT_BREATH; + break; + case 2: + state.effect = WUSHI_L50_EFFECT_WAVE; + state.wave_ltr = modes[active_mode].direction?0:1; + state.wave_rtl = modes[active_mode].direction?1:0; + break; + case 3: + state.effect = WUSHI_L50_EFFECT_SMOOTH; + break; + case 4: + state.effect = WUSHI_L50_EFFECT_RACE; + state.wave_ltr = modes[active_mode].direction?0:1; + state.wave_rtl = modes[active_mode].direction?1:0; + break; + case 5: + state.effect = WUSHI_L50_EFFECT_STACK; + state.wave_ltr = modes[active_mode].direction?0:1; + state.wave_rtl = modes[active_mode].direction?1:0; + break; + case 6: + state.effect = WUSHI_L50_EFFECT_STATIC; + state.zone0_rgb[0] = 0;state.zone0_rgb[1] = 0;state.zone0_rgb[2] = 0; + state.zone1_rgb[0] = 0;state.zone1_rgb[1] = 0;state.zone1_rgb[2] = 0; + state.zone2_rgb[0] = 0;state.zone2_rgb[1] = 0;state.zone2_rgb[2] = 0; + state.zone3_rgb[0] = 0;state.zone3_rgb[1] = 0;state.zone3_rgb[2] = 0; + break; + } + + if(active_mode != (WUSHI_L50_EFFECT_STATIC - 1)) // mode number from 0, but in mode from 1 + { + state.speed = modes[active_mode].speed; + } + state.brightness = modes[active_mode].brightness; + + controller->setMode(state); +} + +void RGBController_WushiL50USB::DeviceSaveMode() +{ + /*---------------------------------------------------------*\ + | This device does not support saving or multiple modes | + \*---------------------------------------------------------*/ +} diff --git a/Controllers/WushiController/RGBController_WushiL50USB.h b/Controllers/WushiController/RGBController_WushiL50USB.h new file mode 100644 index 00000000..401649f5 --- /dev/null +++ b/Controllers/WushiController/RGBController_WushiL50USB.h @@ -0,0 +1,37 @@ +/*-------------------------------------------------------------------*\ +| RGBController_WushiL50USB.h | +| | +| interface for Wushi L50 Devices | +\*-------------------------------------------------------------------*/ + +#pragma once + +#include "WushiDevices.h" +#include "WushiL50USBController.h" +#include "RGBController.h" + +#include + +#define NA 0xFFFFFFFF + +class RGBController_WushiL50USB : public RGBController +{ +public: + RGBController_WushiL50USB(WushiL50USBController* controller_ptr); + ~RGBController_WushiL50USB(); + + void SetupZones(); + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void DeviceUpdateMode(); + void DeviceSaveMode(); + +private: + KeyboardState state; + + WushiL50USBController *controller; +}; diff --git a/Controllers/WushiController/WushiDevices.h b/Controllers/WushiController/WushiDevices.h new file mode 100644 index 00000000..97961db6 --- /dev/null +++ b/Controllers/WushiController/WushiDevices.h @@ -0,0 +1,52 @@ + #include + #include "RGBController.h" + +#define NA 0xFFFFFFFF +#ifndef wushiDEVICES_H +#define wushiDEVICES_H +/*-----------------------------------------------------*\ +| WUSHI product IDs | +\*-----------------------------------------------------*/ +#define WF_S60 0x5678 + +struct Wushi_led +{ + uint8_t led_num; + std::string name; +}; + +struct Wushi_zone +{ + std::string name; + zone_type type; + unsigned char id; + unsigned int height; + unsigned int width; + const unsigned int* matrix_map; + const Wushi_led* leds; + unsigned int start; //index to start reading the list of leds + unsigned int end; //end index +}; + +/*--------------------------------------------------------*\ +| Additional LEDs for wf S60 | +\*--------------------------------------------------------*/ +const Wushi_led wf_wf_S60_additional_leds[] +{ + {0x86, "WUSHI_L50"} +}; + +static const Wushi_zone WUSHI_L50 = +{ + "LED Strip", + ZONE_TYPE_LINEAR, + 1, + 1, + 1, + NULL, + wf_wf_S60_additional_leds, + 3, + 3, +}; + +#endif diff --git a/Controllers/WushiController/WushiDevicesL50.h b/Controllers/WushiController/WushiDevicesL50.h new file mode 100644 index 00000000..7161cb55 --- /dev/null +++ b/Controllers/WushiController/WushiDevicesL50.h @@ -0,0 +1,233 @@ + +#pragma once + +#include +#include "RGBController.h" +#include "WushiDevices.h" + +/*-----------------------------------------------------*\ +| WUSHI product IDs | +\*-----------------------------------------------------*/ +#define WU_S80 0x1234 + +enum WUSHI_L50_EFFECT +{ + WUSHI_L50_EFFECT_STATIC = 1, + WUSHI_L50_EFFECT_BREATH = 3, + WUSHI_L50_EFFECT_WAVE = 4, + WUSHI_L50_EFFECT_SMOOTH = 6, + WUSHI_L50_EFFECT_RACE = 8, + WUSHI_L50_EFFECT_STACK =10, +}; + +enum WUSHI_L50_BRIGHTNESS +{ + WUSHI_L50_BRIGHTNESS_LOW = 1, + WUSHI_L50_BRIGHTNESS_HIGH = 2, +}; + +enum WUSHI_L50_SPEED +{ + WUSHI_L50_SPEED_SLOWEST = 1, + WUSHI_L50_SPEED_SLOW = 2, + WUSHI_L50_SPEED_FAST = 3, + WUSHI_L50_SPEED_FASTEST = 4, +}; + +enum WUSHI_L50_Direction +{ + WUSHI_L50_Direction_LEFT = 1, + WUSHI_L50_Direction_RIGHT = 2, +}; +/// struct a USB packet for set the keyboard LEDs +class KeyboardState +{ +public: + uint8_t header[2] = {0xCC, 0x16}; + uint8_t effect = WUSHI_L50_EFFECT_STATIC; + uint8_t speed = WUSHI_L50_SPEED_SLOWEST; + uint8_t brightness = WUSHI_L50_BRIGHTNESS_LOW; + uint8_t zone0_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone1_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone2_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone3_rgb[3] = {0xFF, 0xFF, 0xFF}; + + //uint8_t zone_rgb[50][3]; + /*uint8_t zone0_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone1_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone2_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone3_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone4_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone5_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone6_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone7_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone8_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone9_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone10_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone11_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone12_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone13_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone14_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone15_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone16_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone17_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone18_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone19_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone20_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone21_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone22_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone23_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone24_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone25_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone26_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone27_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone28_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone29_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone30_rgb[3] = {0xFF, 0xFF, 0xFF}; + + uint8_t zone31_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone32_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone33_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone34_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone35_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone36_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone37_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone38_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone39_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone40_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone41_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone42_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone43_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone44_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone45_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone46_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone47_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone48_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone49_rgb[3] = {0xFF, 0xFF, 0xFF}; + uint8_t zone50_rgb[3] = {0xFF, 0xFF, 0xFF};*/ + uint8_t padding = 0; + uint8_t wave_ltr = 0; + uint8_t wave_rtl = 0; + uint8_t unused[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + void Reset() + { + header[0] = 0xCC, header[1] = 0x16; + effect = WUSHI_L50_EFFECT_STATIC; + speed = WUSHI_L50_SPEED_SLOWEST; + brightness = WUSHI_L50_BRIGHTNESS_LOW; + //zone0_rgb[0] = 0xFF, zone0_rgb[1] = 0xFF, zone0_rgb[2] = 0xFF; + //zone1_rgb[0] = 0xFF, zone1_rgb[1] = 0xFF, zone1_rgb[2] = 0xFF; + //zone2_rgb[0] = 0xFF, zone2_rgb[1] = 0xFF, zone2_rgb[2] = 0xFF; + //zone3_rgb[0] = 0xFF, zone3_rgb[1] = 0xFF, zone3_rgb[2] = 0xFF; + padding = 0; + wave_ltr = 0; + wave_rtl = 0; + for(int i = 0; i < 13; ++i) + { + unused[i] = 0; + } + } + + void SetColors(std::vector group_colors) + { + zone0_rgb[0] = RGBGetRValue(group_colors[0]); + zone0_rgb[1] = RGBGetGValue(group_colors[0]); + zone0_rgb[2] = RGBGetBValue(group_colors[0]); + zone1_rgb[0] = RGBGetRValue(group_colors[1]); + zone1_rgb[1] = RGBGetGValue(group_colors[1]); + zone1_rgb[2] = RGBGetBValue(group_colors[1]); + zone2_rgb[0] = RGBGetRValue(group_colors[2]); + zone2_rgb[1] = RGBGetGValue(group_colors[2]); + zone2_rgb[2] = RGBGetBValue(group_colors[2]); + zone3_rgb[0] = RGBGetRValue(group_colors[3]); + zone3_rgb[1] = RGBGetGValue(group_colors[3]); + zone3_rgb[2] = RGBGetBValue(group_colors[3]); + + //zone_rgb[0][0]=0x12;zone_rgb[0][1]=0x34;zone_rgb[0][2]=0x56; + //zone_rgb[1][0]=0x78;zone_rgb[1][1]=0x90;zone_rgb[1][2]=0x12; + /*for(uint8_t zone=0;zone<50;zone++) + { + //for(uint8_t rgb_idx=0;rgb_idx<3;rgb_idx++) + zone_rgb[zone][0] = RGBGetRValue(group_colors[zone]); + zone_rgb[zone][1] = RGBGetGValue(group_colors[zone]); + zone_rgb[zone][2] = RGBGetBValue(group_colors[zone]); + }*/ + wave_rtl = 0; + } +}; + +/*-------------------------*\ +| L50 keyboard | +\*-------------------------*/ + +static const Wushi_led WUSHI_L50_leds[] +{ + {0x00, "Zone 1"}, + {0x01, "Zone 2"}, + {0x02, "Zone 3"}, + {0x03, "Zone 4"}, +/* {0x00, "Pixel 1"}, + {0x01, "Pixel 2"}, + {0x02, "Pixel 3"}, + {0x03, "Pixel 4"}, + {0x04, "Pixel 5"}, + {0x05, "Pixel 6"}, + {0x06, "Pixel 7"}, + {0x07, "Pixel 8"}, + {0x08, "Pixel 9"}, + {0x09, "Pixel 10"}, + {10, "Pixel 11"}, + {11, "Pixel 12"}, + + {12, "Pixel 13"}, + {13, "Pixel 14"}, + {14, "Pixel 15"}, + {15, "Pixel 16"}, + + {16, "Pixel 17"}, + {17, "Pixel 18"}, + {18, "Pixel 19"}, + {19, "Pixel 20"}, + + {20, "Pixel 21"}, + {21, "Pixel 22"}, + {22, "Pixel 23"}, + {23, "Pixel 24"}, + + {24, "Pixel 25"}, + {25, "Pixel 26"}, + {26, "Pixel 27"}, + {27, "Pixel 28"}, + + {28, "Pixel 29"}, + {29, "Pixel 30"}, + {30, "Pixel 31"}, + {31, "Pixel 32"}, + + {32, "Pixel 33"}, + {33, "Pixel 34"}, + {34, "Pixel 35"}, + {35, "Pixel 36"}, + + {36, "Pixel 37"}, + {37, "Pixel 38"}, + {38, "Pixel 39"}, + {39, "Pixel 40"}, + + {40, "Pixel 41"}, + {41, "Pixel 42"}, + {42, "Pixel 43"}, + {43, "Pixel 44"}, + + + {44, "Pixel 45"}, + {45, "Pixel 46"}, + {46, "Pixel 47"}, + {47, "Pixel 48"}, + + {48, "Pixel 49"}, + {49, "Pixel 50"},*/ + +}; + diff --git a/Controllers/WushiController/WushiL50USBController.cpp b/Controllers/WushiController/WushiL50USBController.cpp new file mode 100644 index 00000000..528f4963 --- /dev/null +++ b/Controllers/WushiController/WushiL50USBController.cpp @@ -0,0 +1,90 @@ +/*-------------------------------------------------------------------*\ +| WushiL50USBController.cpp | +| | +| interface for Wushi L50 Devices | +\*-------------------------------------------------------------------*/ + +#include +#include "WushiL50USBController.h" +#include "LogManager.h" + +WushiL50USBController::WushiL50USBController(hid_device* dev_handle, const char* path, uint16_t in_pid) +{ + const uint8_t sz = HID_MAX_STR; + wchar_t tmp[sz]; + wchar_t serial_string[128]; + dev = dev_handle; + location = path; + pid = in_pid; + + + + hid_get_manufacturer_string(dev, tmp, sz); + std::wstring w_tmp = std::wstring(tmp); + name = std::string(w_tmp.begin(), w_tmp.end()); + + hid_get_product_string(dev, tmp, sz); + w_tmp = std::wstring(tmp); + name.append(" ").append(std::string(w_tmp.begin(), w_tmp.end())); + + int ret = hid_get_serial_number_string(dev, tmp, sz); + + if(ret != 0) + { + serial_number = ""; + } + else + { + std::wstring return_wstring = tmp;//serial_string; + serial_number = std::string(return_wstring.begin(), return_wstring.end()); + } + version ="0.10"; // + setDeviceSoftwareMode(); +} + +WushiL50USBController::~WushiL50USBController() +{ + hid_close(dev); +} + +void WushiL50USBController::setMode(const KeyboardState &in_mode) +{ + uint8_t buffer[WUSHIL50_HID_PACKET_SIZE]; + memcpy(buffer, &in_mode, WUSHIL50_HID_PACKET_SIZE); + hid_send_feature_report(dev, buffer, WUSHIL50_HID_PACKET_SIZE); +} + +uint16_t WushiL50USBController::getPid() +{ + return pid; +} + +std::string WushiL50USBController::getName() +{ + return name; +} + +std::string WushiL50USBController::getLocation() +{ + return location; +} + +std::string WushiL50USBController::GetSerialString() +{ + return(serial_number); +} + +std::string WushiL50USBController::GetFirmwareVersion() +{ + return(version); +} + +void WushiL50USBController::setDeviceSoftwareMode() +{ + +} + +void WushiL50USBController::setDeviceHardwareMode() +{ + +} diff --git a/Controllers/WushiController/WushiL50USBController.h b/Controllers/WushiController/WushiL50USBController.h new file mode 100644 index 00000000..1110a6d9 --- /dev/null +++ b/Controllers/WushiController/WushiL50USBController.h @@ -0,0 +1,63 @@ +/*-------------------------------------------------------------------*\ +| WushiL50USBController.h | +| | +| interface for Wushi L50 Devices | +\*-------------------------------------------------------------------*/ + +#pragma once + +#include "RGBController.h" +#include "LogManager.h" +#include "WushiDevicesL50.h" + +#include +#include +#include +#include +#include + +#ifndef HID_MAX_STR +#define HID_MAX_STR 255 +#endif + +#define WUSHIL50_HID_PACKET_SIZE 33 + +class WushiL50USBController +{ + public: + /*--------------*\ + |ctor(s) and dtor| + \*--------------*/ + WushiL50USBController(hid_device* dev_handle, const char* path, uint16_t in_pid); + ~WushiL50USBController(); + + void setMode(const KeyboardState &in_mode); + + /*--------------*\ + |device functions| + \*--------------*/ + uint16_t getPid(); + std::string getName(); + std::string getLocation(); + std::string GetSerialString(); + std::string GetFirmwareVersion(); + + void setDeviceSoftwareMode(); + void setDeviceHardwareMode(); + + private: + /*--------------*\ + |data members | + \*--------------*/ + std::string name; + hid_device *dev; + std::string location; + std::string serial_number; + uint16_t pid; + KeyboardState mode; + std::string version; + /*--------------*\ + |device functions| + \*--------------*/ + void sendBasicInstruction(uint8_t instruction); +}; diff --git a/Controllers/WushiController/WushiL50USBDetect.cpp b/Controllers/WushiController/WushiL50USBDetect.cpp new file mode 100644 index 00000000..4c9ad309 --- /dev/null +++ b/Controllers/WushiController/WushiL50USBDetect.cpp @@ -0,0 +1,39 @@ + + +#include "Detector.h" +#include "LogManager.h" +#include "RGBController.h" +#include "WushiL50USBController.h" +#include "WushiDevicesL50.h" +#include "RGBController_WushiL50USB.h" +#include + +/*-----------------------------------------------------*\ +| vendor IDs | +\*-----------------------------------------------------*/ +#define WUSHI_VID 0x306F + +/*-----------------------------------------------------*\ +| Interface, Usage, and Usage Page | +\*-----------------------------------------------------*/ +enum +{ + WUSHI_PAGE = 0xFF63, + WUSHI_USAGE = 0x0C +}; + +void DetectWushiL50USBControllers(hid_device_info* info, const std::string& name) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) //WushiL50USBController + { + WushiL50USBController* controller = new WushiL50USBController(dev, info->path, info->product_id); + RGBController_WushiL50USB* rgb_controller = new RGBController_WushiL50USB(controller); + rgb_controller->name = name; + + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_HID_DETECTOR_PU("JSAUX RGB Docking Station", DetectWushiL50USBControllers, WUSHI_VID, WU_S80, WUSHI_PAGE, WUSHI_USAGE);