Compare commits

...
Author SHA1 Message Date
Kasper 90242dad0f QMK Improvements - make LEDs per update configurable
* Fix Windows include error that breaks std::min/max if a Windows header is included (tracked down to
net_port.h)

Commit amended by Adam Honse <[email protected]>
2021-06-25 20:52:19 -05:00
Dima-Kal 325169b16b Add support for Sinowealth keyboard
Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-06-24 22:51:01 -05:00
edbgon 6b184f2b8c Initial G933 support 2021-06-22 17:19:47 +00:00
Adam Honse 742b477f6f Add keymap for Blade 14 2021 2021-06-21 20:27:58 -05:00
Adam Honse b4b22e2dce Add Razer Blade 14 2021 2021-06-21 12:31:10 -07:00
TheRogueZeta 6a134a1f75 Add logging to ASRock Polychome SMBus detection and fix stack smashing caused by Polychrome block read. 2021-06-21 04:45:48 +00:00
Chris 920542e8b6 Adding "random" to the acceptable inputs for the --color switch to align with GUI
* Allows for the selection of color_mode = MODE_COLORS_RANDOM from the CLI for devices that support it
* For all other implementations will return a random colour from the `human_colors` struct

* To avoid filtering in the profile manager and to ensure that color_mode is set to MODE_COLORS_RANDOM correctly
for HW that has the mode flags

MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_PER_LED_COLOR

The values for speed_min, speed_max, colors_min and colors_max NEED to be initialised to allow for a saved
profile to load correctly in `ProfileManager::LoadDeviceFromListWithOptions`

Commit amended by Adam Honse <[email protected]> to remove Aura SMBus change, will add as its own
commit.
2021-06-20 23:35:37 -05:00
David Lee 09db948f9f fixed typo in SteelSeriesControllerDetect.cpp 2021-06-21 04:12:05 +00:00
Alex fdfe6f764e Update Fedora build instructions in readme
git, make, gcc are pre-installed; qt-creator isn't necessary, qt5-qtbase-devel provides qmake-qt5; libusb is now libusbx; libmbedtls is actually mbedtls
2021-06-20 23:11:10 -05:00
Stefan Silviu 510ac44d27 Fix typo 2021-06-20 23:07:42 -05:00
Stefan Silviu 840aae45a4 Detect Redragon M716 Inquisitor mouse 2021-06-20 23:07:10 -05:00
Alex 9d36d6743a Add Asus Strix rx570 O4G pci id 2021-06-18 22:31:24 +02:00
Adam Honse 50f3c4c4b8 Add Womier K66 to EVision Keyboard controller 2021-06-18 11:01:57 -05:00
Adam Honse bec99489fb Add Womier K87 to EVision Keyboard controller 2021-06-17 21:13:02 -05:00
TheRogueZeta 90338354a6 Update PCI ID Macros to test against device ID 2021-06-17 10:48:06 -05:00
Alex 1053b83782 Fixing wmi issue when device detection thread run nth time 2021-06-17 10:47:59 -05:00
Mola19 b49edaafb0 Added support for ASUS TUF Gaming K7
* Always sends save command when changing modes, this should be reworked to be optional in a future commit

Commit amended for code style by Adam Honse <[email protected]>
2021-06-17 10:47:50 -05:00
Alex ba3aae8780 Fix Razer Ornata V2 Detection 2021-06-16 21:22:44 +02:00
Dave 518c05976e * Fix Smart Device V2 in H710i, bought in June 2021 - it uses a new PID 2021-06-16 13:20:36 -05:00
Alex 276895359a Add UK layout support for HyperX Alloy 2021-06-16 13:13:39 -05:00
mike 4a333e9b50 Fixed HyperX Alloy Origins Core HID communication on Windows
* Added serial number support
  * Amended to pass in HID device information for version number rather than enumerate a second time

Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-06-13 16:00:05 -05:00
Vavooon a20a19e570 Add HyperX Origins Core support (direct mode)
Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-06-13 00:02:32 -05:00
Roman Stingler c665c877fa Bad deallocator in AsusAuraSMBusController.cpp 2021-06-13 04:43:35 +00:00
Adam Honse 3ccab3d949 Fix Logitech common files out of order in project file 2021-06-12 00:18:00 -05:00
Mola19 fcb617ee47 Add support for ASUS ROG Throne Qi headset stand
Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-06-12 00:16:40 -05:00
Alex ce7478737c Add Steelseries Rival 650 wireless support
* Also reworks the LED update functions to handle zones with more than one LED
  * Some other minor code style cleanup in the Rival code

Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-06-11 18:12:40 -05:00
edbgon 8736f1b169 Initial support for Logitech X56 Rhino Hotas
Commit amended for code style by Adam Honse <[email protected]>
2021-06-11 17:01:42 -05:00
Alex 18939e6754 Add ASUS ROG Gladius II Wireless
Commit amended for code style by Adam Honse <[email protected]>
2021-06-10 23:13:26 -05:00
TheRogueZeta 806d77d2d6 Convert Polychrome read to i2c_smbus_read_block_data 2021-06-10 22:33:50 -05:00
TheRogueZeta b17b6340bd Test to see if Patriot Viper DRAM modules exist before performing writes
Amended to use read check as quick check doesn't work for SPD addresses by Adam Honse <[email protected]>
2021-06-10 21:09:26 -05:00
TheRogueZeta 46d353bc66 Fix missing % that got lost in transfer 2021-06-10 00:10:28 -05:00
TheRogueZeta b72de2fe5e Update README.md for Hue build requirements 2021-06-07 10:49:52 -07:00
TheRogueZeta 24d1c5f2ae Update HID device log prints to use caps 2021-06-06 16:44:05 -07:00
DrZlo13 bf99a5f250 New device: Obinslab Anne Pro 2
* Renamed "Obins Lab" to "Obinslab" as that is the name that I saw used most frequently in store listings.

Commit amended for code style and to update the name by Adam Honse <[email protected]>
2021-06-06 14:17:57 -05:00
Thomas greenwood 0755959741 Implement modes for Logitech G213 Keyboard 2021-06-06 02:41:56 +01:00
Jeff P fe11115f32 Add support for Corsair Commander Core / Elite Capellix
Amended for code style by Adam Honse <[email protected]>
2021-06-04 22:45:36 -05:00
Adam Honse 9a00f1d6d8 Fix CI for Philips Hue changes
* Debian builder has been upgraded to buster due to incompatible mbedtls package on stretch
  * Mint 19, Ubuntu 18.04 have been disabled for testing as they use incompatible mbedtls packages
2021-06-05 03:18:12 +00:00
Adam Honse b7e2103f41 Disable parsing certificate, it doesn't appear to be necessary to control Hue and prevents build on older mbedtls releases 2021-06-05 03:18:12 +00:00
Adam Honse 87043cde65 Fix issue with Windows in hueplusplus library 2021-06-05 03:18:12 +00:00
Adam Honse 2aaf7017ee Philips Hue (Standard and Entertainment Mode) Support using hueplusplus library
* Dependency hueplusplus-1.0.0 added from https://github.com/enwi/hueplusplus/releases/tag/v1.0.0
* Dependency mbedtls-2.24.0 added (Windows-only) from https://github.com/ARMmbed/mbedtls/releases/tag/mbedtls-2.24.0
2021-06-05 03:18:12 +00:00
mike 22acdd1fed Check return code from hid_get_serial_number_string() in GetSerialString()
Amended for code style by Adam Honse <[email protected]>
2021-06-04 22:14:05 -05:00
Thomas greenwood 4e4eade335 Pad commands for 0x62 with 4 zero bytes 2021-06-05 02:52:37 +00:00
Joe Smith 9f7812bc7b No more qt5-default package in debian
[Looks](https://askubuntu.com/questions/1335184/qt5-default-not-in-ubuntu-21-04) like this [was removed](https://bugs.launchpad.net/ubuntu/+source/qtbase-opensource-src/+bug/1926802) in Debian `bullseye` + Ubuntu `21.04`.
2021-06-05 02:18:02 +00:00
TheRogueZeta 6029a5b0c5 Add Non OC 2060S PCIe ID, correct RAM 2021-06-04 15:51:15 -07:00
TheRogueZeta 74a49ec3e6 Add ASUS ROG Strix RTX 2060S A8G Evo to detector 2021-06-04 15:50:17 -07:00
Short_String_Dev 21dd2ee66a Add ASUS ROG STRIX 2070 A8G Gaming 2021-06-04 08:57:23 -04:00
Short_String_Dev f76d78775c Add ASUS ROG STRIX 2070 O8G Gaming 2021-06-04 08:25:15 -04:00
TheRogueZeta af01ff5de3 Add ASUS ROG Strix 1080 O8G to detector 2021-06-03 17:53:40 +00:00
Tom Greenwood f2f84fc7e3 Add support for Gigabyte RTX3060 Gaming OC 12GB 2021-06-03 17:07:48 +00:00
TheRogueZeta 939f46c025 G Pro Wired are only 1 zone devices 2021-06-03 08:31:37 -07:00
TheRogueZeta a1469041e5 Add ASUS ROG Strix 1070 Gaming to detector 2021-06-03 02:27:14 +00:00
TheRogueZeta f39b57fadc Add Gigabyte RTX 2060 Gaming OC Pro to the detector 2021-06-03 02:26:00 +00:00
Dennis Piecha 08a985a216 Add ASUS ROG STRIX RTX 2070S O8G Gaming 8G 2021-06-02 22:01:52 +02:00
Harry Kane 7054badf4f Update URL to HTTPS 2021-06-02 03:30:01 +00:00
SR_team 332a04f94c Add missing key for ANSI layout of Logitech G815 into LED View 2021-06-01 20:41:57 +00:00
TheRogueZeta ae88771e79 Correct G502 Wireless (wired) PID in linux builds 2021-06-01 00:19:50 -07:00
TheRogueZeta 09e524314f Correct G502 PS and G502 Hero detector changes. 2021-05-31 23:47:37 -07:00
Adam Honse 8e8573e7d0 Increment version number post-release 2021-06-01 01:35:51 -05:00
Adam Honse 405ff7f6a5 OpenRGB version 0.6 2021-06-01 00:05:08 -05:00
Adam Honse 563ff31fe3 Wait up to 5 seconds for the local server connection to retrieve all controllers before continuing, so that CLI mode has all controllers available for applying changes 2021-05-31 23:44:33 -05:00
Chris 4a6c4f0e52 Adding test stages to Linux builds
* Build based on new OpenRGB docker image (Debian Stretch)
* Adapting AppImage build scripts to new docker image
* Changing postinstall script to avoid error

+ Adding test stage keyword
+ Adding needs keyword
+ Debian 10       Buster 32bit & 64bit
+ Debian 11       Bullseye 32bit & 64bit
+ Fedora 34       v34 64bit only
+ Ubuntu 18.04LTS Bionic 32bit & 64bit
+ Ubuntu 20.04LTS Focal 64bit only
+ Ubuntu 20.10    Groovy 64bit only
+ Mint   20.1     Ulyssa 32bit & 64bit

Amended to leave Bullseye builds in place by Adam Honse <[email protected]>
2021-05-31 23:32:09 -05:00
TheRogueZeta be838aa1d6 Update Logitech Lightspeed detector names 2021-06-01 04:13:46 +00:00
Adam Honse 68b0287cdd Make detectors for QMK OpenRGB controller configurable 2021-05-31 18:35:07 -05:00
Adam Honse d18f66f995 Implement dynamic detectors - run-once functions that can register detectors dynamically 2021-05-31 13:55:22 -05:00
Chris 259ba898b0 Enumerate Wireless connected Logitech Lightspeed (Unifying) devices
+ Added common library for Logitech Protocol
    + Moved wireless detection to the LogitechProtocolCommon.cpp
    + Adding Direct Mode to the wireless control
    + Copying the mutex from Lightsync controller to avoid interference
    + Adding LED count info to controller constructor

+ Created a new Logitech class
    + Added Feature list enumeration
    + Added DeviceName detection from device

* Changed LogitechGProWirelessController to accomodate generic devices
    * LED count from device is now used in RGBController setup

+ Adding Windows specific detection as Linux Kernel handles this already.
+ Adding virtual PIDS for wireless detection
    * LOGITECH G403
    * LOGITECH G502
    * LOGITECH G703
    * LOGITECH G900
    * LOGITECH G903
    * LOGITECH GPRO
+ Adding Logitech G900 Wired Gaming Mouse PID
+ Adding other all lightspeed mice to wired detector for testing
    * Genericised and optimised code paths
    * Speed up wireless detection

Commit amended for code style by Adam Honse <[email protected]>
2021-05-31 10:59:04 -07:00
Adam Honse d8252281ce Prevent theme box from saving theme setting until initialized 2021-05-30 21:08:23 -07:00
Kasper a5928518c1 Implement QMK OpenRGB Procotol
This commit squashes commits by:

    Kasper <[email protected]>
    jath03 <[email protected]>
    Adam Honse <[email protected]>

Commits squashed and amended for code style by Adam Honse <[email protected]>
2021-05-30 18:41:55 -05:00
Felipe Guaycuru b3b392b3e2 Make Corsair K55 behavior be closer to iCue's 2021-05-30 22:33:31 +00:00
1478 changed files with 385906 additions and 355 deletions
+240 -9
View File
@@ -16,6 +16,7 @@
stages:
- build
- test
before_script:
- echo "started by ${GITLAB_USER_NAME}"
@@ -23,15 +24,15 @@ before_script:
#reusable templates
.ccache_init: &ccache_init
before_script:
- apt update
- apt install -y build-essential qtcreator qtbase5-dev libusb-1.0-0-dev libhidapi-dev pkgconf wget git file
- export QT_SELECT=qt5
- export APPIMAGE_EXTRACT_AND_RUN=1
#-----------------------------------------------------------------------#
# Linux (AppImage) 32-bit Build Target #
#-----------------------------------------------------------------------#
"Linux 32 AppImage":
<<: *ccache_init
image: i386/debian:bullseye
image: registry.gitlab.com/openrgbdevelopers/openrgb-linux-ci-deb-builder:buster-32
stage: build
script:
- export $(dpkg-architecture)
@@ -50,7 +51,7 @@ before_script:
#-----------------------------------------------------------------------#
"Linux 64 AppImage":
<<: *ccache_init
image: debian:bullseye
image: registry.gitlab.com/openrgbdevelopers/openrgb-linux-ci-deb-builder:buster-64
stage: build
script:
- export $(dpkg-architecture)
@@ -69,10 +70,9 @@ before_script:
#-----------------------------------------------------------------------#
"Linux 32 deb":
<<: *ccache_init
image: i386/debian:bullseye
image: registry.gitlab.com/openrgbdevelopers/openrgb-linux-ci-deb-builder:buster-32
stage: build
script:
- apt install -y debhelper
- dpkg-architecture -l
- dpkg-buildpackage --target-arch i386 -us -B
- rm -v ../openrgb-dbgsym*.deb
@@ -91,10 +91,9 @@ before_script:
#-----------------------------------------------------------------------#
"Linux 64 deb":
<<: *ccache_init
image: debian:bullseye
image: registry.gitlab.com/openrgbdevelopers/openrgb-linux-ci-deb-builder:buster-64
stage: build
script:
- apt install -y debhelper
- dpkg-architecture -l
- dpkg-buildpackage -us -B
- rm -v ../openrgb-dbgsym*.deb
@@ -134,7 +133,239 @@ before_script:
paths:
- openrgb*.rpm
expire_in: 30 days
#-----------------------------------------------------------------------#
# Linux (.deb) Debian Bullseye 32-bit Build Target #
#-----------------------------------------------------------------------#
"Linux 32 deb Bullseye":
<<: *ccache_init
image: i386/debian:bullseye
stage: build
script:
- apt update
- apt install -y build-essential qtcreator qtbase5-dev libusb-1.0-0-dev libhidapi-dev libmbedtls-dev pkgconf wget git file debhelper
- dpkg-architecture -l
- dpkg-buildpackage --target-arch i386 -us -B
- rm -v ../openrgb-dbgsym*.deb
- mv -v ../openrgb*.deb ./
artifacts:
name: "${CI_PROJECT_NAME}_Linux_32_deb_${CI_COMMIT_SHORT_SHA}"
paths:
- openrgb*.deb
exclude:
- openrgb-dbgsym*.deb
expire_in: 30 days
#-----------------------------------------------------------------------#
# Linux (.deb) Debian Bullseye 64-bit Build Target #
#-----------------------------------------------------------------------#
"Linux 64 deb Bullseye":
<<: *ccache_init
image: debian:bullseye
stage: build
script:
- apt update
- apt install -y build-essential qtcreator qtbase5-dev libusb-1.0-0-dev libhidapi-dev libmbedtls-dev pkgconf wget git file debhelper
- dpkg-architecture -l
- dpkg-buildpackage -us -B
- rm -v ../openrgb-dbgsym*.deb
- mv -v ../openrgb*.deb ./
artifacts:
name: "${CI_PROJECT_NAME}_Linux_64_deb_${CI_COMMIT_SHORT_SHA}"
paths:
- openrgb*.deb
exclude:
- openrgb-dbgsym*.deb
expire_in: 30 days
#-----------------------------------------------------------------------#
# Debian 32 Buster test #
#-----------------------------------------------------------------------#
"Debian 32 Buster":
image: i386/debian:buster
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*i386.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 32 deb"
needs:
- "Linux 32 deb"
#-----------------------------------------------------------------------#
# Debian 32 Bullseye test #
#-----------------------------------------------------------------------#
"Debian 32 Bullseye":
image: i386/debian:bullseye
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*i386.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 32 deb"
needs:
- "Linux 32 deb"
# #-----------------------------------------------------------------------#
# # Ubuntu 32 18.04LTS test #
# #-----------------------------------------------------------------------#
# "Ubuntu 32 18.04LTS":
# image: i386/ubuntu:bionic
# stage: test
# script:
# - apt update
# - DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*i386.deb
# - openrgb --version
# - openrgb -l
# - apt remove -y openrgb
# dependencies:
# - "Linux 32 deb"
# needs:
# - "Linux 32 deb"
# #-----------------------------------------------------------------------#
# # Mint 32 19.3 test #
# #-----------------------------------------------------------------------#
# "Mint 32 20.1":
# image: linuxmintd/mint19.3-i386
# stage: test
# script:
# - apt update
# - DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*i386.deb
# - openrgb --version
# - openrgb -l
# - apt remove -y openrgb
# dependencies:
# - "Linux 32 deb"
# needs:
# - "Linux 32 deb"
#-----------------------------------------------------------------------#
# Debian 64 Buster test #
#-----------------------------------------------------------------------#
"Debian 64 Buster":
image: debian:buster
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 64 deb"
needs:
- "Linux 64 deb"
#-----------------------------------------------------------------------#
# Debian 64 Bullseye test #
#-----------------------------------------------------------------------#
"Debian 64 Bullseye":
image: debian:bullseye
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 64 deb"
needs:
- "Linux 64 deb"
#-----------------------------------------------------------------------#
# Fedora 64 v34 test #
#-----------------------------------------------------------------------#
"Fedora 64 v34":
image: fedora:34
stage: test
script:
- yum -y localinstall ./openrgb*64.rpm
- openrgb --version
- openrgb -l
- yum -y remove openrgb
dependencies:
- "Linux 64 rpm"
needs:
- "Linux 64 rpm"
# #-----------------------------------------------------------------------#
# # Ubuntu 64 18.04LTS test #
# #-----------------------------------------------------------------------#
# "Ubuntu 64 18.04LTS":
# image: ubuntu:bionic
# stage: test
# script:
# - apt update
# - DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
# - openrgb --version
# - openrgb -l
# - apt remove -y openrgb
# dependencies:
# - "Linux 64 deb"
# needs:
# - "Linux 64 deb"
#-----------------------------------------------------------------------#
# Ubuntu 64 20.04LTS test #
#-----------------------------------------------------------------------#
"Ubuntu 64 20.04LTS":
image: ubuntu:focal
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 64 deb"
needs:
- "Linux 64 deb"
#-----------------------------------------------------------------------#
# Ubuntu 64 20.10 test #
#-----------------------------------------------------------------------#
"Ubuntu 64 20.10":
image: ubuntu:groovy
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 64 deb"
needs:
- "Linux 64 deb"
#-----------------------------------------------------------------------#
# Mint 64 20.1 test #
#-----------------------------------------------------------------------#
"Mint 64 20.1":
image: linuxmintd/mint20.1-amd64
stage: test
script:
- apt update
- DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends ./openrgb*amd64.deb
- openrgb --version
- openrgb -l
- apt remove -y openrgb
dependencies:
- "Linux 64 deb"
needs:
- "Linux 64 deb"
#-----------------------------------------------------------------------#
# Windows (32-bit) Build Target #
#-----------------------------------------------------------------------#
+19 -1
View File
@@ -65,6 +65,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18cf", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18e5", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18e3", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="1958", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18a0", TAG+="uaccess"
#---------------------------------------------------------------#
# ASUS TUF Laptops (faustus) #
@@ -338,6 +339,12 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0cf2", ATTR{idProduct}=="7750", TAG+="uacces
# Speakers: #
# Logitech G560 #
# #
# Headsets: #
# Logitech G933 #
# #
# Joysticks: #
# Logitech Rhino X56 Hotas (Throttle and Stick) #
# #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c336", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c342", TAG+="uaccess"
@@ -375,6 +382,11 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c53a", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="0a78", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="0a5b", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0738", ATTR{idProduct}=="2221", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0738", ATTR{idProduct}=="A221", TAG+="uaccess"
#---------------------------------------------------------------#
# Metadot Das Keyboard 4Q + 5Q #
#---------------------------------------------------------------#
@@ -456,6 +468,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2005", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2006", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2007", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="2009", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1e71", ATTR{idProduct}=="200D", TAG+="uaccess"
#---------------------------------------------------------------#
# NZXT Kraken #
@@ -614,6 +627,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1e7d", ATTR{idProduct}=="2e27", TAG+="uacces
# Mice: #
# Redragon M711 Cobra #
# Redragon M715 Dagger #
# Redragon M716 Inquisitor #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5204", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="5104", TAG+="uaccess"
@@ -622,6 +636,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0c45", ATTR{idProduct}=="652f", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc30", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc39", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc3a", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc4d", TAG+="uaccess"
#---------------------------------------------------------------#
@@ -665,7 +680,8 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="0ba0", TAG+="uacces
# SteelSeries Rival 300 Blackops Edition #
# SteelSeries Rival 310 #
# SteelSeries Rival 310 CS:GO Howl Edition #
# SteelSeries Rival 310 PubG Edition #
# SteelSeries Rival 310 PubG Edition #
# SteelSeries Rival 650 Wireless #
# SteelSeries Rival Sensei Ten #
# SteelSeries Rival Sensei Ten CS:GO Neon Rider #
# SteelSeries Rival Sensei 310 #
@@ -700,6 +716,8 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1736", TAG+="uacces
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1832", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1834", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1722", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1726", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="172B", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1038", ATTR{idProduct}=="1229", TAG+="uaccess"
@@ -52,7 +52,12 @@ char* AMDWraithPrismController::GetDeviceName()
std::string AMDWraithPrismController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -10,6 +10,7 @@
#include "ASRockPolychromeSMBusController.h"
#include <cstring>
#include "dependencies/dmiinfo.h"
#include "LogManager.h"
using namespace std::chrono_literals;
@@ -20,36 +21,39 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
DMIInfo dmi;
unsigned short fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
device_name = "ASRock " + dmi.getMainboard();
fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
/*-----------------------------------------------------*\
| Determine whether the device uses ASR LED or |
| Polychrome protocol by checking firmware version. |
| Versions 1.xx and 2.xx use ASR LED, 3.xx uses |
| Polychrome |
| Versions: 1.xx are ASR RGB LED |
| 2.xx are Polychrome v1 |
| 3.xx are Polychrome v2 |
\*-----------------------------------------------------*/
switch(major_version)
{
case ASROCK_TYPE_ASRLED:
device_name = "ASRock " + dmi.getMainboard();
LOG_DEBUG("Device type is ASR RGB LED");
asrock_type = ASROCK_TYPE_ASRLED;
memset(zone_led_count, 0, sizeof(zone_led_count));
break;
case ASROCK_TYPE_POLYCHROME_V1:
device_name = "ASRock " + dmi.getMainboard();
LOG_DEBUG("Device type is Polychrome v1");
asrock_type = ASROCK_TYPE_POLYCHROME_V1;
ReadLEDConfiguration();
break;
case ASROCK_TYPE_POLYCHROME_V2:
device_name = "ASRock " + dmi.getMainboard();
LOG_DEBUG("Device type is Polychrome v2");
asrock_type = ASROCK_TYPE_POLYCHROME_V2;
ReadLEDConfiguration();
break;
default:
LOG_DEBUG("Got Unknown version!");
asrock_type = ASROCK_TYPE_UNKNOWN;
break;
}
@@ -82,7 +86,6 @@ std::string PolychromeController::GetDeviceName()
std::string PolychromeController::GetFirmwareVersion()
{
unsigned short fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
unsigned char minor_version = fw_version & 0xFF;
@@ -93,17 +96,20 @@ unsigned short PolychromeController::ReadFirmwareVersion()
{
// The firmware register holds two bytes, so the first read should return 2
// If not, report invalid firmware revision FFFF
if (bus->i2c_smbus_read_byte_data(dev, ASROCK_REG_FIRMWARE_VER) == 0x02)
LOG_DEBUG("Reading back device firmware version");
// Version response array needs to be 32 bytes to prevent non ASRock board from stack smashing
unsigned char asrock_version[I2C_SMBUS_BLOCK_MAX] = { 0x00, 0x00 };
if (bus->i2c_smbus_read_block_data(dev, ASROCK_REG_FIRMWARE_VER, asrock_version) == 0x02)
{
std::this_thread::sleep_for(1ms);
unsigned char major = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
unsigned char minor = bus->i2c_smbus_read_byte(dev);
unsigned char major = asrock_version[0];
unsigned char minor = asrock_version[1];
LOG_DEBUG("Device firmware version: v%02d.%02d", major, minor);
return((major << 8) | minor);
}
else
{
LOG_WARNING("Firmware readback failed; Returning 0xFFFF");
return(0xFFFF);
}
}
@@ -114,23 +120,26 @@ void PolychromeController::ReadLEDConfiguration()
| The LED configuration register holds 6 bytes, so the first read should return 6 |
| If not, set all zone sizes to zero |
\*---------------------------------------------------------------------------------*/
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_LED_CONFIG) == 0x06)
LOG_DEBUG("Reading back LED config");
unsigned char asrock_zone_count[I2C_SMBUS_BLOCK_MAX] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
if (bus->i2c_smbus_read_block_data(dev, POLYCHROME_REG_LED_CONFIG, asrock_zone_count) == 0x06)
{
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_1] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_2] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_3] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_4] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_5] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = bus->i2c_smbus_read_byte(dev);
zone_led_count[POLYCHROME_ZONE_1] = asrock_zone_count[0];
zone_led_count[POLYCHROME_ZONE_2] = asrock_zone_count[1];
zone_led_count[POLYCHROME_ZONE_3] = asrock_zone_count[2];
zone_led_count[POLYCHROME_ZONE_4] = asrock_zone_count[3];
zone_led_count[POLYCHROME_ZONE_5] = asrock_zone_count[4];
zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = asrock_zone_count[5];
LOG_DEBUG("Zone 1 LED count: %02d", zone_led_count[POLYCHROME_ZONE_1]);
LOG_DEBUG("Zone 2 LED count: %02d", zone_led_count[POLYCHROME_ZONE_2]);
LOG_DEBUG("Zone 3 LED count: %02d", zone_led_count[POLYCHROME_ZONE_3]);
LOG_DEBUG("Zone 4 LED count: %02d", zone_led_count[POLYCHROME_ZONE_4]);
LOG_DEBUG("Zone 5 LED count: %02d", zone_led_count[POLYCHROME_ZONE_5]);
LOG_DEBUG("Addressable Zone LED count: %02d", zone_led_count[POLYCHROME_ZONE_ADDRESSABLE]);
}
else
{
LOG_WARNING("LED config read failed");
memset(zone_led_count, 0, sizeof(zone_led_count));
}
}
@@ -209,6 +209,7 @@ public:
private:
unsigned int asrock_type;
unsigned short fw_version;
std::string device_name;
unsigned char active_zone;
unsigned char active_mode;
@@ -1,5 +1,6 @@
#include "Detector.h"
#include "ASRockPolychromeSMBusController.h"
#include "LogManager.h"
#include "RGBController.h"
#include "RGBController_ASRockPolychromeSMBus.h"
#include "i2c_smbus.h"
@@ -56,15 +57,18 @@ void DetectPolychromeSMBusControllers(std::vector<i2c_smbus_interface*>& busses)
// Check for Polychrome controller at 0x6A
if (TestForPolychromeSMBusController(busses[bus], 0x6A))
{
LOG_DEBUG("Detected a device at address 0x6A, Testing for a known controller");
new_polychrome = new PolychromeController(busses[bus], 0x6A);
if(new_polychrome->GetASRockType() != ASROCK_TYPE_UNKNOWN)
{
LOG_DEBUG("Found a known Polychrome device");
new_controller = new RGBController_Polychrome(new_polychrome);
ResourceManager::get()->RegisterRGBController(new_controller);
}
else
{
LOG_DEBUG("Not a Polychrome device or unknown type");
delete new_polychrome;
}
}
@@ -46,7 +46,7 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
{
case ASROCK_TYPE_ASRLED:
{
description = "ASRock ASR LED Device";
description = "ASRock ASR RGB LED Device";
mode Off;
Off.name = "Off";
@@ -54,8 +54,13 @@ std::string PolychromeUSBController::GetDeviceName()
std::string PolychromeUSBController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -0,0 +1,122 @@
/*-----------------------------------------*\
| AnnePro2Controller.cpp |
| |
| Driver for Obins Lab AnnePro2 keyboard |
| |
| Sergey Gavrilov (DrZlo13) 06/06/2021 |
\*-----------------------------------------*/
#include "AnnePro2Controller.h"
using namespace std::chrono_literals;
AnnePro2Controller::AnnePro2Controller(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
AnnePro2Controller::~AnnePro2Controller()
{
hid_close(dev);
}
std::string AnnePro2Controller::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AnnePro2Controller::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void AnnePro2Controller::SendDirect(unsigned char frame_count, unsigned char * frame_data)
{
/*-------------------------------------------------------------*\
| Reverse engineered by https://github.com/manualmanul/Annemone |
\*-------------------------------------------------------------*/
const unsigned char hid_cmd_service_data_length = 4;
const unsigned char hid_cmd_service_data[hid_cmd_service_data_length] = {0, 123, 16, 65};
const unsigned char hid_cmd_static_message_length = 3;
const unsigned char hid_cmd_static_message[hid_cmd_static_message_length] = {0, 0, 125};
const unsigned char hid_cmd_command_info_length = 3;
const unsigned char hid_cmd_command_info[hid_cmd_command_info_length] = {32, 3, 255};
const unsigned char real_command_info_length = hid_cmd_command_info_length + 1;
const unsigned char max_hid_length = 64;
const unsigned char max_command_length = max_hid_length - hid_cmd_service_data_length - 2 - hid_cmd_static_message_length;
const unsigned char max_message_length = max_command_length - real_command_info_length;
const unsigned char messages_to_send_amount = frame_count / max_message_length + 1;
const unsigned char val_1 = frame_count % max_message_length;
const unsigned char val_2 = (0 == val_1) ? max_message_length : val_1;
unsigned char hid_command[max_hid_length];
unsigned char led_data = 0;
for(unsigned char p = 0; p < messages_to_send_amount; p++)
{
const unsigned char e = (messages_to_send_amount << 4) + p;
const unsigned char a = ((messages_to_send_amount - 1) == p) ? val_2 + real_command_info_length : max_message_length + real_command_info_length;
/*---------------------------------------------------------*\
| Service data |
\*---------------------------------------------------------*/
hid_command[0] = hid_cmd_service_data[0];
hid_command[1] = hid_cmd_service_data[1];
hid_command[2] = hid_cmd_service_data[2];
hid_command[3] = hid_cmd_service_data[3];
hid_command[4] = e;
hid_command[5] = a;
/*---------------------------------------------------------*\
| Static message |
\*---------------------------------------------------------*/
hid_command[6] = hid_cmd_static_message[0];
hid_command[7] = hid_cmd_static_message[1];
hid_command[8] = hid_cmd_static_message[2];
/*---------------------------------------------------------*\
| Command info |
\*---------------------------------------------------------*/
hid_command[9] = hid_cmd_command_info[0];
hid_command[10] = hid_cmd_command_info[1];
hid_command[11] = hid_cmd_command_info[2];
hid_command[12] = 2;
/*---------------------------------------------------------*\
| LED data |
\*---------------------------------------------------------*/
for(uint8_t i = 0; i < max_message_length; i++)
{
hid_command[13 + i] = frame_data[led_data];
led_data++;
}
hid_write(dev, hid_command, max_hid_length);
/*---------------------------------------------------------*\
| Needed due to Anne Pro 2 ignoring commands when they're |
| sent faster than 50ms apart from each other. |
\*---------------------------------------------------------*/
std::this_thread::sleep_for(50ms);
}
}
@@ -0,0 +1,36 @@
/*-----------------------------------------*\
| AnnePro2Controller.h |
| |
| Driver for Obins Lab AnnePro2 keyboard |
| |
| Sergey Gavrilov (DrZlo13) 06/06/2021 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include <string>
#include <vector>
#include <hidapi/hidapi.h>
#pragma once
class AnnePro2Controller
{
public:
AnnePro2Controller(hid_device* dev_handle, const char* path);
~AnnePro2Controller();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendDirect
(
unsigned char frame_count,
unsigned char * frame_data
);
private:
hid_device* dev;
std::string location;
};
@@ -0,0 +1,36 @@
#include "Detector.h"
#include "AnnePro2Controller.h"
#include "RGBController.h"
#include "RGBController_AnnePro2.h"
#include <hidapi/hidapi.h>
#define ANNE_PRO_2_VID 0x04D9
#define ANNE_PRO_2_PID_1 0x8008
#define ANNE_PRO_2_PID_2 0x8009
#define ANNE_PRO_2_PID_3 0xA292
#define ANNE_PRO_2_PID_4 0xA293
/******************************************************************************************\
* *
* DetectAnnePro2Controllers *
* *
* Tests the USB address to see if an Obins Lab AnnePro2 keyboard exists there. *
* *
\******************************************************************************************/
void DetectAnnePro2Controllers(hid_device_info* info, const std::string&)
{
hid_device* dev = hid_open_path(info->path);
if( dev )
{
AnnePro2Controller* controller = new AnnePro2Controller(dev, info->path);
RGBController_AnnePro2* rgb_controller = new RGBController_AnnePro2(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_I("Anne Pro 2", DetectAnnePro2Controllers, ANNE_PRO_2_VID, ANNE_PRO_2_PID_1, 1);
REGISTER_HID_DETECTOR_I("Anne Pro 2", DetectAnnePro2Controllers, ANNE_PRO_2_VID, ANNE_PRO_2_PID_2, 1);
REGISTER_HID_DETECTOR_I("Anne Pro 2", DetectAnnePro2Controllers, ANNE_PRO_2_VID, ANNE_PRO_2_PID_3, 1);
REGISTER_HID_DETECTOR_I("Anne Pro 2", DetectAnnePro2Controllers, ANNE_PRO_2_VID, ANNE_PRO_2_PID_4, 1);
@@ -0,0 +1,235 @@
/*-----------------------------------------*\
| RGBController_AnnePro2.cpp |
| |
| Generic RGB Interface for Obins Lab |
| AnnePro2 keyboard |
| |
| Sergey Gavrilov (DrZlo13) 06/06/2021 |
\*-----------------------------------------*/
#include "RGBController_AnnePro2.h"
#define NA 0xFFFFFFFF
#define LED_REAL_COUNT (5*14)
#define LED_COUNT (LED_REAL_COUNT - 9)
static unsigned int matrix_map[5][14] =
{ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 },
{ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 },
{ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, NA },
{ 41, NA, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, NA },
{ 53, NA, 54, 55, NA, NA, 56, NA, NA, 57, 58, 59, 60, NA } };
static const char* zone_names[] =
{
"Keyboard",
};
static zone_type zone_types[] =
{
ZONE_TYPE_MATRIX
};
static const unsigned int zone_sizes[] =
{
LED_COUNT,
};
typedef struct
{
const char * name;
const unsigned char idx;
} led_type;
static const led_type led_names[] =
{
/* Key Label Index */
{ "Key: Escape", 0 },
{ "Key: 1", 1 },
{ "Key: 2", 2 },
{ "Key: 3", 3 },
{ "Key: 4", 4 },
{ "Key: 5", 5 },
{ "Key: 6", 6 },
{ "Key: 7", 7 },
{ "Key: 8", 8 },
{ "Key: 9", 9 },
{ "Key: 0", 10 },
{ "Key: -", 11 },
{ "Key: =", 12 },
{ "Key: Backspace", 13 },
{ "Key: Tab", 14 },
{ "Key: Q", 15 },
{ "Key: W", 16 },
{ "Key: E", 17 },
{ "Key: R", 18 },
{ "Key: T", 19 },
{ "Key: Y", 20 },
{ "Key: U", 21 },
{ "Key: I", 22 },
{ "Key: O", 23 },
{ "Key: P", 24 },
{ "Key: [", 25 },
{ "Key: ]", 26 },
{ "Key: \\ (ANSI)", 27 },
{ "Key: Caps Lock", 28 },
{ "Key: A", 29 },
{ "Key: S", 30 },
{ "Key: D", 31 },
{ "Key: F", 32 },
{ "Key: G", 33 },
{ "Key: H", 34 },
{ "Key: J", 35 },
{ "Key: K", 36 },
{ "Key: L", 37 },
{ "Key: ;", 38 },
{ "Key: '", 39 },
{ "Key: Enter", 40 },
{ "Key: Left Shift", 41 },
{ "Key: Z", 42 },
{ "Key: X", 43 },
{ "Key: C", 44 },
{ "Key: V", 45 },
{ "Key: B", 46 },
{ "Key: N", 47 },
{ "Key: M", 48 },
{ "Key: ,", 49 },
{ "Key: .", 50 },
{ "Key: /", 51 },
{ "Key: Right Shift", 52 },
{ "Key: Left Control", 53 },
{ "Key: Left Windows", 54 },
{ "Key: Left Alt", 55 },
{ "Key: Space", 56 },
{ "Key: Right Alt", 57 },
{ "Key: Right Fn", 58 },
{ "Key: Menu", 59 },
{ "Key: Right Control", 60 },
};
RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* annepro2_ptr)
{
annepro2 = annepro2_ptr;
name = "Anne Pro 2";
vendor = "Obinslab";
type = DEVICE_TYPE_KEYBOARD;
description = "Obinslab Anne Pro 2 Device";
location = annepro2->GetDeviceLocation();
serial = annepro2->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_AnnePro2::~RGBController_AnnePro2()
{
delete annepro2;
}
void RGBController_AnnePro2::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 = 5;
new_zone.matrix_map->width = 14;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx].name;
new_led.value = led_names[led_idx].idx;
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_AnnePro2::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AnnePro2::DeviceUpdateLEDs()
{
const unsigned char frame_buf_length = LED_REAL_COUNT * 3;
unsigned char frame_buf[frame_buf_length];
/*---------------------------------------------------------*\
| TODO: Send packets with multiple LED frames |
\*---------------------------------------------------------*/
std::size_t led_real_idx = 0;
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
frame_buf[(led_real_idx * 3) + 0] = RGBGetRValue(colors[led_idx]);
frame_buf[(led_real_idx * 3) + 1] = RGBGetGValue(colors[led_idx]);
frame_buf[(led_real_idx * 3) + 2] = RGBGetBValue(colors[led_idx]);
if(led_idx == 40 || led_idx == 41 || led_idx == 52 || led_idx == 53 || led_idx == 60)
{
led_real_idx++;
}
else if(led_idx == 55 || led_idx == 56)
{
led_real_idx++;
led_real_idx++;
}
led_real_idx++;
}
annepro2->SendDirect(frame_buf_length, frame_buf);
}
void RGBController_AnnePro2::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AnnePro2::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AnnePro2::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AnnePro2::DeviceUpdateMode()
{
}
@@ -0,0 +1,32 @@
/*-----------------------------------------*\
| RGBController_AnnePro2.h |
| |
| Generic RGB Interface for Obins Lab |
| AnnePro2 keyboard |
| |
| Sergey Gavrilov (DrZlo13) 06/06/2021 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AnnePro2Controller.h"
class RGBController_AnnePro2 : public RGBController
{
public:
RGBController_AnnePro2(AnnePro2Controller* annepro2_ptr);
~RGBController_AnnePro2();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AnnePro2Controller* annepro2;
};
@@ -40,7 +40,12 @@ std::string AuraCoreController::GetDeviceLocation()
std::string AuraCoreController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -33,17 +33,24 @@ typedef struct
static const gpu_pci_device device_list[] =
{
{ NVIDIA_VEN, NVIDIA_GTX1060_DEV, ASUS_SUB_VEN, ASUS_GTX1060_STRIX, 0x29, "ASUS GTX 1060 Strix" },
{ NVIDIA_VEN, NVIDIA_GTX1070_DEV, ASUS_SUB_VEN, ASUS_GTX1070_STRIX, 0x29, "ASUS GTX 1070 Strix OC" },
{ NVIDIA_VEN, NVIDIA_GTX1070_DEV, ASUS_SUB_VEN, ASUS_GTX1070_STRIX_GAMING, 0x29, "ASUS GTX 1070 Strix Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1070_DEV, ASUS_SUB_VEN, ASUS_GTX1070_STRIX_OC, 0x29, "ASUS GTX 1070 Strix OC" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, ASUS_SUB_VEN, ASUS_GTX1080_STRIX, 0x29, "ASUS GTX 1080 Strix OC" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080_A8G_GAMING, 0x29, "ASUS ROG Strix GTX1080 A8G Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080_O8G_GAMING, 0x29, "ASUS ROG Strix GTX1080 O8G Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1080TI_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_GTX1080TI_GAMING, 0x29, "ASUS ROG Strix GTX1080 Ti Gaming" },
{ NVIDIA_VEN, NVIDIA_GTX1660TI_DEV, ASUS_SUB_VEN, ASUS_ROG_GTX1660TI_OC, 0x2A, "ASUS ROG GTX 1660 Ti OC 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2060_EVO_GAMING, 0x2A, "ASUS ROG STRIX RTX 2060 EVO Gaming 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2060S_A8G_EVO_GAMING, 0x2A, "ASUS ROG STRIX RTX 2060S A8G EVO Gaming 6G"},
{ NVIDIA_VEN, NVIDIA_RTX2070_OC_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2070_A8G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2070 A8G Gaming 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2070_OC_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2070_O8G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2070 O8G Gaming 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2070S_A8G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2070S A8G Gaming 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2070S_O8G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2070S O8G Gaming 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2080_A_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2080_O8G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2080 O8G Gaming" },
{ NVIDIA_VEN, NVIDIA_RTX2080TI_DEV, ASUS_SUB_VEN, ASUS_ROG_STRIX_RTX2080TI_O11G_GAMING, 0x2A, "ASUS ROG STRIX RTX 2080 Ti O11G Gaming" },
{ AMD_GPU_VEN, AMD_VEGA10_DEV, ASUS_SUB_VEN, ASUS_VEGA64_STRIX, 0x29, "ASUS Vega 64 Strix" },
{ AMD_GPU_VEN, AMD_NAVI10_DEV, ASUS_SUB_VEN, ASUS_RX5700XT_STRIX_GAMING_OC, 0x2A, "ASUS RX 5700XT Strix Gaming OC" },
{ AMD_GPU_VEN, AMD_POLARIS_DEV, ASUS_SUB_VEN, ASUS_RX570_STRIX_O4G_GAMING_OC, 0x29, "ASUS RX 570 Strix O4G Gaming OC" },
{ AMD_GPU_VEN, AMD_POLARIS_DEV, ASUS_SUB_VEN, ASUS_RX580_STRIX_GAMING_OC, 0x29, "ASUS RX 580 Strix Gaming OC" }
};
@@ -207,7 +207,7 @@ void AuraSMBusController::SetAllColorsDirect(RGBColor* colors)
AuraRegisterWriteBlock(direct_reg, color_buf, led_count * 3);
delete color_buf;
delete[] color_buf;
}
void AuraSMBusController::SetAllColorsEffect(RGBColor* colors)
@@ -0,0 +1,133 @@
/*-----------------------------------------*\
| AsusAuraHeadsetStandController.cpp |
| |
| Driver for ASUS Aura RGB USB |
| lighting controller |
| |
| Mola19 06/04/2021 |
\*-----------------------------------------*/
#include "AsusAuraHeadsetStandController.h"
#include <cstring>
AuraHeadsetStandController::AuraHeadsetStandController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
AuraHeadsetStandController::~AuraHeadsetStandController()
{
hid_close(dev);
}
std::string AuraHeadsetStandController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AuraHeadsetStandController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void AuraHeadsetStandController::UpdateLeds
(
std::vector<RGBColor> colors
)
{
unsigned char usb_buf_0[365];
memset(usb_buf_0, 0x00, sizeof(usb_buf_0));
usb_buf_0[0x00] = 0x00;
usb_buf_0[0x01] = 0xC0;
usb_buf_0[0x02] = 0x81;
usb_buf_0[0x03] = 0x00;
usb_buf_0[0x04] = 0x00;
for(unsigned int i = 0; i < 60; i += 4)
{
usb_buf_0[5 + i] = 0x00;
usb_buf_0[6 + i] = RGBGetRValue(colors[i / 4]);
usb_buf_0[7 + i] = RGBGetGValue(colors[i / 4]);
usb_buf_0[8 + i] = RGBGetBValue(colors[i / 4]);
}
hid_write(dev, usb_buf_0, 65);
unsigned char usb_buf_1[65];
memset(usb_buf_1, 0x00, sizeof(usb_buf_1));
usb_buf_1[0x00] = 0x00;
usb_buf_1[0x01] = 0xC0;
usb_buf_1[0x02] = 0x81;
usb_buf_1[0x03] = 0x01;
usb_buf_1[0x04] = 0x00;
for(unsigned int i = 0; i < 12; i += 4)
{
usb_buf_1[5 + i] = 0x00;
usb_buf_1[6 + i] = RGBGetRValue(colors[(i / 4) + 15]);
usb_buf_1[7 + i] = RGBGetGValue(colors[(i / 4) + 15]);
usb_buf_1[8 + i] = RGBGetBValue(colors[(i / 4) + 15]);
}
hid_write(dev, usb_buf_1, 65);
}
void AuraHeadsetStandController::UpdateDevice
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char speed,
bool save
)
{
unsigned char usb_buf[65];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = 0x28;
usb_buf[0x03] = 0x00;
usb_buf[0x04] = 0x00;
usb_buf[0x05] = mode;
usb_buf[0x06] = speed;
usb_buf[0x07] = 0x04;
usb_buf[0x08] = 0x00;
usb_buf[0x09] = 0x00;
usb_buf[0x0a] = red;
usb_buf[0x0b] = grn;
usb_buf[0x0c] = blu;
hid_write(dev, usb_buf, 65);
if(save)
{
unsigned char usb_save_buf[65];
memset(usb_save_buf, 0x00, sizeof(usb_save_buf));
usb_save_buf[0x00] = 0x00;
usb_save_buf[0x01] = 0x50;
usb_save_buf[0x02] = 0x55;
hid_write(dev, usb_save_buf, 65);
}
}
@@ -0,0 +1,59 @@
/*-----------------------------------------*\
| AsusAuraHeadsetStandController.h |
| |
| Definitions and types for ASUS Aura |
| USB RGB lighting controller |
| |
| Mola19 06/04/2021 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <hidapi/hidapi.h>
#pragma once
enum
{
AURA_HEADSET_STAND_ZONE_UNDERGLOW = 0,
AURA_HEADSET_STAND_ZONE_LOGO = 1
};
enum
{
AURA_HEADSET_STAND_MODE_DIRECT = 0,
AURA_HEADSET_STAND_MODE_STATIC = 1,
AURA_HEADSET_STAND_MODE_BREATHING = 2,
AURA_HEADSET_STAND_MODE_STROBING = 3,
AURA_HEADSET_STAND_MODE_COLOR_CYCLE = 4,
AURA_HEADSET_STAND_MODE_RAINBOW = 5
};
class AuraHeadsetStandController
{
public:
AuraHeadsetStandController(hid_device* dev_handle, const char* path);
virtual ~AuraHeadsetStandController();
std::string GetDeviceLocation();
std::string GetSerialString();
void UpdateLeds
(
std::vector<RGBColor> colors
);
void UpdateDevice
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu,
unsigned char speed,
bool save
);
private:
hid_device* dev;
std::string location;
};
@@ -30,7 +30,12 @@ std::string AuraKeyboardController::GetDeviceLocation()
std::string AuraKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -30,7 +30,12 @@ std::string AuraMouseController::GetDeviceLocation()
std::string AuraMouseController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -0,0 +1,218 @@
/*-----------------------------------------*\
| AsusAuraTUFKeyboardController.cpp |
| |
| Driver for ASUS Aura RGB USB |
| lighting controller |
| |
| Mola19 03/03/2021 |
\*-----------------------------------------*/
#include "AsusAuraTUFKeyboardController.h"
#include <cstring>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
AuraTUFKeyboardController::AuraTUFKeyboardController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
AuraTUFKeyboardController::~AuraTUFKeyboardController()
{
hid_close(dev);
}
std::string AuraTUFKeyboardController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AuraTUFKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void AuraTUFKeyboardController::UpdateSingleLed
(
int led,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
/*-----------------------------------------------------*\
| Set up message packet for single LED |
\*-----------------------------------------------------*/
unsigned char usb_buf[65];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = 0x00;
usb_buf[1] = 0xc0;
usb_buf[2] = 0x81;
usb_buf[3] = 0x01;
usb_buf[4] = 0x00;
/*-----------------------------------------------------*\
| Convert LED index |
\*-----------------------------------------------------*/
usb_buf[5] = floor(led/6)*8 + led%6;
usb_buf[6] = red;
usb_buf[7] = green;
usb_buf[8] = blue;
hid_write(dev, usb_buf, 65);
}
void AuraTUFKeyboardController::UpdateLeds
(
std::vector<RGBColor> colors
)
{
/*-----------------------------------------------------*\
| Loop over every column (optimisation needed) |
\*-----------------------------------------------------*/
for(unsigned int i = 0; i < 192; i += 16)
{
unsigned char usb_buf[69];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = 0x00;
usb_buf[1] = 0xc0;
usb_buf[2] = 0x81;
usb_buf[3] = (138 - i / 16 * 12);
usb_buf[4] = 0x00;
for(unsigned int n = 0; n < 6; n++)
{
usb_buf[n * 4 + 5] = i + n;
usb_buf[n * 4 + 6] = RGBGetRValue(colors[i/16*12+n]);
usb_buf[n * 4 + 7] = RGBGetGValue(colors[i/16*12+n]);
usb_buf[n * 4 + 8] = RGBGetBValue(colors[i/16*12+n]);
}
for(unsigned int n = 6; n < 8; n++)
{
usb_buf[n * 4 + 5] = i + n;
usb_buf[n * 4 + 6] = 0;
usb_buf[n * 4 + 7] = 0;
usb_buf[n * 4 + 8] = 0;
}
if(i != 176)
{
for(unsigned int n = 8; n < 14; n++)
{
usb_buf[n * 4 + 5] = i + n;
usb_buf[n * 4 + 6] = RGBGetRValue(colors[i/16*12+n-2]);
usb_buf[n * 4 + 7] = RGBGetGValue(colors[i/16*12+n-2]);
usb_buf[n * 4 + 8] = RGBGetBValue(colors[i/16*12+n-2]);
}
for(unsigned int n = 14; n < 16; n++)
{
usb_buf[n * 4 + 5] = i + n;
usb_buf[n * 4 + 6] = 0;
usb_buf[n * 4 + 7] = 0;
usb_buf[n * 4 + 8] = 0;
}
}
hid_write(dev, usb_buf, 69);
}
}
void AuraTUFKeyboardController::UpdateDevice
(
unsigned char mode,
std::vector<RGBColor> colors,
unsigned char dir,
unsigned char color_mode,
unsigned char speed
)
{
unsigned char usb_buf[65];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = 0x2C;
usb_buf[0x03] = mode;
usb_buf[0x04] = 0x00;
usb_buf[0x05] = speed;
usb_buf[0x06] = 0x64;
usb_buf[0x07] = color_mode;
usb_buf[0x08] = dir;
usb_buf[0x09] = 0x02;
if(mode == 4 || mode == 5)
{
/*-----------------------------------------------------*\
| If mode is Rainbow or Ripple |
\*-----------------------------------------------------*/
usb_buf[0x0A] = colors.size();
/*-----------------------------------------------------*\
| Loop over every color given |
\*-----------------------------------------------------*/
for(unsigned int i = 0; i / 4 < colors.size(); i += 4)
{
if(colors[i / 4])
{
usb_buf[11 + i] = 100/(double)colors.size()*(i/4+1);
usb_buf[12 + i] = RGBGetRValue(colors[i/4]);
usb_buf[13 + i] = RGBGetGValue(colors[i/4]);
usb_buf[14 + i] = RGBGetBValue(colors[i/4]);
}
}
}
else
{
/*-----------------------------------------------------*\
| Loop over Color1, Color2 and Background if there |
\*-----------------------------------------------------*/
for(unsigned int i = 0; i / 3 != colors.size(); i += 3)
{
if(colors[i / 3])
{
usb_buf[10 + i] = RGBGetRValue(colors[i/3]);
usb_buf[11 + i] = RGBGetGValue(colors[i/3]);
usb_buf[12 + i] = RGBGetBValue(colors[i/3]);
}
}
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 65);
/*-----------------------------------------------------*\
| Set up and send packet save Packet |
\*-----------------------------------------------------*/
unsigned char usb_save_buf[65];
memset(usb_save_buf, 0x00, sizeof(usb_save_buf));
usb_save_buf[0x00] = 0x00;
usb_save_buf[0x01] = 0x50;
usb_save_buf[0x02] = 0x55;
hid_write(dev, usb_save_buf, 65);
}
@@ -0,0 +1,76 @@
/*-----------------------------------------*\
| AsusAuraTUFKeyboardController.h |
| |
| Definitions and types for ASUS Aura |
| USB RGB lighting controller |
| |
| Mola19 03/03/2021 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <vector>
#include <hidapi/hidapi.h>
#pragma once
enum
{
AURA_KEYBOARD_ZONE_LOGO = 0,
AURA_KEYBOARD_ZONE_SCROLL = 1,
AURA_KEYBOARD_ZONE_UNDERGLOW = 2,
AURA_KEYBOARD_ZONE_ALL = 3,
};
enum
{
AURA_KEYBOARD_MODE_STATIC = 0,
AURA_KEYBOARD_MODE_BREATHING = 1,
AURA_KEYBOARD_MODE_COLOR_CYCLE = 2,
AURA_KEYBOARD_MODE_REACTIVE = 3,
AURA_KEYBOARD_MODE_WAVE = 4,
AURA_KEYBOARD_MODE_RIPPLE = 5,
AURA_KEYBOARD_MODE_STARRY_NIGHT = 6,
AURA_KEYBOARD_MODE_QUICKSAND = 7,
AURA_KEYBOARD_MODE_CURRENT = 8,
AURA_KEYBOARD_MODE_RAIN_DROP = 9,
AURA_KEYBOARD_MODE_DIRECT = 15,
};
class AuraTUFKeyboardController
{
public:
AuraTUFKeyboardController(hid_device* dev_handle, const char* path);
~AuraTUFKeyboardController();
std::string GetDeviceLocation();
std::string GetSerialString();
void UpdateSingleLed
(
int led,
unsigned char red,
unsigned char green,
unsigned char blue
);
void UpdateLeds
(
std::vector<RGBColor> colors
);
void UpdateDevice
(
unsigned char mode,
std::vector<RGBColor> colors,
unsigned char dir,
unsigned char color_mode,
unsigned char speed
);
private:
hid_device* dev;
std::string location;
};
@@ -42,7 +42,12 @@ std::string AuraUSBController::GetDeviceName()
std::string AuraUSBController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -1,11 +1,15 @@
#include "Detector.h"
#include "AsusAuraAddressableController.h"
#include "AsusAuraHeadsetStandController.h"
#include "AsusAuraKeyboardController.h"
#include "AsusAuraTUFKeyboardController.h"
#include "AsusAuraMainboardController.h"
#include "AsusAuraMouseController.h"
#include "RGBController.h"
#include "RGBController_AsusAuraUSB.h"
#include "RGBController_AsusAuraHeadsetStand.h"
#include "RGBController_AsusAuraKeyboard.h"
#include "RGBController_AsusAuraTUFKeyboard.h"
#include "RGBController_AsusAuraMouse.h"
#include <stdexcept>
#include <hidapi/hidapi.h>
@@ -25,10 +29,13 @@
#define AURA_ROG_STRIX_FLARE_PID 0x1875
#define AURA_ROG_GLADIUS_II_ORIGIN_PID 0x1877
#define AURA_ROG_GLADIUS_II_ORIGIN_PNK_LTD_PID 0x18CD
#define AURA_ROG_GLADIUS_II_WIRELESS_PID 0x18A0
#define AURA_ROG_STRIX_FLARE_PNK_LTD_PID 0x18CF
#define AURA_ROG_CHAKRAM_WIRELESS_PID 0x18E5
#define AURA_ROG_CHAKRAM_WIRED_1_PID 0x18E3
#define AURA_ROG_CHAKRAM_WIRED_2_PID 0x1958
#define AURA_ROG_THRONE_QI_PID 0x18C5
#define AURA_TUF_K7_GAMING_PID 0x18AA
void DetectAsusAuraUSBTerminal(hid_device_info* info, const std::string& name)
{
@@ -101,6 +108,30 @@ void DetectAsusAuraUSBMice(hid_device_info* info, const std::string& name)
}
}
void DetectAsusAuraUSBHeadsetStand(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AuraHeadsetStandController* controller = new AuraHeadsetStandController(dev, info->path);
RGBController_AuraHeadsetStand* rgb_controller = new RGBController_AuraHeadsetStand(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectAsusAuraTUFUSBKeyboard(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AuraTUFKeyboardController* controller = new AuraTUFKeyboardController(dev, info->path);
RGBController_AuraTUFKeyboard* rgb_controller = new RGBController_AuraTUFKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR ("ASUS ROG AURA Terminal", DetectAsusAuraUSBTerminal, AURA_USB_VID, AURA_TERMINAL_PID);
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_1_PID);
REGISTER_HID_DETECTOR ("ASUS Aura Addressable", DetectAsusAuraUSBAddressable, AURA_USB_VID, AURA_ADDRESSABLE_2_PID);
@@ -113,8 +144,11 @@ REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Core", DetectAsusAuraUS
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Origin", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_ORIGIN_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Origin PNK LTD", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_ORIGIN_PNK_LTD_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("ASUS ROG Gladius II Wireless", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_GLADIUS_II_WIRELESS_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("ASUS ROG Chakram (Wireless)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRELESS_PID, 0, 0xFF01);
REGISTER_HID_DETECTOR_IP("Asus ROG Chakram (Wired)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRED_1_PID, 0, 0xFF01);
REGISTER_HID_DETECTOR_IP("Asus ROG Chakram (Wired)", DetectAsusAuraUSBMice, AURA_USB_VID, AURA_ROG_CHAKRAM_WIRED_2_PID, 0, 0xFF01);
REGISTER_HID_DETECTOR_IP("ASUS ROG Strix Flare", DetectAsusAuraUSBKeyboards, AURA_USB_VID, AURA_ROG_STRIX_FLARE_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("ASUS ROG Strix Flare PNK LTD", DetectAsusAuraUSBKeyboards, AURA_USB_VID, AURA_ROG_STRIX_FLARE_PNK_LTD_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("ASUS ROG Strix Flare PNK LTD", DetectAsusAuraUSBKeyboards, AURA_USB_VID, AURA_ROG_STRIX_FLARE_PNK_LTD_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_I ("ASUS ROG Throne QI", DetectAsusAuraUSBHeadsetStand, AURA_USB_VID, AURA_ROG_THRONE_QI_PID, 0);
REGISTER_HID_DETECTOR_I ("ASUS TUF Gaming K7", DetectAsusAuraTUFUSBKeyboard, AURA_USB_VID, AURA_TUF_K7_GAMING_PID, 1);
@@ -0,0 +1,182 @@
/*-----------------------------------------*\
| RGBController_AsusAuraHeadsetStand.cpp |
| |
| Generic RGB Interface for Asus Aura |
| USB controller driver |
| |
| Mola19 06/04/2021 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraHeadsetStand.h"
RGBController_AuraHeadsetStand::RGBController_AuraHeadsetStand(AuraHeadsetStandController* aura_ptr)
{
aura = aura_ptr;
name = "ASUS Aura Headset Stand";
vendor = "ASUS";
type = DEVICE_TYPE_HEADSET_STAND;
description = "ASUS Aura Headset Stand Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_HEADSET_STAND_MODE_DIRECT;
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 = AURA_HEADSET_STAND_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(1);
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_HEADSET_STAND_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed_min = 0;
Breathing.speed_max = 255;
Breathing.speed = 127;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.colors.resize(1);
modes.push_back(Breathing);
mode Strobing;
Strobing.name = "Strobing";
Strobing.value = AURA_HEADSET_STAND_MODE_STROBING;
Strobing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Strobing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Strobing.colors_min = 1;
Strobing.colors_max = 1;
Strobing.colors.resize(1);
modes.push_back(Strobing);
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = AURA_HEADSET_STAND_MODE_COLOR_CYCLE;
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
SpectrumCycle.speed_min = 0;
SpectrumCycle.speed_max = 255;
SpectrumCycle.speed = 127;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = AURA_HEADSET_STAND_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = 0;
Rainbow.speed_max = 255;
Rainbow.speed = 127;
modes.push_back(Rainbow);
SetupZones();
}
RGBController_AuraHeadsetStand::~RGBController_AuraHeadsetStand()
{
delete aura;
}
void RGBController_AuraHeadsetStand::SetupZones()
{
zone underglow_zone;
underglow_zone.name = "Underglow";
underglow_zone.type = ZONE_TYPE_LINEAR;
underglow_zone.leds_min = 17;
underglow_zone.leds_max = 17;
underglow_zone.leds_count = 17;
underglow_zone.matrix_map = NULL;
zones.push_back(underglow_zone);
for(unsigned int i = 0; i < 17; i++)
{
led underglow_led;
underglow_led.name = "Underglow LED " + std::to_string(i);
leds.push_back(underglow_led);
}
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
led logo_led;
logo_led.name = "Logo LED";
leds.push_back(logo_led);
SetupColors();
}
void RGBController_AuraHeadsetStand::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AuraHeadsetStand::DeviceUpdateLEDs()
{
aura->UpdateLeds(std::vector<RGBColor>(colors));
}
void RGBController_AuraHeadsetStand::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraHeadsetStand::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AuraHeadsetStand::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraHeadsetStand::DeviceUpdateMode()
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
switch(modes[active_mode].value)
{
case 0:
aura->UpdateLeds(std::vector<RGBColor>(colors));
break;
case 1:
case 2:
case 3:
red = RGBGetRValue(modes[active_mode].colors[0]);
grn = RGBGetGValue(modes[active_mode].colors[0]);
blu = RGBGetBValue(modes[active_mode].colors[0]);
aura->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed, false);
break;
case 4:
case 5:
aura->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed, false);
break;
}
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_AsusAuraHeadsetStand.h |
| |
| Generic RGB Interface for Asus Aura |
| USB controller driver |
| |
| Mola19 06/04/2021 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraHeadsetStandController.h"
class RGBController_AuraHeadsetStand : public RGBController
{
public:
RGBController_AuraHeadsetStand(AuraHeadsetStandController* aura_ptr);
~RGBController_AuraHeadsetStand();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraHeadsetStandController* aura;
};
@@ -0,0 +1,470 @@
/*-----------------------------------------*\
| RGBController_AsusAuraTUFKeyboard.cpp |
| |
| Generic RGB Interface for Asus Aura |
| USB controller driver |
| |
| Mola19 03/03/2020 |
\*-----------------------------------------*/
#include "RGBController_AsusAuraTUFKeyboard.h"
#include <vector>
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][23] =
{ { 0, NA, 18, 24, 30, 36, NA, 48, 54, 60, 66, 72, 78, 84, 90, NA, 96, 102, 108, NA, NA, NA, NA },
{ 1, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 91, NA, NA, 97, 103, 109, 115, 121, 127, 133 },
{ 2, NA, 14, 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, NA, NA, 98, 104, 110, 116, 122, 128, 134 },
{ 3, NA, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 93, NA, NA, NA, NA, 117, 123, 129, NA },
{ 4, 10, 16, 22, 28, 34, 40, 46, 52, 58, 64, 70, NA, 94, NA, NA, NA, 106, NA, 118, 124, 130, 136 },
{ 5, 11, 17, NA, NA, NA, 41, NA, NA, NA, 59, 71, 77, NA, 95, NA, 101, 107, 113, 119, NA, 131, NA } };
static const char* zone_names[] =
{
"Keyboard"
};
static zone_type zone_types[] =
{
ZONE_TYPE_MATRIX,
};
static const unsigned int zone_sizes[] =
{
138
};
static const char *led_names[] =
{
"Key: Escape",
"Key: ^",
"Key: Tab",
"Key: Caps Lock",
"Key: Left Shift",
"Key: Left Control",
"Unused",
"Unused",
"Unused",
"Unused",
"Key: <",
"Key: Left Windows",
"Unused",
"Key: 1",
"Key: Q",
"Key: A",
"Key: Y",
"Key: Left Alt",
"Key: F1",
"Key: 2",
"Key: W",
"Key: S",
"Key: X",
"Unused",
"Key: F2",
"Key: 3",
"Key: E",
"Key: D",
"Key: C",
"Unused",
"Key: F3",
"Key: 4",
"Key: R",
"Key: F",
"Key: V",
"Unused",
"Key: F4",
"Key: 5",
"Key: T",
"Key: G",
"Key: B",
"Key: Space",
"Unused",
"Key: 6",
"Key: Z",
"Key: H",
"Key: N",
"Unused",
"Key: F5",
"Key: 7",
"Key: U",
"Key: J",
"Key: M",
"Unused",
"Key: F6",
"Key: 8",
"Key: I",
"Key: K",
"Key: ,",
"Key: Right Alt",
"Key: F7",
"Key: 9",
"Key: O",
"Key: L",
"Key: .",
"Unused",
"Key: F8",
"Key: 0",
"Key: P",
"Key: Ö",
"Key: -",
"Key: Right Fn",
"Key: F9",
"Key: ß",
"Key: Ü",
"Key: Ä",
"Unused",
"Key: Menu",
"Key: F10",
"Key: ´",
"Key: +",
"Key: #",
"Unused",
"Unused",
"Key: F11",
"Unused",
"Unused",
"Unused",
"Unused",
"Unused",
"Key: F12",
"Key: Backspace",
"Unused",
"Key: Enter",
"Key: Right Shift",
"Key: Right Control",
"Key: Print Screen",
"Key: Insert",
"Key: Delete",
"Unused",
"Unused",
"Key: Left Arrow",
"Key: Scroll Lock",
"Key: Home",
"Key: End",
"Unused",
"Key: Up Arrow",
"Key: Down Arrow",
"Key: Pause/Break",
"Key: Page Up",
"Key: Page Down",
"Unused",
"Unused",
"Key: Right Arrow",
"Unused",
"Key: Num Lock",
"Key: Number Pad 7",
"Key: Number Pad 4",
"Key: Number Pad 1",
"Key: Number Pad 0",
"Unused",
"Key: Number Pad /",
"Key: Number Pad 8",
"Key: Number Pad 5",
"Key: Number Pad 2",
"Unused",
"Unused",
"Key: Number Pad *",
"Key: Number Pad 9",
"Key: Number Pad 6",
"Key: Number Pad 3",
"Key: Number Pad ,",
"Unused",
"Key: Number Pad -",
"Key: Number Pad +",
"Unused",
"Key: Number Pad Enter",
"Unused",
};
RGBController_AuraTUFKeyboard::RGBController_AuraTUFKeyboard(AuraTUFKeyboardController* aura_ptr)
{
aura = aura_ptr;
name = "ASUS Aura Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Aura Keyboard Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_KEYBOARD_MODE_DIRECT;
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 = AURA_KEYBOARD_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(1);
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_KEYBOARD_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed_min = 0;
Breathing.speed_max = 15;
Breathing.speed = 8;
Breathing.colors_min = 1;
Breathing.colors_max = 2;
Breathing.colors.resize(1);
modes.push_back(Breathing);
mode Color_Cycle;
Color_Cycle.name = "Color Cycle";
Color_Cycle.value = AURA_KEYBOARD_MODE_COLOR_CYCLE;
Color_Cycle.flags = MODE_FLAG_HAS_SPEED;
Color_Cycle.color_mode = MODE_COLORS_NONE;
Color_Cycle.speed_min = 0;
Color_Cycle.speed_max = 15;
Color_Cycle.speed = 8;
modes.push_back(Color_Cycle);
mode Wave;
Wave.name = "Wave";
Wave.value = AURA_KEYBOARD_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_HAS_DIRECTION_HV;
Wave.color_mode = MODE_COLORS_MODE_SPECIFIC;
Wave.speed_min = 0;
Wave.speed_max = 15;
Wave.speed = 8;
Wave.direction = MODE_DIRECTION_LEFT;
Wave.colors_min = 1;
Wave.colors_max = 7;
Wave.colors.resize(7);
modes.push_back(Wave);
mode Ripple;
Ripple.name = "Ripple";
Ripple.value = AURA_KEYBOARD_MODE_RIPPLE;
Ripple.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Ripple.color_mode = MODE_COLORS_MODE_SPECIFIC;
Ripple.speed_min = 0;
Ripple.speed_max = 15;
Ripple.speed = 8;
Ripple.colors_min = 1;
Ripple.colors_max = 8;
Ripple.colors.resize(7);
modes.push_back(Ripple);
mode Reactive;
Reactive.name = "Reactive";
Reactive.value = AURA_KEYBOARD_MODE_REACTIVE;
Reactive.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
Reactive.speed_min = 0;
Reactive.speed_max = 15;
Reactive.speed = 8;
Reactive.colors_min = 1;
Reactive.colors_max = 2;
Reactive.colors.resize(1);
modes.push_back(Reactive);
mode Starry_Night;
Starry_Night.name = "Starry Night";
Starry_Night.value = AURA_KEYBOARD_MODE_STARRY_NIGHT;
Starry_Night.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Starry_Night.color_mode = MODE_COLORS_MODE_SPECIFIC;
Starry_Night.speed_min = 0;
Starry_Night.speed_max = 15;
Starry_Night.speed = 8;
Starry_Night.colors_min = 1;
Starry_Night.colors_max = 3;
Starry_Night.colors.resize(1);
modes.push_back(Starry_Night);
mode Quicksand;
Quicksand.name = "Quicksand";
Quicksand.value = AURA_KEYBOARD_MODE_QUICKSAND;
Quicksand.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD;
Quicksand.color_mode = MODE_COLORS_MODE_SPECIFIC;
Quicksand.direction = MODE_DIRECTION_DOWN;
Quicksand.speed_min = 0;
Quicksand.speed_max = 15;
Quicksand.speed = 8;
Quicksand.colors_min = 6;
Quicksand.colors_max = 6;
Quicksand.colors.resize(6);
modes.push_back(Quicksand);
mode Current;
Current.name = "Current";
Current.value = AURA_KEYBOARD_MODE_CURRENT;
Current.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Current.color_mode = MODE_COLORS_MODE_SPECIFIC;
Current.speed_min = 0;
Current.speed_max = 15;
Current.speed = 8;
Current.colors_min = 1;
Current.colors_max = 3;
Current.colors.resize(1);
modes.push_back(Current);
mode Rain_Drop;
Rain_Drop.name = "Rain Drop";
Rain_Drop.value = AURA_KEYBOARD_MODE_RAIN_DROP;
Rain_Drop.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
Rain_Drop.color_mode = MODE_COLORS_MODE_SPECIFIC;
Rain_Drop.speed_min = 0;
Rain_Drop.speed_max = 15;
Rain_Drop.speed = 8;
Rain_Drop.colors_min = 1;
Rain_Drop.colors_max = 3;
Rain_Drop.colors.resize(1);
modes.push_back(Rain_Drop);
SetupZones();
}
RGBController_AuraTUFKeyboard::~RGBController_AuraTUFKeyboard()
{
delete aura;
}
void RGBController_AuraTUFKeyboard::SetupZones()
{
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{
zone new_zone;
new_zone.name = zone_names[zone_idx];
new_zone.type = zone_types[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_AuraTUFKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_AuraTUFKeyboard::DeviceUpdateLEDs()
{
DeviceUpdateMode();
}
void RGBController_AuraTUFKeyboard::UpdateZoneLEDs(int /*zone*/)
{
aura->UpdateLeds(colors);
}
void RGBController_AuraTUFKeyboard::UpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char green = RGBGetGValue(colors[led]);
unsigned char blue = RGBGetBValue(colors[led]);
aura->UpdateSingleLed(led, red, green, blue);
}
void RGBController_AuraTUFKeyboard::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraTUFKeyboard::DeviceUpdateMode()
{
unsigned char color_mode;
std::vector<RGBColor> mode_colors;
if(modes[active_mode].value == AURA_KEYBOARD_MODE_DIRECT)
{
aura->UpdateLeds(colors);
}
else
{
bool mode_with_double = (modes[active_mode].value == 1 || modes[active_mode].value == 3 || modes[active_mode].value == 6 || modes[active_mode].value == 8 || modes[active_mode].value == 9);
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC && mode_with_double && modes[active_mode].colors.size() > 1)
{
if(modes[active_mode].colors[1] == 000)
{
color_mode = 0;
}
else
{
color_mode = 16;
}
}
else
{
color_mode = modes[active_mode].color_mode == MODE_COLORS_RANDOM ? 1 : 0;
}
int direction = 0;
switch (modes[active_mode].direction)
{
case MODE_DIRECTION_LEFT:
direction = 0;
break;
case MODE_DIRECTION_RIGHT:
direction = 4;
break;
case MODE_DIRECTION_UP:
direction = 6;
break;
case MODE_DIRECTION_DOWN:
direction = 2;
break;
case MODE_DIRECTION_HORIZONTAL:
direction = 8;
break;
case MODE_DIRECTION_VERTICAL:
direction = 1;
break;
}
mode_colors = modes[active_mode].color_mode == MODE_COLORS_PER_LED ? std::vector<RGBColor>(colors) : std::vector<RGBColor>(modes[active_mode].colors);
aura->UpdateDevice(modes[active_mode].value, mode_colors, direction, color_mode, (15 - modes[active_mode].speed));
}
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_AsusAuraTUFKeyboard.h |
| |
| Generic RGB Interface for Asus Aura |
| USB controller driver |
| |
| Mola19 03/03/2021 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusAuraTUFKeyboardController.h"
class RGBController_AuraTUFKeyboard : public RGBController
{
public:
RGBController_AuraTUFKeyboard(AuraTUFKeyboardController* aura_ptr);
~RGBController_AuraTUFKeyboard();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
AuraTUFKeyboardController* aura;
};
@@ -0,0 +1,276 @@
/*---------------------------------------------------------*\
| CorsairCommanderCoreController.cpp |
| |
| Processing Code for Corsair Commander Core |
| |
| Jeff P. |
\*---------------------------------------------------------*/
#include "CorsairCommanderCoreController.h"
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std::chrono_literals;
CorsairCommanderCoreController::CorsairCommanderCoreController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
keepalive_thread_run = 1;
controller_ready = 0;
/*-----------------------------------------------------*\
| Initialize controller |
\*-----------------------------------------------------*/
InitController();
/*-----------------------------------------------------*\
| Start keepalive thread |
\*-----------------------------------------------------*/
keepalive_thread = new std::thread(&CorsairCommanderCoreController::KeepaliveThread, this);
}
CorsairCommanderCoreController::~CorsairCommanderCoreController()
{
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
keepalive_thread_run = 0;
keepalive_thread->join();
delete keepalive_thread;
/*-----------------------------------------------------*\
| Close HID device |
\*-----------------------------------------------------*/
hid_close(dev);
}
void CorsairCommanderCoreController::InitController()
{
/*-----------------------------------------------------*\
| Packet sequence to put controller into direct mode |
\*-----------------------------------------------------*/
unsigned char buffarray[][5] =
{
{0x08, 0x01, 0x03, 0x00, 0x02},
{0x08, 0x0D, 0x00, 0x22, 0x00},
};
SendMultiPkt(buffarray, sizeof(buffarray) / sizeof(buffarray[0]), sizeof(buffarray)[0] / sizeof(buffarray[0][0]));
SetFanMode();
}
std::string CorsairCommanderCoreController::GetLocationString()
{
return("HID: " + location);
}
void CorsairCommanderCoreController::KeepaliveThread()
{
while(keepalive_thread_run.load())
{
if (controller_ready)
{
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(10))
{
SendCommit();
}
}
std::this_thread::sleep_for(1s);
}
}
void CorsairCommanderCoreController::SendCommit()
{
if(!lastcolors.empty())
{
/*-----------------------------------------------------*\
| If colors remain to be sent, send them |
\*-----------------------------------------------------*/
SetDirectColor(lastcolors, lastzones);
}
else
{
unsigned char usb_buf[1025];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Update last commit time |
\*-----------------------------------------------------*/
last_commit_time = std::chrono::steady_clock::now();
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
memset(usb_buf, 0, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
usb_buf[0] = 0x00;
usb_buf[1] = 0x08;
usb_buf[2] = 0x06;
usb_buf[4] = 0xBD;
usb_buf[5] = 0x02;
usb_buf[8] = 0x12;
hid_write(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
}
}
void CorsairCommanderCoreController::SendMultiPkt(unsigned char buffarray[][5], int r, int c)
{
/*---------------------------------------------------------*\
| Private function to send multiple packets |
\*---------------------------------------------------------*/
unsigned char* hidtemp = new unsigned char[CORSAIR_COMMANDER_CORE_PACKET_SIZE];
for(unsigned int i = 0; i < r; i++)
{
memset(hidtemp, 0, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
for(unsigned int j = 0; j < c; j++)
{
hidtemp[j+1] = buffarray[i][j];
}
hid_write(dev, hidtemp, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
hid_read(dev, hidtemp, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
}
}
void CorsairCommanderCoreController::SetDirectColor
(
std::vector<RGBColor> colors,
std::vector<zone> zones
)
{
if(controller_ready == 1 && ((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::milliseconds(33)))
{
lastcolors = colors;
lastzones = zones;
int packet_offset = CORSAIR_COMMANDER_CORE_PREAMBLE_OFFSET;
int led_idx = 0;
int channel_idx = 0;
unsigned char* usb_buf = new unsigned char[CORSAIR_COMMANDER_CORE_PACKET_SIZE];
memset(usb_buf, 0, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
/*-----------------------------------------------------*\
| Prepare color information packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x00;
usb_buf[1] = 0x08;
usb_buf[2] = 0x06;
usb_buf[4] = 0xBD;
usb_buf[5] = 0x02;
usb_buf[8] = 0x12;
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
/*-------------------------------------------------*\
| Add led colors |
\*-------------------------------------------------*/
for(unsigned int i = led_idx; i < led_idx + zones[zone_idx].leds_count; i++)
{
usb_buf[packet_offset] = RGBGetRValue(colors[i]);
usb_buf[packet_offset+1] = RGBGetGValue(colors[i]);
usb_buf[packet_offset+2] = RGBGetBValue(colors[i]);
packet_offset = packet_offset + 3;
}
led_idx = led_idx + zones[zone_idx].leds_count;
/*-------------------------------------------------*\
| Move offset for pump zone with less than 29 LEDs |
\*-------------------------------------------------*/
if(zone_idx == 0)
{
packet_offset = packet_offset + 3 * (29 - zones[zone_idx].leds_count);
}
/*-------------------------------------------------*\
| Move offset for fans with less than 34 LEDs |
\*-------------------------------------------------*/
if(zone_idx != 0)
{
packet_offset = packet_offset + 3 * (34 - zones[zone_idx].leds_count);
}
channel_idx++;
}
/*-----------------------------------------------------*\
| Sending a direct mode color packet resets the timeout |
\*-----------------------------------------------------*/
last_commit_time = std::chrono::steady_clock::now();
hid_write(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
}
}
void CorsairCommanderCoreController::SetFanMode()
{
/*--------------------------------------------------------------------------------------------------*\
| Force controller to 6 QL fan mode to expose maximum number of LEDs per rgb port (34 LEDs per port) |
\*--------------------------------------------------------------------------------------------------*/
unsigned char usb_buf[1025];
unsigned char buffarray4[][5] =
{
{0x08, 0x05, 0x01, 0x01, 0x00},
{0x08, 0x0D, 0x01, 0x1E, 0x00},
{0x08, 0x09, 0x01, 0x00, 0x00}
};
SendMultiPkt(buffarray4, sizeof(buffarray4) / sizeof(buffarray4[0]), sizeof(buffarray4)[0] / sizeof(buffarray4[0][0]));
memset(usb_buf, 0, sizeof(usb_buf));
usb_buf[0] = 0x00;
usb_buf[1] = 0x08;
usb_buf[2] = 0x06;
usb_buf[3] = 0x01;
usb_buf[4] = 0x11;
usb_buf[8] = 0x0D;
usb_buf[10] = 0x07;
usb_buf[11] = 0x01;
usb_buf[12] = 0x08;
for(unsigned int i = 13; i < 25; i = i + 2)
{
usb_buf[i] = 0x01;
usb_buf[i + 1] = 0x06;
}
hid_write(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
hid_read(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
unsigned char buffarray2[][5] =
{
{0x08, 0x05, 0x01, 0x01, 0x00},
{0x08, 0x15, 0x01, 0x00, 0x00}
};
SendMultiPkt(buffarray2, sizeof(buffarray2) / sizeof(buffarray2[0]), sizeof(buffarray2)[0] / sizeof(buffarray2[0][0]));
memset(usb_buf, 0, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
usb_buf[0] = 0x00;
usb_buf[1] = 0x08;
usb_buf[2] = 0x06;
usb_buf[4] = 0xBD;
usb_buf[5] = 0x02;
usb_buf[8] = 0x12;
hid_write(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
hid_read(dev, usb_buf, CORSAIR_COMMANDER_CORE_PACKET_SIZE);
controller_ready = 1;
}
@@ -0,0 +1,65 @@
/*---------------------------------------------------------*\
| CorsairCommanderCoreController.h |
| |
| Definitions for Corsair Commander Core |
| Based on code by: |
| Adam Honse ([email protected]), 8/17/2020 |
| |
| Jeff P. |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <chrono>
#include <hidapi/hidapi.h>
#pragma once
#define CORSAIR_COMMANDER_CORE_PACKET_SIZE 1025
#define CORSAIR_COMMANDER_CORE_PREAMBLE_OFFSET 10
#define CORSAIR_ELITE_CAPELLIX_PUMP_LED_OFFSET 87
#define CORSAIR_QL_FAN_ZONE_OFFSET 102
#define CORSAIR_COMMANDER_CORE_NUM_CHANNELS 6
enum
{
CORSAIR_COMMANDER_CORE_MODE_DIRECT = 0x00,
};
class CorsairCommanderCoreController
{
public:
CorsairCommanderCoreController(hid_device* dev_handle, const char* path);
~CorsairCommanderCoreController();
std::string GetLocationString();
void SetDirectColor
(
std::vector<RGBColor>,
std::vector<zone>
);
void KeepaliveThread();
void SetFanMode();
private:
hid_device* dev;
std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run;
std::atomic<bool> controller_ready;
std::string location;
std::vector<RGBColor> lastcolors;
std::vector<zone> lastzones;
std::chrono::time_point<std::chrono::steady_clock> last_commit_time;
void SendMultiPkt
(
unsigned char buffarray[][5],
int r,
int c
);
void SendCommit();
void InitController();
};
@@ -0,0 +1,41 @@
#include "Detector.h"
#include "CorsairCommanderCoreController.h"
#include "RGBController.h"
#include "RGBController_CorsairCommanderCore.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Corsair vendor ID |
\*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\
| Commander Core product IDs |
\*-----------------------------------------------------*/
#define CORSAIR_H150I_COMMANDER_CORE_PID 0x0C1C
/******************************************************************************************\
* *
* DetectCorsairCapellixControllers *
* *
* Tests the USB address to see if a Corsair RGB Cooler controller exists there. *
* *
\******************************************************************************************/
void DetectCorsairCapellixHIDControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
CorsairCommanderCoreController* controller = new CorsairCommanderCoreController(dev, info->path);
RGBController_CorsairCommanderCore* rgb_controller = new RGBController_CorsairCommanderCore(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_PU("Corsair Commander Core", DetectCorsairCapellixHIDControllers, CORSAIR_VID, CORSAIR_H150I_COMMANDER_CORE_PID, 0xFF42, 0x01);
@@ -0,0 +1,125 @@
/*-----------------------------------------*\
| RGBController_CorsairCapellix.cpp |
| |
| Generic RGB Interface for Corsair |
| Commander Core |
| |
| Jeff P. |
\*-----------------------------------------*/
#include "RGBController_CorsairCommanderCore.h"
RGBController_CorsairCommanderCore::RGBController_CorsairCommanderCore(CorsairCommanderCoreController* corsair_ptr)
{
corsair = corsair_ptr;
vendor = "Corsair";
description = "Corsair Commander Core";
type = DEVICE_TYPE_COOLER;
location = corsair->GetLocationString();
SetupZones();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
}
RGBController_CorsairCommanderCore::~RGBController_CorsairCommanderCore()
{
delete corsair;
}
void RGBController_CorsairCommanderCore::SetupZones()
{
std::atomic<bool> first_run;
first_run = 0;
if(zones.size() == 0)
{
first_run = 1;
}
zones.resize(7);
zones[0].name = "Pump";
zones[0].type = ZONE_TYPE_LINEAR;
zones[0].leds_min = 0;
zones[0].leds_max = 29;
for(unsigned int i = 1; i < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); i++)
{
zones[i].name = "RGB Port " + std::to_string(i);
zones[i].type = ZONE_TYPE_LINEAR;
zones[i].leds_min = 0;
zones[i].leds_max = 34;
if(first_run)
{
zones[i].leds_count = 0;
}
}
leds.clear();
colors.clear();
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
leds.push_back(new_led);
}
}
SetupColors();
}
void RGBController_CorsairCommanderCore::ResizeZone(int zone, int new_size)
{
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_CorsairCommanderCore::DeviceUpdateLEDs()
{
DeviceUpdateMode();
}
void RGBController_CorsairCommanderCore::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_CorsairCommanderCore::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_CorsairCommanderCore::SetCustomMode()
{
active_mode = 0;
}
void RGBController_CorsairCommanderCore::DeviceUpdateMode()
{
switch(modes[active_mode].value)
{
case CORSAIR_COMMANDER_CORE_MODE_DIRECT:
corsair->SetDirectColor(colors, zones);
break;
}
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_CorsairCapellix.h |
| |
| Generic RGB Interface for Corsair |
| Commander Core |
| |
| Jeff P. |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairCommanderCoreController.h"
class RGBController_CorsairCommanderCore : public RGBController
{
public:
RGBController_CorsairCommanderCore(CorsairCommanderCoreController* corsair_ptr);
~RGBController_CorsairCommanderCore();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
CorsairCommanderCoreController* corsair;
std::vector<int> fanleds{0};
};
@@ -64,7 +64,12 @@ std::string CorsairLightingNodeController::GetLocationString()
std::string CorsairLightingNodeController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -59,18 +59,18 @@ CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle,
ReadFirmwareInfo();
/*-----------------------------------------------------*\
| K95 Platinum requires additional steps |
| K55 and K95 Platinum require additional steps |
\*-----------------------------------------------------*/
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
if (logical_layout == CORSAIR_TYPE_K55 || logical_layout == CORSAIR_TYPE_K95_PLAT)
{
SpecialFunctionControl();
}
LightingControl();
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
if (logical_layout == CORSAIR_TYPE_K55 || logical_layout == CORSAIR_TYPE_K95_PLAT)
{
SetupK95LightingControl();
SetupK55AndK95LightingControl();
}
}
@@ -112,7 +112,12 @@ std::string CorsairPeripheralController::GetName()
std::string CorsairPeripheralController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -232,7 +237,6 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
SubmitKeyboardFullColors(3, 3, 2);
}
void CorsairPeripheralController::SetLEDsMouse(std::vector<RGBColor> colors)
{
SubmitMouseColors(colors.size(), &colors[0]);
@@ -370,7 +374,7 @@ void CorsairPeripheralController::LightingControl()
| Probably a key mapping packet? |
\*-----------------------------------------------------*/
void CorsairPeripheralController::SetupK95LightingControl()
void CorsairPeripheralController::SetupK55AndK95LightingControl()
{
char usb_buf[65];
@@ -535,7 +539,6 @@ void CorsairPeripheralController::ReadFirmwareInfo()
case 0x1B3D:
logical_layout = CORSAIR_TYPE_K55;
SpecialFunctionControl();
break;
default:
@@ -97,7 +97,7 @@ private:
int logical_layout; //Normal, K95 or K95 Platinum
void LightingControl();
void SetupK95LightingControl();
void SetupK55AndK95LightingControl();
void SpecialFunctionControl();
void ReadFirmwareInfo();
@@ -91,7 +91,7 @@ void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IP("Corsair K55 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K55_RGB_PID, 1, 0xFFC2); // Not per-key, disabled for now
REGISTER_HID_DETECTOR_IP("Corsair K55 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K55_RGB_PID, 1, 0xFFC2);
REGISTER_HID_DETECTOR_IP("Corsair K65 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_RGB_PID, 1, 0xFFC2);
REGISTER_HID_DETECTOR_IP("Corsair K65 LUX RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_LUX_RGB_PID, 1, 0xFFC2);
REGISTER_HID_DETECTOR_IP("Corsair K65 RGB RAPIDFIRE", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_K65_RGB_RAPIDFIRE_PID, 1, 0xFFC2);
@@ -51,7 +51,12 @@ std::string CorsairWirelessController::GetName()
std::string CorsairWirelessController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -38,7 +38,7 @@ std::string DasKeyboardController::GetSerialString()
int err = hid_get_serial_number_string(dev, serial_string, 128);
std::string return_string;
if(!err)
if(err == 0)
{
std::wstring return_wstring = serial_string;
return_string = std::string(return_wstring.begin(), return_wstring.end());
@@ -31,7 +31,12 @@ std::string DuckyKeyboardController::GetDeviceLocation()
std::string DuckyKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -33,7 +33,12 @@ std::string EVisionKeyboardController::GetDeviceLocation()
std::string EVisionKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -9,12 +9,15 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define EVISION_KEYBOARD_VID 0x0C45
#define WOMIER_K87_VID 0x320F
#define EVISION_KEYBOARD_USAGE_PAGE 0xFF1C
#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
#define WOMIER_K87_PID 0x502A
#define WOMIER_K66_PID 0x7698
/******************************************************************************************\
* *
@@ -44,3 +47,5 @@ REGISTER_HID_DETECTOR_IP("EVision Keyboard 0C45:5104", DetectEVisionKeyboards,
REGISTER_HID_DETECTOR_IP("EVision Keyboard 0C45:5004", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, REDRAGON_K556_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
REGISTER_HID_DETECTOR_IP("EVision Keyboard 0C45:652F", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
REGISTER_HID_DETECTOR_IP("EVision Keyboard 0C45:8520", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, EVISION_KEYBOARD_USAGE_PAGE);
REGISTER_HID_DETECTOR_IP("EVision Keyboard 320F:502A", DetectEVisionKeyboards, WOMIER_K87_VID, WOMIER_K87_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
REGISTER_HID_DETECTOR_IP("EVision Keyboard 0C45:7698", DetectEVisionKeyboards, EVISION_KEYBOARD_VID, WOMIER_K66_PID, 1, EVISION_KEYBOARD_USAGE_PAGE);
@@ -30,7 +30,12 @@ std::string ATC800Controller::GetDeviceLocation()
std::string ATC800Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -35,7 +35,7 @@ const uint8_t LED8 = 0x27;
/*-------------------------------------------------------------*\
| LED "headers" 0x20..0x27, As seen on Gigabyte X570 Elite board|
| Internal legacy shorthand naming and possibly depracated |
| Internal legacy shorthand naming and possibly deprecated |
\*-------------------------------------------------------------*/
const uint8_t HDR_BACK_IO = LED1;
const uint8_t HDR_CPU = LED2;
@@ -36,6 +36,15 @@ void RGBFusionGPUController::SetColor(unsigned char red, unsigned char green, un
bus->i2c_smbus_write_byte(dev, red);
bus->i2c_smbus_write_byte(dev, green);
bus->i2c_smbus_write_byte(dev, blue);
// Pad commands with 4 zero-bytes for NVIDIA_RTX3060_DEV
if (dev == 0x62)
{
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
}
}
void RGBFusionGPUController::SetMode(unsigned char mode, unsigned char speed)
@@ -44,4 +53,13 @@ void RGBFusionGPUController::SetMode(unsigned char mode, unsigned char speed)
bus->i2c_smbus_write_byte(dev, mode);
bus->i2c_smbus_write_byte(dev, speed);
bus->i2c_smbus_write_byte(dev, 0x63);
// Pad commands with 4 zero-bytes for NVIDIA_RTX3060_DEV
if (dev == 0x62)
{
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
bus->i2c_smbus_write_byte(dev, 0x00);
}
}
@@ -34,14 +34,16 @@ static const gpu_pci_device device_list[] =
{ NVIDIA_VEN, NVIDIA_GTX1650_DEV, GIGABYTE_SUB_VEN, GIGABYTE_GTX1650_GAMING_OC_SUB_DEV, 0x55, "Gigabyte GTX1650 Gaming OC" },
{ NVIDIA_VEN, NVIDIA_GTX1660S_DEV, GIGABYTE_SUB_VEN, GIGABYTE_GTX1660S_GAMING_OC_SUB_DEV, 0x47, "Gigabyte GTX1660 SUPER Gaming OC" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2060_GAMING_OC_SUB_DEV, 0x47, "Gigabyte RTX2060 Gaming OC" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2060S_GAMING_SUB_DEV, 0x47, "Gigabyte RTX2060 SUPER Gaming" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2060_GAMING_OC_PRO_SUB_DEV, 0x47, "Gigabyte RTX2060 Gaming OC PRO" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_OC_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2060S_GAMING_SUB_DEV, 0x47, "Gigabyte RTX2060 SUPER Gaming" },
{ NVIDIA_VEN, NVIDIA_RTX2070_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2070_GAMING_OC_SUB_DEV, 0x47, "Gigabyte RTX2070 Gaming OC 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2070_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2070_WINDFORCE_SUB_DEV, 0x47, "Gigabyte RTX2070 Windforce 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2070S_GAMING_OC_SUB_DEV, 0x47, "Gigabyte RTX2070S Gaming OC" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2070S_GAMING_OC_3X_SUB_DEV, 0x55, "Gigabyte RTX2070S Gaming OC 3X" },
{ NVIDIA_VEN, NVIDIA_RTX2080_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2080_GAMING_OC_SUB_DEV, 0x47, "Gigabyte RTX2080 Gaming OC 8G" },
{ NVIDIA_VEN, NVIDIA_RTX2080_A_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX2080_A_GAMING_OC_SUB_DEV, 0x47, "Gigabyte RTX2080 Gaming OC 8G" },
{ NVIDIA_VEN, NVIDIA_RTX3060TI_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX3060TI_EAGLE_OC_SUB_DEV, 0x63, "Gigabyte RTX3060 EAGLE OC 8G" },
{ NVIDIA_VEN, NVIDIA_RTX3060_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX3060_GAMING_OC_12GB_SUB_DEV, 0x62, "Gigabyte RTX3060 Gaming OC 12G" },
{ NVIDIA_VEN, NVIDIA_RTX3060TI_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX3060TI_EAGLE_OC_SUB_DEV, 0x63, "Gigabyte RTX3060 Ti EAGLE OC 8G" },
{ NVIDIA_VEN, NVIDIA_RTX3070_DEV, GIGABYTE_SUB_VEN, GIGABYTE_RTX3070_VISION_OC_SUB_DEV, 0x63, "Gigabyte RTX3070 Vision 8G" },
};
@@ -67,6 +69,15 @@ bool TestForGigabyteRGBFusionGPUController(i2c_smbus_interface* bus, unsigned ch
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
// NVIDIA_RTX3060_DEV requires additional bytes to initialise
if (address == 0x62)
{
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
}
pass = true;
@@ -29,7 +29,12 @@ std::string HoltekA070Controller::GetDeviceLocation()
std::string HoltekA070Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -30,7 +30,12 @@ std::string HoltekA1FAController::GetDeviceLocation()
std::string HoltekA1FAController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -35,7 +35,12 @@ std::string HyperXAlloyElite2Controller::GetDeviceLocation()
std::string HyperXAlloyElite2Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -12,7 +12,7 @@
#include <cstring>
// Skip these indices in the color output
static unsigned int skip_idx[] = { 6, 23, 29, 41, 47, 59, 70, 71, 75, 76, 87, 88, 93, 99, 100, 102, 108, 113, 114, 120, 123, 124 };
static unsigned int skip_idx[] = { 23, 29, 41, 47, 59, 70, 71, 76, 87, 88, 93, 99, 100, 102, 108, 113, 114, 120, 123, 124 };
HyperXAlloyOriginsController::HyperXAlloyOriginsController(hid_device* dev_handle, const char* path)
{
@@ -33,7 +33,12 @@ std::string HyperXAlloyOriginsController::GetDeviceLocation()
std::string HyperXAlloyOriginsController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -0,0 +1,118 @@
/*------------------------------------------*\
| HyperXAlloyOriginsCoreController.cpp |
| |
| Driver for HyperX Alloy Origins Core |
| RGB Keyboard lighting controller |
| |
| Volodymyr Nazarchuk (Vavooon) 4/28/2021 |
| mike white (kamaaina) 6/9/2021 |
\*------------------------------------------*/
#include "HyperXAlloyOriginsCoreController.h"
#include <cstring>
// Skip these indices in the color output
static unsigned int skip_idx[] = {6, 7, 14, 15, 22, 23, 30, 31, 38, 39, 44, 46, 47, 54, 55, 58, 60, 61, 62, 63, 70, 71, 78, 79, 86, 87, 94, 95, 101, 102, 103, 109, 110, 111, 118, 119};
HyperXAlloyOriginsCoreController::HyperXAlloyOriginsCoreController(hid_device* dev_handle, hid_device_info* dev_info)
{
dev = dev_handle;
location = dev_info->path;
/*-----------------------------------------------------*\
| Get the firmware version from the device info |
\*-----------------------------------------------------*/
char fw_version_buf[8];
memset(fw_version_buf, '\0', sizeof(fw_version_buf));
unsigned short version = dev_info->release_number;
sprintf(fw_version_buf, "%.2X.%.2X", (version & 0xFF00) >> 8, version & 0x00FF);
firmware_version = fw_version_buf;
}
HyperXAlloyOriginsCoreController::~HyperXAlloyOriginsCoreController()
{
hid_close(dev);
}
std::string HyperXAlloyOriginsCoreController::GetDeviceLocation()
{
return("HID " + location);
}
std::string HyperXAlloyOriginsCoreController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
std::string HyperXAlloyOriginsCoreController::GetFirmwareVersion()
{
return(firmware_version);
}
void HyperXAlloyOriginsCoreController::SetLEDsDirect(std::vector<RGBColor> colors)
{
for(unsigned int skip_cnt = 0; skip_cnt < (sizeof(skip_idx) / sizeof(skip_idx[0])); skip_cnt++)
{
colors.insert(colors.begin() + skip_idx[skip_cnt], 0x00000000);
}
unsigned char buf[380];
memset(buf, 0x00, sizeof(buf));
int offset = 0;
int rowPos = 0;
for(unsigned int color_idx = 0; color_idx < colors.size(); color_idx++)
{
if (color_idx > 0 && color_idx % 16 == 0)
{
offset += 48;
rowPos = 0;
}
buf[rowPos + offset] = RGBGetGValue(colors[color_idx]);
buf[rowPos + offset + 16] = RGBGetRValue(colors[color_idx]);
buf[rowPos + offset + 32] = RGBGetBValue(colors[color_idx]);
rowPos++;
}
unsigned int sentBytes = 0;
unsigned int bytesToSend = sizeof(buf);
unsigned int payloadSize = 60;
unsigned int seq = 0;
while(sentBytes < bytesToSend)
{
if (bytesToSend - sentBytes < payloadSize)
{
payloadSize = bytesToSend - sentBytes;
}
unsigned char packet[65];
memset(packet, 0x00, sizeof(packet));
packet[1] = 0xA2;
packet[2] = seq++;
packet[4] = payloadSize;
memcpy(&packet[5], &buf[sentBytes], payloadSize);
hid_write(dev, packet, 65);
sentBytes += payloadSize;
}
}
@@ -0,0 +1,34 @@
/*------------------------------------------*\
| HyperXAlloyOriginsCoreController.h |
| |
| Definitions and types for HyperX Alloy |
| Origins Core RGB Keyboard lighting |
| controller |
| |
| Volodymyr Nazarchuk (Vavooon) 4/28/2021 |
\*------------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class HyperXAlloyOriginsCoreController
{
public:
HyperXAlloyOriginsCoreController(hid_device* dev_handle, hid_device_info* dev_info);
~HyperXAlloyOriginsCoreController();
std::string GetDeviceLocation();
std::string GetSerialString();
std::string GetFirmwareVersion();
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
hid_device* dev;
std::string location;
std::string firmware_version;
};
@@ -46,7 +46,12 @@ std::string HyperXKeyboardController::GetDeviceLocation()
std::string HyperXKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -1,10 +1,12 @@
#include "Detector.h"
#include "HyperXAlloyElite2Controller.h"
#include "HyperXAlloyOriginsController.h"
#include "HyperXAlloyOriginsCoreController.h"
#include "HyperXKeyboardController.h"
#include "RGBController.h"
#include "RGBController_HyperXAlloyElite2.h"
#include "RGBController_HyperXAlloyOrigins.h"
#include "RGBController_HyperXAlloyOriginsCore.h"
#include "RGBController_HyperXKeyboard.h"
#include <hidapi/hidapi.h>
@@ -41,6 +43,19 @@ void DetectHyperXAlloyOrigins(hid_device_info* info, const std::string& name)
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectHyperXAlloyOriginsCore(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if( dev )
{
HyperXAlloyOriginsCoreController* controller = new HyperXAlloyOriginsCoreController(dev, info);
RGBController_HyperXAlloyOriginsCore* rgb_controller = new RGBController_HyperXAlloyOriginsCore(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectHyperXAlloyElite2(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
@@ -53,15 +68,14 @@ void DetectHyperXAlloyElite2(hid_device_info* info, const std::string& name)
}
}
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("HyperX Alloy FPS RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_IP("HyperX Alloy FPS RGB", DetectHyperXKeyboards, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, 0xFF01);
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core", DetectHyperXAlloyOriginsCore, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 2);
#ifdef _WIN32
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 3);
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 3);
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite 2", DetectHyperXAlloyElite2, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_2_PID, 3, 0xFF90);
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 3);
REGISTER_HID_DETECTOR_IP("HyperX Alloy Elite 2", DetectHyperXAlloyElite2, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_2_PID, 3, 0xFF90);
#else
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins Core", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 0);
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 0);
REGISTER_HID_DETECTOR_I("HyperX Alloy Elite 2", DetectHyperXAlloyElite2, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_2_PID, 0);
REGISTER_HID_DETECTOR_I("HyperX Alloy Origins", DetectHyperXAlloyOrigins, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 0);
REGISTER_HID_DETECTOR_I("HyperX Alloy Elite 2", DetectHyperXAlloyElite2, HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_2_PID, 0);
#endif
@@ -15,12 +15,12 @@ using namespace std::chrono_literals;
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][23] =
{ { 0, NA, 11, 17, 22, 27, NA, 33, 38, 43, 49, NA, 54, 60, 64, 68, 74, 78, 83, NA, NA, NA, NA },
{ 1, 6, 12, 18, 23, 28, 34, 39, 44, 50, 55, NA, 61, 65, 69, NA, 75, 79, 84, 87, 92, 96, 101 },
{ 2, NA, 7, 13, 19, 24, NA, 29, 35, 40, 45, 51, 56, 62, 66, 70, 76, 80, 85, 88, 93, 97, 102 },
{ 3, NA, 8, 14, 20, 25, NA, 30, 36, 41, 46, 52, 57, 63, 71, NA, NA, NA, NA, 89, 94, 98, NA },
{ 4, NA, 9, 15, 21, 26, NA, 31, NA, 37, 42, 47, 53, 58, 72, NA, NA, 81, NA, 90, 95, 99, 103 },
{ 5, 10, 16, NA, NA, NA, NA, 32, NA, NA, NA, NA, 48, 59, 67, 73, 77, 82, 86, 91, NA, 100, NA } };
{ { 0, NA, 12, 18, 23, 28, NA, 34, 39, 44, 50, NA, 55, 61, 65, 70, 76, 80, 85, NA, NA, NA, NA },
{ 1, 7, 13, 19, 24, 29, 35, 40, 45, 51, 56, NA, 62, 66, 71, NA, 77, 81, 86, 89, 94, 98, 103 },
{ 2, NA, 8, 14, 20, 25, NA, 30, 36, 41, 46, 52, 57, 63, 67, 72, 78, 82, 87, 90, 95, 99, 104 },
{ 3, NA, 9, 15, 21, 26, NA, 31, 37, 42, 47, 53, 58, 64, 68, 73, NA, NA, NA, 91, 96, 100, NA },
{ 4, 6, 10, 16, 22, 27, NA, 32, NA, 38, 43, 48, 54, 59, 74, NA, NA, 83, NA, 92, 97, 101, 105 },
{ 5, 11, 17, NA, NA, NA, NA, 33, NA, NA, NA, NA, 49, 60, 69, 75, 79, 84, 88, 93, NA, 102, NA } };
static const char* zone_names[] =
{
@@ -34,7 +34,7 @@ static zone_type zone_types[] =
static const unsigned int zone_sizes[] =
{
104,
106,
};
static const char *led_names[] =
@@ -45,7 +45,7 @@ static const char *led_names[] =
"Key: Caps Lock",
"Key: Left Shift",
"Key: Left Control",
// Skip index 6
"Key: \\ (ISO)",
"Key: 1",
"Key: Q",
"Key: A",
@@ -114,7 +114,7 @@ static const char *led_names[] =
"Key: F11",
"Key: =",
"Key: ]",
// Skip index 75
"Key: #",
// Skip index 76
"Key: Menu",
"Key: F12",
@@ -164,7 +164,7 @@ static const char *led_names[] =
"Key: Number Pad +",
// Skip index 123
// Skip index 124
"Key: Number Pad Enter",
"Key: Number Pad Enter",
};
RGBController_HyperXAlloyOrigins::RGBController_HyperXAlloyOrigins(HyperXAlloyOriginsController* hyperx_ptr)
@@ -0,0 +1,283 @@
/*------------------------------------------*\
| RGBController_HyperXAlloyOriginsCore.cpp |
| |
| Generic RGB Interface for HyperX Alloy |
| Origins Core RGB Keyboard |
| |
| Volodymyr Nazarchuk (Vavooon) 4/28/2021 |
\*------------------------------------------*/
#include "RGBController_HyperXAlloyOriginsCore.h"
using namespace std::chrono_literals;
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][19] =
{
{ 0, NA, 1, 2, 3, 4, 5, 6, 7, 44, NA, 45, 46, 47, 48, NA, 49, 50, 51 },
{ 8, 9, 10, 11, 12, 13, 14, 15, 16, 52, 53, 54, 55, 56, NA, NA, 57, 58, 59 },
{ 17, NA, 18, 19, 20, 21, 22, 23, 24, 60, 61, 62, 63, 64, 65, NA, 66, 67, 68 },
{ 25, NA, 26, 27, 28, 29, 30, 31, 32, 69, 70, 71, 72, 73, NA, NA, NA, NA, NA },
{ 33, NA, 34, 35, 36, 37, 38, NA, 39, 74, 75, 76, 77, 78, NA, NA, NA, 79, NA },
{ 40, 41, 42, NA, NA, NA, 43, NA, NA, NA, NA, 80, 81, 82, 83, NA, 84, 85, 86 }
};
static const char* zone_names[] =
{
"Keyboard",
};
static zone_type zone_types[] =
{
ZONE_TYPE_MATRIX,
};
static const unsigned int zone_sizes[] =
{
87,
};
static const char *led_names[] =
{
"Key: Escape",
"Key: F1",
"Key: F2",
"Key: F3",
"Key: F4",
"Key: F5",
"Key: F6",
"Key: F7",
"Key: `",
"Key: 1",
"Key: 2",
"Key: 3",
"Key: 4",
"Key: 5",
"Key: 6",
"Key: 7",
"Key: 8",
"Key: Tab",
"Key: Q",
"Key: W",
"Key: E",
"Key: R",
"Key: T",
"Key: Y",
"Key: U",
"Key: Caps Lock",
"Key: A",
"Key: S",
"Key: D",
"Key: F",
"Key: G",
"Key: H",
"Key: J",
"Key: Left Shift",
"Key: Z",
"Key: X",
"Key: C",
"Key: V",
"Key: B",
"Key: N",
"Key: Left Control",
"Key: Left Windows",
"Key: Left Alt",
"Key: Space",
// End of first section
"Key: F8",
"Key: F9",
"Key: F10",
"Key: F11",
"Key: F12",
"Key: Print Screen",
"Key: Scroll Lock",
"Key: Pause/Break",
"Key: 9",
"Key: 0",
"Key: -",
"Key: =",
"Key: Backspace",
"Key: Insert",
"Key: Page Up",
"Key: Home",
"Key: I",
"Key: O",
"Key: P",
"Key: [",
"Key: ]",
"Key: \\ (ANSI)",
"Key: Delete",
"Key: Page Down",
"Key: End",
"Key: K",
"Key: L",
"Key: ;",
"Key: '",
"Key: Enter",
"Key: M",
"Key: ,",
"Key: .",
"Key: /",
"Key: Right Shift",
"Key: Up Arrow",
"Key: Right Alt",
"Key: Right Fn",
"Key: Menu",
"Key: Right Control",
"Key: Left Arrow",
"Key: Down Arrow",
"Key: Right Arrow"
};
RGBController_HyperXAlloyOriginsCore::RGBController_HyperXAlloyOriginsCore(HyperXAlloyOriginsCoreController* hyperx_ptr)
{
hyperx = hyperx_ptr;
name = "HyperX Alloy Origins Core Keyboard Device";
vendor = "HyperX";
type = DEVICE_TYPE_KEYBOARD;
description = "HyperX Alloy Origins Core Keyboard Device";
location = hyperx->GetDeviceLocation();
serial = hyperx->GetSerialString();
version = hyperx->GetFirmwareVersion();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
/*-----------------------------------------------------*\
| The HyperX Origins Core requires a packet within few |
| seconds of sending the lighting change in order to |
| not revert back into current profile. Start a thread |
| to continuously send color values each 10ms |
\*-----------------------------------------------------*/
keepalive_thread_run = 1;
keepalive_thread = new std::thread(&RGBController_HyperXAlloyOriginsCore::KeepaliveThread, this);
}
RGBController_HyperXAlloyOriginsCore::~RGBController_HyperXAlloyOriginsCore()
{
keepalive_thread_run = 0;
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete hyperx;
}
void RGBController_HyperXAlloyOriginsCore::SetupZones()
{
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{
zone new_zone;
new_zone.name = zone_names[zone_idx];
new_zone.type = zone_types[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 19;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_HyperXAlloyOriginsCore::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyOriginsCore::DeviceUpdateLEDs()
{
hyperx->SetLEDsDirect(colors);
}
void RGBController_HyperXAlloyOriginsCore::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOriginsCore::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOriginsCore::SetCustomMode()
{
}
void RGBController_HyperXAlloyOriginsCore::DeviceUpdateMode()
{
}
void RGBController_HyperXAlloyOriginsCore::KeepaliveThread()
{
while(keepalive_thread_run.load())
{
if(active_mode == 0)
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
DeviceUpdateLEDs();
}
}
std::this_thread::sleep_for(10ms);
}
}
@@ -0,0 +1,40 @@
/*------------------------------------------*\
| RGBController_HyperXAlloyOriginsCore.h |
| |
| Generic RGB Interface for HyperX Alloy |
| Origins Core RGB Keyboard |
| |
| Volodymyr Nazarchuk (Vavooon) 4/28/2021 |
\*------------------------------------------*/
#pragma once
#include <chrono>
#include "RGBController.h"
#include "HyperXAlloyOriginsCoreController.h"
class RGBController_HyperXAlloyOriginsCore : public RGBController
{
public:
RGBController_HyperXAlloyOriginsCore(HyperXAlloyOriginsCoreController* hyperx_ptr);
~RGBController_HyperXAlloyOriginsCore();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
void KeepaliveThread();
private:
HyperXAlloyOriginsCoreController* hyperx;
std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
};
@@ -30,7 +30,12 @@ std::string HyperXPulsefireDartController::GetDeviceLocation()
std::string HyperXPulsefireDartController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -30,7 +30,12 @@ std::string HyperXPulsefireFPSProController::GetDeviceLocation()
std::string HyperXPulsefireFPSProController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -30,7 +30,12 @@ std::string HyperXPulsefireSurgeController::GetDeviceLocation()
std::string HyperXPulsefireSurgeController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -30,7 +30,12 @@ std::string HyperXMousematController::GetDeviceLocation()
std::string HyperXMousematController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -1,24 +1,31 @@
#include "Detector.h"
#include "LogManager.h"
#include "LogitechProtocolCommon.h"
#include "LogitechG203LController.h"
#include "LogitechG213Controller.h"
#include "LogitechG560Controller.h"
#include "LogitechG933Controller.h"
#include "LogitechG810Controller.h"
#include "LogitechG910Controller.h"
#include "LogitechG815Controller.h"
#include "LogitechGLightsyncController.h"
#include "LogitechLightspeedController.h"
#include "LogitechX56Controller.h"
#include "RGBController.h"
#include "RGBController_LogitechG203L.h"
#include "RGBController_LogitechG213.h"
#include "RGBController_LogitechG560.h"
#include "RGBController_LogitechG933.h"
#include "RGBController_LogitechG810.h"
#include "RGBController_LogitechG910.h"
#include "RGBController_LogitechG815.h"
#include "RGBController_LogitechGLightsync.h"
#include "RGBController_LogitechGLightsync1zone.h"
#include "RGBController_LogitechLightspeed.h"
#include "RGBController_LogitechGPowerPlay.h"
#include "RGBController_LogitechX56.h"
#include <vector>
#include <hidapi/hidapi.h>
#include <LogManager.h>
/*-----------------------------------------------------*\
| Logitech vendor ID |
@@ -44,27 +51,20 @@
| Mouse product IDs |
\*-----------------------------------------------------*/
#define LOGITECH_G203_PID 0xC084
#define LOGITECH_G203L_PID 0xC092
#define LOGITECH_G203_LIGHTSYNC_PID 0xC092
#define LOGITECH_G303_PID 0xC080
#define LOGITECH_G403_PID 0xC083
#define LOGITECH_G403H_PID 0xC08F
#define LOGITECH_G403_WIRELESS_PID 0xC082
#define LOGITECH_G403_WIRELESS_VIRTUAL_PID 0x405D
#define LOGITECH_G502_PS_PID 0xC332
#define LOGITECH_G502H_PID 0xC08B
#define LOGITECH_G502_WIRELESS_PID 0xC08D
#define LOGITECH_G502_WIRELESS_VIRTUAL_PID 0x407F
#define LOGITECH_G703_WIRELESS_PID 0xC087
#define LOGITECH_G703_WIRELESS_VIRTUAL_PID 0x4070
#define LOGITECH_G900_WIRELESS_PID 0xC081
#define LOGITECH_G900_WIRELESS_VIRTUAL_PID 0x4053
#define LOGITECH_G903_WIRELESS_PID 0xC086
#define LOGITECH_G903_WIRELESS_VIRTUAL_PID 0x4067
#define LOGITECH_G_LIGHTSPEED_WIRELESS_PID 0xC539
#define LOGITECH_GPRO_WIRED_PID 0xC085
#define LOGITECH_GPRO_HERO_WIRED_PID 0xC08C
#define LOGITECH_GPRO_WIRELESS_PID 0xC088
#define LOGITECH_GPRO_WIRELESS_VIRTUAL_PID 0x4079
#define LOGITECH_G403_HERO_PID 0xC08F
#define LOGITECH_G403_LIGHTSPEED_PID 0xC082
#define LOGITECH_G502_PROTEUS_SPECTRUM_PID 0xC332
#define LOGITECH_G502_HERO_PID 0xC08B
#define LOGITECH_G502_LIGHTSPEED_PID 0xC08D
#define LOGITECH_G703_LIGHTSPEED_PID 0xC087
#define LOGITECH_G900_LIGHTSPEED_PID 0xC081
#define LOGITECH_G903_LIGHTSPEED_PID 0xC086
#define LOGITECH_G_PRO_PID 0xC085
#define LOGITECH_G_PRO_HERO_PID 0xC08C
#define LOGITECH_G_PRO_WIRELESS_PID 0xC088
/*-----------------------------------------------------*\
| Mousemat product IDs |
@@ -76,6 +76,36 @@
\*-----------------------------------------------------*/
#define LOGITECH_G560_PID 0x0A78
/*-----------------------------------------------------*\
| Headset product IDs |
\*-----------------------------------------------------*/
#define LOGITECH_G933_PID 0x0A5B
/*-----------------------------------------------------*\
| Unifying Device IDs (Including Lightspeed receivers) |
| NB: Not used but preserved for debugging |
\*-----------------------------------------------------*/
#define LOGITECH_G_UNIFYING_RECEIVER_1_PID 0xC52B
#define LOGITECH_G_NANO_RECEIVER_PID 0xC52F
#define LOGITECH_G_G700_RECEIVER_PID 0xC531
#define LOGITECH_G_UNIFYING_RECEIVER_2_PID 0xC532
#define LOGITECH_G_G602_RECEIVER_PID 0xC537
#define LOGITECH_G_LIGHTSPEED_RECEIVER_PID 0xC539
#define LOGITECH_G403_LIGHTSPEED_VIRTUAL_PID 0x405D
#define LOGITECH_G502_LIGHTSPEED_VIRTUAL_PID 0x407F
#define LOGITECH_G703_LIGHTSPEED_VIRTUAL_PID 0x4070
#define LOGITECH_G900_LIGHTSPEED_VIRTUAL_PID 0x4053
#define LOGITECH_G903_LIGHTSPEED_VIRTUAL_PID 0x4067
#define LOGITECH_G_PRO_WIRELESS_VIRTUAL_PID 0x4079
/*-----------------------------------------------------*\
| Joystick product IDs |
\*-----------------------------------------------------*/
#define LOGITECH_X56_VID 0x0738
#define LOGITECH_X56_JOYSTICK_PID 0x2221
#define LOGITECH_X56_THROTTLE_PID 0xA221
/*-----------------------------------------------------*\
| Logitech Keyboards |
\*-----------------------------------------------------*/
@@ -417,7 +447,6 @@ void DetectLogitechMouseG203L(hid_device_info* info, const std::string& name)
}
}
void DetectLogitechMouseG303(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A);
@@ -428,69 +457,14 @@ void DetectLogitechMouseG403(hid_device_info* info, const std::string& name)
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A);
}
void DetectLogitechMouseG403WW(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x18, 0x3A);
}
void DetectLogitechMouseG502PS(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x02, 0x3A);
}
void DetectLogitechMouseG502WW(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x07, 0x3A);
}
void DetectLogitechMouseG703WW(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0x01, 0x18, 0x3C);
}
void DetectLogitechMouseG900WW(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0x01, 0x17, 0x3A);
}
void DetectLogitechMouseG903WW(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0x01, 0x17, 0x3A);
}
void DetectLogitechMouseGPRO(hid_device_info* info, const std::string& name)
{
addLogitechLightsyncMouse2zone(info, name, 0x01, 0x07, 0x3C);
}
void DetectLogitechMouseGLS(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
/*---------------------------------------------*\
| Create mutex to prevent the two controllers |
| from interfering with each other |
\*---------------------------------------------*/
std::shared_ptr<std::mutex> logitech_mutex = std::make_shared<std::mutex>();
/*---------------------------------------------*\
| Add mouse |
\*---------------------------------------------*/
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, 0x01, 0x07, 0x3C, logitech_mutex);
RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
/*---------------------------------------------*\
| Add Powerplay mousemat |
\*---------------------------------------------*/
LogitechGLightsyncController* mousemat_controller = new LogitechGLightsyncController(dev, dev, info->path, 0x07, 0x0B, 0x3C, logitech_mutex);
RGBController_LogitechGPowerPlay* mousemat_rgb_controller = new RGBController_LogitechGPowerPlay(mousemat_controller);
mousemat_rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(mousemat_rgb_controller);
}
addLogitechLightsyncMouse1zone(info, name, 0xFF, 0x0E, 0x3C);
}
/*-----------------------------------------------------*\
@@ -512,6 +486,38 @@ void DetectLogitechG560(hid_device_info* info, const std::string& name)
}
}
void DetectLogitechG933(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
/*---------------------------------------------*\
| Add G933 Headset |
\*---------------------------------------------*/
LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path);
RGBController_LogitechG933* rgb_controller = new RGBController_LogitechG933(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectLogitechX56(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
/*---------------------------------------------*\
| Add X56 Devices |
\*---------------------------------------------*/
LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path);
RGBController_LogitechX56* rgb_controller = new RGBController_LogitechX56(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
@@ -529,27 +535,194 @@ REGISTER_HID_DETECTOR_IP ("Logitech G910 Orion Spectrum", Dete
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IP("Logitech G203 Prodigy", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_G203_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IPU("Logitech G203 Lightsync", DetectLogitechMouseG203L, LOGITECH_VID, LOGITECH_G203L_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IP("Logitech G303 Daedalus Apex", DetectLogitechMouseG303, LOGITECH_VID, LOGITECH_G303_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G403 Prodigy", DetectLogitechMouseG403, LOGITECH_VID, LOGITECH_G403_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G403 Hero", DetectLogitechMouseG403, LOGITECH_VID, LOGITECH_G403H_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G403 Prodigy Wireless (wired)", DetectLogitechMouseG403WW, LOGITECH_VID, LOGITECH_G403_WIRELESS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G502 Proteus Spectrum", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_PS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G502 Hero", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502H_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G502 LIGHTSPEED Wireless (wired)", DetectLogitechMouseG502WW, LOGITECH_VID, LOGITECH_G502_WIRELESS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G703 Wireless (wired)", DetectLogitechMouseG703WW, LOGITECH_VID, LOGITECH_G703_WIRELESS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G900 Chaos Spectrum Wireless (wired)", DetectLogitechMouseG900WW, LOGITECH_VID, LOGITECH_G900_WIRELESS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G903 LIGHTSPEED Wireless (wired)", DetectLogitechMouseG903WW, LOGITECH_VID, LOGITECH_G903_WIRELESS_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Pro Gaming Mouse", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_GPRO_WIRED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Pro (HERO) Gaming Mouse", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_GPRO_HERO_WIRED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Lightspeed Wireless Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_LIGHTSPEED_WIRELESS_PID, 2, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Pro Wireless Gaming Mouse (Wired)", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_GPRO_WIRELESS_PID, 2, 0xFF00);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IPU("Logitech G Powerplay Mousepad with Lightspeed", DetectLogitechMouseGLS, LOGITECH_VID, LOGITECH_G_LIGHTSPEED_POWERPLAY_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IP ("Logitech G203 Prodigy", DetectLogitechMouseG203, LOGITECH_VID, LOGITECH_G203_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IPU("Logitech G203 Lightsync", DetectLogitechMouseG203L, LOGITECH_VID, LOGITECH_G203_LIGHTSYNC_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IP ("Logitech G303 Daedalus Apex", DetectLogitechMouseG303, LOGITECH_VID, LOGITECH_G303_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G403 Hero", DetectLogitechMouseG403, LOGITECH_VID, LOGITECH_G403_HERO_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G502 Proteus Spectrum Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_PROTEUS_SPECTRUM_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G502 Hero Gaming Mouse", DetectLogitechMouseG502PS, LOGITECH_VID, LOGITECH_G502_HERO_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G Pro Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP ("Logitech G Pro (HERO) Gaming Mouse", DetectLogitechMouseGPRO, LOGITECH_VID, LOGITECH_G_PRO_HERO_PID, 1, 0xFF00);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Speakers |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IPU("Logitech G560 Lightsync Speaker", DetectLogitechG560, LOGITECH_VID, LOGITECH_G560_PID, 2, 0xFF43, 514);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Headsets |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IPU("Logitech G933 Lightsync Headset", DetectLogitechG933, LOGITECH_VID, LOGITECH_G933_PID, 3, 0xFF43, 514);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Joysticks |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Joystick", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_JOYSTICK_PID, 2, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech X56 Rhino Hotas Throttle", DetectLogitechX56, LOGITECH_X56_VID, LOGITECH_X56_THROTTLE_PID, 2, 0xFF00);
/*---------------------------------------------------------------------------------------------------------*\
| Windows and MacOS Lightspeed Detection |
| |
| The Lightspeed receiver is a unifying receiver that will only accept 1 connection |
| We must probe the receiver to check what is currently connected |
| |
| Hat tip - kernel driver https://github.com/torvalds/linux/blob/master/drivers/hid/hid-logitech-dj.c |
| - ltunify https://github.com/Lekensteyn/ltunify/ |
\*---------------------------------------------------------------------------------------------------------*/
#if defined(_WIN32) || defined(__APPLE__)
usages BundleLogitechUsages(hid_device_info* info)
{
usages temp_usages;
/*-----------------------------------------------------------------*\
| Need a unique ID to group usages for 1 device if multiple exist |
| Grab all usages that you can open. For normal Logitech FAP |
| devices this will be usage 1, 2 and 4 |
\*-----------------------------------------------------------------*/
if(info->usage == 1)
{
while(info)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
temp_usages.emplace((uint8_t)info->usage, dev);
}
info = info->next;
}
}
return temp_usages;
}
void CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t device_index, bool wireless, std::shared_ptr<std::mutex> mutex_ptr)
{
LogitechLightspeedController* controller = new LogitechLightspeedController(device_usages.find(2)->second, path);
controller->lightspeed = new logitech_device(path, device_usages, device_index, wireless, mutex_ptr);
RGBController_LogitechLightspeed* rgb_controller = new RGBController_LogitechLightspeed(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
void DetectLogitechLightspeedReceiver(hid_device_info* info, const std::string& /*name*/)
{
/*-----------------------------------------------------------------*\
| Need to save the PID and the device path before iterating |
| over "info" in BundleLogitechUsages() |
\*-----------------------------------------------------------------*/
char *path = info->path;
uint16_t dev_pid = info->product_id;
usages device_usages = BundleLogitechUsages(info);
wireless_map wireless_devices;
unsigned int device_count = getWirelessDevice(device_usages, dev_pid, &wireless_devices);
/*-----------------------------------------------------------------*\
| Lightspeed Receivers will only have one paired /connected device |
| Unifying Receivers can have up to 6 devices paired / connected |
\*-----------------------------------------------------------------*/
if(device_count > 0)
{
/*-------------------------------------------------*\
| Create mutex to prevent the controllers sharing a |
| receiver from interfering with each other |
\*-------------------------------------------------*/
std::shared_ptr<std::mutex> logitech_mutex = std::make_shared<std::mutex>();
for(wireless_map::iterator wd = wireless_devices.begin(); wd != wireless_devices.end(); wd++)
{
CreateLogitechLightspeedDevice(path, device_usages, wd->second, true, logitech_mutex);
}
}
}
void DetectLogitechWired(hid_device_info* info, const std::string& /*name*/)
{
/*-----------------------------------------------------------------*\
| Need to save the device path before iterating |
| over "info" in BundleLogitechUsages() |
\*-----------------------------------------------------------------*/
char *path = info->path;
usages device_usages = BundleLogitechUsages(info);
if(device_usages.size() > 0)
{
CreateLogitechLightspeedDevice(path, device_usages, 0xFF, false, nullptr);
}
}
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Lightspeed Receivers (Windows Wireless) |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IP("Logitech Lightspeed Receiver", DetectLogitechLightspeedReceiver, LOGITECH_VID, LOGITECH_G_LIGHTSPEED_RECEIVER_PID, 2, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Powerplay Mousepad", DetectLogitechLightspeedReceiver, LOGITECH_VID, LOGITECH_G_LIGHTSPEED_POWERPLAY_PID, 2, 0xFF00);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Lightspeed Wireless Devices (Windows Wired) |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IP("Logitech G403 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G403_LIGHTSPEED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G502 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G502_LIGHTSPEED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G703 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G703_LIGHTSPEED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G900 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G900_LIGHTSPEED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G903 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_PID, 1, 0xFF00);
REGISTER_HID_DETECTOR_IP("Logitech G Pro Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G_PRO_WIRELESS_PID, 2, 0xFF00);
#endif
/*---------------------------------------------------------------------------------------------------------*\
| Linux Lightspeed Detection |
| |
| The Linux kernel handles detecting wireless devices connected to a Unifying Receiver. |
\*---------------------------------------------------------------------------------------------------------*/
#ifdef __linux__
void CreateLogitechLightspeedDevice(hid_device_info* info, bool wireless)
{
usages device_usages;
hid_device* dev = hid_open_path(info->path);
if(dev)
{
device_usages.emplace((uint8_t)info->usage, dev);
}
if(device_usages.size() > 0)
{
LogitechLightspeedController* controller = new LogitechLightspeedController(device_usages.find(0)->second, info->path);
controller->lightspeed = new logitech_device(info->path, device_usages, 0xFF, wireless);
RGBController_LogitechLightspeed* rgb_controller = new RGBController_LogitechLightspeed(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectLogitechWireless(hid_device_info* info, const std::string& /*name*/)
{
CreateLogitechLightspeedDevice(info, true);
}
void DetectLogitechWired(hid_device_info* info, const std::string& /*name*/)
{
CreateLogitechLightspeedDevice(info, false);
}
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Lightspeed Devices (Linux Wireless) |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IPU("Logitech G403 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G403_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G502 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G502_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G703 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G703_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G900 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G900_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_VIRTUAL_PID, 2, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G Pro Wireless Gaming Mouse", DetectLogitechWireless, LOGITECH_VID, LOGITECH_G_PRO_WIRELESS_VIRTUAL_PID, 2, 0xFF00, 2);
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Lightspeed Wireless Devices (Linux Wired) |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
REGISTER_HID_DETECTOR_IPU("Logitech G403 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G403_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G502 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G502_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G703 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G703_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G900 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G900_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G903 Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G903_LIGHTSPEED_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Logitech G Pro Wireless Gaming Mouse (wired)", DetectLogitechWired, LOGITECH_VID, LOGITECH_G_PRO_WIRELESS_PID, 2, 0xFF00, 2);
#endif
@@ -21,7 +21,12 @@ std::string LogitechG203LController::GetDeviceLocation()
std::string LogitechG203LController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -28,7 +28,12 @@ std::string LogitechG213Controller::GetDeviceLocation()
std::string LogitechG213Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -70,3 +75,78 @@ void LogitechG213Controller::SetDirect
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
}
void LogitechG213Controller::SetMode
(
unsigned char mode,
unsigned short speed,
unsigned char direction,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
SendMode(LOGITECH_G213_ZONE_MODE_KEYBOARD, mode, speed, direction, red, green, blue);
}
void LogitechG213Controller::SendMode
(
unsigned char zone,
unsigned char mode,
unsigned short speed,
unsigned char direction,
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] = 0x0C;
usb_buf[0x03] = 0x3C;
usb_buf[0x04] = zone;
usb_buf[0x05] = mode;
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
speed = 100 * speed;
if(mode == LOGITECH_G213_MODE_BREATHING)
{
usb_buf[0x09] = speed >> 8;
usb_buf[0x0A] = speed & 0xFF;
usb_buf[0x0C] = 0x64;
}
else if(mode == LOGITECH_G213_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
usb_buf[0x0D] = 0x64;
}
else if(mode == LOGITECH_G213_MODE_WAVE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
usb_buf[0x0D] = direction & 0xFF;
usb_buf[0x0F] = speed >> 8;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
}
@@ -13,6 +13,39 @@
#pragma once
enum
{
LOGITECH_G213_ZONE_MODE_KEYBOARD = 0x00
};
enum
{
LOGITECH_G213_MODE_OFF = 0x00,
LOGITECH_G213_MODE_STATIC = 0x01,
LOGITECH_G213_MODE_BREATHING = 0x02,
LOGITECH_G213_MODE_CYCLE = 0x03,
LOGITECH_G213_MODE_WAVE = 0x04,
};
enum
{
LOGITECH_G213_WAVE_MODE_LEFT = 0x06,
LOGITECH_G213_WAVE_MODE_RIGHT = 0x01,
LOGITECH_G213_WAVE_MODE_CENTER_EDGE = 0x03,
LOGITECH_G213_WAVE_MODE_EDGE_CENTER = 0x08,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are multiplied by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G213_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G213_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G213_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechG213Controller
{
public:
@@ -30,8 +63,28 @@ public:
unsigned char b
);
void SetMode
(
unsigned char mode,
unsigned short speed,
unsigned char direction,
unsigned char red,
unsigned char green,
unsigned char blue
);
private:
hid_device* dev;
std::string location;
void SendMode
(
unsigned char zone,
unsigned char mode,
unsigned short speed,
unsigned char direction,
unsigned char red,
unsigned char green,
unsigned char blue
);
};
@@ -25,7 +25,12 @@ LogitechG810Controller::~LogitechG810Controller()
std::string LogitechG810Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -24,7 +24,12 @@ LogitechG815Controller::~LogitechG815Controller()
std::string LogitechG815Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -25,7 +25,12 @@ LogitechG910Controller::~LogitechG910Controller()
std::string LogitechG910Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
int ret = hid_get_serial_number_string(dev_pkt_0x11, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -0,0 +1,146 @@
/*-----------------------------------------*\
| LogitechG933Controller.cpp |
| |
| Driver for Logitech G933 RGB Headset |
| |
| Edbgon 06/21/2021 |
| Based on |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#include "LogitechG933Controller.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
using namespace std::chrono_literals;
LogitechG933Controller::LogitechG933Controller(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
LogitechG933Controller::~LogitechG933Controller()
{
hid_close(dev);
}
std::string LogitechG933Controller::GetDeviceLocation()
{
return("HID: " + location);
}
void LogitechG933Controller::SetDirectMode(uint8_t zone)
{
unsigned char usb_buf[LOGI_G933_LED_PACKET_SIZE];
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x04;
usb_buf[0x03] = 0xCA;
usb_buf[0x04] = zone;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
fail_retry_write(dev, usb_buf, LOGI_G933_LED_PACKET_SIZE);
}
void LogitechG933Controller::SetOffMode(uint8_t zone)
{
unsigned char usb_buf[LOGI_G933_LED_PACKET_SIZE];
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x04;
usb_buf[0x03] = 0x3F;
usb_buf[0x04] = zone;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
fail_retry_write(dev, usb_buf, LOGI_G933_LED_PACKET_SIZE);
}
void LogitechG933Controller::SendHeadsetMode
(
unsigned char zone,
unsigned char mode,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[LOGI_G933_LED_PACKET_SIZE];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x04;
/*-----------------------------------------------------*\
| This packet sets speaker into direct mode. This mode |
| is used by Lightsync Ambilight and Music Visualizer |
| realtime effect. |
\*-----------------------------------------------------*/
usb_buf[0x03] = 0x3A;
/*-----------------------------------------------------*\
| Set up mode and speed |
\*-----------------------------------------------------*/
usb_buf[0x04] = zone;
usb_buf[0x05] = mode;
/*-----------------------------------------------------*\
| And set up the colors |
\*-----------------------------------------------------*/
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
if(mode == LOGITECH_G933_MODE_DIRECT) //G933 only has Direct Mode.
{
usb_buf[0x09] = 0x02;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
fail_retry_write(dev, usb_buf, LOGI_G933_LED_PACKET_SIZE);
}
void LogitechG933Controller::fail_retry_write(hid_device *device, const unsigned char *data, size_t length)
{
unsigned char usb_buf_out[LOGI_G933_LED_PACKET_SIZE];
unsigned int write_max_retry = LOGI_G933_LED_COMMAND_SEND_RETRIES;
do
{
std::this_thread::sleep_for(1ms);
int ret = hid_write(device, data, length);
/*-------------------------------------------------------------------------------------*\
| HID write fails if a change led color and set volume command are sent at |
| the same time because RGB controller and volume control shares the same interface. |
\*-------------------------------------------------------------------------------------*/
if(ret == 20)
{
std::this_thread::sleep_for(1ms);
hid_read_timeout(dev, usb_buf_out, LOGI_G933_LED_PACKET_SIZE, 20);
break;
}
else
{
write_max_retry--;
std::this_thread::sleep_for(10ms);
}
}while (write_max_retry > 0);
}
@@ -0,0 +1,56 @@
/*-----------------------------------------*\
| LogitechG933Controller.h |
| |
| Definitions and types for |
| Logitech G933 RGB Headset |
| |
| Edbgon 06/21/2021 |
| Based on |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
#define LOGI_G933_LED_PACKET_SIZE 20
#define LOGI_G933_LED_COMMAND_SEND_RETRIES 3
enum
{
LOGITECH_G933_MODE_OFF = 0x00,
LOGITECH_G933_MODE_DIRECT = 0x01,
LOGITECH_G933_MODE_CYCLE = 0x02,
LOGITECH_G933_MODE_BREATHING = 0x03,
};
class LogitechG933Controller
{
public:
LogitechG933Controller(hid_device* dev_handle, const char* path);
~LogitechG933Controller();
std::string GetDeviceLocation();
void SetDirectMode(uint8_t zone);
void SetOffMode(uint8_t zone);
void SendHeadsetMode
(
unsigned char zone,
unsigned char mode,
unsigned char red,
unsigned char green,
unsigned char blue
);
private:
hid_device* dev;
std::string location;
void fail_retry_write(hid_device *device, const unsigned char *data, size_t length);
};
@@ -46,7 +46,12 @@ std::string LogitechGLightsyncController::GetDeviceLocation()
std::string LogitechGLightsyncController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -0,0 +1,58 @@
/*-----------------------------------------*\
| LogitechLightspeedController.cpp |
| |
| Driver for Logitech Lightspeed Wireless |
| Gaming Mice lighting controller |
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#include "LogitechLightspeedController.h"
#include <cstring>
LogitechLightspeedController::LogitechLightspeedController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
LogitechLightspeedController::~LogitechLightspeedController()
{
delete lightspeed;
}
std::string LogitechLightspeedController::GetDeviceLocation()
{
return("HID: " + location + " (Receiver) \r\nWireless Index: " + std::to_string(lightspeed->device_index));
}
std::string LogitechLightspeedController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void LogitechLightspeedController::SendMouseMode
(
unsigned char mode,
std::uint16_t speed,
unsigned char zone,
unsigned char red,
unsigned char green,
unsigned char blue
// unsigned char brightness
)
{
lightspeed->setMode(mode, speed, zone, red, green, blue, 0x64);
}
@@ -0,0 +1,63 @@
/*-----------------------------------------*\
| LogitechLightspeedController.h |
| |
| Definitions and types for Logitech G |
| Lightsync Wireless Gaming Mice lighting |
| controller |
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "LogitechProtocolCommon.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
LOGITECH_G_PRO_WIRELESS_MODE_OFF = 0x00,
LOGITECH_G_PRO_WIRELESS_MODE_STATIC = 0x01,
LOGITECH_G_PRO_WIRELESS_MODE_CYCLE = 0x02,
LOGITECH_G_PRO_WIRELESS_MODE_BREATHING = 0x03,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are multiplied by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechLightspeedController
{
public:
LogitechLightspeedController(hid_device* dev_handle, const char* path);
~LogitechLightspeedController();
logitech_device* lightspeed;
std::string GetDeviceLocation();
std::string GetSerialString();
void SendMouseMode
(
unsigned char mode,
unsigned short speed,
unsigned char zone,
unsigned char red,
unsigned char green,
unsigned char blue
// unsigned char brightness
);
private:
hid_device* dev;
std::string location;
};
@@ -0,0 +1,587 @@
/*-------------------------------------------------------------------*\
| LogitechProtocolCommon.cpp |
| |
| Common Logitech RAP and FAP protocol calls |
| |
| Chris M (Dr_No) 4th May 2021 |
| |
\*-------------------------------------------------------------------*/
#include <LogitechProtocolCommon.h>
static std::vector<uint16_t> logitech_RGB_pages =
{
0x8070,
0x8071
};
int getWirelessDevice(usages device_usages, uint16_t pid, wireless_map *wireless_devices)
{
int result;
hid_device* dev_use1;
usages::iterator find_usage = device_usages.find(1);
if (find_usage == device_usages.end())
{
LOG_NOTICE("Unable get_Wireless_Device due to missing FAP Short Message (0x10) usage");
LOG_DEBUG("Dumping device usages:");
for(usages::iterator dev = device_usages.begin(); dev != device_usages.end(); dev++)
{
LOG_DEBUG("Usage index:\t%i", dev->first);
}
}
else
{
dev_use1 = find_usage->second;
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
shortFAPrequest get_connected_devices;
get_connected_devices.init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_GET_REGISTER_REQUEST);
result = hid_write(dev_use1, get_connected_devices.buffer, get_connected_devices.size());
result = hid_read_timeout(dev_use1, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
bool wireless_notifications = response.data[1] & 1; //Connected devices is a flag
if (!wireless_notifications)
{
response.init(); //zero out the response
get_connected_devices.init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_SET_REGISTER_REQUEST);
get_connected_devices.data[1] = 1;
result = hid_write(dev_use1, get_connected_devices.buffer, get_connected_devices.size());
result = hid_read_timeout(dev_use1, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
if(get_connected_devices.feature_index == 0x8F)
{
LOG_ERROR("Logitech Protocol error: %02X %02X %02X %02X %02X %02X %02X", get_connected_devices.report_id, get_connected_devices.device_index, get_connected_devices.feature_index, get_connected_devices.feature_command, get_connected_devices.data[0], get_connected_devices.data[1], get_connected_devices.data[2]);
}
}
response.init(); //zero out the response
get_connected_devices.init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_GET_REGISTER_REQUEST);
get_connected_devices.feature_command = 0x02; //0x02 Connection State register. Essentially asking for count of paired devices
result = hid_write(dev_use1, get_connected_devices.buffer, get_connected_devices.size());
result = hid_read_timeout(dev_use1, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
unsigned int device_count = response.data[1];
LOG_NOTICE("Count of connected devices to %4X: %i", pid, device_count);
if (device_count > 0)
{
LOG_NOTICE("Faking a reconnect to get device list");
device_count++; //Add 1 to the device_count to include the receiver
response.init();
get_connected_devices.init(LOGITECH_RECEIVER_ADDRESS, LOGITECH_SET_REGISTER_REQUEST);
get_connected_devices.feature_index = LOGITECH_SET_REGISTER_REQUEST;
get_connected_devices.feature_command = 0x02; //0x02 Connection State register
get_connected_devices.data[0] = 0x02; //Writting 0x02 to the connection state register will ask the receiver to fake a reconnect of paired devices
result = hid_write(dev_use1, get_connected_devices.buffer, get_connected_devices.size());
for(size_t i = 0; i < device_count; i++)
{
blankFAPmessage devices;
devices.init();
hid_read_timeout(dev_use1, devices.buffer, devices.size(), LOGITECH_PROTOCOL_TIMEOUT);
unsigned int wireless_PID = (devices.data[2] << 8) | devices.data[1];
LOG_NOTICE("Connected Device Index %i:\tVirtualID=%04X\t\t%02X %02X %02X %02X %02X %02X %02X", i, wireless_PID, devices.buffer[0], devices.buffer[1], devices.buffer[2], devices.buffer[3], devices.buffer[4], devices.buffer[5], devices.buffer[6]);
/*-----------------------------------------------------------------*\
| We need to read the receiver from the HID device queue but |
| there is no need to add it as it's own device |
\*-----------------------------------------------------------------*/
if(devices.device_index != 0xFF)
{
wireless_devices->emplace(wireless_PID, devices.device_index);
}
}
}
else
{
LOG_WARNING("No devices were found connected to receiver!");
}
}
return wireless_devices->size();
}
logitech_device::logitech_device(char *path, usages _usages, uint8_t _device_index, bool _wireless)
{
device_index = _device_index;
location = path;
device_usages = _usages;
wireless = _wireless;
RGB_feature_index = 0;
LED_count = 0;
mutex = nullptr;
initialiseDevice();
}
logitech_device::logitech_device(char *path, usages _usages, uint8_t _device_index, bool _wireless, std::shared_ptr<std::mutex> mutex_ptr)
{
device_index = _device_index;
location = path;
device_usages = _usages;
wireless = _wireless;
RGB_feature_index = 0;
LED_count = 0;
mutex = mutex_ptr;
initialiseDevice();
}
logitech_device::~logitech_device()
{
for(usages::iterator dev = device_usages.begin(); dev != device_usages.end(); dev++)
{
hid_close(dev->second);
}
}
void logitech_device::initialiseDevice()
{
flushReadQueue();
getDeviceName(); //This will get the name of the device if it exists
for(std::vector<uint16_t>::iterator page = logitech_RGB_pages.begin(); page != logitech_RGB_pages.end(); page++)
{
int feature_index = getFeatureIndex(*page);
if(feature_index > 0)
{
feature_list.emplace(*page, feature_index);
RGB_feature_index = feature_index;
}
}
if (RGB_feature_index == 0)
{
/*-----------------------------------------------------------------*\
| If there was no RGB Effect Feature page found |
| dump the entire Feature list to log |
\*-----------------------------------------------------------------*/
getDeviceFeatureList(); //This will populate the feature list
LOG_NOTICE("Unable add this device due to missing RGB Effects Feature");
for(features::iterator feature = feature_list.begin(); feature != feature_list.end(); feature++)
{
LOG_NOTICE("Feature Index: %02X\tFeature Page: %04X", feature->second, feature->first);
}
}
else
{
getRGBconfig();
}
}
bool logitech_device::connected()
{
bool test = false;
hid_device* dev_use1 = getDevice(1);
if(dev_use1)
{
blankFAPmessage response;
response.init(); //zero out the response
shortFAPrequest get_connected_devices;
get_connected_devices.init(device_index, LOGITECH_GET_REGISTER_REQUEST);
get_connected_devices.feature_command = 0x02; //0x02 Connection State register. Essentially asking for count of paired devices
hid_write(dev_use1, get_connected_devices.buffer, get_connected_devices.size());
hid_read_timeout(dev_use1, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
test = (response.data[1] != 0x09); //ERR_RESOURCE_ERROR i.e. not currently connected
}
return test;
}
uint8_t logitech_device::getLEDinfo()
{
/*-----------------------------------------------------------------*\
| Get all info about the LEDs and Zones |
\*-----------------------------------------------------------------*/
return LED_count;
}
void logitech_device::flushReadQueue()
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
for(usages::iterator dev = device_usages.begin(); dev != device_usages.end(); dev++)
{
//Flush the buffer
int result = 1;
while( result > 0 )
{
result = hid_read_timeout(dev->second, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
}
}
hid_device* logitech_device::getDevice(uint8_t usage_index)
{
/*-----------------------------------------------------------------*\
| Check the usage map for usage_index |
| Return the associated device if found otherwise a nullptr |
\*-----------------------------------------------------------------*/
#ifdef WIN32
usages::iterator find_usage = device_usages.find(usage_index);
#else
usages::iterator find_usage = device_usages.begin();
#endif //WIN32
if (find_usage == device_usages.end())
{
LOG_NOTICE("Unable add this device due to missing FAP Message usage %i", usage_index);
return nullptr;
}
else
{
return find_usage->second;
}
}
uint8_t logitech_device::getFeatureIndex(uint16_t feature_page)
{
/*-----------------------------------------------------------------*\
| Get the feature index from the Root Index |
| Return the mapped feature_index of the given feature page |
| for this device or else return 0 |
\*-----------------------------------------------------------------*/
int result = 0;
uint8_t feature_index = 0;
hid_device* dev_use2 = getDevice(2);
if(dev_use2)
{
blankFAPmessage response;
longFAPrequest get_index;
get_index.init(device_index, LOGITECH_HIDPP_PAGE_ROOT_IDX, LOGITECH_CMD_ROOT_GET_FEATURE);
get_index.data[0] = feature_page >> 8;
get_index.data[1] = feature_page & 0xFF;
result = hid_write(dev_use2, get_index.buffer, get_index.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
feature_index = response.data[0];
}
return feature_index;
}
int logitech_device::getDeviceFeatureList()
{
int result = 0;
/*-----------------------------------------------------------------*\
| Check the usage map for usage1 (0x10 Short FAP Message) & usage2 |
| (0x11 Long FAP Message) then list all features for device |
\*-----------------------------------------------------------------*/
hid_device* dev_use1 = getDevice(1);
hid_device* dev_use2 = getDevice(2);
if(dev_use1 && dev_use2)
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
/*-----------------------------------------------------------------*\
| Query the root index for the index of the feature list |
| This is done for safety as it is generaly at feature index 0x01 |
\*-----------------------------------------------------------------*/
shortFAPrequest get_index;
get_index.init(device_index, LOGITECH_HIDPP_PAGE_ROOT_IDX);
get_index.feature_command = LOGITECH_CMD_ROOT_GET_FEATURE;
get_index.data[0] = LOGITECH_HIDPP_PAGE_FEATURE_SET >> 8; //Get feature index of the Feature Set 0x0001
get_index.data[1] = LOGITECH_HIDPP_PAGE_FEATURE_SET & 0xFF;
result = hid_write(dev_use1, get_index.buffer, get_index.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
uint8_t feature_index = response.data[0];
/*-----------------------------------------------------------------*\
| Get the count of Features |
\*-----------------------------------------------------------------*/
shortFAPrequest get_count;
get_count.init(device_index, feature_index);
get_count.feature_command = LOGITECH_CMD_FEATURE_SET_GET_COUNT;
result = hid_write(dev_use1, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
unsigned int feature_count = response.data[0];
shortFAPrequest get_features;
get_features.init(device_index, feature_index);
get_features.feature_command = LOGITECH_CMD_FEATURE_SET_GET_ID;
for(std::size_t i = 1; feature_list.size() < feature_count; i++ )
{
get_features.data[0] = i;
result = hid_write(dev_use1, get_features.buffer, get_features.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LOG_DEBUG("Reading HID++ Feature %04X at index: %02X", (response.data[0] << 8) | response.data[1], i);
feature_list.emplace((response.data[0] << 8) | response.data[1], i);
}
}
else
{
if(!dev_use1)
{
LOG_NOTICE("Unable add this device due to missing FAP Short Message (0x10) usage");
}
if(!dev_use2)
{
LOG_NOTICE("Unable add this device due to missing FAP Long Message (0x11) usage");
}
}
return feature_list.size();
}
int logitech_device::getDeviceName()
{
/*-----------------------------------------------------------------*\
| Check the usage map for usage2 (0x11 Long FAP Message) |
| Then use it to get the name for this device |
\*-----------------------------------------------------------------*/
hid_device* dev_use2 = getDevice(2);
if(dev_use2)
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
int result;
/*-----------------------------------------------------------------*\
| Check if the feature_list contains an index for the Device_name |
| feature otherwise query the root index. If not found return 0 |
\*-----------------------------------------------------------------*/
uint8_t name_feature_index;
features::iterator find_feature = feature_list.find(LOGITECH_HIDPP_PAGE_DEVICE_NAME_TYPE);
if (find_feature == feature_list.end())
{
longFAPrequest get_index;
get_index.init(device_index, LOGITECH_HIDPP_PAGE_ROOT_IDX, LOGITECH_CMD_ROOT_GET_FEATURE);
get_index.data[0] = LOGITECH_HIDPP_PAGE_DEVICE_NAME_TYPE >> 8; //Get feature index of the Feature Set 0x0001
get_index.data[1] = LOGITECH_HIDPP_PAGE_DEVICE_NAME_TYPE & 0xFF;
result = hid_write(dev_use2, get_index.buffer, get_index.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
name_feature_index = response.data[0];
}
else
{
name_feature_index = find_feature->second;
}
/*-----------------------------------------------------------------*\
| Get the device name length |
\*-----------------------------------------------------------------*/
longFAPrequest get_length;
get_length.init(device_index, name_feature_index, LOTITECH_CMD_DEVICE_NAME_TYPE_GET_COUNT);
result = hid_write(dev_use2, get_length.buffer, get_length.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
unsigned int name_length = response.data[0];
longFAPrequest get_name;
get_name.init(device_index, name_feature_index, LOGITECH_CMD_DEVICE_NAME_TYPE_GET_DEVICE_NAME);
while(device_name.length() < name_length)
{
get_name.data[0] = device_name.length(); //This sets the character index to get from the device
result = hid_write(dev_use2, get_name.buffer, get_name.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
std::string temp = (char *)&response.data;
device_name.append(temp);
}
get_name.init(device_index, name_feature_index, LOGITECH_CMD_DEVICE_NAME_TYPE_GET_TYPE);
result = hid_write(dev_use2, get_name.buffer, get_name.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
logitech_device_type = response.data[0];
}
return device_name.length();
}
void logitech_device::getRGBconfig()
{
/*-----------------------------------------------------------------*\
| Check the usage map for usage2 (0x11 Long FAP Message) |
| Then use it to get the name for this device |
\*-----------------------------------------------------------------*/
hid_device* dev_use2 = getDevice(2);
if(dev_use2)
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
int result;
longFAPrequest get_count;
get_count.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_GET_COUNT);
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
LED_count = response.data[0];
get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_INFO;
for(std::size_t i = 0; i < LED_count; i++ )
{
//TODO: Push this info into a vector for later enumeration by the RGBController
get_count.data[0] = i;
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
/*get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_STATE;
for(std::size_t i = 0; i < feature_count; i++ )
{
get_count.data[0] = i;
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
get_count.feature_command = LOGITECH_CMD_RGB_EFFECTS_GET_CONFIG;
for(std::size_t i = 0; i < feature_count; i++ )
{
get_count.data[0] = i;
result = hid_write(dev_use2, get_count.buffer, get_count.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}*/
}
}
uint8_t logitech_device::setDirectMode(bool direct)
{
int result = 0;
/*-----------------------------------------------------------------*\
| Check the usage map for usage1 (0x10 Short FAP Message) & usage2 |
| (0x11 Long FAP Message) then set the device into direct mode |
| via register 0x8A |
\*-----------------------------------------------------------------*/
hid_device* dev_use1 = getDevice(1);
hid_device* dev_use2 = getDevice(2);
if(dev_use1 && dev_use2)
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
/*-----------------------------------------------------------------*\
| Turn the direct mode on or off via the RGB_feature_index |
\*-----------------------------------------------------------------*/
shortFAPrequest set_direct;
set_direct.init(device_index, RGB_feature_index);
set_direct.feature_command = LOGITECH_CMD_RGB_EFFECTS_UNKNOWN;
set_direct.data[0] = (direct) ? 1 : 0;
set_direct.data[1] = set_direct.data[0];
/*-----------------------------------------------------*\
| Send packet |
| This code has to be protected to avoid crashes when |
| this is called at the same time to change a powerplay |
| mat and its paired wireless mouse leds. It will |
| happen when using effects engines with high framerate |
\*-----------------------------------------------------*/
if(mutex)
{
std::lock_guard<std::mutex> guard(*mutex);
result = hid_write(dev_use1, set_direct.buffer, set_direct.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
else
{
result = hid_write(dev_use1, set_direct.buffer, set_direct.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
}
return result;
}
uint8_t logitech_device::setMode(uint8_t mode, uint16_t speed, uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness)
{
int result = 0;
/*-----------------------------------------------------------------*\
| Check the usage map for usage2 (0x11 Long FAP Message) then |
| set the device mode via LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL |
\*-----------------------------------------------------------------*/
hid_device* dev_use2 = getDevice(2);
if(dev_use2)
{
/*-----------------------------------------------------------------*\
| Create a buffer for reads |
\*-----------------------------------------------------------------*/
blankFAPmessage response;
response.init();
/*-----------------------------------------------------------------*\
| Set the mode via the RGB_feature_index |
\*-----------------------------------------------------------------*/
longFAPrequest set_mode;
set_mode.init(device_index, RGB_feature_index, LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL);
set_mode.data[0] = zone;
set_mode.data[1] = mode;
set_mode.data[2] = red;
set_mode.data[3] = green;
set_mode.data[4] = blue;
speed *= 100;
if(mode == 1) //Static
{
set_mode.data[5] = zone;
}
else if(mode == 2) //Spectrum Cycle
{
set_mode.data[7] = speed >> 8;
set_mode.data[8] = speed & 0xFF;
set_mode.data[9] = brightness;
}
else if(mode == 3) //Breathing
{
set_mode.data[5] = speed >> 8;
set_mode.data[6] = speed & 0xFF;
set_mode.data[8] = brightness;
}
/*-----------------------------------------------------*\
| Send packet |
| This code has to be protected to avoid crashes when |
| this is called at the same time to change a powerplay |
| mat and its paired wireless mouse leds. It will |
| happen when using effects engines with high framerate |
\*-----------------------------------------------------*/
if(mutex)
{
std::lock_guard<std::mutex> guard(*mutex);
result = hid_write(dev_use2, set_mode.buffer, set_mode.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
else
{
result = hid_write(dev_use2, set_mode.buffer, set_mode.size());
result = hid_read_timeout(dev_use2, response.buffer, response.size(), LOGITECH_PROTOCOL_TIMEOUT);
}
}
return result;
}
@@ -0,0 +1,218 @@
/*-------------------------------------------------------------------*\
| LogitechProtocolCommon.h |
| |
| Common Logitech RAP and FAP protocol calls |
| |
| Chris M (Dr_No) 4th May 2021 |
| |
\*-------------------------------------------------------------------*/
#include <map>
#include <hidapi/hidapi.h>
#include "LogManager.h"
#pragma once
#define LOGITECH_PROTOCOL_TIMEOUT 300 //Timeout in ms
#define LOGITECH_HEADER_SIZE 3
#define LOGITECH_SHORT_MESSAGE 0x10
#define LOGITECH_SHORT_MESSAGE_LEN 7
#define LOGITECH_LONG_MESSAGE 0x11
#define LOGITECH_LONG_MESSAGE_LEN 20
#define LOGITECH_FAP_RESPONSE_LEN 64 //Define a universal response buffer and allow the hidapi to determine the size
#define LOGITECH_RECEIVER_ADDRESS 0xFF //The Unifying receiver uses RAP or register access protocol
#define LOGITECH_SET_REGISTER_REQUEST 0x80
#define LOGITECH_GET_REGISTER_REQUEST 0x81
#define LOGITECH_HIDPP_PAGE_ROOT_IDX 0x00 //Used for querying the feature index
#define LOGITECH_CMD_ROOT_GET_FEATURE 0x01
#define LOGITECH_CMD_ROOT_GET_PROTOCOL 0x11
#define LOGITECH_HIDPP_PAGE_FEATURE_SET 0x0001
#define LOGITECH_CMD_FEATURE_SET_GET_COUNT 0x01
#define LOGITECH_CMD_FEATURE_SET_GET_ID 0x11
#define LOGITECH_HIDPP_PAGE_DEVICE_NAME_TYPE 0x0005
#define LOTITECH_CMD_DEVICE_NAME_TYPE_GET_COUNT 0x01
#define LOGITECH_CMD_DEVICE_NAME_TYPE_GET_DEVICE_NAME 0x11
#define LOGITECH_CMD_DEVICE_NAME_TYPE_GET_TYPE 0x21
#define LOGITECH_HIDPP_PAGE_RGB_EFFECTS1 0x8070
#define LOGITECH_HIDPP_PAGE_RGB_EFFECTS2 0x8071
#define LOGITECH_CMD_RGB_EFFECTS_GET_COUNT 0x00
#define LOGITECH_CMD_RGB_EFFECTS_GET_INFO 0x10
#define LOGITECH_CMD_RGB_EFFECTS_GET_CONTROL 0x20
#define LOGITECH_CMD_RGB_EFFECTS_SET_CONTROL 0x30
#define LOGITECH_CMD_RGB_EFFECTS_GET_STATE 0x40
#define LOGITECH_CMD_RGB_EFFECTS_SET_STATE 0x50
#define LOGITECH_CMD_RGB_EFFECTS_GET_CONFIG 0x60
#define LOGITECH_CMD_RGB_EFFECTS_SET_CONFIG 0x70
#define LOGITECH_CMD_RGB_EFFECTS_UNKNOWN 0x80 //Used to set "direct" mode
enum LOGITECH_DEVICE_TYPE
{
LOGITECH_DEVICE_TYPE_KEYBOARD = 0,
LOGITECH_DEVICE_TYPE_REMOTECONTROL =1,
LOGITECH_DEVICE_TYPE_NUMPAD = 2,
LOGITECH_DEVICE_TYPE_MOUSE = 3,
LOGITECH_DEVICE_TYPE_TOUCHPAD = 4,
LOGITECH_DEVICE_TYPE_TRACKBALL = 5,
LOGITECH_DEVICE_TYPE_PRESENTER = 6,
LOGITECH_DEVICE_TYPE_RECEIVER = 7
};
// Used for: {GET,SET}_REGISTER_{REQ,RSP}, SET_LONG_REGISTER_RSP, GET_LONG_REGISTER_REQ
struct message_short
{
unsigned char address;
unsigned char data[3];
};
// Used for: SET_LONG_REGISTER_REQ, GET_LONG_REGISTER_RSP
struct message_long
{
unsigned char address;
unsigned char data[16];
};
// Used for: ERROR_MSG
struct message_error
{
unsigned char sub_id;
unsigned char address;
unsigned char error_code;
unsigned char padding; /* set to 0 */
};
union shortFAPrequest
{
uint8_t buffer[LOGITECH_SHORT_MESSAGE_LEN];
struct
{
uint8_t report_id;
uint8_t device_index;
uint8_t feature_index;
uint8_t feature_command;
uint8_t data[LOGITECH_SHORT_MESSAGE_LEN - 4];
};
void init(uint8_t device_index, uint8_t feature_index)
{
this->report_id = LOGITECH_SHORT_MESSAGE;
this->device_index = device_index;
this->feature_index = feature_index;
this->feature_command = 0;
for(size_t i = 0; i < sizeof(data); i++)
{
this->data[i] = 0;
}
};
int size()
{
return LOGITECH_SHORT_MESSAGE_LEN;
};
};
union longFAPrequest
{
uint8_t buffer[LOGITECH_LONG_MESSAGE_LEN];
struct
{
uint8_t report_id;
uint8_t device_index;
uint8_t feature_index;
uint8_t feature_command;
uint8_t data[LOGITECH_LONG_MESSAGE_LEN - 4];
};
void init(uint8_t device_index, uint8_t feature_index, uint8_t feature_command)
{
this->report_id = LOGITECH_LONG_MESSAGE;
this->device_index = device_index;
this->feature_index = feature_index;
this->feature_command = feature_command;
for(size_t i = 0; i < sizeof(data); i++)
{
this->data[i] = 0;
}
};
int size()
{
return LOGITECH_LONG_MESSAGE_LEN;
};
};
union blankFAPmessage
{
uint8_t buffer[LOGITECH_FAP_RESPONSE_LEN];
struct
{
uint8_t command;
uint8_t device_index;
uint8_t feature_index;
uint8_t feature_command;
uint8_t data[LOGITECH_FAP_RESPONSE_LEN - 4];
};
//blank this buffer entirely
void init()
{
for(size_t i = 0; i < sizeof(buffer); i++)
{
this->buffer[i] = 0;
}
};
int size()
{
return LOGITECH_FAP_RESPONSE_LEN;
};
};
typedef std::map<uint8_t, hid_device*> usages;
typedef std::map<uint16_t, uint8_t> features;
typedef std::map<uint16_t, uint8_t> wireless_map;
int getWirelessDevice(usages _usages, uint16_t pid, wireless_map *wireless_devices); //Helper function needed outside of class
class logitech_device
{
public:
logitech_device(char *path, usages _usages, uint8_t _device_index, bool _wireless);
logitech_device(char *path, usages _usages, uint8_t _device_index, bool _wireless, std::shared_ptr<std::mutex> mutex_ptr);
~logitech_device();
/*-----------------------------------------------------------------*\
| usages is a std::map that stores all the devices HID usages |
| This is to ensure that we can communicate to all windows usages |
\*-----------------------------------------------------------------*/
usages device_usages;
features feature_list;
uint8_t device_index;
uint8_t RGB_feature_index; //Stored for quick use
uint8_t logitech_device_type;
bool wireless;
std::string device_name;
std::string location;
std::string protocol_version;
bool connected();
void flushReadQueue();
uint8_t getFeatureIndex(uint16_t feature_page);
uint8_t getLEDinfo();
uint8_t setDirectMode(bool direct);
uint8_t setMode(uint8_t mode, uint16_t speed, uint8_t zone, uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness);
int getDeviceName();
private:
uint8_t LED_count;
std::shared_ptr<std::mutex> mutex;
hid_device* getDevice(uint8_t usage_index);
int getDeviceFeatureList();
void getRGBconfig();
void initialiseDevice();
};
@@ -0,0 +1,83 @@
/*-----------------------------------------*\
| LogitechX56Controller.cpp |
| |
| Generic RGB Interface Logitech X56 |
| Class |
| |
| Edbgon 11/06/2021 |
\*-----------------------------------------*/
#include "LogitechX56Controller.h"
#include <cstring>
LogitechX56Controller::LogitechX56Controller(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
LogitechX56Controller::~LogitechX56Controller()
{
hid_close(dev);
}
std::string LogitechX56Controller::GetDeviceLocation()
{
return("HID: " + location);
}
char* LogitechX56Controller::GetDeviceName()
{
return device_name;
}
std::string LogitechX56Controller::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void LogitechX56Controller::SetColor(RGBColor color)
{
unsigned char buf[64];
unsigned char cbuf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
memset(cbuf, 0x00, sizeof(cbuf));
/*-----------------------------------------------------*\
| Set up init packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x09;
buf[0x02] = 0x02;
buf[0x03] = 0x64;
/*-----------------------------------------------------*\
| Set up color packet |
\*-----------------------------------------------------*/
cbuf[0x00] = 0x09;
cbuf[0x02] = 0x03;
cbuf[0x03] = RGBGetRValue(color);
cbuf[0x04] = RGBGetGValue(color);
cbuf[0x05] = RGBGetBValue(color);
/*-----------------------------------------------------*\
| Send packets |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 64);
hid_send_feature_report(dev, cbuf, 64);
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| LogitechX56Controller.h |
| |
| Generic RGB Interface Logitech X56 |
| Class |
| |
| Edbgon 11/06/2021 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class LogitechX56Controller
{
public:
LogitechX56Controller(hid_device* dev_handle, const char* path);
~LogitechX56Controller();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetSerialString();
void SetColor(RGBColor colors);
private:
char device_name[32];
hid_device* dev;
std::string location;
};
@@ -46,6 +46,47 @@ RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* l
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = LOGITECH_G213_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Cycle;
Cycle.name = "Cycle";
Cycle.value = LOGITECH_G213_MODE_CYCLE;
Cycle.flags = MODE_FLAG_HAS_SPEED;
Cycle.color_mode = MODE_COLORS_NONE;
Cycle.speed_min = LOGITECH_G213_SPEED_SLOWEST;
Cycle.speed_max = LOGITECH_G213_SPEED_FASTEST;
Cycle.speed = LOGITECH_G213_SPEED_NORMAL;
modes.push_back(Cycle);
mode Wave;
Wave.name = "Wave";
Wave.value = LOGITECH_G213_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
Wave.color_mode = MODE_COLORS_NONE;
Wave.speed_min = LOGITECH_G213_SPEED_SLOWEST;
Wave.speed_max = LOGITECH_G213_SPEED_FASTEST;
Wave.speed = LOGITECH_G213_SPEED_NORMAL;
Wave.direction = MODE_DIRECTION_LEFT;
modes.push_back(Wave);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = LOGITECH_G213_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_G213_SPEED_SLOWEST;
Breathing.speed_max = LOGITECH_G213_SPEED_FASTEST;
Breathing.speed = LOGITECH_G213_SPEED_NORMAL;
modes.push_back(Breathing);
SetupZones();
}
@@ -117,4 +158,43 @@ void RGBController_LogitechG213::DeviceUpdateMode()
| 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;
unsigned char direction = 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]);
}
switch (modes[active_mode].direction)
{
case MODE_DIRECTION_LEFT:
// Right to left
direction = LOGITECH_G213_WAVE_MODE_LEFT;
break;
case MODE_DIRECTION_RIGHT:
// Left to right
direction = LOGITECH_G213_WAVE_MODE_RIGHT;
break;
case MODE_DIRECTION_UP:
// Edge to center
direction = LOGITECH_G213_WAVE_MODE_EDGE_CENTER;
break;
case MODE_DIRECTION_DOWN:
// Center to edge
direction = LOGITECH_G213_WAVE_MODE_CENTER_EDGE;
break;
}
logitechG213->SetMode(modes[active_mode].value, modes[active_mode].speed, direction, red, grn, blu);
}
@@ -21,7 +21,7 @@ static unsigned int matrix_map[7][27] =
{ NA, NA, 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, NA, 66, 67, 68, NA, 106, 107, 108, 109 },
{ 112, NA, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, NA, 69, 70, 71, NA, 79, 80, 81, 82 },
{ 113, NA, 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, NA, 72, 73, 74, NA, 91, 92, 93, 83 },
{ 114, NA, 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 36, NA, NA, NA, NA, NA, NA, 88, 89, 90, NA },
{ 114, NA, 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, NA, NA, 88, 89, 90, NA },
{ 115, NA, 99, NA, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, NA, 78, NA, NA, 85, 86, 87, 84 },
{ 116, NA, 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, NA, 76, 77, 75, NA, 94, NA, 95, NA } };
@@ -0,0 +1,125 @@
/*-----------------------------------------*\
| RGBController_LogitechG933.cpp |
| |
| Generic RGB Interface for |
| Logitech G933 RGB Headset |
| |
| Edbgon 06/21/2021 |
| Based on |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#include "RGBController_LogitechG933.h"
RGBController_LogitechG933::RGBController_LogitechG933(LogitechG933Controller* logitech_ptr)
{
logitech = logitech_ptr;
name = "Logitech G933 Lightsync Headset";
vendor = "Logitech";
type = DEVICE_TYPE_HEADSET;
description = "Logitech G933 Lightsync Headset";
location = logitech->GetDeviceLocation();
mode Off;
Off.name = "Off";
Off.value = LOGITECH_G933_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Off);
mode Direct;
Direct.name = "Direct";
Direct.value = LOGITECH_G933_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
void RGBController_LogitechG933::SetupZones()
{
zone G933_logo;
G933_logo.name = "Logo";
G933_logo.type = ZONE_TYPE_SINGLE;
G933_logo.leds_min = 1;
G933_logo.leds_max = 1;
G933_logo.leds_count = 1;
G933_logo.matrix_map = NULL;
zones.push_back(G933_logo);
led G933_logo_led;
G933_logo_led.name = "Logo";
G933_logo_led.value = 0x00;
leds.push_back(G933_logo_led);
zone G933_strip;
G933_strip.name = "LED Strip";
G933_strip.type = ZONE_TYPE_SINGLE;
G933_strip.leds_min = 1;
G933_strip.leds_max = 1;
G933_strip.leds_count = 1;
G933_strip.matrix_map = NULL;
zones.push_back(G933_strip);
led G933_strip_led;
G933_strip_led.name = "Led Strip";
G933_strip_led.value = 0x01;
leds.push_back(G933_strip_led);
SetupColors();
}
void RGBController_LogitechG933::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LogitechG933::DeviceUpdateLEDs()
{
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
unsigned char red = RGBGetRValue(colors[led_idx]);
unsigned char grn = RGBGetGValue(colors[led_idx]);
unsigned char blu = RGBGetBValue(colors[led_idx]);
logitech->SendHeadsetMode((unsigned char)leds[led_idx].value, modes[active_mode].value, red, grn, blu);
}
}
void RGBController_LogitechG933::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_LogitechG933::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_LogitechG933::SetCustomMode()
{
active_mode = 1;
}
void RGBController_LogitechG933::DeviceUpdateMode()
{
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
if(modes[active_mode].value == LOGITECH_G933_MODE_OFF)
{
logitech->SetOffMode(leds[led_idx].value);
}
else
{
/*---------------------------------------------------------*\
| Required to "reset" RGB controller and start receiving |
| color in direct mode |
\*---------------------------------------------------------*/
logitech->SetDirectMode(leds[led_idx].value);
}
}
DeviceUpdateLEDs();
}
@@ -0,0 +1,34 @@
/*-----------------------------------------*\
| RGBController_LogitechG933.h |
| |
| Generic RGB Interface for |
| G933 RGB Headset |
| |
| Edbgon 06/21/2021 |
| Based on |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechG933Controller.h"
class RGBController_LogitechG933 : public RGBController
{
public:
RGBController_LogitechG933(LogitechG933Controller* logitech_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
LogitechG933Controller* logitech;
};
@@ -0,0 +1,177 @@
/*-----------------------------------------*\
| RGBController_LogitechLightspeed.cpp |
| |
| Generic RGB Interface for |
| Logitech Lightspeed Gaming Mice |
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#include "RGBController_LogitechLightspeed.h"
RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLightspeedController* logitech_ptr)
{
logitech = logitech_ptr;
bool connected = logitech->lightspeed->connected();
mode Off;
Off.name = "Off";
Off.value = LOGITECH_G_PRO_WIRELESS_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
if(connected)
{
name = logitech->lightspeed->device_name;
vendor = "Logitech";
description = "Logitech Wireless Lightspeed Device";
location = logitech->GetDeviceLocation();
serial = logitech->GetSerialString();
switch(logitech->lightspeed->logitech_device_type)
{
case LOGITECH_DEVICE_TYPE_KEYBOARD:
type = DEVICE_TYPE_KEYBOARD;
break;
case LOGITECH_DEVICE_TYPE_MOUSE:
type = DEVICE_TYPE_MOUSE;
break;
default:
type = DEVICE_TYPE_UNKNOWN;
LOG_NOTICE("Logitech device type not known: %i", logitech->lightspeed->logitech_device_type);
}
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFF;
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_G_PRO_WIRELESS_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Cycle;
Cycle.name = "Spectrum Cycle";
Cycle.value = LOGITECH_G_PRO_WIRELESS_MODE_CYCLE;
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Cycle.color_mode = MODE_COLORS_NONE;
Cycle.speed_min = LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST;
Cycle.speed_max = LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST;
Cycle.speed = LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL;
modes.push_back(Cycle);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = LOGITECH_G_PRO_WIRELESS_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed_min = LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST;
Breathing.speed_max = LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST;
Breathing.speed = LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL;
modes.push_back(Breathing);
SetupZones();
}
else
{
name = "Idle Lightspeed Device";
vendor = "Logitech";
type = DEVICE_TYPE_UNKNOWN;
description = "Idle Logitech Wireless Lightspeed Device";
location = logitech->GetDeviceLocation();
serial = logitech->GetSerialString();
}
}
RGBController_LogitechLightspeed::~RGBController_LogitechLightspeed()
{
delete logitech;
}
void RGBController_LogitechLightspeed::SetupZones()
{
uint8_t LED_count = logitech->lightspeed->getLEDinfo();
if(LED_count > 0)
{
for(size_t i = 0; i < LED_count; i++)
{
zone Lightspeed_logo_zone;
Lightspeed_logo_zone.name = "Zone " + std::to_string(i);
Lightspeed_logo_zone.type = ZONE_TYPE_SINGLE;
Lightspeed_logo_zone.leds_min = 1;
Lightspeed_logo_zone.leds_max = 1;
Lightspeed_logo_zone.leds_count = 1;
Lightspeed_logo_zone.matrix_map = NULL;
zones.push_back(Lightspeed_logo_zone);
led Lightspeed_logo_led;
Lightspeed_logo_led.name = "LED " + std::to_string(i);
Lightspeed_logo_led.value = i;
leds.push_back(Lightspeed_logo_led);
}
}
SetupColors();
}
void RGBController_LogitechLightspeed::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LogitechLightspeed::DeviceUpdateLEDs()
{
for(std::vector<led>::iterator led_index = leds.begin(); led_index != leds.end(); led_index++)
{
UpdateZoneLEDs(led_index->value);
}
}
void RGBController_LogitechLightspeed::UpdateZoneLEDs(int zone)
{
unsigned char red = RGBGetRValue(colors[zone]);
unsigned char grn = RGBGetGValue(colors[zone]);
unsigned char blu = RGBGetBValue(colors[zone]);
/*---------------------------------------------------------*\
| Replace direct mode with static when sending to controller|
\*---------------------------------------------------------*/
unsigned char temp_mode = (modes[active_mode].value == 0xFF) ? LOGITECH_G_PRO_WIRELESS_MODE_STATIC : modes[active_mode].value;
logitech->SendMouseMode(temp_mode, modes[active_mode].speed, zone, red, grn, blu);
}
void RGBController_LogitechLightspeed::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_LogitechLightspeed::SetCustomMode()
{
if(logitech->lightspeed->connected())
{
active_mode = 1;
}
}
void RGBController_LogitechLightspeed::DeviceUpdateMode()
{
/*---------------------------------------------------------*\
| If direct mode is true, then sent the packet to put the |
| mouse in direct mode. This code will only be called when |
| we change modes as to not spam the device. |
\*---------------------------------------------------------*/
logitech->lightspeed->setDirectMode(modes[active_mode].value == 0xFF);
DeviceUpdateLEDs();
}
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_LogitechLightspeed.h |
| |
| Generic RGB Interface for |
| Logitech Lightspeed Gaming Mice |
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechLightspeedController.h"
class RGBController_LogitechLightspeed : public RGBController
{
public:
RGBController_LogitechLightspeed(LogitechLightspeedController* logitech_ptr);
~RGBController_LogitechLightspeed();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
LogitechLightspeedController* logitech;
};
@@ -0,0 +1,94 @@
/*-----------------------------------------*\
| RGBController_LogitechX56.cpp |
| |
| Generic RGB Interface Logitech X56 |
| Class |
| |
| Edbgon 11/06/2021 |
\*-----------------------------------------*/
#include "RGBController_LogitechX56.h"
RGBController_LogitechX56::RGBController_LogitechX56(LogitechX56Controller* controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "Logitech";
type = DEVICE_TYPE_GAMEPAD;
description = "Logitech X56 Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_LogitechX56::~RGBController_LogitechX56()
{
delete controller;
}
void RGBController_LogitechX56::SetupZones()
{
/*---------------------------------------------------------*\
| Each device has only one zone and LED |
\*---------------------------------------------------------*/
zone x56_zone;
x56_zone.name = "X56";
x56_zone.type = ZONE_TYPE_SINGLE;
x56_zone.leds_min = 1;
x56_zone.leds_max = 1;
x56_zone.leds_count = 1;
x56_zone.matrix_map = NULL;
zones.push_back(x56_zone);
led x56_led;
x56_led.name = "X56";
leds.push_back(x56_led);
SetupColors();
}
void RGBController_LogitechX56::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LogitechX56::DeviceUpdateLEDs()
{
controller->SetColor(colors[0]);
}
void RGBController_LogitechX56::UpdateZoneLEDs(int /*zone*/)
{
/*---------------------------------------------------------*\
| Packet expects both LEDs |
\*---------------------------------------------------------*/
DeviceUpdateLEDs();
}
void RGBController_LogitechX56::UpdateSingleLED(int /*led*/)
{
/*---------------------------------------------------------*\
| Packet expects both LEDs |
\*---------------------------------------------------------*/
DeviceUpdateLEDs();
}
void RGBController_LogitechX56::SetCustomMode()
{
active_mode = 0;
}
void RGBController_LogitechX56::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
@@ -0,0 +1,34 @@
/*-----------------------------------------*\
| RGBController_LogitechX56.h |
| |
| Generic RGB Interface Logitech X56 |
| Class |
| |
| Edbgon 11/06/2021 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechX56Controller.h"
class RGBController_LogitechX56 : public RGBController
{
public:
RGBController_LogitechX56(LogitechX56Controller* controller_ptr);
~RGBController_LogitechX56();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
LogitechX56Controller* controller;
};
@@ -35,7 +35,12 @@ std::string MSI3ZoneController::GetDeviceLocation()
std::string MSI3ZoneController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -36,8 +36,8 @@ static const msi_gpu_pci_device device_list[] =
{ NVIDIA_VEN, NVIDIA_RTX2060_TU104_DEV, MSI_SUB_VEN, MSI_RTX2060_GAMING_Z_6G_SUB_DEV, "MSI GeForce RTX 2060 Gaming Z 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, MSI_SUB_VEN, MSI_RTX2060_GAMING_Z_6G_SUB_DEV, "MSI GeForce RTX 2060 Gaming Z 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060_TU106_DEV, MSI_SUB_VEN, MSI_RTX2060_GAMING_Z_6G_SUB_DEV_2, "MSI GeForce RTX 2060 Gaming Z 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, MSI_SUB_VEN, MSI_RTX2060S_GAMING_X_SUB_DEV, "MSI GeForce RTX 2060 Super Gaming X" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, MSI_SUB_VEN, MSI_RTX2060S_ARMOR_OC_SUB_DEV, "MSI GeForce RTX 2060 Super ARMOR OC" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_OC_DEV, MSI_SUB_VEN, MSI_RTX2060S_GAMING_X_SUB_DEV, "MSI GeForce RTX 2060 Super Gaming X" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_OC_DEV, MSI_SUB_VEN, MSI_RTX2060S_ARMOR_OC_SUB_DEV, "MSI GeForce RTX 2060 Super ARMOR OC" },
{ NVIDIA_VEN, NVIDIA_RTX2070_OC_DEV, MSI_SUB_VEN, MSI_RTX2070_GAMING_Z_SUB_DEV, "MSI GeForce RTX 2070 Gaming Z" },
{ NVIDIA_VEN, NVIDIA_RTX2070_DEV, MSI_SUB_VEN, MSI_RTX2070_GAMING_SUB_DEV, "MSI GeForce RTX 2070 Gaming" },
{ NVIDIA_VEN, NVIDIA_RTX2070_DEV, MSI_SUB_VEN, MSI_RTX2070_ARMOR_SUB_DEV, "MSI GeForce RTX 2070 ARMOR" },
@@ -71,7 +71,12 @@ std::string NZXTHue2Controller::GetFirmwareVersion()
std::string NZXTHue2Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -11,6 +11,7 @@
#define NZXT_SMART_DEVICE_V2_PID 0x2006
#define NZXT_KRAKEN_X3_PID 0x2007
#define NZXT_RGB_FAN_CONTROLLER_PID 0x2009
#define NZXT_SMART_DEVICE_V2_1_PID 0x200D
static void spawn_hue(hid_device_info* info, const std::string& name, int rgb_channels, int fan_channels)
{
@@ -60,3 +61,4 @@ REGISTER_HID_DETECTOR("NZXT Hue 2 Motherboard", DetectNZXTHue2Motherboard, NZ
REGISTER_HID_DETECTOR("NZXT Smart Device V2", DetectNZXTSmartDeviceV2, NZXT_VID, NZXT_SMART_DEVICE_V2_PID);
REGISTER_HID_DETECTOR("NZXT Kraken X3", DetectNZXTKrakenX3, NZXT_VID, NZXT_KRAKEN_X3_PID);
REGISTER_HID_DETECTOR("NZXT RGB & Fan Controller", DetectNZXTFanController, NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID);
REGISTER_HID_DETECTOR("NZXT Smart Device V2", DetectNZXTSmartDeviceV2, NZXT_VID, NZXT_SMART_DEVICE_V2_1_PID);
@@ -56,7 +56,12 @@ std::string NZXTKrakenController::GetLocation()
std::string NZXTKrakenController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
@@ -37,32 +37,44 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses)
// Test for Patriot Viper RGB SPD at slot_addr
// This test was copied from Viper RGB software
// 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);
bool pass = false;
std::this_thread::sleep_for(1ms);
int res = busses[bus]->i2c_smbus_read_byte(slot_addr);
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
if (res >= 0)
{
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
pass = true;
}
if(pass)
{
busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF);
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)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x4D)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x49)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x43)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x59)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x5f)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x44))
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
{
slots_valid |= (1 << (slot_addr - 0x50));
}
}
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
std::this_thread::sleep_for(1ms);
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)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x4D)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x49)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x43)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x59)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x5f)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x44))
{
slots_valid |= (1 << (slot_addr - 0x50));
}
}
std::this_thread::sleep_for(1ms);
}
}
if(slots_valid != 0)
@@ -0,0 +1,81 @@
/*---------------------------------------------------------*\
| Driver for Philips Hue |
| |
| Adam Honse (calcprogrammer1@gmail.com), 9/15/2020 |
\*---------------------------------------------------------*/
#include "PhilipsHueController.h"
PhilipsHueController::PhilipsHueController(hueplusplus::Light& light_ptr, std::string bridge_ip):light(light_ptr)
{
dark = false;
location = "IP: " + bridge_ip;
}
PhilipsHueController::~PhilipsHueController()
{
}
std::string PhilipsHueController::GetLocation()
{
return(location);
}
std::string PhilipsHueController::GetName()
{
return(light.getModelId());
}
std::string PhilipsHueController::GetVersion()
{
return(light.getSwVersion());
}
std::string PhilipsHueController::GetManufacturer()
{
return(light.getManufacturername());
}
std::string PhilipsHueController::GetUniqueID()
{
return(light.getUId());
}
void PhilipsHueController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
hueplusplus::RGB rgb;
rgb.r = red;
rgb.g = green;
rgb.b = blue;
if((red == 0) && (green == 0) && (blue == 0))
{
if(!dark)
{
try
{
light.setColorRGB(rgb, 0);
}
catch(std::exception& e)
{
}
}
dark = true;
}
else
{
dark = false;
try
{
light.setColorRGB(rgb, 0);
}
catch(std::exception& e)
{
}
}
}
@@ -0,0 +1,33 @@
/*---------------------------------------------------------*\
| Definitions for Philips Hue |
| |
| Adam Honse (calcprogrammer1@gmail.com), 9/15/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include "HueDeviceTypes.h"
#include <string>
#include <vector>
#pragma once
class PhilipsHueController
{
public:
PhilipsHueController(hueplusplus::Light& light_ptr, std::string bridge_ip);
~PhilipsHueController();
std::string GetLocation();
std::string GetName();
std::string GetVersion();
std::string GetManufacturer();
std::string GetUniqueID();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
hueplusplus::Light& light;
std::string location;
bool dark;
};
@@ -0,0 +1,232 @@
#include "Bridge.h"
#include "HueDeviceTypes.h"
#ifdef _WIN32
#include "WinHttpHandler.h"
#else
#include "LinHttpHandler.h"
#endif
#include "Detector.h"
#include "LogManager.h"
#include "PhilipsHueController.h"
#include "PhilipsHueEntertainmentController.h"
#include "RGBController_PhilipsHue.h"
#include "RGBController_PhilipsHueEntertainment.h"
#include "SettingsManager.h"
/******************************************************************************************\
* *
* DetectPhilipsHueControllers *
* *
* Detect Philips Hue lighting devices with RGB control *
* *
\******************************************************************************************/
void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
{
json hue_settings;
/*-------------------------------------------------*\
| Create an HTTP handler |
\*-------------------------------------------------*/
#ifdef _WIN32
using SystemHttpHandler = hueplusplus::WinHttpHandler;
#else
using SystemHttpHandler = hueplusplus::LinHttpHandler;
#endif
/*-------------------------------------------------*\
| Get Philips Hue settings from settings manager |
\*-------------------------------------------------*/
hue_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("PhilipsHueDevices");
/*-------------------------------------------------*\
| Create a finder and find bridges |
\*-------------------------------------------------*/
static hueplusplus::BridgeFinder finder(std::make_shared<SystemHttpHandler>());
std::vector<hueplusplus::BridgeFinder::BridgeIdentification> bridges;// = finder.findBridges();
/*-------------------------------------------------*\
| If no bridges were detected, manually add bridge |
| IP and MAC (need to get these from file) |
\*-------------------------------------------------*/
if(bridges.empty())
{
if(hue_settings.contains("bridges"))
{
hueplusplus::BridgeFinder::BridgeIdentification ident;
if(hue_settings["bridges"][0].contains("ip"))
{
ident.ip = hue_settings["bridges"][0]["ip"];
}
if(hue_settings["bridges"][0].contains("mac"))
{
ident.mac = hue_settings["bridges"][0]["mac"];
}
bridges.push_back(ident);
}
}
/*-------------------------------------------------*\
| If no bridges were found, return, otherwise |
| connect to the first bridge |
\*-------------------------------------------------*/
if(bridges.empty())
{
return;
}
else
{
/*-------------------------------------------------*\
| Check if a saved username exists |
\*-------------------------------------------------*/
if(hue_settings.contains("bridges"))
{
/*-------------------------------------------------*\
| Add the username if it exists |
\*-------------------------------------------------*/
if(hue_settings["bridges"][0].contains("username"))
{
finder.addUsername(bridges[0].mac, hue_settings["bridges"][0]["username"]);
}
/*-------------------------------------------------*\
| Add the client key if it exists |
\*-------------------------------------------------*/
if(hue_settings["bridges"][0].contains("clientkey"))
{
finder.addClientKey(bridges[0].mac, hue_settings["bridges"][0]["clientkey"]);
}
}
/*-------------------------------------------------*\
| If username was added, this should connect right |
| away. If not, the user will have to push the |
| connect button on the bridge. |
\*-------------------------------------------------*/
try
{
static hueplusplus::Bridge bridge = finder.getBridge(bridges[0]);
bridge.refresh();
/*-------------------------------------------------*\
| Check to see if we need to save the settings |
| Settings need to be saved if either username or |
| client key either do not exist or have changed |
\*-------------------------------------------------*/
bool save_settings = false;
bool use_entertainment = false;
if(hue_settings.contains("bridges"))
{
if(hue_settings["bridges"][0].contains("username"))
{
if(hue_settings["bridges"][0]["username"] != bridge.getUsername())
{
save_settings = true;
}
}
else
{
save_settings = true;
}
if(hue_settings["bridges"][0].contains("clientkey"))
{
if(hue_settings["bridges"][0]["clientkey"] != bridge.getClientKey())
{
use_entertainment = true;
save_settings = true;
}
}
else
{
save_settings = true;
}
}
/*-------------------------------------------------*\
| Save the settings if needed |
\*-------------------------------------------------*/
if(save_settings)
{
hue_settings["bridges"][0]["username"] = bridge.getUsername();
hue_settings["bridges"][0]["clientkey"] = bridge.getClientKey();
hue_settings["bridges"][0]["entertainment"] = use_entertainment;
ResourceManager::get()->GetSettingsManager()->SetSettings("PhilipsHueDevices", hue_settings);
ResourceManager::get()->GetSettingsManager()->SaveSettings();
}
/*-------------------------------------------------*\
| Get all groups from the bridge |
\*-------------------------------------------------*/
if(hue_settings["bridges"][0].contains("entertainment"))
{
use_entertainment = hue_settings["bridges"][0]["entertainment"];
}
/*-------------------------------------------------*\
| Get all groups from the bridge |
\*-------------------------------------------------*/
if(use_entertainment)
{
std::vector<hueplusplus::Group> groups = bridge.groups().getAll();
if(groups.size() > 0)
{
/*-------------------------------------------------*\
| Loop through all available groups and check to |
| see if any are Entertainment groups |
\*-------------------------------------------------*/
for(unsigned int group_idx = 0; group_idx < groups.size(); group_idx++)
{
if(groups[group_idx].getType() == "Entertainment")
{
PhilipsHueEntertainmentController* new_controller = new PhilipsHueEntertainmentController(bridge, groups[group_idx]);
RGBController_PhilipsHueEntertainment* new_rgbcontroller = new RGBController_PhilipsHueEntertainment(new_controller);
rgb_controllers.push_back(new_rgbcontroller);
}
}
}
}
/*-------------------------------------------------*\
| Get all lights from the bridge |
\*-------------------------------------------------*/
else
{
std::vector<hueplusplus::Light> lights = bridge.lights().getAll();
if(lights.size() > 0)
{
/*-------------------------------------------------*\
| Loop through all available lights and add those |
| that have color (RGB) control capability |
\*-------------------------------------------------*/
for(unsigned int light_idx = 0; light_idx < lights.size(); light_idx++)
{
if(lights[light_idx].hasColorControl())
{
PhilipsHueController* new_controller = new PhilipsHueController(lights[light_idx], bridge.getBridgeIP());
RGBController_PhilipsHue* new_rgbcontroller = new RGBController_PhilipsHue(new_controller);
rgb_controllers.push_back(new_rgbcontroller);
}
}
}
}
}
catch(std::exception &e)
{
LOG_NOTICE("Exception occurred in Philips Hue detection");
}
}
} /* DetectPhilipsHueControllers() */
REGISTER_DETECTOR("Philips Hue", DetectPhilipsHueControllers);
@@ -0,0 +1,82 @@
/*---------------------------------------------------------*\
| Driver for Philips Hue Entertainment Mode |
| |
| Adam Honse (calcprogrammer1@gmail.com), 11/6/2020 |
\*---------------------------------------------------------*/
#include "PhilipsHueEntertainmentController.h"
PhilipsHueEntertainmentController::PhilipsHueEntertainmentController(hueplusplus::Bridge& bridge_ptr, hueplusplus::Group& group_ptr):bridge(bridge_ptr),group(group_ptr)
{
/*-------------------------------------------------*\
| Fill in location string with bridge IP |
\*-------------------------------------------------*/
location = "IP: " + bridge.getBridgeIP();
num_leds = group.getLightIds().size();
/*-------------------------------------------------*\
| Create Entertainment Mode from bridge and group |
\*-------------------------------------------------*/
entertainment = new hueplusplus::EntertainmentMode(bridge, group);
/*-------------------------------------------------*\
| Connect Hue Entertainment Mode |
\*-------------------------------------------------*/
entertainment->connect();
}
PhilipsHueEntertainmentController::~PhilipsHueEntertainmentController()
{
/*-------------------------------------------------*\
| Disconnect Hue Entertainment Mode |
\*-------------------------------------------------*/
entertainment->disconnect();
}
std::string PhilipsHueEntertainmentController::GetLocation()
{
return(location);
}
std::string PhilipsHueEntertainmentController::GetName()
{
return(group.getName());
}
std::string PhilipsHueEntertainmentController::GetVersion()
{
return("");
}
std::string PhilipsHueEntertainmentController::GetManufacturer()
{
return("");
}
std::string PhilipsHueEntertainmentController::GetUniqueID()
{
return("");
}
unsigned int PhilipsHueEntertainmentController::GetNumLEDs()
{
return(num_leds);
}
void PhilipsHueEntertainmentController::SetColor(RGBColor* colors)
{
/*-------------------------------------------------*\
| Fill in Entertainment Mode light data |
\*-------------------------------------------------*/
for(unsigned int light_idx = 0; light_idx < num_leds; light_idx++)
{
RGBColor color = colors[light_idx];
unsigned char red = RGBGetRValue(color);
unsigned char green = RGBGetGValue(color);
unsigned char blue = RGBGetBValue(color);
entertainment->setColorRGB(light_idx, red, green, blue);
}
entertainment->update();
}
@@ -0,0 +1,42 @@
/*---------------------------------------------------------*\
| Definitions for Philips Hue Entertainment Mode |
| |
| Adam Honse (calcprogrammer1@gmail.com), 11/6/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include "Bridge.h"
#include "EntertainmentMode.h"
#include "Group.h"
#include <string>
#include <vector>
#pragma once
#define HUE_ENTERTAINMENT_HEADER_SIZE 16
#define HUE_ENTERTAINMENT_LIGHT_SIZE 9
class PhilipsHueEntertainmentController
{
public:
PhilipsHueEntertainmentController(hueplusplus::Bridge& bridge_ptr, hueplusplus::Group& group_ptr);
~PhilipsHueEntertainmentController();
std::string GetLocation();
std::string GetName();
std::string GetVersion();
std::string GetManufacturer();
std::string GetUniqueID();
unsigned int GetNumLEDs();
void SetColor(RGBColor* colors);
private:
hueplusplus::Bridge& bridge;
hueplusplus::Group& group;
hueplusplus::EntertainmentMode* entertainment;
std::string location;
unsigned int num_leds;
};
@@ -0,0 +1,85 @@
/*-----------------------------------------*\
| RGBController_PhilipsHue.cpp |
| |
| Generic RGB Interface for Philips Hue |
| |
| Adam Honse (CalcProgrammer1) 9/15/2020 |
\*-----------------------------------------*/
#include "RGBController_PhilipsHue.h"
RGBController_PhilipsHue::RGBController_PhilipsHue(PhilipsHueController* light_ptr)
{
light = light_ptr;
name = light->GetManufacturer() + " " + light->GetName();
type = DEVICE_TYPE_LIGHT;
version = light->GetVersion();
description = "Philips Hue Device";
serial = light->GetUniqueID();
location = light->GetLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
void RGBController_PhilipsHue::SetupZones()
{
zone led_zone;
led_zone.name = "RGB Light";
led_zone.type = ZONE_TYPE_SINGLE;
led_zone.leds_min = 1;
led_zone.leds_max = 1;
led_zone.leds_count = 1;
led_zone.matrix_map = NULL;
zones.push_back(led_zone);
led new_led;
new_led.name = "RGB Light";
leds.push_back(new_led);
SetupColors();
}
void RGBController_PhilipsHue::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PhilipsHue::DeviceUpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
light->SetColor(red, grn, blu);
}
void RGBController_PhilipsHue::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_PhilipsHue::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_PhilipsHue::SetCustomMode()
{
}
void RGBController_PhilipsHue::DeviceUpdateMode()
{
}
@@ -0,0 +1,31 @@
/*-----------------------------------------*\
| RGBController_PhilipsHue.h |
| |
| Generic RGB Interface for Philips Hue |
| |
| Adam Honse (CalcProgrammer1) 9/15/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "PhilipsHueController.h"
class RGBController_PhilipsHue : public RGBController
{
public:
RGBController_PhilipsHue(PhilipsHueController* light_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
PhilipsHueController* light;
};
@@ -0,0 +1,113 @@
/*-----------------------------------------*\
| RGBController_PhilipsHueEntertainment.cpp|
| |
| Generic RGB Interface for Philips Hue |
| Entertainment Mode |
| |
| Adam Honse (CalcProgrammer1) 11/7/2020 |
\*-----------------------------------------*/
#include "RGBController_PhilipsHueEntertainment.h"
using namespace std::chrono_literals;
RGBController_PhilipsHueEntertainment::RGBController_PhilipsHueEntertainment(PhilipsHueEntertainmentController* light_ptr)
{
light = light_ptr;
name = light->GetManufacturer() + " " + light->GetName();
type = DEVICE_TYPE_LIGHT;
version = light->GetVersion();
description = "Philips Hue Entertainment Mode Device";
serial = light->GetUniqueID();
location = light->GetLocation();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
/*-----------------------------------------------------*\
| The Philips Hue Entertainment Mode requires a packet |
| within 10 seconds of sending the lighting change in |
| order to not exit entertainment mode. Start a thread |
| to continuously send a packet every 5s |
\*-----------------------------------------------------*/
KeepaliveThreadRunning = true;
KeepaliveThread = new std::thread(&RGBController_PhilipsHueEntertainment::KeepaliveThreadFunction, this);
}
void RGBController_PhilipsHueEntertainment::SetupZones()
{
zone led_zone;
led_zone.name = "RGB Light";
led_zone.type = ZONE_TYPE_SINGLE;
led_zone.leds_min = light->GetNumLEDs();
led_zone.leds_max = light->GetNumLEDs();
led_zone.leds_count = light->GetNumLEDs();
led_zone.matrix_map = NULL;
zones.push_back(led_zone);
for(unsigned int led_idx = 0; led_idx < light->GetNumLEDs(); led_idx++)
{
led new_led;
new_led.name = "RGB Light";
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_PhilipsHueEntertainment::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PhilipsHueEntertainment::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
light->SetColor(&colors[0]);
}
void RGBController_PhilipsHueEntertainment::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_PhilipsHueEntertainment::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_PhilipsHueEntertainment::SetCustomMode()
{
active_mode = 0;
}
void RGBController_PhilipsHueEntertainment::DeviceUpdateMode()
{
}
void RGBController_PhilipsHueEntertainment::KeepaliveThreadFunction()
{
while(KeepaliveThreadRunning)
{
if(active_mode == 0)
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::seconds(5))
{
UpdateLEDs();
}
}
std::this_thread::sleep_for(1s);
}
}
@@ -0,0 +1,42 @@
/*-----------------------------------------*\
| RGBController_PhilipsHueEntertainment.h |
| |
| Generic RGB Interface for Philips Hue |
| Entertainment Mode |
| |
| Adam Honse (CalcProgrammer1) 11/7/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "PhilipsHueEntertainmentController.h"
#include <atomic>
#include <thread>
class RGBController_PhilipsHueEntertainment : public RGBController
{
public:
RGBController_PhilipsHueEntertainment(PhilipsHueEntertainmentController* light_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
void KeepaliveThreadFunction();
private:
PhilipsHueEntertainmentController* light;
std::atomic<bool> KeepaliveThreadRunning;
std::thread* KeepaliveThread;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
};

Some files were not shown because too many files have changed in this diff Show More