From 40bf2b75b848d5cdbd31b75991b69f06ebe5ff44 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sat, 6 Mar 2021 22:29:15 -0600 Subject: [PATCH] Clean up MSI Mystic Light code for 185-byte devices --- ...er.cpp => MSIMysticLight185Controller.cpp} | 194 ++++-------------- ...roller.h => MSIMysticLight185Controller.h} | 101 +++------ .../MSIMysticLightControllerDetect.cpp | 120 +++++------ ...pp => RGBController_MSIMysticLight185.cpp} | 70 +++---- ...ht.h => RGBController_MSIMysticLight185.h} | 15 +- OpenRGB.pro | 8 +- 6 files changed, 172 insertions(+), 336 deletions(-) rename Controllers/MSIMysticLightController/{MSIMysticLightController.cpp => MSIMysticLight185Controller.cpp} (67%) rename Controllers/MSIMysticLightController/{MSIMysticLightController.h => MSIMysticLight185Controller.h} (72%) rename Controllers/MSIMysticLightController/{RGBController_MSIMysticLight.cpp => RGBController_MSIMysticLight185.cpp} (80%) rename Controllers/MSIMysticLightController/{RGBController_MSIMysticLight.h => RGBController_MSIMysticLight185.h} (66%) diff --git a/Controllers/MSIMysticLightController/MSIMysticLightController.cpp b/Controllers/MSIMysticLightController/MSIMysticLight185Controller.cpp similarity index 67% rename from Controllers/MSIMysticLightController/MSIMysticLightController.cpp rename to Controllers/MSIMysticLightController/MSIMysticLight185Controller.cpp index fd0d534e..f93c1b9e 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLightController.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller.cpp @@ -1,18 +1,19 @@ /*-----------------------------------------*\ -| MSIMysticLightController.cpp | +| MSIMysticLight185Controller.cpp | | | -| Driver for MSI Mystic Light USB | -| lighting controller | +| Driver for MSI Mystic Light (185-byte) | +| USB lighting controller | | | | T-bond 3/4/2020 | +| Adam Honse 3/6/2021 | \*-----------------------------------------*/ -#include "MSIMysticLightController.h" +#include "MSIMysticLight185Controller.h" #include #include #include -MSIMysticLightController::MSIMysticLightController(hid_device* handle, const char *path) +MSIMysticLight185Controller::MSIMysticLight185Controller(hid_device* handle, const char *path) { dev = handle; @@ -25,14 +26,19 @@ MSIMysticLightController::MSIMysticLightController(hid_device* handle, const cha ReadFwVersion(); ReadSettings(); } + + /*-----------------------------------------*\ + | Initialize save flag | + \*-----------------------------------------*/ + data.save_data = 0; } -MSIMysticLightController::~MSIMysticLightController() +MSIMysticLight185Controller::~MSIMysticLight185Controller() { hid_close(dev); } -unsigned int MSIMysticLightController::GetZoneMinLedCount +unsigned int MSIMysticLight185Controller::GetZoneMinLedCount ( MSI_ZONE /*zone*/ ) @@ -40,7 +46,7 @@ unsigned int MSIMysticLightController::GetZoneMinLedCount return 1; } -unsigned int MSIMysticLightController::GetZoneMaxLedCount +unsigned int MSIMysticLight185Controller::GetZoneMaxLedCount ( MSI_ZONE zone ) @@ -56,7 +62,7 @@ unsigned int MSIMysticLightController::GetZoneMaxLedCount } } -unsigned int MSIMysticLightController::GetZoneLedCount +unsigned int MSIMysticLight185Controller::GetZoneLedCount ( MSI_ZONE zone ) @@ -71,7 +77,7 @@ unsigned int MSIMysticLightController::GetZoneLedCount return requestedZone->cycle_or_led_num; } -void MSIMysticLightController::SetZoneLedCount +void MSIMysticLight185Controller::SetZoneLedCount ( MSI_ZONE zone, unsigned int led_count @@ -88,7 +94,7 @@ void MSIMysticLightController::SetZoneLedCount requestedZone->cycle_or_led_num = led_count; } -void MSIMysticLightController::SetMode +void MSIMysticLight185Controller::SetMode ( MSI_ZONE zone, MSI_MODE mode, @@ -103,32 +109,33 @@ void MSIMysticLightController::SetMode return; } - zoneData->effect = mode; - zoneData->speedAndBrightnessFlags = (zoneData->speedAndBrightnessFlags & 128u) | brightness << 2u | speed; - zoneData->colorFlags = BitSet(zoneData->colorFlags, !rainbow_color, 7u); + zoneData->effect = mode; + zoneData->speedAndBrightnessFlags = ( brightness << 2u ) | speed; + zoneData->colorFlags = 0x00;// BitSet(zoneData->colorFlags, !rainbow_color, 7u); + zoneData->padding = 0x00; } -std::string MSIMysticLightController::GetDeviceName() +std::string MSIMysticLight185Controller::GetDeviceName() { return name; } -std::string MSIMysticLightController::GetFWVersion() +std::string MSIMysticLight185Controller::GetFWVersion() { return std::string("AP/LD ").append(version_APROM).append(" / ").append(version_LDROM); } -std::string MSIMysticLightController::GetDeviceLocation() +std::string MSIMysticLight185Controller::GetDeviceLocation() { return("HID: " + location); } -std::string MSIMysticLightController::GetSerial() +std::string MSIMysticLight185Controller::GetSerial() { return chip_id; } -bool MSIMysticLightController::ReadSettings() +bool MSIMysticLight185Controller::ReadSettings() { /*-----------------------------------------------------*\ | Read packet from hardware, return true if successful | @@ -136,7 +143,7 @@ bool MSIMysticLightController::ReadSettings() return(hid_get_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data); } -bool MSIMysticLightController::Update() +bool MSIMysticLight185Controller::Update() { /*-----------------------------------------------------*\ | Send packet to hardware, return true if successful | @@ -144,12 +151,7 @@ bool MSIMysticLightController::Update() return(hid_send_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data); } -void MSIMysticLightController::SaveOnUpdate(bool save) -{ - data.save_data = save; -} - -void MSIMysticLightController::SetZoneColor +void MSIMysticLight185Controller::SetZoneColor ( MSI_ZONE zone, unsigned char red1, @@ -176,7 +178,7 @@ void MSIMysticLightController::SetZoneColor zoneData->color2.B = blu2; } -std::pair MSIMysticLightController::GetZoneColor +std::pair MSIMysticLight185Controller::GetZoneColor ( MSI_ZONE zone ) @@ -195,7 +197,7 @@ std::pair MSIMysticLightController::GetZoneColor Color{zoneData->color2.R, zoneData->color2.G, zoneData->color2.B}); } -ZoneData *MSIMysticLightController::GetZoneData +ZoneData *MSIMysticLight185Controller::GetZoneData ( MSI_ZONE zone ) @@ -244,7 +246,7 @@ ZoneData *MSIMysticLightController::GetZoneData return nullptr; } -RainbowZoneData *MSIMysticLightController::GetRainbowZoneData +RainbowZoneData *MSIMysticLight185Controller::GetRainbowZoneData ( MSI_ZONE zone ) @@ -261,7 +263,7 @@ RainbowZoneData *MSIMysticLightController::GetRainbowZoneData } } -bool MSIMysticLightController::ReadFwVersion() +bool MSIMysticLight185Controller::ReadFwVersion() { unsigned char request[64]; unsigned char response[64]; @@ -343,7 +345,7 @@ bool MSIMysticLightController::ReadFwVersion() return(ret_val > 0); } -void MSIMysticLightController::ReadSerial() +void MSIMysticLight185Controller::ReadSerial() { wchar_t serial[256]; @@ -359,7 +361,7 @@ void MSIMysticLightController::ReadSerial() chip_id = std::string(wserial.begin(), wserial.end()); } -void MSIMysticLightController::ReadName() +void MSIMysticLight185Controller::ReadName() { wchar_t tname[256]; @@ -386,84 +388,7 @@ void MSIMysticLightController::ReadName() name.append(" ").append(std::string(wname.begin(), wname.end())); } -void MSIMysticLightController::SetDeviceSettings - ( - bool is_fan, - MSI_FAN_TYPE fan_type, - unsigned char corsair_device_quantity, - bool is_LL120Outer_individual - ) -{ - /*-----------------------------------------------------*\ - | If is_fan is false, it is an LED strip | - \*-----------------------------------------------------*/ - CorsairZoneData &settingsZone = data.j_corsair; - settingsZone.fan_flags = (settingsZone.fan_flags & 0x80) | fan_type << 1 | is_fan; - settingsZone.corsair_quantity = corsair_device_quantity << 2; - settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0); -} - -bool MSIMysticLightController::SetVolume - ( - unsigned char main, - unsigned char left, - unsigned char right - ) -{ - unsigned char packet[64]; - std::fill_n(packet, sizeof packet, 204u); - - if(main > 100u) - { - main = 100u; - } - - if(left > 100u) - { - left = 100u; - } - - if(right > 100u) - { - right = 100u; - } - - packet[0] = 1u; - packet[1] = 192u; - packet[3] = main; - packet[4] = left; - packet[5] = right; - - return hid_write(dev, packet, sizeof packet); -} - -void MSIMysticLightController::SetBoardSyncSettings - ( - bool onboard_sync, - bool combine_JRGB, - bool combine_JPIPE1, - bool combine_JPIPE2, - bool combine_JRAINBOW1, - bool combine_JRAINBOW2, - bool combine_crossair - ) -{ - ZoneData &syncZone = data.on_board_led; - - /*-----------------------------------------------------*\ - | Set sync flags for on-board LED zone | - \*-----------------------------------------------------*/ - syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0); - syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1); - syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2); - syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3); - syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4); - syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5); - - syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7); -} - -void MSIMysticLightController::GetMode +void MSIMysticLight185Controller::GetMode ( MSI_ZONE zone, MSI_MODE &mode, @@ -494,7 +419,7 @@ void MSIMysticLightController::GetMode rainbow_color = (zoneData->colorFlags & 0x80) >> 7; } -unsigned char MSIMysticLightController::BitSet +unsigned char MSIMysticLight185Controller::BitSet ( unsigned char value, bool bit, @@ -504,7 +429,7 @@ unsigned char MSIMysticLightController::BitSet return static_cast(std::bitset<8>(value).set(position, bit).to_ulong()); } -void MSIMysticLightController::SetCycleCount +void MSIMysticLight185Controller::SetCycleCount ( MSI_ZONE zone, unsigned char cycle_num @@ -520,7 +445,7 @@ void MSIMysticLightController::SetCycleCount requestedZone->cycle_or_led_num = cycle_num; } -unsigned char MSIMysticLightController::GetCycleCount +unsigned char MSIMysticLight185Controller::GetCycleCount ( MSI_ZONE zone ) @@ -533,45 +458,4 @@ unsigned char MSIMysticLightController::GetCycleCount } return requestedZone->cycle_or_led_num; -} - -void MSIMysticLightController::GetBoardSyncSettings - ( - bool &onboard_sync, - bool &combine_JRGB, - bool &combine_JPIPE1, - bool &combine_JPIPE2, - bool &combine_JRAINBOW1, - bool &combine_JRAINBOW2, - bool &combine_crossair - ) -{ - ZoneData &syncZone = data.on_board_led; - - /*-----------------------------------------------------*\ - | Get sync flags for on-board LED zone | - \*-----------------------------------------------------*/ - onboard_sync = (syncZone.colorFlags >> 0) & 0x01; - combine_JRAINBOW1 = (syncZone.colorFlags >> 1) & 0x01; - combine_JRAINBOW2 = (syncZone.colorFlags >> 2) & 0x01; - combine_crossair = (syncZone.colorFlags >> 3) & 0x01; - combine_JPIPE1 = (syncZone.colorFlags >> 4) & 0x01; - combine_JPIPE2 = (syncZone.colorFlags >> 5) & 0x01; - - combine_JRGB = (syncZone.speedAndBrightnessFlags & 0x80) >> 7; -} - -void MSIMysticLightController::GetDeviceSettings - ( - bool &stripe_or_fan, - MSI_FAN_TYPE &fan_type, - unsigned char &corsair_device_quantity, - bool &is_LL120Outer_individual - ) -{ - CorsairZoneData &settingsZone = data.j_corsair; - stripe_or_fan = settingsZone.fan_flags & 0x01; - fan_type = (MSI_FAN_TYPE )((settingsZone.fan_flags & 14u) >> 1); - corsair_device_quantity = (settingsZone.corsair_quantity & 0xFC) >> 2; - is_LL120Outer_individual = settingsZone.is_individual & 0x01; -} +} \ No newline at end of file diff --git a/Controllers/MSIMysticLightController/MSIMysticLightController.h b/Controllers/MSIMysticLightController/MSIMysticLight185Controller.h similarity index 72% rename from Controllers/MSIMysticLightController/MSIMysticLightController.h rename to Controllers/MSIMysticLightController/MSIMysticLight185Controller.h index 3b378eff..4505bf69 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLightController.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller.h @@ -1,10 +1,12 @@ /*-----------------------------------------*\ -| MSIMysticLightController.h | +| MSIMysticLight185Controller.h | | | | Definitions and types for MSI Mystic | -| Light USB lighting controllers | +| Light (185-byte) USB lighting | +| controllers | | | | T-bond 3/4/2020 | +| Adam Honse 3/6/2021 | \*-----------------------------------------*/ #include "RGBController.h" @@ -17,23 +19,23 @@ enum MSI_ZONE { MSI_ZONE_J_RGB_1 = 1, - MSI_ZONE_J_RGB_2 = 174, - MSI_ZONE_J_PIPE_1 = 11, - MSI_ZONE_J_PIPE_2 = 21, - MSI_ZONE_J_RAINBOW_1 = 31, - MSI_ZONE_J_RAINBOW_2 = 42, - MSI_ZONE_J_CORSAIR = 53, - MSI_ZONE_J_CORSAIR_OUTERLL120 = 64, - MSI_ZONE_ON_BOARD_LED = 74, - MSI_ZONE_ON_BOARD_LED_1 = 84, - MSI_ZONE_ON_BOARD_LED_2 = 94, - MSI_ZONE_ON_BOARD_LED_3 = 104, - MSI_ZONE_ON_BOARD_LED_4 = 114, - MSI_ZONE_ON_BOARD_LED_5 = 124, - MSI_ZONE_ON_BOARD_LED_6 = 134, - MSI_ZONE_ON_BOARD_LED_7 = 144, - MSI_ZONE_ON_BOARD_LED_8 = 154, - MSI_ZONE_ON_BOARD_LED_9 = 164 + MSI_ZONE_J_RGB_2 = 2, + MSI_ZONE_J_PIPE_1 = 3, + MSI_ZONE_J_PIPE_2 = 4, + MSI_ZONE_J_RAINBOW_1 = 5, + MSI_ZONE_J_RAINBOW_2 = 6, + MSI_ZONE_J_CORSAIR = 7, + MSI_ZONE_J_CORSAIR_OUTERLL120 = 8, + MSI_ZONE_ON_BOARD_LED = 9, + MSI_ZONE_ON_BOARD_LED_1 = 10, + MSI_ZONE_ON_BOARD_LED_2 = 11, + MSI_ZONE_ON_BOARD_LED_3 = 12, + MSI_ZONE_ON_BOARD_LED_4 = 13, + MSI_ZONE_ON_BOARD_LED_5 = 14, + MSI_ZONE_ON_BOARD_LED_6 = 15, + MSI_ZONE_ON_BOARD_LED_7 = 16, + MSI_ZONE_ON_BOARD_LED_8 = 17, + MSI_ZONE_ON_BOARD_LED_9 = 18 }; struct ZoneDescription @@ -136,10 +138,10 @@ struct ZoneData { unsigned char effect = MSI_MODE_STATIC; Color color { 0, 0, 0 }; - unsigned char speedAndBrightnessFlags = 40; + unsigned char speedAndBrightnessFlags = 0; Color color2 { 0, 0, 0 }; - unsigned char colorFlags = 128; - const unsigned char padding = 0; + unsigned char colorFlags = 0; + unsigned char padding = 0; }; struct RainbowZoneData : ZoneData @@ -147,7 +149,7 @@ struct RainbowZoneData : ZoneData unsigned char cycle_or_led_num = 20; }; -struct FeaturePacket +struct FeaturePacket_185 { const unsigned char report_id = 0x52; // Report ID ZoneData j_rgb_1; // 1 @@ -172,11 +174,11 @@ struct FeaturePacket }; -class MSIMysticLightController +class MSIMysticLight185Controller { public: - MSIMysticLightController(hid_device* handle, const char *path); - ~MSIMysticLightController(); + MSIMysticLight185Controller(hid_device* handle, const char *path); + ~MSIMysticLight185Controller(); unsigned int GetZoneMinLedCount ( @@ -244,51 +246,6 @@ public: bool Update(); - void SetDeviceSettings - ( - bool stripe_or_fan, - MSI_FAN_TYPE fan_type, - unsigned char corsair_device_quantity, - bool is_LL120Outer_individual - ); - - void GetDeviceSettings - ( - bool &stripe_or_fan, - MSI_FAN_TYPE &fan_type, - unsigned char &corsair_device_quantity, - bool &is_LL120Outer_individual - ); - - bool SetVolume - ( - unsigned char main, - unsigned char left, - unsigned char right - ); - - void SetBoardSyncSettings - ( - bool onboard_sync, - bool combine_JRGB, - bool combine_JPIPE1, - bool combine_JPIPE2, - bool combine_JRAINBOW1, - bool combine_JRAINBOW2, - bool combine_crossair - ); - - void GetBoardSyncSettings - ( - bool &onboard_sync, - bool &combine_JRGB, - bool &combine_JPIPE1, - bool &combine_JPIPE2, - bool &combine_JRAINBOW1, - bool &combine_JRAINBOW2, - bool &combine_crossair - ); - std::string GetDeviceName(); std::string GetDeviceLocation(); std::string GetFWVersion(); @@ -312,5 +269,5 @@ private: std::string version_LDROM; std::string chip_id; - FeaturePacket data; + FeaturePacket_185 data; }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp index c5b0c17c..7082895e 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp @@ -1,79 +1,79 @@ #include "Detector.h" -#include "MSIMysticLightController.h" -#include "RGBController_MSIMysticLight.h" +#include "MSIMysticLight185Controller.h" +#include "RGBController_MSIMysticLight185.h" #define MSI_USB_VID 0x1462 -/******************************************************************************************\ -* * -* DetectMSIMysticLightControllers * -* * -* Detect MSI Mystic Light devices that use NCT6775 RGB controllers * -* * -\******************************************************************************************/ - // WARNING! // // The MSI Mystic Light controller is disabled due to bricking risk // Uncomment this line to enable. Do so at your own risk. -// #define ENABLE_MYSTIC_LIGHT +//#define ENABLE_MYSTIC_LIGHT -void DetectMSIMysticLightControllers(hid_device_info* info, const std::string& name) +/******************************************************************************************\ +* * +* DetectMSIMysticLight185Controllers * +* * +* Detect MSI Mystic Light (185-byte) devices * +* * +\******************************************************************************************/ + +void DetectMSIMysticLight185Controllers(hid_device_info* info, const std::string& name) { hid_device* dev = hid_open_path(info->path); if( dev ) { - MSIMysticLightController * controller = new MSIMysticLightController(dev, info->path); - RGBController_MSIMysticLight * rgb_controller = new RGBController_MSIMysticLight(controller); - rgb_controller->name = name; + MSIMysticLight185Controller* controller = new MSIMysticLight185Controller(dev, info->path); + RGBController_MSIMysticLight185* rgb_controller = new RGBController_MSIMysticLight185(controller); + ResourceManager::get()->RegisterRGBController(rgb_controller); } -} /* DetectMSIMysticLightControllers() */ +} /* DetectMSIMysticLight185Controllers() */ #ifdef ENABLE_MYSTIC_LIGHT -REGISTER_HID_DETECTOR("MSI Mystic Light MS_3EA4", DetectMSIMysticLightControllers, MSI_USB_VID, 0x3EA4); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_4459", DetectMSIMysticLightControllers, MSI_USB_VID, 0x4459); - -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B10", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7B10); -REGISTER_HID_DETECTOR("MSI B450 Pro Carbon AC", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7B93); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B94", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7B94); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B96", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7B96); - -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C34", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C34); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C35", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C35); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C36", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C36); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C37", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C37); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C42", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C42); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C56", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C56); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C59", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C59); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C60", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C60); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C67", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C67); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C70", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C70); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C71", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C71); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C73", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C73); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C75", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C75); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C76", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C76); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C77", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C77); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C79", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C79); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C80", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C80); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C81", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C81); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C82", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C82); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C83", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C83); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C84", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C84); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C85", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C85); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C86", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C86); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C87", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C87); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C88", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C88); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C89", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C89); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C90", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C90); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C91", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C91); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C92", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C92); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C94", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C94); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C95", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C95); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C96", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C96); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C98", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C98); -REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C99", DetectMSIMysticLightControllers, MSI_USB_VID, 0x7C99); - -REGISTER_HID_DETECTOR("MSI Mystic Light MS_905D", DetectMSIMysticLightControllers, MSI_USB_VID, 0x905D); +/*-------------------------------------------------------------*\ +| MSI Mystic Light 185-byte Devices | +\*-------------------------------------------------------------*/ +REGISTER_HID_DETECTOR("MSI Mystic Light MS_3EA4", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x3EA4); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_4459", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x4459); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B10", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7B10); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B93", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7B93); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B94", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7B94); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7B96", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7B96); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C34", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C34); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C35", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C35); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C36", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C36); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C37", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C37); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C42", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C42); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C56", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C56); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C59", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C59); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C60", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C60); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C67", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C67); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C70", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C70); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C71", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C71); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C73", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C73); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C75", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C75); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C76", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C76); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C77", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C77); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C79", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C79); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C80", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C80); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C81", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C81); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C82", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C82); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C83", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C83); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C84", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C84); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C85", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C85); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C86", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C86); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C87", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C87); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C88", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C88); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C89", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C89); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C90", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C90); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C91", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C91); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C92", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C92); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C94", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C94); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C95", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C95); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C96", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C96); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C98", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C98); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_7C99", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x7C99); +REGISTER_HID_DETECTOR("MSI Mystic Light MS_905D", DetectMSIMysticLight185Controllers, MSI_USB_VID, 0x905D); #endif diff --git a/Controllers/MSIMysticLightController/RGBController_MSIMysticLight.cpp b/Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.cpp similarity index 80% rename from Controllers/MSIMysticLightController/RGBController_MSIMysticLight.cpp rename to Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.cpp index 9e7ce6ee..e3a0f538 100644 --- a/Controllers/MSIMysticLightController/RGBController_MSIMysticLight.cpp +++ b/Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.cpp @@ -1,16 +1,18 @@ /*-----------------------------------------*\ -| RGBController_MSIMysticLight.cpp | +| RGBController_MSIMysticLight185.cpp | | | | Generic RGB Interface for OpenRGB | -| MSI Mystic Light USB Driver | +| MSI Mystic Light (185-byte) USB Driver | | | | T-bond 3/4/2020 | +| Adam Honse 3/6/2021 | \*-----------------------------------------*/ -#include "RGBController_MSIMysticLight.h" -#include +#include "RGBController_MSIMysticLight185.h" -static const std::array led_zones +#define NUM_LED_ZONES (sizeof(led_zones) / sizeof(ZoneDescription)) + +static const ZoneDescription led_zones[] = { ZoneDescription{"JRGB1", MSI_ZONE_J_RGB_1}, ZoneDescription{"JRGB2", MSI_ZONE_J_RGB_2}, @@ -19,7 +21,6 @@ static const std::array led_zones ZoneDescription{"JPIPE1", MSI_ZONE_J_PIPE_1}, ZoneDescription{"JPIPE2", MSI_ZONE_J_PIPE_2}, ZoneDescription{"JCORSAIR", MSI_ZONE_J_CORSAIR}, - ZoneDescription{"JCORSAIR Outer", MSI_ZONE_J_CORSAIR_OUTERLL120}, ZoneDescription{"Onboard LED 0", MSI_ZONE_ON_BOARD_LED}, ZoneDescription{"Onboard LED 1", MSI_ZONE_ON_BOARD_LED_1}, ZoneDescription{"Onboard LED 2", MSI_ZONE_ON_BOARD_LED_2}, @@ -32,14 +33,14 @@ static const std::array led_zones ZoneDescription{"Onboard LED 9", MSI_ZONE_ON_BOARD_LED_9}, }; -RGBController_MSIMysticLight::RGBController_MSIMysticLight(MSIMysticLightController* controller_ptr) +RGBController_MSIMysticLight185::RGBController_MSIMysticLight185(MSIMysticLight185Controller* controller_ptr) { controller = controller_ptr; - name = "MSI Mystic Light Controller"; + name = controller->GetDeviceName(); vendor = "MSI"; type = DEVICE_TYPE_MOTHERBOARD; - description = controller->GetDeviceName(); + description = "MSI Mystic Light Device (185-byte)"; version = controller->GetFWVersion(); location = controller->GetDeviceLocation(); serial = controller->GetSerial(); @@ -49,26 +50,26 @@ RGBController_MSIMysticLight::RGBController_MSIMysticLight(MSIMysticLightControl SetupColors(); } -RGBController_MSIMysticLight::~RGBController_MSIMysticLight() +RGBController_MSIMysticLight185::~RGBController_MSIMysticLight185() { delete controller; } -void RGBController_MSIMysticLight::SetupZones() +void RGBController_MSIMysticLight185::SetupZones() { /*---------------------------------------------------------*\ | Set up zones | \*---------------------------------------------------------*/ - for(std::size_t zone_idx = 0; zone_idx < led_zones.size(); zone_idx++) + for(std::size_t zone_idx = 0; zone_idx < NUM_LED_ZONES; zone_idx++) { ZoneDescription zd = led_zones[zone_idx]; zone new_zone; new_zone.name = zd.name; new_zone.type = ZONE_TYPE_LINEAR; - new_zone.leds_min = controller->GetZoneMinLedCount(zd.value); - new_zone.leds_max = controller->GetZoneMaxLedCount(zd.value); - new_zone.leds_count = controller->GetZoneLedCount(zd.value); + new_zone.leds_min = 1; + new_zone.leds_max = 1; + new_zone.leds_count = 1; new_zone.matrix_map = NULL; zones.push_back(new_zone); @@ -92,35 +93,28 @@ void RGBController_MSIMysticLight::SetupZones() } } -void RGBController_MSIMysticLight::ResizeZone(int zone, int new_size) +void RGBController_MSIMysticLight185::ResizeZone(int zone, int new_size) { - if((size_t) zone >= zones.size()) - { - return; - } - - MSI_ZONE zon = ZoneFromPos(zone); - unsigned int max_count = controller->GetZoneMaxLedCount(zon); - unsigned int min_count = controller->GetZoneMinLedCount(zon); - unsigned int new_siz = new_size; - new_siz = std::min(std::max(new_siz, min_count), max_count); // std::clamp only from C++17 - /// TODO: Update LED count } -void RGBController_MSIMysticLight::SetCustomMode() +void RGBController_MSIMysticLight185::SetCustomMode() { active_mode = 0; } -void RGBController_MSIMysticLight::DeviceUpdateLEDs() +void RGBController_MSIMysticLight185::DeviceUpdateLEDs() { for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++) { - UpdateZoneLEDs(zone_idx); + for(int led_idx = zones[zone_idx].leds_count - 1; led_idx >= 0; led_idx--) + { + UpdateLed(zone_idx, led_idx); + } } + controller->Update(); } -void RGBController_MSIMysticLight::UpdateZoneLEDs(int zone) +void RGBController_MSIMysticLight185::UpdateZoneLEDs(int zone) { for(int led_idx = zones[zone].leds_count - 1; led_idx >= 0; led_idx--) { @@ -129,23 +123,23 @@ void RGBController_MSIMysticLight::UpdateZoneLEDs(int zone) controller->Update(); } -void RGBController_MSIMysticLight::UpdateSingleLED(int led) +void RGBController_MSIMysticLight185::UpdateSingleLED(int led) { UpdateLed(leds[led].value, led); controller->Update(); } -void RGBController_MSIMysticLight::DeviceUpdateMode() +void RGBController_MSIMysticLight185::DeviceUpdateMode() { } -void RGBController_MSIMysticLight::SetupModes() +void RGBController_MSIMysticLight185::SetupModes() { constexpr unsigned int RANDOM_ONLY = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_RANDOM_COLOR; constexpr unsigned int COMMON = RANDOM_ONLY | MODE_FLAG_HAS_PER_LED_COLOR; SetupMode("Static", MSI_MODE_STATIC, MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR); - SetupMode("Off", MSI_MODE_DISABLE, 0); + //SetupMode("Off", MSI_MODE_DISABLE, 0); SetupMode("Breathing", MSI_MODE_BREATHING, COMMON); SetupMode("Flashing", MSI_MODE_FLASHING, COMMON); SetupMode("Double flashing", MSI_MODE_DOUBLE_FLASHING, COMMON); @@ -186,7 +180,7 @@ void RGBController_MSIMysticLight::SetupModes() // SetupMode("Lava", MSI_MODE_LAVA, COMMON); } -void RGBController_MSIMysticLight::UpdateLed(int zone, int led) +void RGBController_MSIMysticLight185::UpdateLed(int zone, int led) { bool random = modes[active_mode].color_mode == MODE_COLORS_RANDOM; unsigned char red = RGBGetRValue(zones[zone].colors[led]); @@ -200,12 +194,12 @@ void RGBController_MSIMysticLight::UpdateLed(int zone, int led) controller->SetZoneColor(zon, red, grn, blu, red, grn, blu); } -MSI_ZONE RGBController_MSIMysticLight::ZoneFromPos(int zone) +MSI_ZONE RGBController_MSIMysticLight185::ZoneFromPos(int zone) { return led_zones[zone].value; } -void RGBController_MSIMysticLight::SetupMode(const char *name, MSI_MODE mod, unsigned int flags) +void RGBController_MSIMysticLight185::SetupMode(const char *name, MSI_MODE mod, unsigned int flags) { mode Mode; Mode.name = name; diff --git a/Controllers/MSIMysticLightController/RGBController_MSIMysticLight.h b/Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.h similarity index 66% rename from Controllers/MSIMysticLightController/RGBController_MSIMysticLight.h rename to Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.h index 1a1b5456..073b9aad 100644 --- a/Controllers/MSIMysticLightController/RGBController_MSIMysticLight.h +++ b/Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.h @@ -1,22 +1,23 @@ /*-----------------------------------------*\ -| RGBController_MSIMysticLight.h | +| RGBController_MSIMysticLight185.h | | | | Generic RGB Interface for OpenRGB | -| MSI Mystic Light USB Driver | +| MSI Mystic Light (185-byte) USB Driver | | | | T-bond 3/4/2020 | +| Adam Honse 3/6/2021 | \*-----------------------------------------*/ #pragma once #include "RGBController.h" -#include "MSIMysticLightController.h" +#include "MSIMysticLight185Controller.h" #include -class RGBController_MSIMysticLight: public RGBController +class RGBController_MSIMysticLight185: public RGBController { public: - RGBController_MSIMysticLight(MSIMysticLightController* controller_ptr); - ~RGBController_MSIMysticLight(); + RGBController_MSIMysticLight185(MSIMysticLight185Controller* controller_ptr); + ~RGBController_MSIMysticLight185(); void SetupZones(); @@ -35,5 +36,5 @@ private: MSI_ZONE ZoneFromPos(int zone); void SetupMode(const char *name, MSI_MODE mode, unsigned int flags); - MSIMysticLightController* controller; + MSIMysticLight185Controller* controller; }; diff --git a/OpenRGB.pro b/OpenRGB.pro index 27369844..e932be71 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -264,8 +264,8 @@ HEADERS += Controllers/MSI3ZoneController/RGBController_MSI3Zone.h \ Controllers/MSIGPUController/MSIGPUController.h \ Controllers/MSIGPUController/RGBController_MSIGPU.h \ - Controllers/MSIMysticLightController/MSIMysticLightController.h \ - Controllers/MSIMysticLightController/RGBController_MSIMysticLight.h \ + Controllers/MSIMysticLightController/MSIMysticLight185Controller.h \ + Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.h \ Controllers/MSIRGBController/MSIRGBController.h \ Controllers/MSIRGBController/RGBController_MSIRGB.h \ Controllers/NZXTHue2Controller/NZXTHue2Controller.h \ @@ -513,9 +513,9 @@ SOURCES += Controllers/MSIGPUController/MSIGPUController.cpp \ Controllers/MSIGPUController/MSIGPUControllerDetect.cpp \ Controllers/MSIGPUController/RGBController_MSIGPU.cpp \ - Controllers/MSIMysticLightController/MSIMysticLightController.cpp \ + Controllers/MSIMysticLightController/MSIMysticLight185Controller.cpp \ Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp \ - Controllers/MSIMysticLightController/RGBController_MSIMysticLight.cpp \ + Controllers/MSIMysticLightController/RGBController_MSIMysticLight185.cpp \ Controllers/MSIRGBController/MSIRGBController.cpp \ Controllers/MSIRGBController/MSIRGBControllerDetect.cpp \ Controllers/MSIRGBController/RGBController_MSIRGB.cpp \