Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6de8c374dc |
-10
@@ -1,11 +1 @@
|
||||
*.pro.user*
|
||||
*.o
|
||||
ui_*
|
||||
moc_*
|
||||
qrc_*
|
||||
OpenRGB
|
||||
openrgb
|
||||
Makefile
|
||||
OpenRGB-x86_64.AppImage
|
||||
.qmake.stash
|
||||
.vscode
|
||||
|
||||
-249
@@ -1,249 +0,0 @@
|
||||
# swy: some useful references; the MSVC part of the CI script is based on the one from bind9, by Michał Kępień:
|
||||
# https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/blob/master/cookbooks/preinstalled-software/README.md
|
||||
# https://gitlab.isc.org/isc-projects/bind9/commit/facc6a051fcac70fbbc61cb92a37be8c3e4db5ec#587d266bb27a4dc3022bbed44dfa19849df3044c_718_731
|
||||
# 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
|
||||
- windows
|
||||
- windows-1809
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- echo "started by ${GITLAB_USER_NAME}"
|
||||
|
||||
#reusable templates
|
||||
.ccache_init: &ccache_init
|
||||
before_script:
|
||||
- apt update
|
||||
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (AppImage) 32-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
build_linux_32:
|
||||
<<: *ccache_init
|
||||
image: i386/ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- export $(dpkg-architecture)
|
||||
- ./scripts/build-appimage.sh
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- OpenRGB-i386.AppImage
|
||||
- 60-openrgb.rules
|
||||
- README.md
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (AppImage) 64-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
build_linux_64:
|
||||
<<: *ccache_init
|
||||
image: ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- export $(dpkg-architecture)
|
||||
- ./scripts/build-appimage.sh
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- OpenRGB-x86_64.AppImage
|
||||
- 60-openrgb.rules
|
||||
- README.md
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (.deb) 32-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
build_linux_deb32:
|
||||
<<: *ccache_init
|
||||
image: i386/ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- apt install -y debhelper
|
||||
- dpkg-architecture -l
|
||||
- dpkg-buildpackage --target-arch i386 -us -B
|
||||
- rm -v ../openrgb-dbgsym*.ddeb
|
||||
- mv -v ../openrgb*.deb ./
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- openrgb*.deb
|
||||
exclude:
|
||||
- openrgb-dbgsym*.deb
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (.deb) 64-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
build_linux_deb64:
|
||||
<<: *ccache_init
|
||||
image: ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- apt install -y debhelper
|
||||
- dpkg-architecture -l
|
||||
- dpkg-buildpackage -us -B
|
||||
- rm -v ../openrgb-dbgsym*.ddeb
|
||||
- mv -v ../openrgb*.deb ./
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- openrgb*.deb
|
||||
exclude:
|
||||
- openrgb-dbgsym*.deb
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# 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: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Windows (64-bit) Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
build_windows_64:
|
||||
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 x64 & 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.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_
|
||||
|
||||
- _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_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
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
|
||||
- mkdir _build; cd _build
|
||||
- ..\_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'
|
||||
- ..\_qt\jom
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
|
||||
- ..\_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'
|
||||
- mv release 'OpenRGB Windows 64-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}_64_${revision}_nightly_${datetime}.7z" 'OpenRGB Windows 64-bit'
|
||||
- _fold_final_
|
||||
# cache:
|
||||
# key: same-key
|
||||
# paths:
|
||||
# - C:\vcpkg\installed\
|
||||
artifacts:
|
||||
paths:
|
||||
- _build/*.7z
|
||||
expire_in: 30 days
|
||||
@@ -1,14 +0,0 @@
|
||||
<!--
|
||||
Found a bug? Something isn't working as expected? To help us keep track of the requests please start the title with [Bug Report]
|
||||
-->
|
||||
|
||||
### Description of Bug
|
||||
<!--
|
||||
Please describe the bug. Explain steps taken to reproduce the bug and what you expect the correct behavior to be.
|
||||
-->
|
||||
|
||||
|
||||
### Hardware Configuration
|
||||
<!--
|
||||
Please list the RGB hardware that you are using with OpenRGB. If your bug does not relate to any one particular device or device type, or if the bug is in a part of the code not directly interacting with hardware, this is optional.
|
||||
-->
|
||||
@@ -1,9 +0,0 @@
|
||||
<!--
|
||||
Have something you would like to see added to OpenRGB? Let us know here
|
||||
To help us keep track of the requests please start the title with [Feature Request]
|
||||
-->
|
||||
|
||||
### Feature Request
|
||||
<!--
|
||||
Please explain the new feature you would like to see added in detail. Explain how you think it should work and provide any mock-ups, code snippets, etc. that you think will help explain the feature.
|
||||
-->
|
||||
@@ -1,48 +0,0 @@
|
||||
<!--
|
||||
When naming the support request please title the request as
|
||||
`[New Device] <Name of new device>`
|
||||
Please open one issue per device you would lke to add
|
||||
-->
|
||||
|
||||
### Name of device:
|
||||
<!--
|
||||
Please put the name of the product, including manufacturer, beneath this line
|
||||
-->
|
||||
|
||||
|
||||
### Link to manufacturer's product page:
|
||||
<!--
|
||||
Please link us to the manufacturer's product page beneath this line
|
||||
-->
|
||||
|
||||
|
||||
### Please select what type of device/interface the device uses:
|
||||
<!--
|
||||
Place an x between the brackets to check the box
|
||||
-->
|
||||
- [ ] Motherboard (SMBus)
|
||||
- [ ] Motherboard (USB)
|
||||
- [ ] RAM (SMBus)
|
||||
- [ ] GPU (I2C)
|
||||
- [ ] External USB (Peripheral, lighting controller, etc)
|
||||
- [ ] Internal USB (lighting controller, cooler, fan hub, etc)
|
||||
- [ ] I don't know (we can help you determine this)
|
||||
|
||||
### ID information:
|
||||
<!--
|
||||
For PCI (GPU) devices we will need the Vendor ID, Device ID, Sub-Vendor ID and Sub-Device IDs
|
||||
In Windows this can be found under the device manager and on Linux this can be found with lspci -vv
|
||||
For USB devices we will need the USB VID and PID
|
||||
-->
|
||||
|
||||
|
||||
### Please attach screenshots of the device's official control application here:
|
||||
<!--
|
||||
Screenshots of the official control software should show lists of supported modes, color selection, and zone/LED selection capabilities of the device's official software.
|
||||
-->
|
||||
|
||||
|
||||
### Please attach device captures here:
|
||||
<!--
|
||||
For information on how to capture device packets please see https://gitlab.com/Dr_No/OpenRGB/-/wikis/OpenRGB-doesn%27t-have-my-device
|
||||
-->
|
||||
@@ -1,3 +1,6 @@
|
||||
[submodule "dependencies/libe131"]
|
||||
path = dependencies/libe131
|
||||
url = https://github.com/CalcProgrammer1/libe131
|
||||
[submodule "razer-drivers-win32"]
|
||||
path = razer-drivers-win32
|
||||
url = https://github.com/rsandoz/razer-drivers-win32
|
||||
|
||||
@@ -1,334 +0,0 @@
|
||||
#---------------------------------------------------------------#
|
||||
# OpenRGB udev rules #
|
||||
# #
|
||||
# Adam Honse (CalcProgrammer1) 5/29/2020 #
|
||||
#---------------------------------------------------------------#
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# User I2C/SMBus Access #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="i2c-[0-99]*", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# User hidraw Access #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# AMD Wraith Prism #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0051", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Aorus Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1044", ATTR{idProduct}=="7a42", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS Aura Core Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1854", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1869", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1866", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS Aura USB Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1867", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1872", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1889", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18a3", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18f3", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Cooler Master Peripheral Devices #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# Cooler Master MP750 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0109", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Corsair Hydro Series Devices #
|
||||
# #
|
||||
# Corsair H100i Pro RGB #
|
||||
# Corsair H115i Pro RGB #
|
||||
# Corsair H150i Pro RGB #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c15", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c13", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c12", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Corsair Lighting Node Devices #
|
||||
# #
|
||||
# Corsair Lighting Node Core #
|
||||
# Corsair Lighting Node Pro #
|
||||
# Corsair Commander Pro #
|
||||
# Corsair LS100 #
|
||||
# Corsair 1000D Obsidian #
|
||||
# Corsair Spec Omega RGB #
|
||||
# Corsair LT100 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c1a", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c0b", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c10", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c1e", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1d00", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1d04", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0a32", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Corsair Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# Corsair K55 RGB #
|
||||
# Corsair K65 RGB #
|
||||
# Corsair K65 RGB Lux #
|
||||
# Corsair K65 RGB Rapidfire #
|
||||
# Corsair K68 RGB #
|
||||
# Corsair K70 RGB #
|
||||
# Corsair K70 RGB Lux #
|
||||
# Corsair K70 RGB Rapidfire #
|
||||
# Corsair K70 RGB MK2 #
|
||||
# Corsair K70 RGB MK2 SE #
|
||||
# Corsair K70 RGB MK2 LP #
|
||||
# Corsair K95 RGB #
|
||||
# Corsair K95 Platinum #
|
||||
# Corsair Strafe #
|
||||
# Corsair Strafe MK2 #
|
||||
# #
|
||||
# Mice: #
|
||||
# Corsair M65 Pro #
|
||||
# Corsair M65 RGB Elite #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# Corsair MM800 RGB Polaris #
|
||||
# #
|
||||
# Headset Stands: #
|
||||
# Corsair ST100 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b3d", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b17", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b37", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b39", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b4f", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b13", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b33", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b38", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b49", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b6b", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b55", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b11", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b2d", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b20", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b48", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b2e", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b5a", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b3b", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0a34", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# HyperX Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# HyperX Alloy Elite #
|
||||
# #
|
||||
# Mice: #
|
||||
# HyperX Pulsefire Surge #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# HyperX Fury Ultra #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0951", ATTR{idProduct}=="16be", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0951", ATTR{idProduct}=="16d3", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0951", ATTR{idProduct}=="1705", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Logitech Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# Logitech G213 #
|
||||
# Logitech G512 #
|
||||
# Logitech G512 RGB #
|
||||
# Logitech G610 #
|
||||
# Logitech G810 #1 #
|
||||
# Logitech G810 #2 #
|
||||
# #
|
||||
# Mice: #
|
||||
# Logitech G203 Prodigy #
|
||||
# Logitech G203 Lightsync #
|
||||
# Logitech G403 Prodigy #
|
||||
# Logitech G403 Hero #
|
||||
# Logitech G502 Proteus Spectrum #
|
||||
# Logitech G Lightspeed Wireless Gaming Mouse #
|
||||
# Logitech G Pro Wireless Gaming Mouse (Wired) #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# Logitech G Powerplay Mousepad with Lightspeed #
|
||||
# #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c336", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c342", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c33c", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c333", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c331", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c337", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c084", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c092", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c083", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08f", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c332", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08b", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c539", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c088", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c53a", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# MSI Mysticlight #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="3EA4", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="4559", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B10", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B93", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B94", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B96", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C34", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C35", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C36", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C37", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C42", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C56", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C59", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C60", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C67", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C70", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C71", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C73", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C75", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C76", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C77", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C79", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C80", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C81", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C82", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C83", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C84", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C85", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C86", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C87", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C88", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C89", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C90", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C91", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C92", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C94", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C95", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C96", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C98", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C99", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="905D", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# MSI/SteelSeries 3-Zone Laptop Keyboard #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1770", ATTR{idProduct}=="FF00", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# NZXT Hue+ #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="ttyACM[0-9]*", ATTR{idVendor}=="04D8", ATTR{idProduct}=="00DF", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# NZXT Hue 2 Devices #
|
||||
# #
|
||||
# NZXT Hue 2 #
|
||||
# NZXT Smart Device V2 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2001", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2006", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# NZXT Kraken #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="170e", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Redragon Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# Redragon K550 Yama #
|
||||
# Redragon K552 Kumara #
|
||||
# Redragon K556 Devarajas #
|
||||
# Tecware Phantom Elite #
|
||||
# #
|
||||
# Mice: #
|
||||
# Redragon M711 Cobra #
|
||||
# Redragon M715 Dagger #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5204", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5104", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5004", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="652f", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc30", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc39", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc4d", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Gigabyte/Aorus RGB Fusion 2 USB #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="8297", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="5702", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Sinowealth USB #
|
||||
# Glorious Model O / O- #
|
||||
# Glorious Model D / D- #
|
||||
# Everest GT-100 RGB #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0036", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0033", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="258a", ATTR{idProduct}=="0029", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# SteelSeries Peripheral Devices #
|
||||
# #
|
||||
# Mice: #
|
||||
# SteelSeries Rival 100 #
|
||||
# SteelSeries Rival 100 DotA 2 Edition #
|
||||
# SteelSeries Rival 105 #
|
||||
# SteelSeries Rival 110 #
|
||||
# SteelSeries Rival 300 #
|
||||
# Acer Predator Gaming Mouse (Rival 300) #
|
||||
# SteelSeries Rival 300 CS:GO Fade Edition #
|
||||
# SteelSeries Rival 300 CS:GO Fade Edition (stm32) #
|
||||
# SteelSeries Rival 300 CS:GO Hyperbeast Edition #
|
||||
# SteelSeries Rival 300 Dota 2 Edition #
|
||||
# SteelSeries Rival 300 HP Omen Edition #
|
||||
# Headsets: #
|
||||
# SteelSeries Siberia 350 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1702", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="170c", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1814", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1729", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1384", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1714", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1394", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1716", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="171a", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1392", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1718", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1229", TAG+="uaccess"
|
||||
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Thermaltake Poseidon Z RGB Keyboard #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="3006", TAG+="uaccess"
|
||||
@@ -12,10 +12,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle, const char* path)
|
||||
AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
dev = dev_handle;
|
||||
|
||||
strcpy(device_name, "AMD Wraith Prism");
|
||||
|
||||
@@ -39,34 +38,17 @@ AMDWraithPrismController::~AMDWraithPrismController()
|
||||
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetLocationString()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
char* AMDWraithPrismController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetEffectChannelString(unsigned char channel)
|
||||
{
|
||||
std::string ret_string = "";
|
||||
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x40, 0x21, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
@@ -85,10 +67,12 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
usb_buf[0x03] = channel;
|
||||
int actual;
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
usb_buf[0x02] = channel;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
|
||||
ret_string.append((char *)&usb_buf[0x08]);
|
||||
|
||||
@@ -101,7 +85,6 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x12, 0x20, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
@@ -120,10 +103,11 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
unsigned char fw_buf[16] = {0x00};
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
|
||||
for(int char_idx = 0; char_idx < 16; char_idx+=2)
|
||||
{
|
||||
@@ -225,7 +209,6 @@ void AMDWraithPrismController::SendEnableCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x41, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
@@ -244,15 +227,16 @@ void AMDWraithPrismController::SendEnableCommand()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
int actual;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendApplyCommand()
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x51, 0x28, 0x00, 0x00,
|
||||
0xE0, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
@@ -271,8 +255,10 @@ void AMDWraithPrismController::SendApplyCommand()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
int actual;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
@@ -290,7 +276,6 @@ void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x51, 0x2C, 0x01, 0x00,
|
||||
0x05, 0xFF, 0x00, 0x01,
|
||||
0xFF, 0xFF, 0x00, 0xFF,
|
||||
@@ -309,26 +294,27 @@ void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
usb_buf[0x05] = effect_channel;
|
||||
usb_buf[0x06] = speed;
|
||||
usb_buf[0x07] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
|
||||
usb_buf[0x08] = mode;
|
||||
int actual;
|
||||
|
||||
usb_buf[0x0A] = brightness;
|
||||
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[0x0B] = red;
|
||||
usb_buf[0x0C] = green;
|
||||
usb_buf[0x0D] = blue;
|
||||
usb_buf[0x09] = brightness;
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
usb_buf[0x0A] = red;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
|
||||
{
|
||||
unsigned char usb_buf[] =
|
||||
{
|
||||
0x00,
|
||||
0x51, 0xA0, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00,
|
||||
0x05, 0x06, 0x07, 0x07,
|
||||
@@ -347,14 +333,16 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
usb_buf[0x09] = logo_channel;
|
||||
usb_buf[0x0A] = fan_channel;
|
||||
int actual;
|
||||
|
||||
for(int led = 0x0B; led <= 0x19; led++)
|
||||
usb_buf[0x08] = logo_channel;
|
||||
usb_buf[0x09] = fan_channel;
|
||||
|
||||
for(int led = 0x0A; led <= 0x18; led++)
|
||||
{
|
||||
usb_buf[led] = ring_channel;
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -109,15 +109,13 @@ enum
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
AMDWraithPrismController(hid_device* dev_handle, const char* path);
|
||||
AMDWraithPrismController(libusb_device_handle* dev_handle);
|
||||
~AMDWraithPrismController();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
std::string GetEffectChannelString(unsigned char channel);
|
||||
std::string GetFirmwareVersionString();
|
||||
std::string GetLocationString();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetRingEffectChannel(unsigned char channel);
|
||||
|
||||
@@ -132,8 +130,7 @@ public:
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
libusb_device_handle* dev;
|
||||
|
||||
unsigned char current_fan_mode;
|
||||
unsigned char current_fan_speed;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "Detector.h"
|
||||
#include "AMDWraithPrismController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AMDWraithPrism.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define AMD_WRAITH_PRISM_VID 0x2516
|
||||
#define AMD_WRAITH_PRISM_PID 0x0051
|
||||
@@ -15,16 +15,23 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAMDWraithPrismControllers(hid_device_info* info, const std::string&)
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for AMD Wraith Prism
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path);
|
||||
libusb_detach_kernel_driver(dev, 1);
|
||||
libusb_claim_interface(dev, 1);
|
||||
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
|
||||
|
||||
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IP("AMD Wraith Prism", DetectAMDWraithPrismControllers, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID, 1, 0xFF00);
|
||||
|
||||
@@ -1,342 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| ASRockPolychromeSMBusController.cpp |
|
||||
| |
|
||||
| Driver for for ASRock ASR LED and |
|
||||
| Polychrome RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/14/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "ASRockPolychromeSMBusController.h"
|
||||
#include <cstring>
|
||||
#include "dependencies/dmiinfo.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
DMIInfo dmi;
|
||||
|
||||
unsigned short fw_version = ReadFirmwareVersion();
|
||||
unsigned char major_version = fw_version >> 8;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine whether the device uses ASR LED or |
|
||||
| Polychrome protocol by checking firmware version. |
|
||||
| Versions 1.xx and 2.xx use ASR LED, 3.xx uses |
|
||||
| Polychrome |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(major_version)
|
||||
{
|
||||
case ASROCK_TYPE_ASRLED:
|
||||
device_name = "ASRock " + dmi.getMainboard();
|
||||
asrock_type = ASROCK_TYPE_ASRLED;
|
||||
memset(zone_led_count, 0, sizeof(zone_led_count));
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V1:
|
||||
device_name = "ASRock " + dmi.getMainboard();
|
||||
asrock_type = ASROCK_TYPE_POLYCHROME_V1;
|
||||
ReadLEDConfiguration();
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V2:
|
||||
device_name = "ASRock " + dmi.getMainboard();
|
||||
asrock_type = ASROCK_TYPE_POLYCHROME_V2;
|
||||
ReadLEDConfiguration();
|
||||
break;
|
||||
|
||||
default:
|
||||
asrock_type = ASROCK_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PolychromeController::~PolychromeController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int PolychromeController::GetASRockType()
|
||||
{
|
||||
return(asrock_type);
|
||||
}
|
||||
|
||||
std::string PolychromeController::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("I2C: " + return_string);
|
||||
}
|
||||
|
||||
std::string PolychromeController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string PolychromeController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned short fw_version = ReadFirmwareVersion();
|
||||
unsigned char major_version = fw_version >> 8;
|
||||
unsigned char minor_version = fw_version & 0xFF;
|
||||
|
||||
return(std::to_string(major_version) + "." + std::to_string(minor_version));
|
||||
}
|
||||
|
||||
unsigned short PolychromeController::ReadFirmwareVersion()
|
||||
{
|
||||
// The firmware register holds two bytes, so the first read should return 2
|
||||
// If not, report invalid firmware revision FFFF
|
||||
if (bus->i2c_smbus_read_byte_data(dev, ASROCK_REG_FIRMWARE_VER) == 0x02)
|
||||
{
|
||||
std::this_thread::sleep_for(1ms);
|
||||
unsigned char major = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
unsigned char minor = bus->i2c_smbus_read_byte(dev);
|
||||
|
||||
return((major << 8) | minor);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::ReadLEDConfiguration()
|
||||
{
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
| The LED configuration register holds 6 bytes, so the first read should return 6 |
|
||||
| If not, set all zone sizes to zero |
|
||||
\*---------------------------------------------------------------------------------*/
|
||||
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_LED_CONFIG) == 0x06)
|
||||
{
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_1] = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_2] = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_3] = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_4] = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_5] = bus->i2c_smbus_read_byte(dev);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = bus->i2c_smbus_read_byte(dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(zone_led_count, 0, sizeof(zone_led_count));
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PolychromeController::GetMode()
|
||||
{
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char color_speed_pkt[4] = { red, green, blue, active_speed };
|
||||
unsigned char select_led_pkt[1] = { led };
|
||||
|
||||
switch(asrock_type)
|
||||
{
|
||||
case ASROCK_TYPE_ASRLED:
|
||||
/*-----------------------------------------------------*\
|
||||
| Select LED |
|
||||
\*-----------------------------------------------------*/
|
||||
if(active_mode != ASRLED_MODE_OFF)
|
||||
{
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
switch(active_mode)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes take 4 bytes in R/G/B/S order |
|
||||
\*-----------------------------------------------------*/
|
||||
case ASRLED_MODE_BREATHING:
|
||||
case ASRLED_MODE_STROBE:
|
||||
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, &active_speed);
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes take no bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
case ASRLED_MODE_OFF:
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V1:
|
||||
/*-----------------------------------------------------*\
|
||||
| Select LED |
|
||||
\*-----------------------------------------------------*/
|
||||
if(active_mode != ASRLED_MODE_OFF)
|
||||
{
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
switch(active_mode)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes take 4 bytes in R/G/B/S order |
|
||||
\*-----------------------------------------------------*/
|
||||
case POLYCHROME_V1_MODE_BREATHING:
|
||||
case POLYCHROME_V1_MODE_STROBE:
|
||||
case POLYCHROME_V1_MODE_SPECTRUM_CYCLE:
|
||||
case POLYCHROME_V1_MODE_SPRING:
|
||||
case POLYCHROME_V1_MODE_METEOR:
|
||||
case POLYCHROME_V1_MODE_STACK:
|
||||
case POLYCHROME_V1_MODE_CRAM:
|
||||
case POLYCHROME_V1_MODE_SCAN:
|
||||
case POLYCHROME_V1_MODE_NEON:
|
||||
case POLYCHROME_V1_MODE_WATER:
|
||||
|
||||
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 POLYCHROME_V1_MODE_STATIC:
|
||||
case POLYCHROME_V1_MODE_MUSIC:
|
||||
bus->i2c_smbus_write_block_data(dev, active_mode, 3, color_speed_pkt);
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes take 1 byte - speed |
|
||||
\*-----------------------------------------------------*/
|
||||
case POLYCHROME_V1_MODE_RANDOM:
|
||||
case POLYCHROME_V1_MODE_WAVE:
|
||||
case POLYCHROME_V1_MODE_RAINBOW:
|
||||
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &active_speed);
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes take no bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
case POLYCHROME_V1_MODE_OFF:
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V2:
|
||||
/*-----------------------------------------------------*\
|
||||
| Select LED |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(active_mode)
|
||||
{
|
||||
case POLYCHROME_V2_MODE_OFF:
|
||||
case POLYCHROME_V2_MODE_RAINBOW:
|
||||
case POLYCHROME_V2_MODE_SPECTRUM_CYCLE:
|
||||
break;
|
||||
|
||||
default:
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Polychrome firmware always writes color to fixed reg |
|
||||
\*-----------------------------------------------------*/
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V2_REG_COLOR, 3, color_speed_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetMode(unsigned char zone,unsigned char mode, unsigned char speed)
|
||||
{
|
||||
unsigned char led_count_pkt[1] = { 0x00 };
|
||||
active_zone = zone;
|
||||
active_mode = mode;
|
||||
active_speed = speed;
|
||||
|
||||
switch(asrock_type)
|
||||
{
|
||||
case ASROCK_TYPE_ASRLED:
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V1:
|
||||
/*-----------------------------------------------------*\
|
||||
| Make sure set all register is set to 0 |
|
||||
\*-----------------------------------------------------*/
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 1, led_count_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the zone we are working on |
|
||||
\*-----------------------------------------------------*/
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, &active_zone);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Write the mode |
|
||||
\*-----------------------------------------------------*/
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V2:
|
||||
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Select a single LED |
|
||||
\*-----------------------------------------------------*/
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V2_REG_LED_COUNT, 0, led_count_pkt);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
switch(active_mode)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| These modes don't take a speed |
|
||||
\*-----------------------------------------------------*/
|
||||
case POLYCHROME_V2_MODE_OFF:
|
||||
case POLYCHROME_V2_MODE_STATIC:
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| All other modes, write speed to active mode register |
|
||||
\*-----------------------------------------------------*/
|
||||
default:
|
||||
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &speed);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,221 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| ASRockPolychromeSMBusController.h |
|
||||
| |
|
||||
| Definitions and types for ASRock |
|
||||
| ASR LED and Polychrome RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
#include <string>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char polychrome_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
ASROCK_TYPE_UNKNOWN = 0x00, /* Unknown Type or Not ASRock Device */
|
||||
ASROCK_TYPE_ASRLED = 0x01, /* ASRock Firmware 1.x - ASR LED */
|
||||
ASROCK_TYPE_POLYCHROME_V1 = 0x02, /* ASRock Firmware 2.x - Polychrome V1 */
|
||||
ASROCK_TYPE_POLYCHROME_V2 = 0x03, /* ASRock Firmware 3.x - Polychrome V2 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| ASRock Common Registers |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
ASROCK_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
ASROCK_REG_MODE = 0x30, /* Mode selection register */
|
||||
ASROCK_REG_LED_SELECT = 0x31, /* LED selection register */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| ASRock Polychrome V1/V2 Common Registers |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_REG_LED_CONFIG = 0x33, /* LED configuration register */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| ASRock Polychrome V1 (Firmware 2.x) Registers |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_REG_SET_ALL = 0x32, /* Set All register 0x1 = set all */
|
||||
POLYCHROME_V1_REG_ARGB_GRB = 0x35, /* ARGB bistream reversing register */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| ASRock Polychrome V2 (Firmware 3.x) Registers |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V2_REG_LED_COUNT = 0x32, /* Additional LED count register */
|
||||
POLYCHROME_V2_REG_COLOR = 0x34, /* Color register: Red, Green, Blue */
|
||||
POLYCHROME_V2_REG_ARGB_GRB = 0x35, /* ARGB bistream reversing register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_ZONE_1 = 0x00, /* RGB LED 1 Header */
|
||||
POLYCHROME_ZONE_2 = 0x01, /* RGB LED 2 Header */
|
||||
POLYCHROME_ZONE_3 = 0x02, /* Audio/PCH Zone LEDs */
|
||||
POLYCHROME_ZONE_4 = 0x03, /* Audio/PCH Zone LEDs */
|
||||
POLYCHROME_ZONE_5 = 0x04, /* IO Cover Zone LEDs */
|
||||
POLYCHROME_ZONE_ADDRESSABLE = 0x05, /* Addressable LED header */
|
||||
POLYCHROME_ZONE_COUNT = 0x06, /* Total number of zones */
|
||||
POLYCHROME_ZONE_ADDRESSABLE_MAX = 0x64, /* Maxinum number of ARGB LEDs */
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
| Definitions for ASR LED |
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
#define ASRLED_NUM_MODES 8 /* Number of ASR LED modes */
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_MODE_OFF = 0x10, /* OFF mode */
|
||||
ASRLED_MODE_STATIC = 0x11, /* Static color mode */
|
||||
ASRLED_MODE_BREATHING = 0x12, /* Breathing effect mode */
|
||||
ASRLED_MODE_STROBE = 0x13, /* Strobe effect mode */
|
||||
ASRLED_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
ASRLED_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
ASRLED_MODE_MUSIC = 0x17, /* Music effect mode */
|
||||
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 */
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
| Definitions for Polychrome V1 |
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
#define POLYCHROME_V1_NUM_MODES 16 /* Number of Polychrome V1 modes */
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_V1_MODE_OFF = 0x10, /* OFF mode */
|
||||
POLYCHROME_V1_MODE_STATIC = 0x11, /* Static color mode */
|
||||
POLYCHROME_V1_MODE_BREATHING = 0x12, /* Breating effect mode */
|
||||
POLYCHROME_V1_MODE_STROBE = 0x13, /* Strobe effect mode */
|
||||
POLYCHROME_V1_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
POLYCHROME_V1_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
POLYCHROME_V1_MODE_MUSIC = 0x17, /* Music effect mode */
|
||||
POLYCHROME_V1_MODE_WAVE = 0x18, /* Wave effect mode */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| Modes only available on ARGB headers |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_MODE_SPRING = 0x19, /* Spring effect mode */
|
||||
POLYCHROME_V1_MODE_METEOR = 0x1A, /* Meteor effect mode */
|
||||
POLYCHROME_V1_MODE_STACK = 0x1B, /* Stack effect mode */
|
||||
POLYCHROME_V1_MODE_CRAM = 0x1C, /* Cram effect mode */
|
||||
POLYCHROME_V1_MODE_SCAN = 0x1D, /* Scan effect mode */
|
||||
POLYCHROME_V1_MODE_NEON = 0x1E, /* Neon effect mode */
|
||||
POLYCHROME_V1_MODE_WATER = 0x1F, /* Water effect mode */
|
||||
POLYCHROME_V1_MODE_RAINBOW = 0x20, /* Rainbow chase effect mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_BREATHING |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_BREATHING = 0x0A, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_BREATHING = 0x02, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_BREATHING = 0x02, /* Fastest speed */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_STROBE |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_STROBE = 0xA0, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_STROBE = 0x14, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_STROBE = 0x05, /* Fastest speed */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_SPECTRUM_CYCLE |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_CYCLE = 0xA0, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_CYCLE = 0x14, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_CYCLE = 0x0A, /* Fastest speed */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_RANDOM |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_RANDOM = 0xA0, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_RANDOM = 0x28, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_RANDOM = 0x05, /* Fastest speed */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_WAVE |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_WAVE = 0x06, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_WAVE = 0x02, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_WAVE = 0x01, /* Fastest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_SPRING = 0x04, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_METEOR = 0x0A, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_STACK = 0x04, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_CRAM = 0x04, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_SCAN = 0x0A, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_NEON = 0x20, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_WATER = 0x0A, /* Default speed */
|
||||
/*------------------------------------------------------------------------------------------*\
|
||||
| POLYCHROME_V1_MODE_RAINBOW |
|
||||
\*------------------------------------------------------------------------------------------*/
|
||||
POLYCHROME_V1_SPEED_MIN_RAINBOW = 0x12, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_DEFAULT_RAINBOW = 0x0A, /* Default speed */
|
||||
POLYCHROME_V1_SPEED_MAX_RAINBOW = 0x01, /* Fastest speed */
|
||||
POLYCHROME_V1_SPEED_MIN_ARGB = 0x20, /* Slowest speed */
|
||||
POLYCHROME_V1_SPEED_MAX_ARGB = 0x02, /* Fastest speed */
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
| Definitions for Polychrome V2 |
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
#define POLYCHROME_V2_NUM_MODES 14 /* Number of Polychrome V2 modes */
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_V2_MODE_OFF = 0x10, /* OFF mode */
|
||||
POLYCHROME_V2_MODE_STATIC = 0x11, /* Static color mode */
|
||||
POLYCHROME_V2_MODE_BREATHING = 0x12, /* Breating effect mode */
|
||||
POLYCHROME_V2_MODE_STROBE = 0x13, /* Strobe effect mode */
|
||||
POLYCHROME_V2_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
POLYCHROME_V2_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
POLYCHROME_V2_MODE_WAVE = 0x17, /* Wave effect mode */
|
||||
POLYCHROME_V2_MODE_SPRING = 0x18, /* Spring effect mode */
|
||||
POLYCHROME_V2_MODE_STACK = 0x19, /* Stack effect mode */
|
||||
POLYCHROME_V2_MODE_CRAM = 0x1A, /* Cram effect mode */
|
||||
POLYCHROME_V2_MODE_SCAN = 0x1B, /* Scan effect mode */
|
||||
POLYCHROME_V2_MODE_NEON = 0x1C, /* Neon effect mode */
|
||||
POLYCHROME_V2_MODE_WATER = 0x1D, /* Water effect mode */
|
||||
POLYCHROME_V2_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_V2_SPEED_MIN = 0x05, /* Slowest speed */
|
||||
POLYCHROME_V2_SPEED_DEFAULT = 0x03, /* Default speed */
|
||||
POLYCHROME_V2_SPEED_MAX = 0x00, /* Fastest speed */
|
||||
};
|
||||
|
||||
class PolychromeController
|
||||
{
|
||||
public:
|
||||
PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev);
|
||||
~PolychromeController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetFirmwareVersion();
|
||||
unsigned int GetMode();
|
||||
unsigned int GetASRockType();
|
||||
void SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char zone, unsigned char mode, unsigned char speed);
|
||||
|
||||
unsigned char zone_led_count[6];
|
||||
|
||||
private:
|
||||
unsigned int asrock_type;
|
||||
std::string device_name;
|
||||
unsigned char active_zone;
|
||||
unsigned char active_mode;
|
||||
unsigned char active_speed;
|
||||
i2c_smbus_interface* bus;
|
||||
polychrome_dev_id dev;
|
||||
|
||||
unsigned short ReadFirmwareVersion();
|
||||
void ReadLEDConfiguration();
|
||||
};
|
||||
@@ -1,635 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_ASRockPolychromeSMBus.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock ASR LED and Polychrome RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_ASRockPolychromeSMBus.h"
|
||||
|
||||
#define ASROCK_MAX_ZONES 4
|
||||
#define ASROCK_MAX_LEDS 22
|
||||
|
||||
static const char* polychrome_v1_zone_names[] =
|
||||
{
|
||||
"RGB LED 1 Header",
|
||||
"RGB LED 2 Header",
|
||||
"PCH",
|
||||
"IO Cover",
|
||||
"Audio",
|
||||
"Addressable Header"
|
||||
};
|
||||
|
||||
static const char* polychrome_v2_zone_names[] =
|
||||
{
|
||||
"RGB LED 1 Header",
|
||||
"RGB LED 2 Header",
|
||||
"Audio",
|
||||
"PCH",
|
||||
"IO Cover",
|
||||
"Addressable Header"
|
||||
};
|
||||
|
||||
RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychrome_ptr)
|
||||
{
|
||||
polychrome = polychrome_ptr;
|
||||
|
||||
name = polychrome->GetDeviceName();
|
||||
vendor = "ASRock";
|
||||
version = polychrome->GetFirmwareVersion();
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
location = polychrome->GetDeviceLocation();
|
||||
|
||||
switch(polychrome->GetASRockType())
|
||||
{
|
||||
case ASROCK_TYPE_ASRLED:
|
||||
{
|
||||
description = "ASRock ASR LED Device";
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = ASRLED_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = ASRLED_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
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);
|
||||
|
||||
mode Strobe;
|
||||
Strobe.name = "Strobe";
|
||||
Strobe.value = ASRLED_MODE_STROBE;
|
||||
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);
|
||||
|
||||
mode SpectrumCycle;
|
||||
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);
|
||||
|
||||
mode Random;
|
||||
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);
|
||||
|
||||
mode Music;
|
||||
Music.name = "Music";
|
||||
Music.value = ASRLED_MODE_MUSIC;
|
||||
Music.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Music.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Music);
|
||||
|
||||
mode Wave;
|
||||
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);
|
||||
}
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V1:
|
||||
{
|
||||
description = "ASRock Polychrome v1 Device";
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = POLYCHROME_V1_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = POLYCHROME_V1_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = POLYCHROME_V1_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = POLYCHROME_V1_SPEED_MIN_BREATHING;
|
||||
Breathing.speed_max = POLYCHROME_V1_SPEED_MAX_BREATHING;
|
||||
Breathing.speed = POLYCHROME_V1_SPEED_DEFAULT_BREATHING;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Strobe;
|
||||
Strobe.name = "Strobe";
|
||||
Strobe.value = POLYCHROME_V1_MODE_STROBE;
|
||||
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Strobe.speed_min = POLYCHROME_V1_SPEED_MIN_STROBE;
|
||||
Strobe.speed_max = POLYCHROME_V1_SPEED_MAX_STROBE;
|
||||
Strobe.speed = POLYCHROME_V1_SPEED_DEFAULT_STROBE;
|
||||
Strobe.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Strobe);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = POLYCHROME_V1_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = POLYCHROME_V1_SPEED_MIN_CYCLE;
|
||||
SpectrumCycle.speed_max = POLYCHROME_V1_SPEED_MAX_CYCLE;
|
||||
SpectrumCycle.speed = POLYCHROME_V1_SPEED_DEFAULT_CYCLE;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Random;
|
||||
Random.name = "Random";
|
||||
Random.value = POLYCHROME_V1_MODE_RANDOM;
|
||||
Random.flags = MODE_FLAG_HAS_SPEED;
|
||||
Random.speed_min = POLYCHROME_V1_SPEED_MIN_RANDOM;
|
||||
Random.speed_max = POLYCHROME_V1_SPEED_MAX_RANDOM;
|
||||
Random.speed = POLYCHROME_V1_SPEED_DEFAULT_RANDOM;
|
||||
Random.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Random);
|
||||
|
||||
mode Music;
|
||||
Music.name = "Music";
|
||||
Music.value = POLYCHROME_V1_MODE_MUSIC;
|
||||
Music.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Music.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Music);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = POLYCHROME_V1_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED;
|
||||
Wave.speed_min = POLYCHROME_V1_SPEED_MIN_WAVE;
|
||||
Wave.speed_max = POLYCHROME_V1_SPEED_MAX_WAVE;
|
||||
Wave.speed = POLYCHROME_V1_SPEED_DEFAULT_WAVE;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Wave);
|
||||
|
||||
/*---------------------------------------------------------------------*\
|
||||
| Comment out until per zone modes are working. These are only for ARGB |
|
||||
\*---------------------------------------------------------------------*/
|
||||
// mode Spring;
|
||||
// Spring.name = "Spring";
|
||||
// Spring.value = POLYCHROME_V1_MODE_SPRING;
|
||||
// Spring.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Spring.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Spring.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Spring.speed = POLYCHROME_V1_SPEED_DEFAULT_SPRING;
|
||||
// Spring.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Spring);
|
||||
|
||||
// mode Stack;
|
||||
// Stack.name = "Stack";
|
||||
// Stack.value = POLYCHROME_V1_MODE_STACK;
|
||||
// Stack.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Stack.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Stack.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Stack.speed = POLYCHROME_V1_SPEED_DEFAULT_STACK;
|
||||
// Stack.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Stack);
|
||||
|
||||
// mode Cram;
|
||||
// Cram.name = "Cram";
|
||||
// Cram.value = POLYCHROME_V1_MODE_CRAM;
|
||||
// Cram.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Cram.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Cram.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Cram.speed = POLYCHROME_V1_SPEED_DEFAULT_CRAM;
|
||||
// Cram.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Cram);
|
||||
|
||||
// mode Scan;
|
||||
// Scan.name = "Scan";
|
||||
// Scan.value = POLYCHROME_V1_MODE_SCAN;
|
||||
// Scan.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Scan.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Scan.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Scan.speed = POLYCHROME_V1_SPEED_DEFAULT_SCAN;
|
||||
// Scan.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Scan);
|
||||
|
||||
// mode Neon;
|
||||
// Neon.name = "Neon";
|
||||
// Neon.value = POLYCHROME_V1_MODE_NEON;
|
||||
// Neon.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Neon.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Neon.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Neon.speed = POLYCHROME_V1_SPEED_DEFAULT_NEON;
|
||||
// Neon.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Neon);
|
||||
|
||||
// mode Water;
|
||||
// Water.name = "Water";
|
||||
// Water.value = POLYCHROME_V1_MODE_WATER;
|
||||
// Water.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Water.speed_min = POLYCHROME_V1_SPEED_MIN_ARGB;
|
||||
// Water.speed_max = POLYCHROME_V1_SPEED_MAX_ARGB;
|
||||
// Water.speed = POLYCHROME_V1_SPEED_DEFAULT_WATER;
|
||||
// Water.color_mode = MODE_COLORS_PER_LED;
|
||||
// modes.push_back(Water);
|
||||
|
||||
// mode Rainbow;
|
||||
// Rainbow.name = "Rainbow";
|
||||
// Rainbow.value = POLYCHROME_V1_MODE_RAINBOW;
|
||||
// Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
// Rainbow.speed_min = POLYCHROME_V1_SPEED_MIN_RAINBOW;
|
||||
// Rainbow.speed_max = POLYCHROME_V1_SPEED_MAX_RAINBOW;
|
||||
// Rainbow.speed = POLYCHROME_V1_SPEED_DEFAULT_RAINBOW;
|
||||
// Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
// modes.push_back(Rainbow);
|
||||
}
|
||||
break;
|
||||
|
||||
case ASROCK_TYPE_POLYCHROME_V2:
|
||||
{
|
||||
description = "ASRock Polychrome v2 Device";
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = POLYCHROME_V2_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = POLYCHROME_V2_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = POLYCHROME_V2_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Breathing.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Breathing.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Strobe;
|
||||
Strobe.name = "Strobe";
|
||||
Strobe.value = POLYCHROME_V2_MODE_STROBE;
|
||||
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Strobe.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Strobe.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Strobe.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Strobe.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Strobe);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = POLYCHROME_V2_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
SpectrumCycle.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
SpectrumCycle.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Random;
|
||||
Random.name = "Random";
|
||||
Random.value = POLYCHROME_V2_MODE_RANDOM;
|
||||
Random.flags = MODE_FLAG_HAS_SPEED;
|
||||
Random.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Random.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Random.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Random.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Random);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = POLYCHROME_V2_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED;
|
||||
Wave.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Wave.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Wave.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Spring;
|
||||
Spring.name = "Spring";
|
||||
Spring.value = POLYCHROME_V2_MODE_SPRING;
|
||||
Spring.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spring.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Spring.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Spring.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Spring.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Spring);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
Stack.value = POLYCHROME_V2_MODE_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_SPEED;
|
||||
Stack.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Stack.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Stack.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Stack.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode Cram;
|
||||
Cram.name = "Cram";
|
||||
Cram.value = POLYCHROME_V2_MODE_CRAM;
|
||||
Cram.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cram.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Cram.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Cram.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Cram.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Cram);
|
||||
|
||||
mode Scan;
|
||||
Scan.name = "Scan";
|
||||
Scan.value = POLYCHROME_V2_MODE_SCAN;
|
||||
Scan.flags = MODE_FLAG_HAS_SPEED;
|
||||
Scan.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Scan.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Scan.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Scan.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Scan);
|
||||
|
||||
mode Neon;
|
||||
Neon.name = "Neon";
|
||||
Neon.value = POLYCHROME_V2_MODE_NEON;
|
||||
Neon.flags = 0;
|
||||
Neon.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Neon);
|
||||
|
||||
mode Water;
|
||||
Water.name = "Water";
|
||||
Water.value = POLYCHROME_V2_MODE_WATER;
|
||||
Water.flags = MODE_FLAG_HAS_SPEED;
|
||||
Water.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Water.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Water.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Water.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Water);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = POLYCHROME_V2_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = POLYCHROME_V2_SPEED_MIN;
|
||||
Rainbow.speed_max = POLYCHROME_V2_SPEED_MAX;
|
||||
Rainbow.speed = POLYCHROME_V2_SPEED_DEFAULT;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetupZones()
|
||||
{
|
||||
switch(polychrome->GetASRockType())
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| ASR LED motherboards only have a single zone/LED |
|
||||
\*---------------------------------------------------------*/
|
||||
case ASROCK_TYPE_ASRLED:
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
zone* new_zone = new zone();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set single zone name to "Motherboard" |
|
||||
\*---------------------------------------------------------*/
|
||||
new_zone->name = "Motherboard";
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
new_zone->leds_min = 1;
|
||||
new_zone->leds_max = 1;
|
||||
new_zone->leds_count = 1;
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new zone to zones vector |
|
||||
\*---------------------------------------------------------*/
|
||||
zones.push_back(*new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
led* new_led = new led();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set single LED name to "Motherboard" |
|
||||
\*---------------------------------------------------------*/
|
||||
new_led->name = "Motherboard";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new LED to LEDs vector |
|
||||
\*---------------------------------------------------------*/
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
break;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Polychrome motherboards should set up zones based on LED |
|
||||
| configuration register read from device |
|
||||
\*---------------------------------------------------------*/
|
||||
case ASROCK_TYPE_POLYCHROME_V1:
|
||||
case ASROCK_TYPE_POLYCHROME_V2:
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_idx = 0; zone_idx < POLYCHROME_ZONE_COUNT; zone_idx++)
|
||||
{
|
||||
if(polychrome->zone_led_count[zone_idx] > 0)
|
||||
{
|
||||
zone* new_zone = new zone();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set zone name to channel name |
|
||||
\*---------------------------------------------------------*/
|
||||
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
|
||||
{
|
||||
new_zone->name = polychrome_v1_zone_names[zone_idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone->name = polychrome_v2_zone_names[zone_idx];
|
||||
}
|
||||
|
||||
if(zone_idx == POLYCHROME_ZONE_ADDRESSABLE)
|
||||
{
|
||||
new_zone->leds_min = 1;
|
||||
new_zone->leds_max = 1;
|
||||
new_zone->leds_count = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone->leds_min = polychrome->zone_led_count[zone_idx];
|
||||
new_zone->leds_max = polychrome->zone_led_count[zone_idx];
|
||||
new_zone->leds_count = polychrome->zone_led_count[zone_idx];
|
||||
}
|
||||
|
||||
if(new_zone->leds_count > 1)
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone->type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
|
||||
new_zone->matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new zone to zones vector |
|
||||
\*---------------------------------------------------------*/
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int led_count = 0;
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_idx = 0; zone_idx < POLYCHROME_ZONE_COUNT; zone_idx++)
|
||||
{
|
||||
if(polychrome->zone_led_count[zone_idx] > 0)
|
||||
{
|
||||
for(unsigned int led_idx = 0; led_idx < polychrome->zone_led_count[zone_idx]; led_idx++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Each zone only has one LED |
|
||||
\*---------------------------------------------------------*/
|
||||
led* new_led = new led();
|
||||
|
||||
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
|
||||
{
|
||||
new_led->name = polychrome_v1_zone_names[zone_idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led->name = polychrome_v2_zone_names[zone_idx];
|
||||
}
|
||||
|
||||
new_led->name.append(" " + std::to_string(led_idx + 1));
|
||||
new_led->value = 0;
|
||||
|
||||
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
|
||||
{
|
||||
new_led->value = zone_idx;
|
||||
}
|
||||
else if(zone_idx == POLYCHROME_ZONE_ADDRESSABLE)
|
||||
{
|
||||
new_led->value = 0x19;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push new LED to LEDs vector |
|
||||
\*---------------------------------------------------------*/
|
||||
leds.push_back(*new_led);
|
||||
|
||||
led_count++;
|
||||
|
||||
if(zone_idx == POLYCHROME_ZONE_ADDRESSABLE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::DeviceUpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
UpdateSingleLED(led);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If the LED value is non-zero, this LED overrides the LED |
|
||||
| index |
|
||||
\*---------------------------------------------------------*/
|
||||
if(leds[led].value != 0)
|
||||
{
|
||||
led = leds[led].value;
|
||||
}
|
||||
|
||||
polychrome->SetColorsAndSpeed(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::DeviceUpdateMode()
|
||||
{
|
||||
if(polychrome->GetASRockType() == ASROCK_TYPE_POLYCHROME_V1)
|
||||
{
|
||||
for(unsigned int led_idx = 0; led_idx <= leds.size(); led_idx++)
|
||||
{
|
||||
polychrome->SetMode(led_idx, modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
polychrome->SetMode(0, modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraCoreController.cpp |
|
||||
| |
|
||||
| Driver for ASUS ROG Aura Core RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraCoreController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraCoreController::AuraCoreController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
AuraCoreController::~AuraCoreController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string AuraCoreController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AuraCoreController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5A;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_BRIGHTNESS;
|
||||
usb_buf[0x02] = 0xC5;
|
||||
usb_buf[0x03] = 0xC4;
|
||||
usb_buf[0x04] = brightness;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_UPDATE;
|
||||
usb_buf[0x02] = zone;
|
||||
usb_buf[0x03] = mode;
|
||||
usb_buf[0x04] = red;
|
||||
usb_buf[0x05] = green;
|
||||
usb_buf[0x06] = blue;
|
||||
usb_buf[0x07] = speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendSet()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_SET;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraCoreController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS ROG Aura |
|
||||
| Core RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_MODE_STATIC = 0, /* Static color mode */
|
||||
AURA_CORE_MODE_BREATHING = 1, /* Breathing effect mode */
|
||||
AURA_CORE_MODE_SPECTRUM_CYCLE = 2, /* Spectrum Cycle mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_COMMAND_UPDATE = 0xB3, /* Update mode and color */
|
||||
AURA_CORE_COMMAND_SET = 0xB5, /* Set command */
|
||||
AURA_CORE_COMMAND_APPLY = 0xB4, /* Apply command */
|
||||
AURA_CORE_COMMAND_BRIGHTNESS = 0xBA, /* Brightness command */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_ZONE_IDX_ALL = 0x00, /* Update all zones */
|
||||
AURA_CORE_ZONE_IDX_1 = 0x01, /* Update zone 1 */
|
||||
AURA_CORE_ZONE_IDX_2 = 0x02, /* Update zone 2 */
|
||||
AURA_CORE_ZONE_IDX_3 = 0x03, /* Update zone 3 */
|
||||
AURA_CORE_ZONE_IDX_4 = 0x04, /* Update zone 4 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_SPEED_SLOW = 0xE1, /* Slowest speed */
|
||||
AURA_CORE_SPEED_NORMAL = 0xEB, /* Normal speed */
|
||||
AURA_CORE_SPEED_FAST = 0xF5, /* Fastest speed */
|
||||
};
|
||||
|
||||
class AuraCoreController
|
||||
{
|
||||
public:
|
||||
AuraCoreController(hid_device* dev_handle, const char* path);
|
||||
~AuraCoreController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
);
|
||||
|
||||
void SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendSet();
|
||||
|
||||
void SendApply();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraCoreController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraCore.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_CORE_VID 0x0B05
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraCoreControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
AuraCoreController* controller = new AuraCoreController(dev, info->path);
|
||||
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1854);
|
||||
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1866);
|
||||
REGISTER_HID_DETECTOR("ASUS Aura Core", DetectAsusAuraCoreControllers, AURA_CORE_VID, 0x1869);
|
||||
@@ -1,111 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraCore.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraCore.h"
|
||||
|
||||
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Core";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "ASUS Aura Core Device";
|
||||
location = aura->GetDeviceLocation();
|
||||
serial = aura->GetSerialString();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_CORE_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_CORE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AURA_CORE_MODE_SPECTRUM_CYCLE;
|
||||
ColorCycle.flags = 0;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupZones()
|
||||
{
|
||||
zone Keyboard;
|
||||
Keyboard.name = "Keyboard";
|
||||
Keyboard.type = ZONE_TYPE_SINGLE;
|
||||
Keyboard.leds_min = 4;
|
||||
Keyboard.leds_max = 4;
|
||||
Keyboard.leds_count = 4;
|
||||
Keyboard.matrix_map = NULL;
|
||||
zones.push_back(Keyboard);
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < Keyboard.leds_count; led_idx++)
|
||||
{
|
||||
led KeyLED;
|
||||
KeyLED.name = "Keyboard LED ";
|
||||
KeyLED.name.append(std::to_string(led_idx + 1));
|
||||
leds.push_back(KeyLED);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::DeviceUpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
UpdateSingleLED(led_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateSingleLED(int led)
|
||||
{
|
||||
aura->SendUpdate
|
||||
(
|
||||
led + 1,
|
||||
modes[active_mode].value,
|
||||
AURA_CORE_SPEED_NORMAL,
|
||||
RGBGetRValue(colors[led]),
|
||||
RGBGetGValue(colors[led]),
|
||||
RGBGetBValue(colors[led])
|
||||
);
|
||||
aura->SendSet();
|
||||
aura->SendApply();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraCore.h |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraCoreController.h"
|
||||
|
||||
class RGBController_AuraCore : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraCore(AuraCoreController* aura_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AuraCoreController* aura;
|
||||
|
||||
};
|
||||
@@ -1,84 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraGPUController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraGPUController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
strcpy(device_name, "ASUS Aura GPU"); // Would be nice to get the actual GPU name. Using this as a placeholder.
|
||||
}
|
||||
|
||||
AuraGPUController::~AuraGPUController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string AuraGPUController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string AuraGPUController::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);
|
||||
}
|
||||
|
||||
unsigned char AuraGPUController::GetLEDRed()
|
||||
{
|
||||
return(AuraGPURegisterRead(AURA_GPU_REG_RED));
|
||||
}
|
||||
|
||||
unsigned char AuraGPUController::GetLEDGreen()
|
||||
{
|
||||
return(AuraGPURegisterRead(AURA_GPU_REG_GREEN));
|
||||
}
|
||||
|
||||
unsigned char AuraGPUController::GetLEDBlue()
|
||||
{
|
||||
return(AuraGPURegisterRead(AURA_GPU_REG_BLUE));
|
||||
}
|
||||
|
||||
void AuraGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes
|
||||
{
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
|
||||
}
|
||||
|
||||
void AuraGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraGPUController::SetMode(unsigned char mode)
|
||||
{
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_MODE, mode);
|
||||
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
|
||||
}
|
||||
|
||||
unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg)
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, reg));
|
||||
}
|
||||
|
||||
void AuraGPUController::AuraGPURegisterWrite(unsigned char reg, unsigned char val)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, reg, val);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraGPUController.h |
|
||||
| |
|
||||
| Definitions for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char aura_gpu_dev_id;
|
||||
|
||||
#define AURA_GPU_MAGIC_VAL 0x1589 /* This magic value is present in all Aura GPU controllers */
|
||||
#define AURA_GPU_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_GPU_REG_RED = 0x04, /* AURA GPU RED Register */
|
||||
AURA_GPU_REG_GREEN = 0x05, /* AURA GPU GREEN Register */
|
||||
AURA_GPU_REG_BLUE = 0x06, /* AURA GPU BLUE Register */
|
||||
AURA_GPU_REG_MODE = 0x07, /* AURA GPU Mode Selection Register */
|
||||
AURA_GPU_REG_SYNC = 0x0C, /* AURA GPU "Sync" Register */
|
||||
AURA_GPU_REG_APPLY = 0x0E, /* AURA GPU Apply Chnages Register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_GPU_MODE_OFF = 0, /* OFF mode (not a real Mode! Doesn't do anything!) */
|
||||
AURA_GPU_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_GPU_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_GPU_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_GPU_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_GPU_MODE_DIRECT = 5, /* Direct mode (not a real Mode! Doesn't do anything!) */
|
||||
AURA_GPU_NUMBER_MODES
|
||||
};
|
||||
|
||||
class AuraGPUController
|
||||
{
|
||||
public:
|
||||
AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id);
|
||||
~AuraGPUController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
unsigned char GetLEDRed();
|
||||
unsigned char GetLEDGreen();
|
||||
unsigned char GetLEDBlue();
|
||||
void SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
unsigned char AuraGPURegisterRead(unsigned char reg);
|
||||
void AuraGPURegisterWrite(unsigned char reg, unsigned char val);
|
||||
|
||||
bool direct = false; // Temporary solution to check if we are in "Direct" mode
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
i2c_smbus_interface * bus;
|
||||
aura_gpu_dev_id dev;
|
||||
};
|
||||
@@ -1,88 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraGPUControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| This list contains the available I2C addresses for Aura GPUs |
|
||||
\*-------------------------------------------------------------*/
|
||||
#define AURA_GPU_ADDRESS_COUNT 3
|
||||
|
||||
static const unsigned char aura_gpu_addresses[] =
|
||||
{
|
||||
0x29,
|
||||
0x2A,
|
||||
0x60
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraGPUController *
|
||||
* *
|
||||
* Tests the given address to see if an Aura GPU controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForAsusAuraGPUController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
unsigned char aura_gpu_magic_high = bus->i2c_smbus_read_byte_data(address, 0x20); // High Byte of magic (0x15)
|
||||
unsigned char aura_gpu_magic_low = bus->i2c_smbus_read_byte_data(address, 0x21); // Low Byte of magic (0x89)
|
||||
|
||||
if((aura_gpu_magic_high << 8) + aura_gpu_magic_low == AURA_GPU_MAGIC_VAL)
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForAuraGPUController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraGPUControllers *
|
||||
* *
|
||||
* Detect Aura GPU controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAsusAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
AuraGPUController* new_aura_gpu;
|
||||
RGBController_AuraGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Add Aura-enabled GPU controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_GPU_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForAsusAuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]))
|
||||
{
|
||||
new_aura_gpu = new AuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_AuraGPU(new_aura_gpu);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
} /* DetectAuraGPUControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("ASUS Aura GPU", DetectAsusAuraGPUControllers);
|
||||
@@ -1,199 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura GPU |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraGPU.h"
|
||||
|
||||
int RGBController_AuraGPU::GetDeviceMode()
|
||||
{
|
||||
int dev_mode = aura_gpu->AuraGPURegisterRead(AURA_GPU_REG_MODE);
|
||||
int color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
if(dev_mode == AURA_GPU_MODE_STATIC)
|
||||
{
|
||||
if (aura_gpu->direct)
|
||||
{
|
||||
dev_mode = AURA_GPU_MODE_DIRECT;
|
||||
}
|
||||
}
|
||||
|
||||
switch(dev_mode)
|
||||
{
|
||||
case AURA_GPU_MODE_OFF:
|
||||
case AURA_GPU_MODE_SPECTRUM_CYCLE:
|
||||
color_mode = MODE_COLORS_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
for(std::size_t mode = 0; mode < modes.size(); mode++)
|
||||
{
|
||||
if(modes[mode].value == dev_mode)
|
||||
{
|
||||
active_mode = mode;
|
||||
modes[mode].color_mode = color_mode;
|
||||
}
|
||||
}
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
|
||||
{
|
||||
aura_gpu = aura_gpu_ptr;
|
||||
|
||||
|
||||
name = aura_gpu->GetDeviceName();
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = "ASUS Aura GPU Device";
|
||||
version = "0.00.1";
|
||||
location = aura_gpu->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = AURA_GPU_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_GPU_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_GPU_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_GPU_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_GPU_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Spectrum_Cycle;
|
||||
Spectrum_Cycle.name = "Spectrum Cycle";
|
||||
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE;
|
||||
Spectrum_Cycle.flags = 0;
|
||||
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Spectrum_Cycle);
|
||||
|
||||
SetupZones();
|
||||
|
||||
active_mode = GetDeviceMode();
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone aura_gpu_zone;
|
||||
aura_gpu_zone.name = "GPU";
|
||||
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
|
||||
aura_gpu_zone.leds_min = 1;
|
||||
aura_gpu_zone.leds_max = 1;
|
||||
aura_gpu_zone.leds_count = 1;
|
||||
aura_gpu_zone.matrix_map = NULL;
|
||||
zones.push_back(aura_gpu_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LED |
|
||||
\*---------------------------------------------------------*/
|
||||
led aura_gpu_led;
|
||||
aura_gpu_led.name = "GPU";
|
||||
leds.push_back(aura_gpu_led);
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize color |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char red = aura_gpu->GetLEDRed();
|
||||
unsigned char grn = aura_gpu->GetLEDGreen();
|
||||
unsigned char blu = aura_gpu->GetLEDBlue();
|
||||
|
||||
colors[0] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura_gpu->SetLEDColorsDirect(red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura_gpu->SetLEDColorsEffect(red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraGPU::DeviceUpdateMode()
|
||||
{
|
||||
int new_mode = modes[active_mode].value;
|
||||
aura_gpu->direct = false;
|
||||
|
||||
switch(new_mode)
|
||||
{
|
||||
|
||||
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
|
||||
case AURA_GPU_MODE_OFF:
|
||||
aura_gpu->SetLEDColorsEffect(0, 0, 0);
|
||||
new_mode = AURA_GPU_MODE_STATIC;
|
||||
break;
|
||||
|
||||
// Direct mode is done by switching to Static and not applying color changes
|
||||
case AURA_GPU_MODE_DIRECT:
|
||||
aura_gpu->direct = true;
|
||||
new_mode = AURA_GPU_MODE_STATIC;
|
||||
break;
|
||||
}
|
||||
|
||||
aura_gpu->SetMode(new_mode);
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura GPU |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraGPUController.h"
|
||||
|
||||
class RGBController_AuraGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraGPU(AuraGPUController* aura_gpu_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AuraGPUController* aura_gpu;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
@@ -1,144 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle, const char* path) : AuraUSBController(dev_handle, path)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add addressable devices |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < config_table[0x02]; ++i)
|
||||
{
|
||||
device_info.push_back({0x01, (unsigned char)i, 0x01, AuraDeviceType::ADDRESSABLE});
|
||||
}
|
||||
}
|
||||
|
||||
AuraAddressableController::~AuraAddressableController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendDirectApply(channel);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
SendEffect
|
||||
(
|
||||
channel,
|
||||
mode,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_ADDRESSABLE_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = grn;
|
||||
usb_buf[0x07] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80 | channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraAddressableController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| Addressable RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_ADDRESSABLE_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
|
||||
};
|
||||
|
||||
class AuraAddressableController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraAddressableController(hid_device* dev_handle, const char* path);
|
||||
~AuraAddressableController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
void SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
};
|
||||
@@ -1,66 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMainboardController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB Mainboard RGB lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MAINBOARD_CONTROL_MODE_EFFECT = 0x35, /* Effect control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR = 0x36, /* Effect color control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_COMMIT = 0x3F, /* Commit mode */
|
||||
};
|
||||
|
||||
class AuraMainboardController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraMainboardController(hid_device* dev_handle, const char* path);
|
||||
~AuraMainboardController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int mode;
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
);
|
||||
|
||||
void SendColor
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
};
|
||||
@@ -1,75 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMouseController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/23/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraMouseController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
AuraMouseController::AuraMouseController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
AuraMouseController::~AuraMouseController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string AuraMouseController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AuraMouseController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void AuraMouseController::SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x51;
|
||||
usb_buf[0x02] = 0x28;
|
||||
usb_buf[0x03] = zone;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = mode;
|
||||
usb_buf[0x06] = 0x04;
|
||||
usb_buf[0x07] = red;
|
||||
usb_buf[0x08] = grn;
|
||||
usb_buf[0x09] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMouseController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/23/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MOUSE_ZONE_LOGO = 0,
|
||||
AURA_MOUSE_ZONE_SCROLL = 1,
|
||||
AURA_MOUSE_ZONE_UNDERGLOW = 2,
|
||||
AURA_MOUSE_ZONE_ALL = 3,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MOUSE_MODE_STATIC = 0,
|
||||
AURA_MOUSE_MODE_BREATHING = 1,
|
||||
AURA_MOUSE_MODE_COLOR_CYCLE = 2,
|
||||
AURA_MOUSE_MODE_REACTIVE = 3,
|
||||
};
|
||||
|
||||
class AuraMouseController
|
||||
{
|
||||
public:
|
||||
AuraMouseController(hid_device* dev_handle, const char* path);
|
||||
virtual ~AuraMouseController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
};
|
||||
@@ -1,172 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraUSBController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraUSBController.h"
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
GetFirmwareVersion();
|
||||
GetConfigTable();
|
||||
}
|
||||
|
||||
AuraUSBController::~AuraUSBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int AuraUSBController::GetChannelCount()
|
||||
{
|
||||
return(device_info.size());
|
||||
}
|
||||
|
||||
std::string AuraUSBController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AuraUSBController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string AuraUSBController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
const std::vector<AuraDeviceInfo>& AuraUSBController::GetAuraDevices() const
|
||||
{
|
||||
return(device_info);
|
||||
}
|
||||
|
||||
void AuraUSBController::GetConfigTable()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_CONFIG_TABLE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x30)
|
||||
{
|
||||
memcpy(config_table, &usb_buf[4], 60);
|
||||
|
||||
for(int i = 0; i < 60; i+=6)
|
||||
{
|
||||
printf("%02X %02X %02X %02X %02X %02X\r\n", config_table[i + 0],
|
||||
config_table[i + 1],
|
||||
config_table[i + 2],
|
||||
config_table[i + 3],
|
||||
config_table[i + 4],
|
||||
config_table[i + 5]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
throw std::runtime_error("Could not read config table");
|
||||
}
|
||||
}
|
||||
|
||||
void AuraUSBController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up firmware version request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_FIRMWARE_VERSION;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x02)
|
||||
{
|
||||
memcpy(device_name, &usb_buf[2], 16);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraUSBController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool apply /* = false */
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = apply ? 0x80 : 0x00;
|
||||
usb_buf[0x02] |= device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraAddressableController.h"
|
||||
#include "AsusAuraMainboardController.h"
|
||||
#include "AsusAuraMouseController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraUSB.h"
|
||||
#include "RGBController_AsusAuraMouse.h"
|
||||
#include <stdexcept>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_USB_VID 0x0B05
|
||||
#define AURA_TERMINAL_PID 0x1889
|
||||
#define AURA_ADDRESSABLE_1_PID 0x1867
|
||||
#define AURA_ADDRESSABLE_2_PID 0x1872
|
||||
#define AURA_ADDRESSABLE_3_PID 0x18A3
|
||||
#define AURA_ADDRESSABLE_4_PID 0x18A5
|
||||
#define AURA_MOTHERBOARD_1_PID 0x18F3
|
||||
#define AURA_MOTHERBOARD_2_PID 0x1939
|
||||
#define AURA_ROG_GLADIUS_II_CORE_PID 0x18DD
|
||||
#define AURA_ROG_GLADIUS_II_PID 0x1845
|
||||
#define AURA_ROG_GLADIUS_II_ORIGIN_PID 0x1877
|
||||
|
||||
void DetectAsusAuraUSBAddressable(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev, info->path);
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectAsusAuraUSBMotherboards(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
try
|
||||
{
|
||||
AuraMainboardController* controller = new AuraMainboardController(dev, info->path);
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
catch(std::runtime_error&)
|
||||
{
|
||||
// reading the config table failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DetectAsusAuraUSBMice(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
AuraMouseController* controller = new AuraMouseController(dev, info->path);
|
||||
RGBController_AuraMouse* rgb_controller = new RGBController_AuraMouse(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR ("ASUS ROG AURA Terminal", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_TERMINAL_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_1_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_2_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_3_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_4_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Motherboard", DetectAsusAuraUSBMotherboards, AURA_USB_VID, AURA_MOTHERBOARD_1_PID);
|
||||
REGISTER_HID_DETECTOR ("ASUS Aura Motherboard", DetectAsusAuraUSBMotherboards, AURA_USB_VID, AURA_MOTHERBOARD_2_PID);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Core", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_CORE_PID, 0, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Origin", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_ORIGIN_PID, 2, 0xFF01);
|
||||
@@ -1,204 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraMouse.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraMouse.h"
|
||||
|
||||
RGBController_AuraMouse::RGBController_AuraMouse(AuraMouseController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Mouse";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "ASUS Aura Mouse Device";
|
||||
location = aura->GetDeviceLocation();
|
||||
serial = aura->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = AURA_MOUSE_MODE_STATIC;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MOUSE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MOUSE_MODE_COLOR_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = AURA_MOUSE_MODE_REACTIVE;
|
||||
Reactive.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Reactive.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Reactive);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AuraMouse::~RGBController_AuraMouse()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::SetupZones()
|
||||
{
|
||||
zone logo_zone;
|
||||
|
||||
logo_zone.name = "Logo";
|
||||
logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
logo_zone.leds_min = 1;
|
||||
logo_zone.leds_max = 1;
|
||||
logo_zone.leds_count = 1;
|
||||
logo_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
led logo_led;
|
||||
|
||||
logo_led.name = "Logo";
|
||||
|
||||
leds.push_back(logo_led);
|
||||
|
||||
zone scroll_zone;
|
||||
|
||||
scroll_zone.name = "Scroll Wheel";
|
||||
scroll_zone.type = ZONE_TYPE_SINGLE;
|
||||
scroll_zone.leds_min = 1;
|
||||
scroll_zone.leds_max = 1;
|
||||
scroll_zone.leds_count = 1;
|
||||
scroll_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(scroll_zone);
|
||||
|
||||
led scroll_led;
|
||||
|
||||
scroll_led.name = "Scroll Wheel";
|
||||
|
||||
leds.push_back(scroll_led);
|
||||
|
||||
zone underglow_zone;
|
||||
|
||||
underglow_zone.name = "Underglow";
|
||||
underglow_zone.type = ZONE_TYPE_SINGLE;
|
||||
underglow_zone.leds_min = 1;
|
||||
underglow_zone.leds_max = 1;
|
||||
underglow_zone.leds_count = 1;
|
||||
underglow_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(underglow_zone);
|
||||
|
||||
led underglow_led;
|
||||
|
||||
underglow_led.name = "Underglow";
|
||||
|
||||
leds.push_back(underglow_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateSingleLED(zone);
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
if(led == 0)
|
||||
{
|
||||
red = RGBGetRValue(colors[led]);
|
||||
grn = RGBGetGValue(colors[led]);
|
||||
blu = RGBGetBValue(colors[led]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_LOGO, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
else if(led == 1)
|
||||
{
|
||||
red = RGBGetRValue(colors[led]);
|
||||
grn = RGBGetGValue(colors[led]);
|
||||
blu = RGBGetBValue(colors[led]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_SCROLL, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
red = RGBGetRValue(colors[led]);
|
||||
grn = RGBGetGValue(colors[led]);
|
||||
blu = RGBGetBValue(colors[led]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_UNDERGLOW, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_ALL, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraMouse::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
red = RGBGetRValue(colors[0]);
|
||||
grn = RGBGetGValue(colors[0]);
|
||||
blu = RGBGetBValue(colors[0]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_LOGO, modes[active_mode].value, red, grn, blu);
|
||||
|
||||
red = RGBGetRValue(colors[1]);
|
||||
grn = RGBGetGValue(colors[1]);
|
||||
blu = RGBGetBValue(colors[1]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_SCROLL, modes[active_mode].value, red, grn, blu);
|
||||
|
||||
red = RGBGetRValue(colors[2]);
|
||||
grn = RGBGetGValue(colors[2]);
|
||||
blu = RGBGetBValue(colors[2]);
|
||||
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_UNDERGLOW, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SendUpdate(AURA_MOUSE_ZONE_ALL, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraMouse.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraMouseController.h"
|
||||
|
||||
class RGBController_AuraMouse : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraMouse(AuraMouseController* aura_ptr);
|
||||
~RGBController_AuraMouse();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AuraMouseController* aura;
|
||||
};
|
||||
@@ -1,253 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraUSB.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraUSB.h"
|
||||
|
||||
RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* aura_ptr) :
|
||||
initializedMode(false)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura USB";
|
||||
vendor = "ASUS";
|
||||
version = aura->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = "ASUS Aura USB Device";
|
||||
location = aura->GetDeviceLocation();
|
||||
serial = aura->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = AURA_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = AURA_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = AURA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flashing.colors_min = 1;
|
||||
Flashing.colors_max = 1;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.colors.resize(1);
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = 0;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_MODE_RAINBOW;
|
||||
Rainbow.flags = 0;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode ChaseFade;
|
||||
ChaseFade.name = "Chase Fade";
|
||||
ChaseFade.value = AURA_MODE_CHASE_FADE;
|
||||
ChaseFade.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
ChaseFade.colors_min = 1;
|
||||
ChaseFade.colors_max = 1;
|
||||
ChaseFade.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ChaseFade.colors.resize(1);
|
||||
modes.push_back(ChaseFade);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Chase";
|
||||
Chase.value = AURA_MODE_CHASE;
|
||||
Chase.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Chase.colors_min = 1;
|
||||
Chase.colors_max = 1;
|
||||
Chase.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Chase.colors.resize(1);
|
||||
modes.push_back(Chase);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AuraUSB::~RGBController_AuraUSB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(aura->GetChannelCount());
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
int addressableCounter = 1;
|
||||
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
AuraDeviceInfo device_info = aura->GetAuraDevices()[channel_idx];
|
||||
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
if(device_info.device_type == AuraDeviceType::FIXED)
|
||||
{
|
||||
zones[channel_idx].name = "Aura Mainboard";
|
||||
zones[channel_idx].leds_min = device_info.num_leds;
|
||||
zones[channel_idx].leds_max = device_info.num_leds;
|
||||
zones[channel_idx].leds_count = device_info.num_leds;
|
||||
}
|
||||
else
|
||||
{
|
||||
zones[channel_idx].name = "Aura Addressable ";
|
||||
zones[channel_idx].name.append(std::to_string(addressableCounter));
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
|
||||
|
||||
addressableCounter++;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[channel_idx].name;
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(std::to_string(led_ch_idx + 1));
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::DeviceUpdateLEDs()
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
aura->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
aura->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::UpdateSingleLED(int led)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
unsigned int channel = leds[led].value;
|
||||
|
||||
aura->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraUSB::DeviceUpdateMode()
|
||||
{
|
||||
initializedMode = true;
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
if(zones[zone_idx].leds_count > 0)
|
||||
{
|
||||
aura->SetMode(zone_idx, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraUSB.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraUSBController.h"
|
||||
|
||||
#define AURA_ADDRESSABLE_MAX_LEDS 120
|
||||
|
||||
class RGBController_AuraUSB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraUSB(AuraUSBController* aura_ptr);
|
||||
~RGBController_AuraUSB();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AuraUSBController* aura;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
bool initializedMode;
|
||||
};
|
||||
@@ -1,48 +0,0 @@
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "RGBController_AsusTUFLaptopWMI.h"
|
||||
|
||||
#include "acpiwmi.h"
|
||||
#include "Detector.h"
|
||||
#include "wmi.h"
|
||||
#include <string>
|
||||
|
||||
static void DetectAsusTUFLaptopWMIControllers(std::vector<RGBController*>&)
|
||||
{
|
||||
// Try to retrieve ProductID / Device name from WMI; Possibly can be rewritten to use wmi.cpp
|
||||
// IF you encounter false detection ( e.g. if your laptop keyboard backlight uses USB interface
|
||||
// instead of ACPI WMI) please add a WHITELIST by checking the
|
||||
// `name` variable for model substrings like "FX505DU"
|
||||
// For now, checking for "TUF Gaming" should suffice
|
||||
|
||||
Wmi wmi;
|
||||
wmi.init();
|
||||
|
||||
std::vector<QueryObj> systemProduct;
|
||||
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// There should only be one, a cycle is a precaution
|
||||
if(systemProduct.size() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
std::string& name = systemProduct[0]["Name"];
|
||||
if(name.find("TUF Gaming") == name.npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(AsWMI_Open())
|
||||
{
|
||||
RGBController* new_controller = new RGBController_AsusTUFLaptopWMI();
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
// Success! No more if's
|
||||
}
|
||||
} /* DetectFaustusControllers() */
|
||||
|
||||
REGISTER_DETECTOR("TUF Laptop WMI", DetectAsusTUFLaptopWMIControllers);
|
||||
|
||||
#endif
|
||||
@@ -1,143 +0,0 @@
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "RGBController_AsusTUFLaptopWMI.h"
|
||||
|
||||
#include "acpiwmi.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Detector.h"
|
||||
#include "wmi.h"
|
||||
#include <string>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController_AsusTUFLaptopWMI::RGBController_AsusTUFLaptopWMI()
|
||||
{
|
||||
name = "ASUS TUF Keyboard";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "WMI Device";
|
||||
location = "\\\\.\\ATKACPI";
|
||||
|
||||
modes.resize(5);
|
||||
modes[0].name = "Direct";
|
||||
modes[0].value = 4;
|
||||
modes[0].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[0].color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
modes[1].name = "Static";
|
||||
modes[1].value = 0;
|
||||
modes[1].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[1].color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
modes[2].name = "Breathing";
|
||||
modes[2].value = 1;
|
||||
modes[2].flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[2].speed_min = 0;
|
||||
modes[2].speed_max = 2;
|
||||
modes[2].color_mode = MODE_COLORS_PER_LED;
|
||||
modes[2].speed = 1;
|
||||
|
||||
modes[3].name = "Color Cycle";
|
||||
modes[3].value = 2;
|
||||
modes[3].flags = MODE_FLAG_HAS_SPEED;
|
||||
modes[3].speed_min = 0;
|
||||
modes[3].speed_max = 2;
|
||||
modes[3].color_mode = MODE_COLORS_NONE;
|
||||
modes[3].speed = 1;
|
||||
|
||||
modes[4].name = "Strobe";
|
||||
modes[4].value = 0x0A;
|
||||
modes[4].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes[4].color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AsusTUFLaptopWMI::~RGBController_AsusTUFLaptopWMI()
|
||||
{
|
||||
AsWMI_Close();
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zones.resize(1);
|
||||
zones[0].type = ZONE_TYPE_SINGLE;
|
||||
zones[0].name = "Keyboard Backlight zone";
|
||||
zones[0].leds_min = 1;
|
||||
zones[0].leds_max = 1;
|
||||
zones[0].leds_count = 1;
|
||||
zones[0].matrix_map = NULL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LED |
|
||||
\*---------------------------------------------------------*/
|
||||
leds.resize(1);
|
||||
leds[0].name = "Keyboard Backlight LED";
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::DeviceUpdateLEDs()
|
||||
{
|
||||
uint8_t red = RGBGetRValue(colors[0]);
|
||||
uint8_t green = RGBGetGValue(colors[0]);
|
||||
uint8_t blue = RGBGetBValue(colors[0]);
|
||||
uint8_t speed_byte = 0;
|
||||
uint8_t mode = modes[active_mode].value;
|
||||
uint8_t inv = 0;
|
||||
if(mode == 4)
|
||||
{
|
||||
mode = 1;
|
||||
inv = 4; // Any invalid mode, i.e. anything other than 0, 1, 2 and 10
|
||||
}
|
||||
if(mode == 1 || mode == 2)
|
||||
{
|
||||
switch(modes[active_mode].speed)
|
||||
{
|
||||
case 0: speed_byte = 0xE1; break;
|
||||
case 1: speed_byte = 0xEB; break;
|
||||
case 2: speed_byte = 0xF5; break;
|
||||
}
|
||||
}
|
||||
int high = ((mode | ((red | (green << 8)) << 8)) << 8) | 0xB3;
|
||||
int low = blue | (speed_byte << 8);
|
||||
AsWMI_NB_DeviceControl_2arg(0x100056, high, low);
|
||||
if(inv)
|
||||
{
|
||||
//std::this_thread::sleep_for(10ms);
|
||||
high = ((inv | ((red | (green << 8)) << 8)) << 8) | 0xB3;
|
||||
AsWMI_NB_DeviceControl_2arg(0x100056, high, low);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::SetCustomMode()
|
||||
{
|
||||
SetMode(0);
|
||||
}
|
||||
|
||||
void RGBController_AsusTUFLaptopWMI::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,29 +0,0 @@
|
||||
#ifndef RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
|
||||
#define RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_AsusTUFLaptopWMI : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AsusTUFLaptopWMI();
|
||||
virtual ~RGBController_AsusTUFLaptopWMI();
|
||||
|
||||
void SetupZones() override;
|
||||
|
||||
void ResizeZone(int zone, int new_size) override;
|
||||
|
||||
void DeviceUpdateLEDs() override;
|
||||
void UpdateZoneLEDs(int zone) override;
|
||||
void UpdateSingleLED(int led) override;
|
||||
|
||||
void DeviceUpdateMode() override;
|
||||
|
||||
void SetCustomMode() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
|
||||
+120
-117
@@ -1,121 +1,97 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMainboardController.cpp |
|
||||
| AuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB mainboard |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraMainboardController.h"
|
||||
#include "AuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraMainboardController::AuraMainboardController(hid_device* dev_handle, const char* path) : AuraUSBController(dev_handle, path), mode(AURA_MODE_DIRECT)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add mainboard device |
|
||||
\*-----------------------------------------------------*/
|
||||
device_info.push_back({0x00, 0x04, config_table[0x1B], AuraDeviceType::FIXED});
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add addressable devices |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < config_table[0x02]; ++i)
|
||||
{
|
||||
device_info.push_back({0x01, (unsigned char)i, 0x01, AuraDeviceType::ADDRESSABLE});
|
||||
}
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
channel_leds[0] = 40;
|
||||
}
|
||||
|
||||
AuraMainboardController::~AuraMainboardController()
|
||||
AuraAddressableController::~AuraAddressableController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
void AuraAddressableController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
SendDirectBegin();
|
||||
|
||||
while(leds_sent < colors.size())
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
if((colors.size() - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
leds_to_send = colors.size() - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
for(int led_idx = 0; leds_to_send < 20; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
device_info[channel].direct_channel,
|
||||
0,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data,
|
||||
leds_sent + leds_to_send >= num_colors
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendCommit();
|
||||
SendDirectApply();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetMode
|
||||
void AuraAddressableController::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
SendEffect
|
||||
(
|
||||
mode,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
this->mode = mode;
|
||||
RGBColor color = ToRGBColor(red, grn, blu);
|
||||
|
||||
SendEffect(device_info[channel].effect_channel, mode);
|
||||
if(mode == AURA_MODE_DIRECT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char led_data[60];
|
||||
unsigned char start_led = 0;
|
||||
|
||||
for(std::size_t i = 0; i < channel; ++i)
|
||||
{
|
||||
start_led += device_info[i].num_leds;
|
||||
}
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < device_info[channel].num_leds; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(color);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(color);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
channel,
|
||||
start_led,
|
||||
device_info[channel].num_leds,
|
||||
led_data,
|
||||
device_info[channel].device_type == AuraDeviceType::FIXED
|
||||
);
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
@@ -128,55 +104,31 @@ void AuraMainboardController::SendEffect
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendColor
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = fixed ? 0xFF : 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05 + 3 * start_led], led_data, led_count * 3);
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = grn;
|
||||
usb_buf[0x07] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendCommit()
|
||||
void AuraAddressableController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
@@ -189,11 +141,62 @@ void AuraMainboardController::SendCommit()
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_COMMIT;
|
||||
usb_buf[0x02] = 0x55;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectBegin()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x04] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 64);
|
||||
}
|
||||
+27
-53
@@ -1,16 +1,15 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraUSBController.h |
|
||||
| AuraAddressableController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB RGB lighting controller |
|
||||
| Addressable RGB lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
@@ -32,79 +31,54 @@ enum
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
AURA_MODE_MUSIC = 14, /* Music effect mode */
|
||||
AURA_MODE_DIRECT = 0xFF, /* Direct control mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REQUEST_FIRMWARE_VERSION = 0x82, /* Request firmware string */
|
||||
AURA_REQUEST_CONFIG_TABLE = 0xB0, /* Request configuration table */
|
||||
AURA_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
|
||||
AURA_CONTROL_MODE_DIRECT = 0x40, /* Direct control mode */
|
||||
};
|
||||
|
||||
enum class AuraDeviceType
|
||||
{
|
||||
FIXED,
|
||||
ADDRESSABLE,
|
||||
};
|
||||
|
||||
struct AuraDeviceInfo
|
||||
{
|
||||
unsigned char effect_channel;
|
||||
unsigned char direct_channel;
|
||||
unsigned char num_leds;
|
||||
AuraDeviceType device_type;
|
||||
};
|
||||
|
||||
class AuraUSBController
|
||||
class AuraAddressableController
|
||||
{
|
||||
public:
|
||||
AuraUSBController(hid_device* dev_handle, const char* path);
|
||||
virtual ~AuraUSBController();
|
||||
AuraAddressableController(hid_device* dev_handle);
|
||||
~AuraAddressableController();
|
||||
|
||||
unsigned int GetChannelCount();
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
|
||||
const std::vector<AuraDeviceInfo>& GetAuraDevices() const;
|
||||
|
||||
virtual void SetChannelLEDs
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
) = 0;
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
unsigned int channel_leds[1];
|
||||
|
||||
virtual void SetMode
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
unsigned int led_count;
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
) = 0;
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
unsigned char config_table[60];
|
||||
std::vector<AuraDeviceInfo> device_info;
|
||||
std::string location;
|
||||
);
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool apply = false
|
||||
unsigned char* led_data
|
||||
);
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned int led_count;
|
||||
|
||||
void SendDirectBegin();
|
||||
|
||||
void GetConfigTable();
|
||||
|
||||
void GetFirmwareVersion();
|
||||
void SendDirectApply();
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "AuraAddressableController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraAddressable.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_ADDRESSABLE_VID 0x0B05
|
||||
#define AURA_ADDRESSABLE_PID 0x1872
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraAddressableControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus Aura addressable RGB header controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraAddressableControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus Aura addressable RGB header controller
|
||||
hid_init();
|
||||
|
||||
dev = hid_open(AURA_ADDRESSABLE_VID, AURA_ADDRESSABLE_PID, 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
|
||||
RGBController_AuraAddressable* rgb_controller = new RGBController_AuraAddressable(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
+24
-46
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.cpp |
|
||||
| AuraController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
@@ -7,25 +7,10 @@
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraSMBusController.h"
|
||||
#include "AuraController.h"
|
||||
#include <cstring>
|
||||
|
||||
static const char* aura_channels[] = /* Aura channel strings */
|
||||
{
|
||||
"Audio",
|
||||
"Backplate",
|
||||
"Back I/O",
|
||||
"Center",
|
||||
"Center",
|
||||
"DRAM",
|
||||
"PCIe",
|
||||
"RGB Header",
|
||||
"RGB Header 2",
|
||||
"RGB Header",
|
||||
"Unknown",
|
||||
};
|
||||
|
||||
AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id dev)
|
||||
AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
@@ -60,7 +45,7 @@ AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id d
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0106 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0106") == 0)
|
||||
@@ -83,13 +68,6 @@ AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id d
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E8K4-0101 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E8K4-0101") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// Assume first generation controller if string does not match
|
||||
else
|
||||
{
|
||||
@@ -99,32 +77,32 @@ AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id d
|
||||
}
|
||||
}
|
||||
|
||||
AuraSMBusController::~AuraSMBusController()
|
||||
AuraController::~AuraController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string AuraSMBusController::GetDeviceName()
|
||||
std::string AuraController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string AuraSMBusController::GetDeviceLocation()
|
||||
std::string AuraController::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("I2C: " + return_string);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned char AuraSMBusController::GetChannel(unsigned int led)
|
||||
unsigned char AuraController::GetChannel(unsigned int led)
|
||||
{
|
||||
return(config_table[channel_cfg + led]);
|
||||
}
|
||||
|
||||
const char * AuraSMBusController::GetChannelName(unsigned int led)
|
||||
const char * AuraController::GetChannelName(unsigned int led)
|
||||
{
|
||||
switch (config_table[channel_cfg + led])
|
||||
{
|
||||
@@ -174,27 +152,27 @@ const char * AuraSMBusController::GetChannelName(unsigned int led)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int AuraSMBusController::GetLEDCount()
|
||||
unsigned int AuraController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char AuraSMBusController::GetLEDRed(unsigned int led)
|
||||
unsigned char AuraController::GetLEDRed(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led )));
|
||||
}
|
||||
|
||||
unsigned char AuraSMBusController::GetLEDGreen(unsigned int led)
|
||||
unsigned char AuraController::GetLEDGreen(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
|
||||
}
|
||||
|
||||
unsigned char AuraSMBusController::GetLEDBlue(unsigned int led)
|
||||
unsigned char AuraController::GetLEDBlue(unsigned int led)
|
||||
{
|
||||
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
@@ -210,7 +188,7 @@ void AuraSMBusController::SetAllColorsDirect(unsigned char red, unsigned char gr
|
||||
delete colors;
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
@@ -228,20 +206,20 @@ void AuraSMBusController::SetAllColorsEffect(unsigned char red, unsigned char gr
|
||||
delete[] colors;
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetDirect(unsigned char direct)
|
||||
void AuraController::SetDirect(unsigned char direct)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_DIRECT, direct);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void AuraController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg + ( 3 * led ), colors, 3);
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void AuraController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
@@ -250,13 +228,13 @@ void AuraSMBusController::SetLEDColorEffect(unsigned int led, unsigned char red,
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraSMBusController::SetMode(unsigned char mode)
|
||||
void AuraController::SetMode(unsigned char mode)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_MODE, mode);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraSMBusController::AuraUpdateDeviceName()
|
||||
void AuraController::AuraUpdateDeviceName()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
@@ -264,7 +242,7 @@ void AuraSMBusController::AuraUpdateDeviceName()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char AuraSMBusController::AuraRegisterRead(aura_register reg)
|
||||
unsigned char AuraController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
@@ -274,7 +252,7 @@ unsigned char AuraSMBusController::AuraRegisterRead(aura_register reg)
|
||||
|
||||
}
|
||||
|
||||
void AuraSMBusController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
@@ -284,7 +262,7 @@ void AuraSMBusController::AuraRegisterWrite(aura_register reg, unsigned char val
|
||||
|
||||
}
|
||||
|
||||
void AuraSMBusController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
+19
-4
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.h |
|
||||
| AuraController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura RGB |
|
||||
| lighting controller |
|
||||
@@ -66,6 +66,21 @@ enum
|
||||
AURA_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
static const char* aura_channels[] = /* Aura channel strings */
|
||||
{
|
||||
"Audio",
|
||||
"Backplate",
|
||||
"Back I/O",
|
||||
"Center",
|
||||
"Center",
|
||||
"DRAM",
|
||||
"PCIe",
|
||||
"RGB Header",
|
||||
"RGB Header 2",
|
||||
"RGB Header",
|
||||
"Unknown",
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
@@ -73,11 +88,11 @@ enum
|
||||
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
class AuraSMBusController
|
||||
class AuraController
|
||||
{
|
||||
public:
|
||||
AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id dev);
|
||||
~AuraSMBusController();
|
||||
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
|
||||
~AuraController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
+65
-71
@@ -1,25 +1,31 @@
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraSMBusController.h"
|
||||
#include "AuraController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraSMBus.h"
|
||||
#include "RGBController_Aura.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
#define AURA_RAM_ADDRESS_COUNT 23
|
||||
#define AURA_RAM_ADDRESS_COUNT 21
|
||||
|
||||
static const unsigned char aura_ram_addresses[] =
|
||||
{
|
||||
0x70,
|
||||
0x71,
|
||||
0x72,
|
||||
0x73,
|
||||
0x74,
|
||||
0x75,
|
||||
@@ -36,7 +42,6 @@ static const unsigned char aura_ram_addresses[] =
|
||||
0x66,
|
||||
0x67,
|
||||
0x39,
|
||||
0x3A,
|
||||
0x3B,
|
||||
0x3C,
|
||||
0x3D
|
||||
@@ -45,26 +50,27 @@ static const unsigned char aura_ram_addresses[] =
|
||||
/*---------------------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura motherboards |
|
||||
\*---------------------------------------------------------------------------------*/
|
||||
#define AURA_MOBO_ADDRESS_COUNT 3
|
||||
#define AURA_MOBO_ADDRESS_COUNT 4
|
||||
|
||||
static const unsigned char aura_mobo_addresses[] =
|
||||
{
|
||||
0x40,
|
||||
0x4E,
|
||||
0x4F
|
||||
0x4F,
|
||||
0x66
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* AuraRegisterWrite *
|
||||
* *
|
||||
* A standalone version of the AuraSMBusController::AuraRegisterWrite function for *
|
||||
* access to Aura devices without instancing the AuraSMBusController class or reading *
|
||||
* the config table from the device. *
|
||||
* A standalone version of the AuraController::AuraRegisterWrite function for access *
|
||||
* to Aura devices without instancing the AuraController class or reading the config *
|
||||
* table from the device. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void AsusAuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register reg, unsigned char val)
|
||||
void AuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register reg, unsigned char val)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
@@ -75,7 +81,7 @@ void AsusAuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_regis
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraSMBusController *
|
||||
* TestForAuraController *
|
||||
* *
|
||||
* Tests the given address to see if an Aura controller exists there. First does a *
|
||||
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
|
||||
@@ -83,7 +89,7 @@ void AsusAuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_regis
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char address)
|
||||
bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
@@ -106,11 +112,11 @@ bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char addr
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForAuraSMBusController() */
|
||||
} /* TestForAuraController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraSMBusControllers *
|
||||
* DetectAuraControllers *
|
||||
* *
|
||||
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
|
||||
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
|
||||
@@ -122,79 +128,67 @@ bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char addr
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAsusAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
AuraSMBusController* new_aura;
|
||||
RGBController_AuraSMBus* new_controller;
|
||||
AuraController* new_aura;
|
||||
RGBController_Aura* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
int address_list_idx = -1;
|
||||
int address_list_idx = 0;
|
||||
|
||||
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res < 0)
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
|
||||
{
|
||||
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
|
||||
address_list_idx++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (res >= 0);
|
||||
|
||||
do
|
||||
{
|
||||
address_list_idx++;
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
|
||||
}
|
||||
|
||||
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
|
||||
{
|
||||
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (res >= 0);
|
||||
|
||||
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
|
||||
{
|
||||
AsusAuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
|
||||
AsusAuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_RAM_ADDRESS_COUNT; address_list_idx++)
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_RAM_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForAuraController(busses[bus], aura_ram_addresses[address_list_idx]))
|
||||
{
|
||||
if (TestForAsusAuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]))
|
||||
{
|
||||
new_aura = new AuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_AuraSMBus(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
new_aura = new AuraController(busses[bus], aura_ram_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
// Add Aura-enabled motherboard controllers
|
||||
IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
if (TestForAuraController(busses[bus], aura_mobo_addresses[address_list_idx]))
|
||||
{
|
||||
if (TestForAsusAuraSMBusController(busses[bus], aura_mobo_addresses[address_list_idx]))
|
||||
{
|
||||
new_aura = new AuraSMBusController(busses[bus], aura_mobo_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_AuraSMBus(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
new_aura = new AuraController(busses[bus], aura_mobo_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraSMBusControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("ASUS Aura SMBus", DetectAsusAuraSMBusControllers);
|
||||
} /* DetectAuraControllers() */
|
||||
@@ -1,283 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 10th Oct 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMARGBcontroller.h"
|
||||
#include <cstring>
|
||||
|
||||
static unsigned char argb_colour_index_data[2][2][2] =
|
||||
{ //B0 B1
|
||||
{ { 0x00, 0x03 }, //G0 R0
|
||||
{ 0x02, 0x06 }, }, //G1 R0
|
||||
{ { 0x01, 0x05 }, //G0 R1
|
||||
{ 0x04, 0x07 }, } //G1 R1
|
||||
};
|
||||
|
||||
static unsigned char argb_mode_data[2][9] =
|
||||
{
|
||||
{ 0x05, 0x01, 0x02, 0x03, 0x04, 0x01, 0x01, 0x01, 0x01 }, //12v RGB Mode values
|
||||
{ 0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08, 0x09 } //5v ARGB Mode values
|
||||
};
|
||||
|
||||
CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx)
|
||||
{
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
zone_index = _zone_idx;
|
||||
current_speed = CM_ARGB_SPEED_NORMAL;
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
|
||||
|
||||
hid_get_serial_number_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
GetStatus();
|
||||
}
|
||||
|
||||
CMARGBController::~CMARGBController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void CMARGBController::GetStatus()
|
||||
{
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int header = zone_index - 1;
|
||||
|
||||
/*buffer[CM_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0b;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x03;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = 0xFF;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
int i = 0;
|
||||
do{
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
i++;
|
||||
}while( (i < 4) );
|
||||
|
||||
current_mode = argb_mode_data[1][buffer[4]];
|
||||
current_speed = buffer[5];*/
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetZoneIndex()
|
||||
{
|
||||
return zone_index;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedRed()
|
||||
{
|
||||
return current_red;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedGreen()
|
||||
{
|
||||
return current_green;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedBlue()
|
||||
{
|
||||
return current_blue;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedSpeed()
|
||||
{
|
||||
return current_speed;
|
||||
}
|
||||
|
||||
unsigned int CMARGBController::GetLargestColour(unsigned int red, unsigned int green, unsigned int blue)
|
||||
{
|
||||
unsigned int largest;
|
||||
if ( red > green )
|
||||
{
|
||||
( red > blue ) ? largest = red : largest = blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
( green > blue ) ? largest = green : largest = blue;
|
||||
}
|
||||
|
||||
return (largest == 0) ? 1 : largest;
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetColourIndex(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
//The Coolermaster ARGB controller uses a limited colour pallette referenced by an index
|
||||
//Starting at 0x00 Random, 0x01 Red, 0x02 Green, 0x03 Blue, 0x04 Yellow, 0x05 Purple, 0x06 Cyan, 0x07 White
|
||||
//The index can be calculated by normalising the input colour, rounding those values
|
||||
//and using them as the indicies of a 3d array containing the correct index
|
||||
unsigned int divisor = GetLargestColour( red, green, blue);
|
||||
unsigned int r = round( red / divisor );
|
||||
unsigned int g = round( green / divisor );
|
||||
unsigned int b = round( blue / divisor );
|
||||
unsigned char idx = argb_colour_index_data[r][g][b];
|
||||
return idx;
|
||||
}
|
||||
|
||||
void CMARGBController::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMARGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
current_red = red;
|
||||
current_green = green;
|
||||
current_blue = blue;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
|
||||
{
|
||||
const unsigned char buffer_size = 0x41;
|
||||
unsigned char buffer[buffer_size] = { 0x00 };
|
||||
unsigned char packet_count = 0x00;
|
||||
std::vector<unsigned char> colours;
|
||||
|
||||
//Set up the RGB triplets to send
|
||||
for(int i = 0; i < led_count; i++)
|
||||
{
|
||||
RGBColor colour = led_colours[i];
|
||||
unsigned char r = RGBGetRValue(colour);
|
||||
unsigned char g = RGBGetGValue(colour);
|
||||
unsigned char b = RGBGetBValue(colour);
|
||||
|
||||
colours.push_back(r);
|
||||
colours.push_back(g);
|
||||
colours.push_back(b);
|
||||
}
|
||||
|
||||
//buffer[CM_ARGB_REPORT_BYTE] = packet_count;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x10;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x02;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = 0x30; //30 might be the LED count??
|
||||
unsigned char buffer_idx = CM_ARGB_MODE_BYTE + 1; //Start colour info from
|
||||
|
||||
for (std::vector<unsigned char>::iterator it = colours.begin(); it != colours.end(); buffer_idx = 0)
|
||||
{
|
||||
//Fill the write buffer till its full or the colour buffer is empty
|
||||
buffer[CM_ARGB_REPORT_BYTE] = packet_count;
|
||||
while (( buffer_idx < buffer_size) && ( it != colours.end() ))
|
||||
{
|
||||
buffer[buffer_idx] = *it;
|
||||
buffer_idx++;
|
||||
it++;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
//reset the write buffer
|
||||
memset(buffer, 0x00, sizeof(buffer) );
|
||||
packet_count++;
|
||||
}
|
||||
buffer[CM_ARGB_REPORT_BYTE] = 0x82;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x62;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x00;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = 0x73;
|
||||
buffer[CM_ARGB_MODE_BYTE] = 0x00;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = 0x33;
|
||||
buffer[CM_ARGB_SPEED_BYTE] = 0x1B;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
void CMARGBController::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
bool boolARGB_header = argb_header_data[zone_index].digital;
|
||||
bool boolPassthru = ( current_mode == CM_ARGB_MODE_PASSTHRU );
|
||||
bool boolDirect = ( current_mode == CM_ARGB_MODE_DIRECT );
|
||||
unsigned char function = boolPassthru ? 0x02 : ( boolARGB_header ? 0x03 : 0x01);
|
||||
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = boolDirect ? 0x10 : 0x01;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = boolDirect ? 0x01 : function;
|
||||
|
||||
if ( boolDirect )
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x10;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = 0x30; //30 might be the LED count??
|
||||
|
||||
//hid_write(dev, buffer, buffer_size);
|
||||
//hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = function;
|
||||
}
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
|
||||
if ( boolARGB_header )
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0b; //ARGB sends 0x0b (1011) RGB sends 0x04 (0100)
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls custom mode TODO
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = argb_mode_data[1][current_mode];
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = GetColourIndex( current_red, current_green, current_blue );
|
||||
buffer[CM_ARGB_SPEED_BYTE] = current_speed;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x04; //ARGB sends 0x0b (1011) RGB sends 0x04 (0100)
|
||||
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = argb_mode_data[0][current_mode];
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = GetColourIndex( current_red, current_green, current_blue );
|
||||
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = current_speed;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 10th Oct 2020 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <cmath> //Needed by round()
|
||||
#include <hidapi/hidapi.h>
|
||||
#include "RGBController.h" //Needed to set the direct mode
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_ARGB_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
|
||||
#define CM_ARGB_HEADER_DATA_SIZE (sizeof(argb_header_data) / sizeof(argb_headers) )
|
||||
#define CM_ARGB_INTERRUPT_TIMEOUT 250
|
||||
#define CM_ARGB_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_RGB_OFFSET -2
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
enum
|
||||
{
|
||||
CM_ARGB_REPORT_BYTE = 1,
|
||||
CM_ARGB_COMMAND_BYTE = 2,
|
||||
CM_ARGB_FUNCTION_BYTE = 3,
|
||||
CM_ARGB_ZONE_BYTE = 4,
|
||||
CM_ARGB_MODE_BYTE = 5,
|
||||
CM_ARGB_COLOUR_INDEX_BYTE = 6,
|
||||
CM_ARGB_SPEED_BYTE = 7
|
||||
};
|
||||
|
||||
struct argb_headers
|
||||
{
|
||||
const char* name;
|
||||
unsigned char header;
|
||||
bool digital;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static argb_headers argb_header_data[6] =
|
||||
{
|
||||
{ "RGB Header", 0xFF, false, 1 },
|
||||
{ "Digital ARGB1", 0x01, true, 12 },
|
||||
{ "Digital ARGB2", 0x02, true, 12 },
|
||||
{ "Digital ARGB3", 0x04, true, 12 },
|
||||
{ "Digital ARGB4", 0x08, true, 12 },
|
||||
{ "All Digital ARGB", 0xFF, true, 12 }
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_RGB_MODE_OFF = 0, //Turn off
|
||||
CM_RGB_MODE_COLOUR_CYCLE = 1, //Colour Cycle
|
||||
CM_RGB_MODE_FLASH = 2, //Flash
|
||||
CM_RGB_MODE_BREATHING = 3, //Breathing
|
||||
CM_RGB_MODE_PASSTHRU = 4 //Motherboard Pass Thru Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_ARGB_MODE_OFF = 0, //Turn off
|
||||
CM_ARGB_MODE_SPECTRUM = 1, //Spectrum Mode
|
||||
CM_ARGB_MODE_RELOAD = 2, //Reload Mode
|
||||
CM_ARGB_MODE_RECOIL = 3, //Recoil Mode
|
||||
CM_ARGB_MODE_BREATHING = 4, //Breathing Mode
|
||||
CM_ARGB_MODE_REFILL = 5, //Refill Mode
|
||||
CM_ARGB_MODE_DEMO = 6, //Demo Mode
|
||||
CM_ARGB_MODE_FILLFLOW = 7, //Fill Flow Mode
|
||||
CM_ARGB_MODE_RAINBOW = 8, //Rainbow Mode
|
||||
CM_ARGB_MODE_DIRECT = 0xFE, //Direct Led Control
|
||||
CM_ARGB_MODE_PASSTHRU = 0xFF //Motherboard Pass Thru Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_ARGB_SPEED_SLOWEST = 0x00, // Slowest speed
|
||||
CM_ARGB_SPEED_SLOW = 0x01, // Slower speed
|
||||
CM_ARGB_SPEED_NORMAL = 0x02, // Normal speed
|
||||
CM_ARGB_SPEED_FAST = 0x03, // Fast speed
|
||||
CM_ARGB_SPEED_FASTEST = 0x04, // Fastest speed
|
||||
};
|
||||
|
||||
class CMARGBController
|
||||
{
|
||||
public:
|
||||
CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
|
||||
~CMARGBController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetZoneIndex();
|
||||
unsigned char GetMode();
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
unsigned char GetLedBlue();
|
||||
unsigned char GetLedSpeed();
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLedsDirect(RGBColor * led_colours, unsigned int led_count);
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string serial;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char zone_index;
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
|
||||
unsigned int GetLargestColour(unsigned int red, unsigned int green, unsigned int blue);
|
||||
unsigned char GetColourIndex(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
|
||||
};
|
||||
@@ -1,172 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMMP750Controller.h"
|
||||
|
||||
static unsigned char colour_mode_data[][6] =
|
||||
{
|
||||
{ 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */
|
||||
{ 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */
|
||||
{ 0x03, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Breathing */
|
||||
{ 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */
|
||||
{ 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */
|
||||
};
|
||||
|
||||
static unsigned char speed_mode_data[][9] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
|
||||
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Blinking */
|
||||
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Breathing */
|
||||
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Colour Cycle */
|
||||
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 } /* Colour Breath */
|
||||
};
|
||||
|
||||
CMMP750Controller::CMMP750Controller(hid_device* dev_handle, char *_path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
|
||||
|
||||
hid_get_serial_number_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
GetStatus(); //When setting up device get current status
|
||||
}
|
||||
|
||||
CMMP750Controller::~CMMP750Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void CMMP750Controller::GetStatus()
|
||||
{
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
buffer[0] = 0x07;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read(dev, buffer, buffer_size);
|
||||
|
||||
if((buffer[0] == 0x80) && (buffer[1] == 0x05))
|
||||
{
|
||||
current_mode = buffer[2] - 1;
|
||||
current_red = buffer[3];
|
||||
current_green = buffer[4];
|
||||
current_blue = buffer[5];
|
||||
|
||||
for(int i = 0; speed_mode_data[current_mode][i] >= buffer[6]; i++)
|
||||
{
|
||||
current_speed = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Code should never reach here however just in case there is a failure set something
|
||||
current_mode = MP750_MODE_COLOR_CYCLE; //Unicorn Spew
|
||||
current_red = 0xFF;
|
||||
current_green = 0xFF;
|
||||
current_blue = 0xFF;
|
||||
current_speed = MP750_SPEED_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetLedRed()
|
||||
{
|
||||
return current_red;
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetLedGreen()
|
||||
{
|
||||
return current_green;
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetLedBlue()
|
||||
{
|
||||
return current_blue;
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetLedSpeed()
|
||||
{
|
||||
return current_speed;
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetMode(unsigned char mode, unsigned char speed)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
current_red = red;
|
||||
current_green = green;
|
||||
current_blue = blue;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMMP750Controller::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
for(std::size_t i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++)
|
||||
{
|
||||
buffer[i] = colour_mode_data[current_mode][i];
|
||||
}
|
||||
|
||||
if(current_mode > MP750_MODE_BREATHING)
|
||||
{
|
||||
//If the mode is random colours set SPEED at BYTE2
|
||||
buffer[CM_RED_BYTE] = speed_mode_data[current_mode][current_speed];
|
||||
}
|
||||
else
|
||||
{
|
||||
//Otherwise SPEED is BYTE5
|
||||
buffer[CM_RED_BYTE] = current_red;
|
||||
buffer[CM_GREEN_BYTE] = current_green;
|
||||
buffer[CM_BLUE_BYTE] = current_blue;
|
||||
buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 16th Apr 2020 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| BYTE0 = Mode (0x01 thru 0x05 |
|
||||
| BYTE1 = ?? Must be set to 0x04 for colour modes otherwise ignored |
|
||||
| BYTE2 = Colour Modes: RED else Cycle SPEED |
|
||||
| BYTE3 = Colour Modes: GREEN else ignored |
|
||||
| BYTE4 = Colour Modes: BLUE else ignored |
|
||||
| BYTE5 = Colour Modes: SPEED else ignored |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
|
||||
#define CM_INTERRUPT_TIMEOUT 250
|
||||
#define CM_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_SERIAL_SIZE (sizeof(serial) / sizeof(serial[ 0 ]))
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MODE_BYTE = 0,
|
||||
CM_RED_BYTE = 2,
|
||||
CM_GREEN_BYTE = 3,
|
||||
CM_BLUE_BYTE = 4,
|
||||
CM_SPEED_BYTE = 5
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_MODE_STATIC = 0x00, //Static Mode
|
||||
MP750_MODE_BLINK = 0x01, //Blinking Mode
|
||||
MP750_MODE_BREATHING = 0x02, //Breathing Mode
|
||||
MP750_MODE_COLOR_CYCLE = 0x03, //Color Cycle Mode
|
||||
MP750_MODE_BREATH_CYCLE = 0x04 //Breathing Cycle Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MP750_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
MP750_SPEED_SLOWER = 0x01, /* Slower speed */
|
||||
MP750_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
MP750_SPEED_SLOWISH = 0x03, /* Slowish speed */
|
||||
MP750_SPEED_NORMAL = 0x04, /* Normal speed */
|
||||
MP750_SPEED_FASTISH = 0x05, /* Fastish speed */
|
||||
MP750_SPEED_FAST = 0x06, /* Fast speed */
|
||||
MP750_SPEED_FASTER = 0x07, /* Faster speed */
|
||||
MP750_SPEED_FASTEST = 0x08, /* Fastest speed */
|
||||
};
|
||||
|
||||
class CMMP750Controller
|
||||
{
|
||||
public:
|
||||
CMMP750Controller(hid_device* dev_handle, char *_path);
|
||||
~CMMP750Controller();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetMode();
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
unsigned char GetLedBlue();
|
||||
unsigned char GetLedSpeed();
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string serial;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
};
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CMMP750Controller.h"
|
||||
#include "CMARGBcontroller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include "RGBController_CMARGBController.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define COOLERMASTER_VID 0x2516
|
||||
|
||||
#define COOLERMASTER_MP750_XL_PID 0x0109
|
||||
#define COOLERMASTER_MP750_MEDIUM_PID 0x0105
|
||||
#define COOLERMASTER_ARGB_PID 0x1011
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCoolerMasterControllers *
|
||||
* *
|
||||
* Tests the USB address to see if any CoolerMaster controllers exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCoolerMasterMousemats(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
CMMP750Controller* controller = new CMMP750Controller(dev, info->path);
|
||||
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectCoolerMasterARGB(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
for(std::size_t i = 0; i < CM_ARGB_HEADER_DATA_SIZE; i++)
|
||||
{
|
||||
CMARGBController* controller = new CMARGBController(dev, info->path, i);
|
||||
RGBController_CMARGBController* rgb_controller = new RGBController_CMARGBController(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 XL", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_XL_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 Medium", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_MEDIUM_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master ARGB", DetectCoolerMasterARGB, COOLERMASTER_VID, COOLERMASTER_ARGB_PID, 0, 0xFF00, 1);
|
||||
@@ -1,315 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster ARGB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 14th Oct 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMARGBController.h"
|
||||
|
||||
RGBController_CMARGBController::RGBController_CMARGBController(CMARGBController *cmargb_ptr)
|
||||
{
|
||||
cmargb = cmargb_ptr;
|
||||
unsigned char speed = cmargb->GetLedSpeed();
|
||||
|
||||
name = argb_header_data[cmargb->GetZoneIndex()].name;
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = cmargb->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = cmargb->GetSerial();
|
||||
location = cmargb->GetLocation();
|
||||
|
||||
if ( argb_header_data[cmargb->GetZoneIndex()].digital)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_ARGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Reload;
|
||||
Reload.name = "Reload";
|
||||
Reload.value = CM_ARGB_MODE_RELOAD;
|
||||
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Reload.colors_min = 1;
|
||||
Reload.colors_max = 1;
|
||||
Reload.colors.resize(Reload.colors_max);
|
||||
Reload.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Reload.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Reload.color_mode = MODE_COLORS_RANDOM;
|
||||
Reload.speed = speed;
|
||||
modes.push_back(Reload);
|
||||
|
||||
mode Recoil;
|
||||
Recoil.name = "Recoil";
|
||||
Recoil.value = CM_ARGB_MODE_RECOIL;
|
||||
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Recoil.colors_min = 1;
|
||||
Recoil.colors_max = 1;
|
||||
Recoil.colors.resize(Reload.colors_max);
|
||||
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Recoil.color_mode = MODE_COLORS_RANDOM;
|
||||
Recoil.speed = speed;
|
||||
modes.push_back(Recoil);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_ARGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Reload.colors_max);
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_RANDOM;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Refill;
|
||||
Refill.name = "Refill";
|
||||
Refill.value = CM_ARGB_MODE_REFILL;
|
||||
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Refill.colors_min = 1;
|
||||
Refill.colors_max = 1;
|
||||
Refill.colors.resize(Reload.colors_max);
|
||||
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Refill.color_mode = MODE_COLORS_RANDOM;
|
||||
Refill.speed = speed;
|
||||
modes.push_back(Refill);
|
||||
|
||||
mode Demo;
|
||||
Demo.name = "Demo";
|
||||
Demo.value = CM_ARGB_MODE_DEMO;
|
||||
Demo.flags = MODE_FLAG_HAS_SPEED;
|
||||
Demo.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Demo.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Demo.color_mode = MODE_COLORS_NONE;
|
||||
Demo.speed = speed;
|
||||
modes.push_back(Demo);
|
||||
|
||||
mode Spectrum;
|
||||
Spectrum.name = "Spectrum";
|
||||
Spectrum.value = CM_ARGB_MODE_SPECTRUM;
|
||||
Spectrum.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spectrum.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Spectrum.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Spectrum.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum.speed = speed;
|
||||
modes.push_back(Spectrum);
|
||||
|
||||
mode FillFlow;
|
||||
FillFlow.name = "Fill Flow";
|
||||
FillFlow.value = CM_ARGB_MODE_FILLFLOW;
|
||||
FillFlow.flags = MODE_FLAG_HAS_SPEED;
|
||||
FillFlow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
FillFlow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
FillFlow.color_mode = MODE_COLORS_NONE;
|
||||
FillFlow.speed = speed;
|
||||
modes.push_back(FillFlow);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CM_ARGB_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed = speed;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = CM_ARGB_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_ARGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_RGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_RGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_RANDOM;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flash;
|
||||
Breathing.name = "Flash";
|
||||
Breathing.value = CM_RGB_MODE_FLASH;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_RANDOM;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColourCycle;
|
||||
ColourCycle.name = "Colour Cycle";
|
||||
ColourCycle.value = CM_RGB_MODE_COLOUR_CYCLE;
|
||||
ColourCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColourCycle.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
ColourCycle.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
ColourCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColourCycle.speed = speed;
|
||||
modes.push_back(ColourCycle);
|
||||
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_RGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
}
|
||||
|
||||
Init_Controller(); //Only processed on first run
|
||||
SetupZones();
|
||||
//active_mode = cmargb->GetMode();
|
||||
}
|
||||
|
||||
RGBController_CMARGBController::~RGBController_CMARGBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = cmargb->GetZoneIndex();
|
||||
int zone_led_count = argb_header_data[zone_idx].count;
|
||||
bool boolSingleLED = ( zone_led_count == 1 ); //If argb_header_data[zone_idx].count == 1 then the zone is ZONE_TYPE_SINGLE
|
||||
|
||||
zone ARGB_zone;
|
||||
ARGB_zone.name = std::to_string(zone_idx);
|
||||
ARGB_zone.type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
|
||||
ARGB_zone.leds_min = 0;
|
||||
ARGB_zone.leds_max = 64;
|
||||
ARGB_zone.leds_count = zone_led_count;
|
||||
ARGB_zone.matrix_map = NULL;
|
||||
zones.push_back(ARGB_zone);
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
|
||||
|
||||
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
|
||||
{
|
||||
led new_led;
|
||||
unsigned int i = std::stoi(zones[zone_idx].name);
|
||||
|
||||
if(boolSingleLED)
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.value = argb_header_data[i].header;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.name.append(" LED " + std::to_string(lp_idx));
|
||||
new_led.value = argb_header_data[i].header;
|
||||
}
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
/*unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
cmargb->SetColor(red, grn, blu);*/
|
||||
|
||||
//this one
|
||||
cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed );
|
||||
cmargb->SetLedsDirect( zones[0].colors, zones[0].leds_count );
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor colour = colors[zone];
|
||||
unsigned char red = RGBGetRValue(colour);
|
||||
unsigned char grn = RGBGetGValue(colour);
|
||||
unsigned char blu = RGBGetBValue(colour);
|
||||
cmargb->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::UpdateSingleLED(int led)
|
||||
{
|
||||
//cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed );
|
||||
//cmargb->SetLedsDirect( zones[0].colors, zones[0].leds_count );
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::SetCustomMode()
|
||||
{
|
||||
active_mode = CM_ARGB_MODE_DIRECT;
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateMode()
|
||||
{
|
||||
if( modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC )
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
cmargb->SetColor(red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmargb->SetColor(0, 0, 0); //If the mode is not colour specific then set colour to black for the random index
|
||||
}
|
||||
cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed );
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster ARGB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 14th Oct 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMARGBcontroller.h"
|
||||
#include <vector>
|
||||
|
||||
class RGBController_CMARGBController : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMARGBController(CMARGBController* cmargb_ptr);
|
||||
~RGBController_CMARGBController();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
private:
|
||||
void Init_Controller();
|
||||
int GetDeviceMode();
|
||||
|
||||
CMARGBController* cmargb;
|
||||
};
|
||||
@@ -1,148 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
|
||||
RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr)
|
||||
{
|
||||
cmmp750 = cmmp_ptr;
|
||||
unsigned char speed = cmmp750->GetLedSpeed();
|
||||
|
||||
name = cmmp750->GetDeviceName();
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = cmmp750->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = cmmp750->GetSerial();
|
||||
location = cmmp750->GetLocation();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = MP750_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = MP750_MODE_BLINK;
|
||||
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Blink.speed_min = MP750_SPEED_SLOWEST;
|
||||
Blink.speed_max = MP750_SPEED_FASTEST;
|
||||
Blink.color_mode = MODE_COLORS_PER_LED;
|
||||
Blink.speed = speed;
|
||||
modes.push_back(Blink);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = MP750_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = MP750_SPEED_SLOWEST;
|
||||
Breathing.speed_max = MP750_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = MP750_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
ColorCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColorCycle.speed = speed;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode BreathCycle;
|
||||
BreathCycle.name = "Breath Cycle";
|
||||
BreathCycle.value = MP750_MODE_BREATH_CYCLE;
|
||||
BreathCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
BreathCycle.speed_min = MP750_SPEED_SLOWEST;
|
||||
BreathCycle.speed_max = MP750_SPEED_FASTEST;
|
||||
BreathCycle.color_mode = MODE_COLORS_NONE;
|
||||
BreathCycle.speed = speed;
|
||||
modes.push_back(BreathCycle);
|
||||
|
||||
SetupZones();
|
||||
active_mode = cmmp750->GetMode();
|
||||
}
|
||||
|
||||
RGBController_CMMP750Controller::~RGBController_CMMP750Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetupZones()
|
||||
{
|
||||
zone MP_zone;
|
||||
MP_zone.name = "Mousepad";
|
||||
MP_zone.type = ZONE_TYPE_SINGLE;
|
||||
MP_zone.leds_min = 1;
|
||||
MP_zone.leds_max = 1;
|
||||
MP_zone.leds_count = 1;
|
||||
MP_zone.matrix_map = NULL;
|
||||
zones.push_back(MP_zone);
|
||||
|
||||
led MP_led;
|
||||
MP_led.name = "Mousepad LED";
|
||||
leds.push_back(MP_led);
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize colors for each LED |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
unsigned char red = cmmp750->GetLedRed();
|
||||
unsigned char grn = cmmp750->GetLedGreen();
|
||||
unsigned char blu = cmmp750->GetLedBlue();
|
||||
|
||||
colors[led_idx] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
cmmp750->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CMMP750Controller::DeviceUpdateMode()
|
||||
{
|
||||
cmmp750->SetMode(modes[active_mode].value, modes[active_mode].speed);
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMMP750Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster MP750 mousepad |
|
||||
| |
|
||||
| Chris M (Dr_No) 18th Apr 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMMP750Controller.h"
|
||||
|
||||
class RGBController_CMMP750Controller : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMMP750Controller(CMMP750Controller* cmmp_ptr);
|
||||
~RGBController_CMMP750Controller();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
private:
|
||||
CMMP750Controller* cmmp750;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
@@ -0,0 +1,507 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairCmdrProController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
//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
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
CorsairCmdrProController* corsair = static_cast<CorsairCmdrProController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairCmdrProController::CorsairCmdrProController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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
|
||||
}
|
||||
|
||||
CorsairCmdrProController::~CorsairCmdrProController()
|
||||
{
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendReset(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendBegin(channel);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Effect Configuration packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendEffectConfig
|
||||
(
|
||||
channel,
|
||||
0,
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
|
||||
mode,
|
||||
speed,
|
||||
direction,
|
||||
random,
|
||||
red1,
|
||||
grn1,
|
||||
blu1,
|
||||
red2,
|
||||
grn2,
|
||||
blu2,
|
||||
red3,
|
||||
grn3,
|
||||
blu3,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char color_data[50];
|
||||
unsigned char pkt_max;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairCmdrProController::SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = start;
|
||||
usb_buf[0x03] = count;
|
||||
usb_buf[0x04] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], color_data, count);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendCommit()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect Config packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = count * 10;
|
||||
usb_buf[0x03] = 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;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode colors |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x09] = color_0_red;
|
||||
usb_buf[0x10] = color_0_green;
|
||||
usb_buf[0x11] = color_0_blue;
|
||||
usb_buf[0x12] = color_1_red;
|
||||
usb_buf[0x13] = color_1_green;
|
||||
usb_buf[0x14] = color_1_blue;
|
||||
usb_buf[0x15] = color_2_red;
|
||||
usb_buf[0x16] = color_2_green;
|
||||
usb_buf[0x17] = 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);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendTemperature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = state;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendBrightness()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendLEDCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairCmdrProController::SendProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Commander Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/16/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
|
||||
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
|
||||
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
|
||||
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
|
||||
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
|
||||
};
|
||||
|
||||
class CorsairCmdrProController
|
||||
{
|
||||
public:
|
||||
CorsairCmdrProController(libusb_device_handle* dev_handle);
|
||||
~CorsairCmdrProController();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
void SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
|
||||
void SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
);
|
||||
|
||||
void SendTemperature();
|
||||
|
||||
void SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
);
|
||||
|
||||
void SendBrightness();
|
||||
|
||||
void SendLEDCount();
|
||||
|
||||
void SendProtocol();
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "CorsairCmdrProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairCmdrPro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define CORSAIR_COMMANDER_PRO_VID 0x1B1C
|
||||
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairCmdrProControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Commander Pro driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for Corsair Commander Pro
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_COMMANDER_PRO_VID, CORSAIR_COMMANDER_PRO_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairCmdrProController* controller = new CorsairCmdrProController(dev);
|
||||
|
||||
RGBController_CorsairCmdrPro* rgb_controller = new RGBController_CorsairCmdrPro(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairCmdrProControllers() */
|
||||
+10
-10
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairVengeanceController.h |
|
||||
| CorsairController.h |
|
||||
| |
|
||||
| Driver for Corsair Vengeance RGB RAM |
|
||||
| lighting controller |
|
||||
@@ -7,10 +7,10 @@
|
||||
| Adam Honse (CalcProgrammer1) 3/8/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairVengeanceController.h"
|
||||
#include "CorsairController.h"
|
||||
#include <cstring>
|
||||
|
||||
CorsairVengeanceController::CorsairVengeanceController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
CorsairController::CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
@@ -19,32 +19,32 @@ CorsairVengeanceController::CorsairVengeanceController(i2c_smbus_interface* bus,
|
||||
led_count = 1;
|
||||
}
|
||||
|
||||
CorsairVengeanceController::~CorsairVengeanceController()
|
||||
CorsairController::~CorsairController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CorsairVengeanceController::GetDeviceName()
|
||||
std::string CorsairController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CorsairVengeanceController::GetDeviceLocation()
|
||||
std::string CorsairController::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("I2C: " + return_string);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned int CorsairVengeanceController::GetLEDCount()
|
||||
unsigned int CorsairController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CorsairVengeanceController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_RED_VAL, red);
|
||||
@@ -53,7 +53,7 @@ void CorsairVengeanceController::SetLEDColor(unsigned char red, unsigned char gr
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void CorsairVengeanceController::SetMode(unsigned char /*mode*/)
|
||||
void CorsairController::SetMode(unsigned char /*mode*/)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairVengeanceController.h |
|
||||
| CorsairController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance RGB RAM lighting controller |
|
||||
@@ -33,11 +33,11 @@ enum
|
||||
CORSAIR_NUMBER_MODES /* Number of Corsair modes */
|
||||
};
|
||||
|
||||
class CorsairVengeanceController
|
||||
class CorsairController
|
||||
{
|
||||
public:
|
||||
CorsairVengeanceController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairVengeanceController();
|
||||
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
@@ -0,0 +1,125 @@
|
||||
#include "CorsairController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Corsair.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != 0xBA)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairControllers *
|
||||
* *
|
||||
* Detect Corsair controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairController* new_corsair;
|
||||
RGBController_Corsair* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairControllers() */
|
||||
-126
@@ -1,126 +0,0 @@
|
||||
/*------------------------------------------*\
|
||||
| CorsairDominatorPlatinumController.cpp |
|
||||
| |
|
||||
| Drover for Corsair Domintator Platinum |
|
||||
| RGB RAM lighting controller |
|
||||
| |
|
||||
| Erik Gilling (konkers) 9/25/2020 |
|
||||
\*------------------------------------------*/
|
||||
|
||||
#include "CorsairDominatorPlatinumController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
CorsairDominatorPlatinumController::CorsairDominatorPlatinumController(i2c_smbus_interface *bus, corsair_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
led_data[0] = 0xc;
|
||||
}
|
||||
|
||||
CorsairDominatorPlatinumController::~CorsairDominatorPlatinumController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CorsairDominatorPlatinumController::GetDeviceName()
|
||||
{
|
||||
return "Corsair Dominator Platinum RGB";
|
||||
}
|
||||
|
||||
std::string CorsairDominatorPlatinumController::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("I2C: " + return_string);
|
||||
}
|
||||
|
||||
void CorsairDominatorPlatinumController::SetAllColors
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
for(unsigned int led = 0; led < CORSAIR_PLAT_LED_COUNT; led++)
|
||||
{
|
||||
SetLEDColor(led, red, green, blue);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairDominatorPlatinumController::SetLEDColor
|
||||
(
|
||||
unsigned int led,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
if(led >= CORSAIR_PLAT_LED_COUNT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int offset = (led * 3) + 1;
|
||||
led_data[offset] = red;
|
||||
led_data[offset + 1] = green;
|
||||
led_data[offset + 2] = blue;
|
||||
}
|
||||
|
||||
unsigned char CorsairDominatorPlatinumController::crc8
|
||||
(
|
||||
unsigned char init,
|
||||
unsigned char poly,
|
||||
unsigned char* data,
|
||||
unsigned char len
|
||||
)
|
||||
{
|
||||
unsigned char crc = init;
|
||||
|
||||
for(unsigned int i = 0; i < len; i++)
|
||||
{
|
||||
unsigned char val = data[i];
|
||||
for(unsigned char mask = 0x80; mask != 0; mask >>= 1)
|
||||
{
|
||||
unsigned char bit;
|
||||
if ((val & mask) != 0)
|
||||
{
|
||||
bit = (crc & 0x80) ^ 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
bit = crc & 0x80;
|
||||
}
|
||||
|
||||
if (bit == 0)
|
||||
{
|
||||
crc <<= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = (crc << 1) ^ poly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
void CorsairDominatorPlatinumController::ApplyColors()
|
||||
{
|
||||
unsigned char data[sizeof(led_data)];
|
||||
memcpy(data, led_data, sizeof(led_data));
|
||||
unsigned char crc = crc8(0x0, 0x7, data, sizeof(data) - 1);
|
||||
data[sizeof(data) - 1] = crc;
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, 0x31, 0x20, data);
|
||||
std::this_thread::sleep_for(800us);
|
||||
bus->i2c_smbus_write_block_data(dev, 0x32, sizeof(data) - 0x20, data + 0x20);
|
||||
std::this_thread::sleep_for(200us);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairDominatorPlatinumController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Domintator Platinum RGB RAM lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Erik Gilling (konkers) 9/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char corsair_dev_id;
|
||||
|
||||
class CorsairDominatorPlatinumController
|
||||
{
|
||||
public:
|
||||
CorsairDominatorPlatinumController(i2c_smbus_interface *bus, corsair_dev_id dev);
|
||||
~CorsairDominatorPlatinumController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
|
||||
size_t GetLEDCount() { return CORSAIR_PLAT_LED_COUNT; }
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void ApplyColors();
|
||||
bool WaitReady();
|
||||
|
||||
private:
|
||||
static constexpr size_t CORSAIR_PLAT_LED_COUNT = 12;
|
||||
|
||||
unsigned char led_data[CORSAIR_PLAT_LED_COUNT * 3 + 2];
|
||||
|
||||
i2c_smbus_interface* bus;
|
||||
corsair_dev_id dev;
|
||||
|
||||
static unsigned char crc8(unsigned char init, unsigned char poly, unsigned char *data, unsigned char len);
|
||||
};
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairDominatorPlatinumController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairDominatorPlatinum.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
bool TestForCorsairDominatorPlatinumController(i2c_smbus_interface *bus, unsigned char address)
|
||||
{
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
if(res < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if(res != 0x1b)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if(res != 0x04)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairDominatorPlatinumControllers *
|
||||
* *
|
||||
* Detect Corsair Dominator Platinum controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairDominatorPlatinumControllers(std::vector<i2c_smbus_interface *> &busses, std::vector<RGBController *> &rgb_controllers)
|
||||
{
|
||||
for(unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
{
|
||||
for(unsigned char addr = 0x58; addr <= 0x5f; addr++)
|
||||
{
|
||||
if(TestForCorsairDominatorPlatinumController(busses[bus], addr))
|
||||
{
|
||||
CorsairDominatorPlatinumController* new_controller = new CorsairDominatorPlatinumController(busses[bus], addr);
|
||||
RGBController_CorsairDominatorPlatinum* new_rgbcontroller = new RGBController_CorsairDominatorPlatinum(new_controller);
|
||||
rgb_controllers.push_back(new_rgbcontroller);
|
||||
}
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_I2C_DETECTOR("Corsair Dominator Platinum", DetectCorsairDominatorPlatinumControllers);
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/*-------------------------------------------------*\
|
||||
| RGBController_CorsairDominatorPlatinum.cpp |
|
||||
| |
|
||||
| Corsair Vengeance Pro RGB driver |
|
||||
| |
|
||||
| Erik Gilling (konkers) 9/25/2020 |
|
||||
\*-------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairDominatorPlatinum.h"
|
||||
|
||||
RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
vendor = "Corsair";
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Corsair Dominator Platinum RGB Device";
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.speed_min = 0;
|
||||
Direct.speed_max = 0;
|
||||
Direct.speed = 0;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
new_zone.name = "Corsair Platinum Zone";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = corsair->GetLEDCount();
|
||||
new_zone.leds_max = corsair->GetLEDCount();
|
||||
new_zone.leds_count = corsair->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
|
||||
{
|
||||
led *new_led = new led();
|
||||
new_led->name = "Corsair Platinum LED ";
|
||||
new_led->name.append(std::to_string(led_idx));
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::UpdateSingleLED(int led)
|
||||
{
|
||||
RGBColor color = colors[led];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairDominatorPlatinum::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
/*--------------------------------------------*\
|
||||
| RGBController_CorsairDominatorPlatinum.h |
|
||||
| |
|
||||
| Corsair Dominator Platinum RGB driver |
|
||||
| |
|
||||
| Erik Gilling (konkers) 9/25/2020 |
|
||||
\*--------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CorsairDominatorPlatinumController.h"
|
||||
|
||||
class RGBController_CorsairDominatorPlatinum : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairDominatorPlatinum(CorsairDominatorPlatinumController* corsair_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CorsairDominatorPlatinumController* corsair;
|
||||
};
|
||||
@@ -1,268 +0,0 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Corsair Hydro Series |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 8/17/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairHydroController.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
|
||||
CorsairHydroController::CorsairHydroController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in location string with USB ID |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(libusb_get_device(dev_handle), &descriptor);
|
||||
|
||||
std::stringstream location_stream;
|
||||
location_stream << std::hex << std::setfill('0') << std::setw(4) << descriptor.idVendor << ":" << std::hex << std::setfill('0') << std::setw(4) << descriptor.idProduct;
|
||||
location = location_stream.str();
|
||||
|
||||
SendInit();
|
||||
|
||||
SendFirmwareRequest();
|
||||
}
|
||||
|
||||
std::string CorsairHydroController::GetFirmwareString()
|
||||
{
|
||||
return(firmware_version);
|
||||
}
|
||||
|
||||
std::string CorsairHydroController::GetLocation()
|
||||
{
|
||||
return("USB: " + location);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SetBlink
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
SendColors(colors);
|
||||
SendSpeed(speed);
|
||||
SendApplyBlink();
|
||||
}
|
||||
|
||||
void CorsairHydroController::SetFixed
|
||||
(
|
||||
std::vector<RGBColor> & colors
|
||||
)
|
||||
{
|
||||
SendColors(colors);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fixed mode seems to just be shift mode with the same |
|
||||
| value for both colors |
|
||||
\*-----------------------------------------------------*/
|
||||
SendApplyShift();
|
||||
}
|
||||
|
||||
void CorsairHydroController::SetPulse
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
SendColors(colors);
|
||||
SendSpeed(speed);
|
||||
SendApplyPulse();
|
||||
}
|
||||
|
||||
void CorsairHydroController::SetShift
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
SendColors(colors);
|
||||
SendSpeed(speed);
|
||||
SendApplyShift();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairHydroController::SendApplyBlink()
|
||||
{
|
||||
unsigned char usb_buf[3];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Apply Blink packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x58;
|
||||
usb_buf[1] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendApplyPulse()
|
||||
{
|
||||
unsigned char usb_buf[3];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Apply Pulse packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x52;
|
||||
usb_buf[1] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendApplyShift()
|
||||
{
|
||||
unsigned char usb_buf[3];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Apply Shift packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x55;
|
||||
usb_buf[1] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendFirmwareRequest()
|
||||
{
|
||||
unsigned char usb_buf[8];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Firmware Request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0xAA;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 1, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 7, &actual, 1000);
|
||||
|
||||
firmware_version = std::to_string(usb_buf[3]) + "." + std::to_string(usb_buf[4]) + "." + std::to_string(usb_buf[5]) + "." + std::to_string(usb_buf[6]);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendColors
|
||||
(
|
||||
std::vector<RGBColor> & colors
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[23];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Send Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x56;
|
||||
usb_buf[1] = colors.size();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill in colors from vector |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
usb_buf[(color_idx * 3) + 2] = RGBGetRValue(colors[color_idx]);
|
||||
usb_buf[(color_idx * 3) + 3] = RGBGetGValue(colors[color_idx]);
|
||||
usb_buf[(color_idx * 3) + 4] = RGBGetBValue(colors[color_idx]);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If the color vector only has one entry, duplicate it, as |
|
||||
| the controller appears to require two colors in order to |
|
||||
| update. |
|
||||
\*---------------------------------------------------------*/
|
||||
if((color_idx == 0) && colors.size() == 1)
|
||||
{
|
||||
usb_buf[1] = colors.size() + 1;
|
||||
usb_buf[(color_idx * 3) + 5] = RGBGetRValue(colors[color_idx]);
|
||||
usb_buf[(color_idx * 3) + 6] = RGBGetGValue(colors[color_idx]);
|
||||
usb_buf[(color_idx * 3) + 7] = RGBGetBValue(colors[color_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2 + (usb_buf[1] * 3), &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendInit()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_control_transfer( dev, 0x40, 0x00, 0xffff, 0x0000, NULL, 0, 0 );
|
||||
libusb_control_transfer( dev, 0x40, 0x02, 0x0002, 0x0000, NULL, 0, 0 );
|
||||
}
|
||||
|
||||
void CorsairHydroController::SendSpeed
|
||||
(
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[3];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Send Speed packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0] = 0x53;
|
||||
usb_buf[1] = speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
|
||||
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Hydro Series |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 8/17/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_HYDRO_CMD_READ_PUMP_SPEED = 0x31,
|
||||
CORSAIR_HYDRO_CMD_WRITE_PUMP_MODE = 0x32,
|
||||
CORSAIR_HYDRO_CMD_READ_PUMP_MODE = 0x33,
|
||||
CORSAIR_HYDRO_CMD_READ_FAN_SPEED = 0x41,
|
||||
CORSAIR_HYDRO_CMD_READ_AIO_TEMP = 0xA9,
|
||||
CORSAIR_HYDRO_CMD_READ_FIRMWARE = 0xAA,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_HYDRO_PUMP_MODE_QUIET = 0x00,
|
||||
CORSAIR_HYDRO_PUMP_MODE_BALANCED = 0x01,
|
||||
CORSAIR_HYDRO_PUMP_MODE_PERFORMANCE = 0x02,
|
||||
};
|
||||
|
||||
class CorsairHydroController
|
||||
{
|
||||
public:
|
||||
CorsairHydroController(libusb_device_handle* dev_handle);
|
||||
~CorsairHydroController();
|
||||
|
||||
unsigned char GetFanPercent(unsigned char fan_channel);
|
||||
|
||||
unsigned short GetFanRPM(unsigned char fan_channel);
|
||||
|
||||
std::string GetFirmwareString();
|
||||
|
||||
std::string GetLocation();
|
||||
|
||||
void SetBlink
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SetFixed
|
||||
(
|
||||
std::vector<RGBColor> & colors
|
||||
);
|
||||
|
||||
void SetPulse
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SetShift
|
||||
(
|
||||
std::vector<RGBColor> & colors,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
|
||||
void SendApplyBlink();
|
||||
void SendApplyPulse();
|
||||
void SendApplyShift();
|
||||
|
||||
void SendColors
|
||||
(
|
||||
std::vector<RGBColor> & colors
|
||||
);
|
||||
|
||||
void SendFirmwareRequest();
|
||||
|
||||
void SendInit();
|
||||
|
||||
void SendSpeed
|
||||
(
|
||||
unsigned char speed
|
||||
);
|
||||
};
|
||||
@@ -1,78 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairHydroController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairHydro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard Hydro Series product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_H115I_PRO_RGB_PID 0x0C13
|
||||
#define CORSAIR_H100I_PRO_RGB_PID 0x0C15
|
||||
#define CORSAIR_H150I_PRO_RGB_PID 0x0C12
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
const char * name;
|
||||
} corsair_hydro_device;
|
||||
|
||||
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const corsair_hydro_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Coolers |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_H100I_PRO_RGB_PID, 0, "Corsair H100i PRO RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_H115I_PRO_RGB_PID, 0, "Corsair H115i PRO RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_H150I_PRO_RGB_PID, 0, "Corsair H150i PRO RGB" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairHydroControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Corsair RGB Cooler controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
#ifdef _WIN32
|
||||
libusb_set_option(ctx, LIBUSB_OPTION_USE_USBDK);
|
||||
#endif
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Corsair RGB Peripheral
|
||||
if(dev)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairHydroController* controller = new CorsairHydroController(dev);//, device_list[device_idx].usb_endpoint);
|
||||
|
||||
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairHydroControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers);
|
||||
@@ -1,138 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairHydro.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Hydro Series |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairHydro.h"
|
||||
|
||||
RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
vendor = "Corsair";
|
||||
description = "Corsair Hydro Series Device";
|
||||
version = corsair->GetFirmwareString();
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
location = corsair->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Blinking;
|
||||
Blinking.name = "Blinking";
|
||||
Blinking.value = 1;
|
||||
Blinking.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Blinking.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Blinking.speed_min = 0x0F;
|
||||
Blinking.speed_max = 0x05;
|
||||
Blinking.speed = 0x0A;
|
||||
Blinking.colors_min = 2;
|
||||
Blinking.colors_max = 2;
|
||||
Blinking.colors.resize(2);
|
||||
modes.push_back(Blinking);
|
||||
|
||||
mode ColorShift;
|
||||
ColorShift.name = "Color Shift";
|
||||
ColorShift.value = 2;
|
||||
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorShift.speed_min = 0x46;
|
||||
ColorShift.speed_max = 0x0F;
|
||||
ColorShift.speed = 0x28;
|
||||
ColorShift.colors_min = 2;
|
||||
ColorShift.colors_max = 2;
|
||||
ColorShift.colors.resize(2);
|
||||
modes.push_back(ColorShift);
|
||||
|
||||
mode Pulsing;
|
||||
Pulsing.name = "Pulsing";
|
||||
Pulsing.value = 3;
|
||||
Pulsing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Pulsing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Pulsing.speed_min = 0x50;
|
||||
Pulsing.speed_max = 0x1E;
|
||||
Pulsing.speed = 0x37;
|
||||
Pulsing.colors_min = 2;
|
||||
Pulsing.colors_max = 2;
|
||||
Pulsing.colors.resize(2);
|
||||
modes.push_back(Pulsing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Pump Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
led new_led;
|
||||
|
||||
new_led.name = "Pump LED";
|
||||
leds.push_back(new_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydro::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case 0:
|
||||
corsair->SetFixed(colors);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
corsair->SetBlink(modes[active_mode].colors, modes[active_mode].speed);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
corsair->SetShift(modes[active_mode].colors, modes[active_mode].speed);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
corsair->SetPulse(modes[active_mode].colors, modes[active_mode].speed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairHydro.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair |
|
||||
| Hydro Series |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairHydroController.h"
|
||||
|
||||
class RGBController_CorsairHydro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairHydro(CorsairHydroController* corsair_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CorsairHydroController* corsair;
|
||||
};
|
||||
@@ -0,0 +1,253 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Corsair RGB keyboard lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairKeyboardController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
static void get_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_get_feature_report(dev, (unsigned char*)data_pkt, 64);
|
||||
bytes++;
|
||||
}
|
||||
|
||||
CorsairKeyboardController::CorsairKeyboardController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
char data_pkt[64] = { 0 };
|
||||
|
||||
LightingControl();
|
||||
}
|
||||
|
||||
CorsairKeyboardController::~CorsairKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char data_pkt[216];
|
||||
unsigned char red_val[144];
|
||||
unsigned char grn_val[144];
|
||||
unsigned char blu_val[144];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(data_pkt, 0x00, sizeof( data_pkt ));
|
||||
memset(red_val, 0x00, sizeof( red_val ));
|
||||
memset(grn_val, 0x00, sizeof( grn_val ));
|
||||
memset(blu_val, 0x00, sizeof( blu_val ));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Scale color values to 9-bit |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if( red > 7 ) red = 7;
|
||||
if( grn > 7 ) grn = 7;
|
||||
if( blu > 7 ) blu = 7;
|
||||
|
||||
red = 7 - red;
|
||||
grn = 7 - grn;
|
||||
blu = 7 - blu;
|
||||
|
||||
red_val[keys[color_idx]] = red;
|
||||
grn_val[keys[color_idx]] = grn;
|
||||
blu_val[keys[color_idx]] = blu;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Pack the color values, 2 values per byte |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int red_idx = 0; red_idx < 72; red_idx++)
|
||||
{
|
||||
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
|
||||
}
|
||||
|
||||
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
|
||||
{
|
||||
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
|
||||
}
|
||||
|
||||
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
|
||||
{
|
||||
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the packets |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &data_pkt[0]);
|
||||
StreamPacket(2, 60, &data_pkt[60]);
|
||||
StreamPacket(3, 60, &data_pkt[120]);
|
||||
StreamPacket(4, 36, &data_pkt[180]);
|
||||
|
||||
SubmitLimitedColors(216);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairKeyboardController::LightingControl()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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[0x04] = 0x03;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::ReadFirmwareInfo()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Read Firmware Info packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_READ;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
get_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Stream packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
|
||||
usb_buf[0x01] = packet_id;
|
||||
usb_buf[0x02] = data_sz;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04], data_ptr, data_sz);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SubmitColors()
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Keyboard 24-Bit Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
|
||||
void CorsairKeyboardController::SubmitLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairKeyboardController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair RGB |
|
||||
| keyboard lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COMMAND_WRITE = 0x07,
|
||||
CORSAIR_COMMAND_READ = 0x0E,
|
||||
CORSAIR_COMMAND_STREAM = 0x7F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PROPERTY_FIRMWARE_INFO = 0x01,
|
||||
CORSAIR_PROPERTY_RESET = 0x02,
|
||||
CORSAIR_PROPERTY_SPECIAL_FUNCTION = 0x04,
|
||||
CORSAIR_PROPERTY_LIGHTING_CONTROL = 0x05,
|
||||
CORSAIR_PROPERTY_HARDWARE_PROFILE = 0x13,
|
||||
CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR = 0x22,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9 = 0x27,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24 = 0x28,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_CONTROL_HARDWARE = 0x01,
|
||||
CORSAIR_LIGHTING_CONTROL_SOFTWARE = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COLOR_CHANNEL_RED = 0x01,
|
||||
CORSAIR_COLOR_CHANNEL_GREEN = 0x02,
|
||||
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
|
||||
};
|
||||
|
||||
class CorsairKeyboardController
|
||||
{
|
||||
public:
|
||||
CorsairKeyboardController(hid_device* dev_handle);
|
||||
~CorsairKeyboardController();
|
||||
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void LightingControl();
|
||||
|
||||
void ReadFirmwareInfo();
|
||||
|
||||
void StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
);
|
||||
|
||||
void SubmitColors();
|
||||
|
||||
void SubmitLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "CorsairKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairKeyboard.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define CORSAIR_RGB_KEYBOARD_VID 0x1B1C
|
||||
#define CORSAIR_RGB_KEYBOARD_K70_PID 0x1B13
|
||||
#define CORSAIR_RGB_KEYBOARD_K95_PID 0x1B11
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairKeyboardControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(CORSAIR_RGB_KEYBOARD_VID, CORSAIR_RGB_KEYBOARD_K70_PID);
|
||||
|
||||
//Look for Corsair RGB Keyboard, interface 1
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == CORSAIR_RGB_KEYBOARD_VID)
|
||||
&&(info->product_id == CORSAIR_RGB_KEYBOARD_K70_PID)
|
||||
&&(info->interface_number == 1))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairKeyboardController* controller = new CorsairKeyboardController(dev);
|
||||
|
||||
RGBController_CorsairKeyboard* rgb_controller = new RGBController_CorsairKeyboard(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/12/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE = 0x02, /* Get firmware version */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_RESET = 0x37, /* Reset channel packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
|
||||
CORSAIR_LIGHTING_NODE_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
|
||||
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
|
||||
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
|
||||
CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
|
||||
CORSAIR_LIGHTING_NODE_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
|
||||
CORSAIR_LIGHTING_NODE_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
|
||||
CORSAIR_LIGHTING_NODE_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_LIGHTING_NODE_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_LIGHTING_NODE_NUM_CHANNELS = 0x02, /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_SPEED_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_LIGHTING_NODE_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_LIGHTING_NODE_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_NODE_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_STATIC = 0x04, /* Static mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_TEMPERATURE = 0x05, /* Temperature mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_VISOR = 0x06, /* Visor mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_BLINK = 0x08, /* Blink mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_LIGHTING_NODE_MODE_RAINBOW = 0x0A, /* Rainbow mode */
|
||||
};
|
||||
|
||||
class CorsairLightingNodeController
|
||||
{
|
||||
public:
|
||||
CorsairLightingNodeController(hid_device* dev_handle, const char* path);
|
||||
~CorsairLightingNodeController();
|
||||
|
||||
std::string GetFirmwareString();
|
||||
std::string GetLocationString();
|
||||
std::string GetSerialString();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
void SetChannelEffect(unsigned char channel,
|
||||
unsigned char num_leds,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_commit_time;
|
||||
|
||||
void SendFirmwareRequest();
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
|
||||
void SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
);
|
||||
|
||||
void SendTemperature();
|
||||
|
||||
void SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
);
|
||||
|
||||
void SendBrightness();
|
||||
|
||||
void SendLEDCount();
|
||||
|
||||
void SendProtocol();
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairLightingNodeController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairLightingNode.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
#define CORSAIR_LIGHTING_NODE_CORE_PID 0x0C1A
|
||||
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
|
||||
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
|
||||
#define CORSAIR_LS100_PID 0x0C1E
|
||||
#define CORSAIR_1000D_OBSIDIAN_PID 0x1D00
|
||||
#define CORSAIR_SPEC_OMEGA_RGB_PID 0x1D04
|
||||
#define CORSAIR_LT100_PID 0x0C23
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairLightingNodeControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Lighting Node Pro driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairLightingNodeControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, info->path);
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairLightingNodeControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR("Corsair Lighting Node Core", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID); // 1 channel
|
||||
REGISTER_HID_DETECTOR("Corsair Lighting Node Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID); // 2 channels
|
||||
REGISTER_HID_DETECTOR("Corsair Commander Pro", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID); // 2 channels
|
||||
REGISTER_HID_DETECTOR("Corsair LS100 Lighting Kit", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LS100_PID); // 1 channel
|
||||
REGISTER_HID_DETECTOR("Corsair 1000D Obsidian", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID); // 2 channels
|
||||
REGISTER_HID_DETECTOR("Corsair SPEC OMEGA RGB", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID); // 2 channels
|
||||
REGISTER_HID_DETECTOR("Corsair LT100", DetectCorsairLightingNodeControllers, CORSAIR_VID, CORSAIR_LT100_PID); // 2 channels
|
||||
+225
-178
@@ -4,21 +4,53 @@
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 1/12/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "CorsairLightingNodeController.h"
|
||||
#include "CorsairNodeProController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
//Include thread libraries for Windows or Linux
|
||||
#ifdef WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "pthread.h"
|
||||
#include "unistd.h"
|
||||
#endif
|
||||
|
||||
CorsairLightingNodeController::CorsairLightingNodeController(hid_device* dev_handle, const char* path)
|
||||
//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
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
SendFirmwareRequest();
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
CorsairNodeProController* corsair = static_cast<CorsairNodeProController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
channel_leds[0] = 60;
|
||||
channel_leds[1] = 60;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The Corsair Lighting Node Pro requires a packet within|
|
||||
@@ -26,52 +58,28 @@ CorsairLightingNodeController::CorsairLightingNodeController(hid_device* dev_han
|
||||
| to not revert back into rainbow mode. Start a thread |
|
||||
| to continuously send a keepalive packet every 5s |
|
||||
\*-----------------------------------------------------*/
|
||||
keepalive_thread_run = 1;
|
||||
keepalive_thread = new std::thread(&CorsairLightingNodeController::KeepaliveThread, this);
|
||||
#ifdef WIN32
|
||||
_beginthread(keepalive_thread, 0, this);
|
||||
#else
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, &keepalive_thread, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
CorsairLightingNodeController::~CorsairLightingNodeController()
|
||||
CorsairNodeProController::~CorsairNodeProController()
|
||||
{
|
||||
keepalive_thread_run = 0;
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::KeepaliveThread()
|
||||
void CorsairNodeProController::KeepaliveThread()
|
||||
{
|
||||
while(keepalive_thread_run.load())
|
||||
while(1)
|
||||
{
|
||||
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(5))
|
||||
{
|
||||
SendCommit();
|
||||
}
|
||||
std::this_thread::sleep_for(1s);
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CorsairLightingNodeController::GetFirmwareString()
|
||||
{
|
||||
return(firmware_version);
|
||||
}
|
||||
|
||||
std::string CorsairLightingNodeController::GetLocationString()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string CorsairLightingNodeController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
|
||||
unsigned char num_leds,
|
||||
void CorsairNodeProController::SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
@@ -100,7 +108,7 @@ void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_HARDWARE);
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Effect Configuration packet |
|
||||
@@ -109,7 +117,7 @@ void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
|
||||
(
|
||||
channel,
|
||||
0,
|
||||
num_leds,
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
|
||||
mode,
|
||||
speed,
|
||||
direction,
|
||||
@@ -134,47 +142,125 @@ void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[50];
|
||||
unsigned char grn_color_data[50];
|
||||
unsigned char blu_color_data[50];
|
||||
unsigned char pkt_offset = 0;
|
||||
unsigned char pkt_size = 0;
|
||||
unsigned int colors_remaining = num_colors;
|
||||
unsigned char color_data[50];
|
||||
unsigned char pkt_max;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE);
|
||||
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Loop through colors and send 50 at a time |
|
||||
| Send red channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
while(colors_remaining > 0)
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
if(colors_remaining < 50)
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetRValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
pkt_size = colors_remaining;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkt_size = 50;
|
||||
}
|
||||
|
||||
for(int color_idx = 0; color_idx < pkt_size; color_idx++)
|
||||
{
|
||||
red_color_data[color_idx] = RGBGetRValue(colors[pkt_offset + color_idx]);
|
||||
grn_color_data[color_idx] = RGBGetGValue(colors[pkt_offset + color_idx]);
|
||||
blu_color_data[color_idx] = RGBGetBValue(colors[pkt_offset + color_idx]);
|
||||
color_data[idx] = RGBGetRValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, red_color_data);
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, grn_color_data);
|
||||
SendDirect(channel, pkt_offset, pkt_size, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, blu_color_data);
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
|
||||
}
|
||||
|
||||
colors_remaining -= pkt_size;
|
||||
pkt_offset += pkt_size;
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetGValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 1 |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 50;
|
||||
|
||||
if(pkt_max > colors.size())
|
||||
{
|
||||
pkt_max = (unsigned char)colors.size();
|
||||
}
|
||||
|
||||
for(int idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue channel packet 2 if necessary |
|
||||
\*-----------------------------------------------------*/
|
||||
pkt_max = 0;
|
||||
|
||||
if (colors.size() > 50)
|
||||
{
|
||||
pkt_max = (unsigned char)(colors.size() - 50);
|
||||
}
|
||||
|
||||
if(pkt_max > 0)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < pkt_max; idx++)
|
||||
{
|
||||
color_data[idx] = RGBGetBValue(colors[idx+50]);
|
||||
}
|
||||
|
||||
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -187,35 +273,7 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairLightingNodeController::SendFirmwareRequest()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Firmware Version Request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
actual = hid_read(dev, usb_buf, 17);
|
||||
|
||||
if(actual > 0)
|
||||
{
|
||||
firmware_version = std::to_string(usb_buf[0x01]) + "." + std::to_string(usb_buf[0x02]) + "." + std::to_string(usb_buf[0x03]);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendDirect
|
||||
void CorsairNodeProController::SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
@@ -224,7 +282,8 @@ void CorsairLightingNodeController::SendDirect
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -234,59 +293,52 @@ void CorsairLightingNodeController::SendDirect
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = start;
|
||||
usb_buf[0x03] = count;
|
||||
usb_buf[0x04] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x06], color_data, count);
|
||||
memcpy(&usb_buf[0x05], color_data, count);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendCommit()
|
||||
void CorsairNodeProController::SendCommit()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update last commit time |
|
||||
\*-----------------------------------------------------*/
|
||||
last_commit_time = std::chrono::steady_clock::now();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
|
||||
usb_buf[0x02] = 0xFF;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBegin
|
||||
void CorsairNodeProController::SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -296,18 +348,16 @@ void CorsairLightingNodeController::SendBegin
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Begin packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendEffectConfig
|
||||
void CorsairNodeProController::SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
@@ -330,7 +380,8 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
unsigned short temperature_2
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -340,62 +391,61 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect Config packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = count * 10;
|
||||
usb_buf[0x03] = led_type;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = mode;
|
||||
usb_buf[0x06] = speed;
|
||||
usb_buf[0x07] = direction;
|
||||
usb_buf[0x08] = change_style;
|
||||
usb_buf[0x09] = 0;
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = direction;
|
||||
usb_buf[0x07] = change_style;
|
||||
usb_buf[0x08] = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up mode colors |
|
||||
\*-----------------------------------------------------*/
|
||||
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;
|
||||
usb_buf[0x09] = color_0_red;
|
||||
usb_buf[0x10] = color_0_green;
|
||||
usb_buf[0x11] = color_0_blue;
|
||||
usb_buf[0x12] = color_1_red;
|
||||
usb_buf[0x13] = color_1_green;
|
||||
usb_buf[0x14] = color_1_blue;
|
||||
usb_buf[0x15] = color_2_red;
|
||||
usb_buf[0x16] = color_2_green;
|
||||
usb_buf[0x17] = color_2_blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up temperatures |
|
||||
\*-----------------------------------------------------*/
|
||||
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);
|
||||
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);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendTemperature()
|
||||
void CorsairNodeProController::SendTemperature()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendReset
|
||||
void CorsairNodeProController::SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -405,24 +455,23 @@ void CorsairLightingNodeController::SendReset
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Reset packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
|
||||
usb_buf[0x01] = channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendPortState
|
||||
void CorsairNodeProController::SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -432,29 +481,27 @@ void CorsairLightingNodeController::SendPortState
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Port State packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = state;
|
||||
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = state;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 17);
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBrightness()
|
||||
void CorsairNodeProController::SendBrightness()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendLEDCount()
|
||||
void CorsairNodeProController::SendLEDCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendProtocol()
|
||||
void CorsairNodeProController::SendProtocol()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Corsair Lighting Node Pro |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/12/2020 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
|
||||
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
|
||||
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
|
||||
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
|
||||
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
|
||||
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
|
||||
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
|
||||
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
|
||||
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
|
||||
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
|
||||
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_NODE_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
|
||||
CORSAIR_NODE_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
|
||||
CORSAIR_NODE_PRO_NUM_CHANNELS = 0x02 /* Number of channels */
|
||||
};
|
||||
|
||||
class CorsairNodeProController
|
||||
{
|
||||
public:
|
||||
CorsairNodeProController(libusb_device_handle* dev_handle);
|
||||
~CorsairNodeProController();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
void SetChannelEffect(unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
unsigned char red1,
|
||||
unsigned char grn1,
|
||||
unsigned char blu1,
|
||||
unsigned char red2,
|
||||
unsigned char grn2,
|
||||
unsigned char blu2,
|
||||
unsigned char red3,
|
||||
unsigned char grn3,
|
||||
unsigned char blu3
|
||||
);
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
|
||||
unsigned int channel_leds[CORSAIR_NODE_PRO_NUM_CHANNELS];
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start,
|
||||
unsigned char count,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
|
||||
void SendBegin
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendEffectConfig
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char count,
|
||||
unsigned char led_type,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
unsigned char change_style,
|
||||
unsigned char color_0_red,
|
||||
unsigned char color_0_green,
|
||||
unsigned char color_0_blue,
|
||||
unsigned char color_1_red,
|
||||
unsigned char color_1_green,
|
||||
unsigned char color_1_blue,
|
||||
unsigned char color_2_red,
|
||||
unsigned char color_2_green,
|
||||
unsigned char color_2_blue,
|
||||
unsigned short temperature_0,
|
||||
unsigned short temperature_1,
|
||||
unsigned short temperature_2
|
||||
);
|
||||
|
||||
void SendTemperature();
|
||||
|
||||
void SendReset
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
|
||||
void SendPortState
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char state
|
||||
);
|
||||
|
||||
void SendBrightness();
|
||||
|
||||
void SendLEDCount();
|
||||
|
||||
void SendProtocol();
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "CorsairNodeProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairNodePro.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define CORSAIR_LIGHTING_NODE_PRO_VID 0x1B1C
|
||||
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairNodeProControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Lighting Node Pro driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for Corsair Lighting Node Pro
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_LIGHTING_NODE_PRO_VID, CORSAIR_LIGHTING_NODE_PRO_PID);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
CorsairNodeProController* controller = new CorsairNodeProController(dev);
|
||||
|
||||
RGBController_CorsairNodePro* rgb_controller = new RGBController_CorsairNodePro(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectCorsairNodeProControllers() */
|
||||
@@ -1,661 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairPeripheralController.cpp |
|
||||
| |
|
||||
| Driver for Corsair RGB keyboard, mouse, |
|
||||
| and mousemat lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairPeripheralController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
|
||||
static unsigned int keys_k95_plat[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141,
|
||||
0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46,
|
||||
144, 145, 146, 158, 160, 147, 148, 149, 150, 151, 152, 153,
|
||||
154, 155, 159, 162, 161, 156, 157};
|
||||
|
||||
static unsigned int keys_k95[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
|
||||
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
|
||||
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141,
|
||||
0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46, 0x52, 0x5e, 0x6a, 0x76, 0x3b, 0x47, 0x53,
|
||||
0x5f, 0x6b, 0x77, 0x83, 0x8f, 0x0b, 0x17, 0x23, 0x2f};
|
||||
|
||||
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
|
||||
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
ReadFirmwareInfo();
|
||||
|
||||
LightingControl();
|
||||
}
|
||||
|
||||
CorsairPeripheralController::~CorsairPeripheralController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
device_type CorsairPeripheralController::GetDeviceType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
std::string CorsairPeripheralController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
int CorsairPeripheralController::GetPhysicalLayout()
|
||||
{
|
||||
return physical_layout;
|
||||
}
|
||||
|
||||
int CorsairPeripheralController::GetLogicalLayout()
|
||||
{
|
||||
return logical_layout;
|
||||
}
|
||||
|
||||
std::string CorsairPeripheralController::GetFirmwareString()
|
||||
{
|
||||
return firmware_version;
|
||||
}
|
||||
|
||||
std::string CorsairPeripheralController::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string CorsairPeripheralController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
SetLEDsKeyboardFull(colors);
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
SetLEDsMouse(colors);
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
SetLEDsMousemat(colors);
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
/*-----------------------------------------------------*\
|
||||
| The logo zone of the ST100 is in the middle of the |
|
||||
| base LED strip, so remap the colors so that the logo |
|
||||
| is the last LED in the sequence. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<RGBColor> remap_colors;
|
||||
remap_colors.resize(colors.size());
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
remap_colors[st100[i]] = colors[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The ST100 uses the mousemat protocol |
|
||||
\*-----------------------------------------------------*/
|
||||
SetLEDsMousemat(remap_colors);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_val[168];
|
||||
unsigned char grn_val[168];
|
||||
unsigned char blu_val[168];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(red_val, 0x00, sizeof( red_val ));
|
||||
memset(grn_val, 0x00, sizeof( grn_val ));
|
||||
memset(blu_val, 0x00, sizeof( blu_val ));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy red, green, and blue components into buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
red_val[keys_k95_plat[color_idx]] = RGBGetRValue(color);
|
||||
grn_val[keys_k95_plat[color_idx]] = RGBGetGValue(color);
|
||||
blu_val[keys_k95_plat[color_idx]] = RGBGetBValue(color);
|
||||
}
|
||||
else if (logical_layout == CORSAIR_TYPE_K95)
|
||||
{
|
||||
red_val[keys_k95[color_idx]] = RGBGetRValue(color);
|
||||
grn_val[keys_k95[color_idx]] = RGBGetGValue(color);
|
||||
blu_val[keys_k95[color_idx]] = RGBGetBValue(color);
|
||||
}
|
||||
else
|
||||
{
|
||||
red_val[keys[color_idx]] = RGBGetRValue(color);
|
||||
grn_val[keys[color_idx]] = RGBGetGValue(color);
|
||||
blu_val[keys[color_idx]] = RGBGetBValue(color);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send red bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &red_val[0]);
|
||||
StreamPacket(2, 60, &red_val[60]);
|
||||
StreamPacket(3, 48, &red_val[120]);
|
||||
SubmitKeyboardFullColors(1, 3, 1);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send green bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &grn_val[0]);
|
||||
StreamPacket(2, 60, &grn_val[60]);
|
||||
StreamPacket(3, 48, &grn_val[120]);
|
||||
SubmitKeyboardFullColors(2, 3, 1);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send blue bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &blu_val[0]);
|
||||
StreamPacket(2, 60, &blu_val[60]);
|
||||
StreamPacket(3, 48, &blu_val[120]);
|
||||
SubmitKeyboardFullColors(3, 3, 2);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetLEDsMouse(std::vector<RGBColor> colors)
|
||||
{
|
||||
SubmitMouseColors(colors.size(), &colors[0]);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetLEDsMousemat(std::vector<RGBColor> colors)
|
||||
{
|
||||
SubmitMousematColors(colors.size(), &colors[0]);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char data_pkt[216];
|
||||
unsigned char red_val[144];
|
||||
unsigned char grn_val[144];
|
||||
unsigned char blu_val[144];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(data_pkt, 0x00, sizeof( data_pkt ));
|
||||
memset(red_val, 0x00, sizeof( red_val ));
|
||||
memset(grn_val, 0x00, sizeof( grn_val ));
|
||||
memset(blu_val, 0x00, sizeof( blu_val ));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Scale color values to 9-bit |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
|
||||
{
|
||||
RGBColor color = colors[color_idx];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if( red > 7 ) red = 7;
|
||||
if( grn > 7 ) grn = 7;
|
||||
if( blu > 7 ) blu = 7;
|
||||
|
||||
red = 7 - red;
|
||||
grn = 7 - grn;
|
||||
blu = 7 - blu;
|
||||
|
||||
red_val[keys[color_idx]] = red;
|
||||
grn_val[keys[color_idx]] = grn;
|
||||
blu_val[keys[color_idx]] = blu;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Pack the color values, 2 values per byte |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int red_idx = 0; red_idx < 72; red_idx++)
|
||||
{
|
||||
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
|
||||
}
|
||||
|
||||
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
|
||||
{
|
||||
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
|
||||
}
|
||||
|
||||
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
|
||||
{
|
||||
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the packets |
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &data_pkt[0]);
|
||||
StreamPacket(2, 60, &data_pkt[60]);
|
||||
StreamPacket(3, 60, &data_pkt[120]);
|
||||
StreamPacket(4, 36, &data_pkt[180]);
|
||||
|
||||
SubmitKeyboardLimitedColors(216);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetName(std::string device_name)
|
||||
{
|
||||
name = device_name;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CorsairPeripheralController::LightingControl()
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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 |
|
||||
| headset stand, 1 for mice and mousepads |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(type)
|
||||
{
|
||||
default:
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
usb_buf[0x05] = 0x03;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
usb_buf[0x05] = 0x01;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
usb_buf[0x05] = 0x04;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
usb_buf[0x05] = 0x03;
|
||||
break;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SpecialFunctionControl()
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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 |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
|
||||
void CorsairPeripheralController::ReadFirmwareInfo()
|
||||
{
|
||||
int actual;
|
||||
char usb_buf[65];
|
||||
char offset = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Read Firmware Info packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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, 65);
|
||||
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 65, 1000);
|
||||
|
||||
if(actual == 0)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set up Read Firmware Info packet |
|
||||
\*-------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_COMMAND_READ;
|
||||
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
|
||||
|
||||
hid_send_feature_report(dev, (unsigned char*)usb_buf, 65);
|
||||
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 65);
|
||||
offset = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get device type |
|
||||
| 0xC0 Device is a keyboard |
|
||||
| 0xC1 Device is a mouse |
|
||||
| 0xC2 Device is a mousepad or headset stand |
|
||||
\*-----------------------------------------------------*/
|
||||
switch((unsigned char)usb_buf[0x14 + offset])
|
||||
{
|
||||
case 0xC0:
|
||||
{
|
||||
unsigned short pid = (unsigned short)(usb_buf[0x0F] << 8) + (unsigned char)(usb_buf[0x0E]);
|
||||
|
||||
switch(pid)
|
||||
{
|
||||
case 0x2D1B:
|
||||
logical_layout = CORSAIR_TYPE_K95_PLAT;
|
||||
break;
|
||||
|
||||
case 0x1B11:
|
||||
logical_layout = CORSAIR_TYPE_K95;
|
||||
break;
|
||||
|
||||
default:
|
||||
logical_layout = CORSAIR_TYPE_NORMAL;
|
||||
}
|
||||
}
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
break;
|
||||
|
||||
case 0xC1:
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
SpecialFunctionControl();
|
||||
break;
|
||||
|
||||
case 0xC2:
|
||||
{
|
||||
unsigned short pid = (unsigned short)(usb_buf[0x0F] << 8) + (unsigned char)(usb_buf[0x0E]);
|
||||
|
||||
switch(pid)
|
||||
{
|
||||
case 0x0A34:
|
||||
type = DEVICE_TYPE_HEADSET_STAND;
|
||||
SpecialFunctionControl();
|
||||
break;
|
||||
|
||||
default:
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
SpecialFunctionControl();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
type = DEVICE_TYPE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Format firmware version string if device type is valid|
|
||||
\*-----------------------------------------------------*/
|
||||
if(type != DEVICE_TYPE_UNKNOWN)
|
||||
{
|
||||
firmware_version = std::to_string(usb_buf[0x09 + offset]) + "." + std::to_string(usb_buf[0x08 + offset]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the correct Keyboard Layout |
|
||||
\*-----------------------------------------------------*/
|
||||
switch((unsigned char)usb_buf[0x17 + offset])
|
||||
{
|
||||
case CORSAIR_LAYOUT_ANSI:
|
||||
physical_layout = CORSAIR_LAYOUT_ANSI;
|
||||
break;
|
||||
case CORSAIR_LAYOUT_ISO:
|
||||
physical_layout = CORSAIR_LAYOUT_ISO;
|
||||
break;
|
||||
default:
|
||||
physical_layout = CORSAIR_LAYOUT_ANSI;
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
)
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Stream packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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[0x05], data_ptr, data_sz);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardFullColors
|
||||
(
|
||||
unsigned char color_channel,
|
||||
unsigned char packet_count,
|
||||
unsigned char finish_val
|
||||
)
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Keyboard 24-Bit Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
)
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Keyboard 9-Bit Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitMouseColors
|
||||
(
|
||||
unsigned char num_zones,
|
||||
RGBColor * color_data
|
||||
)
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Mouse Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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) + 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, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitMousematColors
|
||||
(
|
||||
unsigned char num_zones,
|
||||
RGBColor * color_data
|
||||
)
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Submit Mouse Colors packet |
|
||||
\*-----------------------------------------------------*/
|
||||
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) + 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 |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairPeripheralController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair RGB |
|
||||
| keyboard, mouse, and mousemat lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COMMAND_WRITE = 0x07,
|
||||
CORSAIR_COMMAND_READ = 0x0E,
|
||||
CORSAIR_COMMAND_STREAM = 0x7F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PROPERTY_FIRMWARE_INFO = 0x01,
|
||||
CORSAIR_PROPERTY_RESET = 0x02,
|
||||
CORSAIR_PROPERTY_SPECIAL_FUNCTION = 0x04,
|
||||
CORSAIR_PROPERTY_LIGHTING_CONTROL = 0x05,
|
||||
CORSAIR_PROPERTY_HARDWARE_PROFILE = 0x13,
|
||||
CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR = 0x22,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9 = 0x27,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24 = 0x28,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LIGHTING_CONTROL_HARDWARE = 0x01,
|
||||
CORSAIR_LIGHTING_CONTROL_SOFTWARE = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_COLOR_CHANNEL_RED = 0x01,
|
||||
CORSAIR_COLOR_CHANNEL_GREEN = 0x02,
|
||||
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_LAYOUT_ANSI = 0x00,
|
||||
CORSAIR_LAYOUT_ISO = 0x01,
|
||||
CORSAIR_LAYOUT_ABNT = 0x02,
|
||||
CORSAIR_LAYOUT_JIS = 0x03,
|
||||
CORSAIR_LAYOUT_DUBEOLSIK = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_TYPE_NORMAL = 0,
|
||||
CORSAIR_TYPE_K95_PLAT = 1,
|
||||
CORSAIR_TYPE_K95 = 2
|
||||
};
|
||||
|
||||
class CorsairPeripheralController
|
||||
{
|
||||
public:
|
||||
CorsairPeripheralController(hid_device* dev_handle, const char* path);
|
||||
~CorsairPeripheralController();
|
||||
|
||||
int GetLogicalLayout();
|
||||
int GetPhysicalLayout();
|
||||
device_type GetDeviceType();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareString();
|
||||
std::string GetName();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
void SetLEDsKeyboardFull(std::vector<RGBColor> colors);
|
||||
void SetLEDsKeyboardLimited(std::vector<RGBColor> colors);
|
||||
void SetLEDsMouse(std::vector<RGBColor> colors);
|
||||
void SetLEDsMousemat(std::vector<RGBColor> colors);
|
||||
void SetName(std::string device_name);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
std::string name;
|
||||
device_type type;
|
||||
int physical_layout; //ANSI, ISO, etc.
|
||||
int logical_layout; //Normal, K95 or K95 Platinum
|
||||
|
||||
void LightingControl();
|
||||
void SpecialFunctionControl();
|
||||
|
||||
void ReadFirmwareInfo();
|
||||
|
||||
void StreamPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char data_sz,
|
||||
unsigned char* data_ptr
|
||||
);
|
||||
|
||||
void SubmitKeyboardFullColors
|
||||
(
|
||||
unsigned char color_channel,
|
||||
unsigned char packet_count,
|
||||
unsigned char finish_val
|
||||
);
|
||||
|
||||
void SubmitKeyboardLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
);
|
||||
|
||||
void SubmitMouseColors
|
||||
(
|
||||
unsigned char num_zones,
|
||||
RGBColor * color_data
|
||||
);
|
||||
|
||||
void SubmitMousematColors
|
||||
(
|
||||
unsigned char num_zones,
|
||||
RGBColor * color_data
|
||||
);
|
||||
};
|
||||
@@ -1,134 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairPeripheralController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPeripheral.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
| List taken from ckb-next |
|
||||
| Non-RGB keyboards were omitted from this list |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_K55_RGB_PID 0x1B3D
|
||||
|
||||
#define CORSAIR_K65_RGB_PID 0x1B17
|
||||
#define CORSAIR_K65_LUX_RGB_PID 0x1B37
|
||||
#define CORSAIR_K65_RGB_RAPIDFIRE_PID 0x1B39
|
||||
|
||||
#define CORSAIR_K68_RGB 0x1B4F
|
||||
|
||||
#define CORSAIR_K70_RGB_PID 0x1B13
|
||||
#define CORSAIR_K70_LUX_RGB_PID 0x1B33
|
||||
#define CORSAIR_K70_RGB_RAPIDFIRE_PID 0x1B38
|
||||
#define CORSAIR_K70_RGB_MK2_PID 0x1B49
|
||||
#define CORSAIR_K70_RGB_MK2_SE_PID 0x1B6B
|
||||
#define CORSAIR_K70_RGB_MK2_LP_PID 0x1B55
|
||||
|
||||
#define CORSAIR_K95_RGB_PID 0x1B11
|
||||
#define CORSAIR_K95_PLATINUM_PID 0x1B2D
|
||||
|
||||
#define CORSAIR_STRAFE_PID 0x1B20
|
||||
#define CORSAIR_STRAFE_MK2_PID 0x1B48
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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
|
||||
#define CORSAIR_SCIMITAR_PRO_RGB_PID 0x1B3E
|
||||
#define CORSAIR_SABRE_RGB_PID 0x1B2F
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mousepad product IDs |
|
||||
| List taken from ckb-next |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_MM800_RGB_POLARIS_PID 0x1B3B
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Headset Stand product IDs |
|
||||
| List taken from ckb-next |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_ST100_PID 0x0A34
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairPeripheralControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
CorsairPeripheralController* controller = new CorsairPeripheralController(dev, info->path);
|
||||
controller->SetName(name);
|
||||
|
||||
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
|
||||
{
|
||||
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairPeripheralControllers() */
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
//REGISTER_HID_DETECTOR_IP("Corsair K55 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K55_RGB_PID, 1, 0xFFC2); // Not per-key, disabled for now
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K65 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K65 LUX RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_LUX_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K65 RGB RAPIDFIRE", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_RGB_RAPIDFIRE_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K68 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K68_RGB, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 LUX RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_LUX_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB RAPIDFIRE", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_RGB_RAPIDFIRE_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB MK.2", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_RGB_MK2_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB MK.2 SE", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_RGB_MK2_SE_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB MK.2 Low Profile", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K70_RGB_MK2_LP_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K95 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K95_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair K95 RGB PLATINUM", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K95_PLATINUM_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Strafe", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_STRAFE_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Strafe MK.2", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_STRAFE_MK2_PID, 1, 0xFFC2);
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Glaive RGB PRO", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_GLAIVE_RGB_PRO_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Harpoon RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_HARPOON_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Harpoon RGB PRO", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_HARPOON_RGB_PRO_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair M65 PRO", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_M65_PRO_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair M65 RGB Elite" , DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Scimitar PRO RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_SCIMITAR_PRO_RGB_PID, 1, 0xFFC2);
|
||||
REGISTER_HID_DETECTOR_IP("Corsair Sabre RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_SABRE_RGB_PID, 1, 0xFFC2);
|
||||
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
#ifdef USE_HID_USAGE
|
||||
REGISTER_HID_DETECTOR_P("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0xFFC2);
|
||||
#else
|
||||
REGISTER_HID_DETECTOR_I("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0);
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Headset Stands |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
#ifdef USE_HID_USAGE
|
||||
REGISTER_HID_DETECTOR_P("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0xFFC2);
|
||||
#else
|
||||
REGISTER_HID_DETECTOR_I("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0);
|
||||
#endif
|
||||
@@ -1,842 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairPeripheral.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair RGB |
|
||||
| keyboard, mouse, and mousemat devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairPeripheral.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 },
|
||||
{ 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 },
|
||||
{ 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 },
|
||||
{ 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA },
|
||||
{ 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 },
|
||||
{ 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } };
|
||||
|
||||
static unsigned int matrix_map_k95_platinum[7][24] =
|
||||
{ { NA, NA, NA, NA, 107, 8, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 16, NA, NA, NA,},
|
||||
{ 113, 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 },
|
||||
{ 114, 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 },
|
||||
{ 115, 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 },
|
||||
{ 116, 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA },
|
||||
{ 117, 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 },
|
||||
{ 118, 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } };
|
||||
|
||||
static unsigned int matrix_map_k95[7][26] =
|
||||
{ { NA, NA, NA, 131, 132, 133, 134, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 107, 8, NA, NA, 16, NA, NA,},
|
||||
{ 113, 114, 115, 0, NA, 10, 18, 28, 36, NA, 46, 55, 64, 74, NA, 84, 93, 102, 6, 15, 24, 33, 26, 35, 44, 53 },
|
||||
{ 116, 117, 118, 1, 11, 19, 29, 37, 47, 56, 65, 75, 85, 94, NA, 103, 7, 25, NA, 42, 51, 60, 62, 72, 82, 91 },
|
||||
{ 119, 120, 121, 2, NA, 12, 20, 30, 38, NA, 48, 57, 66, 76, 86, 95, 104, 70, 80, 34, 43, 52, 9, 17, 27, 100 },
|
||||
{ 122, 123, 124, 3, NA, 13, 21, 31, 39, NA, 49, 58, 67, 77, 87, 96, 105, 98, 112, NA, NA, NA, 45, 54, 63, NA },
|
||||
{ 125, 126, 127, 4, 111, 22, 32, 40, 50, NA, 59, NA, 68, 78, 88, 97, 106, 61, NA, NA, 81, NA, 73, 83, 92, 109 },
|
||||
{ 128, 129, 130, 5, 14, 23, NA, NA, NA, NA, 41, NA, NA, NA, NA, 69, 79, 89, 71, 90, 99, 108, 101, NA, 110, NA } };
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Normal Corsair Layout |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
113
|
||||
};
|
||||
|
||||
static const zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| K95 Platinum |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* zone_names_k95_platinum[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"Light Bar"
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes_k95_platinum[] =
|
||||
{
|
||||
119,
|
||||
19
|
||||
};
|
||||
|
||||
static const zone_type zone_types_k95_platinum[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
ZONE_TYPE_LINEAR
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| K95 non-Platinum |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* zone_names_k95[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes_k95[] =
|
||||
{
|
||||
135
|
||||
};
|
||||
|
||||
static const zone_type zone_types_k95[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX
|
||||
};
|
||||
|
||||
|
||||
static const char* led_names[] =
|
||||
{
|
||||
"Key: Escape", //0
|
||||
"Key: `", //1
|
||||
"Key: Tab", //2
|
||||
"Key: Caps Lock", //3
|
||||
"Key: Left Shift", //4
|
||||
"Key: Left Control", //5
|
||||
"Key: F12", //6
|
||||
"Key: =", //7
|
||||
"Key: Lock", //8
|
||||
"Key: Number Pad 7", //9
|
||||
"Key: F1", //12
|
||||
"Key: 1", //13
|
||||
"Key: Q", //14
|
||||
"Key: A", //15
|
||||
"Key: Left Windows", //17
|
||||
"Key: Print Screen", //18
|
||||
"Key: Media Mute", //20
|
||||
"Key: Number Pad 8", //21
|
||||
"Key: F2", //24
|
||||
"Key: 2", //25
|
||||
"Key: W", //26
|
||||
"Key: S", //27
|
||||
"Key: Z", //28
|
||||
"Key: Left Alt", //29
|
||||
"Key: Scroll Lock", //30
|
||||
"Key: Backspace", //31
|
||||
"Key: Media Stop", //32
|
||||
"Key: Number Pad 9", //33
|
||||
"Key: F3", //36
|
||||
"Key: 3", //37
|
||||
"Key: E", //38
|
||||
"Key: D", //39
|
||||
"Key: X", //40
|
||||
"Key: Pause/Break", //42
|
||||
"Key: Delete", //43
|
||||
"Key: Media Previous", //44
|
||||
"Key: F4", //48
|
||||
"Key: 4", //49
|
||||
"Key: R", //50
|
||||
"Key: F", //51
|
||||
"Key: C", //52
|
||||
"Key: Space", //53
|
||||
"Key: Insert", //54
|
||||
"Key: End", //55
|
||||
"Key: Media Play/Pause",//56
|
||||
"Key: Number Pad 4", //57
|
||||
"Key: F5", //60
|
||||
"Key: 5", //61
|
||||
"Key: T", //62
|
||||
"Key: G", //63
|
||||
"Key: V", //64
|
||||
"Key: Home", //66
|
||||
"Key: Page Down", //67
|
||||
"Key: Media Next", //68
|
||||
"Key: Number Pad 5", //69
|
||||
"Key: F6", //72
|
||||
"Key: 6", //73
|
||||
"Key: Y", //74
|
||||
"Key: H", //75
|
||||
"Key: B", //76
|
||||
"Key: Page Up", //78
|
||||
"Key: Right Shift", //79
|
||||
"Key: Num Lock", //80
|
||||
"Key: Number Pad 6", //81
|
||||
"Key: F7", //84
|
||||
"Key: 7", //85
|
||||
"Key: U", //86
|
||||
"Key: J", //87
|
||||
"Key: N", //88
|
||||
"Key: Right Alt", //89
|
||||
"Key: ]", //90
|
||||
"Key: Right Control", //91
|
||||
"Key: Number Pad /", //92
|
||||
"Key: Number Pad 1", //93
|
||||
"Key: F8", //96
|
||||
"Key: 8", //97
|
||||
"Key: I", //98
|
||||
"Key: K", //99
|
||||
"Key: M", //100
|
||||
"Key: Right Windows", //101
|
||||
"Key: \\ (ANSI)", //102
|
||||
"Key: Up Arrow", //103
|
||||
"Key: Number Pad *", //104
|
||||
"Key: Number Pad 2", //105
|
||||
"Key: F9", //108
|
||||
"Key: 9", //109
|
||||
"Key: O", //110
|
||||
"Key: L", //111
|
||||
"Key: ,", //112
|
||||
"Key: Menu", //113
|
||||
"Key: Left Arrow", //115
|
||||
"Key: Number Pad -", //116
|
||||
"Key: Number Pad 3", //117
|
||||
"Key: F10", //120
|
||||
"Key: 0", //121
|
||||
"Key: P", //122
|
||||
"Key: ;", //123
|
||||
"Key: .", //124
|
||||
"Key: Enter", //126
|
||||
"Key: Down Arrow", //127
|
||||
"Key: Number Pad +", //128
|
||||
"Key: Number Pad 0", //129
|
||||
"Key: F11", //132
|
||||
"Key: -", //133
|
||||
"Key: [", //134
|
||||
"Key: '", //135
|
||||
"Key: /", //136
|
||||
"Key: Brightness", //137
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: / (ISO)",
|
||||
"Key: \\ (ISO)",
|
||||
};
|
||||
|
||||
static const char* led_names_k95_plat[] =
|
||||
{
|
||||
"Key: Escape", //0
|
||||
"Key: `", //1
|
||||
"Key: Tab", //2
|
||||
"Key: Caps Lock", //3
|
||||
"Key: Left Shift", //4
|
||||
"Key: Left Control", //5
|
||||
"Key: F12", //6
|
||||
"Key: =", //7
|
||||
"Key: Lock", //8
|
||||
"Key: Number Pad 7", //9
|
||||
"Key: F1", //12
|
||||
"Key: 1", //13
|
||||
"Key: Q", //14
|
||||
"Key: A", //15
|
||||
"Key: Left Windows", //17
|
||||
"Key: Print Screen", //18
|
||||
"Key: Media Mute", //20
|
||||
"Key: Number Pad 8", //21
|
||||
"Key: F2", //24
|
||||
"Key: 2", //25
|
||||
"Key: W", //26
|
||||
"Key: S", //27
|
||||
"Key: Z", //28
|
||||
"Key: Left Alt", //29
|
||||
"Key: Scroll Lock", //30
|
||||
"Key: Backspace", //31
|
||||
"Key: Media Stop", //32
|
||||
"Key: Number Pad 9", //33
|
||||
"Key: F3", //36
|
||||
"Key: 3", //37
|
||||
"Key: E", //38
|
||||
"Key: D", //39
|
||||
"Key: X", //40
|
||||
"Key: Pause/Break", //42
|
||||
"Key: Delete", //43
|
||||
"Key: Media Previous", //44
|
||||
"Key: F4", //48
|
||||
"Key: 4", //49
|
||||
"Key: R", //50
|
||||
"Key: F", //51
|
||||
"Key: C", //52
|
||||
"Key: Space", //53
|
||||
"Key: Insert", //54
|
||||
"Key: End", //55
|
||||
"Key: Media Play/Pause",//56
|
||||
"Key: Number Pad 4", //57
|
||||
"Key: F5", //60
|
||||
"Key: 5", //61
|
||||
"Key: T", //62
|
||||
"Key: G", //63
|
||||
"Key: V", //64
|
||||
"Key: Home", //66
|
||||
"Key: Page Down", //67
|
||||
"Key: Media Next", //68
|
||||
"Key: Number Pad 5", //69
|
||||
"Key: F6", //72
|
||||
"Key: 6", //73
|
||||
"Key: Y", //74
|
||||
"Key: H", //75
|
||||
"Key: B", //76
|
||||
"Key: Page Up", //78
|
||||
"Key: Right Shift", //79
|
||||
"Key: Num Lock", //80
|
||||
"Key: Number Pad 6", //81
|
||||
"Key: F7", //84
|
||||
"Key: 7", //85
|
||||
"Key: U", //86
|
||||
"Key: J", //87
|
||||
"Key: N", //88
|
||||
"Key: Right Alt", //89
|
||||
"Key: ]", //90
|
||||
"Key: Right Control", //91
|
||||
"Key: Number Pad /", //92
|
||||
"Key: Number Pad 1", //93
|
||||
"Key: F8", //96
|
||||
"Key: 8", //97
|
||||
"Key: I", //98
|
||||
"Key: K", //99
|
||||
"Key: M", //100
|
||||
"Key: Right Windows", //101
|
||||
"Key: \\ (ANSI)", //102
|
||||
"Key: Up Arrow", //103
|
||||
"Key: Number Pad *", //104
|
||||
"Key: Number Pad 2", //105
|
||||
"Key: F9", //108
|
||||
"Key: 9", //109
|
||||
"Key: O", //110
|
||||
"Key: L", //111
|
||||
"Key: ,", //112
|
||||
"Key: Menu", //113
|
||||
"Key: Left Arrow", //115
|
||||
"Key: Number Pad -", //116
|
||||
"Key: Number Pad 3", //117
|
||||
"Key: F10", //120
|
||||
"Key: 0", //121
|
||||
"Key: P", //122
|
||||
"Key: ;", //123
|
||||
"Key: .", //124
|
||||
"Key: Enter", //126
|
||||
"Key: Down Arrow", //127
|
||||
"Key: Number Pad +", //128
|
||||
"Key: Number Pad 0", //129
|
||||
"Key: F11", //132
|
||||
"Key: -", //133
|
||||
"Key: [", //134
|
||||
"Key: '", //135
|
||||
"Key: /", //136
|
||||
"Key: Brightness", //137
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: / (ISO)",
|
||||
"Key: \\ (ISO)",
|
||||
"Key: Macro G1",
|
||||
"Key: Macro G2",
|
||||
"Key: Macro G3",
|
||||
"Key: Macro G4",
|
||||
"Key: Macro G5",
|
||||
"Key: Macro G6",
|
||||
"Light Bar 1",
|
||||
"Light Bar 2",
|
||||
"Light Bar 3",
|
||||
"Light Bar 4",
|
||||
"Light Bar 5",
|
||||
"Light Bar 6",
|
||||
"Light Bar 7",
|
||||
"Light Bar 8",
|
||||
"Light Bar 9",
|
||||
"Light Bar 10",
|
||||
"Light Bar 11",
|
||||
"Light Bar 12",
|
||||
"Light Bar 13",
|
||||
"Light Bar 14",
|
||||
"Light Bar 15",
|
||||
"Light Bar 16",
|
||||
"Light Bar 17",
|
||||
"Light Bar 18",
|
||||
"Light Bar 19"
|
||||
};
|
||||
|
||||
static const char* led_names_k95[] =
|
||||
{
|
||||
"Key: Escape", //0
|
||||
"Key: `", //1
|
||||
"Key: Tab", //2
|
||||
"Key: Caps Lock", //3
|
||||
"Key: Left Shift", //4
|
||||
"Key: Left Control", //5
|
||||
"Key: F12", //6
|
||||
"Key: =", //7
|
||||
"Key: Lock", //8
|
||||
"Key: Number Pad 7", //9
|
||||
"Key: F1", //12
|
||||
"Key: 1", //13
|
||||
"Key: Q", //14
|
||||
"Key: A", //15
|
||||
"Key: Left Windows", //17
|
||||
"Key: Print Screen", //18
|
||||
"Key: Media Mute", //20
|
||||
"Key: Number Pad 8", //21
|
||||
"Key: F2", //24
|
||||
"Key: 2", //25
|
||||
"Key: W", //26
|
||||
"Key: S", //27
|
||||
"Key: Z", //28
|
||||
"Key: Left Alt", //29
|
||||
"Key: Scroll Lock", //30
|
||||
"Key: Backspace", //31
|
||||
"Key: Media Stop", //32
|
||||
"Key: Number Pad 9", //33
|
||||
"Key: F3", //36
|
||||
"Key: 3", //37
|
||||
"Key: E", //38
|
||||
"Key: D", //39
|
||||
"Key: X", //40
|
||||
"Key: Pause/Break", //42
|
||||
"Key: Delete", //43
|
||||
"Key: Media Previous", //44
|
||||
"Key: F4", //48
|
||||
"Key: 4", //49
|
||||
"Key: R", //50
|
||||
"Key: F", //51
|
||||
"Key: C", //52
|
||||
"Key: Space", //53
|
||||
"Key: Insert", //54
|
||||
"Key: End", //55
|
||||
"Key: Media Play/Pause",//56
|
||||
"Key: Number Pad 4", //57
|
||||
"Key: F5", //60
|
||||
"Key: 5", //61
|
||||
"Key: T", //62
|
||||
"Key: G", //63
|
||||
"Key: V", //64
|
||||
"Key: Home", //66
|
||||
"Key: Page Down", //67
|
||||
"Key: Media Next", //68
|
||||
"Key: Number Pad 5", //69
|
||||
"Key: F6", //72
|
||||
"Key: 6", //73
|
||||
"Key: Y", //74
|
||||
"Key: H", //75
|
||||
"Key: B", //76
|
||||
"Key: Page Up", //78
|
||||
"Key: Right Shift", //79
|
||||
"Key: Num Lock", //80
|
||||
"Key: Number Pad 6", //81
|
||||
"Key: F7", //84
|
||||
"Key: 7", //85
|
||||
"Key: U", //86
|
||||
"Key: J", //87
|
||||
"Key: N", //88
|
||||
"Key: Right Alt", //89
|
||||
"Key: ]", //90
|
||||
"Key: Right Control", //91
|
||||
"Key: Number Pad /", //92
|
||||
"Key: Number Pad 1", //93
|
||||
"Key: F8", //96
|
||||
"Key: 8", //97
|
||||
"Key: I", //98
|
||||
"Key: K", //99
|
||||
"Key: M", //100
|
||||
"Key: Right Windows", //101
|
||||
"Key: \\ (ANSI)", //102
|
||||
"Key: Up Arrow", //103
|
||||
"Key: Number Pad *", //104
|
||||
"Key: Number Pad 2", //105
|
||||
"Key: F9", //108
|
||||
"Key: 9", //109
|
||||
"Key: O", //110
|
||||
"Key: L", //111
|
||||
"Key: ,", //112
|
||||
"Key: Menu", //113
|
||||
"Key: Left Arrow", //115
|
||||
"Key: Number Pad -", //116
|
||||
"Key: Number Pad 3", //117
|
||||
"Key: F10", //120
|
||||
"Key: 0", //121
|
||||
"Key: P", //122
|
||||
"Key: ;", //123
|
||||
"Key: .", //124
|
||||
"Key: Enter", //126
|
||||
"Key: Down Arrow", //127
|
||||
"Key: Number Pad +", //128
|
||||
"Key: Number Pad 0", //129
|
||||
"Key: F11", //132
|
||||
"Key: -", //133
|
||||
"Key: [", //134
|
||||
"Key: '", //135
|
||||
"Key: /", //136
|
||||
"Key: Brightness", //137
|
||||
"Key: Right Arrow", //139
|
||||
"Key: Number Pad Enter",//140
|
||||
"Key: Number Pad .", //141
|
||||
"Key: / (ISO)",
|
||||
"Key: \\ (ISO)",
|
||||
"Key: Macro G1",
|
||||
"Key: Macro G2",
|
||||
"Key: Macro G3",
|
||||
"Key: Macro G4",
|
||||
"Key: Macro G5",
|
||||
"Key: Macro G6",
|
||||
"Key: Macro G7",
|
||||
"Key: Macro G8",
|
||||
"Key: Macro G9",
|
||||
"Key: Macro G10",
|
||||
"Key: Macro G11",
|
||||
"Key: Macro G12",
|
||||
"Key: Macro G13",
|
||||
"Key: Macro G14",
|
||||
"Key: Macro G15",
|
||||
"Key: Macro G16",
|
||||
"Key: Macro G17",
|
||||
"Key: Macro G18",
|
||||
"Key: MR",
|
||||
"Key: M1",
|
||||
"Key: M2",
|
||||
"Key: M3",
|
||||
};
|
||||
|
||||
static const char* corsair_mouse_leds[] =
|
||||
{
|
||||
"Mouse LED 1",
|
||||
"Mouse LED 2",
|
||||
"Mouse LED 3",
|
||||
"Mouse LED 4",
|
||||
"Mouse LED 5",
|
||||
"Mouse LED 6",
|
||||
"Mouse LED 7",
|
||||
"Mouse LED 8",
|
||||
"Mouse LED 9",
|
||||
"Mouse LED 10",
|
||||
"Mouse LED 11",
|
||||
"Mouse LED 12",
|
||||
"Mouse LED 13",
|
||||
"Mouse LED 14",
|
||||
"Mouse LED 15",
|
||||
};
|
||||
|
||||
static const char* corsair_m65_elite_leds[] =
|
||||
{
|
||||
"",
|
||||
"",
|
||||
"Logo",
|
||||
"DPI",
|
||||
"Scroll Wheel",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
static const char* corsair_sabre_rgb_leds[] =
|
||||
{
|
||||
"",
|
||||
"Underglow",
|
||||
"Logo",
|
||||
"DPI",
|
||||
"Scroll Wheel",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
};
|
||||
|
||||
static const char* corsair_harpoon_pro_leds[] =
|
||||
{
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"Logo",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
};
|
||||
|
||||
RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetName();
|
||||
vendor = "Corsair";
|
||||
description = "Corsair RGB Peripheral Device";
|
||||
type = corsair->GetDeviceType();
|
||||
version = corsair->GetFirmwareString();
|
||||
location = corsair->GetDeviceLocation();
|
||||
serial = corsair->GetSerialString();
|
||||
|
||||
physical_layout = corsair->GetPhysicalLayout();
|
||||
logical_layout = corsair->GetLogicalLayout();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Determine number of zones |
|
||||
| For now, keyboard has 2 zones and mousemat has 1 |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int num_zones = 0;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
num_zones = 2;
|
||||
break;
|
||||
}
|
||||
num_zones = 1;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
num_zones = 1;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
num_zones = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
new_zone.name = zone_names_k95_platinum[zone_idx];
|
||||
new_zone.type = zone_types_k95_platinum[zone_idx];
|
||||
new_zone.leds_min = zone_sizes_k95_platinum[zone_idx];
|
||||
new_zone.leds_max = zone_sizes_k95_platinum[zone_idx];
|
||||
new_zone.leds_count = zone_sizes_k95_platinum[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 24;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95_platinum;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
}
|
||||
else if (logical_layout == CORSAIR_TYPE_K95)
|
||||
{
|
||||
new_zone.name = zone_names_k95[zone_idx];
|
||||
new_zone.type = zone_types_k95[zone_idx];
|
||||
new_zone.leds_min = zone_sizes_k95[zone_idx];
|
||||
new_zone.leds_max = zone_sizes_k95[zone_idx];
|
||||
new_zone.leds_count = zone_sizes_k95[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 26;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
}
|
||||
else //default layout
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
new_zone.name = "Mouse Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
new_zone.name = "Mousemat Zone";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
if(zone_idx == 0)
|
||||
{
|
||||
new_zone.name = "Base LED Strip";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 8;
|
||||
new_zone.leds_max = 8;
|
||||
new_zone.leds_count = 8;
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.name = "Logo";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += new_zone.leds_count;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
if(logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
new_led.name = led_names_k95_plat[led_idx];
|
||||
}
|
||||
else if(logical_layout == CORSAIR_TYPE_K95)
|
||||
{
|
||||
new_led.name = led_names_k95[led_idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = led_names[led_idx];
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
if(name == "Corsair M65 RGB Elite")
|
||||
{
|
||||
new_led.name = corsair_m65_elite_leds[led_idx];
|
||||
}
|
||||
else if(name == "Corsair Harpoon RGB PRO")
|
||||
{
|
||||
new_led.name = corsair_harpoon_pro_leds[led_idx];
|
||||
}
|
||||
else if(name == "Corsair Sabre RGB")
|
||||
{
|
||||
new_led.name = corsair_sabre_rgb_leds[led_idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = corsair_mouse_leds[led_idx];
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
new_led.name = "Mousemat LED ";
|
||||
new_led.name.append(std::to_string(led_idx + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateLEDs()
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
corsair->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairPeripheral.h |
|
||||
| |
|
||||
| Generic RGB Interface for Corsair RGB |
|
||||
| keyboard, mouse, and mousemat devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/9/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairPeripheralController.h"
|
||||
|
||||
class RGBController_CorsairPeripheral : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr);
|
||||
~RGBController_CorsairPeripheral();
|
||||
|
||||
int physical_layout;
|
||||
int logical_layout;
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CorsairPeripheralController* corsair;
|
||||
};
|
||||
+29
-20
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairVengeanceProController.cpp |
|
||||
| CorsairProController.cpp |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance Pro RGB RAM lighting controller|
|
||||
@@ -7,12 +7,21 @@
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairVengeanceProController.h"
|
||||
#include "CorsairProController.h"
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
@@ -30,37 +39,37 @@ CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface
|
||||
}
|
||||
}
|
||||
|
||||
CorsairVengeanceProController::~CorsairVengeanceProController()
|
||||
CorsairProController::~CorsairProController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string CorsairVengeanceProController::GetDeviceName()
|
||||
std::string CorsairProController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CorsairVengeanceProController::GetDeviceLocation()
|
||||
std::string CorsairProController::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("I2C: " + return_string);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned int CorsairVengeanceProController::GetLEDCount()
|
||||
unsigned int CorsairProController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char CorsairVengeanceProController::GetEffect()
|
||||
unsigned char CorsairProController::GetEffect()
|
||||
{
|
||||
return(effect_mode);
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
@@ -70,19 +79,19 @@ void CorsairVengeanceProController::SetAllColors(unsigned char red, unsigned cha
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
void CorsairProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
led_red[led] = red;
|
||||
led_green[led] = green;
|
||||
led_blue[led] = blue;
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::ApplyColors()
|
||||
void CorsairProController::ApplyColors()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Sleep(1);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -95,7 +104,7 @@ void CorsairVengeanceProController::ApplyColors()
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
void CorsairProController::SetEffect(unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
bool random,
|
||||
@@ -110,9 +119,9 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
effect_mode = mode;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Sleep(1);
|
||||
|
||||
unsigned char random_byte;
|
||||
|
||||
@@ -150,13 +159,13 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
WaitReady();
|
||||
}
|
||||
|
||||
bool CorsairVengeanceProController::WaitReady()
|
||||
bool CorsairProController::WaitReady()
|
||||
{
|
||||
int i = 0;
|
||||
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
|
||||
{
|
||||
i++;
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
return false;
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairVengeanceProController.h |
|
||||
| CorsairProController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance Pro RGB RAM lighting controller|
|
||||
@@ -60,11 +60,11 @@ enum
|
||||
CORSAIR_PRO_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */
|
||||
};
|
||||
|
||||
class CorsairVengeanceProController
|
||||
class CorsairProController
|
||||
{
|
||||
public:
|
||||
CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairVengeanceProController();
|
||||
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairProController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceLocation();
|
||||
@@ -0,0 +1,142 @@
|
||||
#include "CorsairProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPro.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair Pro controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if (res != 0x03)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairProControllers *
|
||||
* *
|
||||
* Detect Corsair Pro controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairProController* new_corsair_pro;
|
||||
RGBController_CorsairPro* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairProController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairProController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairProController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairProController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairProController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairProController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairProController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairProController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairProControllers() */
|
||||
@@ -1,132 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairVengeanceController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairVengeance.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairVengeanceController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairVengeanceController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != 0xBA)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairVengeanceController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairVengeanceControllers *
|
||||
* *
|
||||
* Detect Corsair controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairVengeanceController* new_corsair;
|
||||
RGBController_CorsairVengeance* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairVengeanceController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair = new CorsairVengeanceController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_CorsairVengeance(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairVengeanceControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("Corsair Vengeance", DetectCorsairVengeanceControllers);
|
||||
@@ -1,108 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairVengeance.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Corsair Vengeance RGB driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairVengeance.h"
|
||||
|
||||
RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
vendor = "Corsair";
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Corsair Vengeance RGB Device";
|
||||
location = corsair->GetDeviceLocation();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Fade;
|
||||
Fade.name = "Fade";
|
||||
Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE;
|
||||
Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Fade.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Fade);
|
||||
|
||||
mode Pulse;
|
||||
Pulse.name = "Pulse";
|
||||
Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE;
|
||||
Pulse.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Pulse.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Pulse);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a single zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
new_zone.name = "Corsair Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = corsair->GetLEDCount();
|
||||
new_zone.leds_max = corsair->GetLEDCount();
|
||||
new_zone.leds_count = corsair->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
new_led->name = "Corsair LED";
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::DeviceUpdateLEDs()
|
||||
{
|
||||
RGBColor color = colors[0];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairVengeance::DeviceUpdateMode()
|
||||
{
|
||||
corsair->SetMode(modes[active_mode].value);
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairVengeanceProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairVengeancePro.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairVengeanceProController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair Pro controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if (!((res == 0x03) || (res == 0x04)))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairVengeanceProController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairVengeanceProControllers *
|
||||
* *
|
||||
* Detect Corsair Vengeance Pro controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairVengeanceProController* new_corsair_pro;
|
||||
RGBController_CorsairVengeancePro* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5E
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5E))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5E);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5F
|
||||
if (TestForCorsairVengeanceProController(busses[bus], 0x5F))
|
||||
{
|
||||
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5F);
|
||||
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairVengeanceProControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("Corsair Vengeance Pro", DetectCorsairVengeanceProControllers);
|
||||
@@ -15,9 +15,6 @@ CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id de
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
// We don't know what mode the sticks are in until we set one.
|
||||
this->last_mode = CRUCIAL_MODE_UNKNOWN;
|
||||
}
|
||||
|
||||
CrucialController::~CrucialController()
|
||||
@@ -37,7 +34,7 @@ std::string CrucialController::GetDeviceLocation()
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return("I2C: " + return_string);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
unsigned int CrucialController::GetLEDCount()
|
||||
@@ -47,11 +44,7 @@ unsigned int CrucialController::GetLEDCount()
|
||||
|
||||
void CrucialController::SetMode(unsigned char mode)
|
||||
{
|
||||
// Don't set a mode if we've already set the same one before.
|
||||
// This is mostly useful for direct mode and updating colors often.
|
||||
if (mode == last_mode) return;
|
||||
SendEffectMode(mode, 0x10);
|
||||
last_mode = mode;
|
||||
}
|
||||
|
||||
void CrucialController::SetAllColorsDirect(RGBColor* colors)
|
||||
@@ -59,15 +52,16 @@ void CrucialController::SetAllColorsDirect(RGBColor* colors)
|
||||
SendDirectColors(colors);
|
||||
}
|
||||
|
||||
void CrucialController::SetAllColorsEffect(RGBColor* colors)
|
||||
void CrucialController::SendEffectColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for(int led_idx = 0; led_idx < 8; led_idx++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led_idx]);
|
||||
unsigned char grn = RGBGetGValue(colors[led_idx]);
|
||||
unsigned char blu = RGBGetBValue(colors[led_idx]);
|
||||
SendEffectColor(led_idx, red, grn, blu);
|
||||
}
|
||||
CrucialRegisterWrite(0x82E9, 0xFF);
|
||||
CrucialRegisterWrite(0x82EA, 0x00);
|
||||
CrucialRegisterWrite(0x82EB, 0x00);
|
||||
CrucialRegisterWrite(0x82EC, 0x00);
|
||||
CrucialRegisterWrite(0x82ED, red);
|
||||
CrucialRegisterWrite(0x82EE, green);
|
||||
CrucialRegisterWrite(0x82EF, blue);
|
||||
CrucialRegisterWrite(0x82F0, 0x01);
|
||||
}
|
||||
|
||||
void CrucialController::SendBrightness(unsigned char brightness)
|
||||
@@ -87,8 +81,6 @@ void CrucialController::SendEffectMode(unsigned char mode, unsigned char speed)
|
||||
|
||||
void CrucialController::SendDirectColors(RGBColor* color_buf)
|
||||
{
|
||||
SetMode(CRUCIAL_MODE_STATIC);
|
||||
|
||||
//Red Channels
|
||||
CrucialRegisterWrite(0x8300, RGBGetRValue(color_buf[0]));
|
||||
CrucialRegisterWrite(0x8301, RGBGetRValue(color_buf[1]));
|
||||
@@ -139,21 +131,3 @@ void CrucialController::CrucialRegisterWrite(crucial_register reg, unsigned char
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
|
||||
}
|
||||
|
||||
void CrucialController::SendEffectColor
|
||||
(
|
||||
unsigned int led_idx,
|
||||
unsigned int red,
|
||||
unsigned int green,
|
||||
unsigned int blue
|
||||
)
|
||||
{
|
||||
CrucialRegisterWrite(0x82E9, (1 << led_idx));
|
||||
CrucialRegisterWrite(0x82EA, 0x00);
|
||||
CrucialRegisterWrite(0x82EB, 0x00);
|
||||
CrucialRegisterWrite(0x82EC, 0x00);
|
||||
CrucialRegisterWrite(0x82ED, red);
|
||||
CrucialRegisterWrite(0x82EE, green);
|
||||
CrucialRegisterWrite(0x82EF, blue);
|
||||
CrucialRegisterWrite(0x82F0, 0x01);
|
||||
}
|
||||
@@ -18,7 +18,6 @@ typedef unsigned short crucial_register;
|
||||
|
||||
enum
|
||||
{
|
||||
CRUCIAL_MODE_UNKNOWN = 0x00, /* We don't know what the mode is */
|
||||
CRUCIAL_MODE_SHIFT = 0x1F, /* Shift effect mode */
|
||||
CRUCIAL_MODE_GRADIENT_SHIFT = 0x2F, /* Gradient shift mode */
|
||||
CRUCIAL_MODE_FILL = 0x3F, /* Fill effect mode */
|
||||
@@ -43,7 +42,6 @@ public:
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void SetAllColorsDirect(RGBColor* colors);
|
||||
void SetAllColorsEffect(RGBColor* colors);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
unsigned char CrucialRegisterRead(crucial_register reg);
|
||||
@@ -54,19 +52,11 @@ private:
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
unsigned char channel_cfg;
|
||||
unsigned char last_mode;
|
||||
i2c_smbus_interface * bus;
|
||||
crucial_dev_id dev;
|
||||
|
||||
void SendEffectColor
|
||||
(
|
||||
unsigned int led_idx,
|
||||
unsigned int red,
|
||||
unsigned int green,
|
||||
unsigned int blue
|
||||
);
|
||||
|
||||
void SendDirectColors(RGBColor* color_buf);
|
||||
void SendEffectColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SendBrightness(unsigned char brightness);
|
||||
void SendEffectMode(unsigned char mode, unsigned char speed);
|
||||
};
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include "Detector.h"
|
||||
#include "CrucialController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Crucial.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -75,21 +73,16 @@ void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
// Add Crucial controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < CRUCIAL_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
// Add Crucial controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < CRUCIAL_ADDRESS_COUNT; address_list_idx++)
|
||||
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
|
||||
{
|
||||
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
|
||||
{
|
||||
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Crucial(new_crucial);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Crucial(new_crucial);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCrucialControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("Crucial", DetectCrucialControllers);
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Crucial.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Crucial |
|
||||
| Ballistix RGB controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Crucial.h"
|
||||
|
||||
RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
|
||||
{
|
||||
crucial = crucial_ptr;
|
||||
|
||||
name = "Crucial DRAM";
|
||||
vendor = "Crucial";
|
||||
type = DEVICE_TYPE_DRAM;
|
||||
description = "Crucial DRAM Device";
|
||||
location = crucial->GetDeviceLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Shift;
|
||||
Shift.name = "Shift";
|
||||
Shift.value = CRUCIAL_MODE_SHIFT;
|
||||
Shift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Shift.colors_min = 1;
|
||||
Shift.colors_max = 1;
|
||||
Shift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Shift.colors.resize(1);
|
||||
modes.push_back(Shift);
|
||||
|
||||
mode GradientShift;
|
||||
GradientShift.name = "Gradient Shift";
|
||||
GradientShift.value = CRUCIAL_MODE_GRADIENT_SHIFT;
|
||||
GradientShift.flags = 0;
|
||||
GradientShift.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(GradientShift);
|
||||
|
||||
mode Fill;
|
||||
Fill.name = "Fill";
|
||||
Fill.value = CRUCIAL_MODE_FILL;
|
||||
Fill.flags = 0;
|
||||
Fill.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Fill);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
Stack.value = CRUCIAL_MODE_STACK;
|
||||
Stack.flags = 0;
|
||||
Stack.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode DoubleStack;
|
||||
DoubleStack.name = "Double Stack";
|
||||
DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK;
|
||||
DoubleStack.flags = 0;
|
||||
DoubleStack.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(DoubleStack);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CRUCIAL_MODE_BREATHING;
|
||||
Breathing.flags = 0;
|
||||
Breathing.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode MotionPoint;
|
||||
MotionPoint.name = "Motion Point";
|
||||
MotionPoint.value = CRUCIAL_MODE_MOTION_POINT;
|
||||
MotionPoint.flags = 0;
|
||||
MotionPoint.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(MotionPoint);
|
||||
|
||||
mode InsideOut;
|
||||
InsideOut.name = "Inside Out";
|
||||
InsideOut.value = CRUCIAL_MODE_INSIDE_OUT;
|
||||
InsideOut.flags = 0;
|
||||
InsideOut.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(InsideOut);
|
||||
|
||||
mode ColorStep;
|
||||
ColorStep.name = "Color Step";
|
||||
ColorStep.value = CRUCIAL_MODE_COLOR_STEP;
|
||||
ColorStep.flags = 0;
|
||||
ColorStep.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(ColorStep);
|
||||
|
||||
mode WaterWave;
|
||||
WaterWave.name = "Water Wave (Color Blending)";
|
||||
WaterWave.value = CRUCIAL_MODE_WATER_WAVE;
|
||||
WaterWave.flags = 0;
|
||||
WaterWave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(WaterWave);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = CRUCIAL_MODE_FLASHING;
|
||||
Flashing.flags = 0;
|
||||
Flashing.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CRUCIAL_MODE_STATIC;
|
||||
Static.flags = 0;
|
||||
Static.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Static);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
new_zone.name = "DRAM";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 8;
|
||||
new_zone.leds_max = 8;
|
||||
new_zone.leds_count = 8;
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up LEDs |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "DRAM LED ";
|
||||
new_led.name.append(std::to_string(led_idx));
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Crucial::DeviceUpdateLEDs()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
crucial->SetAllColorsDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
crucial->SetAllColorsEffect(&colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Crucial::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Crucial::DeviceUpdateMode()
|
||||
{
|
||||
crucial->SetMode(modes[active_mode].value);
|
||||
}
|
||||
@@ -1,544 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Debug.h"
|
||||
#include "RGBController_Dummy.h"
|
||||
#include "SettingsManager.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int debug_keyboard_matrix_map[6][23] =
|
||||
{ { 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 *led_names[] =
|
||||
{
|
||||
"Key: Escape",
|
||||
"Key: `",
|
||||
"Key: Tab",
|
||||
"Key: Caps Lock",
|
||||
"Key: Left Shift",
|
||||
"Key: Left Control",
|
||||
"Key: F12",
|
||||
"Key: =",
|
||||
"Key: F9",
|
||||
"Key: 9",
|
||||
"Key: O",
|
||||
"Key: L",
|
||||
"Key: ,",
|
||||
"Key: Menu",
|
||||
"Key: Enter (ISO)",
|
||||
"Key: Left Arrow",
|
||||
"Key: F1",
|
||||
"Key: 1",
|
||||
"Key: Q",
|
||||
"Key: A",
|
||||
"Key: \\ (ISO)",
|
||||
"Key: Left Windows",
|
||||
"Key: Print Screen",
|
||||
"Key: F10",
|
||||
"Key: 0",
|
||||
"Key: P",
|
||||
"Key: ;",
|
||||
"Key: .",
|
||||
"Key: Enter",
|
||||
"Key: Down Arrow",
|
||||
"Key: F2",
|
||||
"Key: 2",
|
||||
"Key: W",
|
||||
"Key: S",
|
||||
"Key: Z",
|
||||
"Key: Left Alt",
|
||||
"Key: Scroll Lock",
|
||||
"Key: Backspace",
|
||||
"Key: F11",
|
||||
"Key: -",
|
||||
"Key: [",
|
||||
"Key: '",
|
||||
"Key: /",
|
||||
"Key: Right Arrow",
|
||||
"Key: F3",
|
||||
"Key: 3",
|
||||
"Key: E",
|
||||
"Key: D",
|
||||
"Key: X",
|
||||
"Key: Pause/Break",
|
||||
"Key: Delete",
|
||||
"Key: Number Pad 7",
|
||||
"Key: Num Lock",
|
||||
"Key: Number Pad 6",
|
||||
"Key: F4",
|
||||
"Key: 4",
|
||||
"Key: R",
|
||||
"Key: F",
|
||||
"Key: C",
|
||||
"Key: Space",
|
||||
"Key: Insert",
|
||||
"Key: End",
|
||||
"Key: Number Pad 8",
|
||||
"Key: Number Pad /",
|
||||
"Key: Number Pad 1",
|
||||
"Key: F5",
|
||||
"Key: 5",
|
||||
"Key: T",
|
||||
"Key: G",
|
||||
"Key: V",
|
||||
"Key: Home",
|
||||
"Key: Page Down",
|
||||
"Key: Number Pad 9",
|
||||
"Key: Number Pad *",
|
||||
"Key: Number Pad 2",
|
||||
"Key: F6",
|
||||
"Key: 6",
|
||||
"Key: Y",
|
||||
"Key: H",
|
||||
"Key: B",
|
||||
"Key: Page Up",
|
||||
"Key: Right Shift",
|
||||
"Key: Number Pad -",
|
||||
"Key: Number Pad 3",
|
||||
"Key: F7",
|
||||
"Key: 7",
|
||||
"Key: U",
|
||||
"Key: J",
|
||||
"Key: N",
|
||||
"Key: Right Alt",
|
||||
"Key: ]",
|
||||
"Key: Right Control",
|
||||
"Key: Number Pad 4",
|
||||
"Key: Number Pad +",
|
||||
"Key: Number Pad 0",
|
||||
"Key: F8",
|
||||
"Key: 8",
|
||||
"Key: I",
|
||||
"Key: K",
|
||||
"Key: M",
|
||||
"Key: Right Windows",
|
||||
"Key: \\ (ANSI)",
|
||||
"Key: Up Arrow",
|
||||
"Key: Number Pad 5",
|
||||
"Key: Number Pad Enter",
|
||||
"Key: Number Pad .",
|
||||
"RGB Strip 1",
|
||||
"RGB Strip 2",
|
||||
"RGB Strip 3",
|
||||
"RGB Strip 4",
|
||||
"RGB Strip 5",
|
||||
"RGB Strip 6",
|
||||
"RGB Strip 7",
|
||||
"RGB Strip 8",
|
||||
"RGB Strip 9",
|
||||
"RGB Strip 10",
|
||||
"RGB Strip 11",
|
||||
"RGB Strip 12",
|
||||
"RGB Strip 13",
|
||||
"RGB Strip 14",
|
||||
"RGB Strip 15",
|
||||
"RGB Strip 16",
|
||||
"RGB Strip 17",
|
||||
"RGB Strip 18",
|
||||
"Key: Media Previous",
|
||||
"Key: Media Play/Pause",
|
||||
"Key: Media Next",
|
||||
"Key: Media Mute"
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectDebugControllers *
|
||||
* *
|
||||
* Add dummy controllers based on the DebugDevices key in the settings json *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
json debug_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Debug Device settings from settings manager |
|
||||
\*-------------------------------------------------*/
|
||||
debug_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("DebugDevices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the Debug settings contains devices, process |
|
||||
\*-------------------------------------------------*/
|
||||
if(debug_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < debug_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
std::string type = "";
|
||||
|
||||
if(debug_settings["devices"][device_idx].contains("type"))
|
||||
{
|
||||
type = debug_settings["devices"][device_idx]["type"];
|
||||
}
|
||||
|
||||
if(type == "motherboard")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a dummy motherboard |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController_Dummy* dummy_motherboard = new RGBController_Dummy();
|
||||
|
||||
dummy_motherboard->name = "Debug Motherboard";
|
||||
dummy_motherboard->type = DEVICE_TYPE_MOTHERBOARD;
|
||||
dummy_motherboard->description = "Debug Motherboard Device";
|
||||
dummy_motherboard->location = "Debug Motherboard Location";
|
||||
dummy_motherboard->version = "Debug Motherboard Version";
|
||||
dummy_motherboard->serial = "Debug Motherboard Serial";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a direct mode for the dummy motherboard |
|
||||
\*---------------------------------------------------------*/
|
||||
mode dummy_motherboard_direct_mode;
|
||||
|
||||
dummy_motherboard_direct_mode.name = "Direct";
|
||||
dummy_motherboard_direct_mode.value = 0;
|
||||
dummy_motherboard_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_motherboard_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_motherboard->modes.push_back(dummy_motherboard_direct_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a single zone/LED for the dummy motherboard |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_motherboard_single_zone;
|
||||
|
||||
dummy_motherboard_single_zone.name = "Single Zone";
|
||||
dummy_motherboard_single_zone.type = ZONE_TYPE_SINGLE;
|
||||
dummy_motherboard_single_zone.leds_min = 1;
|
||||
dummy_motherboard_single_zone.leds_max = 1;
|
||||
dummy_motherboard_single_zone.leds_count = 1;
|
||||
dummy_motherboard_single_zone.matrix_map = NULL;
|
||||
|
||||
dummy_motherboard->zones.push_back(dummy_motherboard_single_zone);
|
||||
|
||||
led dummy_motherboard_single_led;
|
||||
|
||||
dummy_motherboard_single_led.name = "Single LED";
|
||||
|
||||
dummy_motherboard->leds.push_back(dummy_motherboard_single_led);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy motherboard |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_motherboard_linear_zone;
|
||||
|
||||
dummy_motherboard_linear_zone.name = "Linear Zone";
|
||||
dummy_motherboard_linear_zone.type = ZONE_TYPE_LINEAR;
|
||||
dummy_motherboard_linear_zone.leds_min = 10;
|
||||
dummy_motherboard_linear_zone.leds_max = 10;
|
||||
dummy_motherboard_linear_zone.leds_count = 10;
|
||||
dummy_motherboard_linear_zone.matrix_map = NULL;
|
||||
|
||||
dummy_motherboard->zones.push_back(dummy_motherboard_linear_zone);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < 10; led_idx++)
|
||||
{
|
||||
led dummy_motherboard_linear_led;
|
||||
|
||||
dummy_motherboard_linear_led.name = "Linear LED " + std::to_string(led_idx);
|
||||
|
||||
dummy_motherboard->leds.push_back(dummy_motherboard_linear_led);
|
||||
}
|
||||
|
||||
dummy_motherboard->SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the dummy motherboard onto the controller list |
|
||||
\*---------------------------------------------------------*/
|
||||
rgb_controllers.push_back(dummy_motherboard);
|
||||
}
|
||||
else if(type == "dram")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a dummy DRAM |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController_Dummy* dummy_dram = new RGBController_Dummy();
|
||||
|
||||
dummy_dram->name = "Debug DRAM";
|
||||
dummy_dram->type = DEVICE_TYPE_DRAM;
|
||||
dummy_dram->description = "Debug DRAM Device";
|
||||
dummy_dram->location = "Debug DRAM Location";
|
||||
dummy_dram->version = "Debug DRAM Version";
|
||||
dummy_dram->serial = "Debug DRAM Serial";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a direct mode for the dummy DRAM |
|
||||
\*---------------------------------------------------------*/
|
||||
mode dummy_dram_direct_mode;
|
||||
|
||||
dummy_dram_direct_mode.name = "Direct";
|
||||
dummy_dram_direct_mode.value = 0;
|
||||
dummy_dram_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_dram_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_dram->modes.push_back(dummy_dram_direct_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a single zone/LED for the dummy DRAM |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_dram_single_zone;
|
||||
|
||||
dummy_dram_single_zone.name = "Single Zone";
|
||||
dummy_dram_single_zone.type = ZONE_TYPE_SINGLE;
|
||||
dummy_dram_single_zone.leds_min = 1;
|
||||
dummy_dram_single_zone.leds_max = 1;
|
||||
dummy_dram_single_zone.leds_count = 1;
|
||||
dummy_dram_single_zone.matrix_map = NULL;
|
||||
|
||||
dummy_dram->zones.push_back(dummy_dram_single_zone);
|
||||
|
||||
led dummy_dram_single_led;
|
||||
|
||||
dummy_dram_single_led.name = "Single LED";
|
||||
|
||||
dummy_dram->leds.push_back(dummy_dram_single_led);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy DRAM |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_dram_linear_zone;
|
||||
|
||||
dummy_dram_linear_zone.name = "Linear Zone";
|
||||
dummy_dram_linear_zone.type = ZONE_TYPE_LINEAR;
|
||||
dummy_dram_linear_zone.leds_min = 5;
|
||||
dummy_dram_linear_zone.leds_max = 5;
|
||||
dummy_dram_linear_zone.leds_count = 5;
|
||||
dummy_dram_linear_zone.matrix_map = NULL;
|
||||
|
||||
dummy_dram->zones.push_back(dummy_dram_linear_zone);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < 5; led_idx++)
|
||||
{
|
||||
led dummy_dram_linear_led;
|
||||
|
||||
dummy_dram_linear_led.name = "Linear LED " + std::to_string(led_idx);
|
||||
|
||||
dummy_dram->leds.push_back(dummy_dram_linear_led);
|
||||
}
|
||||
|
||||
dummy_dram->SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the dummy DRAM onto the controller list |
|
||||
\*---------------------------------------------------------*/
|
||||
rgb_controllers.push_back(dummy_dram);
|
||||
}
|
||||
else if(type == "gpu")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController_Dummy* dummy_gpu = new RGBController_Dummy();
|
||||
|
||||
dummy_gpu->name = "Debug GPU";
|
||||
dummy_gpu->type = DEVICE_TYPE_GPU;
|
||||
dummy_gpu->description = "Debug GPU Device";
|
||||
dummy_gpu->location = "Debug GPU Location";
|
||||
dummy_gpu->version = "Debug GPU Version";
|
||||
dummy_gpu->serial = "Debug GPU Serial";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a direct mode for the dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
mode dummy_gpu_direct_mode;
|
||||
|
||||
dummy_gpu_direct_mode.name = "Direct";
|
||||
dummy_gpu_direct_mode.value = 0;
|
||||
dummy_gpu_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_gpu_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_gpu->modes.push_back(dummy_gpu_direct_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a single zone/LED for the dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_gpu_single_zone;
|
||||
|
||||
dummy_gpu_single_zone.name = "Single Zone";
|
||||
dummy_gpu_single_zone.type = ZONE_TYPE_SINGLE;
|
||||
dummy_gpu_single_zone.leds_min = 1;
|
||||
dummy_gpu_single_zone.leds_max = 1;
|
||||
dummy_gpu_single_zone.leds_count = 1;
|
||||
dummy_gpu_single_zone.matrix_map = NULL;
|
||||
|
||||
dummy_gpu->zones.push_back(dummy_gpu_single_zone);
|
||||
|
||||
led dummy_gpu_single_led;
|
||||
|
||||
dummy_gpu_single_led.name = "Single LED";
|
||||
|
||||
dummy_gpu->leds.push_back(dummy_gpu_single_led);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_gpu_linear_zone;
|
||||
|
||||
dummy_gpu_linear_zone.name = "Linear Zone";
|
||||
dummy_gpu_linear_zone.type = ZONE_TYPE_LINEAR;
|
||||
dummy_gpu_linear_zone.leds_min = 15;
|
||||
dummy_gpu_linear_zone.leds_max = 15;
|
||||
dummy_gpu_linear_zone.leds_count = 15;
|
||||
dummy_gpu_linear_zone.matrix_map = NULL;
|
||||
|
||||
dummy_gpu->zones.push_back(dummy_gpu_linear_zone);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < 15; led_idx++)
|
||||
{
|
||||
led dummy_gpu_linear_led;
|
||||
|
||||
dummy_gpu_linear_led.name = "Linear LED " + std::to_string(led_idx);
|
||||
|
||||
dummy_gpu->leds.push_back(dummy_gpu_linear_led);
|
||||
}
|
||||
|
||||
dummy_gpu->SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the dummy GPU onto the controller list |
|
||||
\*---------------------------------------------------------*/
|
||||
rgb_controllers.push_back(dummy_gpu);
|
||||
}
|
||||
else if(type == "keyboard")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a dummy Keyboard |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController_Dummy* dummy_keyboard = new RGBController_Dummy();
|
||||
|
||||
dummy_keyboard->name = "Debug Keyboard";
|
||||
dummy_keyboard->type = DEVICE_TYPE_KEYBOARD;
|
||||
dummy_keyboard->description = "Debug Keyboard Device";
|
||||
dummy_keyboard->location = "Debug Keyboard Location";
|
||||
dummy_keyboard->version = "Debug Keyboard Version";
|
||||
dummy_keyboard->serial = "Debug Keyboard Serial";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a direct mode for the dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
mode dummy_gpu_direct_mode;
|
||||
|
||||
dummy_gpu_direct_mode.name = "Direct";
|
||||
dummy_gpu_direct_mode.value = 0;
|
||||
dummy_gpu_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_gpu_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_keyboard->modes.push_back(dummy_gpu_direct_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a matrix zone for the debug Keyboard |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_keyboard_matrix_zone;
|
||||
|
||||
dummy_keyboard_matrix_zone.name = "Keyboard Matrix Zone";
|
||||
dummy_keyboard_matrix_zone.type = ZONE_TYPE_MATRIX;
|
||||
dummy_keyboard_matrix_zone.leds_min = 106;
|
||||
dummy_keyboard_matrix_zone.leds_max = 106;
|
||||
dummy_keyboard_matrix_zone.leds_count = 106;
|
||||
dummy_keyboard_matrix_zone.matrix_map = new matrix_map_type;
|
||||
dummy_keyboard_matrix_zone.matrix_map->height = 6;
|
||||
dummy_keyboard_matrix_zone.matrix_map->width = 23;
|
||||
dummy_keyboard_matrix_zone.matrix_map->map = (unsigned int*)&debug_keyboard_matrix_map;
|
||||
|
||||
dummy_keyboard->zones.push_back(dummy_keyboard_matrix_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy GPU |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_keyboard_linear_zone;
|
||||
|
||||
dummy_keyboard_linear_zone.name = "Linear Zone";
|
||||
dummy_keyboard_linear_zone.type = ZONE_TYPE_LINEAR;
|
||||
dummy_keyboard_linear_zone.leds_min = 18;
|
||||
dummy_keyboard_linear_zone.leds_max = 18;
|
||||
dummy_keyboard_linear_zone.leds_count = 18;
|
||||
dummy_keyboard_linear_zone.matrix_map = NULL;
|
||||
|
||||
dummy_keyboard->zones.push_back(dummy_keyboard_linear_zone);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < 124; led_idx++)
|
||||
{
|
||||
led dummy_keyboard_led;
|
||||
dummy_keyboard_led.name = led_names[led_idx];
|
||||
dummy_keyboard->leds.push_back(dummy_keyboard_led);
|
||||
}
|
||||
|
||||
dummy_keyboard->SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the dummy Keyboard onto the controller list |
|
||||
\*---------------------------------------------------------*/
|
||||
rgb_controllers.push_back(dummy_keyboard);
|
||||
}
|
||||
else if(type == "argb")
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a dummy ARGB |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBController_Debug* dummy_argb = new RGBController_Debug();
|
||||
|
||||
dummy_argb->name = "Debug ARGB";
|
||||
dummy_argb->type = DEVICE_TYPE_LEDSTRIP;
|
||||
dummy_argb->description = "Debug ARGB Device";
|
||||
dummy_argb->location = "Debug ARGB Location";
|
||||
dummy_argb->version = "Debug ARGB Version";
|
||||
dummy_argb->serial = "Debug ARGB Serial";
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a direct mode for the dummy ARGB |
|
||||
\*---------------------------------------------------------*/
|
||||
mode dummy_argb_direct_mode;
|
||||
|
||||
dummy_argb_direct_mode.name = "Direct";
|
||||
dummy_argb_direct_mode.value = 0;
|
||||
dummy_argb_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_argb_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_argb->modes.push_back(dummy_argb_direct_mode);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy ARGB |
|
||||
\*---------------------------------------------------------*/
|
||||
zone dummy_argb_linear_zone;
|
||||
|
||||
dummy_argb_linear_zone.name = "Resizable zone";
|
||||
dummy_argb_linear_zone.type = ZONE_TYPE_LINEAR;
|
||||
dummy_argb_linear_zone.leds_min = 1;
|
||||
dummy_argb_linear_zone.leds_max = 100;
|
||||
dummy_argb_linear_zone.leds_count = 0;
|
||||
dummy_argb_linear_zone.matrix_map = NULL;
|
||||
|
||||
dummy_argb->zones.push_back(dummy_argb_linear_zone);
|
||||
|
||||
dummy_argb->SetupColors();
|
||||
dummy_argb->ResizeZone(0, 60);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Push the dummy ARGB onto the controller list |
|
||||
\*---------------------------------------------------------*/
|
||||
rgb_controllers.push_back(dummy_argb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectDebugControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Debug Controllers", DetectDebugControllers);
|
||||
@@ -1,49 +0,0 @@
|
||||
#include "RGBController_Debug.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
RGBController_Debug::RGBController_Debug()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Debug::ResizeZone(int index, int new_size)
|
||||
{
|
||||
//Make sure that it isn't out of bounds (negative numbers)
|
||||
if(new_size < int(zones[index].leds_min))
|
||||
{
|
||||
new_size = zones[index].leds_min;
|
||||
}
|
||||
|
||||
// Same thing as the above line except for over 100
|
||||
if(new_size > int(zones[index].leds_max))
|
||||
{
|
||||
new_size = zones[index].leds_max;
|
||||
}
|
||||
|
||||
// Store the previous amount of LEDs
|
||||
int old_size = zones[index].leds_count;
|
||||
|
||||
// Set the LED count in the zone to the new ammount
|
||||
zones[index].leds_count = new_size;
|
||||
|
||||
// Set the new ammount of LEDs for to the new size
|
||||
size_t old_leds_size = leds.size();
|
||||
|
||||
// Add the new ammount of LEDs to the old ammount
|
||||
size_t new_leds_size = leds.size() - old_size + new_size;
|
||||
|
||||
leds.resize(std::max(old_leds_size, new_leds_size));
|
||||
|
||||
memmove(&leds[zones[index].start_idx] + old_leds_size, &leds[zones[index].start_idx] + new_leds_size, (old_leds_size - zones[index].start_idx - old_size) * sizeof(led));
|
||||
|
||||
leds.resize(new_leds_size);
|
||||
|
||||
for(int i = 0; i < new_size; ++i)
|
||||
{
|
||||
leds[zones[index].start_idx + i].name = "Linear LED " + std::to_string(i);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
#ifndef RGBCONTROLLER_DEBUG_H
|
||||
#define RGBCONTROLLER_DEBUG_H
|
||||
|
||||
#include "RGBController_Dummy.h"
|
||||
|
||||
// A variation of Dummy controller that allows the zones to be resized
|
||||
|
||||
class RGBController_Debug : public RGBController_Dummy
|
||||
{
|
||||
public:
|
||||
RGBController_Debug();
|
||||
void ResizeZone(int zone, int newSize) override;
|
||||
};
|
||||
|
||||
#endif // RGBCONTROLLER_DEBUG_H
|
||||
@@ -1,204 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
DuckyKeyboardController::~DuckyKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string DuckyKeyboardController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string DuckyKeyboardController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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, const char* path);
|
||||
~DuckyKeyboardController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendColors
|
||||
(
|
||||
unsigned char* color_data,
|
||||
unsigned int color_data_size
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
|
||||
void SendInitialize();
|
||||
void SendInitializeColorPacket();
|
||||
unsigned int SendColorDataPacket
|
||||
(
|
||||
unsigned char packet_id,
|
||||
unsigned char* color_data,
|
||||
unsigned int color_size
|
||||
);
|
||||
void SendTerminateColorPacket();
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "DuckyKeyboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_DuckyKeyboard.h"
|
||||
#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
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectDuckyKeyboardControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Ducky RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectDuckyKeyboardControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
DuckyKeyboardController* controller = new DuckyKeyboardController(dev, info->path);
|
||||
RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectDuckyKeyboardControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR_I("Ducky Shine 7/Ducky One 2 RGB", DetectDuckyKeyboardControllers, DUCKY_VID, DUCKY_SHINE_7_ONE_2_RGB_PID, 1);
|
||||
REGISTER_HID_DETECTOR_I("Ducky One 2 RGB TKL", DetectDuckyKeyboardControllers, DUCKY_VID, DUCKY_ONE_2_RGB_TKL_PID, 1);
|
||||
@@ -1,281 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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, 108, 114, 120, 126 },
|
||||
{ 1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, NA, 67, 73, 85, NA, 91, 97, 103, 109, 115, 121, 127 },
|
||||
{ 2, NA, 8, 14, 20, 26, NA, 32, 38, 44, 50, 56, 62, 68, 74, 86, 92, 98, 104, 110, 116, 122, 128 },
|
||||
{ 3, NA, 9, 15, 21, 27, NA, 33, 39, 45, 51, 57, 63, 69, 87, NA, NA, NA, NA, 111, 117, 123, NA },
|
||||
{ 4, NA, 16, 22, 28, 34, NA, 40, NA, 46, 52, 58, 64, 70, 82, NA, NA, 100, NA, 112, 118, 124, 131 },
|
||||
{ 5, 11, 17, NA, NA, NA, NA, 41, NA, NA, NA, NA, 65, 77, 83, 89, 95, 101, 107, 113, NA, 125, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard"
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
132
|
||||
};
|
||||
|
||||
static const char *led_names[] =
|
||||
{
|
||||
"Key: Escape",
|
||||
"Key: `",
|
||||
"Key: Tab",
|
||||
"Key: Caps Lock",
|
||||
"Key: Left Shift",
|
||||
"Key: Left Control",
|
||||
"Unused",
|
||||
"Key: 1",
|
||||
"Key: Q",
|
||||
"Key: A",
|
||||
"Unused",
|
||||
"Key: Left Windows",
|
||||
"Key: F1",
|
||||
"Key: 2",
|
||||
"Key: W",
|
||||
"Key: S",
|
||||
"Key: Z",
|
||||
"Key: Left Alt",
|
||||
"Key: F2",
|
||||
"Key: 3",
|
||||
"Key: E",
|
||||
"Key: D",
|
||||
"Key: X",
|
||||
"Unused",
|
||||
"Key: F3",
|
||||
"Key: 4",
|
||||
"Key: R",
|
||||
"Key: F",
|
||||
"Key: C",
|
||||
"Unused",
|
||||
"Key: F4",
|
||||
"Key: 5",
|
||||
"Key: T",
|
||||
"Key: G",
|
||||
"Key: V",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: 6",
|
||||
"Key: Y",
|
||||
"Key: H",
|
||||
"Key: B",
|
||||
"Key: Space",
|
||||
"Key: F5",
|
||||
"Key: 7",
|
||||
"Key: U",
|
||||
"Key: J",
|
||||
"Key: N",
|
||||
"Unused",
|
||||
"Key: F6",
|
||||
"Key: 8",
|
||||
"Key: I",
|
||||
"Key: K",
|
||||
"Key: M",
|
||||
"Unused",
|
||||
"Key: F7",
|
||||
"Key: 9",
|
||||
"Key: O",
|
||||
"Key: L",
|
||||
"Key: ,",
|
||||
"Unused",
|
||||
"Key: F8",
|
||||
"Key: 0",
|
||||
"Key: P",
|
||||
"Key: ;",
|
||||
"Key: .",
|
||||
"Key: Right Alt",
|
||||
"Key: F9",
|
||||
"Key: -",
|
||||
"Key: [",
|
||||
"Key: '",
|
||||
"Key: /",
|
||||
"Unused",
|
||||
"Key: F10",
|
||||
"Key: =",
|
||||
"Key: ]",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: Right Windows",
|
||||
"Key: F11",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: Right Shift",
|
||||
"Key: Right Fn",
|
||||
"Key: F12",
|
||||
"Key: Backspace",
|
||||
"Key: \\ (ANSI)",
|
||||
"Key: Enter",
|
||||
"Unused",
|
||||
"Key: Right Control",
|
||||
"Key: Print Screen",
|
||||
"Key: Insert",
|
||||
"Key: Delete",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: Left Arrow",
|
||||
"Key: Scroll Lock",
|
||||
"Key: Home",
|
||||
"Key: End",
|
||||
"Unused",
|
||||
"Key: Up Arrow",
|
||||
"Key: Down Arrow",
|
||||
"Key: Pause/Break",
|
||||
"Key: Page Up",
|
||||
"Key: Page Down",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: Right Arrow",
|
||||
"Key: Calculator",
|
||||
"Key: Num Lock",
|
||||
"Key: Number Pad 7",
|
||||
"Key: Number Pad 4",
|
||||
"Key: Number Pad 1",
|
||||
"Key: Number Pad 0",
|
||||
"Key: Media Mute",
|
||||
"Key: Number Pad /",
|
||||
"Key: Number Pad 8",
|
||||
"Key: Number Pad 5",
|
||||
"Key: Number Pad 2",
|
||||
"Unused",
|
||||
"Key: Media Volume Down",
|
||||
"Key: Number Pad *",
|
||||
"Key: Number Pad 9",
|
||||
"Key: Number Pad 6",
|
||||
"Key: Number Pad 3",
|
||||
"Key: Number Pad .",
|
||||
"Key: Media Volume Up",
|
||||
"Key: Number Pad -",
|
||||
"Key: Number Pad +",
|
||||
"Unused",
|
||||
"Unused",
|
||||
"Key: Number Pad Enter",
|
||||
};
|
||||
|
||||
RGBController_DuckyKeyboard::RGBController_DuckyKeyboard(DuckyKeyboardController* ducky_ptr)
|
||||
{
|
||||
ducky = ducky_ptr;
|
||||
|
||||
name = "Ducky Keyboard Device";
|
||||
vendor = "Ducky";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Ducky Keyboard Device";
|
||||
location = ducky->GetDeviceLocation();
|
||||
serial = ducky->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_DuckyKeyboard::~RGBController_DuckyKeyboard()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_DuckyKeyboard::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];
|
||||
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);
|
||||
|
||||
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_DuckyKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_DuckyKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char colordata[155*3];
|
||||
|
||||
for(std::size_t 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::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| 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 DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
DuckyKeyboardController* ducky;
|
||||
};
|
||||
@@ -1,274 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_E131.h"
|
||||
#include "SettingsManager.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectE131Controllers *
|
||||
* *
|
||||
* Detect devices supported by the E131 driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
json e131_settings;
|
||||
|
||||
std::vector<std::vector<E131Device>> device_lists;
|
||||
E131Device dev;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get E1.31 settings from settings manager |
|
||||
\*-------------------------------------------------*/
|
||||
e131_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("E131Devices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the E1.31 settings contains devices, process |
|
||||
\*-------------------------------------------------*/
|
||||
if(e131_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < e131_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear E1.31 device data |
|
||||
\*-------------------------------------------------*/
|
||||
dev.name = "";
|
||||
dev.ip = "";
|
||||
dev.type = ZONE_TYPE_SINGLE;
|
||||
dev.num_leds = 0;
|
||||
dev.rgb_order = E131_RGB_ORDER_RBG;
|
||||
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT;
|
||||
dev.matrix_width = 0;
|
||||
dev.matrix_height = 0;
|
||||
dev.start_channel = 1;
|
||||
dev.start_universe = 1;
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
dev.name = e131_settings["devices"][device_idx]["name"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("ip"))
|
||||
{
|
||||
dev.ip = e131_settings["devices"][device_idx]["ip"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("num_leds"))
|
||||
{
|
||||
dev.num_leds = e131_settings["devices"][device_idx]["num_leds"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("start_universe"))
|
||||
{
|
||||
dev.start_universe = e131_settings["devices"][device_idx]["start_universe"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("start_channel"))
|
||||
{
|
||||
dev.start_channel = e131_settings["devices"][device_idx]["start_channel"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("matrix_order"))
|
||||
{
|
||||
std::string matrix_order_val = e131_settings["devices"][device_idx]["matrix_order"];
|
||||
|
||||
if(matrix_order_val == "HORIZONTAL_TOP_LEFT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_LEFT;
|
||||
}
|
||||
else if(matrix_order_val == "HORIZONTAL_TOP_RIGHT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_TOP_RIGHT;
|
||||
}
|
||||
else if(matrix_order_val == "HORIZONTAL_BOTTOM_LEFT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_LEFT;
|
||||
}
|
||||
else if(matrix_order_val == "HORIZONTAL_BOTTOM_RIGHT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_HORIZONTAL_BOTTOM_RIGHT;
|
||||
}
|
||||
else if(matrix_order_val == "VERTICAL_TOP_LEFT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_LEFT;
|
||||
}
|
||||
else if(matrix_order_val == "VERTICAL_TOP_RIGHT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_TOP_RIGHT;
|
||||
}
|
||||
else if(matrix_order_val == "VERTICAL_BOTTOM_LEFT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_LEFT;
|
||||
}
|
||||
else if(matrix_order_val == "VERTICAL_BOTTOM_RIGHT")
|
||||
{
|
||||
dev.matrix_order = E131_MATRIX_ORDER_VERTICAL_BOTTOM_RIGHT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.matrix_order = e131_settings["devices"][device_idx]["matrix_order"];
|
||||
}
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("rgb_order"))
|
||||
{
|
||||
std::string rgb_order_val = e131_settings["devices"][device_idx]["rgb_order"];
|
||||
|
||||
if(rgb_order_val == "RGB")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_RGB;
|
||||
}
|
||||
else if(rgb_order_val == "RBG")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_RBG;
|
||||
}
|
||||
else if(rgb_order_val == "GRB")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_GRB;
|
||||
}
|
||||
else if(rgb_order_val == "GBR")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_GBR;
|
||||
}
|
||||
else if(rgb_order_val == "BRG")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_BGR;
|
||||
}
|
||||
else if(rgb_order_val == "BGR")
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_BGR;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.rgb_order = e131_settings["devices"][device_idx]["rgb_order"];
|
||||
}
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("matrix_width"))
|
||||
{
|
||||
dev.matrix_width = e131_settings["devices"][device_idx]["matrix_width"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("matrix_height"))
|
||||
{
|
||||
dev.matrix_height = e131_settings["devices"][device_idx]["matrix_height"];
|
||||
}
|
||||
|
||||
if(e131_settings["devices"][device_idx].contains("type"))
|
||||
{
|
||||
std::string type_val = e131_settings["devices"][device_idx]["type"];
|
||||
|
||||
if(type_val == "SINGLE")
|
||||
{
|
||||
dev.type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
else if(type_val == "LINEAR")
|
||||
{
|
||||
dev.type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
else if(type_val == "MATRIX")
|
||||
{
|
||||
dev.type = ZONE_TYPE_MATRIX;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.type = e131_settings["devices"][device_idx]["type"];
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Determine whether to create a new list or add this device |
|
||||
| to an existing list. A device is added to an existing |
|
||||
| list if both devices share one or more universes for the |
|
||||
| same output destination |
|
||||
\*---------------------------------------------------------*/
|
||||
bool device_added_to_existing_list = false;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Only track grouping for multicast controllers. Unicast |
|
||||
| controllers are currently not grouped. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(dev.ip == "")
|
||||
{
|
||||
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < device_lists[list_idx].size(); device_idx++)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Determine if there is any overlap between this device and |
|
||||
| any existing device list |
|
||||
| Offset the end by two - one because the range is 1-512 |
|
||||
| rather than 0-511, and one because the start channel is |
|
||||
| included in the first set of 3 channels. |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int dev_start = dev.start_universe;
|
||||
unsigned int list_start = device_lists[list_idx][device_idx].start_universe;
|
||||
unsigned int dev_end = dev.start_universe + ((dev.start_channel + (3 * dev.num_leds) - 2) / 512);
|
||||
unsigned int list_end = device_lists[list_idx][device_idx].start_universe + ((device_lists[list_idx][device_idx].start_channel + (3 * device_lists[list_idx][device_idx].num_leds) - 2) / 512);
|
||||
|
||||
bool overlap = !(dev_end < list_start || list_end < dev_start);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Check if any universes used by this new device exist in |
|
||||
| the existing device. If so, add the new device to the |
|
||||
| existing list. |
|
||||
\*---------------------------------------------------------*/
|
||||
if(overlap)
|
||||
{
|
||||
device_lists[list_idx].push_back(dev);
|
||||
device_added_to_existing_list = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(device_added_to_existing_list)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If the device did not overlap with existing devices, |
|
||||
| create a new list for it |
|
||||
\*---------------------------------------------------------*/
|
||||
if(!device_added_to_existing_list)
|
||||
{
|
||||
std::vector<E131Device> new_list;
|
||||
|
||||
new_list.push_back(dev);
|
||||
|
||||
device_lists.push_back(new_list);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<E131Device> tmp_device_list;
|
||||
tmp_device_list.push_back(dev);
|
||||
|
||||
RGBController_E131* rgb_controller;
|
||||
rgb_controller = new RGBController_E131(tmp_device_list);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
|
||||
{
|
||||
RGBController_E131* rgb_controller;
|
||||
rgb_controller = new RGBController_E131(device_lists[list_idx]);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectE131Controllers() */
|
||||
|
||||
REGISTER_DETECTOR("E1.31", DetectE131Controllers);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user