Update Glorious (Sinowealth) driver (Merge request !155)

Manually merged by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
crashniels 2020-09-22 22:50:12 -05:00 committed by Adam Honse
parent 5fb3d83706
commit 88759aaac3
10 changed files with 459 additions and 447 deletions

View file

@ -261,6 +261,16 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc39", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="8297", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="5702", TAG+="uaccess"
#---------------------------------------------------------------#
# Sinowealth USB #
# Glorious Model O / O- #
# Glorious Model D / D- #
# Everest GT-100 RGB #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0036", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0033", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0029", TAG+="uaccess"
#---------------------------------------------------------------#
# SteelSeries Peripheral Devices #
# #

View file

@ -1,278 +0,0 @@
/*-----------------------------------------*\
| RGBController_GloriousModelO.cpp |
| |
| Definitions and types for Glorious |
| and other Mice |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
#include "GloriousModelOController.h"
#include <cstring>
using namespace std::chrono_literals;
GloriousModelOController::GloriousModelOController(hid_device* dev_handle)
{
dev = dev_handle;
strcpy(device_name, "Glorious Mouse");
led_count = 1;
current_mode = GLORIOUS_MODE_STATIC;
current_speed = GLORIOUS_SPEED_NORMAL;
current_direction = GLORIOUS_DIRECTION_UP;
}
GloriousModelOController::~GloriousModelOController()
{
}
std::string GloriousModelOController::GetDeviceName()
{
return(device_name);
}
unsigned int GloriousModelOController::GetLEDCount()
{
return(led_count);
}
void GloriousModelOController::SetLEDColor(RGBColor* color_buf)
{
unsigned char usb_buf[520] =
{
0x04, 0x11, 0x00, 0x7b,
0x00, 0x00, 0x00, 0x00, 0x64, 0x06, 0x04, 0x24,
0xf0, 0x03, 0x07, 0x0f, 0x1f, 0x31, 0x63, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff,
0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43,
0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
0x42, 0x02, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
usb_buf[0x0B] = 0x24;
usb_buf[0x35] = GLORIOUS_MODE_STATIC;
usb_buf[0x38] = 0x40; //max brightness
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
//DPI Button
/*
usb_buf[0x0B] = 0x44; //third DPI
usb_buf[0x26] = red;
usb_buf[0x27] = blue;
usb_buf[0x28] = green;
*/
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
std::this_thread::sleep_for(1ms);
}
void GloriousModelOController::SetMode(unsigned char mode,
unsigned char speed,
unsigned char direction,
RGBColor* color_buf)
{
unsigned char usb_buf[520] =
{
0x04, 0x11, 0x00, 0x7b,
0x00, 0x00, 0x00, 0x00, 0x64, 0x06, 0x04, 0x24,
0xf0, 0x03, 0x07, 0x0f, 0x1f, 0x31, 0x63, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff,
0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43,
0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
0x42, 0x02, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
usb_buf[0x35] = mode;
switch (mode)
{
case GLORIOUS_MODE_OFF:
usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03
break;
case GLORIOUS_MODE_RAINBOW:
usb_buf[0x36] = speed;
usb_buf[0x37] = direction;
break;
case GLORIOUS_MODE_SPECTRUM_BREATING:
//colours not yet researched
usb_buf[0x3C] = speed; //speed for mode 3
usb_buf[0x3D] = 0x07; //maybe some kind of bank change?+
//usb_buf[0x3D] = 0x06;
usb_buf[0x3E] = RGBGetRValue(color_buf[0]); //mode 3 red 1
usb_buf[0x3F] = RGBGetBValue(color_buf[0]); //mode 3 blue 1
usb_buf[0x40] = RGBGetGValue(color_buf[0]); //mode 3 green 1
usb_buf[0x41] = RGBGetRValue(color_buf[1]); //mode 3 red 2
usb_buf[0x42] = RGBGetBValue(color_buf[1]); //mode 3 blue 2
usb_buf[0x43] = RGBGetGValue(color_buf[1]); //mode 3 green 2
usb_buf[0x44] = RGBGetRValue(color_buf[2]); //mode 3 red 3
usb_buf[0x45] = RGBGetBValue(color_buf[2]); //mode 3 blue 3
usb_buf[0x46] = RGBGetGValue(color_buf[2]); //mode 3 green 3
usb_buf[0x47] = RGBGetRValue(color_buf[3]); //mode 3 red 4
usb_buf[0x48] = RGBGetBValue(color_buf[3]); //mode 3 blue 4
usb_buf[0x49] = RGBGetGValue(color_buf[3]); //mode 3 green 4
usb_buf[0x4A] = RGBGetRValue(color_buf[4]); //mode 3 red 5
usb_buf[0x4B] = RGBGetBValue(color_buf[4]); //mode 3 blue 5
usb_buf[0x4C] = RGBGetGValue(color_buf[4]); //mode 3 green 5
usb_buf[0x4D] = RGBGetRValue(color_buf[5]); //mode 3 red 6
usb_buf[0x4E] = RGBGetBValue(color_buf[5]); //mode 3 blue 6
usb_buf[0x4F] = RGBGetGValue(color_buf[5]); //mode 3 green 6
usb_buf[0x50] = RGBGetRValue(color_buf[6]); //mode 3 red 7
usb_buf[0x51] = RGBGetBValue(color_buf[6]); //mode 3 blue 7
usb_buf[0x52] = RGBGetGValue(color_buf[6]); //mode 3 green 7
break;
case GLORIOUS_MODE_TAIL:
usb_buf[0x53] = speed; //Speed for mode 4
break;
case GLORIOUS_MODE_SPECTRUM_CYCLE:
usb_buf[0x54] = speed; //Speed for mode 1,2,5
break;
case GLORIOUS_MODE_RAVE:
usb_buf[0x74] = speed; //Speed for mode 7
usb_buf[0x75] = RGBGetRValue(color_buf[0]); //mode 7 red 1
usb_buf[0x76] = RGBGetBValue(color_buf[0]); //mode 7 blue 1
usb_buf[0x77] = RGBGetGValue(color_buf[0]); //mode 7 green 1
usb_buf[0x78] = RGBGetRValue(color_buf[1]); //mode 7 red 2
usb_buf[0x79] = RGBGetBValue(color_buf[1]); //mode 7 blue 2
usb_buf[0x7A] = RGBGetGValue(color_buf[1]); //mode 7 green 2
break;
case GLORIOUS_MODE_WAVE:
usb_buf[0x7C] = speed; //Speed for mode 9
break;
case GLORIOUS_MODE_BREATHING:
usb_buf[0x7D] = speed;
usb_buf[0x7E] = RGBGetRValue(color_buf[0]); //mode 0a red
usb_buf[0x7F] = RGBGetBValue(color_buf[0]); //mode 0a blue
usb_buf[0x80] = RGBGetGValue(color_buf[0]); //mode 0a green
default:
break;
}
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
std::this_thread::sleep_for(1ms);
}

View file

@ -1,71 +0,0 @@
/*-----------------------------------------*\
| GloriousModelOController.h |
| |
| Definitions and types for Glorious |
| and other Mice |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <hidapi/hidapi.h>
#pragma once
enum
{
GLORIOUS_MODE_OFF = 0x00, //does nothing
GLORIOUS_MODE_RAINBOW = 0x01,
GLORIOUS_MODE_STATIC = 0x02,
GLORIOUS_MODE_SPECTRUM_BREATING = 0x03,
GLORIOUS_MODE_TAIL = 0x04,
GLORIOUS_MODE_SPECTRUM_CYCLE = 0x05,
GLORIOUS_MODE_RAVE = 0x07,
GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software
GLORIOUS_MODE_WAVE = 0x09,
GLORIOUS_MODE_BREATHING = 0x0a,
};
enum
{
GLORIOUS_SPEED_SLOW = 0x41,
GLORIOUS_SPEED_NORMAL = 0x42,
GLORIOUS_SPEED_FAST = 0x43,
};
enum
{
GLORIOUS_DIRECTION_UP = 0x00,
GLORIOUS_DIRECTION_DOWN = 0x01,
};
enum
{
GLORIOUS_MODE_BREATING_SLOW = 0x01,
GLORIOUS_MODE_BREATING_NORMAL = 0x02,
GLORIOUS_MODE_BREATING_FAST = 0x03,
};
class GloriousModelOController
{
public:
GloriousModelOController(hid_device* dev_handle);
~GloriousModelOController();
std::string GetDeviceName();
unsigned int GetLEDCount();
void SetLEDColor(RGBColor* color_buf);
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction, RGBColor* color_buf);
private:
hid_device* dev;
char device_name[32];
unsigned int led_count;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_direction;
};

View file

@ -1,60 +0,0 @@
#include "Detector.h"
#include "GloriousModelOController.h"
#include "RGBController.h"
#include "RGBController_GloriousModelO.h"
#include <vector>
#include <hidapi/hidapi.h>
#define Glorious_Model_O_VID 0x258A
#define Glorious_Model_O_PID 0x0036
/******************************************************************************************\
* *
* DetectGloriousModelController *
* *
* Tests the USB address to see if a Glorious Model O controller exists there. *
* *
\******************************************************************************************/
void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
info = hid_enumerate(Glorious_Model_O_VID, Glorious_Model_O_PID);
//Look for Glorious Model O
while(info)
{
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
GloriousModelOController* controller = new GloriousModelOController(dev);
RGBController_GloriousModelO* rgb_controller = new RGBController_GloriousModelO(controller);
rgb_controller->name = "Glorious Mouse";
rgb_controllers.push_back(rgb_controller);
}
} /* DetectGloriousModelOControllers() */
REGISTER_DETECTOR("Glorious Model O", DetectGloriousModelOControllers);

View file

@ -0,0 +1,186 @@
/*-----------------------------------------*\
| SinowealthController.cpp |
| |
| Definitions and types for Sinowealth |
| mice, including Glorious |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
#include "SinowealthController.h"
#include <cstring>
SinowealthController::SinowealthController(hid_device* dev_handle_id_4, hid_device* dev_handle_id_5, char *_path)
{
dev_report_id_4 = dev_handle_id_4;
dev_report_id_5 = dev_handle_id_5;
led_count = 1;
current_mode = GLORIOUS_MODE_STATIC;
current_speed = GLORIOUS_SPEED_NORMAL;
current_direction = GLORIOUS_DIRECTION_UP;
location = _path;
}
SinowealthController::~SinowealthController()
{
}
std::string SinowealthController::GetLocation()
{
return(location);
}
unsigned int SinowealthController::GetLEDCount()
{
return(led_count);
}
void SinowealthController::SetLEDColor
(
RGBColor* color_buf
)
{
GetProfile();
unsigned char usb_buf[520];
memset(usb_buf, 0x00, sizeof(usb_buf));
for (int i = 0x00; i < 0x83; i++)
{
usb_buf[i] = device_configuration[i];
}
usb_buf[0x03] = 0x7B; //write to device
usb_buf[0x06] = 0x00;
usb_buf[0x82] = device_configuration[0x82];
usb_buf[0x35] = GLORIOUS_MODE_STATIC;
usb_buf[0x38] = 0x40; //max brightness
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
hid_send_feature_report(dev_report_id_4, usb_buf, sizeof(usb_buf));
}
void SinowealthController::SetMode
(
unsigned char mode,
unsigned char speed,
unsigned char direction,
RGBColor* color_buf
)
{
GetProfile();
unsigned char usb_buf[520];
memset(usb_buf, 0x00, sizeof(usb_buf));
for (int i = 0x00; i < 0x83; i++)
{
usb_buf[i] = device_configuration[i];
}
usb_buf[0x03] = 0x7B; //write to device
usb_buf[0x06] = 0x00;
usb_buf[0x82] = device_configuration[0x82];
usb_buf[0x35] = mode;
switch (mode)
{
case GLORIOUS_MODE_OFF:
usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03
break;
case GLORIOUS_MODE_RAINBOW:
usb_buf[0x36] = speed;
usb_buf[0x37] = direction;
break;
case GLORIOUS_MODE_SPECTRUM_BREATING:
//colours not yet researched
usb_buf[0x3C] = speed; //speed for mode 3
usb_buf[0x3D] = 0x07; //maybe some kind of bank change?+
//usb_buf[0x3D] = 0x06;
usb_buf[0x3E] = RGBGetRValue(color_buf[0]); //mode 3 red 1
usb_buf[0x3F] = RGBGetBValue(color_buf[0]); //mode 3 blue 1
usb_buf[0x40] = RGBGetGValue(color_buf[0]); //mode 3 green 1
usb_buf[0x41] = RGBGetRValue(color_buf[1]); //mode 3 red 2
usb_buf[0x42] = RGBGetBValue(color_buf[1]); //mode 3 blue 2
usb_buf[0x43] = RGBGetGValue(color_buf[1]); //mode 3 green 2
usb_buf[0x44] = RGBGetRValue(color_buf[2]); //mode 3 red 3
usb_buf[0x45] = RGBGetBValue(color_buf[2]); //mode 3 blue 3
usb_buf[0x46] = RGBGetGValue(color_buf[2]); //mode 3 green 3
usb_buf[0x47] = RGBGetRValue(color_buf[3]); //mode 3 red 4
usb_buf[0x48] = RGBGetBValue(color_buf[3]); //mode 3 blue 4
usb_buf[0x49] = RGBGetGValue(color_buf[3]); //mode 3 green 4
usb_buf[0x4A] = RGBGetRValue(color_buf[4]); //mode 3 red 5
usb_buf[0x4B] = RGBGetBValue(color_buf[4]); //mode 3 blue 5
usb_buf[0x4C] = RGBGetGValue(color_buf[4]); //mode 3 green 5
usb_buf[0x4D] = RGBGetRValue(color_buf[5]); //mode 3 red 6
usb_buf[0x4E] = RGBGetBValue(color_buf[5]); //mode 3 blue 6
usb_buf[0x4F] = RGBGetGValue(color_buf[5]); //mode 3 green 6
usb_buf[0x50] = RGBGetRValue(color_buf[6]); //mode 3 red 7
usb_buf[0x51] = RGBGetBValue(color_buf[6]); //mode 3 blue 7
usb_buf[0x52] = RGBGetGValue(color_buf[6]); //mode 3 green 7
break;
case GLORIOUS_MODE_TAIL:
usb_buf[0x53] = speed; //Speed for mode 4
break;
case GLORIOUS_MODE_SPECTRUM_CYCLE:
usb_buf[0x54] = speed; //Speed for mode 1,2,5
break;
case GLORIOUS_MODE_RAVE:
usb_buf[0x74] = speed; //Speed for mode 7
usb_buf[0x75] = RGBGetRValue(color_buf[0]); //mode 7 red 1
usb_buf[0x76] = RGBGetBValue(color_buf[0]); //mode 7 blue 1
usb_buf[0x77] = RGBGetGValue(color_buf[0]); //mode 7 green 1
usb_buf[0x78] = RGBGetRValue(color_buf[1]); //mode 7 red 2
usb_buf[0x79] = RGBGetBValue(color_buf[1]); //mode 7 blue 2
usb_buf[0x7A] = RGBGetGValue(color_buf[1]); //mode 7 green 2
break;
case GLORIOUS_MODE_WAVE:
usb_buf[0x7C] = speed; //Speed for mode 9
break;
case GLORIOUS_MODE_BREATHING:
usb_buf[0x7D] = speed;
usb_buf[0x7E] = RGBGetRValue(color_buf[0]); //mode 0a red
usb_buf[0x7F] = RGBGetBValue(color_buf[0]); //mode 0a blue
usb_buf[0x80] = RGBGetGValue(color_buf[0]); //mode 0a green
default:
break;
}
hid_send_feature_report(dev_report_id_4, usb_buf, sizeof(usb_buf));
}
void SinowealthController::GetProfile()
{
int actual;
unsigned char usb_buf[6];
usb_buf[0] = 0x05;
usb_buf[1] = 0x11;
actual = hid_send_feature_report(dev_report_id_5, usb_buf, 6);
if (actual != 6)
{
printf("Error sending read request!");
}
else
{
memset(device_configuration, 0x00, sizeof(device_configuration));
//unsigned char device_configuration[520];
device_configuration[0] = 0x04;
device_configuration[1] = 0x11;
actual = hid_get_feature_report(dev_report_id_4, device_configuration, 520);
if (actual != 131)
{
printf("Error reading device configuration");
}
}
}

View file

@ -0,0 +1,74 @@
/*-----------------------------------------*\
| SinowealthController.h |
| |
| Definitions and types for Sinowealth |
| mice, including Glorious |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <hidapi/hidapi.h>
#pragma once
enum
{
GLORIOUS_MODE_OFF = 0x00, //does nothing
GLORIOUS_MODE_RAINBOW = 0x01,
GLORIOUS_MODE_STATIC = 0x02,
GLORIOUS_MODE_SPECTRUM_BREATING = 0x03,
GLORIOUS_MODE_TAIL = 0x04,
GLORIOUS_MODE_SPECTRUM_CYCLE = 0x05,
GLORIOUS_MODE_RAVE = 0x07,
GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software
GLORIOUS_MODE_WAVE = 0x09,
GLORIOUS_MODE_BREATHING = 0x0a,
};
enum
{
GLORIOUS_SPEED_SLOW = 0x41,
GLORIOUS_SPEED_NORMAL = 0x42,
GLORIOUS_SPEED_FAST = 0x43,
};
enum
{
GLORIOUS_DIRECTION_UP = 0x00,
GLORIOUS_DIRECTION_DOWN = 0x01,
};
enum
{
GLORIOUS_MODE_BREATING_SLOW = 0x01,
GLORIOUS_MODE_BREATING_NORMAL = 0x02,
GLORIOUS_MODE_BREATING_FAST = 0x03,
};
class SinowealthController
{
public:
SinowealthController(hid_device* dev_handle_id_4, hid_device* dev_handle_id_5, char *_path); //RGB, Command, path
~SinowealthController();
unsigned int GetLEDCount();
std::string GetLocation();
void SetLEDColor(RGBColor* color_buf);
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction, RGBColor* color_buf);
void GetProfile();
private:
hid_device* dev_report_id_4;
hid_device* dev_report_id_5;
unsigned int led_count;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_direction;
unsigned char device_configuration[520];
std::string location;
};

View file

@ -0,0 +1,147 @@
#include "Detector.h"
#include "SinowealthController.h"
#include "RGBController.h"
#include "RGBController_Sinowealth.h"
#include <vector>
#include <hidapi/hidapi.h>
#define SINOWEALTH_VID 0x258A
#define Glorious_Model_O_PID 0x0036
#define Glorious_Model_D_PID 0x0033
#define Everest_GT100_PID 0x0029
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
const char * name;
} sinowealth_device;
#define SINOWEALTH_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const sinowealth_device device_list[] =
{
{ SINOWEALTH_VID, Glorious_Model_O_PID, "Glorious Model O / O- " },
{ SINOWEALTH_VID, Glorious_Model_D_PID, "Glorious Model D / D- " },
{ SINOWEALTH_VID, Everest_GT100_PID , "Everest GT-100 RGB" },
};
/******************************************************************************************\
* *
* DetectSinowealthControllers *
* *
* Tests the USB address to see if a Sinowealth controller exists there. *
* *
\******************************************************************************************/
void DetectSinowealthControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
int pass = 0;
hid_init();
for(std::size_t device_idx = 0; device_idx < SINOWEALTH_NUM_DEVICES; device_idx++)
{
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
/*-------------------------------------------------------------------------------------------------*\
| Sinowealth devices use 3 different Report IDs on the same Usage Page. |
| The 4 on 0xFF00 is for RGB, 7 is Unknown and 5 is for Commands. |
\*-------------------------------------------------------------------------------------------------*/
//Look for Sinowealth Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
#ifdef USE_HID_USAGE
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->usage_page == 0xFF00))
#else
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == 1))
#endif
{
//Open first
pass = 1;
hid_device* dev_report_id_4 = hid_open_path(info->path);
if( dev_report_id_4 )
{
#ifdef USE_HID_USAGE
hid_device_info* tmp_info_id_7 = info;
while(tmp_info_id_7)
{
if((tmp_info_id_7->vendor_id == device_list[device_idx].usb_vid)
&&(tmp_info_id_7->product_id == device_list[device_idx].usb_pid)
&&(tmp_info_id_7->usage_page == 0xFF00))
{
//skip second
tmp_info_id_7 = tmp_info_id_7->next;
hid_device_info* tmp_info_id_5 = tmp_info_id_7;
while(tmp_info_id_5)
{
if((tmp_info_id_5->vendor_id == device_list[device_idx].usb_vid)
&&(tmp_info_id_5->product_id == device_list[device_idx].usb_pid)
&&(tmp_info_id_5->usage_page == 0xFF00))
{
//Open third
hid_device* dev_report_id_5 = hid_open_path(tmp_info_id_5->path);
if(dev_report_id_5)
{
SinowealthController* controller = new SinowealthController(dev_report_id_4, dev_report_id_5, info->path);
RGBController_Sinowealth* rgb_controller = new RGBController_Sinowealth(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
int pass = 3;
}
}
if (pass == 2)
{
tmp_info_id_5 = tmp_info_id_5->next;
}
else break;
}
}
if (pass == 1)
{
tmp_info_id_7 = tmp_info_id_7->next;
}
else break;
}
#else
SinowealthController* controller = new SinowealthController(dev_report_id_4, dev_report_id_4, info->path);
RGBController_Sinowealth* rgb_controller = new RGBController_Sinowealth(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
#endif
}
}
if (pass == 0)
{
info = info->next;
}
else break;
}
}
}
REGISTER_DETECTOR("Sinowealth Device", DetectSinowealthControllers);

View file

@ -66,7 +66,6 @@ INCLUDEPATH += \
Controllers/EspurnaController/ \
Controllers/EVGAGPUController/ \
Controllers/GalaxGPUController/ \
Controllers/GloriousModelOController/ \
Controllers/HoltekController/ \
Controllers/HuePlusController/ \
Controllers/HyperXDRAMController/ \
@ -90,6 +89,7 @@ INCLUDEPATH += \
Controllers/RGBFusion2USBController/ \
Controllers/RGBFusionGPUController/ \
Controllers/SapphireGPUController/ \
Controllers/SinowealthController/ \
Controllers/SteelSeriesController/ \
Controllers/TecknetController/ \
Controllers/ThermaltakeRiingController/ \
@ -144,7 +144,6 @@ HEADERS += \
Controllers/EVGAGPUController/EVGAGPUv1Controller.h \
Controllers/EVGAGPUController/EVGAGPUv2Controller.h \
Controllers/GalaxGPUController/GalaxGPUController.h \
Controllers/GloriousModelOController/GloriousModelOController.h \
Controllers/HoltekController/HoltekA070Controller.h \
Controllers/HuePlusController/HuePlusController.h \
Controllers/HyperXDRAMController/HyperXDRAMController.h \
@ -176,6 +175,7 @@ HEADERS += \
Controllers/RedragonController/RedragonK556Controller.h \
Controllers/RedragonController/RedragonM711Controller.h \
Controllers/SapphireGPUController/SapphireGPUController.h \
Controllers/SinowealthController/SinowealthController.h \
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
Controllers/SteelSeriesController/SteelSeriesApexController.h \
@ -203,7 +203,6 @@ HEADERS += \
RGBController/RGBController_EVGAGPUv1.h \
RGBController/RGBController_EVGAGPUv2.h \
RGBController/RGBController_GalaxGPU.h \
RGBController/RGBController_GloriousModelO.h \
RGBController/RGBController_HoltekA070.h \
RGBController/RGBController_HuePlus.h \
RGBController/RGBController_HyperXAlloyOrigins.h \
@ -237,6 +236,7 @@ HEADERS += \
RGBController/RGBController_RGBFusion2USB.h \
RGBController/RGBController_RGBFusionGPU.h \
RGBController/RGBController_SapphireGPU.h \
RGBController/RGBController_Sinowealth.h \
RGBController/RGBController_SteelSeriesRival.h \
RGBController/RGBController_SteelSeriesSiberia.h \
RGBController/RGBController_SteelSeriesApex.h \
@ -310,8 +310,6 @@ SOURCES += \
Controllers/EVGAGPUController/EVGAGPUControllerDetect.cpp \
Controllers/GalaxGPUController/GalaxGPUController.cpp \
Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp \
Controllers/GloriousModelOController/GloriousModelOController.cpp \
Controllers/GloriousModelOController/GloriousModelOControllerDetect.cpp \
Controllers/HoltekController/HoltekA070Controller.cpp \
Controllers/HoltekController/HoltekControllerDetect.cpp \
Controllers/HuePlusController/HuePlusController.cpp \
@ -366,6 +364,8 @@ SOURCES += \
Controllers/RedragonController/RedragonControllerDetect.cpp \
Controllers/SapphireGPUController/SapphireGPUController.cpp \
Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp \
Controllers/SinowealthController/SinowealthController.cpp \
Controllers/SinowealthController/SinowealthControllerDetect.cpp \
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
Controllers/SteelSeriesController/SteelSeriesApexController.cpp \
@ -398,7 +398,6 @@ SOURCES += \
RGBController/RGBController_EVGAGPUv1.cpp \
RGBController/RGBController_EVGAGPUv2.cpp \
RGBController/RGBController_GalaxGPU.cpp \
RGBController/RGBController_GloriousModelO.cpp \
RGBController/RGBController_HoltekA070.cpp \
RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperXAlloyOrigins.cpp \
@ -431,6 +430,7 @@ SOURCES += \
RGBController/RGBController_RGBFusion2USB.cpp \
RGBController/RGBController_RGBFusionGPU.cpp \
RGBController/RGBController_SapphireGPU.cpp \
RGBController/RGBController_Sinowealth.cpp \
RGBController/RGBController_SteelSeriesRival.cpp \
RGBController/RGBController_SteelSeriesSiberia.cpp \
RGBController/RGBController_SteelSeriesApex.cpp \

View file

@ -1,21 +1,22 @@
/*-----------------------------------------*\
| RGBController_GloriousModelO.cpp |
| RGBController_Sinowealth.cpp |
| |
| Definitions and types for Glorious |
| and other Mice |
| Definitions and types for Sinowealth |
| mice, including Glorious |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
#include "RGBController_GloriousModelO.h"
#include "RGBController_Sinowealth.h"
RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOController* gmo_ptr)
RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* sinowealth_ptr)
{
gmo = gmo_ptr;
sinowealth = sinowealth_ptr;
name = gmo->GetDeviceName();
name = "Sinowealth Device";
type = DEVICE_TYPE_MOUSE;
description = "Glorious Device";
description = "Sinowealth Device";
location = sinowealth->GetLocation();
mode Static;
Static.name = "Static";
@ -121,17 +122,17 @@ RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOControl
SetupZones();
}
void RGBController_GloriousModelO::SetupZones()
void RGBController_Sinowealth::SetupZones()
{
/*---------------------------------------------------------*\
| Create a single zone |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = "Glorious Zone";
new_zone.name = "Mouse";
new_zone.type = ZONE_TYPE_SINGLE;
new_zone.leds_min = gmo->GetLEDCount();
new_zone.leds_max = gmo->GetLEDCount();
new_zone.leds_count = gmo->GetLEDCount();
new_zone.leds_min = sinowealth->GetLEDCount();
new_zone.leds_max = sinowealth->GetLEDCount();
new_zone.leds_count = sinowealth->GetLEDCount();
new_zone.matrix_map = NULL;
zones.push_back(new_zone);
@ -141,40 +142,42 @@ void RGBController_GloriousModelO::SetupZones()
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = "Glorious LED";
new_led->name = "Mouse LED";
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_GloriousModelO::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_Sinowealth::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_GloriousModelO::DeviceUpdateLEDs()
void RGBController_Sinowealth::DeviceUpdateLEDs()
{
gmo->SetLEDColor(&colors[0]);
sinowealth->SetLEDColor(&colors[0]);
}
void RGBController_GloriousModelO::UpdateZoneLEDs(int /*zone*/)
void RGBController_Sinowealth::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_GloriousModelO::UpdateSingleLED(int /*led*/)
void RGBController_Sinowealth::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_GloriousModelO::SetCustomMode()
void RGBController_Sinowealth::SetCustomMode()
{
//active_mode = 2;
active_mode = 0;
}
void RGBController_GloriousModelO::DeviceUpdateMode()
void RGBController_Sinowealth::DeviceUpdateMode()
{
unsigned int direction = 0;
unsigned int speed = GLORIOUS_SPEED_NORMAL;
@ -216,13 +219,12 @@ void RGBController_GloriousModelO::DeviceUpdateMode()
if (modes[active_mode].color_mode == MODE_COLORS_NONE)
{
gmo->SetMode(modes[active_mode].value, speed, direction, 0);
sinowealth->SetMode(modes[active_mode].value, speed, direction, 0);
}
else
{
gmo->SetMode(modes[active_mode].value, speed, direction, &modes[active_mode].colors[0]);
sinowealth->SetMode(modes[active_mode].value, speed, direction, &modes[active_mode].colors[0]);
}
}
}
//wave, epilepsy, spectrum cycle, tail, glorious mode, off

View file

@ -1,8 +1,8 @@
/*-----------------------------------------*\
| RGBController_GloriousModelO.h |
| RGBController_Sinowealth.h |
| |
| Definitions and types for Glorious |
| and other Mice |
| Definitions and types for Sinowealth |
| mice, including Glorious |
| |
| Niels Westphal (crashniels) 20/5/2020 |
\*-----------------------------------------*/
@ -10,12 +10,12 @@
#pragma once
#include "RGBController.h"
#include "GloriousModelOController.h"
#include "SinowealthController.h"
class RGBController_GloriousModelO : public RGBController
class RGBController_Sinowealth : public RGBController
{
public:
RGBController_GloriousModelO(GloriousModelOController* gmo_ptr);
RGBController_Sinowealth(SinowealthController* sinowealth_ptr);
void SetupZones();
@ -26,8 +26,10 @@ public:
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
GloriousModelOController* gmo;
SinowealthController* sinowealth;
};