Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c1ec2f187 | ||
|
|
7dadc8d9ee | ||
|
|
cd7146d611 | ||
|
|
853833d18a | ||
|
|
c500803d95 |
@@ -1,12 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: CalcProgrammer1
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -4,8 +4,5 @@ ui_*
|
||||
moc_*
|
||||
qrc_*
|
||||
OpenRGB
|
||||
openrgb
|
||||
Makefile
|
||||
OpenRGB-x86_64.AppImage
|
||||
.qmake.stash
|
||||
.vscode
|
||||
|
||||
+29
-142
@@ -20,98 +20,26 @@ stages:
|
||||
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 #
|
||||
# Linux (AppImage) Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Linux 32 AppImage":
|
||||
<<: *ccache_init
|
||||
image: i386/ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- export $(dpkg-architecture)
|
||||
- ./scripts/build-appimage.sh
|
||||
|
||||
artifacts:
|
||||
name: "${CI_PROJECT_NAME}_Linux_32_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- OpenRGB-i386.AppImage
|
||||
- 60-openrgb.rules
|
||||
- README.md
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (AppImage) 64-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Linux 64 AppImage":
|
||||
<<: *ccache_init
|
||||
build_linux:
|
||||
image: ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- export $(dpkg-architecture)
|
||||
- apt update
|
||||
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
|
||||
- ./scripts/build-appimage.sh
|
||||
|
||||
artifacts:
|
||||
name: "${CI_PROJECT_NAME}_Linux_64_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- OpenRGB-x86_64.AppImage
|
||||
- 60-openrgb.rules
|
||||
- README.md
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (.deb) 32-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Linux 32 deb":
|
||||
<<: *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:
|
||||
name: "${CI_PROJECT_NAME}_Linux_32_deb_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- openrgb*.deb
|
||||
exclude:
|
||||
- openrgb-dbgsym*.deb
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux (.deb) 64-bit Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Linux 64 deb":
|
||||
<<: *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:
|
||||
name: "${CI_PROJECT_NAME}_Linux_64_deb_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- openrgb*.deb
|
||||
exclude:
|
||||
- openrgb-dbgsym*.deb
|
||||
expire_in: 30 days
|
||||
expire_in: 1337 years
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Windows (32-bit) Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Windows 32":
|
||||
build_windows_32:
|
||||
extends:
|
||||
- .shared_windows_runners
|
||||
stage: build
|
||||
@@ -133,9 +61,9 @@ before_script:
|
||||
- mkdir _qt
|
||||
- mkdir _qt_download
|
||||
- Push-Location _qt_download
|
||||
- curl.exe -LJ -o qt-base.7z 'https://qt-mirror.dannhauer.de/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://qt-mirror.dannhauer.de/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://qt-mirror.dannhauer.de/official_releases/jom/jom.zip'
|
||||
- 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'
|
||||
@@ -164,23 +92,26 @@ before_script:
|
||||
- ..\_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_ 'Moving results for upload'
|
||||
- mv release ../'OpenRGB Windows 32-bit'
|
||||
- _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:
|
||||
name: "${CI_PROJECT_NAME}_Windows_32_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- 'OpenRGB Windows 32-bit'
|
||||
expire_in: 30 days
|
||||
- _build/*.7z
|
||||
expire_in: 1337 years
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Windows (64-bit) Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"Windows 64":
|
||||
build_windows_64:
|
||||
extends:
|
||||
- .shared_windows_runners
|
||||
stage: build
|
||||
@@ -202,9 +133,9 @@ before_script:
|
||||
- mkdir _qt
|
||||
- mkdir _qt_download
|
||||
- Push-Location _qt_download
|
||||
- curl.exe -LJ -o qt-base.7z 'https://qt-mirror.dannhauer.de/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://qt-mirror.dannhauer.de/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://qt-mirror.dannhauer.de/official_releases/jom/jom.zip'
|
||||
- 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'
|
||||
@@ -233,62 +164,18 @@ before_script:
|
||||
- ..\_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_ 'Moving results for upload'
|
||||
- mv release ../'OpenRGB Windows 64-bit'
|
||||
- _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:
|
||||
name: "${CI_PROJECT_NAME}_Windows_64_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- 'OpenRGB Windows 64-bit'
|
||||
expire_in: 30 days
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# MacOS Build Target #
|
||||
#-----------------------------------------------------------------------#
|
||||
"MacOS ARM64":
|
||||
tags:
|
||||
- macos
|
||||
stage: build
|
||||
script:
|
||||
- eval $(/opt/homebrew/bin/brew shellenv)
|
||||
- qmake OpenRGB.pro
|
||||
- make -j16
|
||||
- macdeployqt OpenRGB.app -codesign=OpenRGB
|
||||
|
||||
artifacts:
|
||||
name: "${CI_PROJECT_NAME}_MacOS_ARM64_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- OpenRGB.app
|
||||
expire_in: 30 days
|
||||
|
||||
rules:
|
||||
- if: '$CI_PROJECT_PATH == "CalcProgrammer1/OpenRGB"'
|
||||
when: on_success
|
||||
- if: '$BUILD_MACOS =~ /.+/'
|
||||
when: on_success
|
||||
|
||||
"MacOS Intel":
|
||||
tags:
|
||||
- macos
|
||||
stage: build
|
||||
script:
|
||||
- eval $(/usr/local/bin/brew shellenv)
|
||||
- arch -x86_64 /usr/local/bin/qmake OpenRGB.pro
|
||||
- arch -x86_64 make -j16
|
||||
- arch -x86_64 macdeployqt OpenRGB.app -codesign=OpenRGB
|
||||
|
||||
artifacts:
|
||||
name: "${CI_PROJECT_NAME}_MacOS_Intel_${CI_COMMIT_SHORT_SHA}"
|
||||
paths:
|
||||
- OpenRGB.app
|
||||
expire_in: 30 days
|
||||
|
||||
rules:
|
||||
- if: '$CI_PROJECT_PATH == "CalcProgrammer1/OpenRGB"'
|
||||
when: on_success
|
||||
- if: '$BUILD_MACOS =~ /.+/'
|
||||
when: on_success
|
||||
- _build/*.7z
|
||||
expire_in: 1337 years
|
||||
|
||||
@@ -1,19 +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 any 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,11 +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,86 +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 like to add
|
||||
-->
|
||||
|
||||
### Name of device:
|
||||
<!--
|
||||
Please put the name of the product, including manufacturer, beneath this line
|
||||
-->
|
||||
|
||||
|
||||
### Link to manufacturer's product page:
|
||||
<!--
|
||||
Please add a link to the manufacturer's product page beneath this line
|
||||
-->
|
||||
|
||||
|
||||
### Please select what type of device/interface the device uses:
|
||||
<!-- Please select from one of the following
|
||||
This determines how the device connects to the PC -->
|
||||
|
||||
~"DeviceType::IDK" <!-- I Don't know -->
|
||||
~"DeviceType::USB" <!-- The device connects to an internal header or external usb port -->
|
||||
~"DeviceType::GPU::AMD" <!-- The device is an AMD GPU -->
|
||||
~"DeviceType::GPU::NVidia" <!-- The device is a NVidia GPU -->
|
||||
~"DeviceType::SMBus" <!-- The device is connected to the SMBus eg. RAM -->
|
||||
~"DeviceType::WMI" <!-- The device is controlled thru Windows Management Instrumentation -->
|
||||
|
||||
<!-- Please delete any lines that are not relevant -->
|
||||
|
||||
### ID information:
|
||||
<!--
|
||||
For PCI (GPU) devices we will need the Vendor ID, Device ID, Sub-Vendor ID and Sub-Device IDs
|
||||
To get the Device ID formation for a GPU on Windows run the following command in Powershell:
|
||||
|
||||
wmic path Win32_VideoController get name,PNPDeviceID
|
||||
|
||||
Linux this can be found using the terminal:
|
||||
|
||||
lspci -d 1002: -nnvm | head -6 | tail -n 4 && lspci -d 10DE: -nnvm | head -6 | tail -n 4
|
||||
-->
|
||||
|
||||
<!--
|
||||
For USB devices we will need the USB VID and PID
|
||||
Windows Powershell:
|
||||
|
||||
gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)} | Sort Manufacturer,Description,DeviceID | Ft -GroupBy Manufacturer Description,Service,DeviceID
|
||||
|
||||
Linux Terminal:
|
||||
lsusb
|
||||
-->
|
||||
|
||||
|
||||
### 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:
|
||||
<!-- If you have code examples from other projects please link them here or alternatively
|
||||
for information on how to capture device packets please refer to the wiki article
|
||||
https://gitlab.com/Dr_No/OpenRGB/-/wikis/OpenRGB-doesn%27t-have-my-device
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- For admin purposes: Please leave this section as is -->
|
||||
/label ~"Issue Type - New Device"
|
||||
/label ~"NewDevice::Step0 - Unconfirmed"
|
||||
|
||||
# Checklist for Step2
|
||||
- [ ] Name of device
|
||||
- [ ] A link to the vendors product page has been included
|
||||
- [ ] The transport bus has been identified and the appropriate label added to the issue.
|
||||
- [ ] The device ID's have been included for [USB](https://gitlab.com/Dr_No/OpenRGB/-/wikis/USB-Vendor-Identification-and-Product-Identification) or PCI
|
||||
- [ ] Screenshots of the OEM Application are included
|
||||
- [ ] There is either, appropriate code examples linked or suitable device captures attached
|
||||
<!-- For admin purposes: Please leave this section as is -->
|
||||
@@ -9,11 +9,6 @@
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="i2c-[0-99]*", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Super I/O Access #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="port", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# User hidraw Access #
|
||||
#---------------------------------------------------------------#
|
||||
@@ -24,20 +19,6 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", TAG+="uaccess"
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0051", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Aorus Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1044", ATTR{idProduct}=="7a42", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASRock Devices #
|
||||
# #
|
||||
# ASRock Polychrome USB #
|
||||
# ASRock Deskmini Addressable LED Strip #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="26CE", ATTR{idProduct}=="01A2", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="26CE", ATTR{idProduct}=="01A6", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS Aura Core Devices #
|
||||
#---------------------------------------------------------------#
|
||||
@@ -54,17 +35,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1889", TAG+="uacces
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18a3", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18f3", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS TUF Laptops (faustus) #
|
||||
#---------------------------------------------------------------#
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_blue"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_flags"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_green"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_mode"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_red"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_set"
|
||||
ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /sys/bus/platform/devices/%k/kbbl/kbbl_speed"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Cooler Master Peripheral Devices #
|
||||
# #
|
||||
@@ -73,17 +43,6 @@ ACTION=="add", SUBSYSTEM=="platform", KERNEL=="faustus", RUN+="/bin/chmod a+w /s
|
||||
#---------------------------------------------------------------#
|
||||
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 #
|
||||
# #
|
||||
@@ -93,7 +52,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c12", TAG+="uacces
|
||||
# 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"
|
||||
@@ -101,7 +59,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c10", TAG+="uacces
|
||||
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 #
|
||||
@@ -161,69 +118,20 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0a34", TAG+="uacces
|
||||
# #
|
||||
# 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"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Lian Li Uni Hub #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0cf2", ATTR{idProduct}=="7750", 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"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Metadot Das Keyboard 4Q + 5Q #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="24f0", ATTR{idProduct}=="2037", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="24f0", ATTR{idProduct}=="202b", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# MSI Mysticlight #
|
||||
@@ -275,11 +183,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="905D", TAG+="uacces
|
||||
#---------------------------------------------------------------#
|
||||
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 #
|
||||
# #
|
||||
@@ -314,7 +217,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="652f", TAG+="uacces
|
||||
|
||||
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 #
|
||||
@@ -322,16 +224,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc4d", TAG+="uacces
|
||||
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 #
|
||||
# #
|
||||
@@ -368,11 +260,3 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1229", TAG+="uacces
|
||||
# Thermaltake Poseidon Z RGB Keyboard #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="3006", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Thermaltake Riing Controllers #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="1FA[5-9]", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="1FA[A-F]", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="1FB[0-5]", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="226[0-3]", TAG+="uaccess"
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle, const char* path)
|
||||
AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
dev = dev_handle;
|
||||
|
||||
strcpy(device_name, "AMD Wraith Prism");
|
||||
|
||||
@@ -36,12 +35,7 @@ AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle, const
|
||||
|
||||
AMDWraithPrismController::~AMDWraithPrismController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string AMDWraithPrismController::GetLocationString()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
char* AMDWraithPrismController::GetDeviceName()
|
||||
@@ -49,17 +43,6 @@ 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 = "";
|
||||
|
||||
@@ -109,15 +109,13 @@ enum
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
AMDWraithPrismController(hid_device* dev_handle, const char* path);
|
||||
AMDWraithPrismController(hid_device* 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);
|
||||
|
||||
@@ -133,7 +131,6 @@ public:
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
|
||||
unsigned char current_fan_mode;
|
||||
unsigned char current_fan_speed;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "Detector.h"
|
||||
#include "AMDWraithPrismController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AMDWraithPrism.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AMD_WRAITH_PRISM_VID 0x2516
|
||||
#define AMD_WRAITH_PRISM_PID 0x0051
|
||||
|
||||
@@ -15,16 +14,38 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAMDWraithPrismControllers(hid_device_info* info, const std::string&)
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID);
|
||||
|
||||
//Look for AMD Wraith Prism
|
||||
while(info)
|
||||
{
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path);
|
||||
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
if((info->vendor_id == AMD_WRAITH_PRISM_VID)
|
||||
&&(info->product_id == AMD_WRAITH_PRISM_PID)
|
||||
#if USE_HID_USAGE
|
||||
&&(info->interface_number == 1)
|
||||
&&(info->usage_page == 0xFF00))
|
||||
#else
|
||||
&&(info->interface_number == 1))
|
||||
#endif
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
|
||||
|
||||
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
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,642 +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();
|
||||
}
|
||||
|
||||
RGBController_Polychrome::~RGBController_Polychrome()
|
||||
{
|
||||
delete polychrome;
|
||||
}
|
||||
|
||||
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,355 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| ASRockPolychromeUSBController.cpp |
|
||||
| |
|
||||
| Driver for ASRock Polychrome USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Ed Kambulow (dredvard) 12/20/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "ASRockPolychromeUSBController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include "dependencies/dmiinfo.h"
|
||||
|
||||
#define POLYCHROME_USB_READ_ZONE_CONFIG 0x11
|
||||
#define POLYCHROME_USB_READ_HEADER 0x14
|
||||
#define POLYCHROME_USB_WRITE_HEADER 0x15
|
||||
#define POLYCHROME_USB_SET_ZONE 0x10
|
||||
#define POLYCHROME_USB_INIT 0xA4
|
||||
#define POLYCHROME_USB_COMMIT 0x12
|
||||
|
||||
PolychromeUSBController::PolychromeUSBController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
DMIInfo dmi;
|
||||
|
||||
dev = dev_handle;
|
||||
device_name = "ASRock " + dmi.getMainboard();
|
||||
location = path;
|
||||
|
||||
SetDeviceInfo();
|
||||
}
|
||||
|
||||
PolychromeUSBController::~PolychromeUSBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int PolychromeUSBController::GetChannelCount()
|
||||
{
|
||||
return(device_info.size());
|
||||
}
|
||||
|
||||
std::string PolychromeUSBController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string PolychromeUSBController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string PolychromeUSBController::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 PolychromeUSBController::SetDeviceInfo()
|
||||
{
|
||||
PolychromeDeviceInfo newdev_info;
|
||||
ReadConfigTables();
|
||||
|
||||
for (unsigned int zonecnt = 0; zonecnt < POLYCHROME_USB_ZONE_MAX_NUM; zonecnt++)
|
||||
{
|
||||
if(configtable[zonecnt] == 0x1E)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
newdev_info.num_leds = configtable[zonecnt];
|
||||
|
||||
switch (zonecnt)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Type: Addressable, configurable |
|
||||
\*-----------------------------------------*/
|
||||
case POLYCHROME_USB_ZONE_ARGB1:
|
||||
case POLYCHROME_USB_ZONE_ARGB2:
|
||||
newdev_info.device_type = PolychromeDeviceType::ADDRESSABLE;
|
||||
break;
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Type: Addressable, not configurable |
|
||||
\*-----------------------------------------*/
|
||||
case POLYCHROME_USB_ZONE_PCH:
|
||||
case POLYCHROME_USB_ZONE_IOCOVER:
|
||||
case POLYCHROME_USB_ZONE_PCB:
|
||||
case POLYCHROME_USB_ZONE_AUDIO:
|
||||
newdev_info.device_type = PolychromeDeviceType::FIXED;
|
||||
break;
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Type: Fixed |
|
||||
\*-----------------------------------------*/
|
||||
case POLYCHROME_USB_ZONE_RGB1:
|
||||
case POLYCHROME_USB_ZONE_RGB2:
|
||||
default:
|
||||
newdev_info.device_type = PolychromeDeviceType::FIXED;
|
||||
break;
|
||||
}
|
||||
|
||||
device_info.push_back(newdev_info);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeUSBController::WriteZone
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
RGBColor rgb,
|
||||
bool allzone = false
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet with leading 00 |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_SET_ZONE;
|
||||
usb_buf[0x03] = zone;
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x05] = RGBGetRValue(rgb);
|
||||
usb_buf[0x06] = RGBGetGValue(rgb);
|
||||
usb_buf[0x07] = RGBGetBValue(rgb);
|
||||
usb_buf[0x08] = speed;
|
||||
usb_buf[0x09] = 0xFF;
|
||||
usb_buf[0x10] = allzone;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
};
|
||||
|
||||
void PolychromeUSBController::WriteRGSwap
|
||||
(
|
||||
bool ahdr1,
|
||||
bool ahdr0,
|
||||
bool hdr1,
|
||||
bool hdr0
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet with leading 00 |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_WRITE_HEADER;
|
||||
|
||||
usb_buf[0x04] = POLYCHROME_USB_RGSWAP_CFG;
|
||||
usb_buf[0x05] = ((ahdr1 << 3) & (ahdr0 << 2) & (hdr1 << 1) & hdr0) & 0x40;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void PolychromeUSBController::WriteHeader
|
||||
(
|
||||
unsigned char cfg,
|
||||
unsigned char configstring[]
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet with leading 00 |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_WRITE_HEADER;
|
||||
usb_buf[0x03] = cfg;
|
||||
memcpy(&usb_buf[4], configstring, sizeof(configstring));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
PolychromeZoneInfo PolychromeUSBController::GetZoneConfig(unsigned char zone)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
PolychromeZoneInfo zoneinfo;
|
||||
unsigned char all;
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_READ_ZONE_CONFIG;
|
||||
usb_buf[0x03] = zone;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read response |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
r = usb_buf[0x05];
|
||||
g = usb_buf[0x06];
|
||||
b = usb_buf[0x07];
|
||||
|
||||
zoneinfo.mode = usb_buf[0x04];
|
||||
zoneinfo.color = ToRGBColor(r,g,b);
|
||||
zoneinfo.speed = usb_buf[0x08];
|
||||
zoneinfo.zone = usb_buf[0x03];
|
||||
all = usb_buf[0x10];
|
||||
|
||||
return(zoneinfo);
|
||||
}
|
||||
|
||||
void PolychromeUSBController::ReadConfigTables()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
unsigned char maxzoneleds[8];
|
||||
unsigned char rgbswap;
|
||||
unsigned char header1;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up max led config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_READ_HEADER;
|
||||
usb_buf[0x03] = POLYCHROME_USB_LEDCOUNT_CFG;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read response |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Reads in format: RGB1, RGB2, ARGB1, ARGB2, PCH, IO, |
|
||||
| PCB, AUDIO |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&maxzoneleds,&usb_buf[0x04],8);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up RGB Swap table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_READ_HEADER;
|
||||
usb_buf[0x03] = POLYCHROME_USB_RGSWAP_CFG;
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Reads bitwise in format: AUDIO, PCB, IO, PCH, ARGB2, |
|
||||
| ARGB1, RGB2, RGB1 if available |
|
||||
\*-----------------------------------------------------*/
|
||||
rgbswap=usb_buf[4];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Header1 config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_READ_HEADER;
|
||||
usb_buf[0x03] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, 64);
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
hid_read(dev, usb_buf, 64);
|
||||
header1=usb_buf[4];
|
||||
|
||||
memcpy(configtable,&maxzoneleds,8);
|
||||
configtable[8]=rgbswap;
|
||||
configtable[9]=header1;
|
||||
return;
|
||||
}
|
||||
|
||||
void PolychromeUSBController::Commit()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Saves all Writes in Device - Will keep after powerup |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet with leading 00 |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x01] = POLYCHROME_USB_COMMIT;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
};
|
||||
|
||||
const std::vector<PolychromeDeviceInfo>& PolychromeUSBController::GetPolychromeDevices() const
|
||||
{
|
||||
return(device_info);
|
||||
};
|
||||
@@ -1,150 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| ASRockPolychromeUSBController.h |
|
||||
| |
|
||||
| Driver for ASRock Polychrome USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Ed Kambulow (dredvard) 12/20/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
#include <string>
|
||||
|
||||
#pragma once
|
||||
|
||||
/*----------------------------------------------------------------------------------------------*\
|
||||
| Definitions for Polychrome USB |
|
||||
\*----------------------------------------------------------------------------------------------*/
|
||||
#define POLYCHROME_USB_NUM_MODES 15 /* Number of Polychrome USB modes */
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_USB_MODE_OFF = 0x00, /* OFF mode */
|
||||
POLYCHROME_USB_MODE_STATIC = 0x01, /* Static color mode */
|
||||
POLYCHROME_USB_MODE_BREATHING = 0x02, /* Breathing effect mode */
|
||||
POLYCHROME_USB_MODE_STROBE = 0x03, /* Strobe effect mode */
|
||||
POLYCHROME_USB_MODE_SPECTRUM_CYCLE = 0x04, /* Spectrum Cycle effect mode */
|
||||
POLYCHROME_USB_MODE_RANDOM = 0x05, /* Random effect mode */
|
||||
POLYCHROME_USB_MODE_MUSIC = 0x06, /* Random effect mode */
|
||||
POLYCHROME_USB_MODE_WAVE = 0x07, /* Wave effect mode */
|
||||
POLYCHROME_USB_MODE_SPRING = 0x08, /* Spring effect mode */
|
||||
POLYCHROME_USB_MODE_STACK = 0x09, /* Stack effect mode */
|
||||
POLYCHROME_USB_MODE_CRAM = 0x0A, /* Cram effect mode */
|
||||
POLYCHROME_USB_MODE_SCAN = 0x0B, /* Scan effect mode */
|
||||
POLYCHROME_USB_MODE_NEON = 0x0C, /* Neon effect mode */
|
||||
POLYCHROME_USB_MODE_WATER = 0x0D, /* Water effect mode */
|
||||
POLYCHROME_USB_MODE_RAINBOW = 0x0E, /* Rainbow effect mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_USB_SPEED_MIN = 0xFF, /* Slowest speed */
|
||||
POLYCHROME_USB_SPEED_DEFAULT = 0xE0, /* Default speed */
|
||||
POLYCHROME_USB_SPEED_MAX = 0x00, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_USB_ZONE_MAX_NUM = 0x08, /* Total Max number of zones */
|
||||
POLYCHROME_USB_ZONE_ADDRESSABLE_MAX = 0x64, /* Maxinum number of ARGB LEDs */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_USB_LEDCOUNT_CFG = 0x02, // Config for LED Count
|
||||
POLYCHROME_USB_RGSWAP_CFG = 0x03, // Config for RGSWAP
|
||||
POLYCHROME_USB_ZONE_UNAVAILABLE = 0x1E, // Value from LEDCOUNT CFG if zone not present
|
||||
};
|
||||
|
||||
static const char* polychrome_USB_zone_names[] =
|
||||
{
|
||||
"RGB LED 1 Header",
|
||||
"RGB LED 2 Header",
|
||||
"Addressable Header 1",
|
||||
"Addressable Header 2",
|
||||
"PCH",
|
||||
"IO Cover",
|
||||
"PCB",
|
||||
"Audio",
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_USB_ZONE_RGB1 = 0x00, // RGB Header 1
|
||||
POLYCHROME_USB_ZONE_RGB2 = 0X01, // RGB Header 2
|
||||
POLYCHROME_USB_ZONE_ARGB1 = 0X02, // ARGB Header 1
|
||||
POLYCHROME_USB_ZONE_ARGB2 = 0X03, // ARGB Header 2
|
||||
POLYCHROME_USB_ZONE_PCH = 0X04, // PCH
|
||||
POLYCHROME_USB_ZONE_IOCOVER = 0X05, // IOCOVER
|
||||
POLYCHROME_USB_ZONE_PCB = 0X06, // PCB - Could be mixed swapped with 0x07
|
||||
POLYCHROME_USB_ZONE_AUDIO = 0X07 // AUDIO
|
||||
};
|
||||
|
||||
enum class PolychromeDeviceType
|
||||
{
|
||||
FIXED,
|
||||
ADDRESSABLE,
|
||||
};
|
||||
|
||||
struct PolychromeZoneInfo
|
||||
{
|
||||
unsigned char mode;
|
||||
unsigned char zone;
|
||||
unsigned char speed;
|
||||
RGBColor color;
|
||||
};
|
||||
|
||||
struct PolychromeDeviceInfo
|
||||
{
|
||||
unsigned char effect_channel;
|
||||
unsigned char num_leds;
|
||||
PolychromeDeviceType device_type;
|
||||
};
|
||||
|
||||
class PolychromeUSBController
|
||||
{
|
||||
public:
|
||||
unsigned char zone_led_count[8];
|
||||
|
||||
PolychromeUSBController(hid_device* dev_handle, const char* path);
|
||||
~PolychromeUSBController();
|
||||
|
||||
unsigned int GetChannelCount();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
const std::vector<PolychromeDeviceInfo>& GetPolychromeDevices() const;
|
||||
std::string GetSerialString();
|
||||
PolychromeZoneInfo GetZoneConfig (unsigned char zone);
|
||||
|
||||
void WriteZone
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
RGBColor rgb,
|
||||
bool allzone
|
||||
);
|
||||
|
||||
void WriteHeader
|
||||
(
|
||||
unsigned char cfg,
|
||||
unsigned char configstring []
|
||||
);
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
std::vector<PolychromeDeviceInfo> device_info;
|
||||
std::string location;
|
||||
|
||||
void WriteRGSwap(bool ahdr1, bool ahdr0, bool hdr1, bool hdr0);
|
||||
|
||||
private:
|
||||
unsigned int led_count;
|
||||
std::string device_name;
|
||||
unsigned char configtable[12];
|
||||
|
||||
void SetDeviceInfo();
|
||||
void ReadConfigTables();
|
||||
void Commit();
|
||||
};
|
||||
@@ -1,36 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "ASRockPolychromeUSBController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ASRockPolychromeUSB.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| ASRock vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ASROCK_VID 0x26CE
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| ASRock product ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ASROCK_MOTHERBOARD_1_PID 0x01A2
|
||||
#define ASROCK_DESKMINI_ADDRESSABLE_LED_STRIP_PID 0x01A6
|
||||
|
||||
void DetectPolychromeUSBControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
PolychromeUSBController* controller = new PolychromeUSBController(dev, info->path);
|
||||
RGBController_PolychromeUSB* rgb_controller = new RGBController_PolychromeUSB(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR("ASRock Polychrome USB", DetectPolychromeUSBControllers, ASROCK_VID, ASROCK_MOTHERBOARD_1_PID);
|
||||
REGISTER_HID_DETECTOR("ASRock Deskmini Addressable LED Strip", DetectPolychromeUSBControllers, ASROCK_VID, ASROCK_DESKMINI_ADDRESSABLE_LED_STRIP_PID);
|
||||
@@ -1,350 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_ASRockPolychromeUSB.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock Polychrome USB Driver |
|
||||
| |
|
||||
| Ed Kambulow (Dredvard) 12/26/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_ASRockPolychromeUSB.h"
|
||||
#include <string.h>
|
||||
|
||||
#define ASROCK_USB_MAX_ZONES 8
|
||||
#define ASROCK_ADDRESSABLE_MAX_LEDS 100
|
||||
|
||||
RGBController_PolychromeUSB::RGBController_PolychromeUSB(PolychromeUSBController* polychrome_ptr)
|
||||
{
|
||||
polychrome = polychrome_ptr;
|
||||
|
||||
name = polychrome->GetDeviceName();
|
||||
description = "ASRock Polychrome USB Device";
|
||||
vendor = "ASRock";
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
location = polychrome->GetDeviceLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = POLYCHROME_USB_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = POLYCHROME_USB_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_USB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Breathing.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Breathing.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Strobe;
|
||||
Strobe.name = "Strobe";
|
||||
Strobe.value = POLYCHROME_USB_MODE_STROBE;
|
||||
Strobe.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Strobe.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Strobe.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Strobe.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Strobe.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Strobe);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = POLYCHROME_USB_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
SpectrumCycle.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
SpectrumCycle.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Random;
|
||||
Random.name = "Random";
|
||||
Random.value = POLYCHROME_USB_MODE_RANDOM;
|
||||
Random.flags = MODE_FLAG_HAS_SPEED;
|
||||
Random.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Random.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Random.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Random.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Random);
|
||||
|
||||
mode Music;
|
||||
Random.name = "Music";
|
||||
Random.value = POLYCHROME_USB_MODE_RANDOM;
|
||||
Random.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Random.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Random);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = POLYCHROME_USB_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED;
|
||||
Wave.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Wave.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Wave.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Spring;
|
||||
Spring.name = "Spring";
|
||||
Spring.value = POLYCHROME_USB_MODE_SPRING;
|
||||
Spring.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spring.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Spring.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Spring.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Spring.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Spring);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stack";
|
||||
Stack.value = POLYCHROME_USB_MODE_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_SPEED;
|
||||
Stack.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Stack.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Stack.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Stack.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode Cram;
|
||||
Cram.name = "Cram";
|
||||
Cram.value = POLYCHROME_USB_MODE_CRAM;
|
||||
Cram.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cram.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Cram.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Cram.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Cram.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Cram);
|
||||
|
||||
mode Scan;
|
||||
Scan.name = "Scan";
|
||||
Scan.value = POLYCHROME_USB_MODE_SCAN;
|
||||
Scan.flags = MODE_FLAG_HAS_SPEED;
|
||||
Scan.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Scan.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Scan.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Scan.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Scan);
|
||||
|
||||
mode Neon;
|
||||
Neon.name = "Neon";
|
||||
Neon.value = POLYCHROME_USB_MODE_NEON;
|
||||
Neon.flags = 0;
|
||||
Neon.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Neon);
|
||||
|
||||
mode Water;
|
||||
Water.name = "Water";
|
||||
Water.value = POLYCHROME_USB_MODE_WATER;
|
||||
Water.flags = MODE_FLAG_HAS_SPEED;
|
||||
Water.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Water.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Water.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Water.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Water);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = POLYCHROME_USB_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||
Rainbow.speed_min = POLYCHROME_USB_SPEED_MIN;
|
||||
Rainbow.speed_max = POLYCHROME_USB_SPEED_MAX;
|
||||
Rainbow.speed = POLYCHROME_USB_SPEED_DEFAULT;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
SetupZones();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Initialize active mode |
|
||||
\*-------------------------------------------------*/
|
||||
active_mode = GetDeviceMode(1);
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::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(polychrome->GetChannelCount());
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
int addressableCounter = 1;
|
||||
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
PolychromeDeviceInfo device_info = polychrome->GetPolychromeDevices()[channel_idx];
|
||||
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
if(device_info.device_type== PolychromeDeviceType::ADDRESSABLE)
|
||||
{
|
||||
zones[channel_idx].name = polychrome_USB_zone_names[channel_idx];
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = ASROCK_ADDRESSABLE_MAX_LEDS;
|
||||
zones[channel_idx].leds_count = device_info.num_leds;
|
||||
}
|
||||
else if(device_info.device_type==PolychromeDeviceType::FIXED)
|
||||
{
|
||||
zones[channel_idx].name = polychrome_USB_zone_names[channel_idx];
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize colors for each LED |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
unsigned char led = (unsigned char)leds[led_idx].value;
|
||||
|
||||
colors[led_idx] = polychrome->GetZoneConfig(led).color; // TODO Get addressable instead of zone idx
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize zone info to track zone, speed, mode |
|
||||
| B550 Boards have modes, speed for each zone |
|
||||
\*---------------------------------------------------------*/
|
||||
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
PolychromeZoneInfo zoneinfo;
|
||||
zoneinfo = polychrome->GetZoneConfig(channel_idx);
|
||||
zones_info.push_back(zoneinfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
unsigned char zonecfg[ASROCK_USB_MAX_ZONES];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not currently support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
zones[zone].leds_count = (unsigned char) new_size;
|
||||
|
||||
memset(zonecfg, POLYCHROME_USB_ZONE_UNAVAILABLE, ASROCK_USB_MAX_ZONES);
|
||||
|
||||
for(unsigned int i = 0; i < zones.size(); i++)
|
||||
{
|
||||
zonecfg[i]=zones[i].leds_count;
|
||||
}
|
||||
|
||||
unsigned char zonecmd = POLYCHROME_USB_LEDCOUNT_CFG;
|
||||
// WriteHeader(zonecmd, zonecfg);
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
unsigned char set_mode = zones_info[zone_idx].mode;
|
||||
|
||||
if (set_mode>modes.size())
|
||||
{
|
||||
set_mode = active_mode;
|
||||
}
|
||||
|
||||
polychrome->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned char set_mode=zones_info[zone].mode;
|
||||
|
||||
if(set_mode > modes.size())
|
||||
{
|
||||
set_mode = active_mode;
|
||||
}
|
||||
|
||||
polychrome->WriteZone(zone, set_mode, zones_info[zone].speed, zones[zone].colors[0], false);
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds[led].value;
|
||||
unsigned char set_mode = zones_info[channel].mode;
|
||||
|
||||
if(set_mode > modes.size())
|
||||
{
|
||||
set_mode = active_mode;
|
||||
}
|
||||
|
||||
polychrome->WriteZone(channel, set_mode, zones_info[channel].speed, zones[channel].colors[0], false);
|
||||
}
|
||||
|
||||
unsigned char RGBController_PolychromeUSB::GetDeviceMode(unsigned char zone)
|
||||
{
|
||||
int dev_mode;
|
||||
int color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dev_mode = polychrome->GetZoneConfig(zone).mode;
|
||||
active_mode = dev_mode;
|
||||
|
||||
return(active_mode);
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::SetCustomMode()
|
||||
{
|
||||
active_mode = POLYCHROME_USB_MODE_STATIC;
|
||||
}
|
||||
|
||||
void RGBController_PolychromeUSB::DeviceUpdateMode()
|
||||
{
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
if(zones[zone_idx].leds_count > 0)
|
||||
{
|
||||
unsigned char set_mode =(unsigned char) modes[active_mode].value;
|
||||
zones_info[zone_idx].mode =(unsigned char) modes[active_mode].value;
|
||||
zones_info[zone_idx].speed =(unsigned char) modes[active_mode].speed;
|
||||
|
||||
if(set_mode > modes.size())
|
||||
{
|
||||
set_mode = active_mode;
|
||||
}
|
||||
|
||||
polychrome->WriteZone(zone_idx, set_mode, zones_info[zone_idx].speed, zones[zone_idx].colors[0], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_ASRockPolychromeUSB.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock Polychrome USB Driver |
|
||||
| |
|
||||
| Ed Kambulow (Dredvard) 12/26/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "ASRockPolychromeUSBController.h"
|
||||
|
||||
class RGBController_PolychromeUSB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_PolychromeUSB(PolychromeUSBController* polychrome_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:
|
||||
bool initializedMode;
|
||||
PolychromeUSBController* polychrome;
|
||||
std::vector<PolychromeZoneInfo> zones_info;
|
||||
|
||||
unsigned char GetDeviceMode(unsigned char zone);
|
||||
};
|
||||
@@ -1,405 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraCoreController.cpp |
|
||||
| |
|
||||
| Driver for ASUS ROG Aura Core RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraCoreController.h"
|
||||
#include <cstring>
|
||||
|
||||
#define AURA_CORE_MAX_MESSAGE_SIZE 64
|
||||
|
||||
AuraCoreController::AuraCoreController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
aura_device.aura_type = AURA_CORE_DEVICE_UNKNOWN;
|
||||
aura_device.buff_size = 0;
|
||||
aura_device.report_id = 0x5D;
|
||||
aura_device.num_leds = 4;
|
||||
aura_device.supports_direct = false;
|
||||
|
||||
IdentifyDevice();
|
||||
Handshake();
|
||||
}
|
||||
|
||||
AuraCoreController::~AuraCoreController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
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[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| 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, aura_device.buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char dir,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
|
||||
{
|
||||
if(aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
|
||||
{
|
||||
zone += 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
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;
|
||||
usb_buf[0x08] = dir;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::SendSet()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_SET;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
if(aura_device.aura_type != AURA_CORE_DEVICE_UNKNOWN)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::InitDirectMode()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
unsigned char msg_num = 0;
|
||||
int led_count = aura_device.num_leds;
|
||||
|
||||
if(aura_device.supports_direct)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_DIRECT;
|
||||
usb_buf[0x02] = 0xD0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
|
||||
while(led_count > 0)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up second message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x03] = 0x01;
|
||||
usb_buf[0x04] = 0x02;
|
||||
usb_buf[0x05] = 0x00;
|
||||
usb_buf[0x06] = msg_num++;
|
||||
usb_buf[0x07] = (led_count > aura_device.max_leds_per_message) ? aura_device.max_leds_per_message : led_count;
|
||||
usb_buf[0x08] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet 2 |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
|
||||
led_count -= aura_device.max_leds_per_message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::UpdateDirect(std::vector<AuraColor>& color_set)
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
unsigned char msg_num = 0;
|
||||
unsigned char color_index = 0;
|
||||
unsigned char set_count = 0;
|
||||
int led_count = aura_device.num_leds;
|
||||
|
||||
if(aura_device.supports_direct)
|
||||
{
|
||||
while(led_count > 0)
|
||||
{
|
||||
unsigned char msg_index = 0x09;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_DIRECT;
|
||||
usb_buf[0x02] = 0xD0;
|
||||
usb_buf[0x03] = 0x01;
|
||||
usb_buf[0x04] = 0x02;
|
||||
usb_buf[0x05] = 0x00;
|
||||
usb_buf[0x06] = msg_num++;
|
||||
usb_buf[0x07] = (led_count > aura_device.max_leds_per_message) ? aura_device.max_leds_per_message : led_count;
|
||||
usb_buf[0x08] = 0x00;
|
||||
|
||||
set_count = 0;
|
||||
|
||||
while( (msg_index < sizeof(usb_buf) ) &&
|
||||
(led_count > 0 ) &&
|
||||
(set_count < aura_device.max_leds_per_message) )
|
||||
{
|
||||
if(color_index < color_set.size())
|
||||
{
|
||||
usb_buf[msg_index++] = color_set[color_index].red;
|
||||
usb_buf[msg_index++] = color_set[color_index].green;
|
||||
usb_buf[msg_index++] = color_set[color_index].blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_buf[msg_index++] = 0;
|
||||
usb_buf[msg_index++] = 0;
|
||||
usb_buf[msg_index++] = 0;
|
||||
}
|
||||
|
||||
led_count--;
|
||||
color_index++;
|
||||
set_count++;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::IdentifyDevice()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
int num_bytes = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| First, attempt to read the report from the Keyboard |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
|
||||
num_bytes = hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Currently, there is no need to attempt to read the |
|
||||
| returned data. If the device responded,to the report,|
|
||||
| we're good. |
|
||||
\*-----------------------------------------------------*/
|
||||
if(num_bytes > 0)
|
||||
{
|
||||
aura_device.aura_type = AURA_CORE_DEVICE_KEYBOARD;
|
||||
aura_device.buff_size = 17;
|
||||
aura_device.report_id = 0x5D;
|
||||
aura_device.num_leds = 4;
|
||||
aura_device.supports_direct = false;
|
||||
}
|
||||
else if(num_bytes == -1)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| First, attempt to read the report from the |
|
||||
| Keyboard |
|
||||
\*-------------------------------------------------*/
|
||||
usb_buf[0] = 0x5E;
|
||||
num_bytes = hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
|
||||
if(num_bytes > 0)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Currently, there is no need to attempt to |
|
||||
| read the returned data. If the device |
|
||||
| responded,to the report, we're good. |
|
||||
\*---------------------------------------------*/
|
||||
aura_device.aura_type = AURA_CORE_DEVICE_GA15DH;
|
||||
aura_device.buff_size = 64;
|
||||
aura_device.report_id = 0x5E;
|
||||
aura_device.num_leds = 20;
|
||||
aura_device.max_leds_per_message = 16;
|
||||
aura_device.supports_direct = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::Handshake()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
|
||||
if(aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
|
||||
{
|
||||
usb_buf[0] = 0x5E;
|
||||
SendIdString();
|
||||
hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
SendQuery();
|
||||
hid_get_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
}
|
||||
|
||||
void AuraCoreController::SendIdString()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
const char id[] = "ASUS Tech.Inc.";
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in string data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x01], id, sizeof(id));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendQuery()
|
||||
{
|
||||
unsigned char usb_buf[AURA_CORE_MAX_MESSAGE_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = aura_device.report_id;
|
||||
usb_buf[0x01] = 0x05;
|
||||
usb_buf[0x02] = 0x20;
|
||||
usb_buf[0x03] = 0x31;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = 0x10;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, aura_device.buff_size);
|
||||
}
|
||||
@@ -1,34 +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
|
||||
if(rgb_controller->type != DEVICE_TYPE_UNKNOWN)
|
||||
{
|
||||
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,319 +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 Device";
|
||||
vendor = "ASUS";
|
||||
location = aura->GetDeviceLocation();
|
||||
serial = aura->GetSerialString();
|
||||
description = "ASUS Aura Core Device";
|
||||
type = DEVICE_TYPE_UNKNOWN;
|
||||
|
||||
if(aura->aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
|
||||
{
|
||||
SetupKeyboard();
|
||||
}
|
||||
else if(aura->aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
|
||||
{
|
||||
SetupGA15DH();
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupKeyboard()
|
||||
{
|
||||
name = "ASUS Aura Keyboard";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "ASUS Aura Core Device";
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupGA15DH()
|
||||
{
|
||||
name = "ASUS Aura GA15DH";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "ASUS Aura Core Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_CORE_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_CORE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.speed_min = AURA_CORE_SPEED_SLOW;
|
||||
Breathing.speed_max = AURA_CORE_SPEED_FAST;
|
||||
Breathing.speed = AURA_CORE_SPEED_NORMAL;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(2);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AURA_CORE_MODE_SPECTRUM_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = AURA_CORE_SPEED_SLOW;
|
||||
ColorCycle.speed_max = AURA_CORE_SPEED_FAST;
|
||||
ColorCycle.speed = AURA_CORE_SPEED_NORMAL;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = AURA_CORE_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Rainbow.speed_min = AURA_CORE_SPEED_SLOW;
|
||||
Rainbow.speed_max = AURA_CORE_SPEED_FAST;
|
||||
Rainbow.speed = AURA_CORE_SPEED_NORMAL;
|
||||
Rainbow.direction = MODE_DIRECTION_RIGHT;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Strobe;
|
||||
Strobe.name = "Strobe";
|
||||
Strobe.value = AURA_CORE_MODE_STROBE;
|
||||
Strobe.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Strobe.colors_min = 1;
|
||||
Strobe.colors_max = 1;
|
||||
Strobe.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Strobe.colors.resize(1);
|
||||
modes.push_back(Strobe);
|
||||
|
||||
mode Comet;
|
||||
Comet.name = "Comet";
|
||||
Comet.value = AURA_CORE_MODE_COMET;
|
||||
Comet.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Comet.colors_min = 1;
|
||||
Comet.colors_max = 1;
|
||||
Comet.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Comet.colors.resize(1);
|
||||
modes.push_back(Comet);
|
||||
|
||||
mode Flash;
|
||||
Flash.name = "Flash & Dash";
|
||||
Flash.value = AURA_CORE_MODE_FLASHNDASH;
|
||||
Flash.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flash.colors_min = 1;
|
||||
Flash.colors_max = 1;
|
||||
Flash.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flash.colors.resize(1);
|
||||
modes.push_back(Flash);
|
||||
|
||||
mode Irradiation;
|
||||
Irradiation.name = "Irradiation";
|
||||
Irradiation.value = AURA_CORE_MODE_IRRADIATION;
|
||||
Irradiation.flags = 0;
|
||||
Irradiation.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Irradiation);
|
||||
|
||||
mode Direct;
|
||||
Static.name = "Direct";
|
||||
Static.value = AURA_CORE_MODE_DIRECT;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
}
|
||||
|
||||
RGBController_AuraCore::~RGBController_AuraCore()
|
||||
{
|
||||
delete aura;
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupZones()
|
||||
{
|
||||
zone auraZone;
|
||||
|
||||
if(aura->aura_device.aura_type == AURA_CORE_DEVICE_KEYBOARD)
|
||||
{
|
||||
auraZone.name = "Keyboard";
|
||||
auraZone.type = ZONE_TYPE_SINGLE;
|
||||
auraZone.leds_min = 4;
|
||||
auraZone.leds_max = 4;
|
||||
auraZone.leds_count = 4;
|
||||
auraZone.matrix_map = NULL;
|
||||
}
|
||||
else if(aura->aura_device.aura_type == AURA_CORE_DEVICE_GA15DH)
|
||||
{
|
||||
auraZone.name = "GA15DH";
|
||||
auraZone.type = ZONE_TYPE_LINEAR;
|
||||
auraZone.leds_min = 20;
|
||||
auraZone.leds_max = 20;
|
||||
auraZone.leds_count = 20;
|
||||
auraZone.matrix_map = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
auraZone.leds_count = 0;
|
||||
}
|
||||
|
||||
zones.push_back(auraZone);
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < auraZone.leds_count; led_idx++)
|
||||
{
|
||||
led KeyLED;
|
||||
KeyLED.name = auraZone.name + " ";
|
||||
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*/)
|
||||
{
|
||||
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
|
||||
{
|
||||
std::vector<AuraColor> aura_colors;
|
||||
std::vector<RGBColor>& color_set = colors;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
color_set = modes[active_mode].colors;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
AuraColor new_color;
|
||||
|
||||
new_color.red = RGBGetRValue(color_set[led_idx]);
|
||||
new_color.green = RGBGetGValue(color_set[led_idx]);
|
||||
new_color.blue = RGBGetBValue(color_set[led_idx]);
|
||||
|
||||
aura_colors.push_back(new_color);
|
||||
}
|
||||
|
||||
aura->UpdateDirect(aura_colors);
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
UpdateSingleLED(led_idx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateSingleLED(0);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char speed = 0xFF;
|
||||
unsigned char red = 0;
|
||||
unsigned char green = 0;
|
||||
unsigned char blue = 0;
|
||||
unsigned char dir = 0;
|
||||
mode& curr_mode = modes[active_mode];
|
||||
|
||||
if(curr_mode.color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
red = RGBGetRValue(colors[led]);
|
||||
green = RGBGetGValue(colors[led]);
|
||||
blue = RGBGetBValue(colors[led]);
|
||||
}
|
||||
else if(curr_mode.color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(curr_mode.colors[led]);
|
||||
green = RGBGetGValue(curr_mode.colors[led]);
|
||||
blue = RGBGetBValue(curr_mode.colors[led]);
|
||||
}
|
||||
|
||||
if(curr_mode.flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
speed = curr_mode.speed;
|
||||
}
|
||||
|
||||
if(curr_mode.flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
if(curr_mode.direction == MODE_DIRECTION_RIGHT)
|
||||
{
|
||||
dir = 1;
|
||||
}
|
||||
}
|
||||
|
||||
aura->SendUpdate
|
||||
(
|
||||
led,
|
||||
curr_mode.value,
|
||||
speed,
|
||||
dir,
|
||||
red,
|
||||
green,
|
||||
blue
|
||||
);
|
||||
|
||||
aura->SendSet();
|
||||
aura->SendApply();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == AURA_CORE_MODE_DIRECT)
|
||||
{
|
||||
aura->InitDirectMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +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 "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pci_vendor;
|
||||
int pci_device;
|
||||
int pci_subsystem_vendor;
|
||||
int pci_subsystem_device;
|
||||
unsigned char controller_address;
|
||||
const char * name;
|
||||
} gpu_pci_device;
|
||||
|
||||
#define GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const gpu_pci_device device_list[] =
|
||||
{
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1060_DEV, ASUS_SUB_VEN, ASUS_GTX1060_STRIX, 0x29, "ASUS GTX 1060 Strix" },
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1660TI_DEV, ASUS_SUB_VEN, ASUS_ROG_GTX1660TI_OC, 0x2A, "ASUS ROG GTX 1660 Ti OC 6G" },
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080_A8G_GAMING, 0x29, "ASUS ROG Strix GTX1080 A8G Gaming" },
|
||||
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080TI_GAMING, 0x29, "ASUS ROG Strix GTX1080 Ti Gaming" },
|
||||
{ AMD_GPU_VEN, AMD_VEGA10_DEV, ASUS_SUB_VEN, ASUS_VEGA64_STRIX, 0x29, "ASUS Vega 64 Strix" },
|
||||
{ AMD_GPU_VEN, AMD_NAVI10_DEV, ASUS_SUB_VEN, ASUS_RX5700XT_STRIX_GAMING_OC, 0x2A, "ASUS RX 5700XT Strix Gaming OC" },
|
||||
{ AMD_GPU_VEN, AMD_POLARIS_DEV, ASUS_SUB_VEN, ASUS_RX580_STRIX_GAMING_OC, 0x29, "ASUS RX 580 Strix Gaming OC" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* 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)
|
||||
{
|
||||
AuraGPUController* new_aura_gpu;
|
||||
RGBController_AuraGPU* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
for(unsigned int dev_idx = 0; dev_idx < GPU_NUM_DEVICES; dev_idx++)
|
||||
{
|
||||
if(busses[bus]->pci_vendor == device_list[dev_idx].pci_vendor &&
|
||||
busses[bus]->pci_device == device_list[dev_idx].pci_device &&
|
||||
busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor &&
|
||||
busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device)
|
||||
{
|
||||
if (TestForAsusAuraGPUController(busses[bus], device_list[dev_idx].controller_address))
|
||||
{
|
||||
new_aura_gpu = new AuraGPUController(busses[bus], device_list[dev_idx].controller_address);
|
||||
new_controller = new RGBController_AuraGPU(new_aura_gpu);
|
||||
new_controller->name = device_list[dev_idx].name;
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* DetectAsusAuraGPUControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("ASUS Aura GPU", DetectAsusAuraGPUControllers);
|
||||
@@ -1,110 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraKeyboardController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
AuraKeyboardController::AuraKeyboardController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
AuraKeyboardController::~AuraKeyboardController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string AuraKeyboardController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AuraKeyboardController::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 AuraKeyboardController::SendDirect
|
||||
(
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
unsigned int packet_count = frame_count / 15 + (((frame_count % 15) == 0) ? 0 : 1);
|
||||
unsigned int total_frame_idx = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0xC0;
|
||||
usb_buf[0x02] = 0x81;
|
||||
usb_buf[0x03] = packet_count * 15;
|
||||
usb_buf[0x04] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in frame data and send packets until all data |
|
||||
| has been sent |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int packet_idx = 0; packet_idx < packet_count; packet_idx++)
|
||||
{
|
||||
unsigned int packet_data_size = 15 * 4;
|
||||
|
||||
if((frame_count - total_frame_idx) < 15)
|
||||
{
|
||||
packet_data_size = (frame_count - total_frame_idx) * 4;
|
||||
memset(&usb_buf[0x05 + packet_data_size], 0xFF, (15*4) - packet_data_size);
|
||||
}
|
||||
|
||||
memcpy(&usb_buf[0x05], &frame_data[packet_idx * 15 * 4], packet_data_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Decrement remaining frame count |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x03] -= 0x0F;
|
||||
total_frame_idx += 0x0F;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0xC0;
|
||||
usb_buf[0x02] = 0x81;
|
||||
usb_buf[0x03] = 0x90;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read to apply |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_read(dev,usb_buf, 65);
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraKeyboardController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
class AuraKeyboardController
|
||||
{
|
||||
public:
|
||||
AuraKeyboardController(hid_device* dev_handle, const char* path);
|
||||
virtual ~AuraKeyboardController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
};
|
||||
@@ -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()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
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,102 +0,0 @@
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraAddressableController.h"
|
||||
#include "AsusAuraKeyboardController.h"
|
||||
#include "AsusAuraMainboardController.h"
|
||||
#include "AsusAuraMouseController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraUSB.h"
|
||||
#include "RGBController_AsusAuraKeyboard.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_STRIX_FLARE_PID 0x1875
|
||||
#define AURA_ROG_GLADIUS_II_ORIGIN_PID 0x1877
|
||||
#define AURA_ROG_GLADIUS_II_ORIGIN_PNK_LTD_PID 0x18CD
|
||||
#define AURA_ROG_STRIX_FLARE_PNK_LTD_PID 0x18CF
|
||||
#define AURA_ROG_CHAKRAM_WIRELESS_PID 0x18E5
|
||||
#define AURA_ROG_CHAKRAM_WIRED_1_PID 0x18E3
|
||||
#define AURA_ROG_CHAKRAM_WIRED_2_PID 0x1958
|
||||
|
||||
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 DetectAsusAuraUSBKeyboards(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
AuraKeyboardController* controller = new AuraKeyboardController(dev, info->path);
|
||||
RGBController_AuraKeyboard* rgb_controller = new RGBController_AuraKeyboard(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Origin PNK LTD", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_ORIGIN_PNK_LTD_PID, 2, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Chakram (Wireless)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRELESS_PID, 0, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("Asus ROG Chakram (Wired)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRED_1_PID, 0, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("Asus ROG Chakram (Wired)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRED_2_PID, 0, 0xFF01);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Strix Flare", DetectAsusAuraUSBKeyboards, AURA_USB_VID, AURA_ROG_STRIX_FLARE_PID, 1, 0xFF00);
|
||||
REGISTER_HID_DETECTOR_IP("ASUS ROG Strix Flare PNK LTD", DetectAsusAuraUSBKeyboards, AURA_USB_VID, AURA_ROG_STRIX_FLARE_PNK_LTD_PID, 1, 0xFF00);
|
||||
@@ -1,274 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraKeyboard.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraKeyboard.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][22] =
|
||||
{ { 0, NA, 12, 17, 22, 27, 37, 42, 48, 53, 59, 64, 67, 68, NA, 74, 78, 83, NA, NA, NA, NA },
|
||||
{ 1, 7, 13, 18, 23, 28, 33, 38, 43, 49, 54, 60, 65, 69, NA, 75, 79, 84, 87, 92, 96, 101 },
|
||||
{ 2, NA, 8, 14, 19, 24, 29, 34, 39, 44, 50, 55, 61, 66, 70, 76, 80, 85, 88, 93, 97, 102 },
|
||||
{ 3, NA, 9, 15, 20, 25, 30, 35, 40, 45, 51, 56, 62, 71, NA, NA, NA, NA, 89, 94, 98, NA },
|
||||
{ 4, NA, 10, 16, 21, 26, 31, 36, 41, 46, 52, 57, NA, NA, 72, NA, 81, NA, 90, 95, 99, 103 },
|
||||
{ 5, 6, 11, NA, NA, NA, NA, 32, NA, 47, NA, 58, 63, 73, NA, 77, 82, 86, 91, NA, 100, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
"Logo",
|
||||
"Underglow"
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
ZONE_TYPE_SINGLE,
|
||||
ZONE_TYPE_SINGLE
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
1,
|
||||
2,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Index */
|
||||
{ "Key: Escape", 0x00 },
|
||||
{ "Key: `", 0x01 },
|
||||
{ "Key: Tab", 0x02 },
|
||||
{ "Key: Caps Lock", 0x03 },
|
||||
{ "Key: Left Shift", 0x04 },
|
||||
{ "Key: Left Control", 0x05 },
|
||||
{ "Key: Left Windows", 0x0D },
|
||||
{ "Key: 1", 0x11 },
|
||||
{ "Key: Q", 0x12 },
|
||||
{ "Key: A", 0x13 },
|
||||
{ "Key: Z", 0x14 },
|
||||
{ "Key: Left Alt", 0x15 },
|
||||
{ "Key: F1", 0x18 },
|
||||
{ "Key: 2", 0x19 },
|
||||
{ "Key: W", 0x1A },
|
||||
{ "Key: S", 0x1B },
|
||||
{ "Key: X", 0x1C },
|
||||
{ "Key: F2", 0x20 },
|
||||
{ "Key: 3", 0x21 },
|
||||
{ "Key: E", 0x22 },
|
||||
{ "Key: D", 0x23 },
|
||||
{ "Key: C", 0x24 },
|
||||
{ "Key: F3", 0x28 },
|
||||
{ "Key: 4", 0x29 },
|
||||
{ "Key: R", 0x2A },
|
||||
{ "Key: F", 0x2B },
|
||||
{ "Key: V", 0x2C },
|
||||
{ "Key: F4", 0x30 },
|
||||
{ "Key: 5", 0x31 },
|
||||
{ "Key: T", 0x32 },
|
||||
{ "Key: G", 0x33 },
|
||||
{ "Key: B", 0x34 },
|
||||
{ "Key: Space", 0x35 },
|
||||
{ "Key: 6", 0x39 },
|
||||
{ "Key: Y", 0x3A },
|
||||
{ "Key: H", 0x3B },
|
||||
{ "Key: N", 0x3C },
|
||||
{ "Key: F5", 0x40 },
|
||||
{ "Key: 7", 0x41 },
|
||||
{ "Key: U", 0x42 },
|
||||
{ "Key: J", 0x43 },
|
||||
{ "Key: M", 0x44 },
|
||||
{ "Key: F6", 0x48 },
|
||||
{ "Key: 8", 0x49 },
|
||||
{ "Key: I", 0x4A },
|
||||
{ "Key: K", 0x4B },
|
||||
{ "Key: ,", 0x4C },
|
||||
{ "Key: Right Alt", 0x4D },
|
||||
{ "Key: F7", 0x50 },
|
||||
{ "Key: 9", 0x51 },
|
||||
{ "Key: O", 0x52 },
|
||||
{ "Key: L", 0x53 },
|
||||
{ "Key: .", 0x54 },
|
||||
{ "Key: F8", 0x58 },
|
||||
{ "Key: 0", 0x59 },
|
||||
{ "Key: P", 0x5A },
|
||||
{ "Key: ;", 0x5B },
|
||||
{ "Key: /", 0x5C },
|
||||
{ "Key: Right Fn", 0x5D },
|
||||
{ "Key: F9", 0x60 },
|
||||
{ "Key: -", 0x61 },
|
||||
{ "Key: [", 0x62 },
|
||||
{ "Key: '", 0x63 },
|
||||
{ "Key: Menu", 0x65 },
|
||||
{ "Key: F10", 0x68 },
|
||||
{ "Key: =", 0x69 },
|
||||
{ "Key: ]", 0x6A },
|
||||
{ "Key: F11", 0x70 },
|
||||
{ "Key: F12", 0x78 },
|
||||
{ "Key: Backspace", 0x79 },
|
||||
{ "Key: \\ (ANSI)", 0x7A },
|
||||
{ "Key: Enter", 0x7B },
|
||||
{ "Key: Right Shift", 0x7C },
|
||||
{ "Key: Right Control", 0x7D },
|
||||
{ "Key: Print Screen", 0x80 },
|
||||
{ "Key: Insert", 0x81 },
|
||||
{ "Key: Delete", 0x82 },
|
||||
{ "Key: Left Arrow", 0x85 },
|
||||
{ "Key: Scroll Lock", 0x88 },
|
||||
{ "Key: Home", 0x89 },
|
||||
{ "Key: End", 0x8A },
|
||||
{ "Key: Up Arrow", 0x8C },
|
||||
{ "Key: Down Arrow", 0x8D },
|
||||
{ "Key: Pause/Break", 0x90 },
|
||||
{ "Key: Page Up", 0x91 },
|
||||
{ "Key: Page Down", 0x92 },
|
||||
{ "Key: Right Arrow", 0x95 },
|
||||
{ "Key: Num Lock", 0x99 },
|
||||
{ "Key: Number Pad 7", 0x9A },
|
||||
{ "Key: Number Pad 4", 0x9B },
|
||||
{ "Key: Number Pad 1", 0x9C },
|
||||
{ "Key: Number Pad 0", 0x9D },
|
||||
{ "Key: Number Pad /", 0xA1 },
|
||||
{ "Key: Number Pad 8", 0xA2 },
|
||||
{ "Key: Number Pad 5", 0xA3 },
|
||||
{ "Key: Number Pad 2", 0xA4 },
|
||||
{ "Key: Number Pad *", 0xA9 },
|
||||
{ "Key: Number Pad 9", 0xAA },
|
||||
{ "Key: Number Pad 6", 0xAB },
|
||||
{ "Key: Number Pad 3", 0xAC },
|
||||
{ "Key: Number Pad .", 0xAD },
|
||||
{ "Key: Number Pad -", 0xB1 },
|
||||
{ "Key: Number Pad +", 0xB2 },
|
||||
{ "Key: Number Pad Enter", 0xB4 },
|
||||
{ "Logo", 0xB8 },
|
||||
{ "Left Underglow", 0xB9 },
|
||||
{ "Right Underglow", 0xBA },
|
||||
};
|
||||
|
||||
RGBController_AuraKeyboard::RGBController_AuraKeyboard(AuraKeyboardController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Keyboard";
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "ASUS Aura Keyboard Device";
|
||||
location = aura->GetDeviceLocation();
|
||||
serial = aura->GetSerialString();
|
||||
|
||||
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_AuraKeyboard::~RGBController_AuraKeyboard()
|
||||
{
|
||||
delete aura;
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 22;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char frame_buf[107 * 4];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
frame_buf[(led_idx * 4) + 0] = leds[led_idx].value;
|
||||
frame_buf[(led_idx * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(led_idx * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(led_idx * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
}
|
||||
|
||||
aura->SendDirect(107, frame_buf);
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraKeyboard::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AsusAuraKeyboard.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/19/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraKeyboardController.h"
|
||||
|
||||
class RGBController_AuraKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraKeyboard(AuraKeyboardController* aura_ptr);
|
||||
~RGBController_AuraKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AuraKeyboardController* aura;
|
||||
};
|
||||
@@ -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()
|
||||
{
|
||||
delete aura;
|
||||
}
|
||||
|
||||
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,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
|
||||
@@ -0,0 +1,125 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraCoreController.cpp |
|
||||
| |
|
||||
| Driver for ASUS ROG Aura Core RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraCoreController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraCoreController::AuraCoreController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
AuraCoreController::~AuraCoreController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
+5
-52
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraCoreController.h |
|
||||
| AuraCoreController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS ROG Aura |
|
||||
| Core RGB lighting controller |
|
||||
@@ -14,24 +14,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
enum AuraCoreDeviceType
|
||||
{
|
||||
AURA_CORE_DEVICE_UNKNOWN = 0,
|
||||
AURA_CORE_DEVICE_KEYBOARD = 1,
|
||||
AURA_CORE_DEVICE_GA15DH = 2
|
||||
};
|
||||
|
||||
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 */
|
||||
AURA_CORE_MODE_RAINBOW = 3, /* Rainbow mode */
|
||||
AURA_CORE_MODE_STROBE = 10, /* Strobe mode */
|
||||
AURA_CORE_MODE_COMET = 11, /* Comet mode */
|
||||
AURA_CORE_MODE_FLASHNDASH = 12, /* Flash & Dash mode */
|
||||
AURA_CORE_MODE_IRRADIATION = 17, /* Irradiation mode */
|
||||
AURA_CORE_MODE_DIRECT = 255 /* Not a real mode - but need a way to differentiate */
|
||||
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
|
||||
@@ -40,7 +27,6 @@ enum
|
||||
AURA_CORE_COMMAND_SET = 0xB5, /* Set command */
|
||||
AURA_CORE_COMMAND_APPLY = 0xB4, /* Apply command */
|
||||
AURA_CORE_COMMAND_BRIGHTNESS = 0xBA, /* Brightness command */
|
||||
AURA_CORE_COMMAND_DIRECT = 0xBC /* Set LEDs directly */
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -59,34 +45,12 @@ enum
|
||||
AURA_CORE_SPEED_FAST = 0xF5, /* Fastest speed */
|
||||
};
|
||||
|
||||
struct AuraDeviceDescriptor
|
||||
{
|
||||
AuraCoreDeviceType aura_type;
|
||||
unsigned char buff_size;
|
||||
unsigned char report_id;
|
||||
unsigned char num_leds;
|
||||
unsigned char max_leds_per_message;
|
||||
bool supports_direct;
|
||||
};
|
||||
|
||||
struct AuraColor
|
||||
{
|
||||
unsigned char red;
|
||||
unsigned char green;
|
||||
unsigned char blue;
|
||||
};
|
||||
|
||||
class AuraCoreController
|
||||
{
|
||||
public:
|
||||
AuraDeviceDescriptor aura_device;
|
||||
|
||||
AuraCoreController(hid_device* dev_handle, const char* path);
|
||||
AuraCoreController(hid_device* dev_handle);
|
||||
~AuraCoreController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
@@ -97,7 +61,6 @@ public:
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char dir,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
@@ -107,17 +70,7 @@ public:
|
||||
|
||||
void SendApply();
|
||||
|
||||
void InitDirectMode();
|
||||
|
||||
void UpdateDirect(std::vector<AuraColor>& color_set);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
|
||||
void IdentifyDevice();
|
||||
void Handshake();
|
||||
void SendIdString();
|
||||
void SendQuery();
|
||||
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "AuraCoreController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraCore.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_CORE_VID 0x0B05
|
||||
|
||||
#define NUM_PIDS 3
|
||||
static const unsigned short pid_table[] =
|
||||
{
|
||||
0x1854,
|
||||
0x1869,
|
||||
0x1866
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraCoreControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraCoreControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus ROG Aura Core RGB controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_CORE_VID, pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraCoreController* controller = new AuraCoreController(dev);
|
||||
|
||||
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraGPUController.cpp |
|
||||
| AuraGPUController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraGPUController.h"
|
||||
#include "AuraGPUController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraGPUController.h |
|
||||
| AuraGPUController.h |
|
||||
| |
|
||||
| Definitions for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
@@ -0,0 +1,85 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraGPUControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB on GPUs |
|
||||
| |
|
||||
| Jan Rettig (Klapstuhl) 14.02.2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraGPUController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraGPU.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 TestForAuraGPUController(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 DetectAuraGPUControllers(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 (TestForAuraGPUController(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() */
|
||||
+4
-26
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.cpp |
|
||||
| AuraSMBusController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
@@ -7,24 +7,9 @@
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraSMBusController.h"
|
||||
#include "AuraSMBusController.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)
|
||||
{
|
||||
this->bus = bus;
|
||||
@@ -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
|
||||
{
|
||||
@@ -116,7 +94,7 @@ std::string AuraSMBusController::GetDeviceLocation()
|
||||
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)
|
||||
+16
-1
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraSMBusController.h |
|
||||
| AuraSMBusController.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 */
|
||||
+45
-55
@@ -1,9 +1,7 @@
|
||||
#include "Detector.h"
|
||||
#include "AsusAuraSMBusController.h"
|
||||
#include "AuraSMBusController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AsusAuraSMBus.h"
|
||||
#include "RGBController_AuraSMBus.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include "pci_ids.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -64,7 +62,7 @@ static const unsigned char aura_mobo_addresses[] =
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
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));
|
||||
@@ -83,7 +81,7 @@ void AsusAuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_regis
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char address)
|
||||
bool TestForAuraSMBusController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
@@ -110,7 +108,7 @@ bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char addr
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraSMBusControllers *
|
||||
* DetectAuraSMBusControllers *
|
||||
* *
|
||||
* 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,7 +120,7 @@ bool TestForAsusAuraSMBusController(i2c_smbus_interface* bus, unsigned char addr
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAsusAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
AuraSMBusController* new_aura;
|
||||
RGBController_AuraSMBus* new_controller;
|
||||
@@ -131,70 +129,62 @@ void DetectAsusAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
{
|
||||
int address_list_idx = -1;
|
||||
|
||||
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);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
address_list_idx++;
|
||||
|
||||
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);
|
||||
do
|
||||
{
|
||||
address_list_idx++;
|
||||
|
||||
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));
|
||||
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
|
||||
}
|
||||
}
|
||||
|
||||
// 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 (TestForAsusAuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]))
|
||||
else
|
||||
{
|
||||
new_aura = new AuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_AuraSMBus(new_aura);
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
break;
|
||||
}
|
||||
} while (res >= 0);
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
|
||||
{
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
|
||||
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Add Aura-enabled motherboard controllers
|
||||
IF_MOBO_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
|
||||
// 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++)
|
||||
{
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
if (TestForAuraSMBusController(busses[bus], aura_ram_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);
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
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);
|
||||
}
|
||||
|
||||
// Add Aura-enabled motherboard controllers
|
||||
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
|
||||
{
|
||||
if (TestForAuraSMBusController(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);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraSMBusControllers() */
|
||||
|
||||
REGISTER_I2C_DETECTOR("ASUS Aura SMBus", DetectAsusAuraSMBusControllers);
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraAddressableController.cpp |
|
||||
| AuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
@@ -7,10 +7,10 @@
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraAddressableController.h"
|
||||
#include "AuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle, const char* path) : AuraUSBController(dev_handle, path)
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle) : AuraUSBController(dev_handle)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add addressable devices |
|
||||
@@ -40,7 +40,7 @@ void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor *
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
for(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]);
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraAddressableController.h |
|
||||
| AuraAddressableController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| Addressable RGB lighting controller |
|
||||
@@ -8,7 +8,7 @@
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraUSBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
@@ -23,7 +23,7 @@ enum
|
||||
class AuraAddressableController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraAddressableController(hid_device* dev_handle, const char* path);
|
||||
AuraAddressableController(hid_device* dev_handle);
|
||||
~AuraAddressableController();
|
||||
|
||||
void SetChannelLEDs
|
||||
+15
-15
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMainboardController.cpp |
|
||||
| AuraMainboardController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB mainboard |
|
||||
| lighting controller |
|
||||
@@ -7,10 +7,10 @@
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraMainboardController.h"
|
||||
#include "AuraMainboardController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraMainboardController::AuraMainboardController(hid_device* dev_handle, const char* path) : AuraUSBController(dev_handle, path), mode(AURA_MODE_DIRECT)
|
||||
AuraMainboardController::AuraMainboardController(hid_device* dev_handle) : AuraUSBController(dev_handle), mode(AURA_MODE_DIRECT)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add mainboard device |
|
||||
@@ -44,7 +44,7 @@ void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * c
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
for(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]);
|
||||
@@ -62,6 +62,8 @@ void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * c
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetMode
|
||||
@@ -102,13 +104,11 @@ void AuraMainboardController::SetMode
|
||||
channel,
|
||||
start_led,
|
||||
device_info[channel].num_leds,
|
||||
led_data
|
||||
led_data,
|
||||
device_info[channel].device_type == AuraDeviceType::FIXED
|
||||
);
|
||||
}
|
||||
|
||||
unsigned short AuraMainboardController::GetMask(int start, int size)
|
||||
{
|
||||
return(((1 << size) - 1) << start);
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendEffect
|
||||
@@ -145,11 +145,11 @@ void AuraMainboardController::SendColor
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
)
|
||||
{
|
||||
unsigned short mask = GetMask(start_led, led_count);
|
||||
unsigned char usb_buf[65];
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -161,8 +161,8 @@ void AuraMainboardController::SendColor
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR;
|
||||
usb_buf[0x02] = mask >> 8;
|
||||
usb_buf[0x03] = mask & 0xff;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = fixed ? 0xFF : 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -196,4 +196,4 @@ void AuraMainboardController::SendCommit()
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraMainboardController.h |
|
||||
| AuraMainboardController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB Mainboard RGB lighting controller |
|
||||
@@ -8,7 +8,7 @@
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraUSBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
@@ -25,7 +25,7 @@ enum
|
||||
class AuraMainboardController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraMainboardController(hid_device* dev_handle, const char* path);
|
||||
AuraMainboardController(hid_device* dev_handle);
|
||||
~AuraMainboardController();
|
||||
|
||||
void SetChannelLEDs
|
||||
@@ -47,8 +47,6 @@ public:
|
||||
private:
|
||||
unsigned int mode;
|
||||
|
||||
unsigned short GetMask(int start, int size);
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
@@ -60,7 +58,8 @@ private:
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
+11
-25
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraUSBController.cpp |
|
||||
| AuraUSBController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
@@ -7,14 +7,13 @@
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AsusAuraUSBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle, const char* path)
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
dev = dev_handle;
|
||||
|
||||
GetFirmwareVersion();
|
||||
GetConfigTable();
|
||||
@@ -22,34 +21,19 @@ AuraUSBController::AuraUSBController(hid_device* dev_handle, const char* path)
|
||||
|
||||
AuraUSBController::~AuraUSBController()
|
||||
{
|
||||
hid_close(dev);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -94,9 +78,11 @@ void AuraUSBController::GetConfigTable()
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hid_close(dev);
|
||||
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
throw std::runtime_error("Could not read config table");
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| AsusAuraUSBController.h |
|
||||
| AuraUSBController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB RGB lighting controller |
|
||||
@@ -59,14 +59,12 @@ struct AuraDeviceInfo
|
||||
class AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraUSBController(hid_device* dev_handle, const char* path);
|
||||
AuraUSBController(hid_device* dev_handle);
|
||||
virtual ~AuraUSBController();
|
||||
|
||||
unsigned int GetChannelCount();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
|
||||
const std::vector<AuraDeviceInfo>& GetAuraDevices() const;
|
||||
|
||||
@@ -90,7 +88,6 @@ protected:
|
||||
hid_device* dev;
|
||||
unsigned char config_table[60];
|
||||
std::vector<AuraDeviceInfo> device_info;
|
||||
std::string location;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
@@ -0,0 +1,77 @@
|
||||
#include "AuraAddressableController.h"
|
||||
#include "AuraMainboardController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraUSB.h"
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_USB_VID 0x0B05
|
||||
|
||||
#define NUM_ADDRESSABLE_PIDS 4
|
||||
static const unsigned short addressable_pid_table[] =
|
||||
{
|
||||
0x1867,
|
||||
0x1872,
|
||||
0x1889,
|
||||
0x18A3
|
||||
};
|
||||
|
||||
#define NUM_MAINBOARD_PIDS 2
|
||||
static const unsigned short mainboard_pid_table[] =
|
||||
{
|
||||
0x18f3,
|
||||
0x1939
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraUSBControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus Aura USB RGB header controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus Aura addressable RGB header controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_ADDRESSABLE_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, addressable_pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_MAINBOARD_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, mainboard_pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
try
|
||||
{
|
||||
AuraMainboardController* controller = new AuraMainboardController(dev);
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
catch(std::runtime_error&)
|
||||
{
|
||||
// reading the config table failed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,308 +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
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0B, 0x01 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int rgb_offset = 0;
|
||||
int zone;
|
||||
|
||||
if (argb_header_data[zone_index].digital)
|
||||
{
|
||||
zone = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = 0x00;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0A;
|
||||
rgb_offset = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If this is the group then just return the first status |
|
||||
\*---------------------------------------------------------*/
|
||||
buffer[CM_ARGB_ZONE_BYTE] = ( zone > 0x08 ) ? 0x01 : zone;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
current_mode = buffer[4 - rgb_offset];
|
||||
bool_random = ( buffer[5 - rgb_offset] == 0x00 );
|
||||
current_speed = buffer[6 - rgb_offset];
|
||||
current_brightness = buffer[7 - rgb_offset];
|
||||
current_red = buffer[8 - rgb_offset];
|
||||
current_green = buffer[9 - rgb_offset];
|
||||
current_blue = buffer[10 - rgb_offset];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool CMARGBController::GetRandomColours()
|
||||
{
|
||||
return bool_random;
|
||||
}
|
||||
|
||||
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 Cooler Master ARGB controller V0008 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::SetLedCount(int zone, int led_count)
|
||||
{
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0D, 0x02 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
buffer[CM_ARGB_ZONE_BYTE] = zone;
|
||||
buffer[CM_ARGB_MODE_BYTE] = led_count;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = (0x0F - led_count > 0) ? 0x0F - led_count : 0x01;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void CMARGBController::SetMode(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours)
|
||||
{
|
||||
bool needs_update = !( (current_mode == mode) && (current_speed == speed) && (current_brightness == 0xFF) && (ToRGBColor(current_red, current_green, current_blue) == colour));
|
||||
|
||||
if (needs_update)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_brightness = 0xFF;
|
||||
current_red = RGBGetRValue(colour);
|
||||
current_green = RGBGetGValue(colour);
|
||||
current_blue = RGBGetBValue(colour);
|
||||
bool_random = random_colours;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
|
||||
{
|
||||
const unsigned char buffer_size = CM_ARGB_PACKET_SIZE;
|
||||
unsigned char buffer[buffer_size] = { 0x00, 0x10, 0x02 };
|
||||
unsigned char packet_count = 0;
|
||||
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];
|
||||
|
||||
colours.push_back( RGBGetRValue(colour) );
|
||||
colours.push_back( RGBGetGValue(colour) );
|
||||
colours.push_back( RGBGetBValue(colour) );
|
||||
}
|
||||
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = led_count;
|
||||
unsigned char buffer_idx = CM_ARGB_MODE_BYTE + 1;
|
||||
|
||||
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, buffer_size );
|
||||
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[CM_ARGB_PACKET_SIZE] = { 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 ) || ( current_mode == CM_RGB_MODE_PASSTHRU );
|
||||
bool boolDirect = ( current_mode == CM_ARGB_MODE_DIRECT );
|
||||
unsigned char function = boolPassthru ? (boolARGB_header ? 0x02 : 0x04) : (boolARGB_header ? 0x01 : 0x03);
|
||||
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = boolDirect ? 0x01 : function;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Direct mode is now set up and no other mode packet is required |
|
||||
\*-----------------------------------------------------------------*/
|
||||
if(boolDirect)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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 direct mode TODO
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = current_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = bool_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE] = current_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE] = current_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE] = current_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE] = current_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE] = current_blue;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = boolPassthru ? 0x01 : 0x04; //ARGB sends 0x0b (1011) RGB sends 0x04 (0100)
|
||||
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = current_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = bool_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = current_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE + CM_RGB_OFFSET] = current_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE + CM_RGB_OFFSET] = current_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE + CM_RGB_OFFSET] = current_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE + CM_RGB_OFFSET] = current_blue;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
@@ -1,137 +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_PACKET_SIZE 65
|
||||
#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,
|
||||
CM_ARGB_BRIGHTNESS_BYTE = 8,
|
||||
CM_ARGB_RED_BYTE = 9,
|
||||
CM_ARGB_GREEN_BYTE = 10,
|
||||
CM_ARGB_BLUE_BYTE = 11
|
||||
};
|
||||
|
||||
struct argb_headers
|
||||
{
|
||||
const char* name;
|
||||
unsigned char header;
|
||||
bool digital;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static argb_headers argb_header_data[6] =
|
||||
{
|
||||
{ "RGB Header", 0xFE, 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_MIRAGE = 0x01, //Mirage
|
||||
CM_RGB_MODE_FLASH = 0x02, //Flash
|
||||
CM_RGB_MODE_BREATHING = 0x03, //Breathing
|
||||
CM_RGB_MODE_STATIC = 0x05, //Static
|
||||
CM_RGB_MODE_OFF = 0x06, //Turn off
|
||||
CM_RGB_MODE_PASSTHRU = 0xFF //Motherboard Pass Thru Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_ARGB_MODE_OFF = 0x0B, //Turn off
|
||||
CM_ARGB_MODE_SPECTRUM = 0x01, //Spectrum Mode
|
||||
CM_ARGB_MODE_RELOAD = 0x02, //Reload Mode
|
||||
CM_ARGB_MODE_RECOIL = 0x03, //Recoil Mode
|
||||
CM_ARGB_MODE_BREATHING = 0x04, //Breathing Mode
|
||||
CM_ARGB_MODE_REFILL = 0x05, //Refill Mode
|
||||
CM_ARGB_MODE_DEMO = 0x06, //Demo Mode
|
||||
CM_ARGB_MODE_FILLFLOW = 0x08, //Fill Flow Mode
|
||||
CM_ARGB_MODE_RAINBOW = 0x09, //Rainbow Mode
|
||||
CM_ARGB_MODE_STATIC = 0x0A, //Static 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();
|
||||
bool GetRandomColours();
|
||||
void SetLedCount(int zone, int led_count);
|
||||
void SetMode(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours);
|
||||
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 char current_brightness;
|
||||
bool bool_random;
|
||||
|
||||
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();
|
||||
};
|
||||
@@ -9,40 +9,18 @@
|
||||
|
||||
#include "CMMP750Controller.h"
|
||||
|
||||
static unsigned char colour_mode_data[][6] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Off */
|
||||
{ 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] =
|
||||
{
|
||||
0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 /* Speed Definition */
|
||||
};
|
||||
|
||||
CMMP750Controller::CMMP750Controller(hid_device* dev_handle, char *_path)
|
||||
CMMP750Controller::CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path)
|
||||
{
|
||||
int tmp_size = wcslen(_vendor);
|
||||
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());
|
||||
for (int i=0; ( i<tmp_size && i<CM_DEVICE_NAME_SIZE); i++)
|
||||
{
|
||||
device_name[i] = (char)_vendor[i];
|
||||
}
|
||||
for (int j=0; ( j<wcslen(_vendor) && tmp_size+j<CM_DEVICE_NAME_SIZE); j++)
|
||||
device_name[tmp_size+j] = (char)_device_name[j];
|
||||
|
||||
GetStatus(); //When setting up device get current status
|
||||
}
|
||||
@@ -54,29 +32,27 @@ CMMP750Controller::~CMMP750Controller()
|
||||
|
||||
void CMMP750Controller::GetStatus()
|
||||
{
|
||||
unsigned char buffer[0x41] = { 0x00 };
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
buffer[1] = 0x07;
|
||||
buffer[0] = 0x07;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read(dev, buffer, buffer_size);
|
||||
|
||||
if((buffer[0] == 0x80) && (buffer[1] == 0x05))
|
||||
if( buffer[0] == 0x80 && buffer[1] == 0x05 )
|
||||
{
|
||||
current_mode = buffer[2];
|
||||
current_mode = buffer[2] - 1;
|
||||
current_red = buffer[3];
|
||||
current_green = buffer[4];
|
||||
current_blue = buffer[5];
|
||||
|
||||
for(int i = 0; (speed_mode_data[i] >= buffer[6] && i <= MP750_SPEED_FASTEST); i++)
|
||||
{
|
||||
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 = CM_MP750_MODE_COLOR_CYCLE; //Unicorn Spew
|
||||
current_mode = MP750_MODE_COLOR_CYCLE; //Unicorn Spew
|
||||
current_red = 0xFF;
|
||||
current_green = 0xFF;
|
||||
current_blue = 0xFF;
|
||||
@@ -84,19 +60,19 @@ void CMMP750Controller::GetStatus()
|
||||
}
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetDeviceName()
|
||||
char* CMMP750Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetSerial()
|
||||
char* CMMP750Controller::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMMP750Controller::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
return location;
|
||||
}
|
||||
|
||||
unsigned char CMMP750Controller::GetMode()
|
||||
@@ -143,27 +119,27 @@ void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigne
|
||||
|
||||
void CMMP750Controller::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[0x41] = { 0x00 };
|
||||
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++)
|
||||
for(int i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++)
|
||||
{
|
||||
buffer[i+1] = colour_mode_data[current_mode][i];
|
||||
buffer[i] = colour_mode_data[current_mode][i];
|
||||
}
|
||||
|
||||
if(current_mode > CM_MP750_MODE_BREATHING)
|
||||
if(current_mode > MP750_MODE_BREATHING)
|
||||
{
|
||||
//If the mode is random colours set SPEED at BYTE2
|
||||
buffer[CM_RED_BYTE] = speed_mode_data[current_speed];
|
||||
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_speed];
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -28,22 +28,38 @@
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MODE_BYTE = 1,
|
||||
CM_LENGTH_BYTE = 2,
|
||||
CM_RED_BYTE = 3,
|
||||
CM_GREEN_BYTE = 4,
|
||||
CM_BLUE_BYTE = 5,
|
||||
CM_SPEED_BYTE = 6
|
||||
CM_MODE_BYTE = 0,
|
||||
CM_RED_BYTE = 2,
|
||||
CM_GREEN_BYTE = 3,
|
||||
CM_BLUE_BYTE = 4,
|
||||
CM_SPEED_BYTE = 5
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MP750_MODE_OFF = 0x00, //Off
|
||||
CM_MP750_MODE_STATIC = 0x01, //Static Mode
|
||||
CM_MP750_MODE_BLINK = 0x02, //Blinking Mode
|
||||
CM_MP750_MODE_BREATHING = 0x03, //Breathing Mode
|
||||
CM_MP750_MODE_COLOR_CYCLE = 0x04, //Color Cycle Mode
|
||||
CM_MP750_MODE_BREATH_CYCLE = 0x05 //Breathing Cycle Mode
|
||||
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
|
||||
};
|
||||
|
||||
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 */
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -62,11 +78,11 @@ enum
|
||||
class CMMP750Controller
|
||||
{
|
||||
public:
|
||||
CMMP750Controller(hid_device* dev_handle, char *_path);
|
||||
CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path);
|
||||
~CMMP750Controller();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
char* GetDeviceName();
|
||||
char* GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetMode();
|
||||
@@ -78,8 +94,8 @@ public:
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string serial;
|
||||
char device_name[32];
|
||||
char serial[32];
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMR6000Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster based AMD Radeon GPU (6000 series) |
|
||||
| |
|
||||
| Eric S (edbgon) 2nd Feb 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMR6000Controller.h"
|
||||
#include <cstring>
|
||||
|
||||
CMR6000Controller::CMR6000Controller(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
|
||||
}
|
||||
|
||||
CMR6000Controller::~CMR6000Controller()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
void CMR6000Controller::GetStatus()
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0xA0, 0x01, 0x00, 0x00, 0x03 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
// Request mode
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read(dev, buffer, buffer_size);
|
||||
|
||||
unsigned char cmdbuffer[CM_6K_PACKET_SIZE] = { 0x00, 0x52, 0x2C, 0x01, 0x00 };
|
||||
int cmdbuffer_size = (sizeof(cmdbuffer) / sizeof(cmdbuffer[0]));
|
||||
|
||||
current_mode = buffer[0x0A];
|
||||
cmdbuffer[0x05] = current_mode;
|
||||
hid_write(dev, cmdbuffer, cmdbuffer_size);
|
||||
hid_read(dev, cmdbuffer, cmdbuffer_size);
|
||||
|
||||
current_speed = cmdbuffer[0x05];
|
||||
current_brightness = cmdbuffer[0x09];
|
||||
current_red = cmdbuffer[0x0A];
|
||||
current_green = cmdbuffer[0x0B];
|
||||
current_blue = cmdbuffer[0x0C];
|
||||
}
|
||||
|
||||
std::string CMR6000Controller::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMR6000Controller::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMR6000Controller::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMR6000Controller::GetMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned char CMR6000Controller::GetLedRed()
|
||||
{
|
||||
return current_red;
|
||||
}
|
||||
|
||||
unsigned char CMR6000Controller::GetLedGreen()
|
||||
{
|
||||
return current_green;
|
||||
}
|
||||
|
||||
unsigned char CMR6000Controller::GetLedBlue()
|
||||
{
|
||||
return current_blue;
|
||||
}
|
||||
|
||||
unsigned char CMR6000Controller::GetLedSpeed()
|
||||
{
|
||||
return current_speed;
|
||||
}
|
||||
|
||||
bool CMR6000Controller::GetRandomColours()
|
||||
{
|
||||
return current_random;
|
||||
}
|
||||
|
||||
void CMR6000Controller::SetMode(unsigned char mode, unsigned char speed, unsigned char red, unsigned char green, unsigned char blue, unsigned char random)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_red = red;
|
||||
current_green = green;
|
||||
current_blue = blue;
|
||||
current_random = random;
|
||||
current_brightness = (current_mode == CM_MR6000_MODE_COLOR_CYCLE) ? 0x7F : 0xFF; //Color_Cycle brightness needs to be clamped to 0x7F to avoid wash out
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMR6000Controller::SendUpdate()
|
||||
{
|
||||
if(current_mode == CM_MR6000_MODE_OFF)
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x41, 0x43 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendEnableCommand();
|
||||
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
memset(buffer, 0xFF, buffer_size);
|
||||
|
||||
buffer[0x00] = 0x00;
|
||||
buffer[0x01] = 0x51;
|
||||
buffer[0x02] = 0x2C;
|
||||
buffer[0x03] = 0x01;
|
||||
buffer[0x04] = 0x00;
|
||||
buffer[0x05] = current_mode;
|
||||
buffer[0x06] = (current_mode == CM_MR6000_MODE_STATIC) ? 0xFF: current_speed;
|
||||
buffer[0x07] = (current_mode == CM_MR6000_MODE_BREATHE)? current_random : 0x00; //random (A0)
|
||||
buffer[0x08] = (current_mode == CM_MR6000_MODE_BREATHE)? 0x03 : 0xFF;
|
||||
//buffer[0x09] = 0xFF;
|
||||
buffer[0x0A] = current_brightness;
|
||||
buffer[0x0B] = (current_mode == CM_MR6000_MODE_COLOR_CYCLE) ? 0xFF : current_red;
|
||||
buffer[0x0C] = (current_mode == CM_MR6000_MODE_COLOR_CYCLE) ? 0xFF : current_green;
|
||||
buffer[0x0D] = (current_mode == CM_MR6000_MODE_COLOR_CYCLE) ? 0xFF : current_blue;
|
||||
buffer[0x0E] = 0x00;
|
||||
buffer[0x0F] = 0x00;
|
||||
buffer[0x10] = 0x00;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
SendColourConfig();
|
||||
SendApplyCommand();
|
||||
}
|
||||
}
|
||||
|
||||
void CMR6000Controller::SendEnableCommand()
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x41, 0x80 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_6K_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
void CMR6000Controller::SendApplyCommand()
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x51, 0x28, 0x00, 0x00, 0xE0 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_6K_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
void CMR6000Controller::SendColourConfig()
|
||||
{
|
||||
unsigned char buffer[CM_6K_PACKET_SIZE] = { 0x00, 0x51, 0xA0, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x05, 0x06 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
for(int i = 0x0B; i < 0x1A; i++)
|
||||
{
|
||||
buffer[i] = current_mode;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_6K_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMR6000Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster based AMD Radeon GPU (6000 series) |
|
||||
| |
|
||||
| Eric S (edbgon) 2nd Feb 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_6K_PACKET_SIZE 65 //Includes extra first byte for non HID Report packets
|
||||
#define CM_6K_INTERRUPT_TIMEOUT 250
|
||||
#define CM_6K_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_6K_SERIAL_SIZE (sizeof(serial) / sizeof(serial[ 0 ]))
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
enum
|
||||
{
|
||||
CM_MR6000_MODE_STATIC = 0x00, //Static Mode
|
||||
CM_MR6000_MODE_BREATHE = 0x01, //Breathe Mode
|
||||
CM_MR6000_MODE_COLOR_CYCLE = 0x02, //Color cycle
|
||||
CM_MR6000_MODE_OFF = 0xFF, //Off
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MR6000_CYCLE_SPEED_SLOWEST = 0x96, /* Slowest speed */
|
||||
MR6000_CYCLE_SPEED_SLOW = 0x8C, /* Slow speed */
|
||||
MR6000_CYCLE_SPEED_NORMAL = 0x80, /* Normal speed */
|
||||
MR6000_CYCLE_SPEED_FAST = 0x6E, /* Fast speed */
|
||||
MR6000_CYCLE_SPEED_FASTEST = 0x68, /* Fastest speed */
|
||||
|
||||
MR6000_BREATHE_SPEED_SLOWEST = 0x3C, /* Slowest speed */
|
||||
MR6000_BREATHE_SPEED_SLOW = 0x37, /* Slow speed */
|
||||
MR6000_BREATHE_SPEED_NORMAL = 0x31, /* Normal speed */
|
||||
MR6000_BREATHE_SPEED_FAST = 0x2C, /* Fast speed */
|
||||
MR6000_BREATHE_SPEED_FASTEST = 0x26, /* Fastest speed */
|
||||
};
|
||||
|
||||
class CMR6000Controller
|
||||
{
|
||||
public:
|
||||
CMR6000Controller(hid_device* dev_handle, char *_path);
|
||||
~CMR6000Controller();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetMode();
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
unsigned char GetLedBlue();
|
||||
unsigned char GetLedSpeed();
|
||||
bool GetRandomColours();
|
||||
void SetMode(unsigned char mode, unsigned char speed, unsigned char red, unsigned char green, unsigned char blue, unsigned char random);
|
||||
|
||||
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_random;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
unsigned char current_brightness;
|
||||
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
void SendEnableCommand();
|
||||
void SendApplyCommand();
|
||||
void SendColourConfig();
|
||||
};
|
||||
@@ -1,237 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMSmallARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMSmallARGBController.h"
|
||||
#include <cstring>
|
||||
|
||||
CMSmallARGBController::CMSmallARGBController(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_SMALL_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();
|
||||
}
|
||||
|
||||
CMSmallARGBController::~CMSmallARGBController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
void CMSmallARGBController::GetStatus()
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x01, 0x01 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int header = zone_index - 1;
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
memset(buffer, 0x00, buffer_size );
|
||||
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0x01;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
current_mode = buffer[4];
|
||||
current_speed = buffer[5];
|
||||
bool_random = buffer[6] == 0x00;
|
||||
current_brightness = buffer[7];
|
||||
current_red = buffer[8];
|
||||
current_green = buffer[9];
|
||||
current_blue = buffer[10];
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetZoneIndex()
|
||||
{
|
||||
return zone_index;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedRed()
|
||||
{
|
||||
return current_red;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedGreen()
|
||||
{
|
||||
return current_green;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedBlue()
|
||||
{
|
||||
return current_blue;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedSpeed()
|
||||
{
|
||||
return current_speed;
|
||||
}
|
||||
|
||||
bool CMSmallARGBController::GetRandomColours()
|
||||
{
|
||||
return bool_random;
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetLedCount(int zone, int led_count)
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0D, 0x02 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = (0x0F - led_count > 0) ? 0x0F - led_count : 0x01;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = led_count;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetMode(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_red = RGBGetRValue(colour);
|
||||
current_green = RGBGetGValue(colour);
|
||||
current_blue = RGBGetBValue(colour);
|
||||
bool_random = random_colours;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
|
||||
{
|
||||
// Mode not yet Tested
|
||||
/*
|
||||
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_SMALL_ARGB_COMMAND_BYTE] = 0x10;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x02;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = small_argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x30; //30 might be the LED count??
|
||||
unsigned char buffer_idx = CM_SMALL_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_SMALL_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_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
//reset the write buffer
|
||||
memset(buffer, 0x00, sizeof(buffer) );
|
||||
packet_count++;
|
||||
}
|
||||
buffer[CM_SMALL_ARGB_REPORT_BYTE] = 0x82;
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x62;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x00;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0x73;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x00;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = 0x33;
|
||||
buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = 0x18;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
*/
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
bool boolPassthru = ( current_mode == CM_SMALL_ARGB_MODE_PASSTHRU );
|
||||
bool boolDirect = ( current_mode == CM_SMALL_ARGB_MODE_DIRECT );
|
||||
unsigned char function = boolPassthru ? 0x02 : 0x01;
|
||||
buffer[CM_SMALL_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = boolDirect ? 0x10 : 0x01;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = boolDirect ? 0x01 : function;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = boolPassthru ? 0x00 : 0x02;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0b;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls custom mode TODO
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = small_argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = current_mode;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = current_speed;
|
||||
buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = (bool_random) ? 0x00 : 0x10; //This looks to still be the colour index and controls random colours
|
||||
buffer[CM_SMALL_ARGB_BRIGHTNESS_BYTE] = 0xFF;
|
||||
buffer[CM_SMALL_ARGB_RED_BYTE] = current_red;
|
||||
buffer[CM_SMALL_ARGB_GREEN_BYTE] = current_green;
|
||||
buffer[CM_SMALL_ARGB_BLUE_BYTE] = current_blue;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CMSmallARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include "RGBController.h" //Needed to set the direct mode
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_SMALL_ARGB_PACKET_SIZE 65
|
||||
#define CM_SMALL_ARGB_INTERRUPT_TIMEOUT 250
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_REPORT_BYTE = 1,
|
||||
CM_SMALL_ARGB_COMMAND_BYTE = 2,
|
||||
CM_SMALL_ARGB_FUNCTION_BYTE = 3,
|
||||
CM_SMALL_ARGB_ZONE_BYTE = 4,
|
||||
CM_SMALL_ARGB_MODE_BYTE = 5,
|
||||
CM_SMALL_ARGB_SPEED_BYTE = 6,
|
||||
CM_SMALL_ARGB_COLOUR_INDEX_BYTE = 7, //Not used on the small controller
|
||||
CM_SMALL_ARGB_BRIGHTNESS_BYTE = 8, //0x00 thru 0xFF
|
||||
CM_SMALL_ARGB_RED_BYTE = 9,
|
||||
CM_SMALL_ARGB_GREEN_BYTE = 10,
|
||||
CM_SMALL_ARGB_BLUE_BYTE = 11,
|
||||
};
|
||||
|
||||
struct _argb_headers
|
||||
{
|
||||
const char* name;
|
||||
unsigned char header;
|
||||
bool digital;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static _argb_headers small_argb_header_data[1] =
|
||||
{
|
||||
{ "CM Small ARGB", 0x01, true, 12 }
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_MODE_SPECTRUM = 0x01, //Spectrum Mode
|
||||
CM_SMALL_ARGB_MODE_RELOAD = 0x02, //Reload Mode
|
||||
CM_SMALL_ARGB_MODE_RECOIL = 0x03, //Recoil Mode
|
||||
CM_SMALL_ARGB_MODE_BREATHING = 0x04, //Breathing Mode
|
||||
CM_SMALL_ARGB_MODE_REFILL = 0x05, //Refill Mode
|
||||
CM_SMALL_ARGB_MODE_DEMO = 0x06, //Demo Mode
|
||||
CM_SMALL_ARGB_MODE_OFF = 0x09, //Turn off
|
||||
CM_SMALL_ARGB_MODE_DIRECT = 0xFE, //Direct Led Control (possibly N?A for small controller)
|
||||
CM_SMALL_ARGB_MODE_PASSTHRU = 0xFF //Motherboard Pass Thru Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_SPEED_SLOWEST = 0x00, // Slowest speed
|
||||
CM_SMALL_ARGB_SPEED_SLOW = 0x01, // Slower speed
|
||||
CM_SMALL_ARGB_SPEED_NORMAL = 0x02, // Normal speed
|
||||
CM_SMALL_ARGB_SPEED_FAST = 0x03, // Fast speed
|
||||
CM_SMALL_ARGB_SPEED_FASTEST = 0x04, // Fastest speed
|
||||
};
|
||||
|
||||
class CMSmallARGBController
|
||||
{
|
||||
public:
|
||||
CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
|
||||
~CMSmallARGBController();
|
||||
|
||||
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();
|
||||
bool GetRandomColours();
|
||||
|
||||
void SetLedCount(int zone, int led_count);
|
||||
void SetMode(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours);
|
||||
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 char current_brightness;
|
||||
bool bool_random;
|
||||
|
||||
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,22 +1,26 @@
|
||||
#include "Detector.h"
|
||||
#include "CMMP750Controller.h"
|
||||
#include "CMARGBcontroller.h"
|
||||
#include "CMSmallARGBController.h"
|
||||
#include "CMR6000Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include "RGBController_CMARGBController.h"
|
||||
#include "RGBController_CMSmallARGBController.h"
|
||||
#include "RGBController_CMR6000Controller.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
|
||||
#define COOLERMASTER_SMALL_ARGB_PID 0x1000
|
||||
#define COOLERMASTER_RADEON_6000_PID 0x014D
|
||||
|
||||
#define COOLERMASTER_NUM_DEVICES (sizeof(cm_pids) / sizeof(cm_pids[ 0 ]))
|
||||
|
||||
enum
|
||||
{
|
||||
CM_PID = 0,
|
||||
CM_INTERFACE = 1
|
||||
};
|
||||
|
||||
static const unsigned int cm_pids[][4] =
|
||||
{ // PID, Interface
|
||||
{ COOLERMASTER_MP750_XL_PID, 0x00 }, //Coolermaster MP750 (Extra Large)
|
||||
{ COOLERMASTER_MP750_MEDIUM_PID, 0x00 } //Coolermaster MP750 (Medium)
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -26,59 +30,37 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCoolerMasterMousemats(hid_device_info* info, const std::string&)
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
hid_device_info* info;
|
||||
|
||||
void DetectCoolerMasterARGB(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
//Look for the passed in cm_pids
|
||||
hid_init();
|
||||
info = hid_enumerate(COOLERMASTER_VID, 0x0);
|
||||
|
||||
while(info)
|
||||
{
|
||||
for(std::size_t i = 0; i < CM_ARGB_HEADER_DATA_SIZE; i++)
|
||||
hid_device* dev = NULL;
|
||||
if(info->vendor_id == COOLERMASTER_VID)
|
||||
{
|
||||
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);
|
||||
for(int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
|
||||
{
|
||||
if((info->product_id == cm_pids[cm_pid_idx][CM_PID])
|
||||
&&(info->interface_number == cm_pids[cm_pid_idx][CM_INTERFACE]))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DetectCoolerMasterSmallARGB(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0);
|
||||
RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
if(dev)
|
||||
{
|
||||
CMMP750Controller* controller = new CMMP750Controller(dev, info->manufacturer_string, info->product_string, info->path);
|
||||
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
hid_free_enumeration(info);
|
||||
}
|
||||
|
||||
void DetectCoolerMasterGPU(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
CMR6000Controller* controller = new CMR6000Controller(dev, info->path);
|
||||
RGBController_CMR6000Controller* rgb_controller = new RGBController_CMR6000Controller(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_PU ("Cooler Master MP750 XL", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_XL_PID, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_PU ("Cooler Master MP750 Medium", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_MEDIUM_PID, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master ARGB", DetectCoolerMasterARGB, COOLERMASTER_VID, COOLERMASTER_ARGB_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master Smalll ARGB", DetectCoolerMasterSmallARGB, COOLERMASTER_VID, COOLERMASTER_SMALL_ARGB_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_I ("Cooler Master Radeon 6000 GPU", DetectCoolerMasterGPU, COOLERMASTER_VID, COOLERMASTER_RADEON_6000_PID, 1);
|
||||
|
||||
@@ -1,386 +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 = "2.0 for FW0023";
|
||||
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_MODE_SPECIFIC;
|
||||
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(Recoil.colors_max);
|
||||
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Recoil.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
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(Breathing.colors_max);
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
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(Refill.colors_max);
|
||||
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Refill.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
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 Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_ARGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(Static.colors_max);
|
||||
Static.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Static.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.speed = speed;
|
||||
modes.push_back(Static);
|
||||
|
||||
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.flags = 0;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_RGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(Static.colors_max);
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.speed = 0;
|
||||
modes.push_back(Static);
|
||||
|
||||
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_MODE_SPECIFIC;
|
||||
Breathing.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flash;
|
||||
Flash.name = "Flash";
|
||||
Flash.value = CM_RGB_MODE_FLASH;
|
||||
Flash.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Flash.colors_min = 1;
|
||||
Flash.colors_max = 1;
|
||||
Flash.colors.resize(Flash.colors_max);
|
||||
Flash.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Flash.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Flash.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flash.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Flash);
|
||||
|
||||
mode Mirage;
|
||||
Mirage.name = "Mirage";
|
||||
Mirage.value = CM_RGB_MODE_MIRAGE;
|
||||
Mirage.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Mirage.colors_min = 1;
|
||||
Mirage.colors_max = 1;
|
||||
Mirage.colors.resize(Mirage.colors_max);
|
||||
Mirage.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Mirage.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Mirage.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Mirage.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Mirage);
|
||||
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_RGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_RGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
Init_Controller();
|
||||
SetupZones();
|
||||
|
||||
int temp_mode = cmargb->GetMode();
|
||||
for(std::size_t mode_idx = 0; mode_idx < modes.size() ; mode_idx++)
|
||||
{
|
||||
if (temp_mode == modes[mode_idx].value)
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(cmargb->GetLedRed(), cmargb->GetLedGreen(), cmargb->GetLedBlue());
|
||||
}
|
||||
modes[active_mode].color_mode = (cmargb->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = cmargb->GetLedSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CMARGBController::~RGBController_CMARGBController()
|
||||
{
|
||||
delete cmargb;
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = cmargb->GetZoneIndex();
|
||||
int zone_led_count = argb_header_data[zone_idx].count;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If argb_header_data[zone_idx].count == 1 then the |
|
||||
| zone is ZONE_TYPE_SINGLE |
|
||||
\*-------------------------------------------------*/
|
||||
bool boolSingleLED = ( zone_led_count == 1 );
|
||||
|
||||
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 = 4;
|
||||
ARGB_zone.leds_max = 48;
|
||||
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);
|
||||
|
||||
if (!boolSingleLED)
|
||||
{
|
||||
cmargb->SetLedCount( std::stoi(zones[zone_idx].name), zones[zone_idx].leds_count);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
uint8_t end_zone = last_zone(zone);
|
||||
|
||||
for(std::size_t zone_idx = first_zone(zone); zone_idx < end_zone; zone_idx++)
|
||||
{
|
||||
if(((unsigned int)new_size >= zones[zone_idx].leds_min) && ((unsigned int)new_size <= zones[zone_idx].leds_max))
|
||||
{
|
||||
zones[zone_idx].leds_count = new_size;
|
||||
}
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
uint8_t end_zone = last_zone(cmargb->GetZoneIndex());
|
||||
|
||||
for(std::size_t zone_idx = first_zone(cmargb->GetZoneIndex()); zone_idx < end_zone; zone_idx++)
|
||||
{
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
//cmargb->SetLedsDirect( zones[zone].colors, zones[zone].leds_count );
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(GetLED_Zone(led));
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::SetCustomMode()
|
||||
{
|
||||
for(std::size_t mode_idx = 0; mode_idx < modes.size() ; mode_idx++)
|
||||
{
|
||||
if (modes[mode_idx].value == CM_ARGB_MODE_DIRECT)
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateMode()
|
||||
{
|
||||
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
RGBColor colour = (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) ? modes[active_mode].colors[0] : 0;
|
||||
|
||||
cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed, colour, random_colours );
|
||||
}
|
||||
|
||||
int RGBController_CMARGBController::GetLED_Zone(int led_idx)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This may be more useful in the abstract RGBController.cpp |
|
||||
\*---------------------------------------------------------*/
|
||||
for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
int zone_start = zones[zone_idx].start_idx;
|
||||
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
|
||||
|
||||
if( zone_start <= led_idx && zone_end >= led_idx)
|
||||
{
|
||||
return(zone_idx);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -1,40 +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>
|
||||
|
||||
#define first_zone(zn) ((zones.size() > 1) ? 1 : 0)
|
||||
#define last_zone(zn) ((zones.size() > 1) ? 4 : 1)
|
||||
|
||||
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();
|
||||
int GetLED_Zone(int led_idx);
|
||||
|
||||
CMARGBController* cmargb;
|
||||
};
|
||||
@@ -1,149 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMR6000Controller.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster based AMD Radeon GPU (6000 series) |
|
||||
| |
|
||||
| Eric S (edbgon) 2nd Feb 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMR6000Controller.h"
|
||||
|
||||
RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controller* cmmp_ptr)
|
||||
{
|
||||
cmr6000 = cmmp_ptr;
|
||||
unsigned char speed = cmr6000->GetLedSpeed();
|
||||
|
||||
name = "AMD RX 6xxx GPU";
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_GPU;
|
||||
description = cmr6000->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = cmr6000->GetSerial();
|
||||
location = cmr6000->GetLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.flags = 0;
|
||||
Off.value = CM_MR6000_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_MR6000_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = CM_MR6000_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
ColorCycle.speed_min = MR6000_CYCLE_SPEED_SLOWEST;
|
||||
ColorCycle.speed = MR6000_CYCLE_SPEED_NORMAL;
|
||||
ColorCycle.speed_max = MR6000_CYCLE_SPEED_FASTEST;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
ColorCycle.speed = speed;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_MR6000_MODE_BREATHE;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.speed_min = MR6000_BREATHE_SPEED_SLOWEST;
|
||||
Breathing.speed = MR6000_BREATHE_SPEED_NORMAL;
|
||||
Breathing.speed_max = MR6000_BREATHE_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
active_mode = cmr6000->GetMode();
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(cmr6000->GetLedRed(), cmr6000->GetLedGreen(), cmr6000->GetLedBlue());
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_RANDOM_COLOR)
|
||||
{
|
||||
modes[active_mode].color_mode = (cmr6000->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = cmr6000->GetLedSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CMR6000Controller::~RGBController_CMR6000Controller()
|
||||
{
|
||||
delete cmr6000;
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::SetupZones()
|
||||
{
|
||||
zone GP_zone;
|
||||
GP_zone.name = "GPU";
|
||||
GP_zone.type = ZONE_TYPE_SINGLE;
|
||||
GP_zone.leds_min = 1;
|
||||
GP_zone.leds_max = 1;
|
||||
GP_zone.leds_count = 1;
|
||||
GP_zone.matrix_map = NULL;
|
||||
zones.push_back(GP_zone);
|
||||
|
||||
led GP_led;
|
||||
GP_led.name = "Logo";
|
||||
leds.push_back(GP_led);
|
||||
|
||||
SetupColors();
|
||||
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::DeviceUpdateLEDs()
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
unsigned char rnd = (modes[active_mode].color_mode == MODE_COLORS_RANDOM) ? 0xA0 : 0x20;
|
||||
|
||||
cmr6000->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu, rnd);
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
void RGBController_CMR6000Controller::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMR6000Controller.h |
|
||||
| |
|
||||
| Driver for Coolermaster based AMD Radeon GPU (6000 series) |
|
||||
| |
|
||||
| Eric S (edbgon) 2nd Feb 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMR6000Controller.h"
|
||||
|
||||
class RGBController_CMR6000Controller : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMR6000Controller(CMR6000Controller* cmmp_ptr);
|
||||
~RGBController_CMR6000Controller();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
private:
|
||||
CMR6000Controller* cmr6000;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
@@ -1,251 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMSmallARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMSmallARGBController.h"
|
||||
|
||||
RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmallARGBController *cmargb_ptr)
|
||||
{
|
||||
cmargb = cmargb_ptr;
|
||||
unsigned char speed = cmargb->GetLedSpeed();
|
||||
|
||||
name = small_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();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_SMALL_ARGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Reload;
|
||||
Reload.name = "Reload";
|
||||
Reload.value = CM_SMALL_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_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Reload.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Reload.color_mode = MODE_COLORS_RANDOM;
|
||||
Reload.speed = speed;
|
||||
modes.push_back(Reload);
|
||||
|
||||
mode Recoil;
|
||||
Recoil.name = "Recoil";
|
||||
Recoil.value = CM_SMALL_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(Recoil.colors_max);
|
||||
Recoil.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Recoil.color_mode = MODE_COLORS_RANDOM;
|
||||
Recoil.speed = speed;
|
||||
modes.push_back(Recoil);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_SMALL_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(Breathing.colors_max);
|
||||
Breathing.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_RANDOM;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Refill;
|
||||
Refill.name = "Refill";
|
||||
Refill.value = CM_SMALL_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(Refill.colors_max);
|
||||
Refill.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Refill.color_mode = MODE_COLORS_RANDOM;
|
||||
Refill.speed = speed;
|
||||
modes.push_back(Refill);
|
||||
|
||||
mode Demo;
|
||||
Demo.name = "Demo";
|
||||
Demo.value = CM_SMALL_ARGB_MODE_DEMO;
|
||||
Demo.flags = MODE_FLAG_HAS_SPEED;
|
||||
Demo.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Demo.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Demo.color_mode = MODE_COLORS_NONE;
|
||||
Demo.speed = speed;
|
||||
modes.push_back(Demo);
|
||||
|
||||
mode Spectrum;
|
||||
Spectrum.name = "Spectrum";
|
||||
Spectrum.value = CM_SMALL_ARGB_MODE_SPECTRUM;
|
||||
Spectrum.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spectrum.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Spectrum.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Spectrum.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum.speed = speed;
|
||||
modes.push_back(Spectrum);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = CM_SMALL_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_SMALL_ARGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
Init_Controller(); //Only processed on first run
|
||||
SetupZones();
|
||||
|
||||
int temp_mode = cmargb->GetMode();
|
||||
for(std::size_t mode_idx = 0; mode_idx < modes.size() ; mode_idx++)
|
||||
{
|
||||
if (temp_mode == modes[mode_idx].value)
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(cmargb->GetLedRed(), cmargb->GetLedGreen(), cmargb->GetLedBlue());
|
||||
}
|
||||
modes[active_mode].color_mode = (cmargb->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = cmargb->GetLedSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CMSmallARGBController::~RGBController_CMSmallARGBController()
|
||||
{
|
||||
delete cmargb;
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = cmargb->GetZoneIndex();
|
||||
int zone_led_count = small_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 = CM_SMALL_ARGB_MIN_LEDS;
|
||||
ARGB_zone.leds_max = CM_SMALL_ARGB_MAX_LEDS;
|
||||
ARGB_zone.leds_count = zone_led_count;
|
||||
ARGB_zone.matrix_map = NULL;
|
||||
zones.push_back(ARGB_zone);
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::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
|
||||
|
||||
if (!boolSingleLED)
|
||||
{
|
||||
cmargb->SetLedCount(small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
|
||||
}
|
||||
|
||||
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 = small_argb_header_data[i].header;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.name.append(" LED " + std::to_string(lp_idx));
|
||||
new_led.value = small_argb_header_data[i].header;
|
||||
}
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::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_CMSmallARGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
//cmargb->SetLedsDirect(zones[zone].colors, random_colours);
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::UpdateSingleLED(int led)
|
||||
{
|
||||
//cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed );
|
||||
//cmargb->SetLedsDirect( zones[0].colors, zones[0].leds_count );
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::SetCustomMode()
|
||||
{
|
||||
active_mode = CM_SMALL_ARGB_MODE_DIRECT; //The small ARGB may not support "Direct" mode
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::DeviceUpdateMode()
|
||||
{
|
||||
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
RGBColor colour = (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) ? modes[active_mode].colors[0] : 0;
|
||||
|
||||
cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed, colour, random_colours );
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMSmallARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMSmallARGBController.h"
|
||||
#include <vector>
|
||||
|
||||
#define CM_SMALL_ARGB_MIN_LEDS 4
|
||||
#define CM_SMALL_ARGB_MAX_LEDS 48
|
||||
|
||||
class RGBController_CMSmallARGBController : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMSmallARGBController(CMSmallARGBController* cmargb_ptr);
|
||||
~RGBController_CMSmallARGBController();
|
||||
|
||||
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();
|
||||
|
||||
CMSmallARGBController* cmargb;
|
||||
};
|
||||
-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)
|
||||
{
|
||||
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);
|
||||
ResourceManager::get()->RegisterRGBController(new_rgbcontroller);
|
||||
}
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_I2C_DETECTOR("Corsair Dominator Platinum", DetectCorsairDominatorPlatinumControllers);
|
||||
-114
@@ -1,114 +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;
|
||||
}
|
||||
|
||||
RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum()
|
||||
{
|
||||
delete corsair;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +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);
|
||||
~RGBController_CorsairDominatorPlatinum();
|
||||
|
||||
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,276 +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();
|
||||
}
|
||||
|
||||
CorsairHydroController::~CorsairHydroController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
libusb_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
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,77 +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_init(NULL);
|
||||
|
||||
#ifdef _WIN32
|
||||
libusb_set_option(NULL, 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(NULL, 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,143 +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();
|
||||
}
|
||||
|
||||
RGBController_CorsairHydro::~RGBController_CorsairHydro()
|
||||
{
|
||||
delete corsair;
|
||||
}
|
||||
|
||||
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,33 +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);
|
||||
~RGBController_CorsairHydro();
|
||||
|
||||
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;
|
||||
};
|
||||
@@ -1,245 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CorsairHydroPlatinumController.cpp |
|
||||
| |
|
||||
| Driver for Corsair Hydro Platinum AIO Coolers |
|
||||
| |
|
||||
| Kasper 28th March 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CorsairHydroPlatinumController.h"
|
||||
#include <cstring>
|
||||
|
||||
static const uint8_t CRC_TABLE[256] =
|
||||
{
|
||||
0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15,
|
||||
0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
|
||||
0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65,
|
||||
0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
|
||||
0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5,
|
||||
0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
|
||||
0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85,
|
||||
0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
|
||||
0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2,
|
||||
0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
|
||||
0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2,
|
||||
0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
|
||||
0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32,
|
||||
0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
|
||||
0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42,
|
||||
0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
|
||||
0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C,
|
||||
0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
|
||||
0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC,
|
||||
0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
|
||||
0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C,
|
||||
0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
|
||||
0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C,
|
||||
0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
|
||||
0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B,
|
||||
0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
|
||||
0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B,
|
||||
0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
|
||||
0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB,
|
||||
0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
|
||||
0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB,
|
||||
0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
|
||||
};
|
||||
|
||||
static const uint8_t MAGIC_1[61] =
|
||||
{
|
||||
0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
|
||||
0x7f, 0x7f, 0x7f, 0xff, 0x00, 0xff, 0xff, 0xff,
|
||||
0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
static const uint8_t MAGIC_2[61] =
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
||||
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
static const uint8_t MAGIC_3[61] =
|
||||
{
|
||||
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff
|
||||
};
|
||||
|
||||
CorsairHydroPlatinumController::CorsairHydroPlatinumController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
SendMagic(MAGIC_1, CORSAIR_HYDRO_PLATINUM_MAGIC_1);
|
||||
SendMagic(MAGIC_2, CORSAIR_HYDRO_PLATINUM_MAGIC_2);
|
||||
SendMagic(MAGIC_3, CORSAIR_HYDRO_PLATINUM_MAGIC_3);
|
||||
}
|
||||
|
||||
CorsairHydroPlatinumController::~CorsairHydroPlatinumController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CorsairHydroPlatinumController::GetLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
std::string CorsairHydroPlatinumController::GetFirmwareString()
|
||||
{
|
||||
return firmware_version;
|
||||
}
|
||||
|
||||
void CorsairHydroPlatinumController::SetupColors(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned int end_led = colors.size() >= 20 ? 20 : colors.size();
|
||||
SendColors(colors, 0, end_led, CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_1);
|
||||
|
||||
if(colors.size() > 20)
|
||||
{
|
||||
end_led = colors.size() >= 40 ? 40 : colors.size();
|
||||
SendColors(colors, 20, end_led, CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_2);
|
||||
}
|
||||
if(colors.size() > 40)
|
||||
{
|
||||
end_led = colors.size() >= 48 ? 48 : colors.size();
|
||||
SendColors(colors, 40, end_led, CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_3);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairHydroPlatinumController::SendMagic(const uint8_t* magic, unsigned int command)
|
||||
{
|
||||
unsigned char usb_buf[CORSAIR_HYDRO_PLATINUM_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x3F;
|
||||
usb_buf[0x02] = (GetSequenceNumber()) | command;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the magic bytes into the buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[3], magic, 61 * sizeof magic[0]);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The data sent to the PEC function should not contain |
|
||||
| the first (report id), second (prefix) and |
|
||||
| last (checksum) bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<unsigned char> checksum_array;
|
||||
checksum_array.insert(checksum_array.begin(), std::begin(usb_buf) + 2, std::end(usb_buf) - 1);
|
||||
usb_buf[64] = ComputePEC(static_cast<void*>(checksum_array.data()), 62);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, CORSAIR_HYDRO_PLATINUM_PACKET_SIZE);
|
||||
hid_read(dev, usb_buf, CORSAIR_HYDRO_PLATINUM_PACKET_SIZE);
|
||||
|
||||
if(firmware_version.empty())
|
||||
{
|
||||
firmware_version =
|
||||
std::to_string(usb_buf[2] >> 4) + "."
|
||||
+ std::to_string(usb_buf[2] & 0xf) + "."
|
||||
+ std::to_string(usb_buf[3]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| This delay prevents the AIO from soft-locking when |
|
||||
| using an EE. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(CORSAIR_HYDRO_PLATINUM_PACKET_DELAY));
|
||||
}
|
||||
|
||||
void CorsairHydroPlatinumController::SendColors(std::vector<RGBColor> colors, unsigned int start, unsigned int end, unsigned int command)
|
||||
{
|
||||
unsigned char usb_buf[CORSAIR_HYDRO_PLATINUM_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, CORSAIR_HYDRO_PLATINUM_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x3F;
|
||||
usb_buf[0x02] = (GetSequenceNumber()) | command;
|
||||
|
||||
unsigned int i = 0;
|
||||
for(std::size_t color_idx = start; color_idx < end; color_idx++)
|
||||
{
|
||||
usb_buf[(i * 3) + 3] = RGBGetBValue(colors[color_idx]);
|
||||
usb_buf[(i * 3) + 4] = RGBGetGValue(colors[color_idx]);
|
||||
usb_buf[(i * 3) + 5] = RGBGetRValue(colors[color_idx]);
|
||||
i++;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The data sent to the PEC function should not contain |
|
||||
| the first (report id), second (prefix) and |
|
||||
| last (checksum) bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<unsigned char> checksum_array;
|
||||
checksum_array.insert(checksum_array.begin(), std::begin(usb_buf) + 2, std::end(usb_buf) - 1);
|
||||
usb_buf[64] = ComputePEC(static_cast<void*>(checksum_array.data()), 62);
|
||||
|
||||
hid_write(dev, usb_buf, CORSAIR_HYDRO_PLATINUM_PACKET_SIZE);
|
||||
hid_read(dev, usb_buf, CORSAIR_HYDRO_PLATINUM_PACKET_SIZE);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| This delay prevents the AIO from soft-locking when |
|
||||
| using an EE. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(CORSAIR_HYDRO_PLATINUM_PACKET_DELAY));
|
||||
}
|
||||
|
||||
unsigned int CorsairHydroPlatinumController::GetSequenceNumber()
|
||||
{
|
||||
if(sequence_number < 31)
|
||||
{
|
||||
sequence_number++;
|
||||
}
|
||||
else
|
||||
{
|
||||
sequence_number = 1;
|
||||
}
|
||||
|
||||
return(sequence_number << 3);
|
||||
}
|
||||
|
||||
uint8_t CorsairHydroPlatinumController::ComputePEC(const void * data, size_t size)
|
||||
{
|
||||
uint8_t val = 0;
|
||||
|
||||
uint8_t * pos = (uint8_t *) data;
|
||||
uint8_t * end = pos + size;
|
||||
|
||||
while (pos < end)
|
||||
{
|
||||
val = CRC_TABLE[val ^ *pos];
|
||||
pos++;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CorsairHydroPlatinumController.h |
|
||||
| |
|
||||
| Driver for Corsair Hydro Platinum AIO Coolers |
|
||||
| |
|
||||
| Kasper 28th March 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define CORSAIR_HYDRO_PLATINUM_PACKET_SIZE 65
|
||||
#define CORSAIR_HYDRO_PLATINUM_PACKET_DELAY 3
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_HYDRO_PLATINUM_MAGIC_1 = 0b001,
|
||||
CORSAIR_HYDRO_PLATINUM_MAGIC_2 = 0b010,
|
||||
CORSAIR_HYDRO_PLATINUM_MAGIC_3 = 0b011,
|
||||
|
||||
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_1 = 0b100,
|
||||
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_2 = 0b101,
|
||||
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_3 = 0b110,
|
||||
};
|
||||
|
||||
class CorsairHydroPlatinumController
|
||||
{
|
||||
public:
|
||||
CorsairHydroPlatinumController(hid_device* dev_handle, const char* path);
|
||||
~CorsairHydroPlatinumController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetFirmwareString();
|
||||
void SetupColors(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string firmware_version;
|
||||
|
||||
std::atomic<unsigned int> sequence_number;
|
||||
|
||||
void SendMagic(const uint8_t* magic, unsigned int command);
|
||||
void SendColors(std::vector<RGBColor> colors, unsigned int start, unsigned int end, unsigned int command);
|
||||
unsigned int GetSequenceNumber();
|
||||
uint8_t ComputePEC(const void * data, size_t size);
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| CorsairHydroPlatinumControllerDetect.cpp |
|
||||
| |
|
||||
| Driver for Corsair Hydro Platinum AIO Coolers |
|
||||
| |
|
||||
| Kasper 28th March 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "CorsairHydroPlatinumController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairHydroPlatinum.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Corsair vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_HYDRO_H100I_PLATINUM_PID 0x0c18
|
||||
#define CORSAIR_HYDRO_H100I_PLATINUM_SE_PID 0x0C19
|
||||
#define CORSAIR_HYDRO_H115I_PLATINUM_PID 0x0c17
|
||||
#define CORSAIR_HYDRO_H100I_PRO_XT_PID 0x0c20
|
||||
#define CORSAIR_HYDRO_H115I_PRO_XT_PID 0x0c21
|
||||
#define CORSAIR_HYDRO_H150I_PRO_XT_PID 0x0c22
|
||||
|
||||
void DetectCorsairHydroPlatinumControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairHydroPlatinumController* controller = new CorsairHydroPlatinumController(dev, info->path);
|
||||
RGBController_CorsairHydroPlatinum* rgb_controller = new RGBController_CorsairHydroPlatinum(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_PID );
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H100i Platinum SE", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PLATINUM_SE_PID );
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H115i Platinum", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PLATINUM_PID );
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H100i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H100I_PRO_XT_PID );
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H115i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H115I_PRO_XT_PID );
|
||||
REGISTER_HID_DETECTOR("Corsair Hydro H150i Pro XT", DetectCorsairHydroPlatinumControllers, CORSAIR_VID, CORSAIR_HYDRO_H150I_PRO_XT_PID );
|
||||
@@ -1,127 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CorsairHydroPlatinum.cpp |
|
||||
| |
|
||||
| Driver for Corsair Hydro Platinum AIO Coolers |
|
||||
| |
|
||||
| Kasper 28th March 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairHydroPlatinum.h"
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
static unsigned int matrix_map[5][5] =
|
||||
{
|
||||
{ NA, 11, 12, 13, NA },
|
||||
{ 10, NA, 1, NA, 14 },
|
||||
{ 9, 0, NA, 2, 15 },
|
||||
{ 8, NA, 3, NA, 4 },
|
||||
{ NA, 7, 6, 5, NA }
|
||||
};
|
||||
|
||||
RGBController_CorsairHydroPlatinum::RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = "Corsair Hydro Platinum Series Device";
|
||||
vendor = "Corsair";
|
||||
description = "Corsair Hydro Platinum Series Device";
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
location = corsair->GetLocation();
|
||||
version = corsair->GetFirmwareString();
|
||||
|
||||
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);
|
||||
|
||||
Init_Controller();
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::Init_Controller()
|
||||
{
|
||||
zone cpu_block_zone;
|
||||
cpu_block_zone.name = "CPU Block";
|
||||
cpu_block_zone.type = ZONE_TYPE_MATRIX;
|
||||
cpu_block_zone.leds_min = 16;
|
||||
cpu_block_zone.leds_max = 16;
|
||||
cpu_block_zone.leds_count = 16;
|
||||
cpu_block_zone.matrix_map = new matrix_map_type;
|
||||
cpu_block_zone.matrix_map->height = 5;
|
||||
cpu_block_zone.matrix_map->width = 5;
|
||||
cpu_block_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
zones.push_back(cpu_block_zone);
|
||||
|
||||
zone fans_zone;
|
||||
fans_zone.name = "Fans";
|
||||
fans_zone.type = ZONE_TYPE_LINEAR;
|
||||
fans_zone.leds_min = 0;
|
||||
fans_zone.leds_max = 32;
|
||||
fans_zone.leds_count = 0;
|
||||
fans_zone.matrix_map = NULL;
|
||||
zones.push_back(fans_zone);
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
for (unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::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_CorsairHydroPlatinum::DeviceUpdateLEDs()
|
||||
{
|
||||
corsair->SetupColors(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CorsairHydroPlatinum::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CorsairHydroPlatinum.h |
|
||||
| |
|
||||
| Driver for Corsair Hydro Platinum AIO Coolers |
|
||||
| |
|
||||
| Kasper 28th March 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CorsairHydroPlatinumController.h"
|
||||
|
||||
class RGBController_CorsairHydroPlatinum : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairHydroPlatinum(CorsairHydroPlatinumController* 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:
|
||||
CorsairHydroPlatinumController* corsair;
|
||||
|
||||
void Init_Controller();
|
||||
};
|
||||
@@ -11,12 +11,35 @@
|
||||
#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
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
CorsairLightingNodeController::CorsairLightingNodeController(hid_device* dev_handle, const char* path)
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
CorsairLightingNodeController* corsair = static_cast<CorsairLightingNodeController*>(param);
|
||||
corsair->KeepaliveThread();
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairLightingNodeController::CorsairLightingNodeController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
SendFirmwareRequest();
|
||||
|
||||
@@ -26,22 +49,21 @@ 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()
|
||||
{
|
||||
keepalive_thread_run = 0;
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::KeepaliveThread()
|
||||
{
|
||||
while(keepalive_thread_run.load())
|
||||
while(1)
|
||||
{
|
||||
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(5))
|
||||
{
|
||||
@@ -56,22 +78,6 @@ 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,
|
||||
unsigned char mode,
|
||||
|
||||
@@ -79,12 +79,10 @@ enum
|
||||
class CorsairLightingNodeController
|
||||
{
|
||||
public:
|
||||
CorsairLightingNodeController(hid_device* dev_handle, const char* path);
|
||||
CorsairLightingNodeController(hid_device* dev_handle);
|
||||
~CorsairLightingNodeController();
|
||||
|
||||
std::string GetFirmwareString();
|
||||
std::string GetLocationString();
|
||||
std::string GetSerialString();
|
||||
|
||||
unsigned int GetStripsOnChannel(unsigned int channel);
|
||||
|
||||
@@ -112,9 +110,6 @@ public:
|
||||
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();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairLightingNodeController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairLightingNode.h"
|
||||
@@ -12,7 +11,26 @@
|
||||
#define CORSAIR_LS100_PID 0x0C1E
|
||||
#define CORSAIR_1000D_OBSIDIAN_PID 0x1D00
|
||||
#define CORSAIR_SPEC_OMEGA_RGB_PID 0x1D04
|
||||
#define CORSAIR_LT100_PID 0x0C23
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char channel_count;
|
||||
const char * name;
|
||||
} corsair_node_device;
|
||||
|
||||
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const corsair_node_device device_list[] =
|
||||
{
|
||||
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID, 1, "Corsair Lighting Node Core" },
|
||||
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID, 2, "Corsair Lighting Node Pro" },
|
||||
{ CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID, 2, "Corsair Commander Pro" },
|
||||
{ CORSAIR_VID, CORSAIR_LS100_PID, 1, "Corsair LS100 Lighting Kit" },
|
||||
{ CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID, 2, "Corsair 1000D Obsidian" },
|
||||
{ CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID, 2, "Corsair SPEC OMEGA RGB" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -22,22 +40,40 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairLightingNodeControllers(hid_device_info* info, const std::string& name)
|
||||
void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, info->path);
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Corsair Lighting Node Devices
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev);
|
||||
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
} /* 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
|
||||
@@ -20,60 +20,22 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x
|
||||
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};
|
||||
|
||||
|
||||
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, 125,
|
||||
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};
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
|
||||
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle, const char* path)
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
dev = dev_handle;
|
||||
|
||||
ReadFirmwareInfo();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| K95 Platinum requires additional steps |
|
||||
\*-----------------------------------------------------*/
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
SpecialFunctionControl();
|
||||
}
|
||||
|
||||
LightingControl();
|
||||
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
SetupK95LightingControl();
|
||||
}
|
||||
}
|
||||
|
||||
CorsairPeripheralController::~CorsairPeripheralController()
|
||||
{
|
||||
hid_close(dev);
|
||||
|
||||
}
|
||||
|
||||
device_type CorsairPeripheralController::GetDeviceType()
|
||||
@@ -81,55 +43,17 @@ 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:
|
||||
if (logical_layout == CORSAIR_TYPE_K55)
|
||||
{
|
||||
SubmitKeyboardZonesColors(colors[0], colors[1], colors[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLEDsKeyboardFull(colors);
|
||||
}
|
||||
SetLEDsKeyboardFull(colors);
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
@@ -164,10 +88,9 @@ void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
|
||||
|
||||
void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_val[168];
|
||||
unsigned char grn_val[168];
|
||||
unsigned char blu_val[168];
|
||||
unsigned char data_sz = 24;
|
||||
unsigned char red_val[144];
|
||||
unsigned char grn_val[144];
|
||||
unsigned char blu_val[144];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
@@ -182,26 +105,9 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
|
||||
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);
|
||||
data_sz = 48;
|
||||
}
|
||||
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);
|
||||
data_sz = 48; //untested
|
||||
}
|
||||
else
|
||||
{
|
||||
red_val[keys[color_idx]] = RGBGetRValue(color);
|
||||
grn_val[keys[color_idx]] = RGBGetGValue(color);
|
||||
blu_val[keys[color_idx]] = RGBGetBValue(color);
|
||||
}
|
||||
red_val[keys[color_idx]] = RGBGetRValue(color);
|
||||
grn_val[keys[color_idx]] = RGBGetGValue(color);
|
||||
blu_val[keys[color_idx]] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -209,7 +115,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &red_val[0]);
|
||||
StreamPacket(2, 60, &red_val[60]);
|
||||
StreamPacket(3, data_sz, &red_val[120]);
|
||||
StreamPacket(3, 24, &red_val[120]);
|
||||
SubmitKeyboardFullColors(1, 3, 1);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -217,7 +123,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &grn_val[0]);
|
||||
StreamPacket(2, 60, &grn_val[60]);
|
||||
StreamPacket(3, data_sz, &grn_val[120]);
|
||||
StreamPacket(3, 24, &grn_val[120]);
|
||||
SubmitKeyboardFullColors(2, 3, 1);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -225,11 +131,10 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
|
||||
\*-----------------------------------------------------*/
|
||||
StreamPacket(1, 60, &blu_val[0]);
|
||||
StreamPacket(2, 60, &blu_val[60]);
|
||||
StreamPacket(3, data_sz, &blu_val[120]);
|
||||
StreamPacket(3, 24, &blu_val[120]);
|
||||
SubmitKeyboardFullColors(3, 3, 2);
|
||||
}
|
||||
|
||||
|
||||
void CorsairPeripheralController::SetLEDsMouse(std::vector<RGBColor> colors)
|
||||
{
|
||||
SubmitMouseColors(colors.size(), &colors[0]);
|
||||
@@ -307,11 +212,6 @@ void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> c
|
||||
SubmitKeyboardLimitedColors(216);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SetName(std::string device_name)
|
||||
{
|
||||
name = device_name;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
@@ -341,7 +241,7 @@ void CorsairPeripheralController::LightingControl()
|
||||
{
|
||||
default:
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
usb_buf[0x05] = 0x03; // On K95 Platinum, this controls keyboard brightness
|
||||
usb_buf[0x05] = 0x03;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
@@ -363,70 +263,6 @@ void CorsairPeripheralController::LightingControl()
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Probably a key mapping packet? |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
void CorsairPeripheralController::SetupK95LightingControl()
|
||||
{
|
||||
char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up a packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x02] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
|
||||
usb_buf[0x03] = 0x08;
|
||||
|
||||
usb_buf[0x05] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
|
||||
int identifier = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up a packet - a sequence of 120 ids |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
|
||||
usb_buf[0x02] = 0x40;
|
||||
usb_buf[0x03] = 0x1E;
|
||||
|
||||
for (int j = 0; j < 30; j++)
|
||||
{
|
||||
while (identifier == 0x31 || identifier == 0x41 || identifier == 0x42 || identifier == 0x48
|
||||
|| identifier == 0x49 || identifier == 0x51 || identifier == 0x55 || identifier == 0x6f
|
||||
|| identifier == 0x7e || identifier == 0x7f || identifier == 0x80 || identifier == 0x81)
|
||||
{
|
||||
identifier++;
|
||||
}
|
||||
|
||||
usb_buf[5 + 2 * j] = identifier++;
|
||||
usb_buf[5 + 2 * j + 1] = 0xC0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SpecialFunctionControl()
|
||||
{
|
||||
char usb_buf[65];
|
||||
@@ -504,57 +340,6 @@ void CorsairPeripheralController::ReadFirmwareInfo()
|
||||
switch((unsigned char)usb_buf[0x14 + offset])
|
||||
{
|
||||
case 0xC0:
|
||||
{
|
||||
unsigned short pid = (unsigned short)(usb_buf[0x0E] << 8) + (unsigned char)(usb_buf[0x0F]);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the correct Keyboard Type |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(pid)
|
||||
{
|
||||
case 0x1B2D:
|
||||
logical_layout = CORSAIR_TYPE_K95_PLAT;
|
||||
break;
|
||||
|
||||
case 0x1B11:
|
||||
logical_layout = CORSAIR_TYPE_K95;
|
||||
break;
|
||||
|
||||
case 0x1B3D:
|
||||
logical_layout = CORSAIR_TYPE_K55;
|
||||
SpecialFunctionControl();
|
||||
break;
|
||||
|
||||
default:
|
||||
logical_layout = CORSAIR_TYPE_NORMAL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get the correct Keyboard Layout. |
|
||||
| Currently unused but can be implemented in the future.|
|
||||
\*-----------------------------------------------------*/
|
||||
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;
|
||||
case CORSAIR_LAYOUT_ABNT:
|
||||
physical_layout = CORSAIR_LAYOUT_ABNT;
|
||||
break;
|
||||
case CORSAIR_LAYOUT_JIS:
|
||||
physical_layout = CORSAIR_LAYOUT_JIS;
|
||||
break;
|
||||
case CORSAIR_LAYOUT_DUBEOLSIK:
|
||||
physical_layout = CORSAIR_LAYOUT_DUBEOLSIK;
|
||||
break;
|
||||
default:
|
||||
physical_layout = CORSAIR_LAYOUT_ANSI;
|
||||
}
|
||||
|
||||
}
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
break;
|
||||
|
||||
@@ -659,44 +444,6 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardZonesColors
|
||||
(
|
||||
RGBColor left,
|
||||
RGBColor mid,
|
||||
RGBColor right
|
||||
)
|
||||
{
|
||||
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_KBZONES_COLOR_24;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = RGBGetRValue(left);
|
||||
usb_buf[0x06] = RGBGetGValue(left);
|
||||
usb_buf[0x07] = RGBGetBValue(left);
|
||||
usb_buf[0x08] = RGBGetRValue(mid);
|
||||
usb_buf[0x09] = RGBGetGValue(mid);
|
||||
usb_buf[0x0A] = RGBGetBValue(mid);
|
||||
usb_buf[0x0B] = RGBGetRValue(right);
|
||||
usb_buf[0x0C] = RGBGetGValue(right);
|
||||
usb_buf[0x0D] = RGBGetBValue(right);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 65);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
|
||||
@@ -30,7 +30,6 @@ enum
|
||||
CORSAIR_PROPERTY_LIGHTING_CONTROL = 0x05,
|
||||
CORSAIR_PROPERTY_HARDWARE_PROFILE = 0x13,
|
||||
CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR = 0x22,
|
||||
CORSAIR_PROPERTY_SUBMIT_KBZONES_COLOR_24 = 0x25,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9 = 0x27,
|
||||
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24 = 0x28,
|
||||
};
|
||||
@@ -48,56 +47,28 @@ enum
|
||||
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,
|
||||
CORSAIR_TYPE_K55 = 3
|
||||
};
|
||||
|
||||
class CorsairPeripheralController
|
||||
{
|
||||
public:
|
||||
CorsairPeripheralController(hid_device* dev_handle, const char* path);
|
||||
CorsairPeripheralController(hid_device* dev_handle);
|
||||
~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 SetupK95LightingControl();
|
||||
void SpecialFunctionControl();
|
||||
|
||||
void ReadFirmwareInfo();
|
||||
@@ -116,14 +87,6 @@ private:
|
||||
unsigned char finish_val
|
||||
);
|
||||
|
||||
void SubmitKeyboardZonesColors
|
||||
(
|
||||
RGBColor left,
|
||||
RGBColor mid,
|
||||
RGBColor right
|
||||
);
|
||||
|
||||
|
||||
void SubmitKeyboardLimitedColors
|
||||
(
|
||||
unsigned char byte_count
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "Detector.h"
|
||||
#include "CorsairPeripheralController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPeripheral.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -39,14 +39,11 @@
|
||||
| Mouse product IDs |
|
||||
| List taken from ckb-next |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_GLAIVE_RGB_PID 0x1B34
|
||||
#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 |
|
||||
@@ -60,6 +57,54 @@
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_ST100_PID 0x0A34
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
const char * name;
|
||||
} corsair_node_device;
|
||||
|
||||
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const corsair_node_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
// { CORSAIR_VID, CORSAIR_K55_RGB_PID, 1, "Corsair K55 RGB" }, //Not per-key, disabled for now
|
||||
{ CORSAIR_VID, CORSAIR_K65_RGB_PID, 1, "Corsair K65 RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K65_LUX_RGB_PID, 1, "Corsair K65 LUX RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K65_RGB_RAPIDFIRE_PID, 1, "Corsair K65 RGB RAPIDFIRE" },
|
||||
{ CORSAIR_VID, CORSAIR_K68_RGB, 1, "Corsair K68 RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_RGB_PID, 1, "Corsair K70 RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_LUX_RGB_PID, 1, "Corsair K70 LUX RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_RGB_RAPIDFIRE_PID, 1, "Corsair K70 RGB RAPIDFIRE" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_PID, 1, "Corsair K70 RGB MK.2" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_SE_PID, 1, "Corsair K70 RGB MK.2 SE" },
|
||||
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_LP_PID, 1, "Corsair K70 RGB MK.2 Low Profile" },
|
||||
{ CORSAIR_VID, CORSAIR_K95_RGB_PID, 1, "Corsair K95 RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_K95_PLATINUM_PID, 1, "Corsair K95 RGB PLATINUM" },
|
||||
{ CORSAIR_VID, CORSAIR_STRAFE_PID, 1, "Corsair Strafe" },
|
||||
{ CORSAIR_VID, CORSAIR_STRAFE_MK2_PID, 1, "Corsair Strafe MK.2" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_GLAIVE_RGB_PRO_PID, 1, "Corsair Glaive RGB PRO" },
|
||||
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PID, 1, "Corsair Harpoon RGB" },
|
||||
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PRO_PID, 1, "Corsair Harpoon RGB PRO" },
|
||||
{ CORSAIR_VID, CORSAIR_M65_PRO_PID, 1, "Corsair M65 PRO" },
|
||||
{ CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, "Corsair M65 RGB Elite" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0, "Corsair MM800 RGB Polaris" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Headset Stands |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_ST100_PID, 0, "Corsair ST100 RGB" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairPeripheralControllers *
|
||||
@@ -68,69 +113,48 @@
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string& name)
|
||||
void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
CorsairPeripheralController* controller = new CorsairPeripheralController(dev, info->path);
|
||||
controller->SetName(name);
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
|
||||
hid_init();
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Corsair RGB Peripheral
|
||||
while(info)
|
||||
{
|
||||
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete controller;
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
#ifdef USE_HID_USAGE
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->usage_page == 0xFFC2))
|
||||
#else
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
#endif
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
|
||||
|
||||
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
|
||||
{
|
||||
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
} /* 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", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_GLAIVE_RGB_PID, 1, 0xFFC2);
|
||||
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,893 +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, 119, 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[] =
|
||||
{
|
||||
120,
|
||||
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
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| K55 |
|
||||
\*---------------------------------------------------------*/
|
||||
static const char* zone_names_k55[] =
|
||||
{
|
||||
"Left",
|
||||
"Middle",
|
||||
"Right",
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes_k55[] =
|
||||
{
|
||||
1,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const zone_type zone_types_k55[] =
|
||||
{
|
||||
ZONE_TYPE_SINGLE,
|
||||
ZONE_TYPE_SINGLE,
|
||||
ZONE_TYPE_SINGLE
|
||||
};
|
||||
|
||||
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",
|
||||
"Key: Preset",
|
||||
"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* led_names_k55[] =
|
||||
{
|
||||
"LEFT",
|
||||
"MIDDLE",
|
||||
"RIGHT",
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
delete corsair;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
if (logical_layout == CORSAIR_TYPE_K55)
|
||||
{
|
||||
num_zones = 3;
|
||||
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 if (logical_layout == CORSAIR_TYPE_K55)
|
||||
{
|
||||
new_zone.name = zone_names_k55[zone_idx];
|
||||
new_zone.type = zone_types_k55[zone_idx];
|
||||
new_zone.leds_min = zone_sizes_k55[zone_idx];
|
||||
new_zone.leds_max = zone_sizes_k55[zone_idx];
|
||||
new_zone.leds_count = zone_sizes_k55[zone_idx];
|
||||
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 if(logical_layout == CORSAIR_TYPE_K55)
|
||||
{
|
||||
new_led.name = led_names_k55[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()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ std::string CorsairVengeanceController::GetDeviceLocation()
|
||||
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()
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#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>
|
||||
@@ -52,81 +50,76 @@ bool TestForCorsairVengeanceController(i2c_smbus_interface* bus, unsigned char a
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
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))
|
||||
{
|
||||
// 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);
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
}
|
||||
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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
} /* DetectCorsairVengeanceControllers() */
|
||||
@@ -20,7 +20,6 @@ CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface
|
||||
strcpy(device_name, "Corsair Vengeance Pro RGB");
|
||||
led_count = CORSAIR_PRO_LED_COUNT;
|
||||
|
||||
direct_mode = false;
|
||||
effect_mode = CORSAIR_PRO_MODE_STATIC;
|
||||
|
||||
for (unsigned int i = 0; i < led_count; i++)
|
||||
@@ -48,7 +47,7 @@ std::string CorsairVengeanceProController::GetDeviceLocation()
|
||||
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()
|
||||
@@ -80,49 +79,20 @@ void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char
|
||||
|
||||
void CorsairVengeanceProController::ApplyColors()
|
||||
{
|
||||
if(direct_mode)
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
unsigned char full_packet[32];
|
||||
unsigned char crc_packet[31];
|
||||
|
||||
full_packet[0] = 0x0A;
|
||||
crc_packet[0] = 0x0A;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
crc_packet[(i * 3) + 1] = led_red[i];
|
||||
full_packet[(i * 3) + 1] = led_red[i];
|
||||
|
||||
crc_packet[(i * 3) + 2] = led_green[i];
|
||||
full_packet[(i * 3) + 2] = led_green[i];
|
||||
|
||||
crc_packet[(i * 3) + 3] = led_blue[i];
|
||||
full_packet[(i * 3) + 3] = led_blue[i];
|
||||
}
|
||||
|
||||
uint8_t footer = CRCPP::CRC::Calculate(crc_packet, 31, CRCPP::CRC::CRC_8());
|
||||
|
||||
full_packet[31] = footer;
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, CORSAIR_PRO_DIRECT_COMMAND, 32, full_packet);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_red[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_green[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_blue[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_red[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_green[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_blue[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
@@ -137,20 +107,8 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
unsigned char blu2
|
||||
)
|
||||
{
|
||||
if(mode == effect_mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
effect_mode = mode;
|
||||
|
||||
direct_mode = (effect_mode == CORSAIR_PRO_MODE_DIRECT);
|
||||
|
||||
if(direct_mode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
@@ -167,10 +125,10 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
random_byte = CORSAIR_PRO_EFFECT_CUSTOM_COLORS;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); // Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, speed); // Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, random_byte); // Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, direction); // Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, speed); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, random_byte); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, direction); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red1); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn1); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu1); // Custom color 1 blue
|
||||
@@ -203,8 +161,3 @@ bool CorsairVengeanceProController::WaitReady()
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CorsairVengeanceProController::SetDirect(bool direct)
|
||||
{
|
||||
direct_mode = direct;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
#include "CRC.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -20,22 +19,20 @@ typedef unsigned char corsair_dev_id;
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_REG_COMMAND = 0x20, /* Command write register */
|
||||
CORSAIR_PRO_DIRECT_COMMAND = 0x31, /* Where it writes direct mode colors */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_MODE_DIRECT = 0xDD, /* Arbitrary value to compare against later. Not the actual packet */
|
||||
CORSAIR_PRO_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */
|
||||
CORSAIR_PRO_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */
|
||||
CORSAIR_PRO_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */
|
||||
CORSAIR_PRO_MODE_VISOR = 0x05, /* Visor mode */
|
||||
CORSAIR_PRO_MODE_RAIN = 0x06, /* Rain mode */
|
||||
CORSAIR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW = 0x08, /* Rainbow mode */
|
||||
CORSAIR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_PRO_MODE_STATIC = 0x10, /* Static mode */
|
||||
CORSAIR_PRO_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */
|
||||
CORSAIR_PRO_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */
|
||||
CORSAIR_PRO_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */
|
||||
CORSAIR_PRO_MODE_VISOR = 0x05, /* Visor mode */
|
||||
CORSAIR_PRO_MODE_RAIN = 0x06, /* Rain mode */
|
||||
CORSAIR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW = 0x08, /* Rainbow mode */
|
||||
CORSAIR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_PRO_MODE_STATIC = 0x10, /* Static mode */
|
||||
|
||||
CORSAIR_PRO_NUMBER_MODES = 10, /* Number of Corsair Pro modes */
|
||||
};
|
||||
@@ -90,12 +87,9 @@ public:
|
||||
void ApplyColors();
|
||||
bool WaitReady();
|
||||
|
||||
void SetDirect(bool direct);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
bool direct_mode;
|
||||
unsigned char effect_mode;
|
||||
unsigned char led_red[CORSAIR_PRO_LED_COUNT];
|
||||
unsigned char led_green[CORSAIR_PRO_LED_COUNT];
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#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>
|
||||
@@ -60,81 +58,76 @@ bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned cha
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
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))
|
||||
{
|
||||
// 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);
|
||||
ResourceManager::get()->RegisterRGBController(new_controller);
|
||||
}
|
||||
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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
} /* DetectCorsairVengeanceProControllers() */
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "CreativeSoundBlasterXG6Controller.h"
|
||||
#include "RGBController_CreativeSoundBlasterXG6.h"
|
||||
#include "Detector.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Creative vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CREATIVE_VID 0x041E
|
||||
/*-----------------------------------------------------*\
|
||||
| SoundCards |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CREATIVE_SOUNDBLASTERX_G6_PID 0x3256
|
||||
|
||||
void DetectCreativeDevice(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
CreativeSoundBlasterXG6Controller* controller = new CreativeSoundBlasterXG6Controller(dev, info->path);
|
||||
RGBController_CreativeSoundBlasterXG6* rgb_controller = new RGBController_CreativeSoundBlasterXG6(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Sound Cards |
|
||||
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
REGISTER_HID_DETECTOR_I("Creative SoundBlasterX G6", DetectCreativeDevice, CREATIVE_VID, CREATIVE_SOUNDBLASTERX_G6_PID, 4);
|
||||
@@ -1,82 +0,0 @@
|
||||
#include "CreativeSoundBlasterXG6Controller.h"
|
||||
|
||||
CreativeSoundBlasterXG6Controller::CreativeSoundBlasterXG6Controller(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
CreativeSoundBlasterXG6Controller::~CreativeSoundBlasterXG6Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CreativeSoundBlasterXG6Controller::GetDeviceLocation()
|
||||
{
|
||||
return("HID " + location);
|
||||
}
|
||||
|
||||
void CreativeSoundBlasterXG6Controller::SetLedColor (unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
//5A 3A 02 06 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
usb_buf[0x01] = 0x5A;
|
||||
usb_buf[0x02] = 0x3A;
|
||||
usb_buf[0x03] = 0x02;
|
||||
usb_buf[0x04] = 0x06;
|
||||
usb_buf[0x05] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
//5A 3A 06 04 00 03 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|
||||
usb_buf[0x01] = 0x5A;
|
||||
usb_buf[0x02] = 0x3A;
|
||||
usb_buf[0x03] = 0x06;
|
||||
usb_buf[0x04] = 0x04;
|
||||
usb_buf[0x06] = 0x03;
|
||||
usb_buf[0x07] = 0x01;
|
||||
usb_buf[0x09] = 0x01;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
//5A 3A 09 0A 00 03 01 01 FF BB GG RR
|
||||
usb_buf[0x01] = 0x5A;
|
||||
usb_buf[0x02] = 0x3A;
|
||||
usb_buf[0x03] = 0x09;
|
||||
usb_buf[0x04] = 0x0A;
|
||||
usb_buf[0x06] = 0x03;
|
||||
usb_buf[0x07] = 0x01;
|
||||
usb_buf[0x08] = 0x01;
|
||||
usb_buf[0x09] = 0x0FF;
|
||||
|
||||
usb_buf[0x0A] = blue;
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = red;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "RGBController.h"
|
||||
#include <cstring>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
class CreativeSoundBlasterXG6Controller
|
||||
{
|
||||
public:
|
||||
CreativeSoundBlasterXG6Controller(hid_device* dev_handle, const char* path);
|
||||
~CreativeSoundBlasterXG6Controller();
|
||||
void SetLedColor (unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
};
|
||||
@@ -1,81 +0,0 @@
|
||||
#include "RGBController_CreativeSoundBlasterXG6.h"
|
||||
|
||||
RGBController_CreativeSoundBlasterXG6::RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* creative_device)
|
||||
{
|
||||
creative = creative_device;
|
||||
|
||||
name = "Creative SoundBlasterX G6 Device";
|
||||
vendor = "Creative";
|
||||
type = DEVICE_TYPE_HEADSET;
|
||||
description = "Creative SoundBlasterX G6 Device";
|
||||
location = creative_device->GetDeviceLocation();
|
||||
serial = "";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Direct";
|
||||
Static.value = 0;
|
||||
Static.flags = MODE_COLORS_PER_LED;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CreativeSoundBlasterXG6::~RGBController_CreativeSoundBlasterXG6()
|
||||
{
|
||||
delete creative;
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::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);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
creative->SetLedColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_CreativeSoundBlasterXG6::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CreativeSoundBlasterXG6Controller.h"
|
||||
|
||||
class RGBController_CreativeSoundBlasterXG6: public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CreativeSoundBlasterXG6(CreativeSoundBlasterXG6Controller* creative_device);
|
||||
~RGBController_CreativeSoundBlasterXG6();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CreativeSoundBlasterXG6Controller* creative;
|
||||
};
|
||||
@@ -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)
|
||||
@@ -87,8 +80,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]));
|
||||
|
||||
@@ -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 */
|
||||
@@ -54,7 +53,6 @@ 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;
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
#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>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for Crucial RAM |
|
||||
\*----------------------------------------------------------------------*/
|
||||
@@ -17,16 +13,6 @@ using namespace std::chrono_literals;
|
||||
|
||||
static const unsigned char crucial_addresses[] =
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| These addresses have been disabled due to conflict |
|
||||
| with ASUS Aura DRAM. Since the detection scheme is |
|
||||
| the same, Aura RAM will be detected as Crucial. |
|
||||
| We need to improve the Crucial detection scheme. |
|
||||
\*-----------------------------------------------------*/
|
||||
// 0x39,
|
||||
// 0x3A,
|
||||
// 0x3B,
|
||||
// 0x3C,
|
||||
0x20,
|
||||
0x21,
|
||||
0x22,
|
||||
@@ -69,15 +55,6 @@ bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
|
||||
|
||||
} /* TestForCrucialController() */
|
||||
|
||||
void CrucialRegisterWrite(i2c_smbus_interface* bus, unsigned char dev, unsigned short reg, unsigned char val)
|
||||
{
|
||||
//Write Crucial register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Crucial value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCrucialControllers *
|
||||
@@ -89,64 +66,23 @@ void CrucialRegisterWrite(i2c_smbus_interface* bus, unsigned char dev, unsigned
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses)
|
||||
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CrucialController* new_crucial;
|
||||
RGBController_Crucial* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
int address_list_idx = -1;
|
||||
|
||||
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++)
|
||||
{
|
||||
// Remap Crucial RAM modules on 0x27
|
||||
for (unsigned int slot = 0; slot < 4; slot++)
|
||||
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x27, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
address_list_idx++;
|
||||
|
||||
if(address_list_idx < CRUCIAL_ADDRESS_COUNT)
|
||||
{
|
||||
res = busses[bus]->i2c_smbus_write_quick(crucial_addresses[address_list_idx], I2C_SMBUS_WRITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (res >= 0);
|
||||
|
||||
if(address_list_idx < CRUCIAL_ADDRESS_COUNT)
|
||||
{
|
||||
CrucialRegisterWrite(busses[bus], 0x27, 0x82EE, slot);
|
||||
CrucialRegisterWrite(busses[bus], 0x27, 0x82EF, (crucial_addresses[address_list_idx] << 1));
|
||||
CrucialRegisterWrite(busses[bus], 0x27, 0x82F0, 0xF0);
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
// 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]))
|
||||
{
|
||||
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
|
||||
new_controller = new RGBController_Crucial(new_crucial);
|
||||
ResourceManager::get()->RegisterRGBController(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);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user