diff --git a/Controllers/CoolerMasterController/CMMKController.cpp b/Controllers/CoolerMasterController/CMMKController.cpp index 43d7b81e..e50d2308 100644 --- a/Controllers/CoolerMasterController/CMMKController.cpp +++ b/Controllers/CoolerMasterController/CMMKController.cpp @@ -12,24 +12,44 @@ CMMKController::CMMKController(hid_device* dev, hid_device_info* dev_info) { - location = dev_info->path; + location = dev_info->path; - const int szTemp = 256; + const int szTemp = 256; wchar_t tmpName[szTemp]; hid_get_manufacturer_string(dev, tmpName, szTemp); - std::wstring wName = std::wstring(tmpName); - device_name = std::string(wName.begin(), wName.end()); + std::wstring wName = std::wstring(tmpName); + vendor_name = std::string(wName.begin(), wName.end()); hid_get_product_string(dev, tmpName, szTemp); wName = std::wstring(tmpName); - device_name.append(" ").append(std::string(wName.begin(), wName.end())); + device_name = std::string(wName.begin(), wName.end()); cmmk_attach_path(&cmmk_handle, dev_info->path, dev_info->product_id, -1); char buf[32] = {0}; cmmk_get_firmware_version(&cmmk_handle, buf, 32); + /*--------------------------------------------------------------*\ + | Adjust the row count for keyboards without the front light bar | + | Adjust the column count for TKL keyboards (i.e. x30 vs x50) | + \*--------------------------------------------------------------*/ + enum cmmk_product_type kb_type = cmmk_get_device_model(&cmmk_handle); + row_count = (kb_type == CMMK_PRODUCT_MASTERKEYS_MK750) ? CMMK_ROWS_MAX : CMMK_ROWS_MAX - 1; + switch(kb_type) + { + case CMMK_PRODUCT_MASTERKEYS_PRO_S: + case CMMK_PRODUCT_MASTERKEYS_SK630: + column_count = CMMK_COLS_MAX - 4; + break; + + case CMMK_PRODUCT_MASTERKEYS_PRO_L: + case CMMK_PRODUCT_MASTERKEYS_MK750: + case CMMK_PRODUCT_MASTERKEYS_SK650: + default: + column_count = CMMK_COLS_MAX; + } + firmware_version = buf; } @@ -43,6 +63,11 @@ std::string CMMKController::GetDeviceName() return device_name; } +std::string CMMKController::GetDeviceVendor() +{ + return vendor_name; +} + std::string CMMKController::GetLocation() { return location; @@ -53,6 +78,16 @@ std::string CMMKController::GetFirmwareVersion() return firmware_version; } +uint8_t CMMKController::GetRowCount() +{ + return row_count; +} + +uint8_t CMMKController::GetColumnCount() +{ + return column_count; +} + void CMMKController::SetFirmwareControl() { ActivateMode(CMMK_FIRMWARE); diff --git a/Controllers/CoolerMasterController/CMMKController.h b/Controllers/CoolerMasterController/CMMKController.h index 4eca06b1..641a0de1 100644 --- a/Controllers/CoolerMasterController/CMMKController.h +++ b/Controllers/CoolerMasterController/CMMKController.h @@ -20,8 +20,11 @@ public: ~CMMKController(); std::string GetDeviceName(); + std::string GetDeviceVendor(); std::string GetLocation(); std::string GetFirmwareVersion(); + uint8_t GetRowCount(); + uint8_t GetColumnCount(); void SetFirmwareControl(); void SetManualControl(); @@ -51,8 +54,11 @@ private: int current_effect = -1; std::string device_name; + std::string vendor_name; std::string location; std::string firmware_version; + uint8_t row_count; + uint8_t column_count; mutable struct cmmk cmmk_handle; }; diff --git a/Controllers/CoolerMasterController/RGBController_CMMKController.cpp b/Controllers/CoolerMasterController/RGBController_CMMKController.cpp index 742777b1..e9a1ff6b 100644 --- a/Controllers/CoolerMasterController/RGBController_CMMKController.cpp +++ b/Controllers/CoolerMasterController/RGBController_CMMKController.cpp @@ -25,6 +25,7 @@ RGBController_CMMKController::RGBController_CMMKController(CMMKController* cmmk_ cmmk = cmmk_ctrl; name = cmmk->GetDeviceName(); + vendor = cmmk->GetDeviceVendor(); type = DEVICE_TYPE_KEYBOARD; description = "Cooler Master MasterKeys Device"; version = cmmk->GetFirmwareVersion(); @@ -198,9 +199,12 @@ void RGBController_CMMKController::SetupMatrixMap() void RGBController_CMMKController::SetupZones() { - for(int y = 0; y < CMMK_ROWS_MAX; y++) + uint8_t row_count = cmmk->GetRowCount(); + uint8_t column_count = cmmk->GetColumnCount(); + + for(int y = 0; y < row_count; y++) { - for(int x = 0; x < CMMK_COLS_MAX; x++) + for(int x = 0; x < column_count; x++) { if(!cmmk->PositionValid(y, x)) { @@ -227,8 +231,8 @@ void RGBController_CMMKController::SetupZones() KeyboardZone.leds_max = leds.size(); KeyboardZone.leds_count = leds.size(); KeyboardZone.matrix_map = new matrix_map_type; - KeyboardZone.matrix_map->height = CMMK_ROWS_MAX; - KeyboardZone.matrix_map->width = CMMK_COLS_MAX; + KeyboardZone.matrix_map->height = row_count; + KeyboardZone.matrix_map->width = column_count; KeyboardZone.matrix_map->map = (unsigned int *)&matrix_map; zones.push_back(KeyboardZone);