diff --git a/Controllers/CoolerMasterController/CMMP750Controller.cpp b/Controllers/CoolerMasterController/CMMP750Controller.cpp index 6e1b5f69..8fe9098a 100644 --- a/Controllers/CoolerMasterController/CMMP750Controller.cpp +++ b/Controllers/CoolerMasterController/CMMP750Controller.cpp @@ -11,20 +11,17 @@ static unsigned char colour_mode_data[][6] = { - { 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */ - { 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */ - { 0x03, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Breathing */ - { 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */ - { 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Off */ + { 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */ + { 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */ + { 0x03, 0x04, 0xFF, 0x00, 0xFF, 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] = +static unsigned char speed_mode_data[9] = { - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */ - { 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Blinking */ - { 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Breathing */ - { 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Colour Cycle */ - { 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 } /* Colour Breath */ + 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 /* Speed Definition */ }; CMMP750Controller::CMMP750Controller(hid_device* dev_handle, char *_path) @@ -57,9 +54,9 @@ CMMP750Controller::~CMMP750Controller() void CMMP750Controller::GetStatus() { - unsigned char buffer[0x40] = { 0x00 }; + unsigned char buffer[0x41] = { 0x00 }; int buffer_size = (sizeof(buffer) / sizeof(buffer[0])); - buffer[0] = 0x07; + buffer[1] = 0x07; hid_write(dev, buffer, buffer_size); hid_read(dev, buffer, buffer_size); @@ -71,7 +68,7 @@ void CMMP750Controller::GetStatus() current_green = buffer[4]; current_blue = buffer[5]; - for(int i = 0; speed_mode_data[current_mode][i] >= buffer[6]; i++) + for(int i = 0; (speed_mode_data[i] >= buffer[6] && i <= MP750_SPEED_FASTEST); i++) { current_speed = i; } @@ -79,7 +76,7 @@ void CMMP750Controller::GetStatus() 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_mode = CM_MP750_MODE_COLOR_CYCLE; //Unicorn Spew current_red = 0xFF; current_green = 0xFF; current_blue = 0xFF; @@ -146,18 +143,18 @@ void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigne void CMMP750Controller::SendUpdate() { - unsigned char buffer[0x40] = { 0x00 }; + unsigned char buffer[0x41] = { 0x00 }; int buffer_size = (sizeof(buffer) / sizeof(buffer[0])); for(std::size_t i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++) { - buffer[i] = colour_mode_data[current_mode][i]; + buffer[i+1] = colour_mode_data[current_mode][i]; } - if(current_mode > MP750_MODE_BREATHING) + if(current_mode > CM_MP750_MODE_BREATHING) { //If the mode is random colours set SPEED at BYTE2 - buffer[CM_RED_BYTE] = speed_mode_data[current_mode][current_speed]; + buffer[CM_RED_BYTE] = speed_mode_data[current_speed]; } else { @@ -165,7 +162,7 @@ void CMMP750Controller::SendUpdate() buffer[CM_RED_BYTE] = current_red; buffer[CM_GREEN_BYTE] = current_green; buffer[CM_BLUE_BYTE] = current_blue; - buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed]; + buffer[CM_SPEED_BYTE] = speed_mode_data[current_speed]; } hid_write(dev, buffer, buffer_size); diff --git a/Controllers/CoolerMasterController/CMMP750Controller.h b/Controllers/CoolerMasterController/CMMP750Controller.h index 95851115..a6c9e3ca 100644 --- a/Controllers/CoolerMasterController/CMMP750Controller.h +++ b/Controllers/CoolerMasterController/CMMP750Controller.h @@ -28,20 +28,22 @@ enum { - CM_MODE_BYTE = 0, - CM_RED_BYTE = 2, - CM_GREEN_BYTE = 3, - CM_BLUE_BYTE = 4, - CM_SPEED_BYTE = 5 + CM_MODE_BYTE = 1, + CM_LENGTH_BYTE = 2, + CM_RED_BYTE = 3, + CM_GREEN_BYTE = 4, + CM_BLUE_BYTE = 5, + CM_SPEED_BYTE = 6 }; enum { - MP750_MODE_STATIC = 0x00, //Static Mode - MP750_MODE_BLINK = 0x01, //Blinking Mode - MP750_MODE_BREATHING = 0x02, //Breathing Mode - MP750_MODE_COLOR_CYCLE = 0x03, //Color Cycle Mode - MP750_MODE_BREATH_CYCLE = 0x04 //Breathing Cycle Mode + CM_MP750_MODE_OFF = 0x00, //Off + CM_MP750_MODE_STATIC = 0x01, //Static Mode + CM_MP750_MODE_BLINK = 0x02, //Blinking Mode + CM_MP750_MODE_BREATHING = 0x03, //Breathing Mode + CM_MP750_MODE_COLOR_CYCLE = 0x04, //Color Cycle Mode + CM_MP750_MODE_BREATH_CYCLE = 0x05 //Breathing Cycle Mode }; enum diff --git a/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp b/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp index dac9a793..759fb8c0 100644 --- a/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp +++ b/Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp @@ -22,26 +22,32 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll 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); + 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; + 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 = 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 = MP750_MODE_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; @@ -51,7 +57,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll mode ColorCycle; ColorCycle.name = "Color Cycle"; - ColorCycle.value = MP750_MODE_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; @@ -61,7 +67,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll mode BreathCycle; BreathCycle.name = "Breath Cycle"; - BreathCycle.value = MP750_MODE_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; diff --git a/ResourceManager.cpp b/ResourceManager.cpp index b2eaae24..b38fbe3c 100644 --- a/ResourceManager.cpp +++ b/ResourceManager.cpp @@ -578,13 +578,11 @@ void ResourceManager::DetectDevicesThreadFunction() unsigned int addr = (current_hid_device->vendor_id << 16) | current_hid_device->product_id; if(( hid_device_detectors[hid_detector_idx].address == addr ) - && ( ( hid_device_detectors[hid_detector_idx].interface == HID_INTERFACE_ANY ) + && ( ( current_hid_device->interface_number == HID_INTERFACE_ANY ) || ( hid_device_detectors[hid_detector_idx].interface == current_hid_device->interface_number ) ) #ifdef USE_HID_USAGE - && ( ( hid_device_detectors[hid_detector_idx].usage_page == HID_USAGE_PAGE_ANY ) - || ( hid_device_detectors[hid_detector_idx].usage_page == current_hid_device->usage_page ) ) - && ( ( hid_device_detectors[hid_detector_idx].usage == HID_USAGE_ANY ) - || ( hid_device_detectors[hid_detector_idx].usage == current_hid_device->usage ) ) + && ( hid_device_detectors[hid_detector_idx].usage_page == current_hid_device->usage_page ) + && ( hid_device_detectors[hid_detector_idx].usage == current_hid_device->usage ) #endif ) { @@ -654,13 +652,11 @@ void ResourceManager::DetectDevicesThreadFunction() for(unsigned int hid_detector_idx = 0; hid_detector_idx < hid_device_detectors.size() && detection_is_required.load(); hid_detector_idx++) { if(( hid_device_detectors[hid_detector_idx].address == addr ) - && ( ( hid_device_detectors[hid_detector_idx].interface == HID_INTERFACE_ANY ) + && ( ( current_hid_device->interface_number == HID_INTERFACE_ANY ) || ( hid_device_detectors[hid_detector_idx].interface == current_hid_device->interface_number ) ) #ifdef USE_HID_USAGE - && ( ( hid_device_detectors[hid_detector_idx].usage_page == HID_USAGE_PAGE_ANY ) - || ( hid_device_detectors[hid_detector_idx].usage_page == current_hid_device->usage_page ) ) - && ( ( hid_device_detectors[hid_detector_idx].usage == HID_USAGE_ANY ) - || ( hid_device_detectors[hid_detector_idx].usage == current_hid_device->usage ) ) + && ( hid_device_detectors[hid_detector_idx].usage_page == current_hid_device->usage_page ) + && ( hid_device_detectors[hid_detector_idx].usage == current_hid_device->usage ) #endif ) { diff --git a/ResourceManager.h b/ResourceManager.h index cfd6e96a..cf6a13fa 100644 --- a/ResourceManager.h +++ b/ResourceManager.h @@ -42,8 +42,8 @@ typedef struct HIDDeviceDetectorFunction function; unsigned int address; int interface; - int usage_page; - int usage; + unsigned short usage_page; + unsigned short usage; } HIDDeviceDetectorBlock; typedef void (*DeviceListChangeCallback)(void *);