diff --git a/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp new file mode 100644 index 00000000..2ed2b48c --- /dev/null +++ b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp @@ -0,0 +1,245 @@ +/*-----------------------------------------*\ +| RGBController_RoccatVulcanAimo.cpp | +| | +| Generic RGB Interface for OpenRGB | +| | +| | +| Mola19 17/12/2021 | +\*-----------------------------------------*/ + +#include "RGBController_RoccatVulcanAimo.h" +#include + +#define NA 0xFFFFFFFF + +static unsigned int matrix_map[6][22] = + { { 0, NA, 11, 17, 23, 28, NA, 48, 53, 59, 65, 78, 84, 85, 86, 99, 103, 108, NA, NA, NA, NA }, + { 1, 6, 12, 18, 24, 29, 33, 49, 54, 60, 66, 72, 79, 87, NA, 100, 104, 109, 113, 119, 124, 129 }, + { 2, NA, 7, 13, 19, 25, 30, 34, 50, 55, 61, 67, 73, 80, NA, 101, 105, 110, 114, 120, 125, 130 }, + { 3, NA, 8, 14, 20, 26, 31, 35, 51, 56, 62, 68, 74, 96, 88, NA, NA, NA, 115, 121, 126, NA }, + { 4, NA, 9, 15, 21, 27, 32, 36, 52, 57, 63, 69, 75, 82, NA, NA, 106, NA, 116, 122, 127, 131 }, + { 5, 10, 16, NA, NA, NA, 37, NA, NA, NA, NA, 70, 76, 83, 89, 102, 107, 111, 117, NA, 128, NA } }; + +static const unsigned int zone_size = 132; + +static const char *led_names[] = +{ + "Key: Escape", + "Key: ^", + "Key: Tab", + "Key: Caps Lock", + "Key: Left Shift", + "Key: Left Control", + "Key: 1", + "Key: Q", + "Key: A", + "Key: <", + "Key: Left Windows", + "Key: F1", + "Key: 2", + "Key: W", + "Key: S", + "Key: Y", + "Key: Left Alt", + "Key: F2", + "Key: 3", + "Key: E", + "Key: D", + "Key: X", + "Unused", + "Key: F3", + "Key: 4", + "Key: R", + "Key: F", + "Key: C", + "Key: F4", + "Key: 5", + "Key: T", + "Key: G", + "Key: V", + "Key: 6", + "Key: Z", + "Key: H", + "Key: B", + "Key: Space", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Key: F5", + "Key: 7", + "Key: U", + "Key: J", + "Key: N", + "Key: F6", + "Key: 8", + "Key: I", + "Key: K", + "Key: M", + "Unused", + "Key: F7", + "Key: 9", + "Key: O", + "Key: L", + "Key: ,", + "Unused", + "Key: F8", + "Key: 0", + "Key: P", + "Key: Ö", + "Key: .", + "Key: Right Alt", + "Unused", + "Key: ß", + "Key: Ü", + "Key: Ä", + "Key: -", + "Key: Right Fn", + "Unused", + "Key: F9", + "Key: ´", + "Key: +", + "Unused", + "Key: Right Shift", + "Key: Menu", + "Key: F10", + "Key: F11", + "Key: F12", + "Key: Backspace", + "Key: Enter", + "Key: Right Control", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Unused", + "Key: #", + "Unused", + "Unused", + "Key: Print Screen", + "Key: Insert", + "Key: Delete", + "Key: Left Arrow", + "Key: Scroll Lock", + "Key: Home", + "Key: End", + "Key: Up Arrow", + "Key: Down Arrow", + "Key: Pause/Break", + "Key: Page Up", + "Key: Page Down", + "Key: Right Arrow", + "Unused", + "Key: Num Lock", + "Key: Number Pad 7", + "Key: Number Pad 4", + "Key: Number Pad 1", + "Key: Number Pad 0", + "Unused", + "Key: Number Pad /", + "Key: Number Pad 8", + "Key: Number Pad 5", + "Key: Number Pad 2", + "Unused", + "Key: Number Pad *", + "Key: Number Pad 9", + "Key: Number Pad 6", + "Key: Number Pad 3", + "Key: Number Pad ,", + "Key: Number Pad -", + "Key: Number Pad +", + "Key: Number Pad Enter", +}; + +RGBController_RoccatVulcanAimo::RGBController_RoccatVulcanAimo(RoccatVulcanAimoController* controller_ptr) +{ + controller = controller_ptr; + + name = "Roccat Vulcan 120 Aimo"; + vendor = "Roccat"; + type = DEVICE_TYPE_KEYBOARD; + description = "Roccat Vulcan Aimo Keyboard"; + location = controller->GetLocation(); + serial = controller->GetSerial(); + + mode Direct; + Direct.name = "Direct"; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + + SetupZones(); +} + +RGBController_RoccatVulcanAimo::~RGBController_RoccatVulcanAimo() +{ + delete controller; +} + +void RGBController_RoccatVulcanAimo::SetupZones() +{ + /*---------------------------------------------------------*\ + | Set up zones and leds per zone | + \*---------------------------------------------------------*/ + zone new_zone; + new_zone.name = "Keyboard"; + new_zone.type = ZONE_TYPE_MATRIX; + new_zone.leds_min = zone_size; + new_zone.leds_max = zone_size; + new_zone.leds_count = zone_size; + new_zone.matrix_map = new matrix_map_type; + new_zone.matrix_map->height = 6; + new_zone.matrix_map->width = 22; + new_zone.matrix_map->map = (unsigned int *)&matrix_map; + zones.push_back(new_zone); + + for(unsigned int led_idx = 0; led_idx < zone_size; led_idx++) + { + led new_led; + new_led.name = led_names[led_idx]; + leds.push_back(new_led); + } + + SetupColors(); +} + +void RGBController_RoccatVulcanAimo::ResizeZone(int /*zone*/, int /*new_size*/) +{ + /*---------------------------------------------------------*\ + | This device does not support resizing zones | + \*---------------------------------------------------------*/ +} + +void RGBController_RoccatVulcanAimo::DeviceUpdateLEDs() +{ + controller->SendColors(colors); +} + +void RGBController_RoccatVulcanAimo::UpdateZoneLEDs(int /*zone_idx*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_RoccatVulcanAimo::UpdateSingleLED(int /*led_idx*/) +{ + DeviceUpdateLEDs(); +} + +void RGBController_RoccatVulcanAimo::SetCustomMode() +{ + active_mode = 0; +} + +void RGBController_RoccatVulcanAimo::DeviceUpdateMode() +{ + /*---------------------------------------------------------*\ + | Changing modes is currently not implemented | + \*---------------------------------------------------------*/ +} diff --git a/Controllers/RoccatController/RGBController_RoccatVulcanAimo.h b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.h new file mode 100644 index 00000000..4123d493 --- /dev/null +++ b/Controllers/RoccatController/RGBController_RoccatVulcanAimo.h @@ -0,0 +1,33 @@ +/*-----------------------------------------*\ +| RGBController_RoccatVulcanAimo.h | +| | +| Generic RGB Interface for Roccat Vulcan | +| Aimo controller | +| | +| Mola19 17/12/2021 | +\*-----------------------------------------*/ + +#pragma once +#include "RGBController.h" +#include "RoccatVulcanAimoController.h" + +class RGBController_RoccatVulcanAimo : public RGBController +{ +public: + RGBController_RoccatVulcanAimo(RoccatVulcanAimoController* controller_ptr); + ~RGBController_RoccatVulcanAimo(); + + void SetupZones(); + + void ResizeZone(int zone, int new_size); + + void DeviceUpdateLEDs(); + void UpdateZoneLEDs(int zone); + void UpdateSingleLED(int led); + + void SetCustomMode(); + void DeviceUpdateMode(); + +private: + RoccatVulcanAimoController* controller; +}; diff --git a/Controllers/RoccatController/RoccatControllerDetect.cpp b/Controllers/RoccatController/RoccatControllerDetect.cpp index 0bc6165e..a5551bdd 100644 --- a/Controllers/RoccatController/RoccatControllerDetect.cpp +++ b/Controllers/RoccatController/RoccatControllerDetect.cpp @@ -8,23 +8,40 @@ #include "Detector.h" #include "RoccatKoneAimoController.h" +#include "RoccatVulcanAimoController.h" #include "RGBController.h" #include "RGBController_RoccatKoneAimo.h" +#include "RGBController_RoccatVulcanAimo.h" #include #define ROCCAT_VID 0x1E7D -void DetectRoccatControllers(hid_device_info* info, const std::string& name) +void DetectRoccatMouseControllers(hid_device_info* info, const std::string& name) { hid_device* dev = hid_open_path(info->path); - if (dev) + + if(dev) { - RoccatKoneAimoController * controller = new RoccatKoneAimoController(dev, info->path); + RoccatKoneAimoController * controller = new RoccatKoneAimoController(dev, info->path); RGBController_RoccatKoneAimo * rgb_controller = new RGBController_RoccatKoneAimo(controller); rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); } -} /* DetectRoccatControllers() */ +} -REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo 16K", DetectRoccatControllers, ROCCAT_VID, 0x2E2C, 0, 0x0B, 0); -REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo", DetectRoccatControllers, ROCCAT_VID, 0x2E27, 0, 0x0B, 0); +void DetectRoccatKeyboardControllers(hid_device_info* info, const std::string& name) +{ + hid_device* dev = hid_open_path(info->path); + + if(dev) + { + RoccatVulcanAimoController * controller = new RoccatVulcanAimoController(dev, info->path); + RGBController_RoccatVulcanAimo * rgb_controller = new RGBController_RoccatVulcanAimo(controller); + rgb_controller->name = name; + ResourceManager::get()->RegisterRGBController(rgb_controller); + } +} + +REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo 16K", DetectRoccatMouseControllers, ROCCAT_VID, 0x2E2C, 0, 0x0B, 0); +REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo", DetectRoccatMouseControllers, ROCCAT_VID, 0x2E27, 0, 0x0B, 0); +REGISTER_HID_DETECTOR_IP ("Roccat Vulcan 120 Aimo", DetectRoccatKeyboardControllers, ROCCAT_VID, 0x3098, 3, 1); diff --git a/Controllers/RoccatController/RoccatVulcanAimoController.cpp b/Controllers/RoccatController/RoccatVulcanAimoController.cpp new file mode 100644 index 00000000..1663b3df --- /dev/null +++ b/Controllers/RoccatController/RoccatVulcanAimoController.cpp @@ -0,0 +1,75 @@ +/*-------------------------------------------------------------------*\ +| RoccatVulcanAimoController.cpp | +| | +| Driver for Roccat Vulcan Aimo Mouse | +| | +| Mola19 17/12/2021 | +| | +\*-------------------------------------------------------------------*/ + +#include "RoccatVulcanAimoController.h" + +#include + +RoccatVulcanAimoController::RoccatVulcanAimoController(hid_device* dev_handle, char *path) +{ + dev = dev_handle; + location = path; +} + +RoccatVulcanAimoController::~RoccatVulcanAimoController() +{ + hid_close(dev); +} + +std::string RoccatVulcanAimoController::GetSerial() +{ + wchar_t serial_string[128]; + int ret = hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } + + std::wstring return_wstring = serial_string; + std::string return_string(return_wstring.begin(), return_wstring.end()); + + return(return_string); + +} + +std::string RoccatVulcanAimoController::GetLocation() +{ + return("HID: " + location); +} + +void RoccatVulcanAimoController::SendColors(std::vector colors) +{ + unsigned char bufs[7][65]; + + bufs[0][1] = 0xA1; + bufs[0][2] = 0x01; + bufs[0][3] = 0x01; + bufs[0][4] = 0xB4; + + for(int z = 0; z < 11; z++) + { + for(int l = 0; l < 12; l++) + { + int placeR = (z * 36) + 4 + l + 0; + bufs[placeR / 64][placeR % 64 + 1] = RGBGetRValue(colors[z * 12 + l]); + + int placeG = (z * 36) + 4 + l + 12; + bufs[placeG / 64][placeG % 64 + 1] = RGBGetGValue(colors[z * 12 + l]); + + int placeB = (z * 36) + 4 + l + 24; + bufs[placeB / 64][placeB % 64 + 1] = RGBGetBValue(colors[z * 12 + l]); + } + } + + for(int p = 0; p < 7; p++) + { + hid_write(dev, bufs[p], 65); + } +} diff --git a/Controllers/RoccatController/RoccatVulcanAimoController.h b/Controllers/RoccatController/RoccatVulcanAimoController.h new file mode 100644 index 00000000..58451a51 --- /dev/null +++ b/Controllers/RoccatController/RoccatVulcanAimoController.h @@ -0,0 +1,31 @@ +/*-------------------------------------------------------------------*\ +| RoccatVulcanAimoController.h | +| | +| Driver for Roccat Vulcan Aimo Keyboard | +| | +| Mola19 17/12/2021 | +| | +\*-------------------------------------------------------------------*/ + +#pragma once + +#include "RGBController.h" + +#include +#include + +class RoccatVulcanAimoController +{ +public: + RoccatVulcanAimoController(hid_device* dev_handle, char *path); + ~RoccatVulcanAimoController(); + + std::string GetSerial(); + std::string GetLocation(); + + void SendColors(std::vector colors); + +private: + std::string location; + hid_device* dev; +}; diff --git a/OpenRGB.pro b/OpenRGB.pro index 1ac2ee28..88d57fd3 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -427,7 +427,9 @@ HEADERS += Controllers/RedragonController/RedragonM711Controller.h \ Controllers/RedragonController/RGBController_RedragonM711.h \ Controllers/RoccatController/RGBController_RoccatKoneAimo.h \ + Controllers/RoccatController/RGBController_RoccatVulcanAimo.h \ Controllers/RoccatController/RoccatKoneAimoController.h \ + Controllers/RoccatController/RoccatVulcanAimoController.h \ Controllers/SapphireGPUController/SapphireNitroGlowV1Controller.h \ Controllers/SapphireGPUController/SapphireNitroGlowV3Controller.h \ Controllers/SapphireGPUController/RGBController_SapphireNitroGlowV1.h \ @@ -843,7 +845,9 @@ SOURCES += Controllers/RedragonController/RedragonControllerDetect.cpp \ Controllers/RedragonController/RGBController_RedragonM711.cpp \ Controllers/RoccatController/RGBController_RoccatKoneAimo.cpp \ + Controllers/RoccatController/RGBController_RoccatVulcanAimo.cpp \ Controllers/RoccatController/RoccatKoneAimoController.cpp \ + Controllers/RoccatController/RoccatVulcanAimoController.cpp \ Controllers/RoccatController/RoccatControllerDetect.cpp \ Controllers/SapphireGPUController/SapphireNitroGlowV1Controller.cpp \ Controllers/SapphireGPUController/SapphireNitroGlowV3Controller.cpp \