Update Redragon M711 controller with generic write function
This commit is contained in:
parent
479d51df87
commit
919d89d52f
3 changed files with 106 additions and 30 deletions
|
|
@ -20,6 +20,63 @@ static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
|||
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
unsigned char active_profile = 0x00;
|
||||
|
||||
SendWritePacket(0x002C, 1, &active_profile);
|
||||
SendMouseApply();
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char color_buf[3];
|
||||
|
||||
color_buf[0] = red;
|
||||
color_buf[1] = green;
|
||||
color_buf[2] = blue;
|
||||
|
||||
SendWritePacket(0x0449, 3, color_buf);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char mode_buf[3];
|
||||
|
||||
mode_buf[0] = 0x01; //On
|
||||
mode_buf[1] = speed;
|
||||
mode_buf[2] = mode;
|
||||
|
||||
SendWritePacket(0x044C, 3, mode_buf);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char color_mode_buf[6];
|
||||
|
||||
color_mode_buf[0] = red;
|
||||
color_mode_buf[1] = green;
|
||||
color_mode_buf[2] = blue;
|
||||
color_mode_buf[3] = 0x01; //On
|
||||
color_mode_buf[4] = speed;
|
||||
color_mode_buf[5] = mode;
|
||||
|
||||
SendWritePacket(0x0449, 6, color_mode_buf);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
|
|
@ -49,13 +106,11 @@ void RedragonM711Controller::SendMouseApply()
|
|||
send_usb_msg(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
void RedragonM711Controller::SendWritePacket
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
unsigned short address,
|
||||
unsigned char data_size,
|
||||
unsigned char * data
|
||||
)
|
||||
{
|
||||
char usb_buf[16];
|
||||
|
|
@ -70,19 +125,15 @@ void RedragonM711Controller::SendMouseMode
|
|||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x02;
|
||||
usb_buf[0x01] = 0xF3;
|
||||
usb_buf[0x02] = 0x49;
|
||||
usb_buf[0x03] = 0x04;
|
||||
usb_buf[0x04] = 0x06;
|
||||
|
||||
usb_buf[0x08] = red;
|
||||
usb_buf[0x09] = green;
|
||||
usb_buf[0x0A] = blue;
|
||||
|
||||
usb_buf[0x0B] = 0x01; //on
|
||||
|
||||
usb_buf[0x0C] = speed;
|
||||
usb_buf[0x0D] = mode;
|
||||
usb_buf[0x02] = address & 0xFF;
|
||||
usb_buf[0x03] = address >> 8;
|
||||
usb_buf[0x04] = data_size;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], data, data_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -32,6 +32,19 @@ public:
|
|||
|
||||
void SendMouseApply();
|
||||
|
||||
void SendMouseColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
|
|
@ -43,4 +56,11 @@ public:
|
|||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void SendWritePacket
|
||||
(
|
||||
unsigned short address,
|
||||
unsigned char data_size,
|
||||
unsigned char * data
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -82,20 +82,11 @@ void RGBController_RedragonM711::ResizeZone(int /*zone*/, int /*new_size*/)
|
|||
|
||||
void RGBController_RedragonM711::DeviceUpdateLEDs()
|
||||
{
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
if((modes[active_mode].value == REDRAGON_M711_MODE_BREATHING) && random)
|
||||
{
|
||||
redragon->SendMouseMode(REDRAGON_M711_MODE_RANDOM_BREATHING, 0, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
redragon->SendMouseMode(modes[active_mode].value, 0, red, grn, blu);
|
||||
}
|
||||
|
||||
redragon->SendMouseColor(red, grn, blu);
|
||||
redragon->SendMouseApply();
|
||||
}
|
||||
|
||||
|
|
@ -111,10 +102,24 @@ void RGBController_RedragonM711::UpdateSingleLED(int /*led*/)
|
|||
|
||||
void RGBController_RedragonM711::SetCustomMode()
|
||||
{
|
||||
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_RedragonM711::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
if((modes[active_mode].value == REDRAGON_M711_MODE_BREATHING) && random)
|
||||
{
|
||||
redragon->SendMouseMode(REDRAGON_M711_MODE_RANDOM_BREATHING, 0, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
redragon->SendMouseMode(modes[active_mode].value, 0, red, grn, blu);
|
||||
}
|
||||
|
||||
redragon->SendMouseApply();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue