From 977f68c65c6168d2c901f97c6a4ca96305ba25a1 Mon Sep 17 00:00:00 2001 From: Mola19 Date: Fri, 10 Nov 2023 23:44:54 +0100 Subject: [PATCH] fix layout detection for Roccat Vulcan keyboards --- .../RGBController_RoccatVulcanAimo.cpp | 17 +++++++++++------ .../RoccatVulcanAimoController.cpp | 6 ++++-- .../RoccatVulcanAimoController.h | 1 - .../RoccatController/RoccatVulcanAimoLayouts.h | 7 ++++--- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp index ff2c8af6..8204c82f 100644 --- a/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp +++ b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp @@ -78,16 +78,21 @@ RGBController_RoccatVulcanAimo::~RGBController_RoccatVulcanAimo() void RGBController_RoccatVulcanAimo::SetupZones() { - unsigned char layout = controller->GetDeviceInfo().layout_variant; + unsigned char layout; - if(RoccatVulcanLayouts.find(layout) == RoccatVulcanLayouts.end()) + switch(controller->GetDeviceInfo().layout_type) { - /*---------------------------------------------------------*\ - | If Layout not found, take uk or us | - \*---------------------------------------------------------*/ - layout = controller->GetDeviceInfo().layout_type == 1 ? ROCCAT_VULCAN_LAYOUT_UK : ROCCAT_VULCAN_LAYOUT_US; + case ROCCAT_VULCAN_LAYOUT_DE: + case ROCCAT_VULCAN_LAYOUT_UK: + case ROCCAT_VULCAN_LAYOUT_FR: + layout = ROCCAT_VULCAN_LAYOUT_UK; + break; + case ROCCAT_VULCAN_LAYOUT_US: + default: + layout = ROCCAT_VULCAN_LAYOUT_US; } + zone keyboard_zone; keyboard_zone.name = "Keyboard"; keyboard_zone.type = ZONE_TYPE_MATRIX; diff --git a/Controllers/RoccatController/RoccatVulcanAimoController.cpp b/Controllers/RoccatController/RoccatVulcanAimoController.cpp index 2daa7bc3..b261f32e 100644 --- a/Controllers/RoccatController/RoccatVulcanAimoController.cpp +++ b/Controllers/RoccatController/RoccatVulcanAimoController.cpp @@ -12,6 +12,8 @@ #include #include +#include "LogManager.h" + RoccatVulcanAimoController::RoccatVulcanAimoController(hid_device* dev_ctrl_handle, hid_device* dev_led_handle, char *path) { dev_ctrl = dev_ctrl_handle; @@ -55,8 +57,8 @@ device_info RoccatVulcanAimoController::InitDeviceInfo() dev_info.version = std::to_string((int) floor(usb_buf[2] / 100)) + "." + std::to_string(usb_buf[2] % 100); - dev_info.layout_type = usb_buf[6]; - dev_info.layout_variant = usb_buf[7]; + dev_info.layout_type = usb_buf[6]; + LOG_DEBUG("[Roccat Vulcan Aimo]: Detected layout '0x%02X'", usb_buf[6]); return dev_info; } diff --git a/Controllers/RoccatController/RoccatVulcanAimoController.h b/Controllers/RoccatController/RoccatVulcanAimoController.h index 964b63c8..08c2412b 100644 --- a/Controllers/RoccatController/RoccatVulcanAimoController.h +++ b/Controllers/RoccatController/RoccatVulcanAimoController.h @@ -26,7 +26,6 @@ struct device_info { std::string version; int layout_type; - int layout_variant; }; struct led_color diff --git a/Controllers/RoccatController/RoccatVulcanAimoLayouts.h b/Controllers/RoccatController/RoccatVulcanAimoLayouts.h index 6d14b18a..4a99ae1c 100644 --- a/Controllers/RoccatController/RoccatVulcanAimoLayouts.h +++ b/Controllers/RoccatController/RoccatVulcanAimoLayouts.h @@ -16,9 +16,10 @@ enum { - ROCCAT_VULCAN_LAYOUT_US = 6, - ROCCAT_VULCAN_LAYOUT_DE = 7, - ROCCAT_VULCAN_LAYOUT_UK = 0xFF, // this is a placeholder, since the id isn't known + ROCCAT_VULCAN_LAYOUT_US = 0, + ROCCAT_VULCAN_LAYOUT_DE = 1, + ROCCAT_VULCAN_LAYOUT_UK = 2, + ROCCAT_VULCAN_LAYOUT_FR = 3, }; #define NA 0xFFFFFFFF