Compare commits
206
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e89d82c24 | ||
|
|
199db16ec0 | ||
|
|
c364fabf57 | ||
|
|
15a2d5beaf | ||
|
|
5b956f7ff1 | ||
|
|
dc42248a88 | ||
|
|
eeeab399be | ||
|
|
39d451793b | ||
|
|
5db888fba0 | ||
|
|
1b91687fac | ||
|
|
7d38cd4a78 | ||
|
|
899b90decc | ||
|
|
8dcb1f075d | ||
|
|
5588f9b7a9 | ||
|
|
717620e8dd | ||
|
|
877d462dbc | ||
|
|
d3cf315175 | ||
|
|
f47129902a | ||
|
|
5a3c69ec32 | ||
|
|
392c547b87 | ||
|
|
38527a5122 | ||
|
|
77412a959f | ||
|
|
3a5ebe387e | ||
|
|
1db412e970 | ||
|
|
a3c931392a | ||
|
|
b94f701db8 | ||
|
|
b79ff124e6 | ||
|
|
60baf6d05f | ||
|
|
cb9b22804a | ||
|
|
d2dfd03551 | ||
|
|
f3bdee9bd2 | ||
|
|
7a3de1edbb | ||
|
|
0464fbcbe2 | ||
|
|
12226804f3 | ||
|
|
f06d71bd0c | ||
|
|
112d5a1cb2 | ||
|
|
b70658e37d | ||
|
|
80a2770263 | ||
|
|
765ef62858 | ||
|
|
0e58fcc236 | ||
|
|
4bf0330974 | ||
|
|
6d585d3eeb | ||
|
|
0286a5dd58 | ||
|
|
b3cadbae5d | ||
|
|
e26e874d1c | ||
|
|
c9c214267d | ||
|
|
6957c1ca03 | ||
|
|
f5aafda340 | ||
|
|
f1fe428f59 | ||
|
|
614c9768ad | ||
|
|
5828c4df8d | ||
|
|
6cf32b8a94 | ||
|
|
bc6487505a | ||
|
|
d1e8104442 | ||
|
|
91414084d6 | ||
|
|
372ff746ad | ||
|
|
ab297281d3 | ||
|
|
2cbba19bf9 | ||
|
|
b5001c983e | ||
|
|
7d4d6152ab | ||
|
|
f2c1022c7f | ||
|
|
771e362a63 | ||
|
|
3eba2c3dd3 | ||
|
|
305f66ad3d | ||
|
|
3191a87f46 | ||
|
|
a9493d46aa | ||
|
|
6499ee4312 | ||
|
|
f26897df71 | ||
|
|
8ae07ea9e2 | ||
|
|
cb94b4fe28 | ||
|
|
f51f222fb4 | ||
|
|
d3162ea2e8 | ||
|
|
fa1f0b05ce | ||
|
|
c7bb002b7c | ||
|
|
b1de039f21 | ||
|
|
e086ecd0bb | ||
|
|
f612ca8bdc | ||
|
|
5b8441c57d | ||
|
|
919d89d52f | ||
|
|
479d51df87 | ||
|
|
687424e732 | ||
|
|
a2a613f22d | ||
|
|
a34d0f93a3 | ||
|
|
8e62be0b9e | ||
|
|
95bcc5e0fd | ||
|
|
19ef8afe70 | ||
|
|
5fdea9d34f | ||
|
|
32938ec2af | ||
|
|
8d29a40954 | ||
|
|
a75a2bbf8b | ||
|
|
f96a4c3557 | ||
|
|
1d426f109a | ||
|
|
8827d0e0c2 | ||
|
|
edfb4f8d4e | ||
|
|
13ce388e9a | ||
|
|
316902b2c3 | ||
|
|
6667cdeed9 | ||
|
|
de44c57081 | ||
|
|
30a1bc9893 | ||
|
|
cf4b421abd | ||
|
|
1a9e1c2430 | ||
|
|
bde9e7ea6b | ||
|
|
fc9c6585af | ||
|
|
be9711a021 | ||
|
|
bfa7f63486 | ||
|
|
8f19267886 | ||
|
|
fab6e41810 | ||
|
|
c3ceac1ed9 | ||
|
|
bb01790d71 | ||
|
|
9cf7bdea29 | ||
|
|
6da6ff6cc0 | ||
|
|
baa04913c3 | ||
|
|
64c0861097 | ||
|
|
522016137b | ||
|
|
40d0f17ae2 | ||
|
|
c88e71d52a | ||
|
|
c3d284c97b | ||
|
|
19b572da30 | ||
|
|
e6c4017ad0 | ||
|
|
b862912fb1 | ||
|
|
02f7f57130 | ||
|
|
c6b3d7c675 | ||
|
|
1b2a5a4b14 | ||
|
|
c0190d35d1 | ||
|
|
4d0219b184 | ||
|
|
85fc72232a | ||
|
|
cbb13b0d22 | ||
|
|
bd6ec4c41e | ||
|
|
d843b3d619 | ||
|
|
ca9c40f084 | ||
|
|
6a85729f10 | ||
|
|
13414ec9b8 | ||
|
|
74faee0f73 | ||
|
|
3f0027aa90 | ||
|
|
d22aa1ed6c | ||
|
|
23d51f65d0 | ||
|
|
cad356efca | ||
|
|
70e83c13cc | ||
|
|
7ca0a1b6ab | ||
|
|
9bd5536d07 | ||
|
|
eaa3b9a368 | ||
|
|
599c468de8 | ||
|
|
9f21814395 | ||
|
|
cb8a551683 | ||
|
|
7f1156d81c | ||
|
|
5beee08166 | ||
|
|
1334129078 | ||
|
|
216b492f24 | ||
|
|
1b65bb9cc3 | ||
|
|
0f4ddd164f | ||
|
|
e6aadc414b | ||
|
|
883a78ad9d | ||
|
|
15d23d3009 | ||
|
|
e2c2b8c1df | ||
|
|
5133c30242 | ||
|
|
69e1e19bf9 | ||
|
|
46f08f7423 | ||
|
|
352b9928ca | ||
|
|
87854d5781 | ||
|
|
1b3f8f9eb4 | ||
|
|
6438c15dd3 | ||
|
|
dbe29991f0 | ||
|
|
a5e9a3de05 | ||
|
|
edf1b251c0 | ||
|
|
9ff4314840 | ||
|
|
3ad0986ae7 | ||
|
|
6bfc9dd9db | ||
|
|
9b8a0d465e | ||
|
|
119741b736 | ||
|
|
2fe958783c | ||
|
|
1c59ef6b80 | ||
|
|
9e44e4ba4f | ||
|
|
b8e14ea067 | ||
|
|
525071c205 | ||
|
|
bfe03b0564 | ||
|
|
04b87ce2eb | ||
|
|
81acc47cd6 | ||
|
|
6e426b1403 | ||
|
|
6509e53a9b | ||
|
|
5b42b3d11d | ||
|
|
8bd515296d | ||
|
|
2bbf66c0ee | ||
|
|
d716973642 | ||
|
|
25f7a87a79 | ||
|
|
0619a16be2 | ||
|
|
4a3802f344 | ||
|
|
105f5642ef | ||
|
|
54ab57cea6 | ||
|
|
e3e6c0347e | ||
|
|
4d6706ce61 | ||
|
|
39c5aff864 | ||
|
|
450f438538 | ||
|
|
0270c745ce | ||
|
|
e2dfcd5b0f | ||
|
|
68fa3c2def | ||
|
|
cde7469191 | ||
|
|
7c1a1396ca | ||
|
|
7f052f21aa | ||
|
|
dff667751b | ||
|
|
2625807c1a | ||
|
|
7af283fdbf | ||
|
|
c7ffe3b926 | ||
|
|
46339c5f86 | ||
|
|
cf69598fd1 | ||
|
|
594f66ab23 | ||
|
|
01e0808e41 |
@@ -1 +1,8 @@
|
||||
*.pro.user*
|
||||
*.o
|
||||
ui_*
|
||||
moc_*
|
||||
qrc_*
|
||||
OpenRGB
|
||||
Makefile
|
||||
OpenRGB-x86_64.AppImage
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# swy: some useful references; the MSVC part of the CI script is based on the one from bind9, by Michał Kępień:
|
||||
# https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/blob/master/cookbooks/preinstalled-software/README.md
|
||||
# https://gitlab.isc.org/isc-projects/bind9/commit/facc6a051fcac70fbbc61cb92a37be8c3e4db5ec#587d266bb27a4dc3022bbed44dfa19849df3044c_718_731
|
||||
# https://www.kittell.net/code/powershell-unix-sed-equivalent-change-text-file/
|
||||
# https://powershell.org/forums/topic/how-to-use-ansi-vt100-formatting-in-powershell-ooh-pretty-colors/
|
||||
|
||||
.shared_windows_runners:
|
||||
tags:
|
||||
- shared-windows
|
||||
- windows
|
||||
- windows-1809
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
before_script:
|
||||
- echo "started by ${GITLAB_USER_NAME}"
|
||||
|
||||
build_linux:
|
||||
image: ubuntu:bionic
|
||||
stage: build
|
||||
script:
|
||||
- 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:
|
||||
paths:
|
||||
- OpenRGB-x86_64.AppImage
|
||||
expire_in: 1337 years
|
||||
|
||||
build_windows:
|
||||
extends:
|
||||
- .shared_windows_runners
|
||||
stage: build
|
||||
script:
|
||||
- $esc = "$([char]27)"
|
||||
- $count = 0
|
||||
- function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds }
|
||||
- function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; }
|
||||
- function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; }
|
||||
|
||||
|
||||
- _fold_start_ 'configuring the msvc environment variables'
|
||||
- Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build"
|
||||
- '& cmd.exe /C "vcvarsall.bat x64 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }'
|
||||
- Pop-Location
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'downloading precompiled versions of qtbase, qttools (for windeployqt) and jom (for a more parallel nmake)'
|
||||
- mkdir _qt
|
||||
- mkdir _qt_download
|
||||
- Push-Location _qt_download
|
||||
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qtbase-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
|
||||
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qttools-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
|
||||
- curl.exe -LJ -o qt-jom.zip 'https://download.qt.io/official_releases/jom/jom.zip'
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'extracting the downloaded qt binaries'
|
||||
- 7z x qt-base.7z '-o../_qt' -y
|
||||
- 7z x qt-tools.7z '-o../_qt' -y
|
||||
- 7z x qt-jom.zip '-o../_qt' -y
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks'
|
||||
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2017_64\mkspecs\qconfig.pri'
|
||||
- (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder}
|
||||
- (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder}
|
||||
- Pop-Location
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
|
||||
- mkdir _build; cd _build
|
||||
- ..\_qt\5.15.0\msvc2017_64\bin\qmake ..\OpenRGB.pro
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'start the actual build with jom instead of nmake; for speed'
|
||||
- ..\_qt\jom
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
|
||||
- ..\_qt\5.15.0\msvc2017_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
|
||||
- _fold_final_
|
||||
|
||||
- _fold_start_ 'compressing the release folder so that we can upload it as artifact'
|
||||
- mv release 'OpenRGB Windows 64-bit'
|
||||
- ${datetime} = Get-Date ([datetime]::UtcNow) -Format "yyyy-MM-ddTHH-mm-ss"
|
||||
- ${revision} = ((git rev-parse --short HEAD) | Out-String).Trim()
|
||||
- ${rversion} = (((Get-Content '..\OpenRGB.pro' | Select-String -Pattern "VERSION =") | Out-String).Trim().Split("="))[1].Trim()
|
||||
- 7z a -mx9 -r -y "OpenRGB_${rversion}_64_${revision}_nightly_${datetime}.7z" 'OpenRGB Windows 64-bit'
|
||||
- _fold_final_
|
||||
# cache:
|
||||
# key: same-key
|
||||
# paths:
|
||||
# - C:\vcpkg\installed\
|
||||
artifacts:
|
||||
paths:
|
||||
- _build/*.7z
|
||||
expire_in: 1337 years
|
||||
@@ -0,0 +1,216 @@
|
||||
#---------------------------------------------------------------#
|
||||
# OpenRGB udev rules #
|
||||
# #
|
||||
# Adam Honse (CalcProgrammer1) 5/29/2020 #
|
||||
#---------------------------------------------------------------#
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# User I2C/SMBus Access #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="i2c-[0-99]*", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# User hidraw Access #
|
||||
#---------------------------------------------------------------#
|
||||
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# AMD Wraith Prism #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0051", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS Aura Core Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1854", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1869", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1866", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ASUS Aura USB Devices #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1867", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1872", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1889", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18a3", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18f3", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Cooler Master Peripheral Devices #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# Cooler Master MP750 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0109", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Corsair Lighting Node Devices #
|
||||
# #
|
||||
# Corsair Lighting Node Core #
|
||||
# Corsair Lighting Node Pro #
|
||||
# Corsair Commander Pro #
|
||||
# Corsair LS100 #
|
||||
# Corsair 1000D Obsidian #
|
||||
# Corsair Spec Omega RGB #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c1a", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c0b", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c10", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c1e", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1d00", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1d04", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Corsair Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# Corsair K55 RGB #
|
||||
# Corsair K65 RGB #
|
||||
# Corsair K65 RGB Lux #
|
||||
# Corsair K65 RGB Rapidfire #
|
||||
# Corsair K68 RGB #
|
||||
# Corsair K70 RGB #
|
||||
# Corsair K70 RGB Lux #
|
||||
# Corsair K70 RGB Rapidfire #
|
||||
# Corsair K70 RGB MK2 #
|
||||
# Corsair K70 RGB MK2 SE #
|
||||
# Corsair K70 RGB MK2 LP #
|
||||
# Corsair K95 RGB #
|
||||
# Corsair K95 Platinum #
|
||||
# Corsair Strafe #
|
||||
# Corsair Strafe MK2 #
|
||||
# #
|
||||
# Mice: #
|
||||
# Corsair M65 Pro #
|
||||
# Corsair M65 RGB Elite #
|
||||
# #
|
||||
# Mousemats: #
|
||||
# Corsair MM800 RGB Polaris #
|
||||
# #
|
||||
# Headset Stands: #
|
||||
# Corsair ST100 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b3d", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b17", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b37", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b39", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b4f", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b13", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b33", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b38", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b49", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b6b", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b55", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b11", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b2d", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b20", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b48", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b2e", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b5a", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="1b3b", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0a34", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# HyperX Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# HyperX Alloy Elite #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0951", ATTR{idProduct}=="16be", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Logitech Peripheral Devices #
|
||||
# #
|
||||
# Mice: #
|
||||
# Logitech G203 Prodigy #
|
||||
# Logitech G403 Prodigy #
|
||||
# Logitech G403 Hero #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c084", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c083", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08f", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# MSI/SteelSeries 3-Zone Laptop Keyboard #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1770", ATTR{idProduct}=="FF00", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# NZXT Hue 2 Devices #
|
||||
# #
|
||||
# NZXT Hue 2 #
|
||||
# NZXT Smart Device V2 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2001", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2006", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# NZXT Kraken #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="170e", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Redragon Peripheral Devices #
|
||||
# #
|
||||
# Keyboards: #
|
||||
# Redragon K550 Yama #
|
||||
# Redragon K552 Kumara #
|
||||
# Redragon K556 Devarajas #
|
||||
# Tecware Phantom Elite #
|
||||
# #
|
||||
# Mice: #
|
||||
# Redragon M711 Cobra #
|
||||
# Redragon M715 Dagger #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5204", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5104", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5004", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="652f", TAG+="uaccess"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc30", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc39", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Gigabyte/Aorus RGB Fusion 2 USB #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="8297", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# SteelSeries Peripheral Devices #
|
||||
# #
|
||||
# Mice: #
|
||||
# SteelSeries Rival 100 #
|
||||
# SteelSeries Rival 100 DotA 2 Edition #
|
||||
# SteelSeries Rival 105 #
|
||||
# SteelSeries Rival 110 #
|
||||
# SteelSeries Rival 300 #
|
||||
# Acer Predator Gaming Mouse (Rival 300) #
|
||||
# SteelSeries Rival 300 CS:GO Fade Edition #
|
||||
# SteelSeries Rival 300 CS:GO Fade Edition (stm32) #
|
||||
# SteelSeries Rival 300 CS:GO Hyperbeast Edition #
|
||||
# SteelSeries Rival 300 Dota 2 Edition #
|
||||
# SteelSeries Rival 300 HP Omen Edition #
|
||||
# Headsets: #
|
||||
# SteelSeries Siberia 350 #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1702", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="170c", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1814", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1729", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1384", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1714", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1394", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1716", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="171a", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1392", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1718", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1229", TAG+="uaccess"
|
||||
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Thermaltake Poseidon Z RGB Keyboard #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="3006", TAG+="uaccess"
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle)
|
||||
AMDWraithPrismController::AMDWraithPrismController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
@@ -67,12 +67,10 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x02] = channel;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
ret_string.append((char *)&usb_buf[0x08]);
|
||||
|
||||
@@ -103,11 +101,10 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
unsigned char fw_buf[16] = {0x00};
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
for(int char_idx = 0; char_idx < 16; char_idx+=2)
|
||||
{
|
||||
@@ -227,10 +224,8 @@ void AMDWraithPrismController::SendEnableCommand()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendApplyCommand()
|
||||
@@ -255,10 +250,8 @@ void AMDWraithPrismController::SendApplyCommand()
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
@@ -294,8 +287,6 @@ void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
0xFF, 0xFF, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x04] = effect_channel;
|
||||
usb_buf[0x05] = speed;
|
||||
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
|
||||
@@ -307,8 +298,8 @@ void AMDWraithPrismController::SendEffectChannelUpdate
|
||||
usb_buf[0x0B] = green;
|
||||
usb_buf[0x0C] = blue;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
|
||||
@@ -333,8 +324,6 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
int actual;
|
||||
|
||||
usb_buf[0x08] = logo_channel;
|
||||
usb_buf[0x09] = fan_channel;
|
||||
|
||||
@@ -343,6 +332,6 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
|
||||
usb_buf[led] = ring_channel;
|
||||
}
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -109,7 +109,7 @@ enum
|
||||
class AMDWraithPrismController
|
||||
{
|
||||
public:
|
||||
AMDWraithPrismController(libusb_device_handle* dev_handle);
|
||||
AMDWraithPrismController(hid_device* dev_handle);
|
||||
~AMDWraithPrismController();
|
||||
|
||||
char* GetDeviceName();
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
libusb_device_handle* dev;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_fan_mode;
|
||||
unsigned char current_fan_speed;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AMDWraithPrism.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#include <hidapi/hidapi.h>
|
||||
#define AMD_WRAITH_PRISM_VID 0x2516
|
||||
#define AMD_WRAITH_PRISM_PID 0x0051
|
||||
|
||||
@@ -17,17 +16,31 @@
|
||||
|
||||
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
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
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID);
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == AMD_WRAITH_PRISM_VID)
|
||||
&&(info->product_id == AMD_WRAITH_PRISM_PID)
|
||||
&&(info->interface_number == 1))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 1);
|
||||
libusb_claim_interface(dev, 1);
|
||||
|
||||
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
|
||||
|
||||
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
|
||||
|
||||
@@ -1,269 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
GetFirmwareVersion();
|
||||
GetConfigTable();
|
||||
}
|
||||
|
||||
AuraAddressableController::~AuraAddressableController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int AuraAddressableController::GetChannelCount()
|
||||
{
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
std::string AuraAddressableController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendDirectApply(channel);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
for(int channel_idx = 0; channel_idx < GetChannelCount(); channel_idx++)
|
||||
{
|
||||
SendEffect
|
||||
(
|
||||
channel_idx,
|
||||
mode,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraAddressableController::GetConfigTable()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_CONFIG_TABLE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x30)
|
||||
{
|
||||
memcpy(config_table, &usb_buf[4], 60);
|
||||
|
||||
for(int i = 0; i < 60; i+=6)
|
||||
{
|
||||
printf("%02X %02X %02X %02X %02X %02X\r\n", config_table[i + 0],
|
||||
config_table[i + 1],
|
||||
config_table[i + 2],
|
||||
config_table[i + 3],
|
||||
config_table[i + 4],
|
||||
config_table[i + 5]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AuraAddressableController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up firmware version request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_FIRMWARE_VERSION;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x02)
|
||||
{
|
||||
memcpy(device_name, &usb_buf[2], 16);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = grn;
|
||||
usb_buf[0x07] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80 | channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#include "AuraAddressableController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraAddressable.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_ADDRESSABLE_VID 0x0B05
|
||||
|
||||
#define NUM_PIDS 4
|
||||
static const unsigned short pid_table[] =
|
||||
{
|
||||
0x1867,
|
||||
0x1872,
|
||||
0x1889,
|
||||
0x18A3
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraAddressableControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus Aura addressable RGB header controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraAddressableControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus Aura addressable RGB header controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_ADDRESSABLE_VID, pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
|
||||
RGBController_AuraAddressable* rgb_controller = new RGBController_AuraAddressable(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,16 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| This list contains the available I2C addresses for Aura GPUs |
|
||||
@@ -88,7 +79,7 @@ void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
} /* DetectAuraGPUControllers() */
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura RAM |
|
||||
@@ -178,7 +169,7 @@ void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
// Add Aura-enabled motherboard controllers
|
||||
@@ -191,7 +182,7 @@ void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB Addressable |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraAddressableController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraAddressableController::AuraAddressableController(hid_device* dev_handle) : AuraUSBController(dev_handle)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add addressable devices |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < config_table[0x02]; ++i)
|
||||
{
|
||||
device_info.push_back({0x01, (unsigned char)i, 0x01, AuraDeviceType::ADDRESSABLE});
|
||||
}
|
||||
}
|
||||
|
||||
AuraAddressableController::~AuraAddressableController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendDirectApply(channel);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
SendEffect
|
||||
(
|
||||
channel,
|
||||
mode,
|
||||
red,
|
||||
grn,
|
||||
blu
|
||||
);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_ADDRESSABLE_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = grn;
|
||||
usb_buf[0x07] = blu;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraAddressableController::SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = 0x80 | channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| Addressable RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_ADDRESSABLE_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
|
||||
};
|
||||
|
||||
class AuraAddressableController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraAddressableController(hid_device* dev_handle);
|
||||
~AuraAddressableController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
void SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,199 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraMainboardController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB mainboard |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraMainboardController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraMainboardController::AuraMainboardController(hid_device* dev_handle) : AuraUSBController(dev_handle), mode(AURA_MODE_DIRECT)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Add mainboard device |
|
||||
\*-----------------------------------------------------*/
|
||||
device_info.push_back({0x00, 0x04, config_table[0x1B], AuraDeviceType::FIXED});
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add addressable devices |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < config_table[0x02]; ++i)
|
||||
{
|
||||
device_info.push_back({0x01, (unsigned char)i, 0x01, AuraDeviceType::ADDRESSABLE});
|
||||
}
|
||||
}
|
||||
|
||||
AuraMainboardController::~AuraMainboardController()
|
||||
{
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
unsigned char led_data[60];
|
||||
unsigned int leds_sent = 0;
|
||||
|
||||
while(leds_sent < num_colors)
|
||||
{
|
||||
unsigned int leds_to_send = 20;
|
||||
|
||||
if((num_colors - leds_sent) < leds_to_send)
|
||||
{
|
||||
leds_to_send = num_colors - leds_sent;
|
||||
}
|
||||
|
||||
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx + leds_sent]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
(
|
||||
device_info[channel].direct_channel,
|
||||
leds_sent,
|
||||
leds_to_send,
|
||||
led_data,
|
||||
leds_sent + leds_to_send >= num_colors
|
||||
);
|
||||
|
||||
leds_sent += leds_to_send;
|
||||
}
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
)
|
||||
{
|
||||
this->mode = mode;
|
||||
RGBColor color = ToRGBColor(red, grn, blu);
|
||||
|
||||
SendEffect(device_info[channel].effect_channel, mode);
|
||||
if(mode == AURA_MODE_DIRECT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char led_data[60];
|
||||
unsigned char start_led = 0;
|
||||
|
||||
for(std::size_t i = 0; i < channel; ++i)
|
||||
{
|
||||
start_led += device_info[i].num_leds;
|
||||
}
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < device_info[channel].num_leds; led_idx++)
|
||||
{
|
||||
led_data[(led_idx * 3) + 0] = RGBGetRValue(color);
|
||||
led_data[(led_idx * 3) + 1] = RGBGetGValue(color);
|
||||
led_data[(led_idx * 3) + 2] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
channel,
|
||||
start_led,
|
||||
device_info[channel].num_leds,
|
||||
led_data,
|
||||
device_info[channel].device_type == AuraDeviceType::FIXED
|
||||
);
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendColor
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR;
|
||||
usb_buf[0x02] = channel;
|
||||
usb_buf[0x03] = fixed ? 0xFF : 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05 + 3 * start_led], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
|
||||
void AuraMainboardController::SendCommit()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_COMMIT;
|
||||
usb_buf[0x02] = 0x55;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraMainboardController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| USB Mainboard RGB lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MAINBOARD_CONTROL_MODE_EFFECT = 0x35, /* Effect control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR = 0x36, /* Effect color control mode */
|
||||
AURA_MAINBOARD_CONTROL_MODE_COMMIT = 0x3F, /* Commit mode */
|
||||
};
|
||||
|
||||
class AuraMainboardController : public AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraMainboardController(hid_device* dev_handle);
|
||||
~AuraMainboardController();
|
||||
|
||||
void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int mode;
|
||||
|
||||
void SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode
|
||||
);
|
||||
|
||||
void SendColor
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool fixed
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
};
|
||||
@@ -0,0 +1,155 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraUSBController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB USB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraUSBController.h"
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
AuraUSBController::AuraUSBController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
GetFirmwareVersion();
|
||||
GetConfigTable();
|
||||
}
|
||||
|
||||
AuraUSBController::~AuraUSBController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int AuraUSBController::GetChannelCount()
|
||||
{
|
||||
return(device_info.size());
|
||||
}
|
||||
|
||||
std::string AuraUSBController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
const std::vector<AuraDeviceInfo>& AuraUSBController::GetAuraDevices() const
|
||||
{
|
||||
return(device_info);
|
||||
}
|
||||
|
||||
void AuraUSBController::GetConfigTable()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up config table request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_CONFIG_TABLE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x30)
|
||||
{
|
||||
memcpy(config_table, &usb_buf[4], 60);
|
||||
|
||||
for(int i = 0; i < 60; i+=6)
|
||||
{
|
||||
printf("%02X %02X %02X %02X %02X %02X\r\n", config_table[i + 0],
|
||||
config_table[i + 1],
|
||||
config_table[i + 2],
|
||||
config_table[i + 3],
|
||||
config_table[i + 4],
|
||||
config_table[i + 5]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
throw std::runtime_error("Could not read config table");
|
||||
}
|
||||
}
|
||||
|
||||
void AuraUSBController::GetFirmwareVersion()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up firmware version request packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_REQUEST_FIRMWARE_VERSION;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
hid_read(dev, usb_buf, 65);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy the firmware string if the reply ID is correct |
|
||||
\*-----------------------------------------------------*/
|
||||
if(usb_buf[1] == 0x02)
|
||||
{
|
||||
memcpy(device_name, &usb_buf[2], 16);
|
||||
}
|
||||
}
|
||||
|
||||
void AuraUSBController::SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data,
|
||||
bool apply /* = false */
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0xEC;
|
||||
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
|
||||
usb_buf[0x02] = apply ? 0x80 : 0x00;
|
||||
usb_buf[0x02] |= device;
|
||||
usb_buf[0x03] = start_led;
|
||||
usb_buf[0x04] = led_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x05], led_data, led_count * 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 65);
|
||||
}
|
||||
+41
-35
@@ -1,15 +1,16 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraAddressableController.h |
|
||||
| AuraUSBController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura |
|
||||
| Addressable RGB lighting controller |
|
||||
| USB RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
| Martin Hartl (inlart) 4/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
@@ -36,66 +37,71 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
|
||||
AURA_CONTROL_MODE_DIRECT = 0x40, /* Direct control mode */
|
||||
AURA_REQUEST_FIRMWARE_VERSION = 0x82, /* Request firmware string */
|
||||
AURA_REQUEST_CONFIG_TABLE = 0xB0, /* Request configuration table */
|
||||
AURA_CONTROL_MODE_DIRECT = 0x40, /* Direct control mode */
|
||||
};
|
||||
|
||||
class AuraAddressableController
|
||||
enum class AuraDeviceType
|
||||
{
|
||||
FIXED,
|
||||
ADDRESSABLE,
|
||||
};
|
||||
|
||||
struct AuraDeviceInfo
|
||||
{
|
||||
unsigned char effect_channel;
|
||||
unsigned char direct_channel;
|
||||
unsigned char num_leds;
|
||||
AuraDeviceType device_type;
|
||||
};
|
||||
|
||||
class AuraUSBController
|
||||
{
|
||||
public:
|
||||
AuraAddressableController(hid_device* dev_handle);
|
||||
~AuraAddressableController();
|
||||
AuraUSBController(hid_device* dev_handle);
|
||||
virtual ~AuraUSBController();
|
||||
|
||||
unsigned int GetChannelCount();
|
||||
|
||||
std::string GetDeviceName();
|
||||
|
||||
void SetChannelLEDs
|
||||
const std::vector<AuraDeviceInfo>& GetAuraDevices() const;
|
||||
|
||||
virtual void SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
unsigned int num_colors
|
||||
);
|
||||
) = 0;
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned char config_table[60];
|
||||
hid_device* dev;
|
||||
unsigned int led_count;
|
||||
|
||||
void GetConfigTable();
|
||||
|
||||
void GetFirmwareVersion();
|
||||
|
||||
void SendEffect
|
||||
virtual void SetMode
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu
|
||||
);
|
||||
) = 0;
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
unsigned char config_table[60];
|
||||
std::vector<AuraDeviceInfo> device_info;
|
||||
|
||||
void SendDirect
|
||||
(
|
||||
unsigned char device,
|
||||
unsigned char start_led,
|
||||
unsigned char led_count,
|
||||
unsigned char* led_data
|
||||
unsigned char* led_data,
|
||||
bool apply = false
|
||||
);
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned int led_count;
|
||||
|
||||
void SendDirectApply
|
||||
(
|
||||
unsigned char channel
|
||||
);
|
||||
void GetConfigTable();
|
||||
|
||||
void GetFirmwareVersion();
|
||||
};
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,24 +8,21 @@
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMMP750Controller.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
CMMP750Controller::CMMP750Controller(libusb_device_handle* dev_handle, unsigned int _inAddr, unsigned int _outAddr, int _interface)
|
||||
CMMP750Controller::CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path)
|
||||
{
|
||||
int tmp_size = wcslen(_vendor);
|
||||
|
||||
dev = dev_handle;
|
||||
inAddr = _inAddr;
|
||||
outAddr = _outAddr;
|
||||
interface = _interface;
|
||||
|
||||
libusb_device* device = libusb_get_device(dev);
|
||||
int bus = libusb_get_bus_number(device);
|
||||
int bus_addr = libusb_get_device_address(device);
|
||||
int port = libusb_get_port_number(device);
|
||||
location = "Bus: " + std::to_string(bus) + " Addr: " + std::to_string(bus_addr) + " Port: " + std::to_string(port);
|
||||
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];
|
||||
|
||||
strcpy(device_name, "Cooler Master MP750");
|
||||
location = _path;
|
||||
|
||||
current_mode = MP750_MODE_STATIC;
|
||||
current_speed = MP750_SPEED_NORMAL;
|
||||
@@ -33,8 +30,7 @@ CMMP750Controller::CMMP750Controller(libusb_device_handle* dev_handle, unsigned
|
||||
|
||||
CMMP750Controller::~CMMP750Controller()
|
||||
{
|
||||
libusb_release_interface(dev, interface);
|
||||
libusb_attach_kernel_driver(dev, interface);
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
char* CMMP750Controller::GetDeviceName()
|
||||
@@ -71,7 +67,6 @@ void CMMP750Controller::SetColor(unsigned char red, unsigned char green, unsigne
|
||||
|
||||
void CMMP750Controller::SendUpdate()
|
||||
{
|
||||
int actual = 0;
|
||||
unsigned char buffer[0x40] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
@@ -94,7 +89,5 @@ void CMMP750Controller::SendUpdate()
|
||||
buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
|
||||
}
|
||||
|
||||
//Nothing will be done with the "actual" transfer length
|
||||
libusb_interrupt_transfer(dev, outAddr, buffer, buffer_size, nullptr, CM_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
@@ -16,12 +16,15 @@
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data) / sizeof(colour_mode_data[0]))
|
||||
#define CM_INTERRUPT_TIMEOUT 250
|
||||
#define CM_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_SERIAL_SIZE (sizeof(serial) / sizeof(serial[ 0 ]))
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -53,10 +56,10 @@ static unsigned char colour_mode_data[][6] =
|
||||
static unsigned char speed_mode_data[][9] =
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Blinking */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Breathing */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF },/* Colour Cycle */
|
||||
{ 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xE0, 0xFF } /* Colour Breath */
|
||||
{ 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
|
||||
@@ -75,7 +78,7 @@ enum
|
||||
class CMMP750Controller
|
||||
{
|
||||
public:
|
||||
CMMP750Controller(libusb_device_handle *dev_handle, unsigned int _inAddr, unsigned int _outAddr, int _interface);
|
||||
CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path);
|
||||
~CMMP750Controller();
|
||||
|
||||
char* GetDeviceName();
|
||||
@@ -89,10 +92,7 @@ private:
|
||||
char device_name[32];
|
||||
char serial[32];
|
||||
std::string location;
|
||||
libusb_device_handle* dev;
|
||||
unsigned char inAddr;
|
||||
unsigned char outAddr;
|
||||
int interface;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
#include "CMMP750Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define COOLERMASTER_VID 0x2516
|
||||
#define COOLERMASTER_VID 0x2516
|
||||
|
||||
#define COOLERMASTER_MP750_XL_PID 0x0109
|
||||
#define COOLERMASTER_MP750_MEDIUM_PID 0x0105
|
||||
|
||||
#define COOLERMASTER_NUM_DEVICES (sizeof(cm_pids) / sizeof(cm_pids[ 0 ]))
|
||||
|
||||
enum
|
||||
{
|
||||
CM_PID = 0,
|
||||
CM_INADDR = 1,
|
||||
CM_OUTADDR = 2,
|
||||
CM_INTERFACE = 3
|
||||
CM_INTERFACE = 1
|
||||
};
|
||||
|
||||
static const unsigned int cm_pids[][4] =
|
||||
{ //PID, inAddr, outAddr, interface
|
||||
{ 0x0109, 0x82, 0x03, 0x00 } //Coolermaster MP750
|
||||
{ // PID, Interface
|
||||
{ COOLERMASTER_MP750_XL_PID, 0x00 }, //Coolermaster MP750 (Extra Large)
|
||||
{ COOLERMASTER_MP750_MEDIUM_PID, 0x00 } //Coolermaster MP750 (Medium)
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
@@ -31,27 +32,35 @@ static const unsigned int cm_pids[][4] =
|
||||
|
||||
void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * context;
|
||||
libusb_init(&context);
|
||||
hid_device_info* info;
|
||||
|
||||
for(int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
|
||||
//Look for the passed in cm_pids
|
||||
hid_init();
|
||||
info = hid_enumerate(0x0, 0x0);
|
||||
|
||||
while(info)
|
||||
{
|
||||
//Look for the passed in cm_pids
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(context, COOLERMASTER_VID, cm_pids[cm_pid_idx][CM_PID]);
|
||||
hid_device* dev = NULL;
|
||||
if(info->vendor_id == COOLERMASTER_VID)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dev)
|
||||
{
|
||||
int status = libusb_detach_kernel_driver(dev, cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
status = libusb_claim_interface(dev, cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
// Success: Device has been claimed
|
||||
CMMP750Controller* controller = new CMMP750Controller(dev, cm_pids[cm_pid_idx][CM_INADDR], cm_pids[cm_pid_idx][CM_OUTADDR], cm_pids[cm_pid_idx][CM_INTERFACE]);
|
||||
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -28,16 +28,7 @@
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
@@ -46,10 +37,9 @@ THREAD keepalive_thread(void *param)
|
||||
THREADRETURN
|
||||
}
|
||||
|
||||
CorsairLightingNodeController::CorsairLightingNodeController(libusb_device_handle* dev_handle, unsigned int dev_endpoint)
|
||||
CorsairLightingNodeController::CorsairLightingNodeController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
endpoint = dev_endpoint;
|
||||
|
||||
SendFirmwareRequest();
|
||||
|
||||
@@ -75,8 +65,11 @@ void CorsairLightingNodeController::KeepaliveThread()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
if((clock() - last_commit_time) > 5000)
|
||||
{
|
||||
SendCommit();
|
||||
}
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,8 +213,8 @@ void CorsairLightingNodeController::SendFirmwareRequest()
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x80 + endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
actual = hid_read(dev, usb_buf, 16);
|
||||
|
||||
if(actual > 0)
|
||||
{
|
||||
@@ -238,7 +231,6 @@ void CorsairLightingNodeController::SendDirect
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -263,12 +255,12 @@ void CorsairLightingNodeController::SendDirect
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendCommit()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -276,6 +268,11 @@ void CorsairLightingNodeController::SendCommit()
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update last commit time |
|
||||
\*-----------------------------------------------------*/
|
||||
last_commit_time = clock();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
@@ -285,7 +282,8 @@ void CorsairLightingNodeController::SendCommit()
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBegin
|
||||
@@ -293,7 +291,6 @@ void CorsairLightingNodeController::SendBegin
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -310,7 +307,8 @@ void CorsairLightingNodeController::SendBegin
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendEffectConfig
|
||||
@@ -336,7 +334,6 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
unsigned short temperature_2
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -349,7 +346,7 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
|
||||
usb_buf[0x01] = channel;
|
||||
usb_buf[0x02] = count * 10;
|
||||
usb_buf[0x02] = count;
|
||||
usb_buf[0x03] = led_type;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -365,14 +362,14 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
| Set up mode colors |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x09] = color_0_red;
|
||||
usb_buf[0x10] = color_0_green;
|
||||
usb_buf[0x11] = color_0_blue;
|
||||
usb_buf[0x12] = color_1_red;
|
||||
usb_buf[0x13] = color_1_green;
|
||||
usb_buf[0x14] = color_1_blue;
|
||||
usb_buf[0x15] = color_2_red;
|
||||
usb_buf[0x16] = color_2_green;
|
||||
usb_buf[0x17] = color_2_blue;
|
||||
usb_buf[0x0A] = color_0_green;
|
||||
usb_buf[0x0B] = color_0_blue;
|
||||
usb_buf[0x0C] = color_1_red;
|
||||
usb_buf[0x0D] = color_1_green;
|
||||
usb_buf[0x0E] = color_1_blue;
|
||||
usb_buf[0x0F] = color_2_red;
|
||||
usb_buf[0x10] = color_2_green;
|
||||
usb_buf[0x11] = color_2_blue;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up temperatures |
|
||||
@@ -387,7 +384,8 @@ void CorsairLightingNodeController::SendEffectConfig
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendTemperature()
|
||||
@@ -400,7 +398,6 @@ void CorsairLightingNodeController::SendReset
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -417,7 +414,8 @@ void CorsairLightingNodeController::SendReset
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendPortState
|
||||
@@ -426,7 +424,6 @@ void CorsairLightingNodeController::SendPortState
|
||||
unsigned char state
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -444,7 +441,8 @@ void CorsairLightingNodeController::SendPortState
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void CorsairLightingNodeController::SendBrightness()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -78,7 +78,7 @@ enum
|
||||
class CorsairLightingNodeController
|
||||
{
|
||||
public:
|
||||
CorsairLightingNodeController(libusb_device_handle* dev_handle, unsigned int dev_endpoint);
|
||||
CorsairLightingNodeController(hid_device* dev_handle);
|
||||
~CorsairLightingNodeController();
|
||||
|
||||
std::string GetFirmwareString();
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
unsigned int endpoint;
|
||||
hid_device* dev;
|
||||
std::string firmware_version;
|
||||
clock_t last_commit_time;
|
||||
|
||||
void SendFirmwareRequest();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairLightingNode.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define CORSAIR_VID 0x1B1C
|
||||
#define CORSAIR_LIGHTING_NODE_CORE_PID 0x0C1A
|
||||
@@ -16,20 +16,20 @@ typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_endpoint;
|
||||
unsigned char channel_count;
|
||||
const char * name;
|
||||
} corsair_node_device;
|
||||
|
||||
static const corsair_node_device device_list[6] =
|
||||
{
|
||||
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID, 1, 1, "Corsair Lighting Node Core" },
|
||||
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID, 1, 2, "Corsair Lighting Node Pro" },
|
||||
{ CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID, 2, 2, "Corsair Commander Pro" },
|
||||
{ CORSAIR_VID, CORSAIR_LS100_PID, 1, 1, "Corsair LS100 Lighting Kit" },
|
||||
{ CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID, 2, 2, "Corsair 1000D Obsidian" },
|
||||
{ CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID, 1, 2, "Corsair SPEC OMEGA RGB" }
|
||||
#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" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
@@ -37,31 +37,43 @@ static const corsair_node_device device_list[6] =
|
||||
* DetectCorsairLightingNodeControllers *
|
||||
* *
|
||||
* Detect devices supported by the Corsair Lighting Node Pro driver *
|
||||
* * *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
for(int device_idx = 0; device_idx < 6; device_idx++)
|
||||
hid_init();
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
//Look for Corsair Lighting Node Device
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
dev = NULL;
|
||||
|
||||
if( dev )
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Corsair Lighting Node Devices
|
||||
while(info)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
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);
|
||||
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, device_list[device_idx].usb_endpoint);
|
||||
if( dev )
|
||||
{
|
||||
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev);
|
||||
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
} /* DetectCorsairLightingNodeControllers() */
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||||
@@ -20,6 +22,8 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x
|
||||
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
|
||||
136, 137, 139, 140, 141};
|
||||
|
||||
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
{
|
||||
char usb_pkt[65];
|
||||
@@ -30,6 +34,8 @@ static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
}
|
||||
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
|
||||
bytes++;
|
||||
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
|
||||
@@ -72,6 +78,26 @@ void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
SetLEDsMousemat(colors);
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
/*-----------------------------------------------------*\
|
||||
| The logo zone of the ST100 is in the middle of the |
|
||||
| base LED strip, so remap the colors so that the logo |
|
||||
| is the last LED in the sequence. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<RGBColor> remap_colors;
|
||||
remap_colors.resize(colors.size());
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
remap_colors[st100[i]] = colors[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The ST100 uses the mousemat protocol |
|
||||
\*-----------------------------------------------------*/
|
||||
SetLEDsMousemat(remap_colors);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +248,8 @@ void CorsairPeripheralController::LightingControl()
|
||||
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Lighting control byte needs to be 3 for keyboards, 1 |
|
||||
| for mice and mousepads |
|
||||
| Lighting control byte needs to be 3 for keyboards and |
|
||||
| headset stand, 1 for mice and mousepads |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(type)
|
||||
{
|
||||
@@ -239,6 +265,10 @@ void CorsairPeripheralController::LightingControl()
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
usb_buf[0x04] = 0x04;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
usb_buf[0x04] = 0x03;
|
||||
break;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -271,6 +301,7 @@ void CorsairPeripheralController::SpecialFunctionControl()
|
||||
|
||||
void CorsairPeripheralController::ReadFirmwareInfo()
|
||||
{
|
||||
int actual;
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -285,16 +316,35 @@ void CorsairPeripheralController::ReadFirmwareInfo()
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
| Send packet and try reading it using an HID read |
|
||||
| If that fails, repeat the send and read the reply as |
|
||||
| a feature report. |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
|
||||
hid_write(dev, (unsigned char*)usb_buf, 64);
|
||||
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 64, 1000);
|
||||
|
||||
if(actual == 0)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set up Read Firmware Info packet |
|
||||
\*-------------------------------------------------*/
|
||||
usb_buf[0x00] = CORSAIR_COMMAND_READ;
|
||||
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
|
||||
|
||||
hid_write(dev, (unsigned char*)usb_buf, 64);
|
||||
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get device type |
|
||||
| 0xC0 Device is a keyboard |
|
||||
| 0xC1 Device is a mouse |
|
||||
| 0xC2 Device is a mousepad |
|
||||
| 0xC2 Device is a mousepad or headset stand |
|
||||
\*-----------------------------------------------------*/
|
||||
switch((unsigned char)usb_buf[0x14])
|
||||
{
|
||||
@@ -307,7 +357,20 @@ void CorsairPeripheralController::ReadFirmwareInfo()
|
||||
break;
|
||||
|
||||
case 0xC2:
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
{
|
||||
unsigned short pid = (unsigned short)(usb_buf[0x0F] << 8) + (unsigned char)(usb_buf[0x0E]);
|
||||
|
||||
switch(pid)
|
||||
{
|
||||
case 0x0A34:
|
||||
type = DEVICE_TYPE_HEADSET_STAND;
|
||||
break;
|
||||
|
||||
default:
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -353,7 +416,7 @@ void CorsairPeripheralController::StreamPacket
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardFullColors
|
||||
@@ -382,7 +445,7 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitKeyboardLimitedColors
|
||||
@@ -407,7 +470,7 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitMouseColors
|
||||
@@ -445,7 +508,7 @@ void CorsairPeripheralController::SubmitMouseColors
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
}
|
||||
|
||||
void CorsairPeripheralController::SubmitMousematColors
|
||||
@@ -470,18 +533,18 @@ void CorsairPeripheralController::SubmitMousematColors
|
||||
usb_buf[0x03] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
|
||||
| Copy in colors in <RED> <GREEN> <BLUE> order |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
|
||||
{
|
||||
//usb_buf[(zone_idx * 4) + 4] = zone_idx;
|
||||
usb_buf[(zone_idx * 3) + 4] = RGBGetRValue(color_data[zone_idx]);
|
||||
usb_buf[(zone_idx * 3) + 5] = RGBGetGValue(color_data[zone_idx]);
|
||||
usb_buf[(zone_idx * 3) + 6] = RGBGetBValue(color_data[zone_idx]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
| Send packet using feature reports, as headset stand |
|
||||
| seems to not update completely using HID writes |
|
||||
\*-----------------------------------------------------*/
|
||||
send_usb_msg(dev, usb_buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define CORSAIR_K70_RGB_PID 0x1B13
|
||||
#define CORSAIR_K70_LUX_RGB_PID 0x1B33
|
||||
#define CORSAIR_K70_RGB_RAPIDFIRE_PID 0x1B38
|
||||
#define CORSAIR_K70_RGB_MK2_PID 0x1B38
|
||||
#define CORSAIR_K70_RGB_MK2_PID 0x1B49
|
||||
#define CORSAIR_K70_RGB_MK2_SE_PID 0x1B6B
|
||||
#define CORSAIR_K70_RGB_MK2_LP_PID 0x1B55
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_MM800_RGB_POLARIS_PID 0x1B3B
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Headset Stand product IDs |
|
||||
| List taken from ckb-next |
|
||||
\*-----------------------------------------------------*/
|
||||
#define CORSAIR_ST100_PID 0x0A34
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
@@ -63,6 +69,10 @@ 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" },
|
||||
@@ -72,6 +82,8 @@ static const corsair_node_device device_list[] =
|
||||
{ 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 |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
@@ -80,7 +92,11 @@ static const corsair_node_device device_list[] =
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0, "Corsair MM800 RGB Polaris" }
|
||||
{ CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0, "Corsair MM800 RGB Polaris" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Headset Stands |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ CORSAIR_VID, CORSAIR_ST100_PID, 0, "Corsair ST100 RGB" }
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
|
||||
@@ -10,16 +10,7 @@
|
||||
#include "CorsairVengeanceProController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
@@ -89,9 +80,9 @@ void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char
|
||||
void CorsairVengeanceProController::ApplyColors()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -119,9 +110,9 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
effect_mode = mode;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
unsigned char random_byte;
|
||||
|
||||
@@ -165,7 +156,7 @@ bool CorsairVengeanceProController::WaitReady()
|
||||
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
|
||||
{
|
||||
i++;
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -50,7 +41,7 @@ bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned cha
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
return(pass);
|
||||
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_GloriousModelO.cpp |
|
||||
| |
|
||||
| Definitions and types for Glorious |
|
||||
| and other Mice |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 20/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "GloriousModelOController.h"
|
||||
#include <cstring>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
GloriousModelOController::GloriousModelOController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
strcpy(device_name, "Glorious Mouse");
|
||||
led_count = 1;
|
||||
|
||||
current_mode = GLORIOUS_MODE_STATIC;
|
||||
current_speed = GLORIOUS_SPEED_NORMAL;
|
||||
current_direction = GLORIOUS_DIRECTION_UP;
|
||||
|
||||
}
|
||||
|
||||
GloriousModelOController::~GloriousModelOController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string GloriousModelOController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int GloriousModelOController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void GloriousModelOController::SetLEDColor(RGBColor* color_buf)
|
||||
{
|
||||
unsigned char usb_buf[520] =
|
||||
{
|
||||
0x04, 0x11, 0x00, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x00, 0x64, 0x06, 0x04, 0x24,
|
||||
0xf0, 0x03, 0x07, 0x0f, 0x1f, 0x31, 0x63, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff,
|
||||
0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43,
|
||||
0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x42, 0x02, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
usb_buf[0x0B] = 0x24;
|
||||
usb_buf[0x35] = GLORIOUS_MODE_STATIC;
|
||||
usb_buf[0x38] = 0x40; //max brightness
|
||||
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
|
||||
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
|
||||
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
|
||||
|
||||
//DPI Button
|
||||
/*
|
||||
usb_buf[0x0B] = 0x44; //third DPI
|
||||
usb_buf[0x26] = red;
|
||||
usb_buf[0x27] = blue;
|
||||
usb_buf[0x28] = green;
|
||||
*/
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
void GloriousModelOController::SetMode(unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char direction,
|
||||
RGBColor* color_buf)
|
||||
{
|
||||
unsigned char usb_buf[520] =
|
||||
{
|
||||
0x04, 0x11, 0x00, 0x7b,
|
||||
0x00, 0x00, 0x00, 0x00, 0x64, 0x06, 0x04, 0x24,
|
||||
0xf0, 0x03, 0x07, 0x0f, 0x1f, 0x31, 0x63, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
|
||||
0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x41, 0x01, 0x40, 0xff, 0xff, 0xff,
|
||||
0x42, 0x07, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||
0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0x43,
|
||||
0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x42, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
|
||||
0x42, 0x02, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
usb_buf[0x35] = mode;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case GLORIOUS_MODE_OFF:
|
||||
usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03
|
||||
break;
|
||||
case GLORIOUS_MODE_RAINBOW:
|
||||
usb_buf[0x36] = speed;
|
||||
usb_buf[0x37] = direction;
|
||||
break;
|
||||
case GLORIOUS_MODE_SPECTRUM_BREATING:
|
||||
//colours not yet researched
|
||||
usb_buf[0x3C] = speed; //speed for mode 3
|
||||
usb_buf[0x3D] = 0x07; //maybe some kind of bank change?+
|
||||
//usb_buf[0x3D] = 0x06;
|
||||
usb_buf[0x3E] = RGBGetRValue(color_buf[0]); //mode 3 red 1
|
||||
usb_buf[0x3F] = RGBGetBValue(color_buf[0]); //mode 3 blue 1
|
||||
usb_buf[0x40] = RGBGetGValue(color_buf[0]); //mode 3 green 1
|
||||
usb_buf[0x41] = RGBGetRValue(color_buf[1]); //mode 3 red 2
|
||||
usb_buf[0x42] = RGBGetBValue(color_buf[1]); //mode 3 blue 2
|
||||
usb_buf[0x43] = RGBGetGValue(color_buf[1]); //mode 3 green 2
|
||||
usb_buf[0x44] = RGBGetRValue(color_buf[2]); //mode 3 red 3
|
||||
usb_buf[0x45] = RGBGetBValue(color_buf[2]); //mode 3 blue 3
|
||||
usb_buf[0x46] = RGBGetGValue(color_buf[2]); //mode 3 green 3
|
||||
usb_buf[0x47] = RGBGetRValue(color_buf[3]); //mode 3 red 4
|
||||
usb_buf[0x48] = RGBGetBValue(color_buf[3]); //mode 3 blue 4
|
||||
usb_buf[0x49] = RGBGetGValue(color_buf[3]); //mode 3 green 4
|
||||
usb_buf[0x4A] = RGBGetRValue(color_buf[4]); //mode 3 red 5
|
||||
usb_buf[0x4B] = RGBGetBValue(color_buf[4]); //mode 3 blue 5
|
||||
usb_buf[0x4C] = RGBGetGValue(color_buf[4]); //mode 3 green 5
|
||||
usb_buf[0x4D] = RGBGetRValue(color_buf[5]); //mode 3 red 6
|
||||
usb_buf[0x4E] = RGBGetBValue(color_buf[5]); //mode 3 blue 6
|
||||
usb_buf[0x4F] = RGBGetGValue(color_buf[5]); //mode 3 green 6
|
||||
usb_buf[0x50] = RGBGetRValue(color_buf[6]); //mode 3 red 7
|
||||
usb_buf[0x51] = RGBGetBValue(color_buf[6]); //mode 3 blue 7
|
||||
usb_buf[0x52] = RGBGetGValue(color_buf[6]); //mode 3 green 7
|
||||
break;
|
||||
case GLORIOUS_MODE_TAIL:
|
||||
usb_buf[0x53] = speed; //Speed for mode 4
|
||||
break;
|
||||
case GLORIOUS_MODE_SPECTRUM_CYCLE:
|
||||
usb_buf[0x54] = speed; //Speed for mode 1,2,5
|
||||
break;
|
||||
case GLORIOUS_MODE_RAVE:
|
||||
usb_buf[0x74] = speed; //Speed for mode 7
|
||||
usb_buf[0x75] = RGBGetRValue(color_buf[0]); //mode 7 red 1
|
||||
usb_buf[0x76] = RGBGetBValue(color_buf[0]); //mode 7 blue 1
|
||||
usb_buf[0x77] = RGBGetGValue(color_buf[0]); //mode 7 green 1
|
||||
usb_buf[0x78] = RGBGetRValue(color_buf[1]); //mode 7 red 2
|
||||
usb_buf[0x79] = RGBGetBValue(color_buf[1]); //mode 7 blue 2
|
||||
usb_buf[0x7A] = RGBGetGValue(color_buf[1]); //mode 7 green 2
|
||||
break;
|
||||
case GLORIOUS_MODE_WAVE:
|
||||
usb_buf[0x7C] = speed; //Speed for mode 9
|
||||
break;
|
||||
case GLORIOUS_MODE_BREATHING:
|
||||
usb_buf[0x7D] = speed;
|
||||
usb_buf[0x7E] = RGBGetRValue(color_buf[0]); //mode 0a red
|
||||
usb_buf[0x7F] = RGBGetBValue(color_buf[0]); //mode 0a blue
|
||||
usb_buf[0x80] = RGBGetGValue(color_buf[0]); //mode 0a green
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*-----------------------------------------*\
|
||||
| GloriousModelOController.h |
|
||||
| |
|
||||
| Definitions and types for Glorious |
|
||||
| and other Mice |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 20/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
GLORIOUS_MODE_OFF = 0x00, //does nothing
|
||||
GLORIOUS_MODE_RAINBOW = 0x01,
|
||||
GLORIOUS_MODE_STATIC = 0x02,
|
||||
GLORIOUS_MODE_SPECTRUM_BREATING = 0x03,
|
||||
GLORIOUS_MODE_TAIL = 0x04,
|
||||
GLORIOUS_MODE_SPECTRUM_CYCLE = 0x05,
|
||||
GLORIOUS_MODE_RAVE = 0x07,
|
||||
GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software
|
||||
GLORIOUS_MODE_WAVE = 0x09,
|
||||
GLORIOUS_MODE_BREATHING = 0x0a,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GLORIOUS_SPEED_SLOW = 0x41,
|
||||
GLORIOUS_SPEED_NORMAL = 0x42,
|
||||
GLORIOUS_SPEED_FAST = 0x43,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GLORIOUS_DIRECTION_UP = 0x00,
|
||||
GLORIOUS_DIRECTION_DOWN = 0x01,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GLORIOUS_MODE_BREATING_SLOW = 0x01,
|
||||
GLORIOUS_MODE_BREATING_NORMAL = 0x02,
|
||||
GLORIOUS_MODE_BREATING_FAST = 0x03,
|
||||
};
|
||||
|
||||
class GloriousModelOController
|
||||
{
|
||||
public:
|
||||
GloriousModelOController(hid_device* dev_handle);
|
||||
~GloriousModelOController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
|
||||
void SetLEDColor(RGBColor* color_buf);
|
||||
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction, RGBColor* color_buf);
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
unsigned char current_direction;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "GloriousModelOController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_GloriousModelO.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define Glorious_Model_O_VID 0x258A
|
||||
#define Glorious_Model_O_PID 0x0036
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectGloriousModelController *
|
||||
* *
|
||||
* Tests the USB address to see if a Glorious Model O controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(Glorious_Model_O_VID, Glorious_Model_O_PID);
|
||||
|
||||
//Look for Glorious Model O
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == Glorious_Model_O_VID)
|
||||
&&(info->product_id == Glorious_Model_O_PID)
|
||||
&&(info->interface_number == 1))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
GloriousModelOController* controller = new GloriousModelOController(dev);
|
||||
|
||||
RGBController_GloriousModelO* rgb_controller = new RGBController_GloriousModelO(controller);
|
||||
|
||||
rgb_controller->name = "Glorious Mouse";
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#include "Hue2Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Hue2.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define NZXT_HUE_2_VID 0x1E71
|
||||
#define NZXT_HUE_2_PID 0x2001
|
||||
#define NZXT_SMART_DEVICE_V2_PID 0x2006
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHue2Controllers *
|
||||
* *
|
||||
* Detect devices supported by the Hue2 driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
|
||||
//Look for NZXT Hue 2
|
||||
libusb_device_handle * hue_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_HUE_2_PID);
|
||||
|
||||
if( hue_2_dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(hue_2_dev, 0);
|
||||
libusb_claim_interface(hue_2_dev, 0);
|
||||
|
||||
Hue2Controller* controller = new Hue2Controller(hue_2_dev);
|
||||
|
||||
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
//Look for NZXT Smart Device V2
|
||||
libusb_device_handle * smart_dev_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_SMART_DEVICE_V2_PID);
|
||||
|
||||
if( smart_dev_2_dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(smart_dev_2_dev, 0);
|
||||
libusb_claim_interface(smart_dev_2_dev, 0);
|
||||
|
||||
Hue2Controller* controller = new Hue2Controller(smart_dev_2_dev);
|
||||
|
||||
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
} /* DetectHuePlusControllers() */
|
||||
@@ -11,16 +11,7 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
@@ -64,7 +55,7 @@ unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
serialport->serial_write((char *)serial_buf, 2);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(50);
|
||||
std::this_thread::sleep_for(50ms);
|
||||
|
||||
int bytes_read = serialport->serial_read((char *)serial_buf, 5);
|
||||
|
||||
@@ -244,5 +235,5 @@ void HuePlusController::SendPacket
|
||||
/*-----------------------------------------------------*\
|
||||
| Delay to allow Hue+ device to ready for next packet |
|
||||
\*-----------------------------------------------------*/
|
||||
Sleep(20);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -76,7 +67,7 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
|
||||
{
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
|
||||
{
|
||||
@@ -89,7 +80,7 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
|
||||
slots_valid |= (1 << (slot_addr - 0x50));
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
|
||||
@@ -11,26 +11,17 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
|
||||
0x33, 0x34, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x41, 0x44, 0x45,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x51, 0x54, 0x55, 0x58, 0x59,
|
||||
0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x61, 0x64, 0x65, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
|
||||
0x6E, 0x6F, 0x74, 0x75, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x81,
|
||||
0x84, 0x85, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91, 0x94, 0x95 };
|
||||
0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x20, 0x21, 0x22,
|
||||
0x23, 0x24, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
|
||||
0x31, 0x32, 0x33, 0x34, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x41,
|
||||
0x44, 0x45, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x51, 0x54, 0x55,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x61, 0x64, 0x65, 0x68, 0x69, 0x6A,
|
||||
0x6B, 0x6C, 0x6E, 0x6F, 0x74, 0x75, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E,
|
||||
0x7F, 0x81, 0x84, 0x85, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91,
|
||||
0x94, 0x95 };
|
||||
|
||||
static unsigned int extended_red[] = {0x08, 0x48, 0x88, 0x09, 0x89, 0x0A, 0x8A, 0x0B, 0x8B, 0x0C, 0x8C, 0x0D, 0x8D, 0x0E, 0x8F, 0x8E, 0x0F, 0x4F, 0x92, 0x13, 0x93, 0x12 };
|
||||
static unsigned int extended_grn[] = {0x29, 0x28, 0x78, 0x19, 0x79, 0x1A, 0x7A, 0x1B, 0x7B, 0x1C, 0x7C, 0x1D, 0x7D, 0x1E, 0x6E, 0x7E, 0x1F, 0x6F, 0x82, 0x23, 0x83, 0x22 };
|
||||
@@ -107,17 +98,17 @@ void HyperXKeyboardController::SetMode
|
||||
mode_colors[8]
|
||||
);
|
||||
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
unsigned char blu_color_data[106];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
for(std::size_t i = 0; i < 106; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
@@ -126,9 +117,9 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
|
||||
for(std::size_t i = 0; i < 22; i++)
|
||||
{
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 106]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 106]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 106]);
|
||||
}
|
||||
|
||||
SendDirect
|
||||
@@ -137,7 +128,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
@@ -145,7 +136,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
@@ -153,7 +144,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirectExtended
|
||||
(
|
||||
@@ -163,12 +154,12 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
|
||||
void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
unsigned char red_color_data[106];
|
||||
unsigned char grn_color_data[106];
|
||||
unsigned char blu_color_data[106];
|
||||
unsigned char ext_color_data[150];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
for(std::size_t i = 0; i < 106; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
@@ -177,9 +168,9 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
|
||||
for(std::size_t i = 0; i < 22; i++)
|
||||
{
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
|
||||
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 106]);
|
||||
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 106]);
|
||||
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 106]);
|
||||
}
|
||||
|
||||
SendColor
|
||||
@@ -189,7 +180,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -198,7 +189,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -207,7 +198,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendExtendedColor
|
||||
(
|
||||
@@ -375,7 +366,7 @@ void HyperXKeyboardController::SendColor
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
for(int i = 0; i < 106; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
@@ -444,7 +435,7 @@ void HyperXKeyboardController::SendDirect
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
for(int i = 0; i < 106; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
@@ -4,9 +4,30 @@
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| HyperX keyboard vendor IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HYPERX_KEYBOARD_VID 0x0951
|
||||
#define HYPERX_ALLOY_ELITE_PID 0x16BE
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
const char * name;
|
||||
} hyperx_device;
|
||||
|
||||
#define HYPERX_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const hyperx_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, "HyperX Alloy Elite RGB" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXKeyboardControllers *
|
||||
@@ -22,30 +43,37 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
|
||||
|
||||
hid_init();
|
||||
|
||||
info = hid_enumerate(HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID);
|
||||
|
||||
//Look for HyperX Keyboard, Interface 2
|
||||
while(info)
|
||||
for(std::size_t device_idx = 0; device_idx < HYPERX_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
if((info->vendor_id == HYPERX_KEYBOARD_VID)
|
||||
&&(info->product_id == HYPERX_ALLOY_ELITE_PID)
|
||||
&&(info->interface_number == 2))
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for HyperX RGB Peripheral
|
||||
while(info)
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if( dev )
|
||||
{
|
||||
info = info->next;
|
||||
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
|
||||
|
||||
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
|
||||
|
||||
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#include "LogitechG203Controller.h"
|
||||
#include "LogitechG403Controller.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LogitechG203.h"
|
||||
#include "RGBController_LogitechG403.h"
|
||||
#include "RGBController_LogitechG810.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_VID 0x046D
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_G810_1_PID 0xC337
|
||||
#define LOGITECH_G810_2_PID 0xC331
|
||||
#define LOGITECH_G512_PID 0xC342
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_G203_PID 0xC084
|
||||
#define LOGITECH_G403_PID 0xC083
|
||||
#define LOGITECH_G403H_PID 0xC08F
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
device_type type;
|
||||
const char * name;
|
||||
} logitech_device;
|
||||
|
||||
#define LOGITECH_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const logitech_device device_list[] =
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_VID, LOGITECH_G810_1_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
|
||||
{ LOGITECH_VID, LOGITECH_G810_2_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
|
||||
{ LOGITECH_VID, LOGITECH_G512_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G512" },
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
|
||||
{ LOGITECH_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
|
||||
{ LOGITECH_VID, LOGITECH_G403H_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Hero" },
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectLogitechControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Logitech RGB Keyboard controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Logitech RGB Peripheral
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
switch(device_list[device_idx].type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev);
|
||||
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
{
|
||||
switch(device_list[device_idx].usb_pid)
|
||||
{
|
||||
case LOGITECH_G203_PID:
|
||||
{
|
||||
LogitechG203Controller* controller = new LogitechG203Controller(dev);
|
||||
|
||||
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case LOGITECH_G403_PID:
|
||||
case LOGITECH_G403H_PID:
|
||||
{
|
||||
LogitechG403Controller* controller = new LogitechG403Controller(dev);
|
||||
|
||||
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
hid_free_enumeration(info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG203Controller.cpp |
|
||||
| |
|
||||
| Driver for Logitech G203 Prodigy mouse |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechG203Controller.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
LogitechG203Controller::LogitechG203Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void LogitechG203Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0E;
|
||||
usb_buf[0x03] = 0x3C;
|
||||
usb_buf[0x04] = 0x00;
|
||||
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G203_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G203_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G203_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG203Controller.h |
|
||||
| |
|
||||
| Definitions and types for Logitech G203 |
|
||||
| Prodigy mouse lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G203_MODE_OFF = 0x00,
|
||||
LOGITECH_G203_MODE_STATIC = 0x01,
|
||||
LOGITECH_G203_MODE_CYCLE = 0x02,
|
||||
LOGITECH_G203_MODE_BREATHING = 0x03,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G203_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G203_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G203_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G203_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G203_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG203Controller
|
||||
{
|
||||
public:
|
||||
LogitechG203Controller(hid_device* dev_handle);
|
||||
~LogitechG203Controller();
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
};
|
||||
@@ -0,0 +1,75 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG403Controller.cpp |
|
||||
| |
|
||||
| Driver for Logitech G403 Prodigy mouse |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 5/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechG403Controller.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
LogitechG403Controller::LogitechG403Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
LogitechG403Controller::~LogitechG403Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void LogitechG403Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
std::uint16_t speed,
|
||||
unsigned char channel,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0E;
|
||||
usb_buf[0x03] = 0x3C;
|
||||
usb_buf[0x04] = channel;
|
||||
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G403_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G403_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G403_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG403Controller.h |
|
||||
| |
|
||||
| Definitions and types for Logitech G403 |
|
||||
| Prodigy mouse lighting controller |
|
||||
| |
|
||||
| Martin Hartl (inlart) 5/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G403_MODE_OFF = 0x00,
|
||||
LOGITECH_G403_MODE_STATIC = 0x01,
|
||||
LOGITECH_G403_MODE_CYCLE = 0x02,
|
||||
LOGITECH_G403_MODE_BREATHING = 0x03,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G403_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G403_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G403_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G403_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G403_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG403Controller
|
||||
{
|
||||
public:
|
||||
LogitechG403Controller(hid_device* dev_handle);
|
||||
~LogitechG403Controller();
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char channel,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
};
|
||||
@@ -0,0 +1,168 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG810Controller.cpp |
|
||||
| |
|
||||
| Driver for Logitech G810 Orion Spectrum |
|
||||
| keyboard light controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechG810Controller.h"
|
||||
#include <cstring>
|
||||
|
||||
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
LogitechG810Controller::~LogitechG810Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LogitechG810Controller::Commit()
|
||||
{
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SetDirect
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
)
|
||||
{
|
||||
SendDirectFrame(zone, frame_count, frame_data);
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
SendMode(LOGITECH_G810_ZONE_MODE_KEYBOARD, mode, speed, red, green, blue);
|
||||
SendMode(LOGITECH_G810_ZONE_MODE_LOGO, mode, speed, red, green, blue);
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void LogitechG810Controller::SendCommit()
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0C;
|
||||
usb_buf[0x03] = 0x5D;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SendDirectFrame
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
)
|
||||
{
|
||||
char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x12;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0C;
|
||||
usb_buf[0x03] = 0x3D;
|
||||
usb_buf[0x05] = zone;
|
||||
usb_buf[0x07] = frame_count;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in frame data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], frame_data, frame_count * 4);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 64);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0D;
|
||||
usb_buf[0x03] = 0x3D;
|
||||
usb_buf[0x04] = zone;
|
||||
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G810_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G810_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G810_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG810Controller.h |
|
||||
| |
|
||||
| Definitions and types for Logitech G810 |
|
||||
| Orion Spectrum keyboard light controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_ZONE_MODE_KEYBOARD = 0x00,
|
||||
LOGITECH_G810_ZONE_MODE_LOGO = 0x01,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_ZONE_DIRECT_KEYBOARD = 0x01,
|
||||
LOGITECH_G810_ZONE_DIRECT_MEDIA = 0x02,
|
||||
LOGITECH_G810_ZONE_DIRECT_LOGO = 0x10,
|
||||
LOGITECH_G810_ZONE_DIRECT_INDICATORS = 0x40,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_MODE_OFF = 0x00,
|
||||
LOGITECH_G810_MODE_STATIC = 0x01,
|
||||
LOGITECH_G810_MODE_BREATHING = 0x02,
|
||||
LOGITECH_G810_MODE_CYCLE = 0x03,
|
||||
LOGITECH_G810_MODE_WAVE = 0x04,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G810_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G810_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G810_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G810_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG810Controller
|
||||
{
|
||||
public:
|
||||
LogitechG810Controller(hid_device* dev_handle);
|
||||
~LogitechG810Controller();
|
||||
|
||||
void Commit();
|
||||
|
||||
void SetDirect
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
);
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void SendDirectFrame
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char frame_count,
|
||||
unsigned char * frame_data
|
||||
);
|
||||
|
||||
void SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
};
|
||||
@@ -1,52 +1,53 @@
|
||||
#include "MSIMysticLightController.h"
|
||||
#include "RGBController_MSIMysticLight.h"
|
||||
#include <algorithm>
|
||||
|
||||
#define MSI_VID 0x1462
|
||||
#define MSI_USB_VID 0x1462
|
||||
|
||||
constexpr unsigned short SupportedPIDs[41] =
|
||||
#define NUM_MSI_PIDS 41
|
||||
|
||||
static const unsigned short msi_pid_table[] =
|
||||
{
|
||||
31847, // MS_7C67
|
||||
31504, // MS_7B10
|
||||
31879, // MS_7C87
|
||||
31635, // MS_7B93
|
||||
31796, // MS_7C34
|
||||
31797, // MS_7C35
|
||||
31798, // MS_7C36
|
||||
31799, // MS_7C37
|
||||
31810, // MS_7C42
|
||||
31876, // MS_7C84
|
||||
31636, // MS_7B94
|
||||
31638, // MS_7B96
|
||||
31833, // MS_7C59
|
||||
31840, // MS_7C60
|
||||
31856, // MS_7C70
|
||||
31857, // MS_7C71
|
||||
31859, // MS_7C73
|
||||
31861, // MS_7C75
|
||||
31862, // MS_7C76
|
||||
31863, // MS_7C77
|
||||
31865, // MS_7C79
|
||||
31872, // MS_7C80
|
||||
31896, // MS_7C98
|
||||
31897, // MS_7C99
|
||||
31873, // MS_7C81
|
||||
31874, // MS_7C82
|
||||
31875, // MS_7C83
|
||||
31877, // MS_7C85
|
||||
31878, // MS_7C86
|
||||
31880, // MS_7C88
|
||||
31881, // MS_7C89
|
||||
17497, // MS_4459
|
||||
16036, // MS_3EA4
|
||||
36957, // MS_905D
|
||||
31888, // MS_7C90
|
||||
31889, // MS_7C91
|
||||
31890, // MS_7C92
|
||||
31892, // MS_7C94
|
||||
31893, // MS_7C95
|
||||
31894, // MS_7C96
|
||||
31830 // MS_7C56
|
||||
0x7C67, // MS_7C67
|
||||
0x7B10, // MS_7B10
|
||||
0x7C87, // MS_7C87
|
||||
0x7B93, // MS_7B93
|
||||
0x7C34, // MS_7C34
|
||||
0x7C35, // MS_7C35
|
||||
0x7C36, // MS_7C36
|
||||
0x7C37, // MS_7C37
|
||||
0x7C42, // MS_7C42
|
||||
0x7C84, // MS_7C84
|
||||
0x7B94, // MS_7B94
|
||||
0x7B96, // MS_7B96
|
||||
0x7C59, // MS_7C59
|
||||
0x7C60, // MS_7C60
|
||||
0x7C70, // MS_7C70
|
||||
0x7C71, // MS_7C71
|
||||
0x7C73, // MS_7C73
|
||||
0x7C75, // MS_7C75
|
||||
0x7C76, // MS_7C76
|
||||
0x7C77, // MS_7C77
|
||||
0x7C79, // MS_7C79
|
||||
0x7C80, // MS_7C80
|
||||
0x7C98, // MS_7C98
|
||||
0x7C99, // MS_7C99
|
||||
0x7C81, // MS_7C81
|
||||
0x7C82, // MS_7C82
|
||||
0x7C83, // MS_7C83
|
||||
0x7C85, // MS_7C85
|
||||
0x7C86, // MS_7C86
|
||||
0x7C88, // MS_7C88
|
||||
0x7C89, // MS_7C89
|
||||
0x4559, // MS_4459
|
||||
0x3EA4, // MS_3EA4
|
||||
0x905D, // MS_905D
|
||||
0x7C90, // MS_7C90
|
||||
0x7C91, // MS_7C91
|
||||
0x7C92, // MS_7C92
|
||||
0x7C94, // MS_7C94
|
||||
0x7C95, // MS_7C95
|
||||
0x7C96, // MS_7C96
|
||||
0x7C56 // MS_7C56
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
@@ -59,32 +60,39 @@ constexpr unsigned short SupportedPIDs[41] =
|
||||
|
||||
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
if(hid_init() < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_device_info * device_list = hid_enumerate(MSI_VID, 0);
|
||||
if(!device_list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hid_init();
|
||||
|
||||
hid_device_info * device = device_list;
|
||||
while(device)
|
||||
for(int device_idx = 0; device_idx < NUM_MSI_PIDS; device_idx++)
|
||||
{
|
||||
if(std::find(std::begin(SupportedPIDs), std::end(SupportedPIDs), device->product_id) != std::end(SupportedPIDs))
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(MSI_USB_VID, msi_pid_table[device_idx]);
|
||||
|
||||
//Look for MSI Mystic Light Controller
|
||||
while(info)
|
||||
{
|
||||
hid_device * dev = hid_open_path(device->path);
|
||||
if(dev)
|
||||
if((info->vendor_id == MSI_USB_VID)
|
||||
&&(info->product_id == msi_pid_table[device_idx]))
|
||||
{
|
||||
MSIMysticLightController * controller = new MSIMysticLightController(dev, device_list->path);
|
||||
RGBController_MSIMysticLight * rgb_controller = new RGBController_MSIMysticLight(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
device = device->next;
|
||||
}
|
||||
|
||||
hid_free_enumeration(device_list);
|
||||
if( dev )
|
||||
{
|
||||
MSIMysticLightController * controller = new MSIMysticLightController(dev, info->path);
|
||||
|
||||
RGBController_MSIMysticLight * rgb_controller = new RGBController_MSIMysticLight(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+38
-21
@@ -4,26 +4,32 @@
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 12/29/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Hue2Controller.h"
|
||||
#include "NZXTHue2Controller.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
|
||||
NZXTHue2Controller::NZXTHue2Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
SendFirmwareRequest();
|
||||
GetStripsOnChannel(HUE_2_CHANNEL_1);
|
||||
}
|
||||
|
||||
Hue2Controller::~Hue2Controller()
|
||||
NZXTHue2Controller::~NZXTHue2Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
std::string NZXTHue2Controller::GetFirmwareVersion()
|
||||
{
|
||||
return(firmware_version);
|
||||
}
|
||||
|
||||
unsigned int NZXTHue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
{
|
||||
unsigned int ret_val = 0;
|
||||
|
||||
@@ -46,10 +52,9 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
int actual = 0;
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
for(int chan = 0; chan < 4; chan++)
|
||||
{
|
||||
@@ -88,7 +93,7 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
|
||||
return(ret_val);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelEffect
|
||||
void NZXTHue2Controller::SetChannelEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
@@ -118,7 +123,7 @@ void Hue2Controller::SetChannelEffect
|
||||
SendEffect(channel, mode, speed, direction, num_colors, &color_data[0]);
|
||||
}
|
||||
|
||||
void Hue2Controller::SetChannelLEDs
|
||||
void NZXTHue2Controller::SetChannelLEDs
|
||||
(
|
||||
unsigned char channel,
|
||||
RGBColor * colors,
|
||||
@@ -162,12 +167,11 @@ void Hue2Controller::SetChannelLEDs
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void Hue2Controller::SendApply
|
||||
void NZXTHue2Controller::SendApply
|
||||
(
|
||||
unsigned char channel
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -190,11 +194,11 @@ void Hue2Controller::SendApply
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void Hue2Controller::SendDirect
|
||||
void NZXTHue2Controller::SendDirect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char group,
|
||||
@@ -202,7 +206,6 @@ void Hue2Controller::SendDirect
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -226,11 +229,11 @@ void Hue2Controller::SendDirect
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void Hue2Controller::SendEffect
|
||||
void NZXTHue2Controller::SendEffect
|
||||
(
|
||||
unsigned char channel,
|
||||
unsigned char mode,
|
||||
@@ -240,7 +243,6 @@ void Hue2Controller::SendEffect
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -281,6 +283,21 @@ void Hue2Controller::SendEffect
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x0A], color_data, color_count * 3);
|
||||
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void NZXTHue2Controller::SendFirmwareRequest()
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x10;
|
||||
usb_buf[0x01] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
|
||||
snprintf(firmware_version, 16, "%u.%u.%u", usb_buf[0x11], usb_buf[0x12], usb_buf[0x13]);
|
||||
}
|
||||
+11
-5
@@ -5,8 +5,9 @@
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -50,11 +51,13 @@ enum
|
||||
HUE_2_NUM_MODES /* Number of Hue 2 modes */
|
||||
};
|
||||
|
||||
class Hue2Controller
|
||||
class NZXTHue2Controller
|
||||
{
|
||||
public:
|
||||
Hue2Controller(libusb_device_handle* dev_handle);
|
||||
~Hue2Controller();
|
||||
NZXTHue2Controller(hid_device* dev_handle);
|
||||
~NZXTHue2Controller();
|
||||
|
||||
std::string GetFirmwareVersion();
|
||||
|
||||
unsigned int GetStripsOnChannel
|
||||
(
|
||||
@@ -81,7 +84,8 @@ public:
|
||||
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
hid_device* dev;
|
||||
char firmware_version[16];
|
||||
|
||||
void SendApply
|
||||
(
|
||||
@@ -105,4 +109,6 @@ private:
|
||||
unsigned char color_count,
|
||||
unsigned char* color_data
|
||||
);
|
||||
|
||||
void SendFirmwareRequest();
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "NZXTHue2Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_NZXTHue2.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define NZXT_VID 0x1E71
|
||||
#define NZXT_HUE_2_PID 0x2001
|
||||
#define NZXT_HUE_2_AMBIENT_PID 0x2002
|
||||
#define NZXT_SMART_DEVICE_V2_PID 0x2006
|
||||
#define NZXT_RGB_FAN_CONTROLLER_PID 0x2009
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
const char * name;
|
||||
} nzxt_hue_2_device;
|
||||
|
||||
#define NZXT_HUE_2_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const nzxt_hue_2_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| NZXT Hue 2 devices |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ NZXT_VID, NZXT_HUE_2_PID, "NZXT Hue 2" },
|
||||
{ NZXT_VID, NZXT_HUE_2_AMBIENT_PID, "NZXT Hue 2 Ambient" },
|
||||
{ NZXT_VID, NZXT_SMART_DEVICE_V2_PID, "NZXT Smart Device V2" },
|
||||
{ NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID, "NZXT RGB & Fan Controller" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNZXTHue2Controllers *
|
||||
* *
|
||||
* Detect devices supported by the NZXT Hue 2 driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectNZXTHue2Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(std::size_t device_idx = 0; device_idx < NZXT_HUE_2_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for NZXT Hue 2 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);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if( dev )
|
||||
{
|
||||
NZXTHue2Controller* controller = new NZXTHue2Controller(dev);
|
||||
|
||||
RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
} /* DetectNZXTHue2Controllers() */
|
||||
@@ -10,9 +10,6 @@
|
||||
#include <sstream>
|
||||
#include <cstring>
|
||||
|
||||
const int NZXT_KRAKEN_READ_ENDPOINT = 0x81;
|
||||
const int NZXT_KRAKEN_WRITE_ENDPOINT = 0x01;
|
||||
|
||||
static void SetColor(const std::vector<RGBColor>& colors, unsigned char* color_data)
|
||||
{
|
||||
for (std::size_t idx = 0; idx < colors.size(); idx++)
|
||||
@@ -30,7 +27,7 @@ static RGBColor ToLogoColor(RGBColor rgb)
|
||||
return ToRGBColor(RGBGetGValue(rgb), RGBGetRValue(rgb), RGBGetBValue(rgb));
|
||||
}
|
||||
|
||||
NZXTKrakenController::NZXTKrakenController(libusb_device_handle* dev_handle)
|
||||
NZXTKrakenController::NZXTKrakenController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
@@ -42,7 +39,7 @@ NZXTKrakenController::NZXTKrakenController(libusb_device_handle* dev_handle)
|
||||
|
||||
NZXTKrakenController::~NZXTKrakenController()
|
||||
{
|
||||
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string NZXTKrakenController::GetFirmwareVersion()
|
||||
@@ -52,11 +49,10 @@ std::string NZXTKrakenController::GetFirmwareVersion()
|
||||
|
||||
void NZXTKrakenController::UpdateStatus()
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[64];
|
||||
memset(usb_buf, 0, sizeof(usb_buf));
|
||||
|
||||
libusb_interrupt_transfer(dev, NZXT_KRAKEN_READ_ENDPOINT, usb_buf, sizeof(usb_buf), &actual, 0);
|
||||
hid_read(dev, usb_buf, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Extract cooler information |
|
||||
@@ -110,7 +106,6 @@ void NZXTKrakenController::SendEffect
|
||||
int size /* = 0 */
|
||||
)
|
||||
{
|
||||
int actual;
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -154,13 +149,5 @@ void NZXTKrakenController::SendEffect
|
||||
/*-----------------------------------------------------*\
|
||||
| Send effect |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer
|
||||
(
|
||||
dev,
|
||||
NZXT_KRAKEN_WRITE_ENDPOINT,
|
||||
usb_buf,
|
||||
sizeof(usb_buf),
|
||||
&actual,
|
||||
0
|
||||
);
|
||||
hid_write(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
enum NZXTKrakenChannel_t
|
||||
{
|
||||
@@ -46,7 +46,7 @@ enum
|
||||
class NZXTKrakenController
|
||||
{
|
||||
public:
|
||||
NZXTKrakenController(libusb_device_handle* dev_handle);
|
||||
NZXTKrakenController(hid_device* dev_handle);
|
||||
~NZXTKrakenController();
|
||||
|
||||
std::string GetFirmwareVersion();
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
int size = 0
|
||||
);
|
||||
|
||||
libusb_device_handle* dev;
|
||||
hid_device* dev;
|
||||
|
||||
// -- status
|
||||
std::string firmware_version;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_NZXTKraken.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define NZXT_KRAKEN_VID 0x1E71
|
||||
#define NZXT_KRAKEN_PID 0x170E
|
||||
@@ -17,16 +17,12 @@
|
||||
|
||||
void DetectNZXTKrakenControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
hid_init();
|
||||
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, NZXT_KRAKEN_VID, NZXT_KRAKEN_PID);
|
||||
hid_device* dev = hid_open(NZXT_KRAKEN_VID, NZXT_KRAKEN_PID, nullptr);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
|
||||
NZXTKrakenController* controller = new NZXTKrakenController(dev);
|
||||
|
||||
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -44,13 +35,13 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
// Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
|
||||
{
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x85)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x02)
|
||||
@@ -67,7 +58,7 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
|
||||
@@ -15,49 +15,33 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
switch (GetFirmwareVersion())
|
||||
unsigned short fw_version = GetFirmwareVersion();
|
||||
unsigned char major_version = fw_version >> 8;
|
||||
unsigned char minor_version = fw_version & 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| 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 |
|
||||
\*-----------------------------------------------------*/
|
||||
if((major_version < 0x03) && (major_version > 0x00))
|
||||
{
|
||||
case FIRMWARE_VER_1_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 1.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_08:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.08");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 2.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_04:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.04");
|
||||
break;
|
||||
|
||||
default:
|
||||
led_count = 0;
|
||||
strcpy(device_name, "");
|
||||
break;
|
||||
snprintf(device_name, 32, "ASRock ASR LED FW %d.%02d", major_version, minor_version);
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
}
|
||||
else if(major_version == 0x03)
|
||||
{
|
||||
snprintf(device_name, 32, "ASRock Polychrome FW %d.%02d", major_version, minor_version);
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
led_count = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PolychromeController::~PolychromeController()
|
||||
|
||||
@@ -14,16 +14,6 @@
|
||||
|
||||
typedef unsigned char polychrome_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
FIRMWARE_VER_1_PT_10 = 0x010A, /* Firmware nu51_1.10 */
|
||||
FIRMWARE_VER_2_PT_00 = 0x0200, /* Firmware nu51_2.00 */
|
||||
FIRMWARE_VER_2_PT_08 = 0x0208, /* Firmware nu51_2.08 */
|
||||
FIRMWARE_VER_2_PT_10 = 0x020A, /* Firmware nu51_2.10 */
|
||||
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
|
||||
FIRMWARE_VER_3_PT_04 = 0x0304, /* Firmware nu51_3.04 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
|
||||
@@ -11,16 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15,
|
||||
0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
|
||||
@@ -57,7 +48,7 @@ void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction
|
||||
active_speed
|
||||
);
|
||||
|
||||
Sleep(200);
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
@@ -107,7 +98,7 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, red_grn_buf, 264);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
hid_send_feature_report(dev, blu_buf, 264);
|
||||
}
|
||||
@@ -132,7 +123,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -141,7 +132,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -150,7 +141,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendControl
|
||||
(
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2DRAMController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion 2 |
|
||||
| DRAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusion2DRAMController.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RGBFusion2DRAMController::RGBFusion2DRAMController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize pointers |
|
||||
\*-----------------------------------------------------*/
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(led_data, 0, sizeof(led_data));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize controller with 6 LEDs and mask 0x3B |
|
||||
| This is hard coded for Aorus RGB RAM |
|
||||
\*-----------------------------------------------------*/
|
||||
led_data[RGB_FUSION_2_DRAM_LED_EN_MASK] = 0x3B;
|
||||
led_count = 6;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize brightness to 100% |
|
||||
\*-----------------------------------------------------*/
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_BRIGHTNESS] = 0x64;
|
||||
}
|
||||
|
||||
unsigned int RGBFusion2DRAMController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
std::string RGBFusion2DRAMController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
void RGBFusion2DRAMController::Apply()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_2_DRAM_APPLY_ADDR, RGB_FUSION_2_DRAM_ACTION_APPLY);
|
||||
}
|
||||
|
||||
void RGBFusion2DRAMController::SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_MODE] = mode;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_RED] = red;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_GREEN] = green;
|
||||
led_data[RGB_FUSION_2_DRAM_IDX_BLUE] = blue;
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, RGB_FUSION_2_DRAM_LED_START_ADDR, 32, led_data);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2DRAMController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion 2 DRAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/7/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_DRAM_LED_EN_MASK = 0x00, /* LED enable bitfield */
|
||||
RGB_FUSION_2_DRAM_IDX_MODE = 0x09, /* Mode index */
|
||||
RGB_FUSION_2_DRAM_IDX_BRIGHTNESS = 0x0A, /* Brightness index */
|
||||
RGB_FUSION_2_DRAM_IDX_BLUE = 0x0C, /* Blue index */
|
||||
RGB_FUSION_2_DRAM_IDX_GREEN = 0x0D, /* Green index */
|
||||
RGB_FUSION_2_DRAM_IDX_RED = 0x0E, /* Red index */
|
||||
// RGB_FUSION_2_DRAM_TIMER_1_LSB = 0x08, /* Timer 1 LSB. Valid timer values [0-65535] */
|
||||
// RGB_FUSION_2_DRAM_TIMER_1_MSB = 0x09, /* Timer 1 MSB. Timer unis are milliseconds */
|
||||
// RGB_FUSION_2_DRAM_TIMER_2_LSB = 0x0A, /* Timer 2 LSB */
|
||||
// RGB_FUSION_2_DRAM_TIMER_2_MSB = 0x0B, /* Timer 2 MSB */
|
||||
// RGB_FUSION_2_DRAM_TIMER_3_LSB = 0x0C, /* Timer 3 LSB */
|
||||
// RGB_FUSION_2_DRAM_TIMER_3_MSB = 0x0D, /* Timer 3 MSB */
|
||||
// RGB_FUSION_2_DRAM_IDX_OPT_1 = 0x0E, /* Option 1. Use case varies by mode */
|
||||
// RGB_FUSION_2_DRAM_IDX_OPT_2 = 0x0F, /* Option 2. Use case varies by mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_DRAM_LED_START_ADDR = 0x20,
|
||||
RGB_FUSION_2_DRAM_APPLY_ADDR = 0x28,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_DRAM_ACTION_APPLY = 0x0F,
|
||||
};
|
||||
|
||||
class RGBFusion2DRAMController
|
||||
{
|
||||
public:
|
||||
RGBFusion2DRAMController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusion2DRAMController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void Apply();
|
||||
|
||||
void SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
unsigned char led_data[32];
|
||||
};
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "RGBFusion2DRAMController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion2DRAM.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusion2DRAMController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB 2 Fusion DRAMcontroller exists there. *
|
||||
* First does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusion2DRAMController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
// res = bus->i2c_smbus_read_byte_data(address, 0xF2);
|
||||
|
||||
// if (res != 0xC4)
|
||||
// {
|
||||
// pass = false;
|
||||
// }
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusion2DRAMController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusion2DRAMControllers *
|
||||
* *
|
||||
* Detect RGB Fusion 2 controllers on the enumerated I2C busses at address 0x67. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusion2DRAMControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusion2DRAMController* new_rgb_fusion;
|
||||
RGBController_RGBFusion2DRAM* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for RGB Fusion 2 DRAM controller at 0x67
|
||||
if (TestForRGBFusion2DRAMController(busses[bus], 0x67))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusion2DRAMController(busses[bus], 0x67);
|
||||
new_controller = new RGBController_RGBFusion2DRAM(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusion2DRAMControllers() */
|
||||
@@ -0,0 +1,139 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2SMBusController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion 2 |
|
||||
| SMBus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/12/2020 |
|
||||
| Matt Harper 5/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusion2SMBusController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#endif
|
||||
|
||||
RGBFusion2SMBusController::RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
memset(led_data, 0, 10*16);
|
||||
|
||||
led_count = 10; // Protocol supports 10 'slots'
|
||||
}
|
||||
|
||||
unsigned int RGBFusion2SMBusController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
std::string RGBFusion2SMBusController::GetDeviceLocation()
|
||||
{
|
||||
std::string return_string(bus->device_name);
|
||||
char addr[5];
|
||||
snprintf(addr, 5, "0x%02X", dev);
|
||||
return_string.append(", address ");
|
||||
return_string.append(addr);
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
/* Writes are performed in 32 byte chunks. If we need to write the second 16 bytes,
|
||||
* we must necessarily write the first 16 as well. Given that reading the existing state
|
||||
* from the device is not yet possible, unfortunately we may overwrite existing device
|
||||
* states if the state transition did not occur within in the same OpenRGB instance.
|
||||
* That is to say, the current behavior is non-deal but the best we have
|
||||
*/
|
||||
void RGBFusion2SMBusController::WriteLED(int led)
|
||||
{
|
||||
unsigned short register_offset = led / 2; // Relying on integer division to truncate
|
||||
unsigned short write_register = RGB_FUSION_2_LED_START_ADDR + 2*register_offset;
|
||||
|
||||
// Adjust if we are writing the second 16 bytes
|
||||
if(led % 2)
|
||||
{
|
||||
led -= 1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cout << std::hex << write_register << "\t";
|
||||
for(int i = 0; i < 2; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
std::cout << std::setw(2) << std::setfill('0') << std::hex << (int)led_data[led+i][j] << " ";
|
||||
}
|
||||
std::cout << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
#endif
|
||||
|
||||
bus->i2c_smbus_write_block_data(RGB_FUSION_2_SMBUS_ADDR, write_register, 32, led_data[led]);
|
||||
}
|
||||
|
||||
void RGBFusion2SMBusController::Apply()
|
||||
{
|
||||
// Protocol expects terminating sequence 0x01ff written to register 0x17
|
||||
bus->i2c_smbus_write_word_data(RGB_FUSION_2_SMBUS_ADDR,
|
||||
RGB_FUSION_2_APPLY_ADDR,
|
||||
RGB_FUSION_2_ACTION_APPLY);
|
||||
}
|
||||
|
||||
void RGBFusion2SMBusController::SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
led_data[led][RGB_FUSION_2_IDX_MODE] = mode;
|
||||
led_data[led][RGB_FUSION_2_IDX_RED] = red;
|
||||
led_data[led][RGB_FUSION_2_IDX_GREEN] = green;
|
||||
led_data[led][RGB_FUSION_2_IDX_BLUE] = blue;
|
||||
led_data[led][RGB_FUSION_2_IDX_BRIGHTNESS] = 0x64;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case RGB_FUSION_2_MODE_PULSE:
|
||||
// Timer 1: On time
|
||||
// Timer 2: Off time
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x20 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0x03 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_LSB] = 0x20 * speed;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_MSB] = 0x03 * speed;
|
||||
break;
|
||||
|
||||
case RGB_FUSION_2_MODE_COLOR_CYCLE:
|
||||
// Timer 1: Cycle time
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x00;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0x03 * speed;
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_1] = 0x07; // Number of colors to cycle through. Valid range [1-7]
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_2] = 0x00; // Color cycle, or color cycle and pulse. [0,1]
|
||||
break;
|
||||
|
||||
case RGB_FUSION_2_MODE_FLASHING:
|
||||
/* Timer 1: On time
|
||||
* Timer 2: Interval
|
||||
* Timer 3: Cycle time */
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_LSB] = 0x64;
|
||||
led_data[led][RGB_FUSION_2_TIMER_1_MSB] = 0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_LSB] = 0xc8;
|
||||
led_data[led][RGB_FUSION_2_TIMER_2_MSB] = 0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_3_LSB] = 0xd0;
|
||||
led_data[led][RGB_FUSION_2_TIMER_3_MSB] = 0x07;
|
||||
|
||||
led_data[led][RGB_FUSION_2_IDX_OPT_1] = speed; // Controls number of flashes
|
||||
break;
|
||||
}
|
||||
|
||||
WriteLED(led);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusion2SMBusController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion 2 SMBus lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_IDX_MODE = 0x01, /* Mode index */
|
||||
RGB_FUSION_2_IDX_BRIGHTNESS = 0x02, /* Brightness index */
|
||||
RGB_FUSION_2_IDX_MAX_BRIGHTNESS = 0x02, /* Max brightness index */
|
||||
RGB_FUSION_2_IDX_MIN_BRIGHTNESS = 0x03, /* Minimum brightness index */
|
||||
RGB_FUSION_2_IDX_BLUE = 0x04, /* Blue index */
|
||||
RGB_FUSION_2_IDX_GREEN = 0x05, /* Green index */
|
||||
RGB_FUSION_2_IDX_RED = 0x06, /* Red index */
|
||||
RGB_FUSION_2_IDX_WHITE = 0x07, /* White index */
|
||||
RGB_FUSION_2_TIMER_1_LSB = 0x08, /* Timer 1 LSB. Valid timer values [0-65535] */
|
||||
RGB_FUSION_2_TIMER_1_MSB = 0x09, /* Timer 1 MSB. Timer unis are milliseconds */
|
||||
RGB_FUSION_2_TIMER_2_LSB = 0x0A, /* Timer 2 LSB */
|
||||
RGB_FUSION_2_TIMER_2_MSB = 0x0B, /* Timer 2 MSB */
|
||||
RGB_FUSION_2_TIMER_3_LSB = 0x0C, /* Timer 3 LSB */
|
||||
RGB_FUSION_2_TIMER_3_MSB = 0x0D, /* Timer 3 MSB */
|
||||
RGB_FUSION_2_IDX_OPT_1 = 0x0E, /* Option 1. Use case varies by mode */
|
||||
RGB_FUSION_2_IDX_OPT_2 = 0x0F, /* Option 2. Use case varies by mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_APPLY_ADDR = 0x17,
|
||||
RGB_FUSION_2_LED_START_ADDR = 0x20,
|
||||
RGB_FUSION_2_SMBUS_ADDR = 0x68,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_ACTION_APPLY = 0x01ff,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_MODE_PULSE = 0x01, /* Pulse mode */
|
||||
RGB_FUSION_2_MODE_MUSIC = 0x02, /* Music mode */
|
||||
RGB_FUSION_2_MODE_COLOR_CYCLE = 0x03, /* Color cycle mode */
|
||||
RGB_FUSION_2_MODE_STATIC = 0x04, /* Static color mode */
|
||||
RGB_FUSION_2_MODE_FLASHING = 0x05, /* Flashing / Double Flashing mode */
|
||||
RGB_FUSION_2_MODE_TRANSITION = 0x09, /* Gradual transition from current */
|
||||
RGB_FUSION_2_MODE_DIGITAL_A = 0x0A, /* Wave mode */
|
||||
RGB_FUSION_2_MODE_DIGITAL_B = 0x0B, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_C = 0x0C, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_D = 0x0D, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_E = 0x0E, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_F = 0x0F, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_G = 0x10, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_H = 0x11, /* */
|
||||
RGB_FUSION_2_MODE_DIGITAL_I = 0x12, /* */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_2_SPEED_FAST = 0x01,
|
||||
RGB_FUSION_2_SPEED_NORMAL = 0x02,
|
||||
RGB_FUSION_2_SPEED_SLOW = 0x04,
|
||||
};
|
||||
|
||||
class RGBFusion2SMBusController
|
||||
{
|
||||
public:
|
||||
RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusion2SMBusController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
unsigned int GetLEDCount();
|
||||
void Apply();
|
||||
|
||||
void SetLEDEffect
|
||||
(
|
||||
unsigned int led,
|
||||
int mode,
|
||||
unsigned int speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
unsigned char led_data[10][16];
|
||||
|
||||
void WriteLED(int);
|
||||
};
|
||||
@@ -0,0 +1,73 @@
|
||||
#include "RGBFusion2SMBusController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion2SMBus.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusion2SMBusController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB 2 Fusion controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusion2SMBusController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
// res = bus->i2c_smbus_read_byte_data(address, 0xF2);
|
||||
|
||||
// if (res != 0xC4)
|
||||
// {
|
||||
// pass = false;
|
||||
// }
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusion2SMBusController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusion2SMBusControllers *
|
||||
* *
|
||||
* Detect RGB Fusion 2 controllers on the enumerated I2C busses at address 0x68. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusion2SMBusController* new_rgb_fusion;
|
||||
RGBController_RGBFusion2SMBus* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// TODO - Is this necessary? Or an artifact of my own system?
|
||||
// Skip dmcd devices
|
||||
std::string device_name = std::string(busses[bus]->device_name);
|
||||
if (device_name.find("dmdc") == std::string::npos)
|
||||
{
|
||||
// Check for RGB Fusion 2 controller at 0x68
|
||||
if (TestForRGBFusion2SMBusController(busses[bus], 0x68))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68);
|
||||
new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusion2SMBusControllers() */
|
||||
@@ -11,8 +11,10 @@
|
||||
\*-----------------------------------------------------*/
|
||||
#define REDRAGON_KEYBOARD_VID 0x0C45
|
||||
#define REDRAGON_K550_PID 0x5204
|
||||
#define REDRAGON_K552_PID 0x5104
|
||||
#define REDRAGON_K556_PID 0x5004
|
||||
|
||||
#define TECWARE_PHANTOM_ELITE_PID 0x652F
|
||||
#define WARRIOR_KANE_TC235 0x8520
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
@@ -34,19 +36,22 @@ typedef struct
|
||||
|
||||
static const redragon_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
|
||||
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
|
||||
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
|
||||
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
|
||||
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
|
||||
@@ -20,6 +20,63 @@ static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
||||
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
unsigned char active_profile = 0x00;
|
||||
|
||||
SendWritePacket(0x002C, 1, &active_profile);
|
||||
SendMouseApply();
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char color_buf[3];
|
||||
|
||||
color_buf[0] = red;
|
||||
color_buf[1] = green;
|
||||
color_buf[2] = blue;
|
||||
|
||||
SendWritePacket(0x0449, 3, color_buf);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char mode_buf[3];
|
||||
|
||||
mode_buf[0] = 0x01; //On
|
||||
mode_buf[1] = speed;
|
||||
mode_buf[2] = mode;
|
||||
|
||||
SendWritePacket(0x044C, 3, mode_buf);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char color_mode_buf[6];
|
||||
|
||||
color_mode_buf[0] = red;
|
||||
color_mode_buf[1] = green;
|
||||
color_mode_buf[2] = blue;
|
||||
color_mode_buf[3] = 0x01; //On
|
||||
color_mode_buf[4] = speed;
|
||||
color_mode_buf[5] = mode;
|
||||
|
||||
SendWritePacket(0x0449, 6, color_mode_buf);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
@@ -49,13 +106,11 @@ void RedragonM711Controller::SendMouseApply()
|
||||
send_usb_msg(dev, usb_buf, 16);
|
||||
}
|
||||
|
||||
void RedragonM711Controller::SendMouseMode
|
||||
void RedragonM711Controller::SendWritePacket
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
unsigned short address,
|
||||
unsigned char data_size,
|
||||
unsigned char * data
|
||||
)
|
||||
{
|
||||
char usb_buf[16];
|
||||
@@ -70,19 +125,15 @@ void RedragonM711Controller::SendMouseMode
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x02;
|
||||
usb_buf[0x01] = 0xF3;
|
||||
usb_buf[0x02] = 0x49;
|
||||
usb_buf[0x03] = 0x04;
|
||||
usb_buf[0x04] = 0x06;
|
||||
|
||||
usb_buf[0x08] = red;
|
||||
usb_buf[0x09] = green;
|
||||
usb_buf[0x0A] = blue;
|
||||
|
||||
usb_buf[0x0B] = 0x01; //on
|
||||
|
||||
usb_buf[0x0C] = speed;
|
||||
usb_buf[0x0D] = mode;
|
||||
usb_buf[0x02] = address & 0xFF;
|
||||
usb_buf[0x03] = address >> 8;
|
||||
usb_buf[0x04] = data_size;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in data bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x08], data, data_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
@@ -32,6 +32,19 @@ public:
|
||||
|
||||
void SendMouseApply();
|
||||
|
||||
void SendMouseColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
@@ -43,4 +56,11 @@ public:
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void SendWritePacket
|
||||
(
|
||||
unsigned short address,
|
||||
unsigned char data_size,
|
||||
unsigned char * data
|
||||
);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
#include "SteelSeriesRivalController.h"
|
||||
#include "SteelSeriesSiberiaController.h"
|
||||
#include "SteelSeriesGeneric.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_SteelSeriesRival.h"
|
||||
#include "RGBController_SteelSeriesSiberia.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define STEELSERIES_VID 0x1038
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define STEELSERIES_RIVAL_100_PID 0x1702
|
||||
#define STEELSERIES_RIVAL_100_DOTA_PID 0x170c
|
||||
#define STEELSERIES_RIVAL_105_PID 0x1814
|
||||
#define STEELSERIES_RIVAL_110_PID 0x1729
|
||||
#define STEELSERIES_RIVAL_300_PID 0x1384
|
||||
#define ACER_PREDATOR_RIVAL_300_PID 0x1714
|
||||
#define STEELSERIES_RIVAL_300_CSGO_PID 0x1394
|
||||
#define STEELSERIES_RIVAL_300_CSGO_STM32_PID 0x1716
|
||||
#define STEELSERIES_RIVAL_300_CSGO_HYPERBEAST_PID 0x171a
|
||||
#define STEELSERIES_RIVAL_300_DOTA_PID 0x1392
|
||||
#define STEELSERIES_RIVAL_300_HP_PID 0x1718
|
||||
#define STEELSERIES_RIVAL_300_BLACKOPS_PID 0x1710
|
||||
/*-----------------------------------------------------*\
|
||||
| Headset product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define STEELSERIES_SIBERIA_350_PID 0x1229
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
unsigned char usb_interface;
|
||||
device_type type;
|
||||
steelseries_type proto_type;
|
||||
const char * name;
|
||||
} steelseries_device;
|
||||
|
||||
#define STEELSERIES_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const steelseries_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_100_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_100, "SteelSeries Rival 100" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_100_DOTA_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_100, "SteelSeries Rival 100 DotA 2 Edition" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_105_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_100, "SteelSeries Rival 105" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_110_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_100, "SteelSeries Rival 110" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300" },
|
||||
{ STEELSERIES_VID, ACER_PREDATOR_RIVAL_300_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "Acer Predator Gaming Mouse (Rival 300)" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_CSGO_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 CS:GO Fade Edition" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_CSGO_STM32_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 CS:GO Fade Edition (stm32)" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_CSGO_HYPERBEAST_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 CS:GO Hyperbeast Edition" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_DOTA_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 Dota 2 Edition" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_HP_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 HP Omen Edition" },
|
||||
{ STEELSERIES_VID, STEELSERIES_RIVAL_300_BLACKOPS_PID, 0, DEVICE_TYPE_MOUSE, RIVAL_300, "SteelSeries Rival 300 Black Ops Edition" },
|
||||
/*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
| Headsets |
|
||||
\*-----------------------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
{ STEELSERIES_VID, STEELSERIES_SIBERIA_350_PID, 3, DEVICE_TYPE_HEADSET, SIBERIA_350, "SteelSeries Siberia 350" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectSteelSeriesControllers *
|
||||
* *
|
||||
* Tests the USB address to find a SteelSeries Rival Mouse or Headset *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectSteelSeriesControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(int device_idx = 0; device_idx < STEELSERIES_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for SteelSeries RGB Peripheral
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if(dev)
|
||||
{
|
||||
switch(device_list[device_idx].type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
/* Not yet supported */
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET:
|
||||
{
|
||||
SteelSeriesSiberiaController* controller = new SteelSeriesSiberiaController(dev);
|
||||
|
||||
RGBController_SteelSeriesSiberia* rgb_controller = new RGBController_SteelSeriesSiberia(controller);
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
{
|
||||
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, device_list[device_idx].proto_type);
|
||||
|
||||
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
/* Not yet supported */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesGeneric.h |
|
||||
| |
|
||||
| Definitions and types for the SteelSeries|
|
||||
| Devices. |
|
||||
| |
|
||||
| B Horn (bahorn) 17/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Allows us to handle variation in the protocol.
|
||||
* Defined in a single enum so we can keep the device_list struct the same
|
||||
* for every possible device. */
|
||||
typedef enum
|
||||
{
|
||||
RIVAL_100 = 0x00,
|
||||
RIVAL_300 = 0x01,
|
||||
SIBERIA_350 = 0x03,
|
||||
} steelseries_type;
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRivalController.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 13/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SteelSeriesRivalController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
||||
{
|
||||
char* usb_pkt = new char[size + 1];
|
||||
|
||||
usb_pkt[0] = 0x00;
|
||||
for(unsigned int i = 1; i < size + 1; i++)
|
||||
{
|
||||
usb_pkt[i] = data_pkt[i-1];
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_pkt, size + 1);
|
||||
|
||||
delete usb_pkt;
|
||||
}
|
||||
|
||||
SteelSeriesRivalController::SteelSeriesRivalController
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type
|
||||
)
|
||||
{
|
||||
dev = dev_handle;
|
||||
proto = proto_type;
|
||||
}
|
||||
|
||||
SteelSeriesRivalController::~SteelSeriesRivalController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* SteelSeriesRivalController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
steelseries_type SteelSeriesRivalController::GetMouseType()
|
||||
{
|
||||
return proto;
|
||||
}
|
||||
|
||||
/* Saves to the internal configuration */
|
||||
void SteelSeriesRivalController::Save()
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x09;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffect
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto) {
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
}
|
||||
usb_buf[0x02] = effect;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffectAll
|
||||
(
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetLightEffect(0, effect);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetLightEffect(0, effect);
|
||||
SetLightEffect(1, effect);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x05;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x08;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
}
|
||||
usb_buf[0x02] = red;
|
||||
usb_buf[0x03] = green;
|
||||
usb_buf[0x04] = blue;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetColorAll
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetColor(0, red, green, blue);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetColor(0, red, green, blue);
|
||||
SetColor(1, red, green, blue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRivalController.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 13/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "SteelSeriesGeneric.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Mode, we then use these to set actual effect based on speed. */
|
||||
enum
|
||||
{
|
||||
STEELSERIES_RIVAL_STATIC = 0x00,
|
||||
STEELSERIES_RIVAL_PULSATE = 0x01
|
||||
};
|
||||
|
||||
/* Effects */
|
||||
enum
|
||||
{
|
||||
STEELSERIES_RIVAL_EFFECT_STATIC = 0x01,
|
||||
STEELSERIES_RIVAL_EFFECT_PULSATE_MIN = 0x02,
|
||||
STEELSERIES_RIVAL_EFFECT_PULSATE_MID = 0x03,
|
||||
STEELSERIES_RIVAL_EFFECT_PULSATE_MAX = 0x04
|
||||
};
|
||||
|
||||
class SteelSeriesRivalController
|
||||
{
|
||||
public:
|
||||
SteelSeriesRivalController
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type
|
||||
);
|
||||
|
||||
~SteelSeriesRivalController();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
steelseries_type GetMouseType();
|
||||
|
||||
void Save();
|
||||
|
||||
void SetLightEffect
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char effect
|
||||
);
|
||||
|
||||
void SetLightEffectAll
|
||||
(
|
||||
unsigned char effect
|
||||
);
|
||||
|
||||
void SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
void SetColorAll
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
steelseries_type proto;
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesSiberiaController.cpp |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Siberia lighting controller |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18/6/2020 |
|
||||
|
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SteelSeriesSiberiaController.h"
|
||||
#include <cstring>
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
||||
{
|
||||
char* usb_pkt = new char[16];
|
||||
memset(usb_pkt, 0x00, sizeof(usb_pkt));
|
||||
|
||||
// Report number
|
||||
usb_pkt[0] = 0x01;
|
||||
// Magic
|
||||
usb_pkt[1] = 0x00;
|
||||
// Command
|
||||
usb_pkt[2] = data_pkt[0];
|
||||
// Payload length
|
||||
usb_pkt[3] = size - 1;
|
||||
|
||||
for(unsigned int i = 0; i < (size - 1); i++)
|
||||
{
|
||||
usb_pkt[4 + i] = data_pkt[1 + i];
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_pkt, 16);
|
||||
|
||||
delete[] usb_pkt;
|
||||
}
|
||||
|
||||
SteelSeriesSiberiaController::SteelSeriesSiberiaController
|
||||
(
|
||||
hid_device* dev_handle
|
||||
)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
SteelSeriesSiberiaController::~SteelSeriesSiberiaController()
|
||||
{
|
||||
}
|
||||
|
||||
char* SteelSeriesSiberiaController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
void SteelSeriesSiberiaController::SetColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[4];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
// Command 1
|
||||
usb_buf[0] = 0x95;
|
||||
usb_buf[1] = 0x80;
|
||||
usb_buf[2] = 0xbf;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
|
||||
// Command 2
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x80;
|
||||
usb_buf[1] = 0x52;
|
||||
usb_buf[2] = 0x20;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
|
||||
// Command 3 (Set color)
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x83;
|
||||
usb_buf[1] = red;
|
||||
usb_buf[2] = green;
|
||||
usb_buf[3] = blue;
|
||||
send_usb_msg(dev, usb_buf, 4);
|
||||
|
||||
// Command 4
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x93;
|
||||
usb_buf[1] = 0x03;
|
||||
usb_buf[2] = 0x80;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesSiberiaController.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Siberia lighting controller |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18/6/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
class SteelSeriesSiberiaController
|
||||
{
|
||||
public:
|
||||
SteelSeriesSiberiaController
|
||||
(
|
||||
hid_device* dev_handle
|
||||
);
|
||||
|
||||
~SteelSeriesSiberiaController();
|
||||
|
||||
char* GetDeviceName();
|
||||
|
||||
void SetColor
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
hid_device* dev;
|
||||
};
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev_handle)
|
||||
ThermaltakeRiingController::ThermaltakeRiingController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
|
||||
@@ -53,7 +53,6 @@ void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed
|
||||
void ThermaltakeRiingController::SendInit()
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -69,8 +68,8 @@ void ThermaltakeRiingController::SendInit()
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
void ThermaltakeRiingController::SendRGB
|
||||
@@ -83,7 +82,6 @@ void ThermaltakeRiingController::SendRGB
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[64];
|
||||
int actual;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
@@ -106,6 +104,6 @@ void ThermaltakeRiingController::SendRGB
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
|
||||
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
|
||||
hid_write(dev, usb_buf, 64);
|
||||
hid_read(dev, usb_buf, 64);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -47,14 +47,14 @@ enum
|
||||
class ThermaltakeRiingController
|
||||
{
|
||||
public:
|
||||
ThermaltakeRiingController(libusb_device_handle* dev_handle);
|
||||
ThermaltakeRiingController(hid_device* dev_handle);
|
||||
~ThermaltakeRiingController();
|
||||
|
||||
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
|
||||
void SetMode(unsigned char mode, unsigned char speed);
|
||||
|
||||
private:
|
||||
libusb_device_handle* dev;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_ThermaltakeRiing.h"
|
||||
#include <vector>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define THERMALTAKE_RIING_VID 0x264A
|
||||
#define THERMALTAKE_RIING_PID_BEGIN 0x1FA5
|
||||
@@ -18,19 +18,34 @@
|
||||
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
libusb_context * ctx;
|
||||
libusb_init(&ctx);
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(int pid = THERMALTAKE_RIING_PID_BEGIN; pid <= THERMALTAKE_RIING_PID_END; pid++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(THERMALTAKE_RIING_VID, pid);
|
||||
|
||||
//Look for Thermaltake Riing device
|
||||
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, THERMALTAKE_RIING_VID, pid);
|
||||
|
||||
if( dev )
|
||||
while(info)
|
||||
{
|
||||
libusb_detach_kernel_driver(dev, 0);
|
||||
libusb_claim_interface(dev, 0);
|
||||
if((info->vendor_id == THERMALTAKE_RIING_VID)
|
||||
&&(info->product_id == pid))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
if(dev)
|
||||
{
|
||||
ThermaltakeRiingController* controller = new ThermaltakeRiingController(dev);
|
||||
|
||||
RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller);
|
||||
|
||||
+276
-112
@@ -10,23 +10,51 @@
|
||||
#include "RGBController_Network.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <unistd.h>
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controllers(control)
|
||||
{
|
||||
strcpy(port_ip, "127.0.0.1");
|
||||
port_num = 1337;
|
||||
port_num = OPENRGB_SDK_PORT;
|
||||
server_connected = false;
|
||||
server_controller_count = 0;
|
||||
|
||||
ListenThread = NULL;
|
||||
ConnectionThread = NULL;
|
||||
}
|
||||
|
||||
void NetworkClient::ClientInfoChanged()
|
||||
{
|
||||
ClientInfoChangeMutex.lock();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
for(unsigned int callback_idx = 0; callback_idx < ClientInfoChangeCallbacks.size(); callback_idx++)
|
||||
{
|
||||
ClientInfoChangeCallbacks[callback_idx](ClientInfoChangeCallbackArgs[callback_idx]);
|
||||
}
|
||||
|
||||
ClientInfoChangeMutex.unlock();
|
||||
}
|
||||
|
||||
const char * NetworkClient::GetIP()
|
||||
{
|
||||
return(port_ip);
|
||||
}
|
||||
|
||||
unsigned short NetworkClient::GetPort()
|
||||
@@ -36,7 +64,13 @@ unsigned short NetworkClient::GetPort()
|
||||
|
||||
bool NetworkClient::GetOnline()
|
||||
{
|
||||
return server_connected;
|
||||
return(server_connected && server_initialized);
|
||||
}
|
||||
|
||||
void NetworkClient::RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg)
|
||||
{
|
||||
ClientInfoChangeCallbacks.push_back(new_callback);
|
||||
ClientInfoChangeCallbackArgs.push_back(new_callback_arg);
|
||||
}
|
||||
|
||||
void NetworkClient::SetIP(const char *new_ip)
|
||||
@@ -67,88 +101,165 @@ void NetworkClient::SetPort(unsigned short new_port)
|
||||
|
||||
void NetworkClient::StartClient()
|
||||
{
|
||||
unsigned int requested_controllers;
|
||||
|
||||
//Start a TCP server and launch threads
|
||||
char port_str[6];
|
||||
snprintf(port_str, 6, "%d", port_num);
|
||||
|
||||
port.tcp_client(port_ip, port_str);
|
||||
|
||||
requested_controllers = 0;
|
||||
client_active = true;
|
||||
|
||||
//Start the connection thread
|
||||
ConnectionThread = new std::thread(&NetworkClient::ConnectionThreadFunction, this);
|
||||
|
||||
//Start the listener thread
|
||||
ListenThread = new std::thread(&NetworkClient::ListenThreadFunction, this);
|
||||
|
||||
//Wait for server to connect
|
||||
while(!server_connected)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
//Once server is connected, send client string
|
||||
SendData_ClientString();
|
||||
|
||||
//Request number of controllers
|
||||
SendRequest_ControllerCount();
|
||||
|
||||
//Wait for server controller count
|
||||
while(server_controller_count == 0)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
printf("Client: Received controller count from server: %d\r\n", server_controller_count);
|
||||
|
||||
//Once count is received, request controllers
|
||||
while(requested_controllers < server_controller_count)
|
||||
{
|
||||
printf("Client: Requesting controller %d\r\n", requested_controllers);
|
||||
|
||||
SendRequest_ControllerData(requested_controllers);
|
||||
|
||||
//Wait until controller is received
|
||||
while(server_controllers.size() == requested_controllers)
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
requested_controllers++;
|
||||
}
|
||||
|
||||
//All controllers received, add them to master list
|
||||
printf("Client: All controllers received, adding them to master list\r\n");
|
||||
for(std::size_t controller_idx = 0; controller_idx < server_controllers.size(); controller_idx++)
|
||||
{
|
||||
controllers.push_back(server_controllers[controller_idx]);
|
||||
}
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::StopClient()
|
||||
{
|
||||
server_connected = false;
|
||||
client_active = false;
|
||||
|
||||
shutdown(client_sock, SD_RECEIVE);
|
||||
closesocket(client_sock);
|
||||
if(ListenThread)
|
||||
ListenThread->join();
|
||||
ConnectionThread->join();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::ConnectionThreadFunction()
|
||||
{
|
||||
unsigned int requested_controllers;
|
||||
|
||||
//This thread manages the connection to the server
|
||||
while(client_active == true)
|
||||
{
|
||||
if(server_connected == false)
|
||||
{
|
||||
//Connect to server and reconnect if the connection is lost
|
||||
server_initialized = false;
|
||||
|
||||
//Try to connect to server
|
||||
if(port.tcp_client_connect() == true)
|
||||
{
|
||||
client_sock = port.sock;
|
||||
printf( "Connected to server\n" );
|
||||
|
||||
//Server is now connected
|
||||
server_connected = true;
|
||||
|
||||
//Start the listener thread
|
||||
ListenThread = new std::thread(&NetworkClient::ListenThreadFunction, this);
|
||||
|
||||
//Server is not initialized
|
||||
server_initialized = false;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "Connection attempt failed\n" );
|
||||
}
|
||||
}
|
||||
|
||||
if(server_initialized == false && server_connected == true)
|
||||
{
|
||||
requested_controllers = 0;
|
||||
server_controller_count = 0;
|
||||
|
||||
//Wait for server to connect
|
||||
std::this_thread::sleep_for(100ms);
|
||||
|
||||
//Once server is connected, send client string
|
||||
SendData_ClientString();
|
||||
|
||||
//Request number of controllers
|
||||
SendRequest_ControllerCount();
|
||||
|
||||
//Wait for server controller count
|
||||
while(server_controller_count == 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
printf("Client: Received controller count from server: %d\r\n", server_controller_count);
|
||||
|
||||
//Once count is received, request controllers
|
||||
while(requested_controllers < server_controller_count)
|
||||
{
|
||||
printf("Client: Requesting controller %d\r\n", requested_controllers);
|
||||
|
||||
SendRequest_ControllerData(requested_controllers);
|
||||
|
||||
//Wait until controller is received
|
||||
while(server_controllers.size() == requested_controllers)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
requested_controllers++;
|
||||
}
|
||||
|
||||
//All controllers received, add them to master list
|
||||
printf("Client: All controllers received, adding them to master list\r\n");
|
||||
for(std::size_t controller_idx = 0; controller_idx < server_controllers.size(); controller_idx++)
|
||||
{
|
||||
controllers.push_back(server_controllers[controller_idx]);
|
||||
}
|
||||
|
||||
server_initialized = true;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
}
|
||||
|
||||
int NetworkClient::recv_select(SOCKET s, char *buf, int len, int flags)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
|
||||
while(1)
|
||||
{
|
||||
//Connect to server and reconnect if the connection is lost
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(s, &set); /* add our file descriptor to the set */
|
||||
|
||||
//Try to connect to server
|
||||
port.tcp_client_connect();
|
||||
int rv = select(s + 1, &set, NULL, NULL, &timeout);
|
||||
|
||||
printf( "Connected to server\n" );
|
||||
|
||||
server_connected = true;
|
||||
break;
|
||||
|
||||
//Wait 1 second between tries;
|
||||
Sleep(1000);
|
||||
if(rv == SOCKET_ERROR || server_connected == false)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// socket has something to read
|
||||
return(recv(s, buf, len, flags));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,17 +267,19 @@ void NetworkClient::ListenThreadFunction()
|
||||
{
|
||||
printf("Network client listener started\n");
|
||||
//This thread handles messages received from the server
|
||||
while(1)
|
||||
while(server_connected == true)
|
||||
{
|
||||
NetPacketHeader header;
|
||||
char * data = NULL;
|
||||
int bytes_read = 0;
|
||||
char * data = NULL;
|
||||
|
||||
//Read first byte of magic
|
||||
do
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
bytes_read = port.tcp_listen(&header.pkt_magic[0], 1);
|
||||
} while(bytes_read == 0);
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test first character of magic - 'O'
|
||||
if(header.pkt_magic[0] != 'O')
|
||||
@@ -175,10 +288,12 @@ void NetworkClient::ListenThreadFunction()
|
||||
}
|
||||
|
||||
//Read second byte of magic
|
||||
do
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
bytes_read = port.tcp_listen(&header.pkt_magic[1], 1);
|
||||
} while(bytes_read == 0);
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test second character of magic - 'R'
|
||||
if(header.pkt_magic[1] != 'R')
|
||||
@@ -187,10 +302,12 @@ void NetworkClient::ListenThreadFunction()
|
||||
}
|
||||
|
||||
//Read third byte of magic
|
||||
do
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
bytes_read = port.tcp_listen(&header.pkt_magic[2], 1);
|
||||
} while(bytes_read == 0);
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test third character of magic - 'G'
|
||||
if(header.pkt_magic[2] != 'G')
|
||||
@@ -199,10 +316,12 @@ void NetworkClient::ListenThreadFunction()
|
||||
}
|
||||
|
||||
//Read fourth byte of magic
|
||||
do
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
bytes_read = port.tcp_listen(&header.pkt_magic[3], 1);
|
||||
} while(bytes_read == 0);
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
//Test fourth character of magic - 'B'
|
||||
if(header.pkt_magic[3] != 'B')
|
||||
@@ -214,45 +333,90 @@ void NetworkClient::ListenThreadFunction()
|
||||
bytes_read = 0;
|
||||
do
|
||||
{
|
||||
bytes_read += port.tcp_listen((char *)&header.pkt_dev_idx + bytes_read, sizeof(header) - sizeof(header.pkt_magic) - bytes_read);
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, (char *)&header.pkt_dev_idx + bytes_read, sizeof(header) - sizeof(header.pkt_magic) - bytes_read, 0);
|
||||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
} while(bytes_read != sizeof(header) - sizeof(header.pkt_magic));
|
||||
|
||||
printf( "Client: Received header, now receiving data of size %d\r\n", header.pkt_size);
|
||||
//printf( "Client: Received header, now receiving data of size %d\r\n", header.pkt_size);
|
||||
|
||||
//Header received, now receive the data
|
||||
if(header.pkt_size > 0)
|
||||
{
|
||||
unsigned int bytes_read = 0;
|
||||
bytes_read = 0;
|
||||
|
||||
data = new char[header.pkt_size];
|
||||
|
||||
do
|
||||
{
|
||||
bytes_read += port.tcp_listen(&data[bytes_read], header.pkt_size - bytes_read);
|
||||
int tmp_bytes_read = 0;
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
} while (bytes_read < header.pkt_size);
|
||||
}
|
||||
|
||||
printf( "Client: Received header and data\r\n" );
|
||||
printf( "Client: Packet ID: %d \r\n", header.pkt_id);
|
||||
//printf( "Client: Received header and data\r\n" );
|
||||
//printf( "Client: Packet ID: %d \r\n", header.pkt_id);
|
||||
|
||||
//Entire request received, select functionality based on request ID
|
||||
switch(header.pkt_id)
|
||||
{
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_COUNT:
|
||||
printf( "Client: NET_PACKET_ID_REQUEST_CONTROLLER_COUNT\r\n" );
|
||||
|
||||
|
||||
ProcessReply_ControllerCount(header.pkt_size, data);
|
||||
break;
|
||||
|
||||
case NET_PACKET_ID_REQUEST_CONTROLLER_DATA:
|
||||
printf( "Client: NET_PACKET_ID_REQUEST_CONTROLLER_DATA\r\n");
|
||||
|
||||
|
||||
ProcessReply_ControllerData(header.pkt_size, data, header.pkt_dev_idx);
|
||||
break;
|
||||
}
|
||||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
listen_done:
|
||||
printf( "Client socket has been closed");
|
||||
server_initialized = false;
|
||||
server_connected = false;
|
||||
|
||||
for(int server_controller_idx = 0; server_controller_idx < server_controllers.size(); server_controller_idx++)
|
||||
{
|
||||
for(int controller_idx = 0; controller_idx < controllers.size(); controller_idx++)
|
||||
{
|
||||
if(controllers[controller_idx] == server_controllers[server_controller_idx])
|
||||
{
|
||||
controllers.erase(controllers.begin() + controller_idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete server_controllers[server_controller_idx];
|
||||
}
|
||||
|
||||
server_controllers.clear();
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Client info has changed, call the callbacks |
|
||||
\*-------------------------------------------------*/
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
void NetworkClient::ProcessReply_ControllerCount(unsigned int data_size, char * data)
|
||||
@@ -287,8 +451,8 @@ void NetworkClient::SendData_ClientString()
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_SET_CLIENT_NAME;
|
||||
reply_hdr.pkt_size = strlen(client_name.c_str()) + 1;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)client_name.c_str(), reply_hdr.pkt_size);
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)client_name.c_str(), reply_hdr.pkt_size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_ControllerCount()
|
||||
@@ -304,13 +468,13 @@ void NetworkClient::SendRequest_ControllerCount()
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_COUNT;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -320,14 +484,14 @@ void NetworkClient::SendRequest_ControllerData(unsigned int dev_idx)
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_REQUEST_CONTROLLER_DATA;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
int reply_data[2];
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -340,14 +504,14 @@ void NetworkClient::SendRequest_RGBController_ResizeZone(unsigned int dev_idx, i
|
||||
reply_data[0] = zone;
|
||||
reply_data[1] = new_size;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)&reply_data, sizeof(reply_data));
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)&reply_data, sizeof(reply_data), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -357,14 +521,14 @@ void NetworkClient::SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, u
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)data, size);
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, 0);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -374,14 +538,14 @@ void NetworkClient::SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_id
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)data, size);
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateSingleLED(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -391,14 +555,14 @@ void NetworkClient::SendRequest_RGBController_UpdateSingleLED(unsigned int dev_i
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)data, size);
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_SetCustomMode(unsigned int dev_idx)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -408,13 +572,13 @@ void NetworkClient::SendRequest_RGBController_SetCustomMode(unsigned int dev_idx
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE;
|
||||
reply_hdr.pkt_size = 0;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size)
|
||||
{
|
||||
NetPacketHeader reply_hdr;
|
||||
|
||||
|
||||
reply_hdr.pkt_magic[0] = 'O';
|
||||
reply_hdr.pkt_magic[1] = 'R';
|
||||
reply_hdr.pkt_magic[2] = 'G';
|
||||
@@ -424,6 +588,6 @@ void NetworkClient::SendRequest_RGBController_UpdateMode(unsigned int dev_idx, u
|
||||
reply_hdr.pkt_id = NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE;
|
||||
reply_hdr.pkt_size = size;
|
||||
|
||||
port.tcp_client_write((char *)&reply_hdr, sizeof(NetPacketHeader));
|
||||
port.tcp_client_write((char *)data, size);
|
||||
send(client_sock, (char *)&reply_hdr, sizeof(NetPacketHeader), MSG_NOSIGNAL);
|
||||
send(client_sock, (char *)data, size, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
+20
-2
@@ -10,19 +10,26 @@
|
||||
#include "NetworkProtocol.h"
|
||||
#include "net_port.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef void (*NetClientCallback)(void *);
|
||||
|
||||
class NetworkClient
|
||||
{
|
||||
public:
|
||||
NetworkClient(std::vector<RGBController *>& control);
|
||||
|
||||
void ClientInfoChanged();
|
||||
|
||||
const char * GetIP();
|
||||
unsigned short GetPort();
|
||||
bool GetOnline();
|
||||
|
||||
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
|
||||
|
||||
void SetIP(const char *new_ip);
|
||||
void SetName(const char *new_name);
|
||||
void SetPort(unsigned short new_port);
|
||||
@@ -51,18 +58,29 @@ public:
|
||||
|
||||
void SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
|
||||
|
||||
protected:
|
||||
std::vector<RGBController *>& controllers;
|
||||
std::vector<RGBController *> server_controllers;
|
||||
|
||||
protected:
|
||||
std::vector<RGBController *>& controllers;
|
||||
|
||||
|
||||
private:
|
||||
SOCKET client_sock;
|
||||
std::string client_name;
|
||||
net_port port;
|
||||
char port_ip[20];
|
||||
unsigned short port_num;
|
||||
bool client_active;
|
||||
bool server_connected;
|
||||
bool server_initialized;
|
||||
unsigned int server_controller_count;
|
||||
|
||||
std::thread * ConnectionThread;
|
||||
std::thread * ListenThread;
|
||||
|
||||
std::mutex ClientInfoChangeMutex;
|
||||
std::vector<NetClientCallback> ClientInfoChangeCallbacks;
|
||||
std::vector<void *> ClientInfoChangeCallbackArgs;
|
||||
|
||||
int recv_select(SOCKET s, char *buf, int len, int flags);
|
||||
};
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Default OpenRGB SDK port is 6742 |
|
||||
| This is "ORGB" on a phone keypad |
|
||||
\*-----------------------------------------*/
|
||||
#define OPENRGB_SDK_PORT 6742
|
||||
|
||||
typedef struct NetPacketHeader
|
||||
{
|
||||
char pkt_magic[4]; /* Magic value "ORGB" identifies beginning of packet */
|
||||
|
||||
+24
-20
@@ -28,16 +28,14 @@ const char yes = 1;
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
NetworkServer::NetworkServer(std::vector<RGBController *>& control) : controllers(control)
|
||||
{
|
||||
port_num = 1337;
|
||||
port_num = OPENRGB_SDK_PORT;
|
||||
server_online = false;
|
||||
}
|
||||
|
||||
@@ -134,6 +132,7 @@ void NetworkServer::StartServer()
|
||||
server_sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (server_sock == INVALID_SOCKET)
|
||||
{
|
||||
printf("Error: network socket could not be created\n");
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
@@ -150,6 +149,7 @@ void NetworkServer::StartServer()
|
||||
\*-------------------------------------------------*/
|
||||
if (bind(server_sock, (sockaddr*)&myAddress, sizeof(myAddress)) == SOCKET_ERROR)
|
||||
{
|
||||
printf("Error: Could not bind network socket \nIs port %hu already being used?\n", GetPort());
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ void NetworkServer::StopServer()
|
||||
|
||||
for(unsigned int client_idx = 0; client_idx < ServerClients.size(); client_idx++)
|
||||
{
|
||||
delete[] ServerClients[client_idx];
|
||||
delete ServerClients[client_idx];
|
||||
}
|
||||
|
||||
ServerClients.clear();
|
||||
@@ -200,7 +200,7 @@ void NetworkServer::ConnectionThreadFunction()
|
||||
{
|
||||
//This thread handles client connections
|
||||
|
||||
printf("Network connection thread started\n");
|
||||
printf("Network connection thread started on port %hu\n", GetPort());
|
||||
while(server_online == true)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
@@ -267,13 +267,14 @@ int NetworkServer::accept_select(int sockfd, struct sockaddr *addr, socklen_t *a
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(sockfd, &set); /* add our file descriptor to the set */
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(sockfd, &set); /* add our file descriptor to the set */
|
||||
|
||||
int rv = select(sockfd + 1, &set, NULL, NULL, &timeout);
|
||||
|
||||
@@ -283,6 +284,7 @@ int NetworkServer::accept_select(int sockfd, struct sockaddr *addr, socklen_t *a
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@@ -297,11 +299,12 @@ int NetworkServer::recv_select(SOCKET s, char *buf, int len, int flags)
|
||||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(s, &set); /* add our file descriptor to the set */
|
||||
|
||||
@@ -313,6 +316,7 @@ int NetworkServer::recv_select(SOCKET s, char *buf, int len, int flags)
|
||||
}
|
||||
else if(rv == 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@@ -338,7 +342,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
//Read first byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[0], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
@@ -352,7 +356,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
//Read second byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[1], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
@@ -366,7 +370,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
//Read third byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[2], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
@@ -380,7 +384,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
//Read fourth byte of magic
|
||||
bytes_read = recv_select(client_sock, &header.pkt_magic[3], 1, 0);
|
||||
|
||||
if(bytes_read == 0)
|
||||
if(bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
@@ -401,7 +405,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
|
||||
bytes_read += tmp_bytes_read;
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
@@ -423,7 +427,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
||||
|
||||
tmp_bytes_read = recv_select(client_sock, &data[bytes_read], header.pkt_size - bytes_read, 0);
|
||||
|
||||
if(tmp_bytes_read == 0)
|
||||
if(tmp_bytes_read <= 0)
|
||||
{
|
||||
goto listen_done;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
+51
-5
@@ -18,6 +18,7 @@
|
||||
#include "i2c_smbus_i801.h"
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include "i2c_smbus_nvapi.h"
|
||||
#include "i2c_smbus_amdadl.h"
|
||||
#include "super_io.h"
|
||||
#include "wmi.h"
|
||||
#else /* WIN32 */
|
||||
@@ -120,6 +121,36 @@ void DetectNvAPII2CBusses()
|
||||
}
|
||||
} /* DetectNvAPII2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAMDADLI2CBusses (Windows) *
|
||||
* *
|
||||
* Detects available AMD ADL I2C adapters and enumerates *
|
||||
* i2c_smbus_interface objects for them. Only enumerates Bus Nr 1 *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectADLI2C()
|
||||
{
|
||||
int adl_status;
|
||||
int gpu_count = 0;
|
||||
ADL_CONTEXT_HANDLE gpu_handle;
|
||||
|
||||
i2c_smbus_amdadl * adl_bus = new i2c_smbus_amdadl(gpu_handle);
|
||||
|
||||
adl_status = adl_bus->ADL_Initialize();
|
||||
|
||||
if(0 != adl_status)
|
||||
{
|
||||
printf_s("ADL Status %d \n", adl_status);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(adl_bus->device_name, "AMD ADL I2C on GPU %d", gpu_count);
|
||||
busses.push_back(adl_bus);
|
||||
}
|
||||
} /* DetectAMDADLI2CBusses() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectI2CBusses (Windows) *
|
||||
@@ -205,6 +236,9 @@ void DetectI2CBusses()
|
||||
// Detect NVidia NvAPI I2C adapters
|
||||
DetectNvAPII2CBusses();
|
||||
|
||||
// Detect AMD ADL I2C adadpters
|
||||
DetectADLI2C();
|
||||
|
||||
} /* DetectI2CBusses() */
|
||||
|
||||
#else /* WIN32 */
|
||||
@@ -254,7 +288,7 @@ void DetectI2CBusses()
|
||||
memset(device_string, 0x00, sizeof(device_string));
|
||||
read(test_fd, device_string, sizeof(device_string));
|
||||
device_string[strlen(device_string) - 1] = 0x00;
|
||||
|
||||
|
||||
close(test_fd);
|
||||
|
||||
strcpy(device_string, "/dev/");
|
||||
@@ -291,12 +325,14 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2DRAMControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraAddressableControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectAuraCoreControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectNZXTHue2Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
@@ -311,7 +347,10 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
|
||||
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectNZXTKrakenControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectSteelSeriesControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -335,14 +374,18 @@ void DetectRGBControllers(void)
|
||||
DetectPolychromeControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionGPUControllers(busses, rgb_controllers);
|
||||
|
||||
//TODO: Implement better detection before enabling these controllers
|
||||
//DetectRGBFusion2SMBusControllers(busses, rgb_controllers);
|
||||
//DetectRGBFusion2DRAMControllers(busses, rgb_controllers);
|
||||
|
||||
DetectRGBFusionControllers(busses, rgb_controllers);
|
||||
DetectMSIMysticLightControllers(rgb_controllers);
|
||||
DetectMSIRGBControllers(rgb_controllers);
|
||||
|
||||
DetectAuraAddressableControllers(rgb_controllers);
|
||||
DetectAuraUSBControllers(rgb_controllers);
|
||||
DetectAuraCoreControllers(rgb_controllers);
|
||||
DetectLEDStripControllers(rgb_controllers);
|
||||
DetectHue2Controllers(rgb_controllers);
|
||||
DetectNZXTHue2Controllers(rgb_controllers);
|
||||
DetectHuePlusControllers(rgb_controllers);
|
||||
|
||||
DetectAMDWraithPrismControllers(rgb_controllers);
|
||||
@@ -355,7 +398,10 @@ void DetectRGBControllers(void)
|
||||
DetectThermaltakeRiingControllers(rgb_controllers);
|
||||
DetectRGBFusion2USBControllers(rgb_controllers);
|
||||
DetectRedragonControllers(rgb_controllers);
|
||||
DetectLogitechControllers(rgb_controllers);
|
||||
DetectNZXTKrakenControllers(rgb_controllers);
|
||||
DetectSteelSeriesControllers(rgb_controllers);
|
||||
DetectGloriousModelOControllers(rgb_controllers);
|
||||
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
|
||||
|
||||
+256
-112
@@ -1,11 +1,28 @@
|
||||
QT += core gui
|
||||
#-----------------------------------------------------------------------#
|
||||
# OpenRGB 0.x QMake Project #
|
||||
# #
|
||||
# Adam Honse (CalcProgrammer1) 5/25/2020 #
|
||||
#-----------------------------------------------------------------------#
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# Qt Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
QT += \
|
||||
core \
|
||||
gui \
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = OpenRGB
|
||||
TEMPLATE = app
|
||||
#-----------------------------------------------------------------------#
|
||||
# Application Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
VERSION = 0.21
|
||||
TARGET = OpenRGB
|
||||
TEMPLATE = app
|
||||
|
||||
VERSION = 0.11
|
||||
#-----------------------------------------------------------------------#
|
||||
# Automatically generated build information #
|
||||
#-----------------------------------------------------------------------#
|
||||
win32:BUILDDATE = $$system(date /t)
|
||||
unix:BUILDDATE = $$system(date -R)
|
||||
GIT_COMMIT_ID = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse HEAD)
|
||||
@@ -19,11 +36,11 @@ DEFINES += \
|
||||
GIT_COMMIT_DATE=\\"\"\"$$GIT_COMMIT_DATE\\"\"\" \
|
||||
GIT_BRANCH=\\"\"\"$$GIT_BRANCH\\"\"\"
|
||||
|
||||
RC_ICONS = qt/OpenRGB.ico
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# OpenRGB Common #
|
||||
#-----------------------------------------------------------------------#
|
||||
INCLUDEPATH += \
|
||||
dependencies/ColorWheel \
|
||||
dependencies/hidapi \
|
||||
dependencies/libe131/src/ \
|
||||
i2c_smbus/ \
|
||||
i2c_tools/ \
|
||||
@@ -31,7 +48,7 @@ INCLUDEPATH += \
|
||||
serial_port/ \
|
||||
super_io/ \
|
||||
Controllers/AMDWraithPrismController/ \
|
||||
Controllers/AuraAddressableController/ \
|
||||
Controllers/AuraUSBController/ \
|
||||
Controllers/AuraCoreController/ \
|
||||
Controllers/AuraGPUController/ \
|
||||
Controllers/AuraSMBusController/ \
|
||||
@@ -41,29 +58,135 @@ INCLUDEPATH += \
|
||||
Controllers/CorsairVengeanceController/ \
|
||||
Controllers/CorsairVengeanceProController/ \
|
||||
Controllers/CrucialController/ \
|
||||
Controllers/Hue2Controller/ \
|
||||
Controllers/GloriousModelOController/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXDRAMController/ \
|
||||
Controllers/HyperXKeyboardController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/LogitechController/ \
|
||||
Controllers/MSI3ZoneController/ \
|
||||
Controllers/MSIMysticLightController/ \
|
||||
Controllers/MSIRGBController/ \
|
||||
Controllers/NZXTHue2Controller/ \
|
||||
Controllers/NZXTKrakenController/ \
|
||||
Controllers/PatriotViperController/ \
|
||||
Controllers/PolychromeController/ \
|
||||
Controllers/PoseidonZRGBController/ \
|
||||
Controllers/RedragonController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
Controllers/RGBFusion2DRAMController/ \
|
||||
Controllers/RGBFusion2SMBusController/ \
|
||||
Controllers/RGBFusion2USBController/ \
|
||||
Controllers/RGBFusionGPUController/ \
|
||||
Controllers/SteelSeriesController/ \
|
||||
Controllers/ThermaltakeRiingController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
HEADERS += \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
NetworkClient.h \
|
||||
NetworkProtocol.h \
|
||||
NetworkServer.h \
|
||||
ProfileManager.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
i2c_tools/i2c_tools.h \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBProfileSaveDialog.h \
|
||||
qt/OpenRGBServerInfoPage.h \
|
||||
qt/OpenRGBSoftwareInfoPage.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
qt/OpenRGBZoneResizeDialog.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
super_io/super_io.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraUSBController/AuraUSBController.h \
|
||||
Controllers/AuraUSBController/AuraAddressableController.h \
|
||||
Controllers/AuraUSBController/AuraMainboardController.h \
|
||||
Controllers/AuraCoreController/AuraCoreController.h \
|
||||
Controllers/AuraGPUController/AuraGPUController.h \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.h \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.h \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
|
||||
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h \
|
||||
Controllers/CrucialController/CrucialController.h \
|
||||
Controllers/GloriousModelOController/GloriousModelOController.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXDRAMController/HyperXDRAMController.h \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/LogitechController/LogitechG203Controller.h \
|
||||
Controllers/LogitechController/LogitechG403Controller.h \
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.h \
|
||||
Controllers/MSIRGBController/MSIRGBController.h \
|
||||
Controllers/NZXTHue2Controller/NZXTHue2Controller.h \
|
||||
Controllers/NZXTKrakenController/NZXTKrakenController.h \
|
||||
Controllers/PatriotViperController/PatriotViperController.h \
|
||||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
Controllers/RGBFusion2DRAMController/RGBFusion2DRAMController.h \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusController.h \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBController.h \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
|
||||
Controllers/RedragonController/RedragonK556Controller.h \
|
||||
Controllers/RedragonController/RedragonM711Controller.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_AuraUSB.h \
|
||||
RGBController/RGBController_AuraCore.h \
|
||||
RGBController/RGBController_AuraGPU.h \
|
||||
RGBController/RGBController_AuraSMBus.h \
|
||||
RGBController/RGBController_CMMP750Controller.h \
|
||||
RGBController/RGBController_CorsairLightingNode.h \
|
||||
RGBController/RGBController_CorsairPeripheral.h \
|
||||
RGBController/RGBController_CorsairVengeance.h \
|
||||
RGBController/RGBController_CorsairVengeancePro.h \
|
||||
RGBController/RGBController_Crucial.h \
|
||||
RGBController/RGBController_Dummy.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_GloriousModelO.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperXDRAM.h \
|
||||
RGBController/RGBController_HyperXKeyboard.h \
|
||||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_LogitechG203.h \
|
||||
RGBController/RGBController_LogitechG403.h \
|
||||
RGBController/RGBController_LogitechG810.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIMysticLight.h \
|
||||
RGBController/RGBController_MSIRGB.h \
|
||||
RGBController/RGBController_Network.h \
|
||||
RGBController/RGBController_NZXTHue2.h \
|
||||
RGBController/RGBController_NZXTKraken.h \
|
||||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_PoseidonZRGB.h \
|
||||
RGBController/RGBController_RedragonK556.h \
|
||||
RGBController/RGBController_RedragonM711.h \
|
||||
RGBController/RGBController_RGBFusion.h \
|
||||
RGBController/RGBController_RGBFusion2DRAM.h \
|
||||
RGBController/RGBController_RGBFusion2SMBus.h \
|
||||
RGBController/RGBController_RGBFusion2USB.h \
|
||||
RGBController/RGBController_RGBFusionGPU.h \
|
||||
RGBController/RGBController_SteelSeriesRival.h \
|
||||
RGBController/RGBController_SteelSeriesSiberia.h \
|
||||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
|
||||
SOURCES += \
|
||||
dependencies/ColorWheel/ColorWheel.cpp \
|
||||
dependencies/hidapi/hidapi.c \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
cli.cpp \
|
||||
@@ -88,8 +211,10 @@ SOURCES += \
|
||||
super_io/super_io.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
|
||||
Controllers/AuraAddressableController/AuraAddressableController.cpp \
|
||||
Controllers/AuraAddressableController/AuraAddressableControllerDetect.cpp \
|
||||
Controllers/AuraUSBController/AuraUSBController.cpp \
|
||||
Controllers/AuraUSBController/AuraAddressableController.cpp \
|
||||
Controllers/AuraUSBController/AuraMainboardController.cpp \
|
||||
Controllers/AuraUSBController/AuraUSBControllerDetect.cpp \
|
||||
Controllers/AuraCoreController/AuraCoreController.cpp \
|
||||
Controllers/AuraCoreController/AuraCoreControllerDetect.cpp \
|
||||
Controllers/AuraGPUController/AuraGPUController.cpp \
|
||||
@@ -108,8 +233,8 @@ SOURCES += \
|
||||
Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp \
|
||||
Controllers/CrucialController/CrucialController.cpp \
|
||||
Controllers/CrucialController/CrucialControllerDetect.cpp \
|
||||
Controllers/Hue2Controller/Hue2Controller.cpp \
|
||||
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
|
||||
Controllers/GloriousModelOController/GloriousModelOController.cpp \
|
||||
Controllers/GloriousModelOController/GloriousModelOControllerDetect.cpp \
|
||||
Controllers/HuePlusController/HuePlusController.cpp \
|
||||
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
|
||||
Controllers/HyperXDRAMController/HyperXDRAMController.cpp \
|
||||
@@ -118,12 +243,18 @@ SOURCES += \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \
|
||||
Controllers/LEDStripController/LEDStripController.cpp \
|
||||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/LogitechController/LogitechControllerDetect.cpp \
|
||||
Controllers/LogitechController/LogitechG203Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG403Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp \
|
||||
Controllers/MSIRGBController/MSIRGBController.cpp \
|
||||
Controllers/MSIRGBController/MSIRGBControllerDetect.cpp \
|
||||
Controllers/NZXTHue2Controller/NZXTHue2Controller.cpp \
|
||||
Controllers/NZXTHue2Controller/NZXTHue2ControllerDetect.cpp \
|
||||
Controllers/NZXTKrakenController/NZXTKrakenController.cpp \
|
||||
Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp \
|
||||
Controllers/PatriotViperController/PatriotViperController.cpp \
|
||||
@@ -134,6 +265,10 @@ SOURCES += \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionController.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
Controllers/RGBFusion2DRAMController/RGBFusion2DRAMController.cpp \
|
||||
Controllers/RGBFusion2DRAMController/RGBFusion2DRAMControllerDetect.cpp \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusController.cpp \
|
||||
Controllers/RGBFusion2SMBusController/RGBFusion2SMBusControllerDetect.cpp \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBController.cpp \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBControllerDetect.cpp \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.cpp \
|
||||
@@ -141,12 +276,15 @@ SOURCES += \
|
||||
Controllers/RedragonController/RedragonK556Controller.cpp \
|
||||
Controllers/RedragonController/RedragonM711Controller.cpp \
|
||||
Controllers/RedragonController/RedragonControllerDetect.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
|
||||
Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
|
||||
RGBController/RGBController.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_AMDWraithPrism.cpp \
|
||||
RGBController/RGBController_AuraAddressable.cpp \
|
||||
RGBController/RGBController_AuraUSB.cpp \
|
||||
RGBController/RGBController_AuraCore.cpp \
|
||||
RGBController/RGBController_AuraGPU.cpp \
|
||||
RGBController/RGBController_AuraSMBus.cpp \
|
||||
@@ -157,16 +295,20 @@ SOURCES += \
|
||||
RGBController/RGBController_CorsairVengeancePro.cpp \
|
||||
RGBController/RGBController_Crucial.cpp \
|
||||
RGBController/RGBController_Dummy.cpp \
|
||||
RGBController/RGBController_Hue2.cpp \
|
||||
RGBController/RGBController_GloriousModelO.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperXDRAM.cpp \
|
||||
RGBController/RGBController_HyperXKeyboard.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_LogitechG203.cpp \
|
||||
RGBController/RGBController_LogitechG403.cpp \
|
||||
RGBController/RGBController_LogitechG810.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_MSIMysticLight.cpp \
|
||||
RGBController/RGBController_MSIRGB.cpp \
|
||||
RGBController/RGBController_Network.cpp \
|
||||
RGBController/RGBController_NZXTHue2.cpp \
|
||||
RGBController/RGBController_NZXTKraken.cpp \
|
||||
RGBController/RGBController_PatriotViper.cpp \
|
||||
RGBController/RGBController_Polychrome.cpp \
|
||||
@@ -174,93 +316,15 @@ SOURCES += \
|
||||
RGBController/RGBController_RedragonK556.cpp \
|
||||
RGBController/RGBController_RedragonM711.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp \
|
||||
RGBController/RGBController_RGBFusion2DRAM.cpp \
|
||||
RGBController/RGBController_RGBFusion2SMBus.cpp \
|
||||
RGBController/RGBController_RGBFusion2USB.cpp \
|
||||
RGBController/RGBController_RGBFusionGPU.cpp \
|
||||
RGBController/RGBController_SteelSeriesRival.cpp \
|
||||
RGBController/RGBController_SteelSeriesSiberia.cpp \
|
||||
RGBController/RGBController_ThermaltakeRiing.cpp \
|
||||
|
||||
HEADERS += \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
NetworkClient.h \
|
||||
NetworkProtocol.h \
|
||||
NetworkServer.h \
|
||||
ProfileManager.h \
|
||||
qt/OpenRGBDeviceInfoPage.h \
|
||||
qt/OpenRGBDevicePage.h \
|
||||
qt/OpenRGBDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
i2c_tools/i2c_tools.h \
|
||||
net_port/net_port.h \
|
||||
qt/OpenRGBDialog2.h \
|
||||
qt/OpenRGBProfileSaveDialog.h \
|
||||
qt/OpenRGBServerInfoPage.h \
|
||||
qt/OpenRGBSoftwareInfoPage.h \
|
||||
qt/OpenRGBSystemInfoPage.h \
|
||||
qt/OpenRGBZoneResizeDialog.h \
|
||||
serial_port/find_usb_serial_port.h \
|
||||
serial_port/serial_port.h \
|
||||
super_io/super_io.h \
|
||||
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
|
||||
Controllers/AuraAddressableController/AuraAddressableController.h \
|
||||
Controllers/AuraCoreController/AuraCoreController.h \
|
||||
Controllers/AuraGPUController/AuraGPUController.h \
|
||||
Controllers/AuraSMBusController/AuraSMBusController.h \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.h \
|
||||
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
|
||||
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
|
||||
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
|
||||
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h \
|
||||
Controllers/CrucialController/CrucialController.h \
|
||||
Controllers/Hue2Controller/Hue2Controller.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXDRAMController/HyperXDRAMController.h \
|
||||
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.h \
|
||||
Controllers/MSIRGBController/MSIRGBController.h \
|
||||
Controllers/PatriotViperController/PatriotViperController.h \
|
||||
Controllers/PolychromeController/PolychromeController.h \
|
||||
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
|
||||
Controllers/RGBFusionController/RGBFusionController.h \
|
||||
Controllers/RGBFusion2USBController/RGBFusion2USBController.h \
|
||||
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
|
||||
Controllers/RedragonController/RedragonK556Controller.h \
|
||||
Controllers/RedragonController/RedragonM711Controller.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_AMDWraithPrism.h \
|
||||
RGBController/RGBController_AuraAddressable.h \
|
||||
RGBController/RGBController_AuraCore.h \
|
||||
RGBController/RGBController_AuraGPU.h \
|
||||
RGBController/RGBController_AuraSMBus.h \
|
||||
RGBController/RGBController_CMMP750Controller.h \
|
||||
RGBController/RGBController_CorsairLightingNode.h \
|
||||
RGBController/RGBController_CorsairPeripheral.h \
|
||||
RGBController/RGBController_CorsairVengeance.h \
|
||||
RGBController/RGBController_CorsairVengeancePro.h \
|
||||
RGBController/RGBController_Crucial.h \
|
||||
RGBController/RGBController_Dummy.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
RGBController/RGBController_Hue2.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperXDRAM.h \
|
||||
RGBController/RGBController_HyperXKeyboard.h \
|
||||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIMysticLight.h \
|
||||
RGBController/RGBController_MSIRGB.h \
|
||||
RGBController/RGBController_Network.h \
|
||||
RGBController/RGBController_PatriotViper.h \
|
||||
RGBController/RGBController_Polychrome.h \
|
||||
RGBController/RGBController_PoseidonZRGB.h \
|
||||
RGBController/RGBController_RedragonK556.h \
|
||||
RGBController/RGBController_RedragonM711.h \
|
||||
RGBController/RGBController_RGBFusion.h \
|
||||
RGBController/RGBController_RGBFusion2USB.h \
|
||||
RGBController/RGBController_RGBFusionGPU.h \
|
||||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
|
||||
RESOURCES += \
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
@@ -274,10 +338,12 @@ FORMS += \
|
||||
qt/OpenRGBSystemInfoPage.ui \
|
||||
qt/OpenRGBZoneResizeDialog.ui \
|
||||
|
||||
#-----------------------------------------------
|
||||
# Windows specific project configuration
|
||||
#-----------------------------------------------
|
||||
#-----------------------------------------------------------------------#
|
||||
# Windows-specific Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
win32:INCLUDEPATH += \
|
||||
dependencies/display-library/include \
|
||||
dependencies/hidapi \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/libusb-1.0.22/include \
|
||||
dependencies/NVFC \
|
||||
@@ -285,7 +351,9 @@ win32:INCLUDEPATH += \
|
||||
wmi/ \
|
||||
|
||||
win32:SOURCES += \
|
||||
dependencies/hidapi/hidapi.c \
|
||||
dependencies/NVFC/nvapi.cpp \
|
||||
i2c_smbus/i2c_smbus_amdadl.cpp \
|
||||
i2c_smbus/i2c_smbus_i801.cpp \
|
||||
i2c_smbus/i2c_smbus_nct6775.cpp \
|
||||
i2c_smbus/i2c_smbus_nvapi.cpp \
|
||||
@@ -296,6 +364,9 @@ win32:SOURCES += \
|
||||
RGBController/RGBController_OpenRazerWindows.cpp \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/display-library/include/adl_defines.h \
|
||||
dependencies/display-library/include/adl_sdk.h \
|
||||
dependencies/display-library/include/adl_structures.h \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
dependencies/NVFC/nvapi.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
@@ -329,9 +400,33 @@ win32:DEFINES += \
|
||||
_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
WIN32_LEAN_AND_MEAN
|
||||
|
||||
# Copy OpenRazer.dll to output directory
|
||||
win32:RC_ICONS += \
|
||||
qt/OpenRGB.ico
|
||||
|
||||
#-------------------------------------------------------------------#
|
||||
# Windows GitLab CI Configuration #
|
||||
#-------------------------------------------------------------------#
|
||||
win32:CONFIG(debug, debug|release) {
|
||||
win32:DESTDIR = debug
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release) {
|
||||
win32:DESTDIR = release
|
||||
}
|
||||
|
||||
win32:OBJECTS_DIR = _intermediate_$$DESTDIR/.obj
|
||||
win32:MOC_DIR = _intermediate_$$DESTDIR/.moc
|
||||
win32:RCC_DIR = _intermediate_$$DESTDIR/.qrc
|
||||
win32:UI_DIR = _intermediate_$$DESTDIR/.ui
|
||||
|
||||
#-------------------------------------------------------------------#
|
||||
# Copy dependencies to output directory #
|
||||
#-------------------------------------------------------------------#
|
||||
|
||||
win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer64.dll)\" \"$$shell_path($$OUT_PWD)\"
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/x64/inpoutx64.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS64/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
first.depends = $(first) copydata
|
||||
export(first.depends)
|
||||
export(copydata.commands)
|
||||
@@ -339,29 +434,78 @@ win32:contains(QMAKE_TARGET.arch, x86_64) {
|
||||
}
|
||||
|
||||
win32:contains(QMAKE_TARGET.arch, x86) {
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer.dll)\" \"$$shell_path($$OUT_PWD)\"
|
||||
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD/dependencies/openrazer-win32/OpenRazer.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/inpout32_1501/Win32/inpout32.dll )\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
copydata.commands += $(COPY_FILE) \"$$shell_path($$PWD/dependencies/libusb-1.0.22/MS32/dll/libusb-1.0.dll)\" \"$$shell_path($$DESTDIR)\" $$escape_expand(\n\t)
|
||||
|
||||
first.depends = $(first) copydata
|
||||
export(first.depends)
|
||||
export(copydata.commands)
|
||||
QMAKE_EXTRA_TARGETS += first copydata
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# Linux specific project configuration
|
||||
#-----------------------------------------------
|
||||
unix:INCLUDEPATH += \
|
||||
#-----------------------------------------------------------------------#
|
||||
# Linux-specific Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
unix:!macx {
|
||||
INCLUDEPATH += \
|
||||
|
||||
unix:HEADERS += \
|
||||
HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
RGBController/RGBController_Faustus.h \
|
||||
|
||||
unix:LIBS += \
|
||||
LIBS += \
|
||||
-lusb-1.0 \
|
||||
-lstdc++fs \
|
||||
|
||||
unix:SOURCES += \
|
||||
#-------------------------------------------------------------------#
|
||||
# Determine which hidapi to use based on availability #
|
||||
# Prefer hidraw backend, then libusb #
|
||||
#-------------------------------------------------------------------#
|
||||
packagesExist(hidapi-hidraw) {
|
||||
LIBS += -lhidapi-hidraw
|
||||
} else {
|
||||
packagesExist(hidapi-libusb) {
|
||||
LIBS += -lhidapi-libusb
|
||||
} else {
|
||||
LIBS += -lhidapi
|
||||
}
|
||||
}
|
||||
|
||||
SOURCES += \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/RGBController_Faustus.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
|
||||
#-------------------------------------------------------------------#
|
||||
# Set up install paths #
|
||||
# These install paths are used for AppImage and .deb packaging #
|
||||
#-------------------------------------------------------------------#
|
||||
isEmpty(PREFIX) {
|
||||
PREFIX = /usr
|
||||
}
|
||||
|
||||
target.path=$$PREFIX/bin/
|
||||
desktop.path=$$PREFIX/share/applications/
|
||||
desktop.files+=qt/OpenRGB.desktop
|
||||
pixmap.path=$$PREFIX/share/pixmaps/
|
||||
pixmap.files+=qt/OpenRGB.png
|
||||
INSTALLS += target desktop pixmap
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------#
|
||||
# MacOS-specific Configuration #
|
||||
#-----------------------------------------------------------------------#
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15
|
||||
|
||||
macx:ICON = qt/OpenRGB.icns
|
||||
|
||||
unix:macx {
|
||||
INCLUDEPATH += \
|
||||
/usr/local/include \
|
||||
|
||||
LIBS += \
|
||||
-L/usr/local/lib -lusb-1.0 -lhidapi \
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ This project provides a tool to probe the SMBus. This is a potentially dangerou
|
||||
|
||||
As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues.
|
||||
|
||||

|
||||

|
||||
|
||||
## Windows
|
||||
* Pre-built binaries are available under the Releases section on GitLab.
|
||||
@@ -32,15 +32,17 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
|
||||
* Some USB devices (especially keyboards and mice) require installation of the WinUSB driver. You can do this with Zadig:
|
||||
- Download Zadig: https://zadig.akeo.ie/
|
||||
- Select "list all devices" from the menu
|
||||
- Select the last interface of your device
|
||||
- Select the last interface (highest number) of your device
|
||||
- With "WinUSB" selected, click Install
|
||||
|
||||
## Linux
|
||||
* Pre-built binaries are not currently available for Linux
|
||||
|
||||
* You can build the project using Qt Creator or on the command line. The commands listed here work for Debian-based distros.
|
||||
* You can build the project using Qt Creator or on the command line.
|
||||
|
||||
1. sudo apt install build-essential qtcreator qt5-default libusb-1.0-0-dev
|
||||
1. Install build dependencies
|
||||
- Debian: sudo apt install build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf
|
||||
- Fedora: sudo dnf install git make automake gcc gcc-c++ qt-creator qt5-devel hidapi-devel libusb-devel
|
||||
2. git clone https://gitlab.com/CalcProgrammer1/OpenRGB
|
||||
3. cd OpenRGB
|
||||
4. qmake OpenRGB.pro
|
||||
@@ -86,11 +88,27 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
|
||||
|
||||
* You can run OpenRGB as root to detect all USB devices.
|
||||
|
||||
* Udev rules can be found here:
|
||||
- https://drive.google.com/drive/folders/1tWVbeOLiLns_IhgyNDWqSK3ZKtP-6oYM?usp=sharing
|
||||
- Copy the .rules files to /etc/udev/rules.d/
|
||||
* Udev rules are included in this repo:
|
||||
- Copy the 60-openrgb.rules file to /etc/udev/rules.d/
|
||||
- Reload rules with `sudo udevadm control --reload-rules && sudo udevadm trigger`
|
||||
- Add your user to the `plugdev` group: `sudo adduser username plugdev`
|
||||
|
||||
## OpenRGB SDK
|
||||
|
||||
OpenRGB provides a network interface for controlling supported RGB devices from other software. These projects implement the OpenRGB SDK and provide additional ways for you to control your lighting setup.
|
||||
|
||||
* Keyboard Visualizer (by me): https://gitlab.com/CalcProgrammer1/KeyboardVisualizer
|
||||
|
||||
* OpenRGB Python Client (by bahorn): https://github.com/bahorn/OpenRGB-PyClient
|
||||
|
||||
* OpenRGB Python Client (by jath03): https://github.com/jath03/openrgb-python
|
||||
|
||||
* OpenRGB Node.js Client (by vlakreeh): https://github.com/vlakreeh/openrgb
|
||||
|
||||
* D-Bus Connector for OpenRGB (by Vinno97): https://github.com/Vinno97/OpenRGB-DBus-Connector
|
||||
|
||||
* OpenRGB E1.31 Receiver (by me): https://gitlab.com/CalcProgrammer1/OpenRGBE131Receiver
|
||||
|
||||
* OpenRGB.NET - C# OpenRGB Client (by diogotr7): https://github.com/diogotr7/OpenRGB.NET
|
||||
|
||||
## Projects Used
|
||||
|
||||
@@ -109,7 +127,9 @@ As of now, only Gigabyte RGB Fusion 2.0 boards have been reported to have issues
|
||||
* OpenRazer-Win32: https://github.com/CalcProgrammer1/openrazer-win32
|
||||
|
||||
* Qt-Plus (ColorWheel): https://github.com/liuyanghejerry/Qt-Plus
|
||||
|
||||
|
||||
* AMD ADL Libraries: https://github.com/GPUOpen-LibrariesAndSDKs/display-library
|
||||
|
||||
## Projects Researched
|
||||
|
||||
While no code from these projects directly made its way into OpenRGB, these projects have been invaluable resources for protocol information.
|
||||
@@ -134,4 +154,12 @@ While no code from these projects directly made its way into OpenRGB, these proj
|
||||
|
||||
* OpenCorsairLink: https://github.com/audiohacked/OpenCorsairLink
|
||||
|
||||
* msi-keyboard: https://github.com/bparker06/msi-keyboard
|
||||
* msi-keyboard: https://github.com/bparker06/msi-keyboard
|
||||
|
||||
* rivalcfg: https://github.com/flozz/rivalcfg
|
||||
|
||||
* VRMTool: https://github.com/rbrune/VRMtool
|
||||
|
||||
* g810-led: https://github.com/MatMoul/g810-led
|
||||
|
||||
* liquidctl: https://github.com/jonasmalacofilho/liquidctl
|
||||
|
||||
@@ -39,7 +39,7 @@ static const razer_zone blackwidow_2019_zone =
|
||||
|
||||
static const razer_device blackwidow_2019_device =
|
||||
{
|
||||
"Razer Blackwidow 2019",
|
||||
"Razer BlackWidow 2019",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
@@ -167,7 +167,7 @@ static const razer_zone blackwidow_elite_zone =
|
||||
|
||||
static const razer_device blackwidow_elite_device =
|
||||
{
|
||||
"Razer Blackwidow Elite",
|
||||
"Razer BlackWidow Elite",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
@@ -199,7 +199,7 @@ static const razer_zone blackwidow_chroma_v2_zone =
|
||||
|
||||
static const razer_device blackwidow_chroma_v2_device =
|
||||
{
|
||||
"Razer Blackwidow Chroma V2",
|
||||
"Razer BlackWidow Chroma V2",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
@@ -412,8 +412,12 @@ static const razer_device huntsman_device =
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
| |
|
||||
| Zone "Underglow" |
|
||||
| Matrix |
|
||||
| 3 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone huntsman_elite_zone =
|
||||
static const razer_zone huntsman_elite_keyboard_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
@@ -421,16 +425,24 @@ static const razer_zone huntsman_elite_zone =
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_zone huntsman_elite_underglow_zone =
|
||||
{
|
||||
"Underglow",
|
||||
ZONE_TYPE_MATRIX,
|
||||
3,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device huntsman_elite_device =
|
||||
{
|
||||
"Razer Huntsman Elite",
|
||||
DEVICE_TYPE_KEYBOARD,
|
||||
true,
|
||||
6,
|
||||
9,
|
||||
22,
|
||||
{
|
||||
&huntsman_elite_zone,
|
||||
NULL,
|
||||
&huntsman_elite_keyboard_zone,
|
||||
&huntsman_elite_underglow_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
@@ -1317,17 +1329,9 @@ static const razer_device deathadder_elite_device =
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Diamondback Chroma |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Bottom" |
|
||||
| Linear |
|
||||
| 5 LEDs |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| 19 LEDs |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
@@ -1337,28 +1341,12 @@ static const razer_device deathadder_elite_device =
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone diamondback_chroma_right_zone =
|
||||
static const razer_zone diamondback_chroma_led_strip_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_bottom_zone =
|
||||
{
|
||||
"Bottom LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
19
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_logo_zone =
|
||||
@@ -1385,11 +1373,11 @@ static const razer_device diamondback_chroma_device =
|
||||
1,
|
||||
21,
|
||||
{
|
||||
&diamondback_chroma_right_zone,
|
||||
&diamondback_chroma_bottom_zone,
|
||||
&diamondback_chroma_left_zone,
|
||||
&diamondback_chroma_led_strip_zone,
|
||||
&diamondback_chroma_logo_zone,
|
||||
&diamondback_chroma_scroll_wheel_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
@@ -2517,7 +2505,7 @@ static const razer_zone base_station_zone =
|
||||
static const razer_device base_station_device =
|
||||
{
|
||||
"Razer Base Station Chroma",
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
DEVICE_TYPE_HEADSET_STAND,
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
#include "RGBController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController::RGBController()
|
||||
{
|
||||
@@ -22,6 +13,22 @@ RGBController::~RGBController()
|
||||
{
|
||||
DeviceThreadRunning = false;
|
||||
DeviceCallThread->join();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
if(zones[zone_index].matrix_map->map != NULL)
|
||||
{
|
||||
delete[] zones[zone_index].matrix_map->map;
|
||||
}
|
||||
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetDeviceDescription()
|
||||
@@ -1319,7 +1326,7 @@ void RGBController::DeviceCallThreadFunction()
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1346,6 +1353,8 @@ std::string device_type_to_str(device_type type)
|
||||
return "Mousemat";
|
||||
case DEVICE_TYPE_HEADSET:
|
||||
return "Headset";
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
return "Headset Stand";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
typedef unsigned int RGBColor;
|
||||
|
||||
@@ -112,6 +113,7 @@ enum
|
||||
DEVICE_TYPE_MOUSE,
|
||||
DEVICE_TYPE_MOUSEMAT,
|
||||
DEVICE_TYPE_HEADSET,
|
||||
DEVICE_TYPE_HEADSET_STAND,
|
||||
DEVICE_TYPE_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
@@ -17,15 +17,17 @@ RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
|
||||
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.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.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;
|
||||
|
||||
+45
-30
@@ -1,22 +1,22 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraAddressable.cpp |
|
||||
| RGBController_AuraUSB.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| addressable controller driver |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AuraAddressable.h"
|
||||
#include "RGBController_AuraUSB.h"
|
||||
|
||||
RGBController_AuraAddressable::RGBController_AuraAddressable(AuraAddressableController* aura_ptr)
|
||||
RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Addressable";
|
||||
name = "ASUS Aura USB";
|
||||
version = aura->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = "ASUS Aura Addressable Device";
|
||||
description = "ASUS Aura USB Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -99,12 +99,12 @@ RGBController_AuraAddressable::RGBController_AuraAddressable(AuraAddressableCont
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AuraAddressable::~RGBController_AuraAddressable()
|
||||
RGBController_AuraUSB::~RGBController_AuraUSB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::SetupZones()
|
||||
void RGBController_AuraUSB::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
@@ -126,33 +126,42 @@ void RGBController_AuraAddressable::SetupZones()
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
int addressableCounter = 1;
|
||||
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
char ch_idx_string[2];
|
||||
sprintf(ch_idx_string, "%d", channel_idx + 1);
|
||||
AuraDeviceInfo device_info = aura->GetAuraDevices()[channel_idx];
|
||||
|
||||
zones[channel_idx].name = "Aura Channel ";
|
||||
zones[channel_idx].name.append(ch_idx_string);
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
|
||||
|
||||
if(first_run)
|
||||
if(device_info.device_type == AuraDeviceType::FIXED)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
zones[channel_idx].name = "Aura Mainboard";
|
||||
zones[channel_idx].leds_min = device_info.num_leds;
|
||||
zones[channel_idx].leds_max = device_info.num_leds;
|
||||
zones[channel_idx].leds_count = device_info.num_leds;
|
||||
}
|
||||
else
|
||||
{
|
||||
zones[channel_idx].name = "Aura Addressable ";
|
||||
zones[channel_idx].name.append(std::to_string(addressableCounter));
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
|
||||
|
||||
addressableCounter++;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[4];
|
||||
sprintf(led_idx_string, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "Aura Channel ";
|
||||
new_led.name.append(ch_idx_string);
|
||||
new_led.name = zones[channel_idx].name;
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
new_led.name.append(std::to_string(led_ch_idx + 1));
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
@@ -164,7 +173,7 @@ void RGBController_AuraAddressable::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::ResizeZone(int zone, int new_size)
|
||||
void RGBController_AuraUSB::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
@@ -174,7 +183,7 @@ void RGBController_AuraAddressable::ResizeZone(int zone, int new_size)
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::DeviceUpdateLEDs()
|
||||
void RGBController_AuraUSB::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
@@ -182,24 +191,24 @@ void RGBController_AuraAddressable::DeviceUpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::UpdateZoneLEDs(int zone)
|
||||
void RGBController_AuraUSB::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
aura->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::UpdateSingleLED(int led)
|
||||
void RGBController_AuraUSB::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int channel = leds[led].value;
|
||||
|
||||
aura->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::SetCustomMode()
|
||||
void RGBController_AuraUSB::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AuraAddressable::UpdateMode()
|
||||
void RGBController_AuraUSB::UpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
@@ -212,5 +221,11 @@ void RGBController_AuraAddressable::UpdateMode()
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
aura->SetMode(modes[active_mode].value, red, grn, blu);
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
if(zones[zone_idx].leds_count > 0)
|
||||
{
|
||||
aura->SetMode(zone_idx, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,23 +1,23 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraAddressable.h |
|
||||
| RGBController_AuraUSB.h |
|
||||
| |
|
||||
| Generic RGB Interface for Asus Aura |
|
||||
| addressable controller driver |
|
||||
| USB controller driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 1/18/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "AuraAddressableController.h"
|
||||
#include "AuraUSBController.h"
|
||||
|
||||
#define AURA_ADDRESSABLE_MAX_LEDS 120
|
||||
|
||||
class RGBController_AuraAddressable : public RGBController
|
||||
class RGBController_AuraUSB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraAddressable(AuraAddressableController* aura_ptr);
|
||||
~RGBController_AuraAddressable();
|
||||
RGBController_AuraUSB(AuraUSBController* aura_ptr);
|
||||
~RGBController_AuraUSB();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraAddressableController* aura;
|
||||
AuraUSBController* aura;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
@@ -15,7 +15,7 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll
|
||||
|
||||
name = cmmp750->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = "Cooler Master Mousepad 750";
|
||||
description = cmmp750->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = "";
|
||||
location = cmmp750->GetLocation();
|
||||
|
||||
@@ -192,6 +192,10 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
num_zones = 1;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
num_zones = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -240,6 +244,27 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
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);
|
||||
@@ -259,6 +284,7 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_GloriousModelO.cpp |
|
||||
| |
|
||||
| Definitions and types for Glorious |
|
||||
| and other Mice |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 20/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_GloriousModelO.h"
|
||||
|
||||
RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOController* gmo_ptr)
|
||||
{
|
||||
gmo = gmo_ptr;
|
||||
|
||||
name = gmo->GetDeviceName();
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Glorious Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
Static.value = GLORIOUS_MODE_STATIC;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
Off.value = GLORIOUS_MODE_OFF;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Glorious Mode";
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD;
|
||||
Rainbow.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
Rainbow.speed = GLORIOUS_SPEED_NORMAL;
|
||||
Rainbow.speed_max = GLORIOUS_SPEED_FAST;
|
||||
Rainbow.direction = MODE_DIRECTION_UP;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.value = GLORIOUS_MODE_RAINBOW;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode SpectrumBreathing;
|
||||
SpectrumBreathing.name = "Seemless Breathing";
|
||||
SpectrumBreathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
SpectrumBreathing.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
SpectrumBreathing.speed = GLORIOUS_SPEED_NORMAL;
|
||||
SpectrumBreathing.speed_max = GLORIOUS_SPEED_FAST;
|
||||
SpectrumBreathing.colors_min = 7;
|
||||
SpectrumBreathing.colors_max = 7;
|
||||
SpectrumBreathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
SpectrumBreathing.value = GLORIOUS_MODE_SPECTRUM_BREATING;
|
||||
SpectrumBreathing.colors.resize(7);
|
||||
modes.push_back(SpectrumBreathing);
|
||||
|
||||
mode Chase;
|
||||
Chase.name = "Tail";
|
||||
Chase.flags = MODE_FLAG_HAS_SPEED;
|
||||
Chase.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
Chase.speed = GLORIOUS_SPEED_NORMAL;
|
||||
Chase.speed_max = GLORIOUS_SPEED_FAST;
|
||||
Chase.color_mode = MODE_COLORS_NONE;
|
||||
Chase.value = GLORIOUS_MODE_TAIL;
|
||||
modes.push_back(Chase);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
SpectrumCycle.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
SpectrumCycle.speed = GLORIOUS_SPEED_NORMAL;
|
||||
SpectrumCycle.speed_max = GLORIOUS_SPEED_FAST;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.value = GLORIOUS_MODE_SPECTRUM_CYCLE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Rave";
|
||||
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Flashing.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
Flashing.speed = GLORIOUS_SPEED_NORMAL;
|
||||
Flashing.speed_max = GLORIOUS_SPEED_FAST;
|
||||
Flashing.colors_min = 2;
|
||||
Flashing.colors_max = 2;
|
||||
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flashing.value = GLORIOUS_MODE_RAVE;
|
||||
Flashing.colors.resize(2);
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Epilepsy;
|
||||
Epilepsy.name = "Epilepsy";
|
||||
Epilepsy.flags = 0;
|
||||
Epilepsy.color_mode = MODE_COLORS_NONE;
|
||||
Epilepsy.value = GLORIOUS_MODE_EPILEPSY;
|
||||
modes.push_back(Epilepsy);
|
||||
|
||||
mode RainbowSlow;
|
||||
RainbowSlow.name = "Wave";
|
||||
RainbowSlow.flags = MODE_FLAG_HAS_SPEED;
|
||||
RainbowSlow.speed_min = GLORIOUS_SPEED_SLOW;
|
||||
RainbowSlow.speed = GLORIOUS_SPEED_NORMAL;
|
||||
RainbowSlow.speed_max = GLORIOUS_SPEED_FAST;
|
||||
RainbowSlow.color_mode = MODE_COLORS_NONE;
|
||||
RainbowSlow.value = GLORIOUS_MODE_WAVE;
|
||||
modes.push_back(RainbowSlow);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.speed_min = GLORIOUS_MODE_BREATING_SLOW;
|
||||
Breathing.speed = GLORIOUS_MODE_BREATING_NORMAL;
|
||||
Breathing.speed_max = GLORIOUS_MODE_BREATING_FAST;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.value = GLORIOUS_MODE_BREATHING;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a single zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone new_zone;
|
||||
new_zone.name = "Glorious Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_min = gmo->GetLEDCount();
|
||||
new_zone.leds_max = gmo->GetLEDCount();
|
||||
new_zone.leds_count = gmo->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 = "Glorious LED";
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::DeviceUpdateLEDs()
|
||||
{
|
||||
gmo->SetLEDColor(&colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
void RGBController_GloriousModelO::SetCustomMode()
|
||||
{
|
||||
//active_mode = 2;
|
||||
}
|
||||
|
||||
void RGBController_GloriousModelO::UpdateMode()
|
||||
{
|
||||
unsigned int direction = 0;
|
||||
unsigned int speed = GLORIOUS_SPEED_NORMAL;
|
||||
|
||||
if (modes[active_mode].value == GLORIOUS_MODE_STATIC)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (modes[active_mode].direction == MODE_DIRECTION_UP)
|
||||
{
|
||||
direction = GLORIOUS_DIRECTION_DOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = GLORIOUS_DIRECTION_UP;
|
||||
}
|
||||
|
||||
if ((modes[active_mode].speed == GLORIOUS_SPEED_FAST) ||
|
||||
(modes[active_mode].speed == GLORIOUS_SPEED_SLOW) ||
|
||||
(modes[active_mode].speed == GLORIOUS_SPEED_NORMAL))
|
||||
{
|
||||
speed = modes[active_mode].speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((modes[active_mode].speed == GLORIOUS_MODE_BREATING_FAST) ||
|
||||
(modes[active_mode].speed == GLORIOUS_MODE_BREATING_SLOW) ||
|
||||
(modes[active_mode].speed == GLORIOUS_MODE_BREATING_NORMAL))
|
||||
{
|
||||
speed = modes[active_mode].speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed = GLORIOUS_SPEED_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (modes[active_mode].color_mode == MODE_COLORS_NONE)
|
||||
{
|
||||
gmo->SetMode(modes[active_mode].value, speed, direction, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
gmo->SetMode(modes[active_mode].value, speed, direction, &modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//wave, epilepsy, spectrum cycle, tail, glorious mode, off
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_GloriousModelO.h |
|
||||
| |
|
||||
| Definitions and types for Glorious |
|
||||
| and other Mice |
|
||||
| |
|
||||
| Niels Westphal (crashniels) 20/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "GloriousModelOController.h"
|
||||
|
||||
class RGBController_GloriousModelO : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_GloriousModelO(GloriousModelOController* gmo_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
GloriousModelOController* gmo;
|
||||
};
|
||||
@@ -26,16 +26,7 @@
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
@@ -48,12 +39,12 @@ THREAD keepalive_thread(void *param)
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 15, 28, 42, 52, NA, 63, 73, 82, 93, NA, 8, 21, 36, 6, 20, 34, 47, NA, NA, NA, NA },
|
||||
{ 1, 16, 29, 43, 53, 64, 74, 83, 94, 9, 22, NA, 37, 7, 35, NA, 58, 68, 78, 50, 61, 71, 80 },
|
||||
{ 2, NA, 17, 30, 44, 54, NA, 65, 75, 84, 95, 10, 23, 38, 88, 99, 48, 59, 69, 49, 60, 70, 91 },
|
||||
{ 3, NA, 18, 31, 45, 55, NA, 66, 76, 85, 96, 11, 24, 39, 26, NA, NA, NA, NA, 90, 101, 51, NA },
|
||||
{ 4, NA, 32, 46, 56, 67, NA, 77, NA, 86, 97, 12, 25, 40, 79, NA, NA, 100, NA, 62, 72, 81, 102 },
|
||||
{ 5, 19, 33, NA, NA, NA, NA, 57, NA, NA, NA, NA, 87, 98, 13, 89, 14, 27, 41, 92, NA, 103, NA } };
|
||||
{ { 0, NA, 16, 30, 44, 54, NA, 65, 75, 84, 95, NA, 8, 23 , 38, 6 , 22, 36, 49, NA, NA, NA, NA },
|
||||
{ 1, 17, 31, 45, 55, 66, 76, 85, 96, 9, 24, NA, 39, 7 , 37, NA , 60, 70, 80, 52, 63, 73, 82 },
|
||||
{ 2, NA, 18, 32, 46, 56, NA, 67, 77, 86, 97, 10, 25, 40 , 90, 101, 50, 61, 71, 51, 62, 72, 93 },
|
||||
{ 3, NA, 19, 33, 47, 57, NA, 68, 78, 87, 98, 11, 26, 41 , 28, 14 , NA, NA, NA, 92, 103, 53, NA },
|
||||
{ 4, 20, 34, 48, 58, 69, NA, 79, NA, 88, 99, 12, 27, 42 , 81, NA , NA, 102, NA, 64, 74, 83, 104 },
|
||||
{ 5, 21, 35, NA, NA, NA, NA, 59, NA, NA, NA, NA, 89, 100, 13, 91 , 15, 29, 43, 94, NA, 105, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
@@ -71,12 +62,12 @@ static zone_type zone_types[] =
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104,
|
||||
106,
|
||||
18,
|
||||
4
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
static const char *led_names[] =
|
||||
{
|
||||
"Key: Escape",
|
||||
"Key: `",
|
||||
@@ -92,11 +83,13 @@ static const char* led_names[] =
|
||||
"Key: L",
|
||||
"Key: ,",
|
||||
"Key: Context",
|
||||
"Key: UK Enter",
|
||||
"Key: Left Arrow",
|
||||
"Key: F1",
|
||||
"Key: 1",
|
||||
"Key: Q",
|
||||
"Key: A",
|
||||
"Key: UK Backslash",
|
||||
"Key: Left Windows",
|
||||
"Key: Print Screen",
|
||||
"Key: F10",
|
||||
@@ -324,6 +317,8 @@ void RGBController_HyperXKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
|
||||
void RGBController_HyperXKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = clock();
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SetLEDsDirect(colors);
|
||||
@@ -368,8 +363,11 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
UpdateLEDs();
|
||||
if((clock() - last_update_time) > 50)
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
}
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(10ms);;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <time.h>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXKeyboardController.h"
|
||||
|
||||
@@ -32,4 +34,6 @@ public:
|
||||
|
||||
private:
|
||||
HyperXKeyboardController* hyperx;
|
||||
|
||||
clock_t last_update_time;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG203.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G203 |
|
||||
| Prodigy RGB Mouse |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG203.h"
|
||||
|
||||
RGBController_LogitechG203::RGBController_LogitechG203(LogitechG203Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Mouse Device";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G203_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G203_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G203_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G203_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G203_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G203_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G203_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = LOGITECH_G203_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G203_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G203_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::SetupZones()
|
||||
{
|
||||
zone g203_zone;
|
||||
g203_zone.name = "Mouse Zone";
|
||||
g203_zone.type = ZONE_TYPE_SINGLE;
|
||||
g203_zone.leds_min = 1;
|
||||
g203_zone.leds_max = 1;
|
||||
g203_zone.leds_count = 1;
|
||||
g203_zone.matrix_map = NULL;
|
||||
zones.push_back(g203_zone);
|
||||
|
||||
led g203_led;
|
||||
g203_led.name = "Mouse LED";
|
||||
leds.push_back(g203_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
logitech->SendMouseMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG203.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G203 |
|
||||
| Prodigy RGB Mouse |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG203Controller.h"
|
||||
|
||||
class RGBController_LogitechG203 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG203(LogitechG203Controller* logitech_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG203Controller* logitech;
|
||||
};
|
||||
@@ -0,0 +1,123 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG403.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G403 |
|
||||
| Prodigy RGB Mouse |
|
||||
| |
|
||||
| Martin Hartl (inlar) 5/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG403.h"
|
||||
|
||||
RGBController_LogitechG403::RGBController_LogitechG403(LogitechG403Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Mouse Device";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G403_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G403_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G403_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G403_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G403_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G403_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G403_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = LOGITECH_G403_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G403_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G403_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::SetupZones()
|
||||
{
|
||||
zone G403_wheel_zone;
|
||||
G403_wheel_zone.name = "Mouse Wheel Zone";
|
||||
G403_wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
G403_wheel_zone.leds_min = 1;
|
||||
G403_wheel_zone.leds_max = 1;
|
||||
G403_wheel_zone.leds_count = 1;
|
||||
G403_wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(G403_wheel_zone);
|
||||
|
||||
led G403_wheel_led;
|
||||
G403_wheel_led.name = "Mouse Wheel LED";
|
||||
leds.push_back(G403_wheel_led);
|
||||
|
||||
zone G403_logo_zone;
|
||||
G403_logo_zone.name = "Logo Zone";
|
||||
G403_logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
G403_logo_zone.leds_min = 1;
|
||||
G403_logo_zone.leds_max = 1;
|
||||
G403_logo_zone.leds_count = 1;
|
||||
G403_logo_zone.matrix_map = NULL;
|
||||
zones.push_back(G403_logo_zone);
|
||||
|
||||
led G403_logo_led;
|
||||
G403_logo_led.name = "Logo LED";
|
||||
leds.push_back(G403_logo_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::DeviceUpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
UpdateZoneLEDs(1);
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[zone]);
|
||||
unsigned char grn = RGBGetGValue(colors[zone]);
|
||||
unsigned char blu = RGBGetBValue(colors[zone]);
|
||||
|
||||
logitech->SendMouseMode(modes[active_mode].value, modes[active_mode].speed, zone, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG403::UpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG403.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G403 |
|
||||
| Prodigy RGB Mouse |
|
||||
| |
|
||||
| Martin Hartl (inlar) 5/19/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG403Controller.h"
|
||||
|
||||
class RGBController_LogitechG403 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG403(LogitechG403Controller* logitech_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG403Controller* logitech;
|
||||
};
|
||||
@@ -0,0 +1,375 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG810.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[7][23] =
|
||||
{ { 111, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 116, 114, 115, NA, 113, NA, 112, 110, NA, NA, NA },
|
||||
{ 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, 66, 67, 68, 109, 108, 107, 106 },
|
||||
{ 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, 69, 70, 71, 79, 80, 81, 82 },
|
||||
{ 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, 72, 73, 74, 91, 92, 93, 83 },
|
||||
{ 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 99, 96, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, 78, NA, 85, 86, 87, 84 },
|
||||
{ 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, 76, 77, 75, 94, NA, 95, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -/_", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =/+", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [/{", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]/}", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\/|", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #/~", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;/:", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '/'\"", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `/~", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,/<", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: ./>", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: //?", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Num Pad /", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Num Pad *", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Num Pad -", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Num Pad +", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Num Pad Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Num Pad 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Num Pad 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Num Pad 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Num Pad 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Num Pad 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Num Pad 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Num Pad 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Num Pad 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Num Pad 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Num Pad 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Num Pad .", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\/|", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Context", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE7 },
|
||||
{ "Media Next", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB5 },
|
||||
{ "Media Previous", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB6 },
|
||||
{ "Media Stop", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB7 },
|
||||
{ "Media Play/Pause", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xCD },
|
||||
{ "Media Mute", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xE2 },
|
||||
{ "Logo", LOGITECH_G810_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Lighting", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x01 },
|
||||
{ "Game Mode", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x02 },
|
||||
{ "Caps Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x03 },
|
||||
{ "Scroll Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x04 },
|
||||
{ "Num Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G810_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 Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G810_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G810_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G810_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateLEDs()
|
||||
{
|
||||
#define MAX_FRAMES_PER_PACKET 0x0E
|
||||
|
||||
unsigned char frame_buf[MAX_FRAMES_PER_PACKET * 4];
|
||||
unsigned char frame_cnt = 0;
|
||||
unsigned char prev_zone = 0;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value & 0xFF );
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
frame_buf[(frame_cnt * 4) + 0] = idx;
|
||||
frame_buf[(frame_cnt * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
frame_cnt++;
|
||||
prev_zone = zone;
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char frame[4];
|
||||
unsigned char zone;
|
||||
unsigned char idx;
|
||||
|
||||
zone = ( leds[led].value >> 8 );
|
||||
idx = ( leds[led].value & 0xFF );
|
||||
|
||||
frame[0] = idx;
|
||||
frame[1] = RGBGetRValue(colors[led]);
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetDirect(zone, 1, frame);
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(active_mode == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
return;
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
|
||||
class RGBController_LogitechG810 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG810(LogitechG810Controller* logitech_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG810Controller* logitech;
|
||||
};
|
||||
@@ -138,8 +138,8 @@ void RGBController_MSIMysticLight::SetupModes()
|
||||
constexpr unsigned int RANDOM_ONLY = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
constexpr unsigned int COMMON = RANDOM_ONLY | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
|
||||
SetupMode("Off", DISABLE, 0);
|
||||
SetupMode("Static", STATIC, MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR);
|
||||
SetupMode("Off", DISABLE, 0);
|
||||
SetupMode("Breathing", BREATHING, COMMON);
|
||||
SetupMode("Flashing", FLASHING, COMMON);
|
||||
SetupMode("Double flashing", DOUBLE_FLASHING, COMMON);
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Hue2.cpp |
|
||||
| RGBController_NZXTHue2.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue 2 |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Hue2.h"
|
||||
#include "RGBController_NZXTHue2.h"
|
||||
|
||||
|
||||
RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
RGBController_NZXTHue2::RGBController_NZXTHue2(NZXTHue2Controller* hue2_ptr)
|
||||
{
|
||||
hue2 = hue2_ptr;
|
||||
|
||||
name = "NZXT Hue 2";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "NZXT Hue 2 Device";
|
||||
version = hue2->GetFirmwareVersion();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -129,7 +130,7 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetupZones()
|
||||
void RGBController_NZXTHue2::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Set up zones |
|
||||
@@ -170,12 +171,12 @@ void RGBController_Hue2::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Hue2::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
void RGBController_NZXTHue2::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Hue2::DeviceUpdateLEDs()
|
||||
void RGBController_NZXTHue2::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
@@ -183,24 +184,24 @@ void RGBController_Hue2::DeviceUpdateLEDs()
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateZoneLEDs(int zone)
|
||||
void RGBController_NZXTHue2::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
hue2->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateSingleLED(int led)
|
||||
void RGBController_NZXTHue2::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned int zone_idx = leds[led].value;
|
||||
|
||||
hue2->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
|
||||
}
|
||||
|
||||
void RGBController_Hue2::SetCustomMode()
|
||||
void RGBController_NZXTHue2::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_Hue2::UpdateMode()
|
||||
void RGBController_NZXTHue2::UpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0xFFFF)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Hue2.h |
|
||||
| RGBController_NZXTHue2.h |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue 2 |
|
||||
| |
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "Hue2Controller.h"
|
||||
#include "NZXTHue2Controller.h"
|
||||
|
||||
class RGBController_Hue2 : public RGBController
|
||||
class RGBController_NZXTHue2 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Hue2(Hue2Controller* hue2_ptr);
|
||||
RGBController_NZXTHue2(NZXTHue2Controller* hue2_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
Hue2Controller* hue2;
|
||||
NZXTHue2Controller* hue2;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
std::vector<unsigned int> zones_channel;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user