From 8716760e7ed5425461e29c9c2a6800d9fd7d4304 Mon Sep 17 00:00:00 2001 From: Chris M Date: Sat, 18 Nov 2023 21:02:23 +1100 Subject: [PATCH] Added brightness to CreativeSoundBlasterXG6Controller --- .../CreativeSoundBlasterXG6Controller.cpp | 7 +++-- .../CreativeSoundBlasterXG6Controller.h | 10 ++++--- .../RGBController_CreativeSoundBlasterXG6.cpp | 27 ++++++++++--------- .../RGBController_CreativeSoundBlasterXG6.h | 3 +++ 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.cpp b/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.cpp index 2680970f..86ba08d1 100644 --- a/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.cpp +++ b/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.cpp @@ -16,7 +16,10 @@ std::string CreativeSoundBlasterXG6Controller::GetDeviceLocation() return("HID " + location); } -void CreativeSoundBlasterXG6Controller::SetLedColor (unsigned char red, unsigned char green, unsigned char blue) +void CreativeSoundBlasterXG6Controller::SetLedColor (unsigned char red, + unsigned char green, + unsigned char blue, + unsigned char brightness) { unsigned char usb_buf[64]; @@ -69,7 +72,7 @@ void CreativeSoundBlasterXG6Controller::SetLedColor (unsigned char red, unsigned usb_buf[0x06] = 0x03; usb_buf[0x07] = 0x01; usb_buf[0x08] = 0x01; - usb_buf[0x09] = 0x0FF; + usb_buf[0x09] = brightness; usb_buf[0x0A] = blue; usb_buf[0x0B] = green; diff --git a/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.h b/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.h index e3b3affb..8c168ee6 100644 --- a/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.h +++ b/Controllers/CreativeController/CreativeSoundBlasterXG6Controller.h @@ -9,10 +9,14 @@ class CreativeSoundBlasterXG6Controller public: CreativeSoundBlasterXG6Controller(hid_device* dev_handle, const char* path); ~CreativeSoundBlasterXG6Controller(); - void SetLedColor (unsigned char red, unsigned char green, unsigned char blue); - std::string GetDeviceLocation(); - std::string GetSerialString(); + void SetLedColor(unsigned char red, + unsigned char green, + unsigned char blue, + unsigned char brightness); + + std::string GetDeviceLocation(); + std::string GetSerialString(); private: hid_device* dev; diff --git a/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.cpp b/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.cpp index 4b1da93a..118016ef 100644 --- a/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.cpp +++ b/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.cpp @@ -13,20 +13,23 @@ RGBController_CreativeSoundBlasterXG6::RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* controller_ptr) { - controller = controller_ptr; + controller = controller_ptr; - name = "Creative SoundBlasterX G6 Device"; - vendor = "Creative"; - type = DEVICE_TYPE_HEADSET; - description = "Creative SoundBlasterX G6 Device"; - location = controller->GetDeviceLocation(); - serial = ""; + name = "Creative SoundBlasterX G6 Device"; + vendor = "Creative"; + type = DEVICE_TYPE_HEADSET; + description = "Creative SoundBlasterX G6 Device"; + location = controller->GetDeviceLocation(); + serial = ""; mode Static; - Static.name = "Direct"; - Static.value = 0; - Static.flags = MODE_COLORS_PER_LED; - Static.color_mode = MODE_COLORS_PER_LED; + Static.name = "Direct"; + Static.value = 0; + Static.flags = MODE_COLORS_PER_LED | MODE_FLAG_HAS_BRIGHTNESS; + Static.color_mode = MODE_COLORS_PER_LED; + Static.brightness_min = XG6_BRIGHTNESS_MIN; + Static.brightness_max = XG6_BRIGHTNESS_MAX; + Static.brightness = XG6_BRIGHTNESS_MAX; modes.push_back(Static); SetupZones(); @@ -68,7 +71,7 @@ void RGBController_CreativeSoundBlasterXG6::DeviceUpdateLEDs() unsigned char grn = RGBGetGValue(colors[0]); unsigned char blu = RGBGetBValue(colors[0]); - controller->SetLedColor(red, grn, blu); + controller->SetLedColor(red, grn, blu, modes[active_mode].brightness); } void RGBController_CreativeSoundBlasterXG6::UpdateZoneLEDs(int /*zone*/) diff --git a/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.h b/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.h index 08894a22..069f4680 100644 --- a/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.h +++ b/Controllers/CreativeController/RGBController_CreativeSoundBlasterXG6.h @@ -2,6 +2,9 @@ #include "RGBController.h" #include "CreativeSoundBlasterXG6Controller.h" +#define XG6_BRIGHTNESS_MIN 0x00 +#define XG6_BRIGHTNESS_MAX 0xFF + class RGBController_CreativeSoundBlasterXG6: public RGBController { public: