Compare commits

...
Author SHA1 Message Date
Adam Honse b20042b9c9 Disable alloy elite extended packet 2020-07-12 17:17:39 -05:00
Adam Honse 18d35fcb82 Re-add interface check for Corsair driver when not using HID usages. Only set special function control for non-keyboards 2020-07-12 17:02:22 -05:00
Chris 94ab5bbced Updated detector to include code pages
* Report descriptor for GB Fusion2 USB 048d:8297

0x06, 0x89, 0xFF,  // Usage Page (Vendor Defined 0xFF89)
0x09, 0x10,        // Usage (0x10)
0xA1, 0x01,        // Collection (Application)
0x85, 0x5A,        //   Report ID (90)
0x09, 0x01,        //   Usage (0x01)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x10,        //   Report Count (16)
0xB1, 0x00,        //   Feature (Data,Array,Abs,No Wrap,Linear,Preferred
State,No Null Position,Non-volatile)
0xC0,              // End Collection
0x06, 0x89, 0xFF,  // Usage Page (Vendor Defined 0xFF89)
0x09, 0xCC,        // Usage (0xCC)
0xA1, 0x01,        // Collection (Application)
0x85, 0xCC,        //   Report ID (-52)
0x09, 0x01,        //   Usage (0x01)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x3F,        //   Report Count (63)
0xB1, 0x00,        //   Feature (Data,Array,Abs,No Wrap,Linear,Preferred
State,No Null Position,Non-volatile)
0xC0,              // End Collection
2020-07-12 17:02:22 -05:00
Katzenbiber e9727fcba6 Fix Wraith Prism using WinUSB on Windows
- Add Usage Page to Wraith Prism Detect, which fixes WinUSB bugs.
- Change AMDWraithPrismControllerDetect.cpp structure
2020-07-12 17:02:22 -05:00
Adam Honse 3614aa0392 Fix issues preventing hidapi from working without WinUSB on Windows 2020-07-12 17:02:22 -05:00
Adam Honse 05e76cc733 Fix Windows build 2020-07-12 17:02:11 -05:00
Adam Honse 816eabb1d1 Update direct packet for HyperX keyboards based on Alloy FPS captures 2020-07-12 16:53:20 -05:00
Adam Honse 9b6e24947d Code style cleanup for MSI GPU controller 2020-07-12 16:29:34 -05:00
Hex3l 5778d344e0 adds support to MSI 2080 Ti Sea Hawk EK X 2020-07-12 16:25:56 -05:00
xyz b785f2efbf Attach PCI IDs in DetectNvAPII2CBusses() 2020-07-12 16:25:07 -05:00
xyz 224f59450e Add support for MSI RTX 2080S Gaming X Trio 2020-07-12 16:20:57 -05:00
Adam Honse b80cbe931e Add Corsair Glaive RGB PRO to detection list 2020-07-12 16:06:58 -05:00
Adam Honse 87adb0bdb7 Add keepalive thread for Alloy Origins 2020-07-12 02:41:07 -05:00
Adam Honse 78c7572a2c Update constants for Alloy Origin driver and use 64 byte instead of 65 byte operations 2020-07-12 02:10:05 -05:00
Adam Honse bbed1f64a7 Use interface 3 for Alloy Origins 2020-07-12 01:20:59 -05:00
Adam Honse ac071902c0 Fix MSVC paths from 2017 to 2019 upgrade 2020-07-12 00:54:06 -05:00
Adam Honse 62a4cd31c5 Update QT path for GitLab CI 2020-07-12 00:47:32 -05:00
Adam Honse 751961b3b3 Initial controller for HyperX Alloy Origins 2020-07-12 00:31:40 -05:00
Chris 30625548e5 Adding USB PID 048D:5702 for Gigabyte B550 Aorus Elite 2020-07-09 22:38:12 -05:00
Chris 9451771ccb Rewrote the RGBFusion2USBController to allow for per model
configurations of LED's and zones

* largely changed knownLayoutsLookup to remove reliance on other enums /
structures and made it a map of maps
* rewritten the code to accomodate that change
2020-07-09 22:25:56 -05:00
Chris 12442046e2 Initial commit for dmiinfo.cpp
- Tested working for Linux
- Implemented in Fusion2USB controller and the motherboard name will
populate the controller name in the GUI / CLI
2020-07-09 22:25:45 -05:00
B Horn 47baeb6b6b Improving NetworkServer's memory management (#373)
This patch resolves several bugs:

* NetworkServer would allocate various instances of `NetworkClientInfo`.
  This is patched by deallocating the NetworkClientInfo when it's
  listening thread ends in the `listen_done` section.

* Memory would be allocated for threads that wouldn't be freed. This
  is resolved by detaching from the threads, so they no longer need to
  be joined to be freed, and then freeing the memory as they finish.

* Thread-Safety issues involving `ServerClients` would result in stray
  `NetworkClientInfo`'s not being removed from the list in certain
  situations. This is resolved by used a mutex to lock access to this
  from different threads.
2020-07-09 21:56:42 -05:00
Neel Chotai 263561868c fix musl compilation 2020-07-09 21:51:33 -05:00
Adam Honse 9bc58b039b Add Corsair Harpoon (non-Pro) to detected Corsair Peripheral list 2020-07-09 12:00:02 -05:00
Adam Honse 82c0ff8452 Add HyperX Alloy FPS to detected HyperX keyboard list 2020-07-08 11:43:41 -05:00
edbgon 2d7e996e4b Added initial support for SteelSeries Apex 7 Keyboard (Nordic model) 2020-07-08 03:22:03 -05:00
Adam Honse 0ae76e40c2 Add matrix map for Ducky One 2 TKL 2020-07-07 16:33:21 -05:00
Adam Honse 343c285321 Initial driver for Ducky One 2 keyboard 2020-07-07 13:15:02 -05:00
Adam Honse 6492852627 Add Corsair Harpoon RGB Pro to supported devices list 2020-07-07 01:20:56 -05:00
Adam Honse acc032a69c Adjust Polychrome speed 2020-07-06 13:17:39 -05:00
Adam Honse 950a3be01d More MSI Mystic Light cleanup 2020-07-06 03:45:45 -05:00
Adam Honse 6626321e80 Don't update NZXT fan status for any Hue 2 devices until we get initialization packet working 2020-07-06 02:13:00 -05:00
Adam Honse 7276f5e1d5 Add speed control to Polychrome controller 2020-07-06 02:03:47 -05:00
Adam Honse 5f9c4f8432 Code cleanup and rework for MSI Mystic Light controller
* Replace decimal constants with hexadecimal constants when ANDing/ORing values
* Add comments to explain what the code is doing
* Use C-style casts to fit the project standards
2020-07-05 18:27:51 -05:00
Adam Honse a1cd324731 Add comments and minor cleanup to Kraken driver 2020-07-05 12:12:07 -05:00
Adam Honse c2c5e6666d Fix previous commit 2020-07-05 12:04:35 -05:00
Adam Honse f7d6ede033 Update NZXT Hue 2 and Kraken detectors 2020-07-05 12:02:29 -05:00
Adam Honse 25f9e2a110 Add --client command line argument for opening network clients 2020-07-05 04:25:46 -05:00
Adam Honse 8ef6888a28 Add I2C byte operation to piix4 driver on Windows 2020-07-04 15:40:46 -05:00
B Horn 78a7be63ef Using the correct PID for the Steelseries 300 (0x1710) 2020-07-04 03:28:46 -05:00
Adam Honse f108515a6e Fix Set All Devices being slow and crashing on certain setups. It was sending the update multiple times 2020-07-03 02:59:54 -05:00
Adam Honse ad4e198aea Replace C-style clock() with std::chrono::steady_clock to fix timing on Linux 2020-07-02 16:59:30 -05:00
Adam Honse 5aad79135f Don't try to read fan status for Hue 2 devices without fan controllers 2020-07-01 19:25:29 -05:00
Adam Honse 5fc6981c16 Fix OpenRazer devices with logo/scroll/left/right matrix effect nodes on Windows 2020-06-30 18:11:15 -05:00
Adam Honse 942df26432 Update Readme 2020-06-30 18:10:44 -05:00
Adam Honse b3860be638 Bring in NZXT Hue 2 controller improvements from fan_devel branch 2020-06-28 23:44:35 -05:00
Adam Honse 8ecabb0789 Add 32-bit GitLab CI build target for Windows 2020-06-28 22:40:42 -05:00
Adam Honse d3fc88b24f Fix USB serial port detection in Windows. Fixes false Hue+ detection 2020-06-28 22:36:25 -05:00
Adam Honse dfb2e52e7b Add --i2c-tools to help text with warning, set GUI flag if --i2c-tools is specified 2020-06-28 21:41:00 -05:00
Adam Honse 96af869d79 Check for local server before detecting devices from hardware and tweak timeouts to make network connections faster 2020-06-28 21:08:59 -05:00
Adam Honse 4c6429ae76 Add OpenRGB client support to GUI 2020-06-28 17:57:27 -05:00
Adam Honse 7d2877a8e9 Don't exit after loading a profile from the command line 2020-06-28 11:21:56 -05:00
Adam Honse a25f3ef2fc GUI rework to provide more control over optional tabs to main.cpp, add TODO comments for client mode 2020-06-28 03:01:43 -05:00
Adam Honse 15ace9d094 Add flag to start application minimized to tray 2020-06-28 02:30:23 -05:00
Adam Honse 58aba0a147 Allow specifying --gui and --server together 2020-06-28 02:18:28 -05:00
87 changed files with 5009 additions and 1216 deletions
+88 -6
View File
@@ -4,6 +4,10 @@
# https://www.kittell.net/code/powershell-unix-sed-equivalent-change-text-file/
# https://powershell.org/forums/topic/how-to-use-ansi-vt100-formatting-in-powershell-ooh-pretty-colors/
#-----------------------------------------------------------------------#
# OpenRGB GitLab CI Configuration #
#-----------------------------------------------------------------------#
.shared_windows_runners:
tags:
- shared-windows
@@ -16,6 +20,9 @@ stages:
before_script:
- echo "started by ${GITLAB_USER_NAME}"
#-----------------------------------------------------------------------#
# Linux (AppImage) Build Target #
#-----------------------------------------------------------------------#
build_linux:
image: ubuntu:bionic
stage: build
@@ -29,7 +36,82 @@ build_linux:
- OpenRGB-x86_64.AppImage
expire_in: 1337 years
build_windows:
#-----------------------------------------------------------------------#
# Windows (32-bit) Build Target #
#-----------------------------------------------------------------------#
build_windows_32:
extends:
- .shared_windows_runners
stage: build
script:
- $esc = "$([char]27)"
- $count = 0
- function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds }
- function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; }
- function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; }
- _fold_start_ 'configuring the msvc environment variables'
- Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build"
- '& cmd.exe /C "vcvarsall.bat x86 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }'
- Pop-Location
- _fold_final_
- _fold_start_ 'downloading precompiled versions of qtbase, qttools (for windeployqt) and jom (for a more parallel nmake)'
- mkdir _qt
- mkdir _qt_download
- Push-Location _qt_download
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win32_msvc2019/5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win32_msvc2019/5.15.0-0-202005150700qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z'
- curl.exe -LJ -o qt-jom.zip 'https://download.qt.io/official_releases/jom/jom.zip'
- _fold_final_
- _fold_start_ 'extracting the downloaded qt binaries'
- 7z x qt-base.7z '-o../_qt' -y
- 7z x qt-tools.7z '-o../_qt' -y
- 7z x qt-jom.zip '-o../_qt' -y
- _fold_final_
- _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019\mkspecs\qconfig.pri'
- (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder}
- (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder}
- Pop-Location
- _fold_final_
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
- mkdir _build; cd _build
- ..\_qt\5.15.0\msvc2019\bin\qmake ..\OpenRGB.pro
- _fold_final_
- _fold_start_ 'start the actual build with jom instead of nmake; for speed'
- ..\_qt\jom
- _fold_final_
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
- ..\_qt\5.15.0\msvc2019\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- _fold_final_
- _fold_start_ 'compressing the release folder so that we can upload it as artifact'
- mv release 'OpenRGB Windows 32-bit'
- ${datetime} = Get-Date ([datetime]::UtcNow) -Format "yyyy-MM-ddTHH-mm-ss"
- ${revision} = ((git rev-parse --short HEAD) | Out-String).Trim()
- ${rversion} = (((Get-Content '..\OpenRGB.pro' | Select-String -Pattern "VERSION =") | Out-String).Trim().Split("="))[1].Trim()
- 7z a -mx9 -r -y "OpenRGB_${rversion}_32_${revision}_nightly_${datetime}.7z" 'OpenRGB Windows 32-bit'
- _fold_final_
# cache:
# key: same-key
# paths:
# - C:\vcpkg\installed\
artifacts:
paths:
- _build/*.7z
expire_in: 1337 years
#-----------------------------------------------------------------------#
# Windows (64-bit) Build Target #
#-----------------------------------------------------------------------#
build_windows_64:
extends:
- .shared_windows_runners
stage: build
@@ -51,8 +133,8 @@ build_windows:
- mkdir _qt
- mkdir _qt_download
- Push-Location _qt_download
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qtbase-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qttools-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2019_64/5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2019_64/5.15.0-0-202005150700qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-jom.zip 'https://download.qt.io/official_releases/jom/jom.zip'
- _fold_final_
@@ -63,7 +145,7 @@ build_windows:
- _fold_final_
- _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2017_64\mkspecs\qconfig.pri'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019_64\mkspecs\qconfig.pri'
- (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder}
- (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder}
- Pop-Location
@@ -71,7 +153,7 @@ build_windows:
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
- mkdir _build; cd _build
- ..\_qt\5.15.0\msvc2017_64\bin\qmake ..\OpenRGB.pro
- ..\_qt\5.15.0\msvc2019_64\bin\qmake ..\OpenRGB.pro
- _fold_final_
- _fold_start_ 'start the actual build with jom instead of nmake; for speed'
@@ -79,7 +161,7 @@ build_windows:
- _fold_final_
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
- ..\_qt\5.15.0\msvc2017_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- ..\_qt\5.15.0\msvc2019_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- _fold_final_
- _fold_start_ 'compressing the release folder so that we can upload it as artifact'
@@ -49,6 +49,7 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
unsigned char usb_buf[] =
{
0x00,
0x40, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -67,9 +68,9 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x02] = channel;
usb_buf[0x03] = channel;
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
ret_string.append((char *)&usb_buf[0x08]);
@@ -83,6 +84,7 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
unsigned char usb_buf[] =
{
0x00,
0x12, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -103,7 +105,7 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
unsigned char fw_buf[16] = {0x00};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
for(int char_idx = 0; char_idx < 16; char_idx+=2)
@@ -206,6 +208,7 @@ void AMDWraithPrismController::SendEnableCommand()
{
unsigned char usb_buf[] =
{
0x00,
0x41, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -224,7 +227,7 @@ void AMDWraithPrismController::SendEnableCommand()
0x00, 0x00, 0x00, 0x00,
};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -232,6 +235,7 @@ void AMDWraithPrismController::SendApplyCommand()
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0x28, 0x00, 0x00,
0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -250,7 +254,7 @@ void AMDWraithPrismController::SendApplyCommand()
0x00, 0x00, 0x00, 0x00,
};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -269,6 +273,7 @@ void AMDWraithPrismController::SendEffectChannelUpdate
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0x2C, 0x01, 0x00,
0x05, 0xFF, 0x00, 0x01,
0xFF, 0xFF, 0x00, 0xFF,
@@ -287,18 +292,18 @@ void AMDWraithPrismController::SendEffectChannelUpdate
0xFF, 0xFF, 0xFF, 0xFF
};
usb_buf[0x04] = effect_channel;
usb_buf[0x05] = speed;
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x07] = mode;
usb_buf[0x05] = effect_channel;
usb_buf[0x06] = speed;
usb_buf[0x07] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x08] = mode;
usb_buf[0x09] = brightness;
usb_buf[0x0A] = brightness;
usb_buf[0x0A] = red;
usb_buf[0x0B] = green;
usb_buf[0x0C] = blue;
usb_buf[0x0B] = red;
usb_buf[0x0C] = green;
usb_buf[0x0D] = blue;
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -306,6 +311,7 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0xA0, 0x01, 0x00,
0x00, 0x03, 0x00, 0x00,
0x05, 0x06, 0x07, 0x07,
@@ -324,14 +330,14 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x08] = logo_channel;
usb_buf[0x09] = fan_channel;
usb_buf[0x09] = logo_channel;
usb_buf[0x0A] = fan_channel;
for(int led = 0x0A; led <= 0x18; led++)
for(int led = 0x0B; led <= 0x19; led++)
{
usb_buf[led] = ring_channel;
}
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -28,23 +28,24 @@ void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controller
{
if((info->vendor_id == AMD_WRAITH_PRISM_VID)
&&(info->product_id == AMD_WRAITH_PRISM_PID)
#if USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
if( dev )
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
@@ -65,7 +65,7 @@ void CorsairLightingNodeController::KeepaliveThread()
{
while(1)
{
if((clock() - last_commit_time) > 5000)
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(5))
{
SendCommit();
}
@@ -198,7 +198,7 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
void CorsairLightingNodeController::SendFirmwareRequest()
{
int actual;
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -208,13 +208,14 @@ void CorsairLightingNodeController::SendFirmwareRequest()
/*-----------------------------------------------------*\
| Set up Firmware Version Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
actual = hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
actual = hid_read(dev, usb_buf, 17);
if(actual > 0)
{
@@ -231,7 +232,7 @@ void CorsairLightingNodeController::SendDirect
unsigned char* color_data
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -241,27 +242,28 @@ void CorsairLightingNodeController::SendDirect
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x02] = channel;
usb_buf[0x03] = start;
usb_buf[0x04] = count;
usb_buf[0x05] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
memcpy(&usb_buf[0x06], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendCommit()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -271,19 +273,20 @@ void CorsairLightingNodeController::SendCommit()
/*-----------------------------------------------------*\
| Update last commit time |
\*-----------------------------------------------------*/
last_commit_time = clock();
last_commit_time = std::chrono::steady_clock::now();
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x02] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBegin
@@ -291,7 +294,7 @@ void CorsairLightingNodeController::SendBegin
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -301,14 +304,15 @@ void CorsairLightingNodeController::SendBegin
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendEffectConfig
@@ -334,7 +338,7 @@ void CorsairLightingNodeController::SendEffectConfig
unsigned short temperature_2
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -344,48 +348,49 @@ void CorsairLightingNodeController::SendEffectConfig
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count;
usb_buf[0x03] = led_type;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x02] = channel;
usb_buf[0x03] = count;
usb_buf[0x04] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
usb_buf[0x05] = mode;
usb_buf[0x06] = speed;
usb_buf[0x07] = direction;
usb_buf[0x08] = change_style;
usb_buf[0x09] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x0A] = color_0_green;
usb_buf[0x0B] = color_0_blue;
usb_buf[0x0C] = color_1_red;
usb_buf[0x0D] = color_1_green;
usb_buf[0x0E] = color_1_blue;
usb_buf[0x0F] = color_2_red;
usb_buf[0x10] = color_2_green;
usb_buf[0x11] = color_2_blue;
usb_buf[0x0A] = color_0_red;
usb_buf[0x0B] = color_0_green;
usb_buf[0x0C] = color_0_blue;
usb_buf[0x0D] = color_1_red;
usb_buf[0x0E] = color_1_green;
usb_buf[0x0F] = color_1_blue;
usb_buf[0x10] = color_2_red;
usb_buf[0x11] = color_2_green;
usb_buf[0x12] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
usb_buf[0x13] = (temperature_0 >> 8);
usb_buf[0x14] = (temperature_0 & 0xFF);
usb_buf[0x15] = (temperature_1 >> 8);
usb_buf[0x16] = (temperature_1 & 0xFF);
usb_buf[0x17] = (temperature_2 >> 8);
usb_buf[0x18] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendTemperature()
@@ -398,7 +403,7 @@ void CorsairLightingNodeController::SendReset
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -408,14 +413,15 @@ void CorsairLightingNodeController::SendReset
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendPortState
@@ -424,7 +430,7 @@ void CorsairLightingNodeController::SendPortState
unsigned char state
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -434,15 +440,16 @@ void CorsairLightingNodeController::SendPortState
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x02] = channel;
usb_buf[0x03] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBrightness()
@@ -5,6 +5,7 @@
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <chrono>
#include <vector>
#include <hidapi/hidapi.h>
@@ -109,7 +110,7 @@ public:
private:
hid_device* dev;
std::string firmware_version;
clock_t last_commit_time;
std::chrono::time_point<std::chrono::steady_clock> last_commit_time;
void SendFirmwareRequest();
@@ -24,27 +24,12 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
std::this_thread::sleep_for(1ms);
}
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
{
dev = dev_handle;
ReadFirmwareInfo();
SpecialFunctionControl();
LightingControl();
}
@@ -233,7 +218,7 @@ void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> c
void CorsairPeripheralController::LightingControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -243,9 +228,10 @@ void CorsairPeripheralController::LightingControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Lighting control byte needs to be 3 for keyboards and |
@@ -255,31 +241,31 @@ void CorsairPeripheralController::LightingControl()
{
default:
case DEVICE_TYPE_KEYBOARD:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
case DEVICE_TYPE_MOUSE:
usb_buf[0x04] = 0x01;
usb_buf[0x05] = 0x01;
break;
case DEVICE_TYPE_MOUSEMAT:
usb_buf[0x04] = 0x04;
usb_buf[0x05] = 0x04;
break;
case DEVICE_TYPE_HEADSET_STAND:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SpecialFunctionControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -289,20 +275,22 @@ void CorsairPeripheralController::SpecialFunctionControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::ReadFirmwareInfo()
{
int actual;
char usb_buf[64];
char usb_buf[65];
char offset = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -312,16 +300,17 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet and try reading it using an HID read |
| If that fails, repeat the send and read the reply as |
| a feature report. |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 64, 1000);
hid_write(dev, (unsigned char*)usb_buf, 65);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 65, 1000);
if(actual == 0)
{
@@ -333,11 +322,13 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
hid_send_feature_report(dev, (unsigned char*)usb_buf, 65);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 65);
offset = 1;
}
/*-----------------------------------------------------*\
@@ -346,7 +337,7 @@ void CorsairPeripheralController::ReadFirmwareInfo()
| 0xC1 Device is a mouse |
| 0xC2 Device is a mousepad or headset stand |
\*-----------------------------------------------------*/
switch((unsigned char)usb_buf[0x14])
switch((unsigned char)usb_buf[0x14 + offset])
{
case 0xC0:
type = DEVICE_TYPE_KEYBOARD;
@@ -354,6 +345,7 @@ void CorsairPeripheralController::ReadFirmwareInfo()
case 0xC1:
type = DEVICE_TYPE_MOUSE;
SpecialFunctionControl();
break;
case 0xC2:
@@ -364,10 +356,12 @@ void CorsairPeripheralController::ReadFirmwareInfo()
{
case 0x0A34:
type = DEVICE_TYPE_HEADSET_STAND;
SpecialFunctionControl();
break;
default:
type = DEVICE_TYPE_MOUSEMAT;
SpecialFunctionControl();
break;
}
}
@@ -383,7 +377,7 @@ void CorsairPeripheralController::ReadFirmwareInfo()
\*-----------------------------------------------------*/
if(type != DEVICE_TYPE_UNKNOWN)
{
firmware_version = std::to_string(usb_buf[0x09]) + "." + std::to_string(usb_buf[0x08]);
firmware_version = std::to_string(usb_buf[0x09 + offset]) + "." + std::to_string(usb_buf[0x08 + offset]);
}
}
@@ -394,7 +388,7 @@ void CorsairPeripheralController::StreamPacket
unsigned char* data_ptr
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -404,19 +398,20 @@ void CorsairPeripheralController::StreamPacket
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_STREAM;
usb_buf[0x02] = packet_id;
usb_buf[0x03] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
memcpy(&usb_buf[0x05], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardFullColors
@@ -426,7 +421,7 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
unsigned char finish_val
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -436,16 +431,17 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x02] = color_channel;
usb_buf[0x03] = packet_count;
usb_buf[0x04] = finish_val;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x03] = color_channel;
usb_buf[0x04] = packet_count;
usb_buf[0x05] = finish_val;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardLimitedColors
@@ -453,7 +449,7 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
unsigned char byte_count
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -463,14 +459,15 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x05] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMouseColors
@@ -479,7 +476,7 @@ void CorsairPeripheralController::SubmitMouseColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -489,26 +486,27 @@ void CorsairPeripheralController::SubmitMouseColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 4) + 4] = zone_idx;
usb_buf[(zone_idx * 4) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 5] = zone_idx;
usb_buf[(zone_idx * 4) + 6] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 8] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMousematColors
@@ -517,7 +515,7 @@ void CorsairPeripheralController::SubmitMousematColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -527,24 +525,25 @@ void CorsairPeripheralController::SubmitMousematColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 3) + 4] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 7] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
@@ -39,6 +39,9 @@
| Mouse product IDs |
| List taken from ckb-next |
\*-----------------------------------------------------*/
#define CORSAIR_GLAIVE_RGB_PRO_PID 0x1B74
#define CORSAIR_HARPOON_RGB_PID 0x1B3C
#define CORSAIR_HARPOON_RGB_PRO_PID 0x1B75
#define CORSAIR_M65_PRO_PID 0x1B2E
#define CORSAIR_M65_RGB_ELITE_PID 0x1B5A
@@ -87,6 +90,9 @@ static const corsair_node_device device_list[] =
/*-----------------------------------------------------------------------------------------------------*\
| Mice |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_GLAIVE_RGB_PRO_PID, 1, "Corsair Glaive RGB PRO" },
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PID, 1, "Corsair Harpoon RGB" },
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PRO_PID, 1, "Corsair Harpoon RGB PRO" },
{ CORSAIR_VID, CORSAIR_M65_PRO_PID, 1, "Corsair M65 PRO" },
{ CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, "Corsair M65 RGB Elite" },
/*-----------------------------------------------------------------------------------------------------*\
@@ -124,30 +130,31 @@ void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_control
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
#ifdef USE_HID_USAGE
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->usage_page == 0xFFC2))
#else
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
info = info->next;
}
}
}
@@ -0,0 +1,187 @@
/*-----------------------------------------*\
| DuckyKeyboardController.cpp |
| |
| Driver for Ducky RGB keyboardlighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#include <cstring>
#include "DuckyKeyboardController.h"
DuckyKeyboardController::DuckyKeyboardController(hid_device* dev_handle)
{
dev = dev_handle;
SendInitialize();
}
DuckyKeyboardController::~DuckyKeyboardController()
{
}
void DuckyKeyboardController::SendColors
(
unsigned char* color_data,
unsigned int color_data_size
)
{
unsigned int bytes_sent;
unsigned char* color_data_ptr = color_data;
SendInitializeColorPacket();
for(int i = 0; i < 8; i++)
{
bytes_sent = SendColorDataPacket(i, color_data_ptr, color_data_size);
color_data_ptr += bytes_sent;
color_data_size -= bytes_sent;
}
SendTerminateColorPacket();
}
void DuckyKeyboardController::SendInitialize()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Initialize Direct Mode packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x41;
usb_buf[0x02] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void DuckyKeyboardController::SendInitializeColorPacket()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Initialize Color packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x56;
usb_buf[0x02] = 0x81;
usb_buf[0x05] = 0x01;
usb_buf[0x09] = 0x08;
usb_buf[0x0D] = 0xAA;
usb_buf[0x0E] = 0xAA;
usb_buf[0x0F] = 0xAA;
usb_buf[0x10] = 0xAA;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
unsigned int DuckyKeyboardController::SendColorDataPacket
(
unsigned char packet_id,
unsigned char* color_data,
unsigned int color_size
)
{
unsigned int bytes_sent;
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Color Data packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x56;
usb_buf[0x02] = 0x83;
usb_buf[0x03] = packet_id;
if(packet_id == 0x00)
{
usb_buf[0x05] = 0x01;
usb_buf[0x09] = 0x80;
usb_buf[0x0A] = 0x01;
usb_buf[0x0C] = 0xC1;
usb_buf[0x11] = 0xFF;
usb_buf[0x12] = 0xFF;
usb_buf[0x13] = 0xFF;
usb_buf[0x14] = 0xFF;
}
/*-----------------------------------------------------*\
| Copy in color data |
\*-----------------------------------------------------*/
if(packet_id == 0x00)
{
bytes_sent = 65 - 0x19;
if(color_size < bytes_sent)
{
bytes_sent = color_size;
}
memcpy(&usb_buf[0x19], color_data, bytes_sent);
}
else
{
bytes_sent = 65 - 0x05;
if(color_size < bytes_sent)
{
bytes_sent = color_size;
}
memcpy(&usb_buf[0x05], color_data, bytes_sent);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
return(bytes_sent);
}
void DuckyKeyboardController::SendTerminateColorPacket()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Terminate Color packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = 0x28;
usb_buf[0x05] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
@@ -0,0 +1,41 @@
/*-----------------------------------------*\
| DuckyKeyboardController.h |
| |
| Definitions and types for Ducky RGB |
| keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class DuckyKeyboardController
{
public:
DuckyKeyboardController(hid_device* dev_handle);
~DuckyKeyboardController();
void SendColors
(
unsigned char* color_data,
unsigned int color_data_size
);
private:
hid_device* dev;
void SendInitialize();
void SendInitializeColorPacket();
unsigned int SendColorDataPacket
(
unsigned char packet_id,
unsigned char* color_data,
unsigned int color_size
);
void SendTerminateColorPacket();
};
@@ -0,0 +1,81 @@
#include "DuckyKeyboardController.h"
#include "RGBController.h"
#include "RGBController_DuckyKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Ducky vendor ID |
\*-----------------------------------------------------*/
#define DUCKY_VID 0x04D9
/*-----------------------------------------------------*\
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define DUCKY_SHINE_7_ONE_2_RGB_PID 0x0348
#define DUCKY_ONE_2_RGB_TKL_PID 0x0356
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
const char * name;
} ducky_device;
#define DUCKY_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const ducky_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ DUCKY_VID, DUCKY_SHINE_7_ONE_2_RGB_PID, 1, "Ducky Shine 7/Ducky One 2 RGB" },
{ DUCKY_VID, DUCKY_ONE_2_RGB_TKL_PID, 1, "Ducky One 2 RGB TKL" },
};
/******************************************************************************************\
* *
* DetectDuckyKeyboardControllers *
* *
* Tests the USB address to see if a Ducky RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectDuckyKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(std::size_t device_idx = 0; device_idx < DUCKY_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Ducky RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
if( dev )
{
DuckyKeyboardController* controller = new DuckyKeyboardController(dev);
RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
}
@@ -29,9 +29,14 @@ void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controller
//Look for Glorious Model O
while(info)
{
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
@@ -0,0 +1,116 @@
/*-----------------------------------------*\
| HyperXAlloyOriginsController.cpp |
| |
| Driver for HyperX Alloy Origins RGB |
| Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#include "HyperXAlloyOriginsController.h"
#include <cstring>
HyperXAlloyOriginsController::HyperXAlloyOriginsController(hid_device* dev_handle)
{
dev = dev_handle;
}
HyperXAlloyOriginsController::~HyperXAlloyOriginsController()
{
}
void HyperXAlloyOriginsController::SetLEDsDirect(std::vector<RGBColor> colors)
{
int colors_to_send = colors.size();
int colors_sent = 0;
SendDirectInitialization();
for(int pkt_idx = 0; pkt_idx < 9; pkt_idx++)
{
if(colors_to_send > 16)
{
SendDirectColorPacket(&colors[colors_sent], 16);
colors_sent += 16;
colors_to_send -= 16;
}
else if(colors_to_send > 0)
{
SendDirectColorPacket(&colors[colors_sent], colors_to_send);
colors_sent += colors_to_send;
colors_to_send -= colors_to_send;
}
else
{
RGBColor temp = 0x00000000;
SendDirectColorPacket(&temp, 1);
}
}
}
void HyperXAlloyOriginsController::SendDirectInitialization()
{
unsigned char buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct Initialization packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x00;
buf[0x01] = 0x04;
buf[0x02] = 0xF2;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, &buf[1], 64);
}
void HyperXAlloyOriginsController::SendDirectColorPacket
(
RGBColor* color_data,
unsigned int color_count
)
{
unsigned char buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct Initialization packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x00;
/*-----------------------------------------------------*\
| The maximum number of colors per packet is 16 |
\*-----------------------------------------------------*/
if(color_count > 16)
{
color_count = 16;
}
/*-----------------------------------------------------*\
| Copy in color data |
\*-----------------------------------------------------*/
for(int color_idx = 0; color_idx < color_count; color_idx++)
{
buf[(color_idx * 4) + 1] = 0x81;
buf[(color_idx * 4) + 2] = RGBGetRValue(color_data[color_idx]);
buf[(color_idx * 4) + 3] = RGBGetGValue(color_data[color_idx]);
buf[(color_idx * 4) + 4] = RGBGetBValue(color_data[color_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, &buf[1], 64);
}
@@ -0,0 +1,34 @@
/*-----------------------------------------*\
| HyperXAlloyOriginsController.h |
| |
| Definitions and types for HyperX Alloy |
| Origins RGB Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class HyperXAlloyOriginsController
{
public:
HyperXAlloyOriginsController(hid_device* dev_handle);
~HyperXAlloyOriginsController();
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
hid_device* dev;
void SendDirectInitialization();
void SendDirectColorPacket
(
RGBColor* color_data,
unsigned int color_count
);
};
@@ -144,12 +144,12 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
blu_color_data
);
std::this_thread::sleep_for(5ms);
//std::this_thread::sleep_for(5ms);
SendDirectExtended
(
ext_color_data
);
//SendDirectExtended
// (
// ext_color_data
// );
}
void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
@@ -431,6 +431,7 @@ void HyperXKeyboardController::SendDirect
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = color_channel;
buf[0x03] = 0xA0;
/*-----------------------------------------------------*\
| Fill in color data |
@@ -464,6 +465,7 @@ void HyperXKeyboardController::SendDirectExtended
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = HYPERX_COLOR_CHANNEL_EXTENDED;
buf[0x03] = 0xA0;
/*-----------------------------------------------------*\
| Fill in color data |
@@ -1,5 +1,7 @@
#include "HyperXAlloyOriginsController.h"
#include "HyperXKeyboardController.h"
#include "RGBController.h"
#include "RGBController_HyperXAlloyOrigins.h"
#include "RGBController_HyperXKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
@@ -9,6 +11,8 @@
\*-----------------------------------------------------*/
#define HYPERX_KEYBOARD_VID 0x0951
#define HYPERX_ALLOY_ELITE_PID 0x16BE
#define HYPERX_ALLOY_FPS_RGB_PID 0x16DC
#define HYPERX_ALLOY_ORIGINS_PID 0x16E5
typedef struct
{
@@ -26,6 +30,8 @@ static const hyperx_device device_list[] =
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, "HyperX Alloy Elite RGB" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, "HyperX Alloy FPS RGB" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 3, "HyperX Alloy Origins" },
};
/******************************************************************************************\
@@ -52,28 +58,50 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
//Look for HyperX RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
if((device_list[device_idx].usb_pid != HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
if((device_list[device_idx].usb_pid == HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
break;
if( dev )
{
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev);
RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
}
@@ -65,78 +65,132 @@ static const logitech_device device_list[] =
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Logitech RGB Peripheral
while(info)
switch(device_list[device_idx].type)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
/*-------------------------------------------------------------------------------------------------*\
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_KEYBOARD:
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF43)
&&(info->usage == 0x0602))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
LogitechG810Controller* controller = new LogitechG810Controller(dev);
hid_device* dev_usage_0x0602 = hid_open_path(info->path);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
if(dev_usage_0x0602)
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
#ifdef USE_HID_USAGE
hid_device_info* tmp_info_0x0604 = info;
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
while(tmp_info_0x0604)
{
if((tmp_info_0x0604->vendor_id == device_list[device_idx].usb_vid)
&&(tmp_info_0x0604->product_id == device_list[device_idx].usb_pid)
&&(tmp_info_0x0604->interface_number == device_list[device_idx].usb_interface)
&&(tmp_info_0x0604->usage_page == 0xFF43)
&&(tmp_info_0x0604->usage == 0x0604))
{
hid_device* dev_usage_0x0604 = hid_open_path(tmp_info_0x0604->path);
if(dev_usage_0x0604)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
tmp_info_0x0604 = tmp_info_0x0604->next;
}
#else
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0602);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
#endif
}
}
}
break;
info = info->next;
}
hid_free_enumeration(info);
}
break;
/*-------------------------------------------------------------------------------------------------*\
| Logitech mice use a single usage on page 0xFF00 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_MOUSE:
{
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF00)
&&(info->usage == 2))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
}
info = info->next;
}
hid_free_enumeration(info);
}
break;
}
hid_free_enumeration(info);
}
}
@@ -10,9 +10,10 @@
#include "LogitechG810Controller.h"
#include <cstring>
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle)
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
{
dev = dev_handle;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
}
LogitechG810Controller::~LogitechG810Controller()
@@ -74,8 +75,8 @@ void LogitechG810Controller::SendCommit()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendDirectFrame
@@ -110,8 +111,8 @@ void LogitechG810Controller::SendDirectFrame
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x12, (unsigned char *)usb_buf, 64);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendMode
@@ -163,6 +164,6 @@ void LogitechG810Controller::SendMode
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
@@ -49,7 +49,7 @@ enum
class LogitechG810Controller
{
public:
LogitechG810Controller(hid_device* dev_handle);
LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
~LogitechG810Controller();
void Commit();
@@ -71,7 +71,8 @@ public:
);
private:
hid_device* dev;
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
void SendDirectFrame
(
@@ -0,0 +1,74 @@
/*-----------------------------------------*\
| MSIGPUController.cpp |
| |
| Driver for MSI GPUs |
| |
\*-----------------------------------------*/
#include "MSIGPUController.h"
#include <cstring>
MSIGPUController::MSIGPUController(i2c_smbus_interface* bus)
{
this->bus = bus;
this->dev = 0x68;
strcpy(device_name, "MSI RTX GPU");
}
MSIGPUController::~MSIGPUController()
{
}
std::string MSIGPUController::GetDeviceName()
{
return(device_name);
}
std::string MSIGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
void MSIGPUController::SetRGB1(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R1, red);
MSIGPURegisterWrite(MSI_GPU_REG_G1, green);
MSIGPURegisterWrite(MSI_GPU_REG_B1, blue);
}
void MSIGPUController::SetRGB2(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R2, red);
MSIGPURegisterWrite(MSI_GPU_REG_G2, green);
MSIGPURegisterWrite(MSI_GPU_REG_B2, blue);
}
void MSIGPUController::SetRGB3(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R3, red);
MSIGPURegisterWrite(MSI_GPU_REG_G3, green);
MSIGPURegisterWrite(MSI_GPU_REG_B3, blue);
}
void MSIGPUController::SetMode(unsigned char mode)
{
MSIGPURegisterWrite(MSI_GPU_REG_MODE, mode);
MSIGPURegisterWrite(MSI_GPU_REG_APPLY, 0x01);
}
unsigned char MSIGPUController::MSIGPURegisterRead(unsigned char reg)
{
return(bus->i2c_smbus_read_byte_data(dev, reg));
}
void MSIGPUController::MSIGPURegisterWrite(unsigned char reg, unsigned char val)
{
bus->i2c_smbus_write_byte_data(dev, reg, val);
}
@@ -0,0 +1,79 @@
/*-----------------------------------------*\
| MSIGPUController.h |
| |
| Definitions for MSI GPUs |
| |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char msi_gpu_dev_id;
enum
{
MSI_GPU_REG_BRIGHTNESS = 0x36, /* MSI GPU Brightness Register */
MSI_GPU_REG_SPEED = 0x38, /* MSI GPU Speed Register */
MSI_GPU_REG_UNKNOWN = 0x26, /* MSI GPU Unknown Register */
MSI_GPU_REG_R1 = 0x30, /* MSI GPU R1 Register */
MSI_GPU_REG_G1 = 0x31, /* MSI GPU G1 Register */
MSI_GPU_REG_B1 = 0x32, /* MSI GPU B1 Register */
MSI_GPU_REG_R2 = 0x27, /* MSI GPU R2 Register */
MSI_GPU_REG_G2 = 0x28, /* MSI GPU G2 Register */
MSI_GPU_REG_B2 = 0x29, /* MSI GPU B2 Register */
MSI_GPU_REG_R3 = 0x2a, /* MSI GPU R3 Register */
MSI_GPU_REG_G3 = 0x2b, /* MSI GPU G3 Register */
MSI_GPU_REG_B3 = 0x2c, /* MSI GPU B3 Register */
MSI_GPU_REG_MODE = 0x22, /* MSI GPU Mode Selection Register */
MSI_GPU_REG_APPLY = 0x3f, /* MSI GPU Apply Changes Register */
};
enum
{
MSI_GPU_MODE_OFF = 0x01, /* OFF mode */
MSI_GPU_MODE_RAINBOW = 0x08, /* Rainbow effect mode */
MSI_GPU_MODE_STATIC = 0x13, /* Static color mode */
MSI_GPU_MODE_RAINDROP = 0x1a, /* Raindrop effect mode */
MSI_GPU_MODE_MAGIC = 0x07, /* Magic effect mode */
MSI_GPU_MODE_PATROLLING = 0x05, /* Patrolling effect mode */
MSI_GPU_MODE_STREAMING = 0x06, /* Streaming effect mode */
MSI_GPU_MODE_LIGHTNING = 0x15, /* Lightning effect mode */
MSI_GPU_MODE_WAVE = 0x1f, /* Wave effect mode */
MSI_GPU_MODE_METEOR = 0x16, /* Meteor effect mode */
MSI_GPU_MODE_STACK = 0x0d, /* Stack effect mode */
MSI_GPU_MODE_RHYTHM = 0x0b, /* Rhythm effect mode */
MSI_GPU_MODE_FLOWING = 0x09, /* Flowing effect mode */
MSI_GPU_MODE_WHIRLING = 0x0f, /* Whirling effect mode */
MSI_GPU_MODE_TWISTING = 0x11, /* Twisting effect mode */
MSI_GPU_MODE_LAMINATING = 0x1d, /* Laminating effect mode */
MSI_GPU_MODE_FADEIN = 0x14, /* Fadein effect mode */
MSI_GPU_MODE_BREATHING = 0x04, /* Breathing effect mode */
MSI_GPU_MODE_FLASHING = 0x02, /* Flashing effect mode */
MSI_GPU_MODE_DOUBLEFLASHING = 0x03, /* Doubleflashing effect mode */
};
class MSIGPUController
{
public:
MSIGPUController(i2c_smbus_interface* bus);
~MSIGPUController();
std::string GetDeviceName();
std::string GetDeviceLocation();
void SetRGB1(unsigned char red, unsigned char green, unsigned char blue);
void SetRGB2(unsigned char red, unsigned char green, unsigned char blue);
void SetRGB3(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned char MSIGPURegisterRead(unsigned char reg);
void MSIGPURegisterWrite(unsigned char reg, unsigned char val);
private:
char device_name[16];
i2c_smbus_interface * bus;
msi_gpu_dev_id dev;
};
@@ -0,0 +1,86 @@
/*-----------------------------------------*\
| MSIGPUControllerDetect.cpp |
| |
| Driver for MSI GPUs |
| |
\*-----------------------------------------*/
#include "MSIGPUController.h"
#include "RGBController.h"
#include "RGBController_MSIGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* IsMSIGPUController *
* *
* Compare PCI IDs *
* *
\******************************************************************************************/
bool IsMSIGPUController(i2c_smbus_interface* bus)
{
bool pass = false;
if (bus->port_id != 1)
{
return(pass);
}
// MSI RTX 2080S Gaming X Trio
if (bus->pci_device == 0x1e81 &&
bus->pci_vendor == 0x10de &&
bus->pci_subsystem_device == 0xc724 &&
bus->pci_subsystem_vendor == 0x1462)
{
pass = true;
}
// MSI RTX 2070S Gaming X Trio
if (bus->pci_device == 0x1e84 &&
bus->pci_vendor == 0x10de &&
bus->pci_subsystem_device == 0xc726 &&
bus->pci_subsystem_vendor == 0x1462)
{
pass = true;
}
// MSI RTX 2080 Ti Sea Hawk EK X
if (bus->pci_device == 0x1e07 &&
bus->pci_vendor == 0x10de &&
bus->pci_subsystem_device == 0x3717 &&
bus->pci_subsystem_vendor == 0x1462)
{
pass = true;
}
return(pass);
} /* IsMSIGPUController() */
/******************************************************************************************\
* *
* DetectMSIGPUControllers *
* *
* Detect MSI GPU controllers on the enumerated I2C busses. *
* *
\******************************************************************************************/
void DetectMSIGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
MSIGPUController* new_msi_gpu;
RGBController_MSIGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
if (IsMSIGPUController(busses[bus]))
{
new_msi_gpu = new MSIGPUController(busses[bus]);
new_controller = new RGBController_MSIGPU(new_msi_gpu);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectMSIGPUControllers() */
@@ -35,25 +35,34 @@ MSIMysticLightController::~MSIMysticLightController()
}
}
unsigned int MSIMysticLightController::GetZoneMinLedCount(ZONE /*zone*/)
unsigned int MSIMysticLightController::GetZoneMinLedCount
(
MSI_ZONE /*zone*/
)
{
return 1u;
return 1;
}
unsigned int MSIMysticLightController::GetZoneMaxLedCount(ZONE zone)
unsigned int MSIMysticLightController::GetZoneMaxLedCount
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RAINBOW_1:
case J_RAINBOW_2:
case J_CORSAIR:
return 4u; // TODO: It can be different by zone and by mobo
case MSI_ZONE_J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_2:
case MSI_ZONE_J_CORSAIR:
return 4; // TODO: It can be different by zone and by mobo
default:
return 1u;
return 1;
}
}
unsigned int MSIMysticLightController::GetZoneLedCount(ZONE zone)
unsigned int MSIMysticLightController::GetZoneLedCount
(
MSI_ZONE zone
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -65,7 +74,11 @@ unsigned int MSIMysticLightController::GetZoneLedCount(ZONE zone)
return requestedZone->cycle_or_led_num;
}
void MSIMysticLightController::SetZoneLedCount(ZONE zone, unsigned int led_count)
void MSIMysticLightController::SetZoneLedCount
(
MSI_ZONE zone,
unsigned int led_count
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -78,7 +91,14 @@ void MSIMysticLightController::SetZoneLedCount(ZONE zone, unsigned int led_count
requestedZone->cycle_or_led_num = led_count;
}
void MSIMysticLightController::SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color)
void MSIMysticLightController::SetMode
(
MSI_ZONE zone,
MSI_MODE mode,
MSI_SPEED speed,
MSI_BRIGHTNESS brightness,
bool rainbow_color
)
{
ZoneData* zoneData = GetZoneData(zone);
if(!zoneData)
@@ -113,12 +133,18 @@ std::string MSIMysticLightController::GetSerial()
bool MSIMysticLightController::ReadSettings()
{
return hid_get_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
/*-----------------------------------------------------*\
| Read packet from hardware, return true if successful |
\*-----------------------------------------------------*/
return(hid_get_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data);
}
bool MSIMysticLightController::Update()
{
return hid_send_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
/*-----------------------------------------------------*\
| Send packet to hardware, return true if successful |
\*-----------------------------------------------------*/
return(hid_send_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data);
}
void MSIMysticLightController::SaveOnUpdate(bool save)
@@ -126,26 +152,40 @@ void MSIMysticLightController::SaveOnUpdate(bool save)
data.save_data = save;
}
void MSIMysticLightController::SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2)
void MSIMysticLightController::SetZoneColor
(
MSI_ZONE zone,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
ZoneData* zoneData = GetZoneData(zone);
if(!zoneData)
{
return;
}
zoneData->color.R = r1;
zoneData->color.G = g1;
zoneData->color.B = b1;
zoneData->color.R = red1;
zoneData->color.G = grn1;
zoneData->color.B = blu1;
zoneData->color2.R = r2;
zoneData->color2.G = g2;
zoneData->color2.B = b2;
zoneData->color2.R = red2;
zoneData->color2.G = grn2;
zoneData->color2.B = blu2;
}
std::pair<Color, Color> MSIMysticLightController::GetZoneColor(ZONE zone)
std::pair<Color, Color> MSIMysticLightController::GetZoneColor
(
MSI_ZONE zone
)
{
ZoneData *zoneData = GetZoneData(zone);
if (!zoneData)
{
return std::make_pair(Color{}, Color{});
@@ -158,61 +198,67 @@ std::pair<Color, Color> MSIMysticLightController::GetZoneColor(ZONE zone)
Color{zoneData->color2.R, zoneData->color2.G, zoneData->color2.B});
}
ZoneData *MSIMysticLightController::GetZoneData(ZONE zone)
ZoneData *MSIMysticLightController::GetZoneData
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RGB_1:
case MSI_ZONE_J_RGB_1:
return &data.j_rgb_1;
case J_RGB_2:
case MSI_ZONE_J_RGB_2:
return &data.j_rgb_2;
case J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_1:
return &data.j_rainbow_1;
case J_RAINBOW_2:
case MSI_ZONE_J_RAINBOW_2:
return &data.j_rainbow_2;
case J_PIPE_1:
case MSI_ZONE_J_PIPE_1:
return &data.j_pipe_1;
case J_PIPE_2:
case MSI_ZONE_J_PIPE_2:
return &data.j_pipe_2;
case ON_BOARD_LED:
case MSI_ZONE_ON_BOARD_LED:
return &data.on_board_led;
case ON_BOARD_LED_1:
case MSI_ZONE_ON_BOARD_LED_1:
return &data.on_board_led_1;
case ON_BOARD_LED_2:
case MSI_ZONE_ON_BOARD_LED_2:
return &data.on_board_led_2;
case ON_BOARD_LED_3:
case MSI_ZONE_ON_BOARD_LED_3:
return &data.on_board_led_3;
case ON_BOARD_LED_4:
case MSI_ZONE_ON_BOARD_LED_4:
return &data.on_board_led_4;
case ON_BOARD_LED_5:
case MSI_ZONE_ON_BOARD_LED_5:
return &data.on_board_led_5;
case ON_BOARD_LED_6:
case MSI_ZONE_ON_BOARD_LED_6:
return &data.on_board_led_6;
case ON_BOARD_LED_7:
case MSI_ZONE_ON_BOARD_LED_7:
return &data.on_board_led_7;
case ON_BOARD_LED_8:
case MSI_ZONE_ON_BOARD_LED_8:
return &data.on_board_led_8;
case ON_BOARD_LED_9:
case MSI_ZONE_ON_BOARD_LED_9:
return &data.on_board_led_9;
case J_CORSAIR_OUTERLL120:
case MSI_ZONE_J_CORSAIR_OUTERLL120:
return &data.j_corsair_outerll120;
default:
case J_CORSAIR:
case MSI_ZONE_J_CORSAIR:
break;
}
return nullptr;
}
RainbowZoneData *MSIMysticLightController::GetRainbowZoneData(ZONE zone)
RainbowZoneData *MSIMysticLightController::GetRainbowZoneData
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_1:
return &data.j_rainbow_1;
case J_RAINBOW_2:
case MSI_ZONE_J_RAINBOW_2:
return &data.j_rainbow_2;
case J_CORSAIR:
case MSI_ZONE_J_CORSAIR:
default:
return nullptr;
}
@@ -220,39 +266,98 @@ RainbowZoneData *MSIMysticLightController::GetRainbowZoneData(ZONE zone)
bool MSIMysticLightController::ReadFwVersion()
{
// First read the APROM
// Checksum also available at report ID 180, with highCheksum stored at index 8, and low at 9
int num = 1;
unsigned char request[64] = {1, 176};
unsigned char request[64];
unsigned char response[64];
int ret_val = 64;
std::fill_n(request + 2, sizeof request - 2, 204);
num &= hid_write(dev, request, 64);
num &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| First read the APROM |
| Checksum also available at report ID 180, with MSB |
| stored at index 0x08 and LSB at 0x09 |
\*-----------------------------------------------------*/
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(request, 0x00, sizeof(request));
memset(response, 0x00, sizeof(response));
/*-----------------------------------------------------*\
| Set up APROM Firmware Version Request packet |
\*-----------------------------------------------------*/
request[0x00] = 0x01;
request[0x01] = 0xB0;
/*-----------------------------------------------------*\
| Fill request from 0x02 to 0x61 with 0xCC |
\*-----------------------------------------------------*/
memset(&request[0x02], 0xCC, sizeof(request) - 2);
/*-----------------------------------------------------*\
| Send request and receive response packets |
\*-----------------------------------------------------*/
ret_val &= hid_write(dev, request, 64);
ret_val &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| Extract high and low values from response |
\*-----------------------------------------------------*/
unsigned char highValue = response[2] >> 4;
unsigned char lowValue = response[2] & 15;
unsigned char lowValue = response[2] & 0x0F;
/*-----------------------------------------------------*\
| Build firmware string <high>.<low> |
\*-----------------------------------------------------*/
version_APROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
// Now read the LDROM
// Checksum also available at report ID 184, with highCheksum stored at index 8, and low at 9
request[1] = 182u;
num &= hid_write(dev, request, 64);
num &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| First read the LDROM |
| Checksum also available at report ID 184, with MSB |
| stored at index 0x08 and LSB at 0x09 |
\*-----------------------------------------------------*/
highValue = response[2] >> 4u;
lowValue = response[2] & 15u;
/*-----------------------------------------------------*\
| Set up LDROM Firmware Version Request packet |
\*-----------------------------------------------------*/
request[0x00] = 0x01;
request[0x01] = 0xB6;
/*-----------------------------------------------------*\
| Send request and receive response packets |
\*-----------------------------------------------------*/
ret_val &= hid_write(dev, request, 64);
ret_val &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| Extract high and low values from response |
\*-----------------------------------------------------*/
highValue = response[2] >> 4;
lowValue = response[2] & 0x0F;
/*-----------------------------------------------------*\
| Build firmware string <high>.<low> |
\*-----------------------------------------------------*/
version_LDROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
return num == 1;
/*-----------------------------------------------------*\
| If return value is zero it means an HID transfer |
| failed |
\*-----------------------------------------------------*/
return(ret_val > 0);
}
void MSIMysticLightController::ReadSerial()
{
wchar_t serial[256];
/*-----------------------------------------------------*\
| Get the serial number string from HID |
\*-----------------------------------------------------*/
hid_get_serial_number_string(dev, serial, 256);
/*-----------------------------------------------------*\
| Convert wchar_t into std::wstring into std::string |
\*-----------------------------------------------------*/
std::wstring wserial = std::wstring(serial);
chip_id = std::string(wserial.begin(), wserial.end());
}
@@ -260,27 +365,53 @@ void MSIMysticLightController::ReadSerial()
void MSIMysticLightController::ReadName()
{
wchar_t tname[256];
/*-----------------------------------------------------*\
| Get the manufacturer string from HID |
\*-----------------------------------------------------*/
hid_get_manufacturer_string(dev, tname, 256);
/*-----------------------------------------------------*\
| Convert wchar_t into std::wstring into std::string |
\*-----------------------------------------------------*/
std::wstring wname = std::wstring(tname);
name = std::string(wname.begin(), wname.end());
/*-----------------------------------------------------*\
| Get the product string from HID |
\*-----------------------------------------------------*/
hid_get_product_string(dev, tname, 256);
/*-----------------------------------------------------*\
| Append the product string to the manufacturer string |
\*-----------------------------------------------------*/
wname = std::wstring(tname);
name.append(" ").append(std::string(wname.begin(), wname.end()));
}
void MSIMysticLightController::SetDeviceSettings(bool is_fan, FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual)
void MSIMysticLightController::SetDeviceSettings
(
bool is_fan,
MSI_FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual
)
{
// If is_fan false, it is a stripe
CorsairZoneData &settingsZone = data.j_corsair;
settingsZone.fan_flags = (settingsZone.fan_flags & 128u) | fan_type << 1u | is_fan;
settingsZone.corsair_quantity = corsair_device_quantity << 2u;
settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0u);
/*-----------------------------------------------------*\
| If is_fan is false, it is an LED strip |
\*-----------------------------------------------------*/
CorsairZoneData &settingsZone = data.j_corsair;
settingsZone.fan_flags = (settingsZone.fan_flags & 0x80) | fan_type << 1 | is_fan;
settingsZone.corsair_quantity = corsair_device_quantity << 2;
settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0);
}
bool MSIMysticLightController::SetVolume(unsigned char main, unsigned char left, unsigned char right)
bool MSIMysticLightController::SetVolume
(
unsigned char main,
unsigned char left,
unsigned char right
)
{
unsigned char packet[64];
std::fill_n(packet, sizeof packet, 204u);
@@ -309,41 +440,78 @@ bool MSIMysticLightController::SetVolume(unsigned char main, unsigned char left,
return hid_write(dev, packet, sizeof packet);
}
void MSIMysticLightController::SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1,
bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2,
bool combine_crossair)
void MSIMysticLightController::SetBoardSyncSettings
(
bool onboard_sync,
bool combine_JRGB,
bool combine_JPIPE1,
bool combine_JPIPE2,
bool combine_JRAINBOW1,
bool combine_JRAINBOW2,
bool combine_crossair
)
{
ZoneData &syncZone = data.on_board_led;
syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5u);
syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7u);
/*-----------------------------------------------------*\
| Set sync flags for on-board LED zone |
\*-----------------------------------------------------*/
syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5);
syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7);
}
void MSIMysticLightController::GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color)
void MSIMysticLightController::GetMode
(
MSI_ZONE zone,
MSI_MODE &mode,
MSI_SPEED &speed,
MSI_BRIGHTNESS &brightness,
bool &rainbow_color
)
{
/*-----------------------------------------------------*\
| Get data for given zone |
\*-----------------------------------------------------*/
ZoneData *zoneData = GetZoneData(zone);
/*-----------------------------------------------------*\
| Return if zone is invalid |
\*-----------------------------------------------------*/
if (!zoneData)
{
return;
}
mode = static_cast<EFFECT>(zoneData->effect);
speed = static_cast<SPEED>(zoneData->speedAndBrightnessFlags & 3u);
brightness = static_cast<BRIGHTNESS>((zoneData->speedAndBrightnessFlags >> 2u) & 31u);
rainbow_color = (zoneData->colorFlags & 128u) >> 7u;
/*-----------------------------------------------------*\
| Update pointers with data |
\*-----------------------------------------------------*/
mode = (MSI_MODE)(zoneData->effect);
speed = (MSI_SPEED)(zoneData->speedAndBrightnessFlags & 0x03);
brightness = (MSI_BRIGHTNESS)((zoneData->speedAndBrightnessFlags >> 2) & 0x1F);
rainbow_color = (zoneData->colorFlags & 0x80) >> 7;
}
unsigned char MSIMysticLightController::BitSet(unsigned char value, bool bit, unsigned int position)
unsigned char MSIMysticLightController::BitSet
(
unsigned char value,
bool bit,
unsigned int position
)
{
return static_cast<unsigned char>(std::bitset<8>(value).set(position, bit).to_ulong());
}
void MSIMysticLightController::SetCycleCount(ZONE zone, unsigned char cycle_num)
void MSIMysticLightController::SetCycleCount
(
MSI_ZONE zone,
unsigned char cycle_num
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -355,7 +523,10 @@ void MSIMysticLightController::SetCycleCount(ZONE zone, unsigned char cycle_num)
requestedZone->cycle_or_led_num = cycle_num;
}
unsigned char MSIMysticLightController::GetCycleCount(ZONE zone)
unsigned char MSIMysticLightController::GetCycleCount
(
MSI_ZONE zone
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -367,28 +538,43 @@ unsigned char MSIMysticLightController::GetCycleCount(ZONE zone)
return requestedZone->cycle_or_led_num;
}
void MSIMysticLightController::GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1,
bool &combine_JPIPE2, bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2, bool &combine_crossair)
void MSIMysticLightController::GetBoardSyncSettings
(
bool &onboard_sync,
bool &combine_JRGB,
bool &combine_JPIPE1,
bool &combine_JPIPE2,
bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2,
bool &combine_crossair
)
{
ZoneData &syncZone = data.on_board_led;
onboard_sync = syncZone.colorFlags & 1u;
combine_JRAINBOW1 = syncZone.colorFlags >> 1u & 1u;
combine_JRAINBOW2 = syncZone.colorFlags >> 1u & 1u;
combine_crossair = syncZone.colorFlags >> 3u & 1u;
combine_JPIPE1 = syncZone.colorFlags >> 4u & 1u;
combine_JPIPE2 = syncZone.colorFlags >> 5u & 1u;
combine_JRGB = (syncZone.speedAndBrightnessFlags & 128u) >> 7u;
/*-----------------------------------------------------*\
| Get sync flags for on-board LED zone |
\*-----------------------------------------------------*/
onboard_sync = (syncZone.colorFlags >> 0) & 0x01;
combine_JRAINBOW1 = (syncZone.colorFlags >> 1) & 0x01;
combine_JRAINBOW2 = (syncZone.colorFlags >> 2) & 0x01;
combine_crossair = (syncZone.colorFlags >> 3) & 0x01;
combine_JPIPE1 = (syncZone.colorFlags >> 4) & 0x01;
combine_JPIPE2 = (syncZone.colorFlags >> 5) & 0x01;
combine_JRGB = (syncZone.speedAndBrightnessFlags & 0x80) >> 7;
}
void MSIMysticLightController::GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual)
void MSIMysticLightController::GetDeviceSettings
(
bool &stripe_or_fan,
MSI_FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual
)
{
CorsairZoneData &settingsZone = data.j_corsair;
stripe_or_fan = settingsZone.fan_flags & 1u;
fan_type = static_cast<FAN_TYPE >((settingsZone.fan_flags & 14u) >> 1u);
corsair_device_quantity = (settingsZone.corsair_quantity & 252u) >> 2u;
is_LL120Outer_individual = settingsZone.is_individual & 1u;
CorsairZoneData &settingsZone = data.j_corsair;
stripe_or_fan = settingsZone.fan_flags & 0x01;
fan_type = (MSI_FAN_TYPE )((settingsZone.fan_flags & 14u) >> 1);
corsair_device_quantity = (settingsZone.corsair_quantity & 0xFC) >> 2;
is_LL120Outer_individual = settingsZone.is_individual & 0x01;
}
@@ -14,105 +14,105 @@
#pragma once
enum ZONE
enum MSI_ZONE
{
J_RGB_1 = 1,
J_RGB_2 = 174,
J_PIPE_1 = 11,
J_PIPE_2 = 21,
J_RAINBOW_1 = 31,
J_RAINBOW_2 = 42,
J_CORSAIR = 53,
J_CORSAIR_OUTERLL120 = 64,
ON_BOARD_LED = 74,
ON_BOARD_LED_1 = 84,
ON_BOARD_LED_2 = 94,
ON_BOARD_LED_3 = 104,
ON_BOARD_LED_4 = 114,
ON_BOARD_LED_5 = 124,
ON_BOARD_LED_6 = 134,
ON_BOARD_LED_7 = 144,
ON_BOARD_LED_8 = 154,
ON_BOARD_LED_9 = 164
MSI_ZONE_J_RGB_1 = 1,
MSI_ZONE_J_RGB_2 = 174,
MSI_ZONE_J_PIPE_1 = 11,
MSI_ZONE_J_PIPE_2 = 21,
MSI_ZONE_J_RAINBOW_1 = 31,
MSI_ZONE_J_RAINBOW_2 = 42,
MSI_ZONE_J_CORSAIR = 53,
MSI_ZONE_J_CORSAIR_OUTERLL120 = 64,
MSI_ZONE_ON_BOARD_LED = 74,
MSI_ZONE_ON_BOARD_LED_1 = 84,
MSI_ZONE_ON_BOARD_LED_2 = 94,
MSI_ZONE_ON_BOARD_LED_3 = 104,
MSI_ZONE_ON_BOARD_LED_4 = 114,
MSI_ZONE_ON_BOARD_LED_5 = 124,
MSI_ZONE_ON_BOARD_LED_6 = 134,
MSI_ZONE_ON_BOARD_LED_7 = 144,
MSI_ZONE_ON_BOARD_LED_8 = 154,
MSI_ZONE_ON_BOARD_LED_9 = 164
};
struct ZoneDescription
{
std::string name;
ZONE value;
MSI_ZONE value;
};
enum EFFECT
enum MSI_MODE
{
DISABLE,
STATIC,
BREATHING,
FLASHING,
DOUBLE_FLASHING,
LIGHTNING,
MSI_MARQUEE,
METEOR,
WATER_DROP,
MSI_RAINBOW,
POP,
RAP,
JAZZ,
PLAY,
MOVIE,
COLOR_RING,
PLANETARY,
DOUBLE_METEOR,
ENERGY,
BLINK,
CLOCK,
COLOR_PULSE,
COLOR_SHIFT,
COLOR_WAVE,
MARQUEE,
RAINBOW,
RAINBOW_WAVE,
VISOR,
JRAINBOW,
RAINBOW_FLASHING,
RAINBOW_DOUBLE_FLASHING,
RANDOM,
FAN_CONTROL,
DISABLE_2,
COLOR_RING_FLASHING,
COLOR_RING_DOUBLE_FLASHING,
STACK,
CORSAIR_QUE,
FIRE,
LAVA
MSI_MODE_DISABLE = 0,
MSI_MODE_STATIC = 1,
MSI_MODE_BREATHING = 2,
MSI_MODE_FLASHING = 3,
MSI_MODE_DOUBLE_FLASHING = 4,
MSI_MODE_LIGHTNING = 5,
MSI_MODE_MSI_MARQUEE = 6,
MSI_MODE_METEOR = 7,
MSI_MODE_WATER_DROP = 8,
MSI_MODE_MSI_RAINBOW = 9,
MSI_MODE_POP = 10,
MSI_MODE_RAP = 11,
MSI_MODE_JAZZ = 12,
MSI_MODE_PLAY = 13,
MSI_MODE_MOVIE = 14,
MSI_MODE_COLOR_RING = 15,
MSI_MODE_PLANETARY = 16,
MSI_MODE_DOUBLE_METEOR = 17,
MSI_MODE_ENERGY = 18,
MSI_MODE_BLINK = 19,
MSI_MODE_CLOCK = 20,
MSI_MODE_COLOR_PULSE = 21,
MSI_MODE_COLOR_SHIFT = 22,
MSI_MODE_COLOR_WAVE = 23,
MSI_MODE_MARQUEE = 24,
MSI_MODE_RAINBOW = 25,
MSI_MODE_RAINBOW_WAVE = 26,
MSI_MODE_VISOR = 27,
MSI_MODE_JRAINBOW = 28,
MSI_MODE_RAINBOW_FLASHING = 29,
MSI_MODE_RAINBOW_DOUBLE_FLASHING = 30,
MSI_MODE_RANDOM = 31,
MSI_MODE_FAN_CONTROL = 32,
MSI_MODE_DISABLE_2 = 33,
MSI_MODE_COLOR_RING_FLASHING = 34,
MSI_MODE_COLOR_RING_DOUBLE_FLASHING = 35,
MSI_MODE_STACK = 36,
MSI_MODE_CORSAIR_QUE = 37,
MSI_MODE_FIRE = 38,
MSI_MODE_LAVA = 39,
};
enum SPEED
enum MSI_SPEED
{
LOW,
MEDIUM,
HIGH
MSI_SPEED_LOW = 0,
MSI_SPEED_MEDIUM = 1,
MSI_SPEED_HIGH = 2,
};
enum FAN_TYPE
enum MSI_FAN_TYPE
{
SP,
HD,
LL
MSI_FAN_TYPE_SP = 0,
MSI_FAN_TYPE_HD = 1,
MSI_FAN_TYPE_LL = 2,
};
enum BRIGHTNESS
enum MSI_BRIGHTNESS
{
OFF,
LEVEL_10,
LEVEL_20,
LEVEL_30,
LEVEL_40,
LEVEL_50,
LEVEL_60,
LEVEL_70,
LEVEL_80,
LEVEL_90,
LEVEL_100
MSI_BRIGHTNESS_OFF = 0,
MSI_BRIGHTNESS_LEVEL_10 = 1,
MSI_BRIGHTNESS_LEVEL_20 = 2,
MSI_BRIGHTNESS_LEVEL_30 = 3,
MSI_BRIGHTNESS_LEVEL_40 = 4,
MSI_BRIGHTNESS_LEVEL_50 = 5,
MSI_BRIGHTNESS_LEVEL_60 = 6,
MSI_BRIGHTNESS_LEVEL_70 = 7,
MSI_BRIGHTNESS_LEVEL_80 = 8,
MSI_BRIGHTNESS_LEVEL_90 = 9,
MSI_BRIGHTNESS_LEVEL_100 = 10,
};
struct Color
@@ -124,54 +124,51 @@ struct Color
struct CorsairZoneData
{
unsigned char effect = EFFECT::STATIC;
Color color { std::numeric_limits<unsigned char>::max(), 0, 0 };
unsigned char fan_flags = 40;
unsigned char effect = MSI_MODE_STATIC;
Color color { 0, 0, 0 };
unsigned char fan_flags = 40;
unsigned char corsair_quantity;
unsigned char padding[3];
unsigned char is_individual = 0;
unsigned char is_individual = 0;
};
struct ZoneData
{
unsigned char effect = EFFECT::STATIC;
Color color { std::numeric_limits<unsigned char>::max(), 0u, 0u };
unsigned char speedAndBrightnessFlags = 40u;
Color color2 { 0, std::numeric_limits<unsigned char>::max(), 0u };
unsigned char colorFlags = 128u;
const unsigned char padding = 0u;
unsigned char effect = MSI_MODE_STATIC;
Color color { 0, 0, 0 };
unsigned char speedAndBrightnessFlags = 40;
Color color2 { 0, 0, 0 };
unsigned char colorFlags = 128;
const unsigned char padding = 0;
};
struct RainbowZoneData : ZoneData
{
unsigned char cycle_or_led_num = 20u;
unsigned char cycle_or_led_num = 20;
};
struct FeaturePacket
{
const unsigned char report_id = 82u; // Report ID
ZoneData j_rgb_1; // 1
ZoneData j_pipe_1; // 11
ZoneData j_pipe_2; // 21
RainbowZoneData j_rainbow_1; // 31
RainbowZoneData j_rainbow_2; // 42
CorsairZoneData j_corsair; // 53
ZoneData j_corsair_outerll120; // 64
ZoneData on_board_led; // 74
ZoneData on_board_led_1; // 84
ZoneData on_board_led_2; // 94
ZoneData on_board_led_3; // 104
ZoneData on_board_led_4; // 114
ZoneData on_board_led_5; // 124
ZoneData on_board_led_6; // 134
ZoneData on_board_led_7; // 144
ZoneData on_board_led_8; // 154
ZoneData on_board_led_9; // 164
ZoneData j_rgb_2; // 174
unsigned char save_data = 0u; // 184
const unsigned char report_id = 0x52; // Report ID
ZoneData j_rgb_1; // 1
ZoneData j_pipe_1; // 11
ZoneData j_pipe_2; // 21
RainbowZoneData j_rainbow_1; // 31
RainbowZoneData j_rainbow_2; // 42
CorsairZoneData j_corsair; // 53
ZoneData j_corsair_outerll120; // 64
ZoneData on_board_led; // 74
ZoneData on_board_led_1; // 84
ZoneData on_board_led_2; // 94
ZoneData on_board_led_3; // 104
ZoneData on_board_led_4; // 114
ZoneData on_board_led_5; // 124
ZoneData on_board_led_6; // 134
ZoneData on_board_led_7; // 144
ZoneData on_board_led_8; // 154
ZoneData on_board_led_9; // 164
ZoneData j_rgb_2; // 174
unsigned char save_data = 0; // 184
};
@@ -181,25 +178,116 @@ public:
MSIMysticLightController(hid_device* handle, const char *path);
~MSIMysticLightController();
unsigned int GetZoneMinLedCount(ZONE zone);
unsigned int GetZoneMaxLedCount(ZONE zone);
unsigned int GetZoneLedCount(ZONE zone);
void SetZoneLedCount(ZONE zone, unsigned int led_count);
unsigned int GetZoneMinLedCount
(
MSI_ZONE zone
);
unsigned int GetZoneMaxLedCount
(
MSI_ZONE zone
);
unsigned int GetZoneLedCount
(
MSI_ZONE zone
);
void SetZoneLedCount
(
MSI_ZONE zone,
unsigned int led_count
);
void SetMode
(
MSI_ZONE zone,
MSI_MODE mode,
MSI_SPEED speed,
MSI_BRIGHTNESS brightness,
bool rainbow_color
);
void GetMode
(
MSI_ZONE zone,
MSI_MODE &mode,
MSI_SPEED &speed,
MSI_BRIGHTNESS &brightness,
bool &rainbow_color
);
void SetZoneColor
(
MSI_ZONE zone,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetCycleCount
(
MSI_ZONE zone,
unsigned char cycle_num
);
unsigned char GetCycleCount
(
MSI_ZONE zone
);
void SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color);
void GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color);
void SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
void SetCycleCount(ZONE zone, unsigned char cycle_num);
unsigned char GetCycleCount(ZONE zone);
std::pair<Color, Color>
GetZoneColor(ZONE zone);
GetZoneColor(MSI_ZONE zone);
bool Update();
void SetDeviceSettings(bool stripe_or_fan, FAN_TYPE fan_type, unsigned char corsair_device_quantity, bool is_LL120Outer_individual);
void GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type, unsigned char &corsair_device_quantity, bool &is_LL120Outer_individual);
bool SetVolume(unsigned char main, unsigned char left, unsigned char right);
void SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1, bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2, bool combine_crossair);
void GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1, bool &combine_JPIPE2, bool &combine_JRAINBOW1, bool &combine_JRAINBOW2, bool &combine_crossair);
void SetDeviceSettings
(
bool stripe_or_fan,
MSI_FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual
);
void GetDeviceSettings
(
bool &stripe_or_fan,
MSI_FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual
);
bool SetVolume
(
unsigned char main,
unsigned char left,
unsigned char right
);
void SetBoardSyncSettings
(
bool onboard_sync,
bool combine_JRGB,
bool combine_JPIPE1,
bool combine_JPIPE2,
bool combine_JRAINBOW1,
bool combine_JRAINBOW2,
bool combine_crossair
);
void GetBoardSyncSettings
(
bool &onboard_sync,
bool &combine_JRGB,
bool &combine_JPIPE1,
bool &combine_JPIPE2,
bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2,
bool &combine_crossair
);
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -212,9 +300,9 @@ private:
bool ReadFwVersion();
void ReadSerial();
void ReadName();
ZoneData* GetZoneData(ZONE zone);
ZoneData* GetZoneData(MSI_ZONE zone);
RainbowZoneData*
GetRainbowZoneData(ZONE zone);
GetRainbowZoneData(MSI_ZONE zone);
static unsigned char BitSet(unsigned char value, bool bit, unsigned int position);
hid_device* dev;
@@ -11,12 +11,19 @@
#include <string>
#include <cstring>
NZXTHue2Controller::NZXTHue2Controller(hid_device* dev_handle)
NZXTHue2Controller::NZXTHue2Controller(hid_device* dev_handle, unsigned int rgb_channels, unsigned int fan_channels)
{
dev = dev_handle;
num_fan_channels = fan_channels;
num_rgb_channels = rgb_channels;
SendFirmwareRequest();
GetStripsOnChannel(HUE_2_CHANNEL_1);
UpdateDeviceList();
fan_cmd.resize(num_fan_channels);
fan_rpm.resize(num_fan_channels);
UpdateStatus();
}
NZXTHue2Controller::~NZXTHue2Controller()
@@ -24,39 +31,96 @@ NZXTHue2Controller::~NZXTHue2Controller()
}
unsigned char NZXTHue2Controller::GetFanCommand
(
unsigned char fan_channel
)
{
return(fan_cmd[fan_channel]);
}
unsigned short NZXTHue2Controller::GetFanRPM
(
unsigned char fan_channel
)
{
return(fan_rpm[fan_channel]);
}
unsigned int NZXTHue2Controller::GetNumFanChannels()
{
return(num_fan_channels);
}
unsigned int NZXTHue2Controller::GetNumRGBChannels()
{
return(num_rgb_channels);
}
std::string NZXTHue2Controller::GetFirmwareVersion()
{
return(firmware_version);
}
unsigned int NZXTHue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
void NZXTHue2Controller::SendFan
(
unsigned char port,
unsigned char mode,
unsigned char speed
)
{
unsigned int ret_val = 0;
unsigned char usb_buf[64];
unsigned char usb_buf[] =
{
0x20, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x62;
usb_buf[0x01] = 0x01;
usb_buf[0x02] = 1 << port;
usb_buf[port + 3] = speed;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
}
for(int chan = 0; chan < 4; chan++)
void NZXTHue2Controller::UpdateDeviceList()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Device Information Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x20;
usb_buf[0x01] = 0x03;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Receive packets until 0x21 0x03 is received |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x21) || (usb_buf[1] != 0x03) );
for(int chan = 0; chan < num_rgb_channels; chan++)
{
unsigned int start = 0x0F + (6 * chan);
unsigned int num_leds_on_channel = 0;
@@ -90,7 +154,43 @@ unsigned int NZXTHue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
}
channel_leds[chan] = num_leds_on_channel;
}
return(ret_val);
}
void NZXTHue2Controller::UpdateStatus()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
if(false)//num_fan_channels > 0)
{
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Read packet |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x67) || (usb_buf[1] != 0x02) );
/*-----------------------------------------------------*\
| Extract fan information |
\*-----------------------------------------------------*/
for(int fan_idx = 0; fan_idx < num_fan_channels; fan_idx++)
{
unsigned char cmd;
unsigned short rpm;
cmd = usb_buf[40 + fan_idx];
rpm = ( usb_buf[25 + (2 * fan_idx)] << 8 ) | usb_buf[24 + (2 * fan_idx)];
fan_cmd[fan_idx] = cmd;
fan_rpm[fan_idx] = rpm;
}
}
}
void NZXTHue2Controller::SetChannelEffect
@@ -195,7 +295,7 @@ void NZXTHue2Controller::SendApply
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendDirect
@@ -230,7 +330,7 @@ void NZXTHue2Controller::SendDirect
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendEffect
@@ -284,20 +384,34 @@ void NZXTHue2Controller::SendEffect
memcpy(&usb_buf[0x0A], color_data, color_count * 3);
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendFirmwareRequest()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Firmware Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x10;
usb_buf[0x01] = 0x01;
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Receive packets until 0x11 0x01 is received |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x11) || (usb_buf[1] != 0x01) );
snprintf(firmware_version, 16, "%u.%u.%u", usb_buf[0x11], usb_buf[0x12], usb_buf[0x13]);
}
@@ -54,14 +54,30 @@ enum
class NZXTHue2Controller
{
public:
NZXTHue2Controller(hid_device* dev_handle);
NZXTHue2Controller(hid_device* dev_handle, unsigned int rgb_channels, unsigned int fan_channels);
~NZXTHue2Controller();
std::string GetFirmwareVersion();
unsigned int GetStripsOnChannel
unsigned char GetFanCommand
(
unsigned int channel
unsigned char fan_channel
);
unsigned short GetFanRPM
(
unsigned char fan_channel
);
unsigned int GetNumFanChannels();
unsigned int GetNumRGBChannels();
void SendFan
(
unsigned char port,
unsigned char mode,
unsigned char speed
);
void SetChannelEffect
@@ -80,12 +96,22 @@ public:
RGBColor * colors,
unsigned int num_colors
);
void UpdateDeviceList();
void UpdateStatus();
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
private:
hid_device* dev;
std::vector<unsigned char> fan_cmd;
std::vector<unsigned short> fan_rpm;
char firmware_version[16];
unsigned int num_fan_channels;
unsigned int num_rgb_channels;
void SendApply
(
@@ -14,6 +14,8 @@ typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned int num_rgb_channels;
unsigned int num_fan_channels;
const char * name;
} nzxt_hue_2_device;
@@ -24,10 +26,10 @@ static const nzxt_hue_2_device device_list[] =
/*-----------------------------------------------------------------------------------------------------*\
| NZXT Hue 2 devices |
\*-----------------------------------------------------------------------------------------------------*/
{ NZXT_VID, NZXT_HUE_2_PID, "NZXT Hue 2" },
{ NZXT_VID, NZXT_HUE_2_AMBIENT_PID, "NZXT Hue 2 Ambient" },
{ NZXT_VID, NZXT_SMART_DEVICE_V2_PID, "NZXT Smart Device V2" },
{ NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID, "NZXT RGB & Fan Controller" },
{ NZXT_VID, NZXT_HUE_2_PID, 4, 0, "NZXT Hue 2" },
{ NZXT_VID, NZXT_HUE_2_AMBIENT_PID, 2, 0, "NZXT Hue 2 Ambient" },
{ NZXT_VID, NZXT_SMART_DEVICE_V2_PID, 2, 3, "NZXT Smart Device V2" },
{ NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID, 2, 3, "NZXT RGB & Fan Controller" },
};
/******************************************************************************************\
@@ -58,23 +60,19 @@ void DetectNZXTHue2Controllers(std::vector<RGBController*> &rgb_controllers)
&&(info->product_id == device_list[device_idx].usb_pid))
{
dev = hid_open_path(info->path);
break;
if( dev )
{
NZXTHue2Controller* controller = new NZXTHue2Controller(dev, device_list[device_idx].num_rgb_channels, device_list[device_idx].num_fan_channels);
RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
NZXTHue2Controller* controller = new NZXTHue2Controller(dev);
RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
} /* DetectNZXTHue2Controllers() */
@@ -50,9 +50,16 @@ std::string NZXTKrakenController::GetFirmwareVersion()
void NZXTKrakenController::UpdateStatus()
{
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
hid_read(dev, usb_buf, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Read packet |
\*-----------------------------------------------------*/
hid_read(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Extract cooler information |
@@ -83,14 +90,28 @@ void NZXTKrakenController::UpdateEffect
)
{
unsigned char color_data[9 * 3];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(color_data, 0, sizeof(color_data));
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
if(!colors.empty() && channel != NZXT_KRAKEN_CHANNEL_RING)
{
colors[0] = ToLogoColor(colors[0]);
}
/*-----------------------------------------------------*\
| Update color data |
\*-----------------------------------------------------*/
SetColor(colors, color_data);
/*-----------------------------------------------------*\
| Send update packet |
\*-----------------------------------------------------*/
SendEffect(channel, mode, direction, color_data, speed, false, seq);
}
@@ -106,7 +127,7 @@ void NZXTKrakenController::SendEffect
int size /* = 0 */
)
{
unsigned char usb_buf[65];
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -149,5 +170,5 @@ void NZXTKrakenController::SendEffect
/*-----------------------------------------------------*\
| Send effect |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, sizeof(usb_buf));
hid_write(dev, usb_buf, 64);
}
@@ -17,17 +17,35 @@
void DetectNZXTKrakenControllers(std::vector<RGBController*> &rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
hid_device* dev = hid_open(NZXT_KRAKEN_VID, NZXT_KRAKEN_PID, nullptr);
if( dev )
for(std::size_t device_idx = 0; device_idx < 1; device_idx++)
{
NZXTKrakenController* controller = new NZXTKrakenController(dev);
dev = NULL;
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
info = hid_enumerate(NZXT_KRAKEN_VID, NZXT_KRAKEN_PID);
rgb_controllers.push_back(rgb_controller);
//Look for NZXT Kraken devices
while(info)
{
if((info->vendor_id == NZXT_KRAKEN_VID)
&&(info->product_id == NZXT_KRAKEN_PID))
{
dev = hid_open_path(info->path);
if( dev )
{
NZXTKrakenController* controller = new NZXTKrakenController(dev);
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
}
@@ -86,17 +86,71 @@ bool PolychromeController::IsAsrLed()
return(asr_led);
}
void PolychromeController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
void PolychromeController::SetColorsAndSpeed(unsigned char red, unsigned char green, unsigned char blue, unsigned char speed)
{
unsigned char colors[3] = { red, green, blue };
unsigned char color_speed_pkt[4] = { red, green, blue, speed };
if (asr_led)
{
bus->i2c_smbus_write_block_data(dev, active_mode, 3, colors);
switch(active_mode)
{
/*-----------------------------------------------------*\
| These modes take 4 bytes in R/G/B/S order |
\*-----------------------------------------------------*/
case ASRLED_MODE_BREATHING:
case ASRLED_MODE_FLASHING:
case ASRLED_MODE_SPECTRUM_CYCLE:
bus->i2c_smbus_write_block_data(dev, active_mode, 4, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 3 bytes in R/G/B order |
\*-----------------------------------------------------*/
default:
case ASRLED_MODE_STATIC:
case ASRLED_MODE_MUSIC:
bus->i2c_smbus_write_block_data(dev, active_mode, 3, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 1 byte - speed |
\*-----------------------------------------------------*/
case ASRLED_MODE_RANDOM:
case ASRLED_MODE_WAVE:
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &speed);
break;
/*-----------------------------------------------------*\
| These modes take no bytes |
\*-----------------------------------------------------*/
case ASRLED_MODE_OFF:
break;
}
}
else
{
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
/*-----------------------------------------------------*\
| Polychrome firmware always writes color to fixed reg |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, color_speed_pkt);
switch(active_mode)
{
/*-----------------------------------------------------*\
| These modes don't take a speed |
\*-----------------------------------------------------*/
POLYCHROME_MODE_OFF:
POLYCHROME_MODE_STATIC:
break;
/*-----------------------------------------------------*\
| All other modes, write speed to active mode register |
\*-----------------------------------------------------*/
default:
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &speed);
break;
}
}
}
@@ -112,4 +166,4 @@ void PolychromeController::SetMode(unsigned char mode)
{
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_MODE, 1, &active_mode);
}
}
}
@@ -34,6 +34,13 @@ enum
ASRLED_MODE_WAVE = 0x18, /* Wave effect mode */
};
enum
{
ASRLED_SPEED_MIN = 0x05, /* Slowest speed */
ASRLED_SPEED_DEFAULT = 0x03, /* Default speed */
ASRLED_SPEED_MAX = 0x00, /* Fastest speed */
};
enum
{
POLYCHROME_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
@@ -61,6 +68,13 @@ enum
POLYCHROME_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
};
enum
{
POLYCHROME_SPEED_MIN = 0x05, /* Slowest speed */
POLYCHROME_SPEED_DEFAULT = 0x03, /* Default speed */
POLYCHROME_SPEED_MAX = 0x00, /* Fastest speed */
};
class PolychromeController
{
public:
@@ -71,7 +85,7 @@ public:
unsigned int GetLEDCount();
unsigned int GetMode();
bool IsAsrLed();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
void SetColorsAndSpeed(unsigned char red, unsigned char green, unsigned char blue, unsigned char speed);
void SetMode(unsigned char mode);
unsigned short GetFirmwareVersion();
@@ -30,23 +30,25 @@ void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
{
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
&&(info->interface_number == 2))
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -27,7 +27,7 @@ static LEDCount LedCountToEnum(unsigned int c)
return(LEDS_1024);
}
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path) : dev(handle)
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name) : dev(handle)
{
int res = 0;
char text[64] {};
@@ -46,8 +46,9 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
{
report = *reinterpret_cast<IT8297Report*>(buffer);
name = std::string(report.str_product, 32);
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
name = mb_name;
description = std::string(report.str_product, 32);
description.erase(std::find(name.begin(), name.end(), '\0'), name.end());
snprintf(text, 11, "0x%08X", report.fw_ver);
version = text;
@@ -135,6 +136,11 @@ std::string RGBFusion2USBController::GetDeviceName()
return(name);
}
std::string RGBFusion2USBController::GetDeviceDescription()
{
return(description);
}
std::string RGBFusion2USBController::GetFWVersion()
{
return(version);
@@ -157,7 +157,7 @@ struct IT8297Report
class RGBFusion2USBController
{
public:
RGBFusion2USBController(hid_device* handle, const char *path);
RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name);
~RGBFusion2USBController();
void SetStripColors
@@ -175,6 +175,7 @@ public:
bool DisableBuiltinEffect(int enable_bit, int mask);
void SetCalibration();
std::string GetDeviceName();
std::string GetDeviceDescription();
std::string GetDeviceLocation();
std::string GetFWVersion();
std::string GetSerial();
@@ -188,6 +189,7 @@ private:
int mode;
IT8297Report report;
std::string name;
std::string description;
std::string loc;
std::string version;
std::string chip_id;
@@ -1,8 +1,17 @@
#include "RGBFusion2USBController.h"
#include "RGBController_RGBFusion2USB.h"
#include "dependencies/dmiinfo.h"
#define IT8297_VID 0x048D
#define IT8297_PID 0x8297
#define IT8297_VID 0x048D
#define IT8297_IFC 0
#define IT8297_UPG 0xFF89
#define COUNT_RGBFUSION2_PIDS (sizeof(RGBFusion2_pids) / sizeof(RGBFusion2_pids[ 0 ]))
static const unsigned short RGBFusion2_pids[] =
{
0x8297, //PID for the ITE 8595 found on the X570
0x5702 //PID for the ITE 8595 found on the B550
};
/******************************************************************************************\
* *
@@ -14,24 +23,45 @@
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
DMIInfo MB_info;
unsigned short tmpPID;
if (hid_init() < 0)
return;
hid_device_info * device_list = hid_enumerate(IT8297_VID, IT8297_PID);
if (!device_list)
return;
hid_device_info * device = device_list;
while (device)
{
hid_device * dev = hid_open_path(device->path);
if (dev) {
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, device_list->path);
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
rgb_controllers.push_back(rgb_controller);
}
device = device->next;
return;
}
hid_free_enumeration(device_list);
for(int dev_idx = 0; dev_idx < COUNT_RGBFUSION2_PIDS; dev_idx++)
{
dev = NULL;
tmpPID = RGBFusion2_pids[dev_idx];
info = hid_enumerate(IT8297_VID, tmpPID);
while(info)
{
if((info->vendor_id == IT8297_VID)
&& (info->interface_number == IT8297_IFC)
#ifdef USE_HID_USAGE
&&(info->product_id == tmpPID)
&&(info->usage_page == IT8297_UPG))
#else
&&(info->product_id == tmpPID))
#endif
{
hid_device * dev = hid_open_path(info->path);
if (dev)
{
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard());
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
hid_free_enumeration(info);
}
@@ -10,6 +10,7 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_KEYBOARD_VID 0x0C45
#define REDRAGON_KEYBOARD_USAGE_PAGE 0xFF1C
#define REDRAGON_K550_PID 0x5204
#define REDRAGON_K552_PID 0x5104
#define REDRAGON_K556_PID 0x5004
@@ -20,6 +21,7 @@
| Mouse product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_MOUSE_VID 0x04D9
#define REDRAGON_MOUSE_USAGE_PAGE 0xFFA0
#define REDRAGON_M711_PID 0xFC30
#define REDRAGON_M715_PID 0xFC39
@@ -28,6 +30,7 @@ typedef struct
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
unsigned short usb_usage_page;
device_type type;
const char * name;
} redragon_device;
@@ -36,22 +39,22 @@ typedef struct
static const redragon_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
@@ -78,45 +81,46 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
//Look for Redragon RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == device_list[device_idx].usb_usage_page))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
if( dev )
{
switch(device_list[device_idx].type)
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
case DEVICE_TYPE_KEYBOARD:
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
info = info->next;
}
}
}
@@ -2,21 +2,6 @@
#include <cstring>
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
{
char* usb_pkt = new char[size + 1];
usb_pkt[0] = 0x00;
for(int i = 1; i < size + 1; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
hid_send_feature_report(dev, (unsigned char *)usb_pkt, size + 1);
delete usb_pkt;
}
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
{
dev = dev_handle;
@@ -103,7 +88,7 @@ void RedragonM711Controller::SendMouseApply()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}
void RedragonM711Controller::SendWritePacket
@@ -137,5 +122,5 @@ void RedragonM711Controller::SendWritePacket
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}
@@ -0,0 +1,117 @@
/*-----------------------------------------*\
| SteelSeriesApexController.cpp |
| |
| Driver for SteelSeries Apex 7 RGB |
| Keyboard lighting controller |
| |
| Eric Samuelson (edbgon) 7/5/2020 |
\*-----------------------------------------*/
#include "SteelSeriesApexController.h"
#include <cstring>
using namespace std::chrono_literals;
static unsigned int keys[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52,
0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xf0 };
SteelSeriesApexController::SteelSeriesApexController(hid_device* dev_handle)
{
dev = dev_handle;
}
SteelSeriesApexController::~SteelSeriesApexController()
{
}
void SteelSeriesApexController::SetMode
(
unsigned char mode,
std::vector<RGBColor> colors
)
{
unsigned char color_mode;
unsigned char mode_colors[9];
active_mode = mode;
memset(mode_colors, 0x00, sizeof(mode_colors));
}
void SteelSeriesApexController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char buf[642];
int num_keys = sizeof(keys)/sizeof(*keys);
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
buf[0x00] = APEX7_PACKET_ID_DIRECT;
buf[0x01] = num_keys;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0; i < num_keys; i++)
{
buf[(i*4)+2] = keys[i];
buf[(i*4)+3] = RGBGetRValue(colors[i]);
buf[(i*4)+4] = RGBGetGValue(colors[i]);
buf[(i*4)+5] = RGBGetBValue(colors[i]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 642);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void SteelSeriesApexController::SelectProfile
(
unsigned char profile
)
{
unsigned char buf[64];
/*-----------------------------------------------------*\
| Zero out buffer, set up first packet and send |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
buf[0x00] = 0x69;
hid_send_feature_report(dev, buf, 64);
/*-----------------------------------------------------*\
| Zero out buffer, set up second packet and send |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
buf[0x00] = 0x89;
buf[0x01] = profile;
hid_send_feature_report(dev, buf, 64);
/*-----------------------------------------------------*\
| Zero out buffer, set up third packet and send |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
buf[0x00] = 0x41;
hid_send_feature_report(dev, buf, 64);
}
@@ -0,0 +1,44 @@
/*-----------------------------------------*\
| SteelSeriesApexController.h |
| |
| Definitions and types for SteelSeries |
| Apex 7 Keyboard lighting controller |
| |
| Eric Samuelson (edbgon) 7/5/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
APEX7_PACKET_ID_DIRECT = 0x3a, /* Direct mode */
};
class SteelSeriesApexController
{
public:
SteelSeriesApexController(hid_device* dev_handle);
~SteelSeriesApexController();
void SetMode
(
unsigned char mode,
std::vector<RGBColor> colors
);
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
hid_device* dev;
unsigned char active_mode;
void SelectProfile
(
unsigned char profile
);
};
@@ -1,9 +1,11 @@
#include "SteelSeriesRivalController.h"
#include "SteelSeriesSiberiaController.h"
#include "SteelSeriesApexController.h"
#include "SteelSeriesGeneric.h"
#include "RGBController.h"
#include "RGBController_SteelSeriesRival.h"
#include "RGBController_SteelSeriesSiberia.h"
#include "RGBController_SteelSeriesApex.h"
#include <vector>
#include <hidapi/hidapi.h>
@@ -18,7 +20,7 @@
#define STEELSERIES_RIVAL_100_DOTA_PID 0x170c
#define STEELSERIES_RIVAL_105_PID 0x1814
#define STEELSERIES_RIVAL_110_PID 0x1729
#define STEELSERIES_RIVAL_300_PID 0x1384
#define STEELSERIES_RIVAL_300_PID 0x1710
#define ACER_PREDATOR_RIVAL_300_PID 0x1714
#define STEELSERIES_RIVAL_300_CSGO_PID 0x1394
#define STEELSERIES_RIVAL_300_CSGO_STM32_PID 0x1716
@@ -30,6 +32,10 @@
| Headset product IDs |
\*-----------------------------------------------------*/
#define STEELSERIES_SIBERIA_350_PID 0x1229
/*-----------------------------------------------------*\
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define STEELSERIES_APEX_7_PID 0x1612
typedef struct
{
@@ -64,13 +70,17 @@ static const steelseries_device device_list[] =
| Headsets |
\*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{ STEELSERIES_VID, STEELSERIES_SIBERIA_350_PID, 3, DEVICE_TYPE_HEADSET, SIBERIA_350, "SteelSeries Siberia 350" },
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
{ STEELSERIES_VID, STEELSERIES_APEX_7_PID, 1, DEVICE_TYPE_KEYBOARD, APEX_7, "SteelSeries Apex 7" },
};
/******************************************************************************************\
* *
* DetectSteelSeriesControllers *
* *
* Tests the USB address to find a SteelSeries Rival Mouse or Headset *
* Tests the USB address to find a SteelSeries Rival Mouse, Headset or Keyboard *
* *
\******************************************************************************************/
@@ -108,7 +118,13 @@ void DetectSteelSeriesControllers(std::vector<RGBController*>& rgb_controllers)
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
/* Not yet supported */
{
SteelSeriesApexController* controller = new SteelSeriesApexController(dev);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_HEADSET:
@@ -20,5 +20,6 @@ typedef enum
RIVAL_100 = 0x00,
RIVAL_300 = 0x01,
SIBERIA_350 = 0x03,
APEX_7 = 0x04,
} steelseries_type;
@@ -52,7 +52,7 @@ void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed
void ThermaltakeRiingController::SendInit()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -62,14 +62,15 @@ void ThermaltakeRiingController::SendInit()
/*-----------------------------------------------------*\
| Set up Init packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xFE;
usb_buf[0x01] = 0x33;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xFE;
usb_buf[0x02] = 0x33;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 65);
}
void ThermaltakeRiingController::SendRGB
@@ -81,7 +82,7 @@ void ThermaltakeRiingController::SendRGB
unsigned char* color_data
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -91,19 +92,20 @@ void ThermaltakeRiingController::SendRGB
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x32;
usb_buf[0x01] = 0x52;
usb_buf[0x02] = port;
usb_buf[0x03] = mode + ( speed & 0x03 );
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x32;
usb_buf[0x02] = 0x52;
usb_buf[0x03] = port;
usb_buf[0x04] = mode + ( speed & 0x03 );
/*-----------------------------------------------------*\
| Copy in GRB color data |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], color_data, (num_colors * 3));
memcpy(&usb_buf[0x05], color_data, (num_colors * 3));
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 65);
}
+17 -5
View File
@@ -22,6 +22,7 @@
#ifdef __linux__
#include <unistd.h>
#include <sys/select.h>
#endif
using namespace std::chrono_literals;
@@ -32,6 +33,9 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
port_num = OPENRGB_SDK_PORT;
server_connected = false;
server_controller_count = 0;
ListenThread = NULL;
ConnectionThread = NULL;
}
void NetworkClient::ClientInfoChanged()
@@ -59,6 +63,11 @@ unsigned short NetworkClient::GetPort()
return port_num;
}
bool NetworkClient::GetConnected()
{
return(server_connected);
}
bool NetworkClient::GetOnline()
{
return(server_connected && server_initialized);
@@ -122,7 +131,8 @@ void NetworkClient::StopClient()
shutdown(client_sock, SD_RECEIVE);
closesocket(client_sock);
ListenThread->join();
if(ListenThread)
ListenThread->join();
ConnectionThread->join();
/*-------------------------------------------------*\
@@ -186,7 +196,7 @@ void NetworkClient::ConnectionThreadFunction()
//Wait for server controller count
while(server_controller_count == 0)
{
std::this_thread::sleep_for(100ms);
std::this_thread::sleep_for(5ms);
}
printf("Client: Received controller count from server: %d\r\n", server_controller_count);
@@ -196,12 +206,13 @@ void NetworkClient::ConnectionThreadFunction()
{
printf("Client: Requesting controller %d\r\n", requested_controllers);
controller_data_received = false;
SendRequest_ControllerData(requested_controllers);
//Wait until controller is received
while(server_controllers.size() == requested_controllers)
while(controller_data_received == false)
{
std::this_thread::sleep_for(100ms);
std::this_thread::sleep_for(5ms);
}
requested_controllers++;
@@ -247,7 +258,6 @@ int NetworkClient::recv_select(SOCKET s, char *buf, int len, int flags)
}
else if(rv == 0)
{
std::this_thread::sleep_for(100ms);
continue;
}
else
@@ -432,6 +442,8 @@ void NetworkClient::ProcessReply_ControllerData(unsigned int data_size, char * d
printf("Received controller: %s\r\n", new_controller->name.c_str());
server_controllers.push_back(new_controller);
controller_data_received = true;
}
void NetworkClient::SendData_ClientString()
+2
View File
@@ -24,6 +24,7 @@ public:
void ClientInfoChanged();
bool GetConnected();
const char * GetIP();
unsigned short GetPort();
bool GetOnline();
@@ -71,6 +72,7 @@ private:
char port_ip[20];
unsigned short port_num;
bool client_active;
bool controller_data_received;
bool server_connected;
bool server_initialized;
unsigned int server_controller_count;
+37 -14
View File
@@ -71,26 +71,42 @@ unsigned int NetworkServer::GetNumClients()
const char * NetworkServer::GetClientString(unsigned int client_num)
{
const char * result;
ServerClientsMutex.lock();
if(client_num < ServerClients.size())
{
return ServerClients[client_num]->client_string.c_str();
result = ServerClients[client_num]->client_string.c_str();
}
else
{
return "";
result = "";
}
ServerClientsMutex.unlock();
return result;
}
const char * NetworkServer::GetClientIP(unsigned int client_num)
{
const char * result;
ServerClientsMutex.lock();
if(client_num < ServerClients.size())
{
return ServerClients[client_num]->client_ip;
result = ServerClients[client_num]->client_ip;
}
else
{
return "";
result = "";
}
ServerClientsMutex.unlock();
return result;
}
void NetworkServer::RegisterClientInfoChangeCallback(NetServerCallback new_callback, void * new_callback_arg)
@@ -165,30 +181,26 @@ void NetworkServer::StartServer()
| Start the connection thread |
\*-------------------------------------------------*/
ConnectionThread = new std::thread(&NetworkServer::ConnectionThreadFunction, this);
ConnectionThread->detach();
}
void NetworkServer::StopServer()
{
server_online = false;
ServerClientsMutex.lock();
for(unsigned int client_idx = 0; client_idx < ServerClients.size(); client_idx++)
{
shutdown(ServerClients[client_idx]->client_sock, SD_RECEIVE);
closesocket(ServerClients[client_idx]->client_sock);
ServerClients[client_idx]->client_listen_thread->join();
delete ServerClients[client_idx];
}
shutdown(server_sock, SD_RECEIVE);
closesocket(server_sock);
ConnectionThread->join();
for(unsigned int client_idx = 0; client_idx < ServerClients.size(); client_idx++)
{
delete ServerClients[client_idx];
}
ServerClients.clear();
ServerClientsMutex.unlock();
/*-------------------------------------------------*\
| Client info has changed, call the callbacks |
@@ -248,10 +260,15 @@ void NetworkServer::ConnectionThreadFunction()
client_info->client_string = "Client";
/* We need to lock before the thread could possibly finish */
ServerClientsMutex.lock();
//Start a listener thread for the new client socket
client_info->client_listen_thread = new std::thread(&NetworkServer::ListenThreadFunction, this, client_info);
client_info->client_listen_thread->detach();
ServerClients.push_back(client_info);
ServerClientsMutex.unlock();
/*-------------------------------------------------*\
| Client info has changed, call the callbacks |
@@ -284,7 +301,6 @@ int NetworkServer::accept_select(int sockfd, struct sockaddr *addr, socklen_t *a
}
else if(rv == 0)
{
std::this_thread::sleep_for(100ms);
continue;
}
else
@@ -316,7 +332,6 @@ int NetworkServer::recv_select(SOCKET s, char *buf, int len, int flags)
}
else if(rv == 0)
{
std::this_thread::sleep_for(100ms);
continue;
}
else
@@ -538,15 +553,21 @@ listen_done:
shutdown(client_info->client_sock, SD_RECEIVE);
closesocket(client_info->client_sock);
ServerClientsMutex.lock();
for(unsigned int this_idx = 0; this_idx < ServerClients.size(); this_idx++)
{
if(ServerClients[this_idx] == client_info)
{
delete client_info->client_listen_thread;
delete client_info;
ServerClients.erase(ServerClients.begin() + this_idx);
break;
}
}
ServerClientsMutex.unlock();
/*-------------------------------------------------*\
| Client info has changed, call the callbacks |
\*-------------------------------------------------*/
@@ -555,6 +576,7 @@ listen_done:
void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data)
{
ServerClientsMutex.lock();
for(unsigned int this_idx = 0; this_idx < ServerClients.size(); this_idx++)
{
if(ServerClients[this_idx]->client_sock == client_sock)
@@ -563,6 +585,7 @@ void NetworkServer::ProcessRequest_ClientString(SOCKET client_sock, unsigned int
break;
}
}
ServerClientsMutex.unlock();
/*-------------------------------------------------*\
| Client info has changed, call the callbacks |
+1
View File
@@ -59,6 +59,7 @@ protected:
std::vector<RGBController *>& controllers;
std::mutex ServerClientsMutex;
std::vector<NetworkClientInfo *> ServerClients;
std::thread * ConnectionThread;
+100
View File
@@ -106,6 +106,11 @@ void DetectNvAPII2CBusses()
{
static NV_PHYSICAL_GPU_HANDLE gpu_handles[64];
static NV_S32 gpu_count = 0;
NV_U32 device_id;
NV_U32 ext_device_id;
NV_STATUS res;
NV_U32 revision_id;
NV_U32 sub_system_id;
NV_STATUS initialize = NvAPI_Initialize();
@@ -117,6 +122,17 @@ void DetectNvAPII2CBusses()
sprintf(nvapi_bus->device_name, "NVidia NvAPI I2C on GPU %d", gpu_idx);
res = NvAPI_GPU_GetPCIIdentifiers(gpu_handles[gpu_idx], &device_id, &sub_system_id, &revision_id, &ext_device_id);
if (res == 0)
{
nvapi_bus->pci_device = device_id >> 16;
nvapi_bus->pci_vendor = device_id & 0xffff;
nvapi_bus->pci_subsystem_device = sub_system_id >> 16;
nvapi_bus->pci_subsystem_vendor = sub_system_id & 0xffff;
nvapi_bus->port_id = 1;
}
busses.push_back(nvapi_bus);
}
} /* DetectNvAPII2CBusses() */
@@ -260,6 +276,11 @@ void DetectI2CBusses()
char driver_path[512];
struct dirent * ent;
int test_fd;
char path[1024];
char buff[100];
unsigned short pci_device, pci_vendor, pci_subsystem_device, pci_subsystem_vendor;
unsigned short port_id;
bool info;
// Start looking for I2C adapters in /sys/bus/i2c/devices/
strcpy(driver_path, "/sys/bus/i2c/devices/");
@@ -291,6 +312,74 @@ void DetectI2CBusses()
close(test_fd);
// For now, only get PCI information from nVidia GPUs
// PCI IDs are not currently obtained from the Nouveau driver
// and GPUs using PCI IDs for detection will not work with it.
if (sscanf(device_string, "NVIDIA i2c adapter %hu at", &port_id) == 1)
{
info = true;
// Get PCI Device
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/device");
test_fd = open(path, O_RDONLY);
if (test_fd < 0)
{
ent = readdir(dir);
continue;
}
memset(buff, 0x00, sizeof(buff));
read(test_fd, buff, sizeof(buff));
buff[strlen(buff) - 1] = 0x00;
pci_device = strtoul(buff, NULL, 16);
close(test_fd);
// Get PCI Vendor
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/vendor");
test_fd = open(path, O_RDONLY);
if (test_fd < 0)
{
ent = readdir(dir);
continue;
}
memset(buff, 0x00, sizeof(buff));
read(test_fd, buff, sizeof(buff));
buff[strlen(buff) - 1] = 0x00;
pci_vendor = strtoul(buff, NULL, 16);
close(test_fd);
// Get PCI Subsystem Device
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/subsystem_device");
test_fd = open(path, O_RDONLY);
if (test_fd < 0)
{
ent = readdir(dir);
continue;
}
memset(buff, 0x00, sizeof(buff));
read(test_fd, buff, sizeof(buff));
buff[strlen(buff) - 1] = 0x00;
pci_subsystem_device = strtoul(buff, NULL, 16);
close(test_fd);
// Get PCI Subsystem Vendor
snprintf(path, sizeof(path), "%s%s%s", driver_path, ent->d_name, "/device/subsystem_vendor");
test_fd = open(path, O_RDONLY);
if (test_fd < 0)
{
ent = readdir(dir);
continue;
}
memset(buff, 0x00, sizeof(buff));
read(test_fd, buff, sizeof(buff));
buff[strlen(buff) - 1] = 0x00;
pci_subsystem_vendor = strtoul(buff, NULL, 16);
close(test_fd);
}
else
{
info = false;
}
strcpy(device_string, "/dev/");
strcat(device_string, ent->d_name);
test_fd = open(device_string, O_RDWR);
@@ -304,6 +393,13 @@ void DetectI2CBusses()
bus = new i2c_smbus_linux();
strcpy(bus->device_name, device_string);
bus->handle = test_fd;
if (info) {
bus->pci_device = pci_device;
bus->pci_vendor = pci_vendor;
bus->pci_subsystem_device = pci_subsystem_device;
bus->pci_subsystem_vendor = pci_subsystem_vendor;
bus->port_id = port_id;
}
busses.push_back(bus);
}
}
@@ -327,6 +423,7 @@ void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusion2DRAMControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectMSIGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers);
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
void DetectAuraUSBControllers(std::vector<RGBController*> &rgb_controllers);
@@ -351,6 +448,7 @@ void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers);
void DetectNZXTKrakenControllers(std::vector<RGBController*>& rgb_controllers);
void DetectSteelSeriesControllers(std::vector<RGBController*>& rgb_controllers);
void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controllers);
void DetectDuckyKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
/******************************************************************************************\
* *
@@ -373,6 +471,7 @@ void DetectRGBControllers(void)
DetectPatriotViperControllers(busses, rgb_controllers);
DetectPolychromeControllers(busses, rgb_controllers);
DetectRGBFusionGPUControllers(busses, rgb_controllers);
DetectMSIGPUControllers(busses, rgb_controllers);
//TODO: Implement better detection before enabling these controllers
//DetectRGBFusion2SMBusControllers(busses, rgb_controllers);
@@ -402,6 +501,7 @@ void DetectRGBControllers(void)
DetectNZXTKrakenControllers(rgb_controllers);
DetectSteelSeriesControllers(rgb_controllers);
DetectGloriousModelOControllers(rgb_controllers);
DetectDuckyKeyboardControllers(rgb_controllers);
DetectE131Controllers(rgb_controllers);
+33 -3
View File
@@ -58,6 +58,7 @@ INCLUDEPATH += \
Controllers/CorsairVengeanceController/ \
Controllers/CorsairVengeanceProController/ \
Controllers/CrucialController/ \
Controllers/DuckyKeyboardController/ \
Controllers/GloriousModelOController/ \
Controllers/HuePlusController/ \
Controllers/HyperXDRAMController/ \
@@ -65,6 +66,7 @@ INCLUDEPATH += \
Controllers/LEDStripController/ \
Controllers/LogitechController/ \
Controllers/MSI3ZoneController/ \
Controllers/MSIGPUController/ \
Controllers/MSIMysticLightController/ \
Controllers/MSIRGBController/ \
Controllers/NZXTHue2Controller/ \
@@ -89,6 +91,7 @@ HEADERS += \
NetworkProtocol.h \
NetworkServer.h \
ProfileManager.h \
qt/OpenRGBClientInfoPage.h \
qt/OpenRGBDeviceInfoPage.h \
qt/OpenRGBDevicePage.h \
qt/OpenRGBDialog.h \
@@ -117,15 +120,18 @@ HEADERS += \
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h \
Controllers/CrucialController/CrucialController.h \
Controllers/DuckyKeyboardController/DuckyKeyboardController.h \
Controllers/GloriousModelOController/GloriousModelOController.h \
Controllers/HuePlusController/HuePlusController.h \
Controllers/HyperXDRAMController/HyperXDRAMController.h \
Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.h \
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
Controllers/LEDStripController/LEDStripController.h \
Controllers/LogitechController/LogitechG203Controller.h \
Controllers/LogitechController/LogitechG403Controller.h \
Controllers/LogitechController/LogitechG810Controller.h \
Controllers/MSI3ZoneController/MSI3ZoneController.h \
Controllers/MSIGPUController/MSIGPUController.h \
Controllers/MSIMysticLightController/MSIMysticLightController.h \
Controllers/MSIRGBController/MSIRGBController.h \
Controllers/NZXTHue2Controller/NZXTHue2Controller.h \
@@ -142,6 +148,7 @@ HEADERS += \
Controllers/RedragonController/RedragonM711Controller.h \
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
Controllers/SteelSeriesController/SteelSeriesApexController.h \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
@@ -155,10 +162,12 @@ HEADERS += \
RGBController/RGBController_CorsairVengeance.h \
RGBController/RGBController_CorsairVengeancePro.h \
RGBController/RGBController_Crucial.h \
RGBController/RGBController_DuckyKeyboard.h \
RGBController/RGBController_Dummy.h \
RGBController/RGBController_E131.h \
RGBController/RGBController_GloriousModelO.h \
RGBController/RGBController_HuePlus.h \
RGBController/RGBController_HyperXAlloyOrigins.h \
RGBController/RGBController_HyperXDRAM.h \
RGBController/RGBController_HyperXKeyboard.h \
RGBController/RGBController_LEDStrip.h \
@@ -166,6 +175,8 @@ HEADERS += \
RGBController/RGBController_LogitechG403.h \
RGBController/RGBController_LogitechG810.h \
RGBController/RGBController_MSI3Zone.h \
RGBController/RGBController_MSIGPU.h \
RGBController/RGBController_MSIGPU.h \
RGBController/RGBController_MSIMysticLight.h \
RGBController/RGBController_MSIRGB.h \
RGBController/RGBController_Network.h \
@@ -183,9 +194,11 @@ HEADERS += \
RGBController/RGBController_RGBFusionGPU.h \
RGBController/RGBController_SteelSeriesRival.h \
RGBController/RGBController_SteelSeriesSiberia.h \
RGBController/RGBController_SteelSeriesApex.h \
RGBController/RGBController_ThermaltakeRiing.h \
SOURCES += \
dependencies/dmiinfo.cpp \
dependencies/ColorWheel/ColorWheel.cpp \
dependencies/libe131/src/e131.c \
main.cpp \
@@ -194,6 +207,7 @@ SOURCES += \
NetworkClient.cpp \
NetworkServer.cpp \
ProfileManager.cpp \
qt/OpenRGBClientInfoPage.cpp \
qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \
qt/OpenRGBDialog.cpp \
@@ -233,12 +247,15 @@ SOURCES += \
Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp \
Controllers/CrucialController/CrucialController.cpp \
Controllers/CrucialController/CrucialControllerDetect.cpp \
Controllers/DuckyKeyboardController/DuckyKeyboardController.cpp \
Controllers/DuckyKeyboardController/DuckyKeyboardControllerDetect.cpp \
Controllers/GloriousModelOController/GloriousModelOController.cpp \
Controllers/GloriousModelOController/GloriousModelOControllerDetect.cpp \
Controllers/HuePlusController/HuePlusController.cpp \
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
Controllers/HyperXDRAMController/HyperXDRAMController.cpp \
Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp \
Controllers/HyperXKeyboardController/HyperXAlloyOriginsController.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \
Controllers/LEDStripController/LEDStripController.cpp \
@@ -249,6 +266,8 @@ SOURCES += \
Controllers/LogitechController/LogitechG810Controller.cpp \
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
Controllers/MSIGPUController/MSIGPUController.cpp \
Controllers/MSIGPUController/MSIGPUControllerDetect.cpp \
Controllers/MSIMysticLightController/MSIMysticLightController.cpp \
Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp \
Controllers/MSIRGBController/MSIRGBController.cpp \
@@ -278,6 +297,7 @@ SOURCES += \
Controllers/RedragonController/RedragonControllerDetect.cpp \
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
Controllers/SteelSeriesController/SteelSeriesApexController.cpp \
Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
@@ -294,9 +314,11 @@ SOURCES += \
RGBController/RGBController_CorsairVengeance.cpp \
RGBController/RGBController_CorsairVengeancePro.cpp \
RGBController/RGBController_Crucial.cpp \
RGBController/RGBController_DuckyKeyboard.cpp \
RGBController/RGBController_Dummy.cpp \
RGBController/RGBController_GloriousModelO.cpp \
RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperXAlloyOrigins.cpp \
RGBController/RGBController_HyperXDRAM.cpp \
RGBController/RGBController_HyperXKeyboard.cpp \
RGBController/RGBController_E131.cpp \
@@ -305,6 +327,7 @@ SOURCES += \
RGBController/RGBController_LogitechG403.cpp \
RGBController/RGBController_LogitechG810.cpp \
RGBController/RGBController_MSI3Zone.cpp \
RGBController/RGBController_MSIGPU.cpp \
RGBController/RGBController_MSIMysticLight.cpp \
RGBController/RGBController_MSIRGB.cpp \
RGBController/RGBController_Network.cpp \
@@ -322,12 +345,14 @@ SOURCES += \
RGBController/RGBController_RGBFusionGPU.cpp \
RGBController/RGBController_SteelSeriesRival.cpp \
RGBController/RGBController_SteelSeriesSiberia.cpp \
RGBController/RGBController_SteelSeriesApex.cpp \
RGBController/RGBController_ThermaltakeRiing.cpp \
RESOURCES += \
qt/resources.qrc
FORMS += \
FORMS += \
qt/OpenRGBClientInfoPage.ui \
qt/OpenRGBDeviceInfoPage.ui \
qt/OpenRGBDevicePage.ui \
qt/OpenRGBDialog.ui \
@@ -351,7 +376,7 @@ win32:INCLUDEPATH += \
wmi/ \
win32:SOURCES += \
dependencies/hidapi/hidapi.c \
# dependencies/hidapi/hidapi.c \
dependencies/NVFC/nvapi.cpp \
i2c_smbus/i2c_smbus_amdadl.cpp \
i2c_smbus/i2c_smbus_i801.cpp \
@@ -381,6 +406,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi \
}
win32:contains(QMAKE_TARGET.arch, x86) {
@@ -388,17 +414,19 @@ win32:contains(QMAKE_TARGET.arch, x86) {
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi \
}
win32:DEFINES -= \
UNICODE
win32:DEFINES += \
USE_HID_USAGE \
_MBCS \
WIN32 \
_CRT_SECURE_NO_WARNINGS \
_WINSOCK_DEPRECATED_NO_WARNINGS \
WIN32_LEAN_AND_MEAN
WIN32_LEAN_AND_MEAN \
win32:RC_ICONS += \
qt/OpenRGB.ico
@@ -427,6 +455,7 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/x64/inpoutx64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS64/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x64/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
@@ -437,6 +466,7 @@ win32:contains(QMAKE_TARGET.arch, x86) {
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/Win32/inpout32.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS32/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/hidapi-win/x86/hidapi.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
first.depends = $(first) copydata
export(first.depends)
+13 -46
View File
@@ -1,7 +1,17 @@
## ![OpenRGB](https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/uploads/5b7e633ac9f63b00c8a4c72686206c3f/OpenRGB.png) (formerly OpenAuraSDK)
One of the biggest complaints about RGB is the software ecosystem surrounding it. Every manufacturer has their own app, their own brand, their own style. If you want to mix and match devices, you end up with a ton of conflicting, functionally identical apps competing for your background resources. On top of that, these apps are proprietary and Windows-only. Some even require online accounts. What if there was a way to control all of your RGB devices from a single app, on both Windows and Linux, without any nonsense? That is what OpenRGB sets out to achieve. One app to rule them all.
OpenRGB is still in its early stages and already supports quite a few products. I'm always on the lookout for good deals on more popular RGB devices to add support for.
## Features
* Set colors and select effect modes for a wide variety of RGB hardware
* Save and load profiles
* Control lighting from third party software using the OpenRGB SDK
* Command line interface
* Connect multiple instances of OpenRGB to synchronize lighting across multiple PCs
* Can operate standalone or in a client/headless server configuration
* View device information
* No official/manufacturer software required
## Supported Devices
@@ -16,15 +26,13 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
![OpenRGB_0.11](https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/uploads/0ef8eb3936fe715217e7e3430c0aae18/OpenRGB_new_icons.PNG)
## Windows
* Pre-built binaries are available under the Releases section on GitLab.
* If you wish to build the application yourself:
1. Download the latest Visual Studio Community Edition and Qt Creator.
2. Open the OpenRGB.pro project in Qt Creator.
3. Use the MSVC compiler kit, either 32- or 64-bit, to build the application.
4. Run the project from Qt Creator. If you want to use your custom build standalone, download the latest matching Release package and replace the OpenRGB.exe in it with your new build.
* **You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
### USB Access
@@ -36,10 +44,9 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
- With "WinUSB" selected, click Install
## Linux
* Pre-built binaries are not currently available for Linux
* You can build the project using Qt Creator or on the command line.
1. Install build dependencies
- Debian: sudo apt install build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf
- Fedora: sudo dnf install git make automake gcc gcc-c++ qt-creator qt5-devel hidapi-devel libusb-devel
@@ -47,22 +54,15 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
3. cd OpenRGB
4. qmake OpenRGB.pro
5. make -j8
* Run the application with ./OpenRGB
### SMBus Access
* SMBus access is necessary for controlling RGB RAM and certain motherboard on-board LEDs.
* If you are not trying to use OpenRGB to control RGB RAM or motherboard LEDs, you may skip this section.
* ASUS and ASRock motherboards have their RGB controller on an SMBus interface that is not accessible by an unmodified Linux kernel (for now). I am working on getting patches submitted upstream, but for now you must patch your kernel with the provided OpenRGB.patch file.
* Allowing access to SMBus:
1. Load the i2c-dev module: `sudo modprobe i2c-dev`
2. Load the i2c driver for your chipset:
- Intel:
- `sudo modprobe i2c-i801`
@@ -70,13 +70,10 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
- AMD:
- `modprobe i2c-piix4`
- Unmodified kernel will have one interface, patched kernel will have two. The first at 0x0B00 and the second at 0x0B20. The 0x0B20 interface is for motherboard LEDs.
* Instructions on patching the kernel:
- https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/OpenRGB-Kernel-Patch
* Some Gigabyte/Aorus motherboards have an ACPI conflict with the SMBus controller.
- Add `acpi_enforce_resources=lax` to your kernel command line and reboot. The controller should now show up.
* You'll have to enable user access to your SMBus if you don't run as root.
- List all SMBus controllers: `sudo i2cdetect -l`
- Note the number for PIIX4, I801, and NCT6775 controllers.
@@ -85,9 +82,7 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
### USB Access
* USB devices require udev rules to access as a normal user.
* You can run OpenRGB as root to detect all USB devices.
* Udev rules are included in this repo:
- Copy the 60-openrgb.rules file to /etc/udev/rules.d/
- Reload rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`
@@ -97,37 +92,23 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
OpenRGB provides a network interface for controlling supported RGB devices from other software. These projects implement the OpenRGB SDK and provide additional ways for you to control your lighting setup.
* Keyboard Visualizer (by me): https://gitlab.com/CalcProgrammer1/KeyboardVisualizer
* OpenRGB Python Client (by bahorn): https://github.com/bahorn/OpenRGB-PyClient
* OpenRGB Python Client (by jath03): https://github.com/jath03/openrgb-python
* OpenRGB Node.js Client (by vlakreeh): https://github.com/vlakreeh/openrgb
* D-Bus Connector for OpenRGB (by Vinno97): https://github.com/Vinno97/OpenRGB-DBus-Connector
* OpenRGB E1.31 Receiver (by me): https://gitlab.com/CalcProgrammer1/OpenRGBE131Receiver
* OpenRGB.NET - C# OpenRGB Client (by diogotr7): https://github.com/diogotr7/OpenRGB.NET
## Projects Used
* InpOutx64: http://www.highrez.co.uk/downloads/inpout32/
* libusb: https://github.com/libusb/libusb
* hidapi: https://github.com/libusb/hidapi
* libe131: https://github.com/hhromic/libe131
* NVFC: https://github.com/graphitemaster/NVFC
* OpenRazer: https://github.com/openrazer/openrazer
* OpenRazer-Win32: https://github.com/CalcProgrammer1/openrazer-win32
* Qt-Plus (ColorWheel): https://github.com/liuyanghejerry/Qt-Plus
* AMD ADL Libraries: https://github.com/GPUOpen-LibrariesAndSDKs/display-library
## Projects Researched
@@ -135,31 +116,17 @@ OpenRGB provides a network interface for controlling supported RGB devices from
While no code from these projects directly made its way into OpenRGB, these projects have been invaluable resources for protocol information.
* ckb-next: https://github.com/ckb-next/ckb-next
* linux_thermaltake_riing: https://github.com/chestm007/linux_thermaltake_riing
* Aura Addressable Header Controller: https://gitlab.com/cneil02/aura-addressable-header-controller
* OpenPyAURA: https://gitlab.com/thelastguardian/openpyaura
* AsrLed: https://github.com/EUA/AsrLed
* asrock-leds: https://github.com/RattyDAVE/asrock-leds
* hue-plus: https://github.com/kusti8/hue-plus
* rogauracore: https://github.com/wroberts/rogauracore
* msi-rgb: https://github.com/nagisa/msi-rgb
* OpenCorsairLink: https://github.com/audiohacked/OpenCorsairLink
* msi-keyboard: https://github.com/bparker06/msi-keyboard
* rivalcfg: https://github.com/flozz/rivalcfg
* VRMTool: https://github.com/rbrune/VRMtool
* g810-led: https://github.com/MatMoul/g810-led
* liquidctl: https://github.com/jonasmalacofilho/liquidctl
-6
View File
@@ -1266,8 +1266,6 @@ void RGBController::SetLED(unsigned int led, RGBColor color)
if(led < colors.size())
{
colors[led] = color;
UpdateSingleLED(led);
}
}
@@ -1277,8 +1275,6 @@ void RGBController::SetAllLEDs(RGBColor color)
{
SetAllZoneLEDs(zone_idx, color);
}
UpdateLEDs();
}
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
@@ -1287,8 +1283,6 @@ void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
{
zones[zone].colors[color_idx] = color;
}
UpdateZoneLEDs(zone);
}
int RGBController::GetMode()
@@ -0,0 +1,112 @@
/*-----------------------------------------*\
| RGBController_DuckyKeyboard.cpp |
| |
| Generic RGB Interface for Ducky RGB |
| keyboard devices |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#include "RGBController_DuckyKeyboard.h"
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][23] =
{ { 0, NA, 12, 18, 24, 30, NA, 42, 48, 54, 60, NA, 66, 72, 78, 84, 90, 96, 102, NA, NA, NA, NA },
{ 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, NA, 67, 73, 85, NA, 91, 97, 103, NA, NA, NA, NA },
{ 2, NA, 8, 14, 20, 26, NA, 32, 38, 44, 50, 56, 62, 68, 74, 86, 92, 98, 104, NA, NA, NA, NA },
{ 3, NA, 9, 15, 21, 27, NA, 33, 39, 45, 51, 57, 63, 69, 87, NA, NA, NA, NA, NA, NA, NA, NA },
{ 4, NA, 16, 22, 28, 34, NA, 40, NA, 46, 52, 58, 64, 70, 82, NA, NA, 100, NA, NA, NA, NA, NA },
{ 5, 11, 17, NA, NA, NA, NA, 41, NA, NA, NA, NA, 65, 77, 83, 89, 95, 101, 107, NA, NA, NA, NA } };
RGBController_DuckyKeyboard::RGBController_DuckyKeyboard(DuckyKeyboardController* ducky_ptr)
{
ducky = ducky_ptr;
name = "Ducky Keyboard Device";
type = DEVICE_TYPE_KEYBOARD;
description = "Ducky Keyboard Device";
mode Custom;
Custom.name = "Custom";
Custom.value = 0xFFFF;
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Custom.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Custom);
SetupZones();
}
RGBController_DuckyKeyboard::~RGBController_DuckyKeyboard()
{
}
void RGBController_DuckyKeyboard::SetupZones()
{
zone new_zone;
new_zone.name = "Keyboard";
new_zone.type = ZONE_TYPE_MATRIX;
new_zone.leds_min = 155;
new_zone.leds_max = 155;
new_zone.leds_count = 155;
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
zones.push_back(new_zone);
for(int led_idx = 0; led_idx < 155; led_idx++)
{
led new_led;
new_led.name = "Keyboard LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_DuckyKeyboard::ResizeZone(int zone, int new_size)
{
}
void RGBController_DuckyKeyboard::DeviceUpdateLEDs()
{
unsigned char colordata[155*3];
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
{
colordata[(color_idx*3)+0] = RGBGetRValue(colors[color_idx]);
colordata[(color_idx*3)+1] = RGBGetGValue(colors[color_idx]);
colordata[(color_idx*3)+2] = RGBGetBValue(colors[color_idx]);
}
ducky->SendColors(colordata, sizeof(colordata));
}
void RGBController_DuckyKeyboard::UpdateZoneLEDs(int zone)
{
DeviceUpdateLEDs();
}
void RGBController_DuckyKeyboard::UpdateSingleLED(int led)
{
DeviceUpdateLEDs();
}
void RGBController_DuckyKeyboard::SetCustomMode()
{
}
void RGBController_DuckyKeyboard::UpdateMode()
{
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_DuckyKeyboard.h |
| |
| Generic RGB Interface for Ducky RGB |
| keyboard devices |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "DuckyKeyboardController.h"
class RGBController_DuckyKeyboard : public RGBController
{
public:
RGBController_DuckyKeyboard(DuckyKeyboardController* ducky_ptr);
~RGBController_DuckyKeyboard();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
DuckyKeyboardController* ducky;
};
@@ -0,0 +1,157 @@
/*-----------------------------------------*\
| RGBController_HyperXAlloyOrigins.cpp |
| |
| Generic RGB Interface for HyperX Alloy |
| Origins RGB Keyboard |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#include "RGBController_HyperXAlloyOrigins.h"
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
using namespace std::chrono_literals;
THREAD keepalive_thread(void *param)
{
RGBController_HyperXAlloyOrigins* controller = static_cast<RGBController_HyperXAlloyOrigins*>(param);
controller->KeepaliveThread();
THREADRETURN
}
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][23] =
{ { 0, NA, 12, 18, 24, 30, NA, 42, 48, 54, 60, NA, 66, 72, 78, 84, 90, 96, 102, NA, NA, NA, NA },
{ 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, NA, 67, 73, 85, NA, 91, 97, 103, NA, NA, NA, NA },
{ 2, NA, 8, 14, 20, 26, NA, 32, 38, 44, 50, 56, 62, 68, 74, 86, 92, 98, 104, NA, NA, NA, NA },
{ 3, NA, 9, 15, 21, 27, NA, 33, 39, 45, 51, 57, 63, 69, 87, NA, NA, NA, NA, NA, NA, NA, NA },
{ 4, NA, 16, 22, 28, 34, NA, 40, NA, 46, 52, 58, 64, 70, 82, NA, NA, 100, NA, NA, NA, NA, NA },
{ 5, 11, 17, NA, NA, NA, NA, 41, NA, NA, NA, NA, 65, 77, 83, 89, 95, 101, 107, NA, NA, NA, NA } };
RGBController_HyperXAlloyOrigins::RGBController_HyperXAlloyOrigins(HyperXAlloyOriginsController* hyperx_ptr)
{
hyperx = hyperx_ptr;
name = "HyperX Alloy Origins Keyboard Device";
type = DEVICE_TYPE_KEYBOARD;
description = "HyperX Alloy Origins Keyboard Device";
mode Custom;
Custom.name = "Custom";
Custom.value = 0xFFFF;
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Custom.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Custom);
SetupZones();
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
}
RGBController_HyperXAlloyOrigins::~RGBController_HyperXAlloyOrigins()
{
}
void RGBController_HyperXAlloyOrigins::SetupZones()
{
zone new_zone;
new_zone.name = "Keyboard";
new_zone.type = ZONE_TYPE_MATRIX;
new_zone.leds_min = 155;
new_zone.leds_max = 155;
new_zone.leds_count = 155;
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
zones.push_back(new_zone);
for(int led_idx = 0; led_idx < 155; led_idx++)
{
led new_led;
new_led.name = "Keyboard LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_HyperXAlloyOrigins::ResizeZone(int zone, int new_size)
{
}
void RGBController_HyperXAlloyOrigins::DeviceUpdateLEDs()
{
hyperx->SetLEDsDirect(colors);
}
void RGBController_HyperXAlloyOrigins::UpdateZoneLEDs(int zone)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOrigins::UpdateSingleLED(int led)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOrigins::SetCustomMode()
{
}
void RGBController_HyperXAlloyOrigins::UpdateMode()
{
}
void RGBController_HyperXAlloyOrigins::KeepaliveThread()
{
while(1)
{
if(active_mode == 0)
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
}
}
std::this_thread::sleep_for(10ms);;
}
}
@@ -0,0 +1,39 @@
/*-----------------------------------------*\
| RGBController_HyperXAlloyOrigins.h |
| |
| Generic RGB Interface for HyperX Alloy |
| Origins RGB Keyboard |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#pragma once
#include <chrono>
#include "RGBController.h"
#include "HyperXAlloyOriginsController.h"
class RGBController_HyperXAlloyOrigins : public RGBController
{
public:
RGBController_HyperXAlloyOrigins(HyperXAlloyOriginsController* hyperx_ptr);
~RGBController_HyperXAlloyOrigins();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
void KeepaliveThread();
private:
HyperXAlloyOriginsController* hyperx;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
};
@@ -317,7 +317,7 @@ void RGBController_HyperXKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_HyperXKeyboard::DeviceUpdateLEDs()
{
last_update_time = clock();
last_update_time = std::chrono::steady_clock::now();
if(active_mode == 0)
{
@@ -363,7 +363,7 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
{
if(active_mode == 0)
{
if((clock() - last_update_time) > 50)
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
}
+2 -2
View File
@@ -8,7 +8,7 @@
\*-----------------------------------------*/
#pragma once
#include <time.h>
#include <chrono>
#include "RGBController.h"
#include "HyperXKeyboardController.h"
@@ -35,5 +35,5 @@ public:
private:
HyperXKeyboardController* hyperx;
clock_t last_update_time;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
};
+322
View File
@@ -0,0 +1,322 @@
/*-----------------------------------------*\
| RGBController_MSIGPU.h |
| |
| Generic RGB Interface for MSI GPU |
| |
\*-----------------------------------------*/
#include "RGBController_MSIGPU.h"
static unsigned char brightness_values[] = { 0x14, 0x28, 0x3c, 0x50, 0x64 };
static unsigned char speed_values[] = { 0x04, 0x02, 0x01 };
int RGBController_MSIGPU::GetDeviceMode()
{
int dev_mode = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_MODE);
for(std::size_t mode = 0; mode < modes.size(); mode++)
{
if (modes[mode].value == dev_mode)
{
active_mode = mode;
break;
}
}
return(active_mode);
}
RGBController_MSIGPU::RGBController_MSIGPU(MSIGPUController * msi_gpu_ptr)
{
msi_gpu = msi_gpu_ptr;
name = msi_gpu->GetDeviceName();
type = DEVICE_TYPE_GPU;
description = "MSI RTX Gaming X Trio GPU Device";
version = "0.00.1";
location = msi_gpu->GetDeviceLocation();
mode Off;
Off.name = "Off";
Off.value = MSI_GPU_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = MSI_GPU_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Rainbow.speed_min = 0;
Rainbow.speed_max = 2;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Static;
Static.name = "Static";
Static.value = MSI_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Raindrop;
Raindrop.name = "Raindrop";
Raindrop.value = MSI_GPU_MODE_RAINDROP;
Raindrop.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Raindrop.speed_min = 0;
Raindrop.speed_max = 2;
Raindrop.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Raindrop);
mode Magic;
Magic.name = "Magic";
Magic.value = MSI_GPU_MODE_MAGIC;
Magic.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Magic.speed_min = 0;
Magic.speed_max = 2;
Magic.color_mode = MODE_COLORS_NONE;
modes.push_back(Magic);
mode Patrolling;
Patrolling.name = "Patrolling";
Patrolling.value = MSI_GPU_MODE_PATROLLING;
Patrolling.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Patrolling.speed_min = 0;
Patrolling.speed_max = 2;
Patrolling.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Patrolling);
mode Streaming;
Streaming.name = "Streaming";
Streaming.value = MSI_GPU_MODE_STREAMING;
Streaming.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Streaming.speed_min = 0;
Streaming.speed_max = 2;
Streaming.color_mode = MODE_COLORS_NONE;
modes.push_back(Streaming);
mode Lightning;
Lightning.name = "Lightning";
Lightning.value = MSI_GPU_MODE_LIGHTNING;
Lightning.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Lightning.speed_min = 0;
Lightning.speed_max = 2;
Lightning.color_mode = MODE_COLORS_NONE;
modes.push_back(Lightning);
mode Wave;
Wave.name = "Wave";
Wave.value = MSI_GPU_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Wave.speed_min = 0;
Wave.speed_max = 2;
Wave.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Wave);
mode Meteor;
Meteor.name = "Meteor";
Meteor.value = MSI_GPU_MODE_METEOR;
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Meteor.speed_min = 0;
Meteor.speed_max = 2;
Meteor.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Meteor);
mode Stack;
Stack.name = "Stack";
Stack.value = MSI_GPU_MODE_STACK;
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Stack.speed_min = 0;
Stack.speed_max = 2;
Stack.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Stack);
mode Rhythm;
Rhythm.name = "Rhythm";
Rhythm.value = MSI_GPU_MODE_RHYTHM;
Rhythm.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Rhythm.speed_min = 0;
Rhythm.speed_max = 2;
Rhythm.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Rhythm);
mode Flowing;
Flowing.name = "Flowing";
Flowing.value = MSI_GPU_MODE_FLOWING;
Flowing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Flowing.speed_min = 0;
Flowing.speed_max = 2;
Flowing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flowing);
mode Whirling;
Whirling.name = "Whirling";
Whirling.value = MSI_GPU_MODE_WHIRLING;
Whirling.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Whirling.speed_min = 0;
Whirling.speed_max = 2;
Whirling.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Whirling);
mode Twisting;
Twisting.name = "Twisting";
Twisting.value = MSI_GPU_MODE_TWISTING;
Twisting.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Twisting.speed_min = 0;
Twisting.speed_max = 2;
Twisting.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Twisting);
mode Laminating;
Laminating.name = "Laminating";
Laminating.value = MSI_GPU_MODE_LAMINATING;
Laminating.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Laminating.speed_min = 0;
Laminating.speed_max = 2;
Laminating.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Laminating);
mode Fadein;
Fadein.name = "Fadein";
Fadein.value = MSI_GPU_MODE_FADEIN;
Fadein.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Fadein.speed_min = 0;
Fadein.speed_max = 2;
Fadein.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Fadein);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = MSI_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = 0;
Breathing.speed_max = 2;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode flashing;
flashing.name = "Flashing";
flashing.value = MSI_GPU_MODE_FLASHING;
flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
flashing.speed_min = 0;
flashing.speed_max = 2;
flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(flashing);
mode doubleflashing;
doubleflashing.name = "Doubleflashing";
doubleflashing.value = MSI_GPU_MODE_DOUBLEFLASHING;
doubleflashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
doubleflashing.speed_min = 0;
doubleflashing.speed_max = 2;
doubleflashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(doubleflashing);
SetupZones();
active_mode = GetDeviceMode();
}
void RGBController_MSIGPU::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone msi_gpu_zone;
msi_gpu_zone.name = "GPU";
msi_gpu_zone.type = ZONE_TYPE_SINGLE;
msi_gpu_zone.leds_min = 1;
msi_gpu_zone.leds_max = 1;
msi_gpu_zone.leds_count = 3;
msi_gpu_zone.matrix_map = NULL;
zones.push_back(msi_gpu_zone);
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
led led1;
led1.name = "Color 1";
leds.push_back(led1);
led led2;
led2.name = "Color 2";
leds.push_back(led2);
led led3;
led3.name = "Color 3";
leds.push_back(led3);
SetupColors();
/*---------------------------------------------------------*\
| Initialize color |
\*---------------------------------------------------------*/
unsigned char r1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R1);
unsigned char g1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G1);
unsigned char b1 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B1);
unsigned char r2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R2);
unsigned char g2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G2);
unsigned char b2 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B2);
unsigned char r3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_R3);
unsigned char g3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_G3);
unsigned char b3 = msi_gpu->MSIGPURegisterRead(MSI_GPU_REG_B3);
colors[0] = ToRGBColor(r1, g1, b1);
colors[1] = ToRGBColor(r2, g2, b2);
colors[2] = ToRGBColor(r3, g3, b3);
}
void RGBController_MSIGPU::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_MSIGPU::DeviceUpdateLEDs()
{
if (modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
{
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_BRIGHTNESS, brightness_values[4]); // how to access brightness value?
}
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_SPEED, speed_values[modes[active_mode].speed]);
}
msi_gpu->MSIGPURegisterWrite(MSI_GPU_REG_UNKNOWN, 0x00);
if (modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR)
{
if (modes[active_mode].value == MSI_GPU_MODE_FADEIN)
{
msi_gpu->SetRGB2(RGBGetRValue(colors[1]), RGBGetGValue(colors[1]), RGBGetBValue(colors[1]));
msi_gpu->SetRGB3(RGBGetRValue(colors[2]), RGBGetGValue(colors[2]), RGBGetBValue(colors[2]));
}
else
{
msi_gpu->SetRGB1(RGBGetRValue(colors[0]), RGBGetGValue(colors[0]), RGBGetBValue(colors[0]));
}
}
msi_gpu->SetMode(modes[active_mode].value);
}
void RGBController_MSIGPU::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_MSIGPU::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_MSIGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_MSIGPU::UpdateMode()
{
DeviceUpdateLEDs();
}
+33
View File
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_MSIGPU.h |
| |
| Generic RGB Interface for MSI GPU |
| |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "MSIGPUController.h"
class RGBController_MSIGPU : public RGBController
{
public:
RGBController_MSIGPU(MSIGPUController* msi_gpu_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
MSIGPUController* msi_gpu;
int GetDeviceMode();
};
+75 -75
View File
@@ -12,24 +12,24 @@
static const std::array<ZoneDescription, 18> led_zones
{
ZoneDescription{"JRGB1", J_RGB_1},
ZoneDescription{"JRGB2", J_RGB_2},
ZoneDescription{"JRAINBOW1", J_RAINBOW_1},
ZoneDescription{"JRAINBOW2", J_RAINBOW_2},
ZoneDescription{"JPIPE1", J_PIPE_1},
ZoneDescription{"JPIPE2", J_PIPE_2},
ZoneDescription{"JCORSAIR", J_CORSAIR},
ZoneDescription{"JCORSAIR Outer", J_CORSAIR_OUTERLL120},
ZoneDescription{"OnboardLED", ON_BOARD_LED},
ZoneDescription{"OnboardLED1", ON_BOARD_LED_1},
ZoneDescription{"OnboardLED2", ON_BOARD_LED_2},
ZoneDescription{"OnboardLED3", ON_BOARD_LED_3},
ZoneDescription{"OnboardLED4", ON_BOARD_LED_4},
ZoneDescription{"OnboardLED5", ON_BOARD_LED_5},
ZoneDescription{"OnboardLED6", ON_BOARD_LED_6},
ZoneDescription{"OnboardLED7", ON_BOARD_LED_7},
ZoneDescription{"OnboardLED8", ON_BOARD_LED_8},
ZoneDescription{"OnboardLED9", ON_BOARD_LED_9},
ZoneDescription{"JRGB1", MSI_ZONE_J_RGB_1},
ZoneDescription{"JRGB2", MSI_ZONE_J_RGB_2},
ZoneDescription{"JRAINBOW1", MSI_ZONE_J_RAINBOW_1},
ZoneDescription{"JRAINBOW2", MSI_ZONE_J_RAINBOW_2},
ZoneDescription{"JPIPE1", MSI_ZONE_J_PIPE_1},
ZoneDescription{"JPIPE2", MSI_ZONE_J_PIPE_2},
ZoneDescription{"JCORSAIR", MSI_ZONE_J_CORSAIR},
ZoneDescription{"JCORSAIR Outer", MSI_ZONE_J_CORSAIR_OUTERLL120},
ZoneDescription{"Onboard LED 0", MSI_ZONE_ON_BOARD_LED},
ZoneDescription{"Onboard LED 1", MSI_ZONE_ON_BOARD_LED_1},
ZoneDescription{"Onboard LED 2", MSI_ZONE_ON_BOARD_LED_2},
ZoneDescription{"Onboard LED 3", MSI_ZONE_ON_BOARD_LED_3},
ZoneDescription{"Onboard LED 4", MSI_ZONE_ON_BOARD_LED_4},
ZoneDescription{"Onboard LED 5", MSI_ZONE_ON_BOARD_LED_5},
ZoneDescription{"Onboard LED 6", MSI_ZONE_ON_BOARD_LED_6},
ZoneDescription{"Onboard LED 7", MSI_ZONE_ON_BOARD_LED_7},
ZoneDescription{"Onboard LED 8", MSI_ZONE_ON_BOARD_LED_8},
ZoneDescription{"Onboard LED 9", MSI_ZONE_ON_BOARD_LED_9},
};
RGBController_MSIMysticLight::RGBController_MSIMysticLight(MSIMysticLightController* controller_ptr)
@@ -93,10 +93,10 @@ void RGBController_MSIMysticLight::SetupZones()
void RGBController_MSIMysticLight::ResizeZone(int zone, int new_size)
{
ZONE zon = ZoneFromPos(zone);
unsigned int max_count = controller->GetZoneMaxLedCount(zon),
min_count = controller->GetZoneMinLedCount(zon),
new_siz = new_size;
MSI_ZONE zon = ZoneFromPos(zone);
unsigned int max_count = controller->GetZoneMaxLedCount(zon);
unsigned int min_count = controller->GetZoneMinLedCount(zon);
unsigned int new_siz = new_size;
new_siz = std::min(std::max(new_siz, min_count), max_count); // std::clamp only from C++17
/// TODO: Update LED count
}
@@ -138,68 +138,68 @@ void RGBController_MSIMysticLight::SetupModes()
constexpr unsigned int RANDOM_ONLY = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_RANDOM_COLOR;
constexpr unsigned int COMMON = RANDOM_ONLY | MODE_FLAG_HAS_PER_LED_COLOR;
SetupMode("Static", STATIC, MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR);
SetupMode("Off", DISABLE, 0);
SetupMode("Breathing", BREATHING, COMMON);
SetupMode("Flashing", FLASHING, COMMON);
SetupMode("Double flashing", DOUBLE_FLASHING, COMMON);
SetupMode("Lightning", LIGHTNING, COMMON);
SetupMode("MSI Marquee", MSI_MARQUEE, COMMON);
SetupMode("Meteor", METEOR, COMMON);
SetupMode("Water drop", WATER_DROP, COMMON);
SetupMode("MSI Rainbow", MSI_RAINBOW, RANDOM_ONLY);
SetupMode("Pop", POP, COMMON);
SetupMode("Rap", RAP, COMMON);
SetupMode("Jazz", JAZZ, COMMON);
SetupMode("Play", PLAY, COMMON);
SetupMode("Movie", MOVIE, COMMON);
SetupMode("Color ring", COLOR_RING, COMMON);
SetupMode("Planetary", PLANETARY, COMMON);
SetupMode("Double meteor", DOUBLE_METEOR, COMMON);
SetupMode("Energy", ENERGY, COMMON);
SetupMode("Blink", BLINK, COMMON);
SetupMode("Clock", CLOCK, COMMON);
SetupMode("Color pulse", COLOR_PULSE, COMMON);
SetupMode("Color shift", COLOR_SHIFT, COMMON);
SetupMode("Color wave", COLOR_WAVE, COMMON);
SetupMode("Marquee", MARQUEE, COMMON);
SetupMode("Rainbow", RAINBOW, COMMON);
SetupMode("Rainbow wave", RAINBOW_WAVE, COMMON);
SetupMode("Visor", VISOR, COMMON);
SetupMode("JRainbow", JRAINBOW, COMMON);
SetupMode("Rainbow flashing", RAINBOW_FLASHING, COMMON);
SetupMode("Rainbow double flashing", RAINBOW_DOUBLE_FLASHING, COMMON);
SetupMode("Random", RANDOM, COMMON);
SetupMode("Fan control", FAN_CONTROL, COMMON);
SetupMode("Off 2", DISABLE_2, COMMON);
SetupMode("Color ring flashing", COLOR_RING_FLASHING, COMMON);
SetupMode("Color ring double flashing", COLOR_RING_DOUBLE_FLASHING, COMMON);
SetupMode("Stack", STACK, COMMON);
SetupMode("Corsair Que", CORSAIR_QUE, COMMON);
SetupMode("Fire", FIRE, COMMON);
SetupMode("Lava", LAVA, COMMON);
SetupMode("Static", MSI_MODE_STATIC, MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR);
SetupMode("Off", MSI_MODE_DISABLE, 0);
SetupMode("Breathing", MSI_MODE_BREATHING, COMMON);
SetupMode("Flashing", MSI_MODE_FLASHING, COMMON);
SetupMode("Double flashing", MSI_MODE_DOUBLE_FLASHING, COMMON);
SetupMode("Lightning", MSI_MODE_LIGHTNING, COMMON);
SetupMode("MSI Marquee", MSI_MODE_MSI_MARQUEE, COMMON);
SetupMode("Meteor", MSI_MODE_METEOR, COMMON);
SetupMode("Water drop", MSI_MODE_WATER_DROP, COMMON);
SetupMode("MSI Rainbow", MSI_MODE_MSI_RAINBOW, RANDOM_ONLY);
SetupMode("Pop", MSI_MODE_POP, COMMON);
SetupMode("Rap", MSI_MODE_RAP, COMMON);
SetupMode("Jazz", MSI_MODE_JAZZ, COMMON);
SetupMode("Play", MSI_MODE_PLAY, COMMON);
SetupMode("Movie", MSI_MODE_MOVIE, COMMON);
SetupMode("Color ring", MSI_MODE_COLOR_RING, COMMON);
SetupMode("Planetary", MSI_MODE_PLANETARY, COMMON);
SetupMode("Double meteor", MSI_MODE_DOUBLE_METEOR, COMMON);
SetupMode("Energy", MSI_MODE_ENERGY, COMMON);
SetupMode("Blink", MSI_MODE_BLINK, COMMON);
SetupMode("Clock", MSI_MODE_CLOCK, COMMON);
SetupMode("Color pulse", MSI_MODE_COLOR_PULSE, COMMON);
SetupMode("Color shift", MSI_MODE_COLOR_SHIFT, COMMON);
SetupMode("Color wave", MSI_MODE_COLOR_WAVE, COMMON);
SetupMode("Marquee", MSI_MODE_MARQUEE, COMMON);
SetupMode("Rainbow", MSI_MODE_RAINBOW, COMMON);
SetupMode("Rainbow wave", MSI_MODE_RAINBOW_WAVE, COMMON);
SetupMode("Visor", MSI_MODE_VISOR, COMMON);
SetupMode("JRainbow", MSI_MODE_JRAINBOW, COMMON);
SetupMode("Rainbow flashing", MSI_MODE_RAINBOW_FLASHING, COMMON);
SetupMode("Rainbow double flashing", MSI_MODE_RAINBOW_DOUBLE_FLASHING, COMMON);
SetupMode("Random", MSI_MODE_RANDOM, COMMON);
SetupMode("Fan control", MSI_MODE_FAN_CONTROL, COMMON);
SetupMode("Off 2", MSI_MODE_DISABLE_2, COMMON);
SetupMode("Color ring flashing", MSI_MODE_COLOR_RING_FLASHING, COMMON);
SetupMode("Color ring double flashing", MSI_MODE_COLOR_RING_DOUBLE_FLASHING, COMMON);
SetupMode("Stack", MSI_MODE_STACK, COMMON);
SetupMode("Corsair Que", MSI_MODE_CORSAIR_QUE, COMMON);
SetupMode("Fire", MSI_MODE_FIRE, COMMON);
SetupMode("Lava", MSI_MODE_LAVA, COMMON);
}
void RGBController_MSIMysticLight::UpdateLed(int zone, int led)
{
bool random = modes[active_mode].color_mode == MODE_COLORS_RANDOM;
unsigned char red = RGBGetRValue(zones[zone].colors[led]);
unsigned char grn = RGBGetGValue(zones[zone].colors[led]);
unsigned char blu = RGBGetBValue(zones[zone].colors[led]);
EFFECT mode = static_cast<EFFECT>(modes[active_mode].value);
SPEED speed = static_cast<SPEED>(modes[active_mode].speed);
ZONE zon = ZoneFromPos(zone);
bool random = modes[active_mode].color_mode == MODE_COLORS_RANDOM;
unsigned char red = RGBGetRValue(zones[zone].colors[led]);
unsigned char grn = RGBGetGValue(zones[zone].colors[led]);
unsigned char blu = RGBGetBValue(zones[zone].colors[led]);
MSI_MODE mode = (MSI_MODE)(modes[active_mode].value);
MSI_SPEED speed = (MSI_SPEED)(modes[active_mode].speed);
MSI_ZONE zon = ZoneFromPos(zone);
controller->SetMode(zon, mode, speed, BRIGHTNESS::LEVEL_100, random);
controller->SetMode(zon, mode, speed, MSI_BRIGHTNESS_LEVEL_100, random);
controller->SetZoneColor(zon, red, grn, blu, red, grn, blu);
}
ZONE RGBController_MSIMysticLight::ZoneFromPos(int zone)
MSI_ZONE RGBController_MSIMysticLight::ZoneFromPos(int zone)
{
return led_zones[zone].value;
}
void RGBController_MSIMysticLight::SetupMode(const char *name, EFFECT mod, unsigned int flags)
void RGBController_MSIMysticLight::SetupMode(const char *name, MSI_MODE mod, unsigned int flags)
{
mode Mode;
Mode.name = name;
@@ -216,9 +216,9 @@ void RGBController_MSIMysticLight::SetupMode(const char *name, EFFECT mod, unsig
if(flags & MODE_FLAG_HAS_SPEED)
{
Mode.speed = SPEED::MEDIUM;
Mode.speed_max = SPEED::HIGH;
Mode.speed_min = SPEED::LOW;
Mode.speed = MSI_SPEED_MEDIUM;
Mode.speed_max = MSI_SPEED_HIGH;
Mode.speed_min = MSI_SPEED_LOW;
}
modes.push_back(Mode);
+2 -2
View File
@@ -32,8 +32,8 @@ public:
private:
void SetupModes();
void UpdateLed(int zone, int led);
ZONE ZoneFromPos(int zone);
void SetupMode(const char *name, EFFECT mode, unsigned int flags);
MSI_ZONE ZoneFromPos(int zone);
void SetupMode(const char *name, MSI_MODE mode, unsigned int flags);
MSIMysticLightController* controller;
};
+1 -1
View File
@@ -135,7 +135,7 @@ void RGBController_NZXTHue2::SetupZones()
/*-------------------------------------------------*\
| Set up zones |
\*-------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < HUE_2_NUM_CHANNELS; zone_idx++)
for(unsigned int zone_idx = 0; zone_idx < hue2->GetNumRGBChannels(); zone_idx++)
{
zone* new_zone = new zone;
@@ -426,14 +426,61 @@ void RGBController_OpenRazer::UpdateMode()
break;
case RAZER_MODE_OFF:
razer_functions->matrix_effect_none->store(razer_device, NULL, update_value, 1);
if(razer_functions->matrix_effect_none)
{
razer_functions->matrix_effect_none->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->logo_matrix_effect_none)
{
razer_functions->logo_matrix_effect_none->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->scroll_matrix_effect_none)
{
razer_functions->scroll_matrix_effect_none->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->left_matrix_effect_none)
{
razer_functions->left_matrix_effect_none->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->right_matrix_effect_none)
{
razer_functions->right_matrix_effect_none->store(razer_device, NULL, update_value, 1);
}
break;
case RAZER_MODE_STATIC:
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
razer_functions->matrix_effect_static->store(razer_device, NULL, update_value, 3);
if(razer_functions->matrix_effect_static)
{
razer_functions->matrix_effect_static->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->logo_matrix_effect_static)
{
razer_functions->logo_matrix_effect_static->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->scroll_matrix_effect_static)
{
razer_functions->scroll_matrix_effect_static->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->left_matrix_effect_static)
{
razer_functions->left_matrix_effect_static->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->right_matrix_effect_static)
{
razer_functions->right_matrix_effect_static->store(razer_device, NULL, update_value, 3);
}
break;
case RAZER_MODE_BREATHING:
@@ -450,22 +497,114 @@ void RGBController_OpenRazer::UpdateMode()
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 6);
if(razer_functions->matrix_effect_breath)
{
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 6);
}
if(razer_functions->logo_matrix_effect_breath)
{
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
}
if(razer_functions->scroll_matrix_effect_breath)
{
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
}
if(razer_functions->left_matrix_effect_breath)
{
razer_functions->left_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
}
if(razer_functions->right_matrix_effect_breath)
{
razer_functions->right_matrix_effect_breath->store(razer_device, NULL, update_value, 6);
}
}
else
{
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 3);
if(razer_functions->matrix_effect_breath)
{
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->logo_matrix_effect_breath)
{
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->scroll_matrix_effect_breath)
{
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->left_matrix_effect_breath)
{
razer_functions->left_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
}
if(razer_functions->right_matrix_effect_breath)
{
razer_functions->right_matrix_effect_breath->store(razer_device, NULL, update_value, 3);
}
}
break;
case MODE_COLORS_RANDOM:
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 1);
if(razer_functions->matrix_effect_breath)
{
razer_functions->matrix_effect_breath->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->logo_matrix_effect_breath)
{
razer_functions->logo_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->scroll_matrix_effect_breath)
{
razer_functions->scroll_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->left_matrix_effect_breath)
{
razer_functions->left_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->right_matrix_effect_breath)
{
razer_functions->right_matrix_effect_breath->store(razer_device, NULL, update_value, 1);
}
break;
}
break;
case RAZER_MODE_SPECTRUM_CYCLE:
razer_functions->matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
if(razer_functions->matrix_effect_spectrum)
{
razer_functions->matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->logo_matrix_effect_spectrum)
{
razer_functions->logo_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->scroll_matrix_effect_spectrum)
{
razer_functions->scroll_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->left_matrix_effect_spectrum)
{
razer_functions->left_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->right_matrix_effect_spectrum)
{
razer_functions->right_matrix_effect_spectrum->store(razer_device, NULL, update_value, 1);
}
break;
case RAZER_MODE_WAVE:
@@ -479,11 +618,48 @@ void RGBController_OpenRazer::UpdateMode()
update_value[0] = '1';
break;
}
razer_functions->matrix_effect_wave->store(razer_device, NULL, update_value, 1);
if(razer_functions->matrix_effect_wave)
{
razer_functions->matrix_effect_wave->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->left_matrix_effect_wave)
{
razer_functions->left_matrix_effect_wave->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->right_matrix_effect_wave)
{
razer_functions->right_matrix_effect_wave->store(razer_device, NULL, update_value, 1);
}
break;
case RAZER_MODE_REACTIVE:
razer_functions->matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
if(razer_functions->matrix_effect_reactive)
{
razer_functions->matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->logo_matrix_effect_reactive)
{
razer_functions->logo_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->scroll_matrix_effect_reactive)
{
razer_functions->scroll_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->left_matrix_effect_reactive)
{
razer_functions->left_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
}
if(razer_functions->right_matrix_effect_reactive)
{
razer_functions->right_matrix_effect_reactive->store(razer_device, NULL, update_value, 1);
}
break;
}
+51 -1
View File
@@ -42,6 +42,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Breathing.name = "Breathing";
Breathing.value = ASRLED_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = ASRLED_SPEED_MIN;
Breathing.speed_max = ASRLED_SPEED_MAX;
Breathing.speed = ASRLED_SPEED_DEFAULT;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
@@ -49,6 +52,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Strobe.name = "Strobe";
Strobe.value = ASRLED_MODE_FLASHING;
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Strobe.speed_min = ASRLED_SPEED_MIN;
Strobe.speed_max = ASRLED_SPEED_MAX;
Strobe.speed = ASRLED_SPEED_DEFAULT;
Strobe.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Strobe);
@@ -56,6 +62,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = ASRLED_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
SpectrumCycle.speed_min = ASRLED_SPEED_MIN;
SpectrumCycle.speed_max = ASRLED_SPEED_MAX;
SpectrumCycle.speed = ASRLED_SPEED_DEFAULT;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
@@ -63,6 +72,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Random.name = "Random";
Random.value = ASRLED_MODE_RANDOM;
Random.flags = MODE_FLAG_HAS_SPEED;
Random.speed_min = ASRLED_SPEED_MIN;
Random.speed_max = ASRLED_SPEED_MAX;
Random.speed = ASRLED_SPEED_DEFAULT;
Random.color_mode = MODE_COLORS_NONE;
modes.push_back(Random);
@@ -77,6 +89,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Wave.name = "Wave";
Wave.value = ASRLED_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED;
Wave.speed_min = ASRLED_SPEED_MIN;
Wave.speed_max = ASRLED_SPEED_MAX;
Wave.speed = ASRLED_SPEED_DEFAULT;
Wave.color_mode = MODE_COLORS_NONE;
modes.push_back(Wave);
}
@@ -100,6 +115,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Breathing.name = "Breathing";
Breathing.value = POLYCHROME_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = POLYCHROME_SPEED_MIN;
Breathing.speed_max = POLYCHROME_SPEED_MAX;
Breathing.speed = POLYCHROME_SPEED_DEFAULT;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
@@ -107,6 +125,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Strobe.name = "Strobe";
Strobe.value = POLYCHROME_MODE_FLASHING;
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Strobe.speed_min = POLYCHROME_SPEED_MIN;
Strobe.speed_max = POLYCHROME_SPEED_MAX;
Strobe.speed = POLYCHROME_SPEED_DEFAULT;
Strobe.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Strobe);
@@ -114,6 +135,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = POLYCHROME_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
SpectrumCycle.speed_min = POLYCHROME_SPEED_MIN;
SpectrumCycle.speed_max = POLYCHROME_SPEED_MAX;
SpectrumCycle.speed = POLYCHROME_SPEED_DEFAULT;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
@@ -121,6 +145,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Random.name = "Random";
Random.value = POLYCHROME_MODE_RANDOM;
Random.flags = MODE_FLAG_HAS_SPEED;
Random.speed_min = POLYCHROME_SPEED_MIN;
Random.speed_max = POLYCHROME_SPEED_MAX;
Random.speed = POLYCHROME_SPEED_DEFAULT;
Random.color_mode = MODE_COLORS_NONE;
modes.push_back(Random);
@@ -128,6 +155,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Wave.name = "Wave";
Wave.value = POLYCHROME_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED;
Wave.speed_min = POLYCHROME_SPEED_MIN;
Wave.speed_max = POLYCHROME_SPEED_MAX;
Wave.speed = POLYCHROME_SPEED_DEFAULT;
Wave.color_mode = MODE_COLORS_NONE;
modes.push_back(Wave);
@@ -135,6 +165,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Spring.name = "Spring";
Spring.value = POLYCHROME_MODE_SPRING;
Spring.flags = MODE_FLAG_HAS_SPEED;
Spring.speed_min = POLYCHROME_SPEED_MIN;
Spring.speed_max = POLYCHROME_SPEED_MAX;
Spring.speed = POLYCHROME_SPEED_DEFAULT;
Spring.color_mode = MODE_COLORS_NONE;
modes.push_back(Spring);
@@ -142,6 +175,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Stack.name = "Stack";
Stack.value = POLYCHROME_MODE_STACK;
Stack.flags = MODE_FLAG_HAS_SPEED;
Stack.speed_min = POLYCHROME_SPEED_MIN;
Stack.speed_max = POLYCHROME_SPEED_MAX;
Stack.speed = POLYCHROME_SPEED_DEFAULT;
Stack.color_mode = MODE_COLORS_NONE;
modes.push_back(Stack);
@@ -149,6 +185,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Cram.name = "Cram";
Cram.value = POLYCHROME_MODE_CRAM;
Cram.flags = MODE_FLAG_HAS_SPEED;
Cram.speed_min = POLYCHROME_SPEED_MIN;
Cram.speed_max = POLYCHROME_SPEED_MAX;
Cram.speed = POLYCHROME_SPEED_DEFAULT;
Cram.color_mode = MODE_COLORS_NONE;
modes.push_back(Cram);
@@ -156,6 +195,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Scan.name = "Scan";
Scan.value = POLYCHROME_MODE_SCAN;
Scan.flags = MODE_FLAG_HAS_SPEED;
Scan.speed_min = POLYCHROME_SPEED_MIN;
Scan.speed_max = POLYCHROME_SPEED_MAX;
Scan.speed = POLYCHROME_SPEED_DEFAULT;
Scan.color_mode = MODE_COLORS_NONE;
modes.push_back(Scan);
@@ -170,6 +212,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Water.name = "Water";
Water.value = POLYCHROME_MODE_WATER;
Water.flags = MODE_FLAG_HAS_SPEED;
Water.speed_min = POLYCHROME_SPEED_MIN;
Water.speed_max = POLYCHROME_SPEED_MAX;
Water.speed = POLYCHROME_SPEED_DEFAULT;
Water.color_mode = MODE_COLORS_NONE;
modes.push_back(Water);
@@ -177,6 +222,9 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Rainbow.name = "Rainbow";
Rainbow.value = POLYCHROME_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = POLYCHROME_SPEED_MIN;
Rainbow.speed_max = POLYCHROME_SPEED_MAX;
Rainbow.speed = POLYCHROME_SPEED_DEFAULT;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
}
@@ -245,7 +293,7 @@ void RGBController_Polychrome::DeviceUpdateLEDs()
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
polychrome->SetColor(red, grn, blu);
polychrome->SetColorsAndSpeed(red, grn, blu, modes[active_mode].speed);
}
}
@@ -267,4 +315,6 @@ void RGBController_Polychrome::SetCustomMode()
void RGBController_Polychrome::UpdateMode()
{
polychrome->SetMode(modes[active_mode].value);
DeviceUpdateLEDs();
}
+132 -142
View File
@@ -11,63 +11,82 @@
#include <sstream>
#include <array>
enum
{
ZONE_MB,
ZONE_STRIP1,
ZONE_STRIP2,
};
static const std::array<const char *, 3> led_zones
{
"Motherboard",
"LED Strip 1", // WS2812(B) strips
"LED Strip 2",
};
static const KnownChannels known_channels
static const KnownLayout knownLayoutsLookup
{
{
"Generic",
"IT8297BX-GBX570", //Left as a catch all
{
{
{ "Led 1", 0x20 },
{ "Led 2", 0x21 },
{ "Led 3", 0x22 },
{ "Led 4", 0x23 },
{ "Led 5", 0x24 },
{ "Led 6", 0x25 },
{ "Led 7", 0x26 },
{ "Led 8", 0x27 },
"Motherboard",
{
{ "Led 1", 0x20, 1 },
{ "Led 2", 0x21, 1 },
{ "Led 3", 0x22, 1 },
{ "Led 4", 0x23, 1 },
{ "Led 5", 0x24, 1 },
{ "Led 6", 0x25, 1 },
{ "Led 7", 0x26, 1 },
{ "Led 8", 0x27, 1 },
}
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
"D_LED1 Bottom",
{
{ "LED Strip 1", HDR_D_LED1, 0 },
}
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
"D_LED2 Top",
{
{ "LED Strip 2", HDR_D_LED2, 0 },
}
}
}
},
{
"IT8297BX-GBX570",
"X570 AORUS PRO WIFI",
{
// Zone 0
{
{ "Back I/O", HDR_BACK_IO },
{ "CPU", HDR_CPU },
{ "PCIe", HDR_PCIE },
{ "LED 2", HDR_LED_2}, // Unique to WiFi models?
{ "LED C1/C2", HDR_LED_C1C2 }, // 12VGRB headers seem to be connected
"Motherboard",
{
{ "Back I/O", HDR_BACK_IO, 1 },
{ "CPU Header", HDR_CPU, 1 },
{ "Rear PCIe", HDR_PCIE, 1},
{ "LED C1/C2", HDR_LED_C1C2, 1 }, // 12VGRB headers seem to be connected
}
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
"D_LED1 Bottom",
{
{ "D_LED1 Bottom", HDR_D_LED1, 0 },
}
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
"D_LED2 Top",
{
{ "D_LED2 Top", HDR_D_LED2, 0 },
}
}
}
},
{
"X570 I AORUS PRO WIFI",
{
{
"Motherboard",
{
{ "LED Group0", HDR_BACK_IO, 1 },
{ "LED Group1", HDR_CPU, 1 },
{ "LED Group2", HDR_D_LED2, 1 },
{ "LED Group3", HDR_PCIE, 1 },
{ "LED C1/C2", HDR_LED_C1C2, 1 }, // 12VGRB headers seem to be connected
}
},
{
"D_LED1",
{
{ "D_LED1", HDR_D_LED1, 0 },
}
}
}
},
@@ -77,9 +96,9 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
{
controller = controller_ptr;
name = "RGB Fusion 2 Controller";
name = controller->GetDeviceName();
type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceName();
description = controller->GetDeviceDescription();
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
@@ -150,99 +169,87 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
Flashing.speed = 2;
modes.push_back(Flashing);
Init_Controller(); //Only processed on first run
SetupZones();
}
void RGBController_RGBFusion2USB::Init_Controller()
{
/*---------------------------------------------------------*\
| Look up channel map based on device name |
\*---------------------------------------------------------*/
if ( knownLayoutsLookup.count(controller->GetDeviceName()) ) //Quick way to get a boolean on find()
{
layout = knownLayoutsLookup.find(controller->GetDeviceName())->second;
}
else
{
layout = knownLayoutsLookup.find("IT8297BX-GBX570")->second;
}
zones.resize(layout.size());
int zone_idx = 0;
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); ++zl)
{
std::vector<LedPort> lp = zl->second;
int LED_count = 0; //We're going to count the leds in the zone
bool boolSingleLED = true; //If all the Ledport.count == 1 then the zone is ZONE_TYPE_SINGLE
for(int lp_idx = 0; lp_idx < lp.size(); lp_idx++)
{
int lp_count = lp[lp_idx].count;
boolSingleLED = boolSingleLED && (lp_count == 1); //Is this a single LED zone??
LED_count += lp_count;
}
zones[zone_idx].name = zl->first;
zones[zone_idx].leds_min = (boolSingleLED) ? LED_count : RGBFusion2_Digital_LEDS_Min;
zones[zone_idx].leds_max = (boolSingleLED) ? LED_count : RGBFusion2_Digital_LEDS_Max;
zones[zone_idx].leds_count = (boolSingleLED) ? LED_count : 0; //Digital LEDS will not be set yet
zones[zone_idx].type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
zones[zone_idx].matrix_map = NULL;
zone_idx++;
}
}
void RGBController_RGBFusion2USB::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
{
first_run = true;
}
/*---------------------------------------------------------*\
| Look up channel map based on device name |
\*---------------------------------------------------------*/
KnownChannels::const_iterator it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end())
{
it = known_channels.find("Generic");
}
/*---------------------------------------------------------*\
| Get number of motherboard LEDs and set addressable LED |
| count |
\*---------------------------------------------------------*/
size_t mb_led_cnt = it->second[0].size();
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(led_zones.size());
/*---------------------------------------------------------*\
/*---------------------------------------------------------*\ <----DEBUG
| Set up zones |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < led_zones.size(); zone_idx++)
int zone_idx = 0;
for(ZoneLeds::iterator zl = layout.begin(); zl != layout.end(); ++zl)
{
zones[zone_idx].name = led_zones[zone_idx];
zones[zone_idx].type = ZONE_TYPE_LINEAR;
zones[zone_idx].matrix_map = NULL;
/*---------------------------------------------------------*\
| Zone index 0 is motherboard LEDs and has fixed size |
\*---------------------------------------------------------*/
if(zone_idx == ZONE_MB)
{
zones[zone_idx].leds_min = mb_led_cnt;
zones[zone_idx].leds_max = mb_led_cnt;
zones[zone_idx].leds_count = mb_led_cnt;
}
else
{
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 1024;
if(first_run)
{
zones[zone_idx].leds_count = 0;
}
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
if (!boolSingleLED)
{
controller->SetLedCount(zones[zone_idx].leds_count);
controller->DisableBuiltinEffect(0, 0x3);
}
}
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
for(int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
{
led new_led;
if( it != known_channels.end() && zone_idx < it->second.size() && led_idx < it->second[zone_idx].size())
new_led.value = zl->second.at(lp_idx).header;
if(boolSingleLED)
{
new_led.name = it->second[zone_idx][led_idx].name;
new_led.name = zl->second.at(lp_idx).name;
}
else
{
new_led.name = zones[zone_idx].name + " LED ";
new_led.name.append(std::to_string(led_idx));
new_led.name = zl->second.at(lp_idx).name;
new_led.name.append(" LED " + std::to_string(lp_idx));
}
new_led.value = zone_idx;
leds.push_back(new_led);
}
zone_idx++;
}
SetupColors();
@@ -279,22 +286,10 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
int mode_value = (modes[active_mode].value);
KnownChannels::const_iterator it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end())
{
it = known_channels.find("Generic");
}
if (it == known_channels.end() || zone >= (int)it->second.size())
{
return;
}
/*---------------------------------------------------------*\
| Set motherboard LEDs |
\*---------------------------------------------------------*/
if(zone == ZONE_MB)
if(zones[zone].type == ZONE_TYPE_SINGLE)
{
unsigned char red = 0;
unsigned char grn = 0;
@@ -332,7 +327,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
/*---------------------------------------------------------*\
| Apply the mode and color to the zone |
\*---------------------------------------------------------*/
controller->SetLEDEffect(it->second[zone][led_idx].header, mode_value, modes[active_mode].speed, random, red, grn, blu);
controller->SetLEDEffect(zones[zone].leds[led_idx].value, mode_value, modes[active_mode].speed, random, red, grn, blu);
}
controller->ApplyEffect();
@@ -342,6 +337,8 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
else
{
unsigned char hdr = zones[zone].start_idx;
/*---------------------------------------------------------*\
| Direct mode |
\*---------------------------------------------------------*/
@@ -349,16 +346,6 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
{
if(zones[zone].leds_count > 0)
{
unsigned char hdr = 0;
if(zone == ZONE_STRIP1)
{
hdr = HDR_D_LED1_RGB;
}
else if(zone == ZONE_STRIP2)
{
hdr = HDR_D_LED2_RGB;
}
controller->DisableBuiltinEffect(1, zone == 1 ? 0x01 : 0x02);
controller->SetStripColors(hdr, zones[zone].colors, zones[zone].leds_count);
}
@@ -368,7 +355,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
\*---------------------------------------------------------*/
else
{
if(it->second[zone].size())
if(zones[zone].leds_count) //If the Digital zone has been resized i.e. > 0
{
unsigned char red = 0;
unsigned char grn = 0;
@@ -384,7 +371,7 @@ void RGBController_RGBFusion2USB::UpdateZoneLEDs(int zone)
blu = RGBGetBValue(modes[active_mode].colors[0]);
}
int hdr = it->second[zone].front().header;
//int hdr = it->second[zone].front().header;
/*---------------------------------------------------------*\
| Apply built-in effects to LED strips |
@@ -404,20 +391,17 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
\*---------------------------------------------------------*/
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
int mode_value = (modes[active_mode].value);
unsigned int zone_idx = leds[led].value;
unsigned int zone_idx = GetLED_Zone(led);
/*---------------------------------------------------------*\
| Set motherboard LEDs |
\*---------------------------------------------------------*/
if(zone_idx == ZONE_MB)
if(zones[zone_idx].type == ZONE_TYPE_SINGLE)
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
KnownChannels::const_iterator it = known_channels.find(controller->GetDeviceName());
/*---------------------------------------------------------*\
| Motherboard LEDs always use effect mode, so use static for|
| direct mode but get colors from zone |
@@ -440,13 +424,7 @@ void RGBController_RGBFusion2USB::UpdateSingleLED(int led)
blu = RGBGetBValue(modes[active_mode].colors[0]);
}
//LED lookup needs to be done after it's used as an index
if (it->second.size() > 0)
{
led = it->second[ZONE_MB][led].header;
}
controller->SetLEDEffect(led, mode_value, modes[active_mode].speed, random, red, grn, blu);
controller->SetLEDEffect(leds[led].value, mode_value, modes[active_mode].speed, random, red, grn, blu);
controller->ApplyEffect();
}
/*---------------------------------------------------------*\
@@ -462,3 +440,15 @@ void RGBController_RGBFusion2USB::UpdateMode()
{
DeviceUpdateLEDs();
}
int RGBController_RGBFusion2USB::GetLED_Zone(int led_idx)
{
//This may be more useful in the abstract RGBController.cpp
for(int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
int zone_start = zones[zone_idx].start_idx;
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
if( zone_start <= led_idx && zone_end >= led_idx)
return(zone_idx);
}
}
+12 -4
View File
@@ -13,14 +13,18 @@
#include <map>
#include <vector>
#define RGBFusion2_Digital_LEDS_Min 0;
#define RGBFusion2_Digital_LEDS_Max 1024;
struct LedPort
{
const char* name;
int header;
int count;
};
typedef std::vector< std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds > KnownChannels;
typedef std::map< std::string, std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds> KnownLayout;
class RGBController_RGBFusion2USB: public RGBController
{
@@ -39,6 +43,10 @@ public:
void UpdateMode();
private:
RGBFusion2USBController* controller;
IT8297Report report;
void Init_Controller();
int GetLED_Zone(int led_idx);
RGBFusion2USBController* controller;
IT8297Report report;
ZoneLeds layout;
};
@@ -0,0 +1,255 @@
/*-----------------------------------------*\
| RGBController_SteelSeriesApex.cpp |
| |
| Generic RGB Interface for SteelSeries |
| Apex 7 Keyboard |
| |
| Eric Samuelson (edbgon) 7/5/2020 |
\*-----------------------------------------*/
#include "RGBController_SteelSeriesApex.h"
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
using namespace std::chrono_literals;
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][23] = //TODO: Create proper matrix map
{ { 0, NA, 16, 30, 44, 54, NA, 65, 75, 84, 95, NA, 8, 23 , 38, 6 , 22, 36, 49, NA, NA, NA, NA },
{ 1, 17, 31, 45, 55, 66, 76, 85, 96, 9, 24, NA, 39, 7 , 37, NA , 60, 70, 80, 52, 63, 73, 82 },
{ 2, NA, 18, 32, 46, 56, NA, 67, 77, 86, 97, 10, 25, 40 , 90, 101, 50, 61, 71, 51, 62, 72, 93 },
{ 3, NA, 19, 33, 47, 57, NA, 68, 78, 87, 98, 11, 26, 41 , 28, 14 , NA, NA, NA, 92, 103, 53, NA },
{ 4, 20, 34, 48, 58, 69, NA, 79, NA, 88, 99, 12, 27, 42 , 81, NA , NA, 102, NA, 64, 74, 83, 104 },
{ 5, 21, 35, NA, NA, NA, NA, 59, NA, NA, NA, NA, 89, 100, 13, 91 , 15, 29, 43, 94, NA, 105, NA } };
static const char* zone_names[] =
{
"Keyboard"
};
static zone_type zone_types[] =
{
ZONE_TYPE_MATRIX
};
static const unsigned int zone_sizes[] =
{
105,
};
static const char *led_names[] =
{
"Key: A",
"Key: B",
"Key: C",
"Key: D",
"Key: E",
"Key: F",
"Key: G",
"Key: H",
"Key: I",
"Key: J",
"Key: K",
"Key: L",
"Key: M",
"Key: N",
"Key: O",
"Key: P",
"Key: Q",
"Key: R",
"Key: S",
"Key: T",
"Key: U",
"Key: V",
"Key: W",
"Key: X",
"Key: Y",
"Key: Z",
"Key: 1",
"Key: 2",
"Key: 3",
"Key: 4",
"Key: 5",
"Key: 6",
"Key: 7",
"Key: 8",
"Key: 9",
"Key: 0",
"Key: Enter",
"Key: Escape",
"Key: Backspace",
"Key: Tab",
"Key: Space",
"Key: +", // TODO: Find international name for this key
"Key: \\", // TODO: Find international name for this key
"Key: Å", // TODO: Find international name for this key
"Key: ¨", // TODO: Find international name for this key
"Key: '", // TODO: Find international name for this key
"Key: Ø", // TODO: Find international name for this key
"Key: Æ", // TODO: Find international name for this key
"Key: |", // TODO: Find international name for this key
"Key: ,",
"Key: .",
"Key: -",
"Key: Caps Lock",
"Key: F1",
"Key: F2",
"Key: F3",
"Key: F4",
"Key: F5",
"Key: F6",
"Key: F7",
"Key: F8",
"Key: F9",
"Key: F10",
"Key: F11",
"Key: F12",
"Key: Print Screen",
"Key: Scroll Lock",
"Key: Pause",
"Key: Insert",
"Key: Home",
"Key: Page Up",
"Key: Delete",
"Key: End",
"Key: Page Down",
"Key: Right Arrow",
"Key: Left Arrow",
"Key: Down Arrow",
"Key: Up Arrow",
"Key: Num Lock",
"Key: Number Pad /",
"Key: Number Pad *",
"Key: Number Pad -",
"Key: Number Pad +",
"Key: Number Pad Enter",
"Key: Number Pad 1",
"Key: Number Pad 2",
"Key: Number Pad 3",
"Key: Number Pad 4",
"Key: Number Pad 5",
"Key: Number Pad 6",
"Key: Number Pad 7",
"Key: Number Pad 8",
"Key: Number Pad 9",
"Key: Number Pad 0",
"Key: Number Pad .",
"Key: <", // TODO: Find international name for this
"Key: Left Control",
"Key: Left Shift",
"Key: Left Alt",
"Key: Left Super",
"Key: Right Control",
"Key: Right Shift",
"Key: Right Alt",
"Key: Right Super",
"Key: FN",
};
RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexController* steelseries_ptr)
{
steelseries = steelseries_ptr;
name = "SteelSeries Apex 7 RGB Keyboard";
type = DEVICE_TYPE_KEYBOARD;
description = "SteelSeries Apex 7 RGB Device";
mode Direct;
Direct.name = "Direct";
Direct.value = 0x00;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_SteelSeriesApex::~RGBController_SteelSeriesApex()
{
}
void RGBController_SteelSeriesApex::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{
zone new_zone;
new_zone.name = zone_names[zone_idx];
new_zone.type = zone_types[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_SteelSeriesApex::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesApex::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
steelseries->SetLEDsDirect(colors);
}
void RGBController_SteelSeriesApex::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesApex::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesApex::SetCustomMode()
{
active_mode = 0;
}
void RGBController_SteelSeriesApex::UpdateMode()
{
std::vector<RGBColor> temp_colors;
steelseries->SetMode(modes[active_mode].value, temp_colors);
}
@@ -0,0 +1,37 @@
/*-----------------------------------------*\
| RGBController_SteelSeriesApex.cpp |
| |
| Generic RGB Interface for SteelSeries |
| Apex 7 Keyboard |
| |
| Eric Samuelson (edbgon) 7/5/2020 |
\*-----------------------------------------*/
#pragma once
#include <chrono>
#include "RGBController.h"
#include "SteelSeriesApexController.h"
class RGBController_SteelSeriesApex : public RGBController
{
public:
RGBController_SteelSeriesApex(SteelSeriesApexController* steelseries_ptr);
~RGBController_SteelSeriesApex();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
SteelSeriesApexController* steelseries;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
};
+160 -62
View File
@@ -7,6 +7,7 @@
#include "ProfileManager.h"
#include "RGBController.h"
#include "i2c_smbus.h"
#include "NetworkClient.h"
#include "NetworkServer.h"
/*-------------------------------------------------------------*\
@@ -19,11 +20,18 @@
using namespace std::chrono_literals;
static std::vector<RGBController*> rgb_controllers;
static ProfileManager* profile_manager;
static NetworkServer* network_server;
static std::string profile_save_filename = "";
enum
{
RET_FLAG_PRINT_HELP = 1,
RET_FLAG_START_GUI = 2,
RET_FLAG_I2C_TOOLS = 4,
RET_FLAG_START_MINIMIZED = 8,
};
struct DeviceOptions
{
int device;
@@ -272,7 +280,7 @@ bool ParseColors(std::string colors_string, DeviceOptions *options)
return options->colors.size() > 0;
}
unsigned int ParseMode(DeviceOptions& options)
unsigned int ParseMode(DeviceOptions& options, std::vector<RGBController *> &rgb_controllers)
{
// no need to check if --mode wasn't passed
if (options.mode.size() == 0)
@@ -341,9 +349,11 @@ void OptionHelp()
help_text += "Usage: OpenRGB (--device [--mode] [--color])...\n";
help_text += "\n";
help_text += "Options:\n";
help_text += "--gui Shows the GUI. GUI also appears when not passing any parameters\n";
help_text += "--startminimized Starts the GUI minimized to tray. Implies --gui, even if not specified\n";
help_text += "--client [IP]:[Port] Starts an SDK client on the given IP:Port (assumes port 6742 if not specified)\n";
help_text += "--server Starts the SDK's server\n";
help_text += "--server-port Sets the SDK's server port. Default: 6742 (1024-65535)\n";
help_text += "--gui Shows the GUI, also appears when not passing any parameters\n";
help_text += "-l, --list-devices Lists every compatible device with their number\n";
help_text += "-d, --device [0-9] Selects device to apply colors and/or effect to, or applies to all devices if omitted\n";
help_text += " Can be specified multiple times with different modes and colors\n";
@@ -358,6 +368,9 @@ void OptionHelp()
help_text += "-v, --version Display version and software build information\n";
help_text += "-p, --profile filename.orp Load the profile from filename.orp\n";
help_text += "-sp, --save-profile filename.orp Save the given settings to profile filename.orp\n";
help_text += "--i2c-tools Shows the I2C/SMBus Tools page in the GUI. Implies --gui, even if not specified.\n";
help_text += " USE I2C TOOLS AT YOUR OWN RISK! Don't use this option if you don't know what you're doing!\n";
help_text += " There is a risk of bricking your motherboard, RGB controller, and RAM if you send invalid SMBus/I2C transactions.\n";
std::cout << help_text << std::endl;
}
@@ -383,7 +396,7 @@ void OptionVersion()
std::cout << version_text << std::endl;
}
void OptionListDevices()
void OptionListDevices(std::vector<RGBController *> &rgb_controllers)
{
for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++)
{
@@ -484,7 +497,7 @@ void OptionListDevices()
}
}
bool OptionDevice(int *current_device, std::string argument, Options *options)
bool OptionDevice(int *current_device, std::string argument, Options *options, std::vector<RGBController *> &rgb_controllers)
{
try
{
@@ -514,7 +527,7 @@ bool OptionDevice(int *current_device, std::string argument, Options *options)
}
}
bool OptionZone(int *current_device, int *current_zone, std::string argument, Options *options)
bool OptionZone(int *current_device, int *current_zone, std::string argument, Options *options, std::vector<RGBController *> &rgb_controllers)
{
try
{
@@ -567,7 +580,7 @@ bool OptionMode(int *currentDev, std::string argument, Options *options)
return true;
}
bool OptionSize(int *current_device, int *current_zone, std::string argument, Options *options)
bool OptionSize(int *current_device, int *current_zone, std::string argument, Options *options, std::vector<RGBController *> &rgb_controllers)
{
const unsigned int new_size = std::stoi(argument);
@@ -602,7 +615,7 @@ bool OptionSize(int *current_device, int *current_zone, std::string argument, Op
return true;
}
bool OptionProfile(std::string argument)
bool OptionProfile(std::string argument, std::vector<RGBController *> &rgb_controllers)
{
/*---------------------------------------------------------*\
| Attempt to load profile |
@@ -643,7 +656,7 @@ bool OptionSaveProfile(std::string argument)
return(true);
}
int ProcessOptions(int argc, char *argv[], Options *options)
int ProcessOptions(int argc, char *argv[], Options *options, std::vector<NetworkClient*> &clients, std::vector<RGBController *> &rgb_controllers)
{
unsigned int ret_flags = 0;
int arg_index = 1;
@@ -663,15 +676,58 @@ int ProcessOptions(int argc, char *argv[], Options *options)
if(arg_index + 1 < argc)
{
argument = argv[arg_index + 1];
arg_index++;
}
/*---------------------------------------------------------*\
| --server |
\*---------------------------------------------------------*/
if(option == "--server")
if(option == "--client")
{
options->servOpts.start = true;
NetworkClient * client = new NetworkClient(rgb_controllers);
std::size_t pos = argument.find(":");
std::string ip = argument.substr(0, pos);
unsigned short port_val;
if(pos == -1)
{
port_val = OPENRGB_SDK_PORT;
}
else
{
std::string port = argument.substr(argument.find(":") + 1);
port_val = std::stoi(port);
}
std::string titleString = "OpenRGB ";
titleString.append(VERSION_STRING);
client->SetIP(ip.c_str());
client->SetName(titleString.c_str());
client->SetPort(port_val);
client->StartClient();
for(int timeout = 0; timeout < 100; timeout++)
{
if(client->GetConnected())
{
break;
}
std::this_thread::sleep_for(10ms);
}
clients.push_back(client);
arg_index++;
}
/*---------------------------------------------------------*\
| --server (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--server")
{
options->servOpts.start = true;
}
/*---------------------------------------------------------*\
@@ -689,36 +745,44 @@ int ProcessOptions(int argc, char *argv[], Options *options)
else
{
std::cout << "Error: port out of range: " << port << " (1024-65535)" << std::endl;
return 1;
return RET_FLAG_PRINT_HELP;
}
}
else
{
std::cout << "Error: Missing argument for --server-port" << std::endl;
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
| --gui |
| --gui (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--gui")
{
ret_flags |= 2;
ret_flags |= RET_FLAG_START_GUI;
}
/*---------------------------------------------------------*\
| --i2c-tools / --yolo |
| --i2c-tools / --yolo (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--i2c-tools" || option == "--yolo")
{
ret_flags |= 4;
ret_flags |= RET_FLAG_START_GUI | RET_FLAG_I2C_TOOLS;
}
/*---------------------------------------------------------*\
| -h / --help |
| --startminimized |
\*---------------------------------------------------------*/
else if(option == "--startminimized")
{
ret_flags |= RET_FLAG_START_GUI | RET_FLAG_START_MINIMIZED;
}
/*---------------------------------------------------------*\
| -h / --help (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--help" || option == "-h")
{
@@ -727,7 +791,7 @@ int ProcessOptions(int argc, char *argv[], Options *options)
}
/*---------------------------------------------------------*\
| -v / --version |
| -v / --version (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--version" || option == "-v")
{
@@ -736,11 +800,11 @@ int ProcessOptions(int argc, char *argv[], Options *options)
}
/*---------------------------------------------------------*\
| -l / --list-devices |
| -l / --list-devices (no arguments) |
\*---------------------------------------------------------*/
else if(option == "--list-devices" || option == "-l")
{
OptionListDevices();
OptionListDevices(rgb_controllers);
exit(0);
}
@@ -749,10 +813,12 @@ int ProcessOptions(int argc, char *argv[], Options *options)
\*---------------------------------------------------------*/
else if(option == "--device" || option == "-d")
{
if(!OptionDevice(&current_device, argument, options))
if(!OptionDevice(&current_device, argument, options, rgb_controllers))
{
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
@@ -760,10 +826,12 @@ int ProcessOptions(int argc, char *argv[], Options *options)
\*---------------------------------------------------------*/
else if(option == "--zone" || option == "-z")
{
if(!OptionZone(&current_device, &current_zone, argument, options))
if(!OptionZone(&current_device, &current_zone, argument, options, rgb_controllers))
{
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
@@ -773,8 +841,10 @@ int ProcessOptions(int argc, char *argv[], Options *options)
{
if(!OptionColor(&current_device, &current_zone, argument, options))
{
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
@@ -784,8 +854,10 @@ int ProcessOptions(int argc, char *argv[], Options *options)
{
if(!OptionMode(&current_device, argument, options))
{
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
@@ -793,10 +865,12 @@ int ProcessOptions(int argc, char *argv[], Options *options)
\*---------------------------------------------------------*/
else if(option == "--size" || option == "-s")
{
if(!OptionSize(&current_device, &current_zone, argument, options))
if(!OptionSize(&current_device, &current_zone, argument, options, rgb_controllers))
{
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
}
/*---------------------------------------------------------*\
@@ -804,8 +878,9 @@ int ProcessOptions(int argc, char *argv[], Options *options)
\*---------------------------------------------------------*/
else if(option == "--profile" || option == "-p")
{
OptionProfile(argument);
exit(0);
OptionProfile(argument, rgb_controllers);
arg_index++;
}
/*---------------------------------------------------------*\
@@ -814,6 +889,8 @@ int ProcessOptions(int argc, char *argv[], Options *options)
else if(option == "--save-profile" || option == "-sp")
{
OptionSaveProfile(argument);
arg_index++;
}
/*---------------------------------------------------------*\
@@ -822,7 +899,7 @@ int ProcessOptions(int argc, char *argv[], Options *options)
else
{
std::cout << "Error: Invalid option: " + option << std::endl;
return 1;
return RET_FLAG_PRINT_HELP;
}
arg_index++;
@@ -839,7 +916,7 @@ int ProcessOptions(int argc, char *argv[], Options *options)
if(!options->devices[option_idx].hasOption)
{
std::cout << "Error: Device " + std::to_string(option_idx) + " specified, but neither mode nor color given" << std::endl;
return 1;
return RET_FLAG_PRINT_HELP;
}
}
return 0;
@@ -850,7 +927,7 @@ int ProcessOptions(int argc, char *argv[], Options *options)
}
}
void ApplyOptions(DeviceOptions& options)
void ApplyOptions(DeviceOptions& options, std::vector<RGBController *> &rgb_controllers)
{
RGBController *device = rgb_controllers[options.device];
@@ -858,7 +935,7 @@ void ApplyOptions(DeviceOptions& options)
| Set mode first, in case it's 'direct' (which affects |
| SetLED below) |
\*---------------------------------------------------------*/
unsigned int mode = ParseMode(options);
unsigned int mode = ParseMode(options, rgb_controllers);
/*---------------------------------------------------------*\
| Determine which color mode this mode uses and update |
@@ -933,24 +1010,64 @@ void WaitWhileServerOnline(NetworkServer* srv)
};
}
unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> rgb_controllers_in, ProfileManager* profile_manager_in, NetworkServer* network_server_in)
unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> &rgb_controllers, ProfileManager* profile_manager_in, NetworkServer* network_server_in, std::vector<NetworkClient*> &clients)
{
rgb_controllers = rgb_controllers_in;
profile_manager = profile_manager_in;
network_server = network_server_in;
/*---------------------------------------------------------*\
| Windows only - Attach console output |
\*---------------------------------------------------------*/
#ifdef _WIN32
AttachConsole(-1);
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
#endif
/*---------------------------------------------------------*\
| Process the argument options |
\*---------------------------------------------------------*/
Options options;
unsigned int ret_flags = ProcessOptions(argc, argv, &options);
unsigned int ret_flags = ProcessOptions(argc, argv, &options, clients, rgb_controllers);
/*---------------------------------------------------------*\
| If the server was told to start, start it before returning|
\*---------------------------------------------------------*/
if(options.servOpts.start)
{
network_server->SetPort(options.servOpts.port);
network_server->StartServer();
if(network_server->GetOnline())
{
/*---------------------------------------------------------*\
| If the GUI has been started, return from cli_main. |
| Otherwise, we are in daemon mode and cli_main should wait |
| to keep the program alive as long as the server is online |
\*---------------------------------------------------------*/
if((ret_flags & RET_FLAG_START_GUI) == 0)
{
WaitWhileServerOnline(network_server);
}
}
else
{
std::cout << "Server failed to start" << std::endl;
exit(1);
}
}
/*---------------------------------------------------------*\
| If the return flags are set, exit CLI mode without |
| processing device updates from CLI input. |
\*---------------------------------------------------------*/
switch(ret_flags)
{
case 0:
break;
case 1:
case RET_FLAG_PRINT_HELP:
OptionHelp();
exit(-1);
break;
@@ -969,7 +1086,7 @@ unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> rgb_c
{
for(unsigned int device_idx = 0; device_idx < options.devices.size(); device_idx++)
{
ApplyOptions(options.devices[device_idx]);
ApplyOptions(options.devices[device_idx], rgb_controllers);
}
}
else
@@ -977,7 +1094,7 @@ unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> rgb_c
for (unsigned int device_idx = 0; device_idx < rgb_controllers.size(); device_idx++)
{
options.allDeviceOptions.device = device_idx;
ApplyOptions(options.allDeviceOptions);
ApplyOptions(options.allDeviceOptions, rgb_controllers);
}
}
@@ -996,25 +1113,6 @@ unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> rgb_c
}
}
if (options.servOpts.start)
{
network_server->SetPort(options.servOpts.port);
network_server->StartServer();
if(network_server->GetOnline())
{
WaitWhileServerOnline(network_server);
return 0;
}
else
{
std::cout << "Server failed to start" << std::endl;
exit(1);
}
}
exit(0);
return 0;
+91
View File
@@ -0,0 +1,91 @@
/*-------------------------------------------------------------------*\
| dmiinfo.cpp |
| |
| Read DMI information for motherboard vendor and name |
| |
| Chris M (Dr_No) 30th Jun 2020 |
| |
\*-------------------------------------------------------------------*/
#include "dmiinfo.h"
#ifdef WIN32
#include "wmi.h"
/******************************************************************************************\
* *
* DMIInfo (Windows) *
* *
* Implementing way to read motherboard vendor and name based on *
* the win32_baseboard WMI query *
* https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-baseboard *
* *
\******************************************************************************************/
DMIInfo::DMIInfo()
{
mainboard = "";
manufacturer = "";
HRESULT hres;
Wmi wmi;
wmi.init();
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
// These devices may be browsed under Device Manager -> System Devices
std::vector<QueryObj> q_res_BaseBoard;
hres = wmi.query("SELECT * FROM Win32_BaseBoard", q_res_BaseBoard);
if (hres)
{
return;
}
for (QueryObj &i : q_res_BaseBoard)
{
manufacturer = i["Manufacturer"].c_str();
mainboard = i["Model"].c_str();
}
}
#else /* WIN32 */
/******************************************************************************************\
* *
* DMIInfo (Linux) *
* *
* Implementing way to read motherboard vendor and name based on *
* the Linux DMIDecode which is read only for users in the sysfs @ *
* /sys/devices/virtual/dmi/id/ *
* *
\******************************************************************************************/
DMIInfo::DMIInfo()
{
mainboard = "";
manufacturer = "";
if ((access(SYSFSDMI "/board_vendor", R_OK)!=0) && (access(SYSFSDMI "/board_name", R_OK)!=0))
return;
std::ifstream mftr(SYSFSDMI "/board_vendor", std::ifstream::in);
getline(mftr, manufacturer);
mftr.close();
std::ifstream prdt(SYSFSDMI "/board_name", std::ifstream::in);
getline(prdt, mainboard);
prdt.close();
}
#endif /* WIN32 */
DMIInfo::~DMIInfo()
{
}
std::string DMIInfo::getMainboard()
{
return mainboard;
}
std::string DMIInfo::getManufacturer()
{
return manufacturer;
}
+37
View File
@@ -0,0 +1,37 @@
/*-------------------------------------------------------------------*\
| dmiinfo.h |
| |
| Read DMI information for motherboard vendor and name |
| |
| Chris M (Dr_No) 30th Jun 2020 |
| |
\*-------------------------------------------------------------------*/
#ifndef DMIINFO_H
#define DMIINFO_H
#include <string>
#ifdef WIN32
#include "wmi.h"
#else
#include <unistd.h> //Linux specific filesystem operation
#include <fstream>
#define SYSFSDMI "/sys/devices/virtual/dmi/id/" //Linux specific file path
#endif
class DMIInfo
{
public:
DMIInfo();
~DMIInfo();
std::string getMainboard();
std::string getManufacturer();
private:
std::string mainboard;
std::string manufacturer;
};
#endif // DMIINFO_H
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8 -3
View File
@@ -17,9 +17,14 @@
i2c_smbus_interface::i2c_smbus_interface()
{
i2c_smbus_start = false;
i2c_smbus_done = false;
i2c_smbus_thread = new std::thread(&i2c_smbus_interface::i2c_smbus_thread_function, this);
i2c_smbus_start = false;
i2c_smbus_done = false;
this->port_id = -1;
this->pci_device = -1;
this->pci_vendor = -1;
this->pci_subsystem_device = -1;
this->pci_subsystem_vendor = -1;
i2c_smbus_thread = new std::thread(&i2c_smbus_interface::i2c_smbus_thread_function, this);
}
s32 i2c_smbus_interface::i2c_smbus_write_quick(u8 addr, u8 value)
+6
View File
@@ -59,6 +59,12 @@ class i2c_smbus_interface
public:
char device_name[512];
int port_id;
int pci_device;
int pci_vendor;
int pci_subsystem_device;
int pci_subsystem_vendor;
i2c_smbus_interface();
virtual ~i2c_smbus_interface() = default;
+8
View File
@@ -86,6 +86,14 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
Out32(SMBHSTADD, (addr << 1) | read_write);
size = PIIX4_QUICK;
break;
case I2C_SMBUS_BYTE:
Out32(SMBHSTADD, (addr << 1) | read_write);
if (read_write == I2C_SMBUS_WRITE)
{
Out32(SMBHSTCMD, command);
}
size = PIIX4_BYTE;
break;
case I2C_SMBUS_BYTE_DATA:
Out32(SMBHSTADD, (addr << 1) | read_write);
Out32(SMBHSTCMD, command);
+107 -21
View File
@@ -6,6 +6,7 @@
* *
\******************************************************************************************/
#include "NetworkClient.h"
#include "NetworkServer.h"
#include "OpenRGB.h"
#include "ProfileManager.h"
@@ -17,12 +18,67 @@
#include "OpenRGBDialog2.h"
using namespace std::chrono_literals;
std::vector<NetworkClient*> clients;
extern std::vector<i2c_smbus_interface*> busses;
extern std::vector<RGBController*> rgb_controllers;
// See cli.cpp
extern unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> rgb_controllers_in, ProfileManager* profile_manager_in, NetworkServer* network_server_in);
/*-------------------------------------------------------------*\
| Command line functionality and return flags |
\*-------------------------------------------------------------*/
extern unsigned int cli_main(int argc, char *argv[], std::vector<RGBController *> &rgb_controllers, ProfileManager* profile_manager_in, NetworkServer* network_server_in, std::vector<NetworkClient*> &clients);
enum
{
RET_FLAG_PRINT_HELP = 1,
RET_FLAG_START_GUI = 2,
RET_FLAG_I2C_TOOLS = 4,
RET_FLAG_START_MINIMIZED = 8,
};
/******************************************************************************************\
* *
* AttemptLocalConnection *
* *
* Attempts an SDK connection to the local server. Returns true if success *
* *
\******************************************************************************************/
bool AttemptLocalConnection()
{
bool success = false;
NetworkClient * client = new NetworkClient(rgb_controllers);
client->StartClient();
for(int timeout = 0; timeout < 10; timeout++)
{
if(client->GetConnected())
{
break;
}
std::this_thread::sleep_for(5ms);
}
if(!client->GetConnected())
{
client->StopClient();
delete client;
client = NULL;
}
else
{
clients.push_back(client);
success = true;
}
return success;
}
/******************************************************************************************\
* *
@@ -37,34 +93,64 @@ int main(int argc, char* argv[])
ProfileManager profile_manager(rgb_controllers);
NetworkServer server(rgb_controllers);
DetectRGBControllers();
if(!AttemptLocalConnection())
{
DetectRGBControllers();
}
profile_manager.LoadSizeFromProfile("sizes.ors");
unsigned int ret_flags = 0;
/*---------------------------------------------------------*\
| Process command line arguments |
\*---------------------------------------------------------*/
unsigned int ret_flags = RET_FLAG_START_GUI;
if(argc > 1)
{
ret_flags = cli_main(argc, argv, rgb_controllers, &profile_manager, &server);
ret_flags = cli_main(argc, argv, rgb_controllers, &profile_manager, &server, clients);
}
if(ret_flags && 2)
/*---------------------------------------------------------*\
| If the command line parser indicates that the GUI should |
| run, or if there were no command line arguments, start the|
| GUI. |
\*---------------------------------------------------------*/
if(ret_flags & RET_FLAG_START_GUI)
{
//GUI is enabled
}
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
bool show_i2c_tools = false;
if(ret_flags && 4)
Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager);
if(ret_flags & RET_FLAG_I2C_TOOLS)
{
dlg.AddI2CToolsPage();
}
if(clients.size() == 0)
{
dlg.AddServerTab(&server);
}
dlg.AddClientTab();
for(int client_idx = 0; client_idx < clients.size(); client_idx++)
{
dlg.AddClient(clients[client_idx]);
}
if(ret_flags & RET_FLAG_START_MINIMIZED)
{
dlg.hide();
}
else
{
dlg.show();
}
return a.exec();
}
else
{
//I2C Tools is enabled
show_i2c_tools = true;
return 0;
}
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
Ui::OpenRGBDialog2 dlg(busses, rgb_controllers, &profile_manager, &server, show_i2c_tools);
dlg.show();
return a.exec();
}
+219
View File
@@ -0,0 +1,219 @@
#include <QSignalMapper>
#include "OpenRGBClientInfoPage.h"
using namespace Ui;
static void UpdateInfoCallback(void * this_ptr)
{
OpenRGBClientInfoPage * this_obj = (OpenRGBClientInfoPage *)this_ptr;
QMetaObject::invokeMethod(this_obj, "UpdateInfo", Qt::QueuedConnection);
}
class NetworkClientPointer : public QObject
{
public:
NetworkClient * net_client;
};
OpenRGBClientInfoPage::OpenRGBClientInfoPage(std::vector<RGBController *>& control, QWidget *parent) :
QFrame(parent),
controllers(control),
ui(new Ui::OpenRGBClientInfoPageUi)
{
/*-----------------------------------------------------*\
| Set initial values for GUI fields |
\*-----------------------------------------------------*/
ui->setupUi(this);
ui->ClientIPValue->setText("127.0.0.1");
ui->ClientPortValue->setText(QString::number(OPENRGB_SDK_PORT));
/*-----------------------------------------------------*\
| Update the information view |
\*-----------------------------------------------------*/
UpdateInfo();
}
OpenRGBClientInfoPage::~OpenRGBClientInfoPage()
{
}
void OpenRGBClientInfoPage::AddClient(NetworkClient* new_client)
{
/*-----------------------------------------------------*\
| Add a new client to the list, register the callback, |
| and update the information view if the pointer is |
| valid |
\*-----------------------------------------------------*/
if(new_client != NULL)
{
rgb_clients.push_back(new_client);
new_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
UpdateInfo();
}
}
void OpenRGBClientInfoPage::UpdateInfo()
{
/*-----------------------------------------------------*\
| Clear the tree view before recreating its contents |
\*-----------------------------------------------------*/
ui->ClientTree->clear();
/*-----------------------------------------------------*\
| Set up the tree view header |
\*-----------------------------------------------------*/
ui->ClientTree->setColumnCount(2);
ui->ClientTree->header()->setStretchLastSection(false);
ui->ClientTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
ui->ClientTree->setColumnWidth(1, 100);
ui->ClientTree->setHeaderLabels(QStringList() << "Connected Clients" << "");
/*-----------------------------------------------------*\
| Set up a signal mapper to handle disconnect buttons |
\*-----------------------------------------------------*/
QSignalMapper* signalMapper = new QSignalMapper(this);
connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(on_ClientDisconnectButton_clicked(QObject *)));
/*-----------------------------------------------------*\
| Loop through all clients in list and display them |
\*-----------------------------------------------------*/
for(int client_idx = 0; client_idx < rgb_clients.size(); client_idx++)
{
/*-----------------------------------------------------*\
| Create the top level tree widget items and display the|
| client IP addresses in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_top_item = new QTreeWidgetItem(ui->ClientTree);
new_top_item->setText(0, QString::fromStdString(rgb_clients[client_idx]->GetIP()));
/*-----------------------------------------------------*\
| Create the disconnect buttons and connect them to the |
| signal mapper |
\*-----------------------------------------------------*/
QPushButton* new_button = new QPushButton( "Disconnect" );
ui->ClientTree->setItemWidget(new_top_item, 1, new_button);
connect(new_button, SIGNAL(clicked()), signalMapper, SLOT(map()));
NetworkClientPointer * new_arg = new NetworkClientPointer();
new_arg->net_client = rgb_clients[client_idx];
signalMapper->setMapping(new_button, new_arg);
/*-----------------------------------------------------*\
| Add child items for each device in the client |
\*-----------------------------------------------------*/
for(int dev_idx = 0; dev_idx < rgb_clients[client_idx]->server_controllers.size(); dev_idx++)
{
/*-----------------------------------------------------*\
| Create child tree widget items and display the device |
| names in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_item = new QTreeWidgetItem(new_top_item);
new_item->setText(0, QString::fromStdString(rgb_clients[client_idx]->server_controllers[dev_idx]->name));
/*-----------------------------------------------------*\
| Add child items for each zone in the device |
\*-----------------------------------------------------*/
for(int zone_idx = 0; zone_idx < rgb_clients[client_idx]->server_controllers[dev_idx]->zones.size(); zone_idx++)
{
/*-----------------------------------------------------*\
| Create child tree widget items and display the zone |
| names, number of LEDs, and types in them |
\*-----------------------------------------------------*/
QTreeWidgetItem* new_child = new QTreeWidgetItem();
std::string zone_str = rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].name + ", ";
zone_str.append(std::to_string(rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].leds_count));
zone_str.append(" LEDs, ");
switch(rgb_clients[client_idx]->server_controllers[dev_idx]->zones[zone_idx].type)
{
case ZONE_TYPE_SINGLE:
zone_str.append("Single");
break;
case ZONE_TYPE_LINEAR:
zone_str.append("Linear");
break;
case ZONE_TYPE_MATRIX:
zone_str.append("Matrix");
break;
}
new_child->setText(0, QString::fromStdString(zone_str));
new_item->addChild(new_child);
}
}
}
/*-----------------------------------------------------*\
| Emit client information updated signal |
\*-----------------------------------------------------*/
emit ClientListUpdated();
}
void Ui::OpenRGBClientInfoPage::on_ClientConnectButton_clicked()
{
/*-----------------------------------------------------*\
| Read the new client IP and Port values from the UI |
\*-----------------------------------------------------*/
unsigned short port = std::stoi(ui->ClientPortValue->text().toStdString());
std::string ip = ui->ClientIPValue->text().toStdString();
/*-----------------------------------------------------*\
| Create a new client and set name, IP, and port values |
\*-----------------------------------------------------*/
NetworkClient * rgb_client = new NetworkClient(controllers);
std::string titleString = "OpenRGB ";
titleString.append(VERSION_STRING);
rgb_client->SetIP(ip.c_str());
rgb_client->SetName(titleString.c_str());
rgb_client->SetPort(port);
rgb_client->StartClient();
/*-----------------------------------------------------*\
| Add new client to list and register update callback |
\*-----------------------------------------------------*/
rgb_clients.push_back(rgb_client);
rgb_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this);
}
void Ui::OpenRGBClientInfoPage::on_ClientDisconnectButton_clicked(QObject * arg)
{
/*-----------------------------------------------------*\
| Get the pointer to the disconnecting client from args |
\*-----------------------------------------------------*/
NetworkClient * disconnect_client = ((NetworkClientPointer *)arg)->net_client;
/*-----------------------------------------------------*\
| Stop the disconnecting client |
\*-----------------------------------------------------*/
disconnect_client->StopClient();
/*-----------------------------------------------------*\
| Remove disconnecting client from list |
\*-----------------------------------------------------*/
for(unsigned int client_idx = 0; client_idx < rgb_clients.size(); client_idx++)
{
if(disconnect_client == rgb_clients[client_idx])
{
rgb_clients.erase(rgb_clients.begin() + client_idx);
break;
}
}
/*-----------------------------------------------------*\
| Delete the disconnecting client |
\*-----------------------------------------------------*/
delete disconnect_client;
}
+40
View File
@@ -0,0 +1,40 @@
#ifndef OPENRGBCLIENTINFOPAGE_H
#define OPENRGBCLIENTINFOPAGE_H
#include <QFrame>
#include "RGBController.h"
#include "ui_OpenRGBClientInfoPage.h"
#include "NetworkClient.h"
namespace Ui {
class OpenRGBClientInfoPage;
}
class Ui::OpenRGBClientInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBClientInfoPage(std::vector<RGBController *>& control, QWidget *parent = nullptr);
~OpenRGBClientInfoPage();
void AddClient(NetworkClient* new_client);
public slots:
void UpdateInfo();
private slots:
void on_ClientConnectButton_clicked();
void on_ClientDisconnectButton_clicked(QObject * arg);
private:
Ui::OpenRGBClientInfoPageUi *ui;
std::vector<RGBController *>& controllers;
std::vector<NetworkClient*> rgb_clients;
signals:
void ClientListUpdated();
};
#endif // OPENRGBCLIENTINFOPAGE_H
+75
View File
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBClientInfoPageUi</class>
<widget class="QFrame" name="OpenRGBClientInfoPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>664</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="6">
<widget class="QLineEdit" name="ClientPortValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLabel" name="ClientPortLabel">
<property name="text">
<string>Port:</string>
</property>
</widget>
</item>
<item row="0" column="7">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="ClientConnectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLineEdit" name="ClientIPValue"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="ClientIPLabel">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="6">
<widget class="QTreeWidget" name="ClientTree">
<property name="columnCount">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+65 -1
View File
@@ -642,13 +642,72 @@ void Ui::OpenRGBDevicePage::UpdateDevice()
UpdateMode();
}
void Ui::OpenRGBDevicePage::SetCustomMode()
void Ui::OpenRGBDevicePage::SetCustomMode(unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| Set the selected mode to the custom mode and update UI|
\*-----------------------------------------------------*/
device->SetCustomMode();
ui->ModeBox->blockSignals(true);
ui->ModeBox->setCurrentIndex(device->active_mode);
ui->ModeBox->blockSignals(false);
UpdateModeUi();
/*-----------------------------------------------------*\
| Set the color boxes |
\*-----------------------------------------------------*/
UpdatingColor = true;
ui->RedSpinBox->setValue(red);
ui->GreenSpinBox->setValue(green);
ui->BlueSpinBox->setValue(blue);
UpdatingColor = false;
updateHSV();
updateWheel();
/*-----------------------------------------------------*\
| Read selected mode |
\*-----------------------------------------------------*/
unsigned int selected_mode = (unsigned int)ui->ModeBox->currentIndex();
switch(device->modes[selected_mode].color_mode)
{
case MODE_COLORS_PER_LED:
{
/*-----------------------------------------------------*\
| Set all device LEDs to the current color |
\*-----------------------------------------------------*/
RGBColor color = ToRGBColor(
ui->RedSpinBox->text().toInt(),
ui->GreenSpinBox->text().toInt(),
ui->BlueSpinBox->text().toInt()
);
device->SetAllLEDs(color);
}
break;
case MODE_COLORS_MODE_SPECIFIC:
{
/*-----------------------------------------------------*\
| Set all device LEDs to the current color |
\*-----------------------------------------------------*/
RGBColor color = ToRGBColor(
ui->RedSpinBox->text().toInt(),
ui->GreenSpinBox->text().toInt(),
ui->BlueSpinBox->text().toInt()
);
for(std::size_t i = 0; i < device->modes[selected_mode].colors.size(); i++)
{
device->modes[selected_mode].colors[i] = color;
}
}
break;
}
/*-----------------------------------------------------*\
| Apply mode and colors |
\*-----------------------------------------------------*/
UpdateMode();
}
@@ -673,6 +732,8 @@ void Ui::OpenRGBDevicePage::on_SetDeviceButton_clicked()
);
device->SetAllLEDs(color);
device->UpdateLEDs();
}
break;
@@ -729,6 +790,7 @@ void Ui::OpenRGBDevicePage::on_SetZoneButton_clicked()
);
device->SetAllZoneLEDs(index, color);
device->UpdateZoneLEDs(index);
}
}
break;
@@ -761,12 +823,14 @@ void Ui::OpenRGBDevicePage::on_SetLEDButton_clicked()
if(selected_zone == 0)
{
device->SetLED(index, color);
device->UpdateSingleLED(index);
}
else
{
selected_zone = selected_zone - 1;
device->SetLED(device->zones[selected_zone].start_idx + index, color);
device->UpdateSingleLED(device->zones[selected_zone].start_idx + index);
}
}
break;
+1 -1
View File
@@ -19,7 +19,7 @@ public:
~OpenRGBDevicePage();
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
void SetCustomMode();
void SetCustomMode(unsigned char red, unsigned char green, unsigned char blue);
void UpdateDevice();
void UpdateMode();
void UpdateModeUi();
+152 -81
View File
@@ -2,8 +2,6 @@
#include "OpenRGBDevicePage.h"
#include "OpenRGBDeviceInfoPage.h"
#include "OpenRGBServerInfoPage.h"
#include "OpenRGBSoftwareInfoPage.h"
#include "OpenRGBSystemInfoPage.h"
#include "OpenRGBProfileSaveDialog.h"
#include <QLabel>
#include <QTabBar>
@@ -13,6 +11,10 @@ using namespace Ui;
static QString GetIconString(device_type type)
{
/*-----------------------------------------------------*\
| Return the icon filename string for the given device |
| type value |
\*-----------------------------------------------------*/
switch(type)
{
case DEVICE_TYPE_MOTHERBOARD:
@@ -51,13 +53,23 @@ static QString GetIconString(device_type type)
}
}
OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, bool show_i2c_tools, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), profile_manager(manager), network_server(server), ui(new OpenRGBDialog2Ui)
OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, QWidget *parent) : QMainWindow(parent), busses(bus), controllers(control), profile_manager(manager), ui(new OpenRGBDialog2Ui)
{
ui->setupUi(this);
/*-----------------------------------------------------*\
| Set window icon |
\*-----------------------------------------------------*/
QIcon logo(":OpenRGB.png");
setWindowIcon(logo);
/*-----------------------------------------------------*\
| Initialize page pointers |
\*-----------------------------------------------------*/
ClientInfoPage = NULL;
SMBusToolsPage = NULL;
SoftInfoPage = NULL;
/*-----------------------------------------------------*\
| Set up tray icon menu |
\*-----------------------------------------------------*/
@@ -118,16 +130,134 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
trayIcon->setContextMenu(trayIconMenu);
trayIcon->show();
RefreshProfileList();
/*-----------------------------------------------------*\
| Update the profile list |
\*-----------------------------------------------------*/
UpdateProfileList();
/*-----------------------------------------------------*\
| Update the device list |
\*-----------------------------------------------------*/
UpdateDevicesList();
/*-----------------------------------------------------*\
| Create the Software Information page |
\*-----------------------------------------------------*/
SoftInfoPage = new OpenRGBSoftwareInfoPage();
ui->InformationTabBar->addTab(SoftInfoPage, "");
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
SoftwareLabelString += ":/software.png";
SoftwareLabelString += "' height='16' width='16'></td><td>Software</td></tr></table></html>";
QLabel *SoftwareTabLabel = new QLabel();
SoftwareTabLabel->setText(SoftwareLabelString);
SoftwareTabLabel->setIndent(20);
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SoftwareTabLabel);
}
OpenRGBDialog2::~OpenRGBDialog2()
{
delete ui;
}
void OpenRGBDialog2::AddI2CToolsPage()
{
/*-----------------------------------------------------*\
| Create the I2C Tools page if it doesn't exist yet |
\*-----------------------------------------------------*/
if(SMBusToolsPage == NULL)
{
SMBusToolsPage = new OpenRGBSystemInfoPage(busses);
/*-----------------------------------------------------*\
| Create the I2C Tools tab in the Information bar |
\*-----------------------------------------------------*/
ui->InformationTabBar->addTab(SMBusToolsPage, "");
QString SMBusToolsLabelString = "<html><table><tr><td width='30'><img src='";
SMBusToolsLabelString += ":/tools.png";
SMBusToolsLabelString += "' height='16' width='16'></td><td>SMBus Tools</td></tr></table></html>";
QLabel *SMBusToolsTabLabel = new QLabel();
SMBusToolsTabLabel->setText(SMBusToolsLabelString);
SMBusToolsTabLabel->setIndent(20);
SMBusToolsTabLabel->setGeometry(0, 0, 200, 20);
ui->InformationTabBar->tabBar()->setTabButton(ui->InformationTabBar->tabBar()->count() - 1, QTabBar::LeftSide, SMBusToolsTabLabel);
}
}
void OpenRGBDialog2::AddClientTab()
{
/*-----------------------------------------------------*\
| Add client information tab if it doesn't exist yet |
\*-----------------------------------------------------*/
if(ClientInfoPage == NULL)
{
ClientInfoPage = new OpenRGBClientInfoPage(controllers);
ui->MainTabBar->addTab(ClientInfoPage, "SDK Client");
/*-----------------------------------------------------*\
| Connect the page's Set All button to the Set All slot |
\*-----------------------------------------------------*/
connect(ClientInfoPage,
SIGNAL(ClientListUpdated()),
this,
SLOT(on_ClientListUpdated()));
}
}
void OpenRGBDialog2::AddClient(NetworkClient* new_client)
{
/*-----------------------------------------------------*\
| Add a client to the client information page |
\*-----------------------------------------------------*/
if(ClientInfoPage != NULL)
{
ClientInfoPage->AddClient(new_client);
}
}
void OpenRGBDialog2::AddServerTab(NetworkServer* network_server)
{
/*-----------------------------------------------------*\
| Add server information tab if there is a server |
\*-----------------------------------------------------*/
if(network_server != NULL)
{
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(network_server);
ui->MainTabBar->addTab(ServerInfoPage, "SDK Server");
}
}
void OpenRGBDialog2::ClearDevicesList()
{
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
{
delete ui->DevicesTabBar->widget(tab_idx);
}
ui->DevicesTabBar->clear();
for(int tab_idx = 0; tab_idx < ui->InformationTabBar->count(); tab_idx++)
{
delete ui->InformationTabBar->widget(tab_idx);
}
ui->InformationTabBar->clear();
}
void OpenRGBDialog2::UpdateDevicesList()
{
/*-----------------------------------------------------*\
| Set up list of devices |
\*-----------------------------------------------------*/
QTabBar *DevicesTabBar = ui->DevicesTabBar->tabBar();
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
for(std::size_t dev_idx = 0; dev_idx < controllers.size(); dev_idx++)
{
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(control[dev_idx]);
OpenRGBDevicePage *NewPage = new OpenRGBDevicePage(controllers[dev_idx]);
ui->DevicesTabBar->addTab(NewPage, "");
/*-----------------------------------------------------*\
@@ -152,8 +282,8 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
| type and append device name string. |
\*-----------------------------------------------------*/
QString NewLabelString = "<html><table><tr><td width='30'><img src=':/";
NewLabelString += GetIconString(control[dev_idx]->type);
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(control[dev_idx]->name) + "</td></tr></table></html>";
NewLabelString += GetIconString(controllers[dev_idx]->type);
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(controllers[dev_idx]->name) + "</td></tr></table></html>";
QLabel *NewTabLabel = new QLabel();
NewTabLabel->setText(NewLabelString);
@@ -168,9 +298,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
\*-----------------------------------------------------*/
QTabBar *InformationTabBar = ui->InformationTabBar->tabBar();
for(std::size_t dev_idx = 0; dev_idx < control.size(); dev_idx++)
for(std::size_t dev_idx = 0; dev_idx < controllers.size(); dev_idx++)
{
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(control[dev_idx]);
OpenRGBDeviceInfoPage *NewPage = new OpenRGBDeviceInfoPage(controllers[dev_idx]);
ui->InformationTabBar->addTab(NewPage, "");
/*-----------------------------------------------------*\
@@ -179,8 +309,8 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
| type and append device name string. |
\*-----------------------------------------------------*/
QString NewLabelString = "<html><table><tr><td width='30'><img src=':/";
NewLabelString += GetIconString(control[dev_idx]->type);
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(control[dev_idx]->name) + "</td></tr></table></html>";
NewLabelString += GetIconString(controllers[dev_idx]->type);
NewLabelString += "' height='16' width='16'></td><td>" + QString::fromStdString(controllers[dev_idx]->name) + "</td></tr></table></html>";
QLabel *NewTabLabel = new QLabel();
NewTabLabel->setText(NewLabelString);
@@ -189,73 +319,9 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
InformationTabBar->setTabButton(dev_idx, QTabBar::LeftSide, NewTabLabel);
}
/*-----------------------------------------------------*\
| Show the I2C Tools page only if enabled |
\*-----------------------------------------------------*/
if(show_i2c_tools)
{
OpenRGBSystemInfoPage *SMBusToolsPage = new OpenRGBSystemInfoPage(bus);
ui->InformationTabBar->addTab(SMBusToolsPage, "");
QString SMBusToolsLabelString = "<html><table><tr><td width='30'><img src='";
SMBusToolsLabelString += ":/tools.png";
SMBusToolsLabelString += "' height='16' width='16'></td><td>SMBus Tools</td></tr></table></html>";
QLabel *SMBusToolsTabLabel = new QLabel();
SMBusToolsTabLabel->setText(SMBusToolsLabelString);
SMBusToolsTabLabel->setIndent(20);
SMBusToolsTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SMBusToolsTabLabel);
}
/*-----------------------------------------------------*\
| Always show the software information page |
\*-----------------------------------------------------*/
OpenRGBSoftwareInfoPage *SoftInfoPage = new OpenRGBSoftwareInfoPage();
ui->InformationTabBar->addTab(SoftInfoPage, "");
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
SoftwareLabelString += ":/software.png";
SoftwareLabelString += "' height='16' width='16'></td><td>Software</td></tr></table></html>";
QLabel *SoftwareTabLabel = new QLabel();
SoftwareTabLabel->setText(SoftwareLabelString);
SoftwareTabLabel->setIndent(20);
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
if(show_i2c_tools)
{
InformationTabBar->setTabButton(control.size() + 1, QTabBar::LeftSide, SoftwareTabLabel);
}
else
{
InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SoftwareTabLabel);
}
/*-----------------------------------------------------*\
| Add server information tab if there is a server |
\*-----------------------------------------------------*/
if(network_server != NULL)
{
OpenRGBServerInfoPage *ServerInfoPage = new OpenRGBServerInfoPage(network_server);
ui->MainTabBar->addTab(ServerInfoPage, "SDK Server");
}
}
OpenRGBDialog2::~OpenRGBDialog2()
{
delete ui;
}
void OpenRGBDialog2::show()
{
QMainWindow::show();
}
void OpenRGBDialog2::RefreshProfileList()
void OpenRGBDialog2::UpdateProfileList()
{
if(profile_manager != NULL)
{
@@ -329,12 +395,17 @@ void OpenRGBDialog2::on_QuickWhite()
on_SetAllDevices(0xFF, 0xFF, 0xFF);
}
void OpenRGBDialog2::on_ClientListUpdated()
{
ClearDevicesList();
UpdateDevicesList();
}
void OpenRGBDialog2::on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue)
{
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode();
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetDevice(red, green, blue);
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->SetCustomMode(red, green, blue);
}
}
@@ -404,7 +475,7 @@ void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
\*---------------------------------------------------------*/
if(profile_manager->SaveProfile(filename))
{
RefreshProfileList();
UpdateProfileList();
}
}
}
@@ -453,7 +524,7 @@ void Ui::OpenRGBDialog2::on_ButtonDeleteProfile_clicked()
{
profile_manager->DeleteProfile(profile_name);
RefreshProfileList();
UpdateProfileList();
}
}
}
+31 -5
View File
@@ -3,10 +3,15 @@
#include "ui_OpenRGBDialog2.h"
#include "OpenRGBClientInfoPage.h"
#include "OpenRGBSoftwareInfoPage.h"
#include "OpenRGBSystemInfoPage.h"
#include <vector>
#include "i2c_smbus.h"
#include "RGBController.h"
#include "ProfileManager.h"
#include "NetworkClient.h"
#include "NetworkServer.h"
#include <QMainWindow>
@@ -24,23 +29,43 @@ class Ui::OpenRGBDialog2 : public QMainWindow
Q_OBJECT
public:
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, NetworkServer* server, bool show_i2c_tools, QWidget *parent = 0);
explicit OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, ProfileManager* manager, QWidget *parent = 0);
~OpenRGBDialog2();
void show();
void AddClient(NetworkClient* new_client);
void AddClientTab();
void AddI2CToolsPage();
void AddServerTab(NetworkServer* network_server);
void setMode(unsigned char mode_val);
protected:
std::vector<i2c_smbus_interface *>& busses;
std::vector<RGBController *>& controllers;
ProfileManager* profile_manager;
NetworkServer* network_server;
private:
Ui::OpenRGBDialog2Ui *ui;
/*-------------------------------------*\
| Page pointers |
\*-------------------------------------*/
OpenRGBClientInfoPage *ClientInfoPage;
OpenRGBSystemInfoPage *SMBusToolsPage;
OpenRGBSoftwareInfoPage *SoftInfoPage;
/*-------------------------------------*\
| System tray icon and menu |
\*-------------------------------------*/
QSystemTrayIcon* trayIcon;
QMenu* profileMenu;
void RefreshProfileList();
/*-------------------------------------*\
| User interface |
\*-------------------------------------*/
Ui::OpenRGBDialog2Ui *ui;
void ClearDevicesList();
void UpdateDevicesList();
void UpdateProfileList();
private slots:
void on_Exit();
@@ -52,6 +77,7 @@ private slots:
void on_QuickBlue();
void on_QuickMagenta();
void on_QuickWhite();
void on_ClientListUpdated();
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
void on_SaveSizeProfile();
void on_ShowHide();
+33 -27
View File
@@ -33,7 +33,7 @@ std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
const char * DevEnum = "USB";
char ExpectedDeviceId[80] = {0}; //Store hardware id
char vid_pid[10] = {0}; //Store VID/PID
BYTE szBuffer[1024] = {0};
char szBuffer[1024] = {0};
DEVPROPTYPE ulPropertyType;
DWORD dwSize = 0;
@@ -41,10 +41,10 @@ std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
| Create device hardware id |
| "vid_ABCD&pid_CDEF" |
\*-----------------------------------------------------------------*/
strcpy(ExpectedDeviceId, "vid_");
strcpy(ExpectedDeviceId, "USB\\VID_");
snprintf(vid_pid, 10, "%04X", vid);
strcat(ExpectedDeviceId, vid_pid);
strcat(ExpectedDeviceId, "&pid_");
strcat(ExpectedDeviceId, "&PID_");
snprintf(vid_pid, 10, "%04X", pid);
strcat(ExpectedDeviceId, vid_pid);
@@ -78,34 +78,40 @@ std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
{
HKEY hDeviceRegistryKey;
hDeviceRegistryKey = SetupDiOpenDevRegKey(DeviceInfoSet, &DeviceInfoData,DICS_FLAG_GLOBAL, 0,DIREG_DEV, KEY_READ);
if (hDeviceRegistryKey == INVALID_HANDLE_VALUE)
/*-----------------------------------------------------*\
| Check if the string for this device property matches |
| our expected device string |
\*-----------------------------------------------------*/
if(strncmp(ExpectedDeviceId, szBuffer, 21) == 0)
{
break;
}
else
{
char pszPortName[BUFF_LEN];
DWORD dwSize = sizeof(pszPortName);
DWORD dwType = 0;
/*-----------------------------------------------------*\
| Read in the name of the port |
\*-----------------------------------------------------*/
if( (RegQueryValueEx(hDeviceRegistryKey,"PortName", NULL, &dwType, (LPBYTE) pszPortName, &dwSize) == ERROR_SUCCESS) && (dwType == REG_SZ))
hDeviceRegistryKey = SetupDiOpenDevRegKey(DeviceInfoSet, &DeviceInfoData,DICS_FLAG_GLOBAL, 0,DIREG_DEV, KEY_READ);
if (hDeviceRegistryKey == INVALID_HANDLE_VALUE)
{
if(strncmp(pszPortName, "COM", 3) == 0)
{
ret_str.append(pszPortName);
return ret_str;
}
break;
}
else
{
char pszPortName[BUFF_LEN];
DWORD dwSize = sizeof(pszPortName);
DWORD dwType = 0;
// Close the key now that we are finished with it
RegCloseKey(hDeviceRegistryKey);
/*-----------------------------------------------------*\
| Read in the name of the port |
\*-----------------------------------------------------*/
if( (RegQueryValueEx(hDeviceRegistryKey,"PortName", NULL, &dwType, (LPBYTE) pszPortName, &dwSize) == ERROR_SUCCESS) && (dwType == REG_SZ))
{
if(strncmp(pszPortName, "COM", 3) == 0)
{
ret_str.append(pszPortName);
return ret_str;
}
}
// Close the key now that we are finished with it
RegCloseKey(hDeviceRegistryKey);
}
}
}
}
}
if (DeviceInfoSet)
@@ -115,4 +121,4 @@ std::string find_usb_serial_port(unsigned short vid, unsigned short pid)
return ret_str;
} /* find_usb_serial_port() */
} /* find_usb_serial_port() */