diff --git a/Controllers/CoolerMasterController/CMMP750Controller.cpp b/Controllers/CoolerMasterController/CMMP750Controller.cpp index 049c2b7f..1c6dea24 100644 --- a/Controllers/CoolerMasterController/CMMP750Controller.cpp +++ b/Controllers/CoolerMasterController/CMMP750Controller.cpp @@ -11,9 +11,9 @@ CMMP750Controller::CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path) { - int tmp_size = wcslen(_vendor); - - dev = dev_handle; + int tmp_size = wcslen(_vendor); + dev = dev_handle; + location = _path; for (int i=0; ( i= buffer[6]; i++) + current_speed = i; + } + else + { + //Code should never reach here however just in case there is a failure set something + current_mode = MP750_MODE_COLOR_CYCLE; //Unicorn Spew + current_red = 0xFF; + current_green = 0xFF; + current_blue = 0xFF; + current_speed = MP750_SPEED_NORMAL; + } +} + char* CMMP750Controller::GetDeviceName() { return device_name; @@ -48,6 +75,31 @@ std::string CMMP750Controller::GetLocation() return location; } +unsigned char CMMP750Controller::GetMode() +{ + return current_mode; +} + +unsigned char CMMP750Controller::GetLedRed() +{ + return current_red; +} + +unsigned char CMMP750Controller::GetLedGreen() +{ + return current_green; +} + +unsigned char CMMP750Controller::GetLedBlue() +{ + return current_blue; +} + +unsigned char CMMP750Controller::GetLedSpeed() +{ + return current_speed; +} + void CMMP750Controller::SetMode(unsigned char mode, unsigned char speed) { current_mode = mode; diff --git a/Controllers/CoolerMasterController/CMMP750Controller.h b/Controllers/CoolerMasterController/CMMP750Controller.h index eaa3ed88..4f3383af 100644 --- a/Controllers/CoolerMasterController/CMMP750Controller.h +++ b/Controllers/CoolerMasterController/CMMP750Controller.h @@ -85,6 +85,11 @@ public: char* GetSerial(); std::string GetLocation(); + unsigned char GetMode(); + unsigned char GetLedRed(); + unsigned char GetLedGreen(); + unsigned char GetLedBlue(); + unsigned char GetLedSpeed(); void SetMode(unsigned char mode, unsigned char speed); void SetColor(unsigned char red, unsigned char green, unsigned char blue); @@ -101,5 +106,6 @@ private: unsigned char current_green; unsigned char current_blue; + void GetStatus(); void SendUpdate(); }; diff --git a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp index a1970c70..ac3ce50b 100644 --- a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp +++ b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp @@ -56,7 +56,7 @@ void DetectCoolerMasterControllers(std::vector& rgb_controllers) if(dev) { - CMMP750Controller* controller = new CMMP750Controller(dev, info->manufacturer_string, info->product_string, info->path); + CMMP750Controller* controller = new CMMP750Controller(dev, info->manufacturer_string, info->product_string, info->path); RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller); rgb_controllers.push_back(rgb_controller); } diff --git a/RGBController/RGBController_CMMP750Controller.cpp b/RGBController/RGBController_CMMP750Controller.cpp index 2cc26d50..c17e9275 100644 --- a/RGBController/RGBController_CMMP750Controller.cpp +++ b/RGBController/RGBController_CMMP750Controller.cpp @@ -11,14 +11,15 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr) { - cmmp750 = cmmp_ptr; + cmmp750 = cmmp_ptr; + unsigned char speed = cmmp750->GetLedSpeed(); - name = cmmp750->GetDeviceName(); - type = DEVICE_TYPE_MOUSEMAT; - description = cmmp750->GetDeviceName(); - version = "1.0"; - serial = ""; - location = cmmp750->GetLocation(); + name = cmmp750->GetDeviceName(); + type = DEVICE_TYPE_MOUSEMAT; + description = cmmp750->GetDeviceName(); + version = "1.0"; + serial = ""; + location = cmmp750->GetLocation(); mode Static; Static.name = "Static"; @@ -34,7 +35,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll Blink.speed_min = MP750_SPEED_SLOWEST; Blink.speed_max = MP750_SPEED_FASTEST; Blink.color_mode = MODE_COLORS_PER_LED; - Blink.speed = MP750_SPEED_NORMAL; + Blink.speed = speed; modes.push_back(Blink); mode Breathing; @@ -44,7 +45,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll Breathing.speed_min = MP750_SPEED_SLOWEST; Breathing.speed_max = MP750_SPEED_FASTEST; Breathing.color_mode = MODE_COLORS_PER_LED; - Breathing.speed = MP750_SPEED_NORMAL; + Breathing.speed = speed; modes.push_back(Breathing); mode ColorCycle; @@ -54,7 +55,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll ColorCycle.speed_min = MP750_SPEED_SLOWEST; ColorCycle.speed_max = MP750_SPEED_FASTEST; ColorCycle.color_mode = MODE_COLORS_NONE; - ColorCycle.speed = MP750_SPEED_NORMAL; + ColorCycle.speed = speed; modes.push_back(ColorCycle); mode BreathCycle; @@ -64,10 +65,11 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll BreathCycle.speed_min = MP750_SPEED_SLOWEST; BreathCycle.speed_max = MP750_SPEED_FASTEST; BreathCycle.color_mode = MODE_COLORS_NONE; - BreathCycle.speed = MP750_SPEED_NORMAL; + BreathCycle.speed = speed; modes.push_back(BreathCycle); SetupZones(); + active_mode = cmmp750->GetMode(); } RGBController_CMMP750Controller::~RGBController_CMMP750Controller() @@ -91,6 +93,18 @@ void RGBController_CMMP750Controller::SetupZones() leds.push_back(MP_led); SetupColors(); + + /*---------------------------------------------------------*\ + | Initialize colors for each LED | + \*---------------------------------------------------------*/ + for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++) + { + unsigned char red = cmmp750->GetLedRed(); + unsigned char grn = cmmp750->GetLedGreen(); + unsigned char blu = cmmp750->GetLedBlue(); + + colors[led_idx] = ToRGBColor(red, grn, blu); + } } void RGBController_CMMP750Controller::ResizeZone(int /*zone*/, int /*new_size*/) diff --git a/RGBController/RGBController_CMMP750Controller.h b/RGBController/RGBController_CMMP750Controller.h index 81995522..9a9e99ed 100644 --- a/RGBController/RGBController_CMMP750Controller.h +++ b/RGBController/RGBController_CMMP750Controller.h @@ -28,4 +28,6 @@ public: void UpdateMode(); private: CMMP750Controller* cmmp750; + + int GetDeviceMode(); };