From 1cc2c3c25251ca59ee2b3911a0b720bf2fed0e5d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 31 Mar 2021 00:08:32 +1100 Subject: [PATCH] Resolving the Windows HIDAPI interface problem by changing the IPU macro to PU * Moved "Off" mode to last * Created GetDeviceMode() to accomodate change * Code formatting cleanup --- .../CoolerMasterControllerDetect.cpp | 10 +- .../RGBController_CMMP750Controller.cpp | 152 ++++++++++++------ 2 files changed, 109 insertions(+), 53 deletions(-) diff --git a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp index 8c0b8bc3..b0698971 100644 --- a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp +++ b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp @@ -77,8 +77,8 @@ void DetectCoolerMasterGPU(hid_device_info* info, const std::string&) } } -REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 XL", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_XL_PID, 0, 0xFF00, 1); -REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 Medium", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_MEDIUM_PID, 0, 0xFF00, 1); -REGISTER_HID_DETECTOR_IPU("Cooler Master ARGB", DetectCoolerMasterARGB, COOLERMASTER_VID, COOLERMASTER_ARGB_PID, 0, 0xFF00, 1); -REGISTER_HID_DETECTOR_IPU("Cooler Master Smalll ARGB", DetectCoolerMasterSmallARGB, COOLERMASTER_VID, COOLERMASTER_SMALL_ARGB_PID, 0, 0xFF00, 1); -REGISTER_HID_DETECTOR_I("Cooler Master Radeon 6000 GPU",DetectCoolerMasterGPU, COOLERMASTER_VID, COOLERMASTER_RADEON_6000_PID, 1); +REGISTER_HID_DETECTOR_PU ("Cooler Master MP750 XL", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_XL_PID, 0xFF00, 1); +REGISTER_HID_DETECTOR_PU ("Cooler Master MP750 Medium", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_MEDIUM_PID, 0xFF00, 1); +REGISTER_HID_DETECTOR_IPU("Cooler Master ARGB", DetectCoolerMasterARGB, COOLERMASTER_VID, COOLERMASTER_ARGB_PID, 0, 0xFF00, 1); +REGISTER_HID_DETECTOR_IPU("Cooler Master Smalll ARGB", DetectCoolerMasterSmallARGB, COOLERMASTER_VID, COOLERMASTER_SMALL_ARGB_PID, 0, 0xFF00, 1); +REGISTER_HID_DETECTOR_I ("Cooler Master Radeon 6000 GPU", DetectCoolerMasterGPU, COOLERMASTER_VID, COOLERMASTER_RADEON_6000_PID, 1); diff --git a/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp b/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp index b55f4478..6a638486 100644 --- a/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp +++ b/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp @@ -11,72 +11,72 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr) { - cmmp750 = cmmp_ptr; - unsigned char speed = cmmp750->GetLedSpeed(); + cmmp750 = cmmp_ptr; + unsigned char speed = cmmp750->GetLedSpeed(); - name = cmmp750->GetDeviceName(); - vendor = "Cooler Master"; - type = DEVICE_TYPE_MOUSEMAT; - description = cmmp750->GetDeviceName(); - version = "1.0"; - serial = cmmp750->GetSerial(); - location = cmmp750->GetLocation(); - - mode Off; - Off.name = "Turn Off"; - Off.value = CM_MP750_MODE_OFF; - Off.color_mode = MODE_COLORS_NONE; - modes.push_back(Off); + name = cmmp750->GetDeviceName(); + vendor = "Cooler Master"; + type = DEVICE_TYPE_MOUSEMAT; + description = cmmp750->GetDeviceName(); + version = "1.0"; + serial = cmmp750->GetSerial(); + location = cmmp750->GetLocation(); mode Static; - Static.name = "Static"; - Static.value = CM_MP750_MODE_STATIC; - Static.flags = MODE_FLAG_HAS_PER_LED_COLOR; - Static.color_mode = MODE_COLORS_PER_LED; + Static.name = "Static"; + Static.value = CM_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 = CM_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 = speed; + Blink.name = "Blink"; + Blink.value = CM_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 = speed; modes.push_back(Blink); mode Breathing; - Breathing.name = "Breathing"; - Breathing.value = CM_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 = speed; + Breathing.name = "Breathing"; + Breathing.value = CM_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 = speed; modes.push_back(Breathing); mode ColorCycle; - ColorCycle.name = "Color Cycle"; - ColorCycle.value = CM_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 = speed; + ColorCycle.name = "Color Cycle"; + ColorCycle.value = CM_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 = speed; modes.push_back(ColorCycle); mode BreathCycle; - BreathCycle.name = "Breath Cycle"; - BreathCycle.value = CM_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 = speed; + BreathCycle.name = "Breath Cycle"; + BreathCycle.value = CM_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 = speed; modes.push_back(BreathCycle); + mode Off; + Off.name = "Turn Off"; + Off.value = CM_MP750_MODE_OFF; + Off.color_mode = MODE_COLORS_NONE; + modes.push_back(Off); + SetupZones(); - active_mode = cmmp750->GetMode(); + active_mode = GetDeviceMode(); } RGBController_CMMP750Controller::~RGBController_CMMP750Controller() @@ -84,6 +84,62 @@ RGBController_CMMP750Controller::~RGBController_CMMP750Controller() delete cmmp750; } +int RGBController_CMMP750Controller::GetDeviceMode() +{ + int temp_mode = cmmp750->GetMode(); + for( int i = 0; i < modes.size(); i++) + { + if (temp_mode == modes[i].value) + { + return i; + } + } + //If not found return 0 + return 0; +} + +int RGBController_CMMP750Controller::GetDeviceMode() +{ + int temp_mode = cmmp750->GetMode(); + for( int i = 0; i < modes.size(); i++) + { + if (temp_mode == modes[i].value) + { + return i; + } + } + //If not found return 0 + return 0; +} + +int RGBController_CMMP750Controller::GetDeviceMode() +{ + int temp_mode = cmmp750->GetMode(); + for( int i = 0; i < modes.size(); i++) + { + if (temp_mode == modes[i].value) + { + return i; + } + } + //If not found return 0 + return 0; +} + +int RGBController_CMMP750Controller::GetDeviceMode() +{ + int temp_mode = cmmp750->GetMode(); + for( int i = 0; i < modes.size(); i++) + { + if (temp_mode == modes[i].value) + { + return i; + } + } + //If not found return 0 + return 0; +} + void RGBController_CMMP750Controller::SetupZones() { zone MP_zone;