Initial addition for the CoolerMaster MP750 Controller
This commit is contained in:
parent
c65edbeebc
commit
7fe87703e5
7 changed files with 418 additions and 0 deletions
88
Controllers/CoolerMasterController/CMMP750Controller.cpp
Normal file
88
Controllers/CoolerMasterController/CMMP750Controller.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMMP750Controller.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
CMMP750Controller::CMMP750Controller(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
inAddr = 0x82;
|
||||
outAddr = 0x03;
|
||||
|
||||
strcpy(device_name, "CoolerMaster MP750");
|
||||
|
||||
current_mode = MP750_MODE_BREATHING;
|
||||
current_speed = 0x80;
|
||||
}
|
||||
|
||||
CMMP750Controller::~CMMP750Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* CMMP750Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
int actual = 0;
|
||||
unsigned char buffer[6] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
for(int i = 0; i < buffer_size; i++)
|
||||
{
|
||||
buffer[i] = colour_mode_data[mode][i];
|
||||
}
|
||||
|
||||
if(mode > 3)
|
||||
{ //If the mode is random colours set SPEED at BYTE2
|
||||
buffer[2] = speed;
|
||||
}
|
||||
else
|
||||
{ //Otherwise SPEED is BYTE5
|
||||
buffer[2] = current_red;
|
||||
buffer[3] = current_green;
|
||||
buffer[4] = current_blue;
|
||||
buffer[5] = speed;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, outAddr, buffer, buffer_size, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, inAddr, buffer, buffer_size, &actual, 0);
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
int actual = 0;
|
||||
unsigned char buffer[6] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
for(int i=0; i < buffer_size; i++)
|
||||
{
|
||||
buffer[i] = colour_mode_data[current_mode][i];
|
||||
}
|
||||
|
||||
if(current_mode > 3)
|
||||
{ //If the mode is random colours set SPEED at BYTE2
|
||||
buffer[2] = current_speed;
|
||||
}
|
||||
else
|
||||
{ //Otherwise SPEED is BYTE5
|
||||
buffer[2] = red;
|
||||
buffer[3] = green;
|
||||
buffer[4] = blue;
|
||||
buffer[5] = current_speed;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, outAddr, buffer, buffer_size, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, inAddr, buffer, buffer_size, &actual, 0);
|
||||
}
|
||||
|
||||
94
Controllers/CoolerMasterController/CMMP750Controller.h
Normal file
94
Controllers/CoolerMasterController/CMMP750Controller.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| BYTE0 = Mode (0x01 thru 0x05 |
|
||||
| BYTE1 = ?? Must be set to 0x04 for colour modes otherwise ignored |
|
||||
| BYTE2 = Colour Modes: RED else Cycle SPEED |
|
||||
| BYTE3 = Colour Modes: GREEN else ignored |
|
||||
| BYTE4 = Colour Modes: BLUE else ignored |
|
||||
| BYTE5 = Colour Modes: SPEED else ignored |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
MODE_BYTE = 0,
|
||||
RED_BYTE = 2,
|
||||
GREEN_BYTE = 3,
|
||||
BLUE_BYTE = 4,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_MODE_STATIC = 0x01, //Static Mode
|
||||
MP750_MODE_BLINK = 0x02, //Blinking Mode
|
||||
MP750_MODE_BREATHING = 0x03, //Breathing Mode
|
||||
MP750_MODE_COLOR_CYCLE = 0x04, //Color Cycle Mode
|
||||
MP750_MODE_BREATH_CYCLE = 0x05 //Breathing Cycle Mode
|
||||
};
|
||||
|
||||
static unsigned char colour_mode_data[][6] =
|
||||
{
|
||||
{ 0x01, 0x04, 0x00, 0x00, 0x00, 0x00 }, /* Static */
|
||||
{ 0x02, 0x04, 0x00, 0x00, 0x00, 0x80 }, /* Blinking */
|
||||
{ 0x03, 0x04, 0x00, 0x00, 0x00, 0x80 }, /* Breathing */
|
||||
{ 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */
|
||||
{ 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */
|
||||
};
|
||||
|
||||
static unsigned char speed_mode_data[][9] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Blinking */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Breathing */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Colour Cycle */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF } /* Colour Breath */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
MP750_SPEED_SLOWER = 0x01, /* Slower speed */
|
||||
MP750_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
MP750_SPEED_SLOWISH = 0x03, /* Slowish speed */
|
||||
MP750_SPEED_NORMAL = 0x04, /* Normal speed */
|
||||
MP750_SPEED_FASTISH = 0x05, /* Fastish speed */
|
||||
MP750_SPEED_FAST = 0x06, /* Fast speed */
|
||||
MP750_SPEED_FASTER = 0x07, /* Faster speed */
|
||||
MP750_SPEED_FASTEST = 0x08, /* Fastest speed */
|
||||
};
|
||||
|
||||
class CMMP750Controller
|
||||
{
|
||||
public:
|
||||
CMMP750Controller(libusb_device_handle *dev_handle);
|
||||
~CMMP750Controller();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
unsigned char inAddr;
|
||||
unsigned char outAddr;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
};
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#include "CMMP750Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define COOLERMASTER_VID 0x2516
|
||||
|
||||
#define COOLERMASTER_NUM_DEVICES (sizeof(cm_pids) / sizeof(cm_pids[ 0 ]))
|
||||
|
||||
static const unsigned int cm_pids[] =
|
||||
{
|
||||
0x0109
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCoolerMasterControllers *
|
||||
* *
|
||||
* Tests the USB address to see if any CoolerMaster controllers exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * context;
|
||||
libusb_init(&context);
|
||||
|
||||
for(int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
|
||||
{
|
||||
//Look for the passed in cm_pids
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(context, COOLERMASTER_VID, cm_pids[cm_pid_idx]);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 1);
|
||||
libusb_claim_interface(dev, 1);
|
||||
|
||||
CMMP750Controller* controller = new CMMP750Controller(dev);
|
||||
|
||||
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -303,6 +303,7 @@ void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
|
|||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
|
|
@ -347,6 +348,7 @@ void DetectRGBControllers(void)
|
|||
DetectHuePlusControllers(rgb_controllers);
|
||||
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
DetectCoolerMasterControllers(rgb_controllers);
|
||||
DetectMSI3ZoneControllers(rgb_controllers);
|
||||
DetectPoseidonZRGBControllers(rgb_controllers);
|
||||
DetectHyperXKeyboardControllers(rgb_controllers);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ INCLUDEPATH += \
|
|||
Controllers/AuraCoreController/ \
|
||||
Controllers/AuraGPUController/ \
|
||||
Controllers/AuraSMBusController/ \
|
||||
Controllers/CoolerMasterController/ \
|
||||
Controllers/CorsairPeripheralController/ \
|
||||
Controllers/CorsairLightingNodeController/ \
|
||||
Controllers/CorsairVengeanceController/ \
|
||||
|
|
@ -92,6 +93,8 @@ SOURCES += \
|
|||
Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.cpp \
|
||||
Controllers/AuraSMBusController/AuraSMBusControllerDetect.cpp \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.cpp \
|
||||
Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp \
|
||||
|
|
@ -144,6 +147,7 @@ SOURCES += \
|
|||
RGBController/RGBController_AuraCore.cpp \
|
||||
RGBController/RGBController_AuraGPU.cpp \
|
||||
RGBController/RGBController_AuraSMBus.cpp \
|
||||
RGBController/RGBController_CMMP750Controller.cpp \
|
||||
RGBController/RGBController_CorsairLightingNode.cpp \
|
||||
RGBController/RGBController_CorsairPeripheral.cpp \
|
||||
RGBController/RGBController_CorsairVengeance.cpp \
|
||||
|
|
@ -192,6 +196,7 @@ HEADERS += \
|
|||
Controllers/AuraCoreController/AuraCoreController.h \
|
||||
Controllers/AuraGPUController/AuraGPUController.h \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.h \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.h \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
|
||||
|
|
@ -220,6 +225,7 @@ HEADERS += \
|
|||
RGBController/RGBController_AuraCore.h \
|
||||
RGBController/RGBController_AuraGPU.h \
|
||||
RGBController/RGBController_AuraSMBus.h \
|
||||
RGBController/RGBController_CMMP750Controller.h \
|
||||
RGBController/RGBController_CorsairLightingNode.h \
|
||||
RGBController/RGBController_CorsairPeripheral.h \
|
||||
RGBController/RGBController_CorsairVengeance.h \
|
||||
|
|
|
|||
150
RGBController/RGBController_CMMP750Controller.cpp
Normal file
150
RGBController/RGBController_CMMP750Controller.cpp
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
|
||||
RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr)
|
||||
{
|
||||
cmmp750 = cmmp_ptr;
|
||||
|
||||
name = cmmp750->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = "Cooler Master Mousepad 750";
|
||||
version = "1.0";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = MP750_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = MP750_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Blink.speed_min = MP750_SPEED_SLOWEST;
|
||||
Blink.speed_max = MP750_SPEED_FASTEST;
|
||||
Blink.color_mode = MODE_COLORS_PER_LED;
|
||||
Blink.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = MP750_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = MP750_SPEED_SLOWEST;
|
||||
Breathing.speed_max = MP750_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = MP750_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
ColorCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColorCycle.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode BreathCycle;
|
||||
BreathCycle.name = "Breath Cycle";
|
||||
BreathCycle.value = MP750_MODE_BREATH_CYCLE;
|
||||
BreathCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
BreathCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
BreathCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
BreathCycle.color_mode = MODE_COLORS_NONE;
|
||||
BreathCycle.speed = MP750_SPEED_NORMAL;
|
||||
modes.push_back(BreathCycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CMMP750Controller::~RGBController_CMMP750Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetupZones()
|
||||
{
|
||||
zone MP_zone;
|
||||
MP_zone.name = "Mousepad";
|
||||
MP_zone.type = ZONE_TYPE_SINGLE;
|
||||
MP_zone.leds_min = 1;
|
||||
MP_zone.leds_max = 1;
|
||||
MP_zone.leds_count = 2;
|
||||
zones.push_back(MP_zone);
|
||||
|
||||
led MP_led;
|
||||
MP_led.name = "Mousepad LED";
|
||||
leds.push_back(MP_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case MP750_MODE_STATIC:
|
||||
cmmp750->SetMode(MP750_MODE_STATIC, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BLINK:
|
||||
cmmp750->SetMode(MP750_MODE_BLINK, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BREATHING:
|
||||
cmmp750->SetMode(MP750_MODE_BREATHING, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_COLOR_CYCLE:
|
||||
cmmp750->SetMode(MP750_MODE_COLOR_CYCLE, modes[active_mode].speed);
|
||||
break;
|
||||
case MP750_MODE_BREATH_CYCLE:
|
||||
cmmp750->SetMode(MP750_MODE_BREATH_CYCLE, modes[active_mode].speed);
|
||||
break;
|
||||
default:
|
||||
cmmp750->SetMode(MP750_MODE_BREATHING, modes[active_mode].speed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
31
RGBController/RGBController_CMMP750Controller.h
Normal file
31
RGBController/RGBController_CMMP750Controller.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMMP750Controller.h"
|
||||
|
||||
class RGBController_CMMP750Controller : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr);
|
||||
~RGBController_CMMP750Controller();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
private:
|
||||
CMMP750Controller* cmmp750;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue