Compare commits

..
Author SHA1 Message Date
Adam Honse 1177e9fa68 OpenRGB version 0.4 2020-09-09 01:05:11 -05:00
Adam Honse 91b139987f Undo Corsair mouse LED change as the zones differ between mice 2020-09-08 17:48:22 -05:00
Adam Honse 72233ffed6 Add Corsair Sabre RGB 2020-09-08 12:37:59 -05:00
Adam Honse bc31490085 Start labeling Corsair mouse LEDs 2020-09-08 12:22:01 -05:00
Adam Honse fa4d330933 Fix LED name on HyperX Pulsefire Surge 2020-09-08 11:55:10 -05:00
Adam Honse 346beed0eb Standardize common mouse zone/LED names 2020-09-08 11:51:26 -05:00
Adam Honse e74faeb6be Rename Static mode to Direct mode for RGB Fusion 2 SMBus 2020-09-08 11:38:35 -05:00
Adam Honse 70c51abff7 Change order of HyperX DRAM so that sticks are in order 2020-09-08 02:11:28 -05:00
Adam Honse d2ebd167b3 Don't update Polychrome LEDs when the active mode doesn't require an update 2020-09-08 01:42:46 -05:00
TheRogueZeta a605d5581a Update zones on mode update
Minor cleanup, logic tweak to only update per-zone modes for Polychrome V1 by Adam Honse <[email protected]>
2020-09-07 16:36:26 -05:00
TheRogueZeta 759e09b3a3 Rework Polychrome v1 to be separate from ASRLED/V2
Code cleanup and some register name changes by Adam Honse <[email protected]>
2020-09-07 16:27:52 -05:00
Adam Honse a8b3279c1d Add X470 Aorus Gaming 7 Wifi 2020-09-07 13:14:20 -05:00
TheRogueZeta 3f2b925dd0 Update remaining controlers 2020-09-07 03:09:49 -05:00
TheRogueZeta 0cab595ef6 Fix G PRO speed slider. 2020-09-07 03:05:29 -05:00
Adam Honse 1a946268ba Update detection list for RGB Fusion 2 SMBus 2020-09-06 15:24:20 -05:00
Adam Honse 1f1548929d Use working directory for all file accesses, some old file accesses always used the executable directory 2020-09-06 12:56:20 -05:00
Adam Honse 3e62c91ed3 Add location to Polychrome controller 2020-09-06 12:44:34 -05:00
Adam Honse 9be25d1ca4 Make zone LED count a char as it can only be up to 0xFF 2020-09-06 12:25:52 -05:00
k1-801 290fddaf55 Fix incorrect font color detection for DeviceView (threshold 50) 2020-09-06 02:36:53 -05:00
Adam Honse 8823e28fa0 Call update device list callback after detection is finished 2020-09-06 02:29:22 -05:00
k1-801 ec77c658f2 Rudimentary rescanning implemented but button for it not added due to SDK conflicts. Stop detection button.
Commit amended by Adam Honse <[email protected]>
2020-09-06 01:37:16 -05:00
Adam Honse be84a60af6 More Polychrome V1 changes, set LED selection register for ASRLED/Polychrome V1 2020-09-05 02:00:56 -05:00
Adam Honse e40617e417 Set LED select register for Polychrome V1 2020-09-05 01:33:18 -05:00
Adam Honse 7556a2872c Rework LED handling for Polychrome V1 2020-09-05 01:13:38 -05:00
TheRogueZeta 7ccb3cd9e6 Fix reversed G PRO modes 2020-09-04 11:49:23 -05:00
TheRogueZeta cbf867c0ee Change zone name and move Polychrome_V1 2020-09-04 11:33:03 -05:00
Adam Honse b7ee237fbf Add Razer Cynosa Chroma keymap and add ISO keys to other Razer layouts 2020-09-03 16:21:29 -05:00
Adam Honse 0345eb582b More warning fixes 2020-09-02 19:03:43 -05:00
Adam Honse f568253c51 Clean up more warnings 2020-09-02 18:25:58 -05:00
Adam Honse 2251feb701 Add AUMA0-E8K4-0101 Aura SMBus controller as a V2 register device 2020-09-02 09:45:50 -05:00
k1-801 8b8451017e Non-important warnings removed
Commit amended by Adam Honse <[email protected]> due to merging from a different branch.
2020-09-01 23:29:00 -05:00
Adam Honse 94c18fc9b4 Change less than or equal to less than. This shouldn't change anything, but it seems the Media Next key has issues as it was and this fixes that 2020-08-31 23:30:29 -05:00
TheRogueZeta f741cb7c6b Add Logitech Powerplay mat and add speed opt GPW 2020-08-31 23:06:51 -05:00
TheRogueZeta d19b5bc87d Update Logitech Lighspeed nameing and openrgb.rule 2020-08-31 22:41:10 -05:00
Carson Mathre 319f19e65d Update RGBController/RGBController_Tecknet.cpp 2020-08-31 17:30:21 -05:00
Adam Honse ad97bf8c08 Rename Key: Cal to Key: Calculator on Ducky keyboard controller 2020-08-31 14:16:33 -05:00
Adam Honse 835a007445 Draw color wheel with transparent background rather than by pulling background color from palette, as it didn't always get the background the right color 2020-08-31 11:17:59 -05:00
k1-801 66fd8ab394 Dark theme icons 2020-08-31 09:35:35 -05:00
Adam Honse 9407ef7f4d Add X470 AORUS GAMING 5 WIFI to RGB Fusion 2 SMBus supported motherboard list 2020-08-31 08:29:37 -05:00
Adam Honse fb420b3928 Add X470 AORUS ULTRA GAMING to RGB Fusion 2 SMBus detection list 2020-08-30 18:01:33 -05:00
Adam Honse bc3e351f26 Add X470 AORUS ULTRA GAMING-CF to RGB Fusion 2 SMBus detection list 2020-08-30 17:13:54 -05:00
Adam Honse edbccc345f Change LED configuration offset for AUDA0-E6K5-0101 Aura SMBus controller 2020-08-30 17:06:54 -05:00
Adam Honse db3c3e9fb1 Use DMI information to detect RGB Fusion 2 SMBus controller. Only one board added for now. 2020-08-30 16:30:47 -05:00
Adam Honse 6af7324840 Fix missing comma in Ducky key name list 2020-08-30 15:25:04 -05:00
Adam Honse 640f7c7cde Add keymap to Ducky keyboard controller 2020-08-30 15:13:16 -05:00
Adam Honse 37224a6c4d Add support for ASRock Polychrome addressable header as a single LED zone 2020-08-30 14:24:37 -05:00
Adam Honse 6235bcb2b4 Update README 2020-08-30 13:24:59 -05:00
Adam Honse 90ca955343 ASRock zones created based on LED configuration register rather than pre-defined board layouts 2020-08-30 13:07:00 -05:00
Adam Honse d38dcc038a Remove boolean for ASR LED and replace it with an ASRock type enum with ASR LED, Polychrome V1, and Polychrome V2. 2020-08-30 01:57:13 -05:00
Adam Honse f577e5ef3c Add more sleeps to prevent mode corruption and add a function for reading the LED configuration register 2020-08-30 01:43:14 -05:00
Adam Honse 877469cd2d Fix case typo 2020-08-30 01:06:10 -05:00
Adam Honse 4d506588b5 Add sleeps after i2c operations to make ASRock controller more reliable 2020-08-30 00:59:45 -05:00
Adam Honse e972335872 Move speed setting to mode function, add struct to hold board information, remove firmware version from name string and add it to firmware version field. 2020-08-30 00:48:51 -05:00
Adam Honse 9f584b1f76 Hard coded test with all B450M Steel Legend LEDs (except addressable) 2020-08-30 00:48:51 -05:00
k1-801 45dc619076 Expand large keys to fill empty spaces in the matrix, if possible
Change manually picked from merge request by Adam Honse <[email protected]>
2020-08-30 00:31:18 -05:00
Kryesh 81c8ec6684 Allow for multiple RGBFusion 2 Controllers
See issue 529
2020-08-30 00:11:32 -05:00
k1-801 1c7bfdaeb4 Proper UTF-8 labels
Commit amended by Adam Honse <[email protected]>
2020-08-29 01:40:59 -05:00
crashniels f6812a5c88 Corsair Layout changes
Added the KeyIDs for the K95 and K95 platinum as well as the European specific keys. IDs from ckb-next. https://github.com/ckb-next/ckb-next/blob/ba063cedb751cecb1b8b1abf1af3f6e8dc31e9fe/src/daemon/keymap.c
2020-08-29 00:32:40 -05:00
Adam Honse c76dbc943f Update udev rules for G502 Lightspeed with Powerplay Mousepad 2020-08-29 00:22:16 -05:00
Ryakna cd1ceed5df Added detection for Logitech G502 Lightspeed when connected through the Logitech Powerplay Mousepad 2020-08-29 00:18:06 -05:00
Rafail Giavrimis 1558ffc61f Added Support for Steelseries Apex 5 2020-08-29 00:10:25 -05:00
k1-801 06b75f5ae7 Add debug keyboard
Commit modified by Adam Honse <[email protected]> to remove wingdings portion of change.
2020-08-29 00:07:29 -05:00
Adam Honse 95275ebf39 Make linear zones linear in demo devices 2020-08-28 17:46:48 -05:00
Adam Honse d5f86baa73 Create a debug controller with fake devices for SDK testing. Enable with debug_<type> lines in debug.txt 2020-08-28 16:47:38 -05:00
Adam Honse c386a6c571 Add i2c tool for reading multiple bytes from an SMBus device register 2020-08-27 19:12:37 -05:00
Adam Honse 4e95bc55d8 Add the ability to disable device detection using a text file 2020-08-26 19:44:24 -05:00
Adam Honse ae4c88fef8 Fix missing parameter in i2c call 2020-08-26 15:14:25 -05:00
Adam Honse 989dc7fc5d Select all zones before applying Polychrome colors 2020-08-26 15:04:43 -05:00
dumbasPL 1b863fdc7b Add support for Corsair H150i Pro RGB 2020-08-25 15:06:50 -05:00
Adam Honse 933ea93c25 Update README 2020-08-24 22:54:20 -05:00
Adam Honse 7daa5b6556 Use horizontal layouts for buttons and detection elements, repaint device view when selecting all 2020-08-24 22:36:18 -05:00
k1-801 1598fc8de4 Add apply and select all buttons.
Select all button and some minor rework by Adam Honse <[email protected]>
2020-08-24 22:12:09 -05:00
Adam Honse b03fce33ca Update Key: Context to Key: Menu in device view label lookup 2020-08-24 00:51:34 -05:00
Adam Honse 6d9aea38a6 Fix setting mode specific colors and not changing to direct mode when the mode has no configurable colors 2020-08-24 00:40:44 -05:00
Adam Honse a2ed9571cf Add button to toggle graphical LED view and default to hidden 2020-08-24 00:40:44 -05:00
Adam Honse ba24efe544 Fix display for devices with multiple matrix zones 2020-08-24 00:40:44 -05:00
Adam Honse f750654b3e Check for size changes and refresh data if size has changed 2020-08-24 00:40:44 -05:00
Adam Honse b0b46dd3a5 Use QString for LED labels vector 2020-08-24 00:40:44 -05:00
Adam Honse 5e002107ef Add key labels based on key names 2020-08-24 00:40:44 -05:00
Adam Honse b6824b8a46 Don't update the mode UI when the update callback occurs for now 2020-08-24 00:40:44 -05:00
Adam Honse 342d90b82a Add function to unregister update callback when device page is deleted 2020-08-24 00:40:44 -05:00
k1-801 63f005d4fc Forgot a DeviceView update in setSelectionColor 2020-08-24 00:40:44 -05:00
k1-801 4601b91f1f Fixed multiple selection, temporarily disabled interface updates due to update spam from a controler
Code style changes and integration by Adam Honse <[email protected]>
2020-08-24 00:40:44 -05:00
k1-801 c8ea2ff36f Zones overlapping fixed
Code from RGBController moved to DeviceView by Adam Honse <[email protected]>
2020-08-24 00:40:44 -05:00
k1-801 7781b1425d Ctrl-held selection fix 2020-08-24 00:40:43 -05:00
k1-801 7977a3ef50 Fix some signedness warnings, add size caching 2020-08-24 00:40:43 -05:00
k1-801 3000d625fa WIP: Zone names displayed fine now, but off-center 2020-08-24 00:40:43 -05:00
k1-801 bbc3c1de5b WIP: Instant color setting, buttons removed
Code cleanup by Adam Honse <[email protected]>
2020-08-24 00:40:43 -05:00
k1-801 a2a394492b WIP: Multiple selection test
Rework of LED position data from RGBController into DeviceView, code style cleanup modified by Adam Honse <[email protected]>
2020-08-24 00:40:43 -05:00
Adam Honse c6b10d9316 Center the device view horizontally 2020-08-24 00:40:43 -05:00
Adam Honse 177cd2ec92 Use matrix map when available 2020-08-24 00:40:43 -05:00
Adam Honse f787c5e63f Move device view above other controls, begin working on matrix display 2020-08-24 00:40:43 -05:00
Adam Honse d3993547c3 Device view resizes width to fit window size, UI updates on SDKcontroller update 2020-08-24 00:40:43 -05:00
Adam Honse 17f1390f36 Add widget that displays the current color of all LEDs on a controller 2020-08-24 00:40:43 -05:00
Adam Honse 38f8808bea Rename Key: Context to Key: Menu 2020-08-23 21:40:06 -05:00
Adam Honse c58d458062 Remove non-direct modes 2020-08-23 15:18:08 -05:00
Adam Honse d96fd19c6c Clean up profile setup packets 2020-08-23 15:16:09 -05:00
Adam Honse 9f91170240 Initial implementation of Pulsefire Surge direct mode (requires new firmware?) 2020-08-23 15:16:09 -05:00
Adam Honse 2440ab8fc9 Update Linux CI scripts to use temporary linuxdeploy path as the main release is broken 2020-08-23 00:16:28 -05:00
Denzil S.T. Ferreira 6ec3cfb1de Add support for NZXT Kraken M22 AIO
Reworked to use device information table by Adam Honse <[email protected]>
2020-08-22 14:06:03 -05:00
Adam Honse ebae2a3ba3 Fix typo in MSIGPUController 2020-08-22 13:24:36 -05:00
Felipe Cavalcanti effa243adb Adding support for CPU Cooler Gigabyte Aorus ATC800 2020-08-22 12:57:50 -05:00
Azymm 715099d768 Update MSIGPUControllerDetect.cpp 2020-08-22 12:42:20 -05:00
Adam Honse e6531e5379 Add HyperX Alloy Origins Core PID 2020-08-21 23:23:32 -05:00
Adam Honse 41762d4670 Add additional Corsair Hydro modes 2020-08-21 00:22:09 -05:00
Adam Honse ce836ce7b6 Fix E1.31 device name strings 2020-08-20 15:06:59 -05:00
Adam Honse c517257cb0 Add initialization packet to Corsair Hydro controller 2020-08-18 13:01:10 -05:00
Adam Honse ed368fba12 Add Corsair H115i PRO RGB to udev rules 2020-08-18 12:10:45 -05:00
Adam Honse 0b7b42b8f5 Add Corsair H115i PRO RGB to Corsair Hydro list 2020-08-18 12:06:47 -05:00
Adam Honse 68a16fadc2 Initial support for Corsair Hydro Series devices (only H100i Pro RGB for now) 2020-08-18 00:34:42 -05:00
Adam Honse 4f5cf83e47 Add keepalive option for E1.31 output 2020-08-17 15:53:44 -05:00
Adam Honse ed01850926 Initialize new map 2020-08-14 01:33:50 -05:00
Adam Honse 29e2626471 Generate matrix maps for E1.31 matrix configurations 2020-08-14 01:32:35 -05:00
Adam Honse 4f0cf752f5 Add e131.txt parser for matrix configuration. 2020-08-13 22:19:14 -05:00
Térence Clastres 6c52e3ce11 Fix hang when deleting busses 2020-08-13 00:05:29 -05:00
Térence Clastres 53379c5482 Fixes for memory issues detected by valgrind 2020-08-12 23:48:03 -05:00
Adam Honse ff07a488a2 Update Blackwidow Elite keymap 2020-08-12 23:34:33 -05:00
Adam Honse 73a8a50848 Add Blackwidow Elite keymap 2020-08-12 15:22:31 -05:00
Adam Honse 78a8a2c4a9 Add Blackwidow 2019 keymap 2020-08-12 15:14:21 -05:00
AnierinB 9939d7e4f1 Add support for RTX 2060 Z with Sub-Device ID 0x3752
USB controller: NVIDIA Corporation Device 1ada (rev a1) (prog-if 30 [XHCI])
Subsystem: Micro-Star International Co., Ltd. [MSI] Device 3752

Signed-off-by: AnierinB <[email protected]>
2020-08-11 00:01:20 -05:00
xyz 9cf32593ae add PID of Logitech G502H 2020-08-10 19:14:21 -05:00
santeri3700 7294fa8180 Enable support for Corsair Scimitar PRO RGB 2020-08-09 14:10:47 -05:00
edbgon bd35a83837 Added missing key for US layouts 2020-08-09 14:09:12 -05:00
edbgon 3da5a4f6ba Update to add Apex Pro keyboard 2020-08-08 22:13:39 -05:00
Adam Honse c571ea124f Add GitLab URL to the Software Information page 2020-08-08 02:46:41 -05:00
Adam Honse 9db92e9afa Show Software Information and SMBus Tools tabs after device list has been refreshed 2020-08-07 23:37:23 -05:00
Adam Honse 634ec9f488 Wait on asynchronous device detection before performing CLI operations that require device list 2020-08-07 23:01:20 -05:00
Adam Honse 9c4e73bbed Set default percentage to 100% so that the progress bar goes away if device detection is skipped 2020-08-07 14:02:00 -05:00
Térence Clastres f8af9980fd Fix crash on close while detecting devices 2020-08-07 14:01:59 -05:00
Adam Honse 06b2cd87c6 Clean up progress bar initial state 2020-08-07 14:01:59 -05:00
Adam Honse f716a05947 Add detector names and display them in the progress bar 2020-08-07 14:01:59 -05:00
Adam Honse 75899f973b Load sizes after detection is complete 2020-08-07 14:01:59 -05:00
Adam Honse e84cb98055 Add detection progress bar to the user interface 2020-08-07 14:01:59 -05:00
Adam Honse aaa2ecddc7 Move i2c bus detectors to their respective files and add a detector macro for i2c busses so they can be detected asynchronously. Fix WMI and DMI info. 2020-08-07 14:01:59 -05:00
Adam Honse 7898e9b95d Initial prototype of asynchronous detection. DMI information broken 2020-08-07 14:01:59 -05:00
TheRogueZeta 5270b46e31 Re-order Zones 2020-08-07 12:54:56 -05:00
TheRogueZeta d0ab5a4de4 Fix Lighting Control packet typo. 2020-08-07 12:53:32 -05:00
TheRogueZeta 9be8ab8371 Add Logitech G Pro Wireless 2020-08-07 11:58:29 -05:00
Chris f0be42db38 Added 'X570 AORUS ULTRA' to known layouts 2020-08-07 11:44:03 -05:00
Adam Honse 8667211180 Move console attachment to main and only perform if running in a terminal. (!102) 2020-08-05 21:49:20 -05:00
Chris 8168e1cadb Initial controller for Tecknet mice 2020-08-05 21:35:23 -05:00
kernzerfall c15ceaa26c Add support for Logitech G502 Proteus Spectrum and G512 RGB.
- Set the G512 RGB to use G810 driver
- Add driver and interface for the G502 Proteus Spectrum
2020-08-05 21:06:30 -05:00
kernzerfall ee61b87fe4 Add udev rules 2020-08-05 21:06:12 -05:00
pobrn ddc69778dc Modular detection system with resource manager.
Includes pull request !87 with modifications by Adam Honse ([email protected]).
2020-08-05 00:23:34 -05:00
Adam Honse b3a7b7be81 Add 32-bit AppImage build target 2020-08-04 17:26:44 -05:00
Adam Honse f05df3768b Add number pad to Ducky matrix map 2020-08-04 10:26:38 -05:00
Katzenbiber 1be9f6e460 Add support for Logitech G203 Lightsync 2020-08-02 22:49:14 -05:00
santeri3700 3bbc3da48b Enable support for Holtek USB Gaming Mouse 2020-08-02 22:45:15 -05:00
santeri3700 92f7fe7dc4 Add support for Holtek USB Gaming Mouse 2020-08-02 22:42:56 -05:00
Ahmad Nassri f1d42d27ce docs(readme): include note about VS 2019 runtime 2020-08-02 22:41:24 -05:00
Adam Honse f288f63087 Update default DPI and add some modes to Pulsefire Surge controller 2020-08-02 22:38:42 -05:00
Adam Honse 226045cb8e Update key names on SteelSeries Apex controller 2020-07-31 22:36:21 -05:00
edbgon 4660870c22 Update SteelSeries Apex controller for Apex 7 TKL version 2020-07-31 22:08:57 -05:00
Adam Honse 412c819699 Set matrix map pointers to NULL for HyperX Pulsefire Surge 2020-07-31 12:29:08 -05:00
Adam Honse 635dcce7f0 Use the name Direct for all custom/static modes that transition smoothly without flicker 2020-07-31 10:49:25 -05:00
B Horn 1457831840 Modifying find_usb_serial_port() to return a vector 2020-07-31 08:47:39 -05:00
Adam Honse 00cc6978a2 Initial HyperX Pulsefire Surge controller 2020-07-28 20:37:12 -05:00
Chris d26e4da9f1 Added B550 Aorus Pro & Elite layouts
* Added MBName2Layout map
* Changed layouts to accomodate
2020-07-27 10:46:52 -05:00
Adam Honse 0a821526fa Fix typo 2020-07-27 10:17:28 -05:00
crashniels 68a92d0219 Read device mode and colours 2020-07-26 23:13:13 -05:00
crashniels 5221d93fc0 Changed UpdateMode() to DeviceUpdateMode() 2020-07-26 23:13:07 -05:00
crashniels 22deb13ac0 Added Galax modes in 2020-07-26 23:12:28 -05:00
crashniels 58b875d5ed Added missing references in the Qt Project file 2020-07-26 23:12:15 -05:00
crashniels 12f5d6070f WIP Galax RTX GPU support
Setting RGB values works. Modes still unknown.
2020-07-26 23:07:35 -05:00
crashniels 5e0b1fa3cc Added 0x3A to the Aura Ram Address list 2020-07-26 20:04:35 -05:00
Roger Roger 1ee3a7c3e2 Fix crash related to Razer Naga Trinity
Not all devices have static_mode at position 1, just setting it without
checking can crash the app
2020-07-26 15:49:39 -05:00
edbgon 43c13db970 Updated HID feature report with report ID for Windows compatibility 2020-07-26 15:46:20 -05:00
edbgon b5818d22af Update HID feature report to include report number for windows compatibility 2020-07-26 15:45:45 -05:00
Adam Honse fd7a5fc057 Add empty files/classes for HyperX Pulsefire Surge 2020-07-25 17:36:24 -05:00
Adam Honse 5af1ca9363 Fix formatting 2020-07-25 16:51:56 -05:00
Adam Honse c4d096e60c Update warning section in README to clarify a few things 2020-07-25 16:50:41 -05:00
Adam Honse 174b0743a9 Update timer resolution every 500ms to ensure it stays set while OpenRGB is active 2020-07-25 01:51:39 -05:00
Adam Honse 4b50533560 Uncomment timer initialization... 2020-07-25 01:33:18 -05:00
Adam Honse 1555dae1c8 Set timer resolution to 0.5ms on Windows 2020-07-25 01:20:49 -05:00
Chris 8b5717470a Fix for Gigabyte Fusion2 USB detection
* Adjusted the selection criteria for  USE_HID_USAGE flags
* Slight changes to the Fusion2USB controller to avoid crashes
* Updated DMIInfo to return correct Motherboard name on windows
2020-07-24 12:41:25 -05:00
edbgon 38b2cf03b0 LED name for 3rd LED group fixed 2020-07-24 12:39:24 -05:00
cjber 1293b07c9e add MSI 2070S Gaming X Support 2020-07-24 12:37:39 -05:00
Adam Honse aa4c41ddf7 Add Razer Blade Stealth and Blade Pro (2017) keymaps 2020-07-24 12:02:16 -05:00
Chris 628f423171 Minor fix for the Razer Blackwidow X Chroma 1532:0216
* Changed the 'w' to 'W' to match upstream
2020-07-23 21:57:21 -05:00
roger roger a9d179f93a Fixed typo that prevented the razer naga trinity from being detected 2020-07-23 21:56:26 -05:00
衛俊儒 4955dc0844 Update MSIGPUControllerDetect.cpp
MSI RTX2080 Sea Hawk EK X
2020-07-23 21:55:04 -05:00
Al_eXs 3f66f0d67a Fix Tab navigation order in the GUI 2020-07-23 21:48:31 -05:00
Adam Honse bc7ab5170a Add Razer BlackWidow Chroma Tournament Edition keymap 2020-07-23 21:18:30 -05:00
Adam Honse d61649f748 Add Razer BlackWidow Chroma keymap 2020-07-23 21:09:38 -05:00
Adam Honse 9a33a78574 Add keymap support to OpenRazer code and add a keymap for the Huntsman Elite 2020-07-23 14:42:34 -05:00
Adam Honse 030c0c60f3 Add (ANSI) and (ISO) specifiers to keys that differ between layouts 2020-07-23 11:17:23 -05:00
Adam Honse 19ff834d99 Fix apostrophe key on G810 2020-07-23 10:54:59 -05:00
Adam Honse 400a078a05 Fix media key names 2020-07-23 10:46:45 -05:00
Adam Honse 618bebc46b Update key names for G810 and Poseidon Z RGB 2020-07-23 10:26:16 -05:00
Adam Honse dee23ec52e Use synchronous mode update function in CLI 2020-07-22 23:29:32 -05:00
Adam Honse baca85b8cd Create a detection list for MSI GPU controller with card names 2020-07-22 22:32:00 -05:00
Arturo Casal 00b1cfcb3b Added Identifiers for MSI RTX 2080 Gaming X Trio 2020-07-22 20:47:55 -05:00
Shawn a9dbf5ef70 Add support for MSI 2060 Gaming X 2020-07-22 20:45:45 -05:00
Jeff Geer a0b1153ec3 Added Identifiers for MSI RTX 2080 Ti Gaming X Trio 2020-07-21 23:22:15 -05:00
Adam Honse 39a5e0eba0 Increment version number post-release 2020-07-21 23:21:10 -05:00
Adam Honse 308bb6f9b8 OpenRGB version 0.3 2020-07-21 19:34:18 -05:00
Adam Honse 86d96848a2 Fix buffer pointer in HyperX Alloy Origins controller 2020-07-21 19:33:34 -05:00
Adam Honse 98100a9bad Add two skipped slots before Number Pad Enter on HyperX Alloy Origins 2020-07-21 17:28:40 -05:00
Adam Honse e66562bb25 Fix number pad mapping on HyperX Alloy Origins 2020-07-21 16:29:17 -05:00
Adam Honse 902ebc2e83 Initialize transmit color count after inserting blanks 2020-07-21 12:28:05 -05:00
Adam Honse 403d60e214 Update skip list for HyperX Alloy Origins 2020-07-21 12:25:34 -05:00
Adam Honse 1c5130e78a HyperX Alloy Origins keymap 2020-07-20 23:30:10 -05:00
Miles M 481a5dea2e Update RGBController/OpenRazerDevices.h 2020-07-20 18:14:46 -05:00
Adam Honse 320129633d Add SMBus detection mode selection box 2020-07-20 17:49:12 -05:00
xgelectro 0dea21a53e i2c_smbus_nvapi::i2c_smbus_xfer now returns -1 for I2C_SMBUS_QUICK accesses which are unsupported 2020-07-20 17:37:43 -05:00
xgelectro 79625e9c8a Removed read bit from i2c_dev_address, so the detection of ASUS ROG RTX20xx Super is now working 2020-07-20 17:37:38 -05:00
Adam Honse 0cff1734ce Use 65 as size for Alloy Origins feature reports 2020-07-20 17:29:45 -05:00
David Reidsma e1d8f48cb9 changed max brightness from 5 to 4 2020-07-19 13:32:47 -05:00
B Horn 752737034b AddressSanitizer build time configuration option
This adds a configuration time option for enabling AddressSanitizer,
a tool included with recent versions of gcc (4.8+) and clang (3.1+).

To use it:
qmake CONFIG+=asan <path to orgb>
2020-07-19 13:25:51 -05:00
B Horn ecf1d2ce98 Bounds checking for ResizeZone implementations
As noted in #350, various RGBControllers don't validate if the zone they
are trying to resize actually exists.

This was fixed by a just checking they remain in bounds.
2020-07-19 13:23:40 -05:00
B Horn bb743c6b62 Validating user provided indexes in RGBController
When using the SDK Server, it was possible to provide indexes that would
later be used inside the various SetXDescription functions in
RGBController. This would result in possible out of bounds reads /
writes.

This is patched by checking the various indexes remain in bounds.
2020-07-19 13:19:59 -05:00
B Horn f02223d6ba Checks to avoid null dereferences in NetworkServer
Various commands in NetworkServer require extra data. However, if the
packet size is set to 0 for these, the code will skip over reading the
data in and allocating memory. This results in null dereferences.

This patch adds checks to the relevant commands to make sure they don't
continue reading a null pointer.
2020-07-19 13:16:19 -05:00
edbgon b87980965d Updated key names in accordance with usb spec 2020-07-19 13:05:51 -05:00
edbgon 2255eea14e Proper matrix map for Apex 7 keyboard 2020-07-19 13:05:26 -05:00
Adam Honse 0ccf2d0c33 Remove some debugging printouts in Network Client and Server code 2020-07-17 22:10:53 -05:00
Adam Honse 5ce6ec9ea7 Request updated controller mode from server after sending a Set Custom Mode command 2020-07-17 18:29:37 -05:00
Adam Honse 97e1c3e913 Update mode asynchronously 2020-07-17 18:29:37 -05:00
Adam Honse 9937731ad8 Remove WinUSB instructions and instead provide WinUSB uninstall instructions after the Windows HID switch 2020-07-17 17:15:19 -05:00
Adam Honse bd4f3728f6 Re-add interface check for Corsair driver when not using HID usages. Only set special function control for non-keyboards 2020-07-17 09:23:50 -05:00
Chris 009a6ccd2a Updated detector to include code pages
* Report descriptor for GB Fusion2 USB 048d:8297

0x06, 0x89, 0xFF,  // Usage Page (Vendor Defined 0xFF89)
0x09, 0x10,        // Usage (0x10)
0xA1, 0x01,        // Collection (Application)
0x85, 0x5A,        //   Report ID (90)
0x09, 0x01,        //   Usage (0x01)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x10,        //   Report Count (16)
0xB1, 0x00,        //   Feature (Data,Array,Abs,No Wrap,Linear,Preferred
State,No Null Position,Non-volatile)
0xC0,              // End Collection
0x06, 0x89, 0xFF,  // Usage Page (Vendor Defined 0xFF89)
0x09, 0xCC,        // Usage (0xCC)
0xA1, 0x01,        // Collection (Application)
0x85, 0xCC,        //   Report ID (-52)
0x09, 0x01,        //   Usage (0x01)
0x15, 0x00,        //   Logical Minimum (0)
0x26, 0xFF, 0x00,  //   Logical Maximum (255)
0x75, 0x08,        //   Report Size (8)
0x95, 0x3F,        //   Report Count (63)
0xB1, 0x00,        //   Feature (Data,Array,Abs,No Wrap,Linear,Preferred
State,No Null Position,Non-volatile)
0xC0,              // End Collection
2020-07-17 09:23:50 -05:00
Katzenbiber 6606ab92bd Fix Wraith Prism using WinUSB on Windows
- Add Usage Page to Wraith Prism Detect, which fixes WinUSB bugs.
- Change AMDWraithPrismControllerDetect.cpp structure
2020-07-17 09:23:49 -05:00
Adam Honse 595248cc10 Fix issues preventing hidapi from working without WinUSB on Windows 2020-07-17 09:23:49 -05:00
Chris ffc02e6c98 Coolermaster MP750 now supports on load status from device
Previous issues with hidapi-hidraw vs hidapi-libusb have been resolved.
CMMP750Controller.cpp now calls GetStatus in the constructor to query
device and set current state. Added "Getters" to the public interface to
allow the RGBController_CMMP750Controller.cpp to access current state in
construction.
2020-07-17 09:16:02 -05:00
Adam Honse ac2d911566 Disable MSI Mystic Light controller until the bricking issues are understood 2020-07-16 23:34:50 -05:00
Adam Honse 633dfdbddd Re-add EKControllerDetect.cpp with fixed capitalization (to fix build break on case-sensitive systems 2020-07-16 13:09:59 -05:00
Adam Honse 54cd8408e8 Temporarily delete EKControllerdetect.cpp (lower case) 2020-07-16 13:09:19 -05:00
Chris 384011aab3 Preliminary functionality implemented for EK Loop Connect
* 9 modes implemented
* Speed Slider works
* Currently single (non linear) zone
2020-07-16 11:12:59 -05:00
Chris 95ded7b871 Initial commit for the EK Loop Connect Support
* Implemented Static & Breathing modes
2020-07-16 11:12:48 -05:00
Adam Honse 607d83b795 More Sapphire GPU work 2020-07-15 14:47:37 -05:00
SuNNjek f4872c52bd Add support for MSI RTX 2070 ARMOR 2020-07-15 10:20:05 -05:00
Adam Honse 505e2d2aa4 Initial driver for Sapphire GPU (tested on RX580 Nitro+ on Windows) 2020-07-15 00:22:46 -05:00
Chris 77ecfc3b46 Cleaned up MSI Mysticlight detect pids
* Added all MSI Mystic light PIDS to udev rules
* Slight tweak to speed up CM detector
2020-07-14 15:43:40 -05:00
Chris 8107288838 Additonal code corrections and updates for B550 2020-07-14 15:36:56 -05:00
Adam Honse 05e76cc733 Fix Windows build 2020-07-12 17:02:11 -05:00
Adam Honse 816eabb1d1 Update direct packet for HyperX keyboards based on Alloy FPS captures 2020-07-12 16:53:20 -05:00
Adam Honse 9b6e24947d Code style cleanup for MSI GPU controller 2020-07-12 16:29:34 -05:00
Hex3l 5778d344e0 adds support to MSI 2080 Ti Sea Hawk EK X 2020-07-12 16:25:56 -05:00
xyz b785f2efbf Attach PCI IDs in DetectNvAPII2CBusses() 2020-07-12 16:25:07 -05:00
xyz 224f59450e Add support for MSI RTX 2080S Gaming X Trio 2020-07-12 16:20:57 -05:00
Adam Honse b80cbe931e Add Corsair Glaive RGB PRO to detection list 2020-07-12 16:06:58 -05:00
Adam Honse 87adb0bdb7 Add keepalive thread for Alloy Origins 2020-07-12 02:41:07 -05:00
Adam Honse 78c7572a2c Update constants for Alloy Origin driver and use 64 byte instead of 65 byte operations 2020-07-12 02:10:05 -05:00
Adam Honse bbed1f64a7 Use interface 3 for Alloy Origins 2020-07-12 01:20:59 -05:00
Adam Honse ac071902c0 Fix MSVC paths from 2017 to 2019 upgrade 2020-07-12 00:54:06 -05:00
Adam Honse 62a4cd31c5 Update QT path for GitLab CI 2020-07-12 00:47:32 -05:00
Adam Honse 751961b3b3 Initial controller for HyperX Alloy Origins 2020-07-12 00:31:40 -05:00
Chris 30625548e5 Adding USB PID 048D:5702 for Gigabyte B550 Aorus Elite 2020-07-09 22:38:12 -05:00
Chris 9451771ccb Rewrote the RGBFusion2USBController to allow for per model
configurations of LED's and zones

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

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

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

* Thread-Safety issues involving `ServerClients` would result in stray
  `NetworkClientInfo`'s not being removed from the list in certain
  situations. This is resolved by used a mutex to lock access to this
  from different threads.
2020-07-09 21:56:42 -05:00
Neel Chotai 263561868c fix musl compilation 2020-07-09 21:51:33 -05:00
Adam Honse 9bc58b039b Add Corsair Harpoon (non-Pro) to detected Corsair Peripheral list 2020-07-09 12:00:02 -05:00
Adam Honse 82c0ff8452 Add HyperX Alloy FPS to detected HyperX keyboard list 2020-07-08 11:43:41 -05:00
edbgon 2d7e996e4b Added initial support for SteelSeries Apex 7 Keyboard (Nordic model) 2020-07-08 03:22:03 -05:00
Adam Honse 0ae76e40c2 Add matrix map for Ducky One 2 TKL 2020-07-07 16:33:21 -05:00
Adam Honse 343c285321 Initial driver for Ducky One 2 keyboard 2020-07-07 13:15:02 -05:00
Adam Honse 6492852627 Add Corsair Harpoon RGB Pro to supported devices list 2020-07-07 01:20:56 -05:00
Adam Honse acc032a69c Adjust Polychrome speed 2020-07-06 13:17:39 -05:00
Adam Honse 950a3be01d More MSI Mystic Light cleanup 2020-07-06 03:45:45 -05:00
Adam Honse 6626321e80 Don't update NZXT fan status for any Hue 2 devices until we get initialization packet working 2020-07-06 02:13:00 -05:00
Adam Honse 7276f5e1d5 Add speed control to Polychrome controller 2020-07-06 02:03:47 -05:00
Adam Honse 5f9c4f8432 Code cleanup and rework for MSI Mystic Light controller
* Replace decimal constants with hexadecimal constants when ANDing/ORing values
* Add comments to explain what the code is doing
* Use C-style casts to fit the project standards
2020-07-05 18:27:51 -05:00
Adam Honse a1cd324731 Add comments and minor cleanup to Kraken driver 2020-07-05 12:12:07 -05:00
Adam Honse c2c5e6666d Fix previous commit 2020-07-05 12:04:35 -05:00
Adam Honse f7d6ede033 Update NZXT Hue 2 and Kraken detectors 2020-07-05 12:02:29 -05:00
Adam Honse 25f9e2a110 Add --client command line argument for opening network clients 2020-07-05 04:25:46 -05:00
Adam Honse 8ef6888a28 Add I2C byte operation to piix4 driver on Windows 2020-07-04 15:40:46 -05:00
B Horn 78a7be63ef Using the correct PID for the Steelseries 300 (0x1710) 2020-07-04 03:28:46 -05:00
Adam Honse f108515a6e Fix Set All Devices being slow and crashing on certain setups. It was sending the update multiple times 2020-07-03 02:59:54 -05:00
Adam Honse ad4e198aea Replace C-style clock() with std::chrono::steady_clock to fix timing on Linux 2020-07-02 16:59:30 -05:00
Adam Honse 5aad79135f Don't try to read fan status for Hue 2 devices without fan controllers 2020-07-01 19:25:29 -05:00
Adam Honse 5fc6981c16 Fix OpenRazer devices with logo/scroll/left/right matrix effect nodes on Windows 2020-06-30 18:11:15 -05:00
Adam Honse 942df26432 Update Readme 2020-06-30 18:10:44 -05:00
Adam Honse b3860be638 Bring in NZXT Hue 2 controller improvements from fan_devel branch 2020-06-28 23:44:35 -05:00
Adam Honse 8ecabb0789 Add 32-bit GitLab CI build target for Windows 2020-06-28 22:40:42 -05:00
Adam Honse d3fc88b24f Fix USB serial port detection in Windows. Fixes false Hue+ detection 2020-06-28 22:36:25 -05:00
Adam Honse dfb2e52e7b Add --i2c-tools to help text with warning, set GUI flag if --i2c-tools is specified 2020-06-28 21:41:00 -05:00
Adam Honse 96af869d79 Check for local server before detecting devices from hardware and tweak timeouts to make network connections faster 2020-06-28 21:08:59 -05:00
Adam Honse 4c6429ae76 Add OpenRGB client support to GUI 2020-06-28 17:57:27 -05:00
Adam Honse 7d2877a8e9 Don't exit after loading a profile from the command line 2020-06-28 11:21:56 -05:00
Adam Honse a25f3ef2fc GUI rework to provide more control over optional tabs to main.cpp, add TODO comments for client mode 2020-06-28 03:01:43 -05:00
Adam Honse 15ace9d094 Add flag to start application minimized to tray 2020-06-28 02:30:23 -05:00
Adam Honse 58aba0a147 Allow specifying --gui and --server together 2020-06-28 02:18:28 -05:00
323 changed files with 17628 additions and 3129 deletions
+105 -7
View File
@@ -4,6 +4,10 @@
# https://www.kittell.net/code/powershell-unix-sed-equivalent-change-text-file/
# https://powershell.org/forums/topic/how-to-use-ansi-vt100-formatting-in-powershell-ooh-pretty-colors/
#-----------------------------------------------------------------------#
# OpenRGB GitLab CI Configuration #
#-----------------------------------------------------------------------#
.shared_windows_runners:
tags:
- shared-windows
@@ -16,7 +20,26 @@ stages:
before_script:
- echo "started by ${GITLAB_USER_NAME}"
build_linux:
#-----------------------------------------------------------------------#
# Linux (AppImage) 32-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_32:
image: i386/ubuntu:bionic
stage: build
script:
- apt update
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
- ./scripts/build-appimage-32.sh
artifacts:
paths:
- OpenRGB-i386.AppImage
expire_in: 1337 years
#-----------------------------------------------------------------------#
# Linux (AppImage) 64-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_64:
image: ubuntu:bionic
stage: build
script:
@@ -28,8 +51,83 @@ build_linux:
paths:
- OpenRGB-x86_64.AppImage
expire_in: 1337 years
#-----------------------------------------------------------------------#
# Windows (32-bit) Build Target #
#-----------------------------------------------------------------------#
build_windows_32:
extends:
- .shared_windows_runners
stage: build
script:
- $esc = "$([char]27)"
- $count = 0
- function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds }
- function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; }
- function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; }
build_windows:
- _fold_start_ 'configuring the msvc environment variables'
- Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build"
- '& cmd.exe /C "vcvarsall.bat x86 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }'
- Pop-Location
- _fold_final_
- _fold_start_ 'downloading precompiled versions of qtbase, qttools (for windeployqt) and jom (for a more parallel nmake)'
- mkdir _qt
- mkdir _qt_download
- Push-Location _qt_download
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win32_msvc2019/5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win32_msvc2019/5.15.0-0-202005150700qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86.7z'
- curl.exe -LJ -o qt-jom.zip 'https://download.qt.io/official_releases/jom/jom.zip'
- _fold_final_
- _fold_start_ 'extracting the downloaded qt binaries'
- 7z x qt-base.7z '-o../_qt' -y
- 7z x qt-tools.7z '-o../_qt' -y
- 7z x qt-jom.zip '-o../_qt' -y
- _fold_final_
- _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019\mkspecs\qconfig.pri'
- (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder}
- (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder}
- Pop-Location
- _fold_final_
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
- mkdir _build; cd _build
- ..\_qt\5.15.0\msvc2019\bin\qmake ..\OpenRGB.pro
- _fold_final_
- _fold_start_ 'start the actual build with jom instead of nmake; for speed'
- ..\_qt\jom
- _fold_final_
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
- ..\_qt\5.15.0\msvc2019\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- _fold_final_
- _fold_start_ 'compressing the release folder so that we can upload it as artifact'
- mv release 'OpenRGB Windows 32-bit'
- ${datetime} = Get-Date ([datetime]::UtcNow) -Format "yyyy-MM-ddTHH-mm-ss"
- ${revision} = ((git rev-parse --short HEAD) | Out-String).Trim()
- ${rversion} = (((Get-Content '..\OpenRGB.pro' | Select-String -Pattern "VERSION =") | Out-String).Trim().Split("="))[1].Trim()
- 7z a -mx9 -r -y "OpenRGB_${rversion}_32_${revision}_nightly_${datetime}.7z" 'OpenRGB Windows 32-bit'
- _fold_final_
# cache:
# key: same-key
# paths:
# - C:\vcpkg\installed\
artifacts:
paths:
- _build/*.7z
expire_in: 1337 years
#-----------------------------------------------------------------------#
# Windows (64-bit) Build Target #
#-----------------------------------------------------------------------#
build_windows_64:
extends:
- .shared_windows_runners
stage: build
@@ -51,8 +149,8 @@ build_windows:
- mkdir _qt
- mkdir _qt_download
- Push-Location _qt_download
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qtbase-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2017_64/5.15.0-0-202002260536qttools-Windows-Windows_10-MSVC2017-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-base.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2019_64/5.15.0-0-202005150700qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-tools.7z 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5150/qt.qt5.5150.win64_msvc2019_64/5.15.0-0-202005150700qttools-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'
- curl.exe -LJ -o qt-jom.zip 'https://download.qt.io/official_releases/jom/jom.zip'
- _fold_final_
@@ -63,7 +161,7 @@ build_windows:
- _fold_final_
- _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2017_64\mkspecs\qconfig.pri'
- ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019_64\mkspecs\qconfig.pri'
- (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder}
- (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder}
- Pop-Location
@@ -71,7 +169,7 @@ build_windows:
- _fold_start_ 'run qmake and generate the msvc nmake makefile'
- mkdir _build; cd _build
- ..\_qt\5.15.0\msvc2017_64\bin\qmake ..\OpenRGB.pro
- ..\_qt\5.15.0\msvc2019_64\bin\qmake ..\OpenRGB.pro
- _fold_final_
- _fold_start_ 'start the actual build with jom instead of nmake; for speed'
@@ -79,7 +177,7 @@ build_windows:
- _fold_final_
- _fold_start_ 'run windeployqt to automatically copy the needed dll files'
- ..\_qt\5.15.0\msvc2017_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- ..\_qt\5.15.0\msvc2019_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\
- _fold_final_
- _fold_start_ 'compressing the release folder so that we can upload it as artifact'
+83
View File
@@ -19,6 +19,11 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", TAG+="uaccess"
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0051", TAG+="uaccess"
#---------------------------------------------------------------#
# Aorus Devices #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="1044", ATTR{idProduct}=="7a42", TAG+="uaccess"
#---------------------------------------------------------------#
# ASUS Aura Core Devices #
#---------------------------------------------------------------#
@@ -43,6 +48,17 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0b05", ATTR{idProduct}=="18f3", TAG+="uacces
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="2516", ATTR{idProduct}=="0109", TAG+="uaccess"
#---------------------------------------------------------------#
# Corsair Hydro Series Devices #
# #
# Corsair H100i Pro RGB #
# Corsair H115i Pro RGB #
# Corsair H150i Pro RGB #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c15", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c13", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1b1c", ATTR{idProduct}=="0c12", TAG+="uaccess"
#---------------------------------------------------------------#
# Corsair Lighting Node Devices #
# #
@@ -126,12 +142,78 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="0951", ATTR{idProduct}=="16be", TAG+="uacces
# #
# Mice: #
# Logitech G203 Prodigy #
# Logitech G203 Lightsync #
# Logitech G403 Prodigy #
# Logitech G403 Hero #
# Logitech G502 Proteus Spectrum #
# Logitech G Lightspeed Wireless Gaming Mouse #
# Logitech G Pro Wireless Gaming Mouse (Wired) #
# Logitech G Powerplay Mousepad with Lightspeed #
# #
# Keyboards: #
# Logitech G512 #
# Logitech G512 RGB #
# Logitech G810 #1 #
# Logitech G810 #2 #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c084", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c092", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c083", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c08f", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c332", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c539", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c088", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c53a", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c342", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c33c", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c337", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="046d", ATTR{idProduct}=="c331", TAG+="uaccess"
#---------------------------------------------------------------#
# MSI Mysticlight #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="3EA4", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="4559", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B10", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B93", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B94", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7B96", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C34", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C35", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C36", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C37", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C42", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C56", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C59", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C60", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C67", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C70", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C71", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C73", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C75", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C76", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C77", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C79", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C80", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C81", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C82", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C83", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C84", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C85", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C86", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C87", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C88", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C89", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C90", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C91", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C92", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C94", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C95", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C96", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C98", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="7C99", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="905D", TAG+="uaccess"
#---------------------------------------------------------------#
# MSI/SteelSeries 3-Zone Laptop Keyboard #
@@ -177,6 +259,7 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="04d9", ATTR{idProduct}=="fc39", TAG+="uacces
# Gigabyte/Aorus RGB Fusion 2 USB #
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="8297", TAG+="uaccess"
SUBSYSTEMS=="usb", ATTR{idVendor}=="048d", ATTR{idProduct}=="5702", TAG+="uaccess"
#---------------------------------------------------------------#
# SteelSeries Peripheral Devices #
@@ -49,6 +49,7 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
unsigned char usb_buf[] =
{
0x00,
0x40, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -67,9 +68,9 @@ std::string AMDWraithPrismController::GetEffectChannelString(unsigned char chann
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x02] = channel;
usb_buf[0x03] = channel;
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
ret_string.append((char *)&usb_buf[0x08]);
@@ -83,6 +84,7 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
unsigned char usb_buf[] =
{
0x00,
0x12, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -103,7 +105,7 @@ std::string AMDWraithPrismController::GetFirmwareVersionString()
unsigned char fw_buf[16] = {0x00};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
for(int char_idx = 0; char_idx < 16; char_idx+=2)
@@ -206,6 +208,7 @@ void AMDWraithPrismController::SendEnableCommand()
{
unsigned char usb_buf[] =
{
0x00,
0x41, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -224,7 +227,7 @@ void AMDWraithPrismController::SendEnableCommand()
0x00, 0x00, 0x00, 0x00,
};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -232,6 +235,7 @@ void AMDWraithPrismController::SendApplyCommand()
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0x28, 0x00, 0x00,
0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
@@ -250,7 +254,7 @@ void AMDWraithPrismController::SendApplyCommand()
0x00, 0x00, 0x00, 0x00,
};
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -269,6 +273,7 @@ void AMDWraithPrismController::SendEffectChannelUpdate
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0x2C, 0x01, 0x00,
0x05, 0xFF, 0x00, 0x01,
0xFF, 0xFF, 0x00, 0xFF,
@@ -287,18 +292,18 @@ void AMDWraithPrismController::SendEffectChannelUpdate
0xFF, 0xFF, 0xFF, 0xFF
};
usb_buf[0x04] = effect_channel;
usb_buf[0x05] = speed;
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x07] = mode;
usb_buf[0x05] = effect_channel;
usb_buf[0x06] = speed;
usb_buf[0x07] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x08] = mode;
usb_buf[0x09] = brightness;
usb_buf[0x0A] = brightness;
usb_buf[0x0A] = red;
usb_buf[0x0B] = green;
usb_buf[0x0C] = blue;
usb_buf[0x0B] = red;
usb_buf[0x0C] = green;
usb_buf[0x0D] = blue;
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -306,6 +311,7 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
{
unsigned char usb_buf[] =
{
0x00,
0x51, 0xA0, 0x01, 0x00,
0x00, 0x03, 0x00, 0x00,
0x05, 0x06, 0x07, 0x07,
@@ -324,14 +330,14 @@ void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsi
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x08] = logo_channel;
usb_buf[0x09] = fan_channel;
usb_buf[0x09] = logo_channel;
usb_buf[0x0A] = fan_channel;
for(int led = 0x0A; led <= 0x18; led++)
for(int led = 0x0B; led <= 0x19; led++)
{
usb_buf[led] = ring_channel;
}
hid_write(dev, usb_buf, 64);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 64);
}
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "AMDWraithPrismController.h"
#include "RGBController.h"
#include "RGBController_AMDWraithPrism.h"
@@ -28,23 +29,26 @@ void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controller
{
if((info->vendor_id == AMD_WRAITH_PRISM_VID)
&&(info->product_id == AMD_WRAITH_PRISM_PID)
#if USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
if( dev )
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
REGISTER_DETECTOR("AMD Wraith Prism", DetectAMDWraithPrismControllers);
@@ -0,0 +1,116 @@
/*-----------------------------------------*\
| ATC800Controller.cpp |
| |
| Driver for Aorus ATC800 CPU Cooler |
| |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#include "ATC800Controller.h"
#include <cstring>
ATC800Controller::ATC800Controller(hid_device* dev_handle)
{
dev = dev_handle;
}
ATC800Controller::~ATC800Controller()
{
hid_close(dev);
}
void ATC800Controller::SendCoolerMode
(
unsigned char mode,
unsigned short /*speed*/,
unsigned char channel,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[9];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
if (channel == AORUS_ATC800_TOP_ZONE)
{
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xbe;
usb_buf[0x08] = 0xcc;
hid_send_feature_report(dev, usb_buf, 9);
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xc9;
usb_buf[0x02] = mode;
usb_buf[0x03] = 0x3c;
usb_buf[0x04] = 0x02;
usb_buf[0x05] = 0x00;
usb_buf[0x06] = 0x00;
hid_send_feature_report(dev, usb_buf, 9);
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xbc;
usb_buf[0x02] = red;
usb_buf[0x03] = green;
usb_buf[0x04] = blue;
hid_send_feature_report(dev, usb_buf, 9);
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xb6;
}
else if (channel == AORUS_ATC800_FANS_ZONE)
{
hid_send_feature_report(dev, usb_buf, 9);
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xc9;
usb_buf[0x02] = mode;
usb_buf[0x03] = 0x3c;
usb_buf[0x04] = 0x02;
usb_buf[0x05] = 0x00;
usb_buf[0x06] = 0x01;
hid_send_feature_report(dev, usb_buf, 9);
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xb0;
usb_buf[0x02] = mode;
usb_buf[0x03] = red;
usb_buf[0x04] = green;
usb_buf[0x05] = blue;
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
for(int i = 0xb0; i <= 0xb3; i++)
{
usb_buf[0x01] = i; //zone b0->b3
hid_send_feature_report(dev, usb_buf, 9);
}
}
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0xb6;
hid_send_feature_report(dev, usb_buf, 9);
}
@@ -0,0 +1,59 @@
/*-----------------------------------------*\
| ATC800Controller.h |
| |
| Definitions and types for ATC800 CPU |
| Cooler |
| |
| Felipe Cavalcanti 08/13/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
AORUS_ATC800_MODE_OFF = 0x00,
AORUS_ATC800_MODE_STATIC = 0x01,
AORUS_ATC800_MODE_PULSE = 0x02,
AORUS_ATC800_MODE_FLASHING = 0x04,
AORUS_ATC800_MODE_DOUBLE_FLASH = 0x05,
};
enum
{
AORUS_ATC800_SPEED_SLOWEST = 0x00, /* Slowest speed */
AORUS_ATC800_SPEED_SLOW = 0x01, /* Slow speed */
AORUS_ATC800_SPEED_NORMAL = 0x02, /* Normal speed */
AORUS_ATC800_SPEED_FAST = 0x03, /* Fast speed */
AORUS_ATC800_SPEED_FASTEST = 0x04, /* Fastest speed */
};
enum
{
AORUS_ATC800_FANS_ZONE = 0,
AORUS_ATC800_TOP_ZONE = 1
};
class ATC800Controller
{
public:
ATC800Controller(hid_device* dev_handle);
~ATC800Controller();
void SendCoolerMode
(
unsigned char mode,
unsigned short speed,
unsigned char channel,
unsigned char red,
unsigned char green,
unsigned char blue
);
private:
hid_device* dev;
};
@@ -0,0 +1,87 @@
#include "Detector.h"
#include "RGBController.h"
#include "ATC800Controller.h"
#include "RGBController_AorusATC800.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Vendor ID |
\*-----------------------------------------------------*/
#define HOLTEK_VID 0x1044
/*-----------------------------------------------------*\
| Controller product ids |
\*-----------------------------------------------------*/
#define ATC_800_CONTROLLER_PID 0x7A42
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
char usb_interface;
device_type type;
const char * name;
} device;
#define NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const device device_list[] =
{
{ HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, DEVICE_TYPE_KEYBOARD, "Aorus ATC800 CPU Cooler" },
};
/******************************************************************************************\
* *
* DetectAorusCPUCoolerControllers *
* *
* Tests the USB address to see if a Aorus RGB CPU Cooler exists there. *
* *
\******************************************************************************************/
void DetectAorusCPUCoolerControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_init();
for(unsigned int device_idx = 0; device_idx < NUM_DEVICES; device_idx++)
{
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF01)
&&(info->usage == 1))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
switch(device_list[device_idx].usb_pid)
{
case ATC_800_CONTROLLER_PID:
{
ATC800Controller* controller = new ATC800Controller(dev);
RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
}
info = info->next;
}
hid_free_enumeration(info);
}
}
REGISTER_DETECTOR("Aorus CPU Coolers", DetectAorusCPUCoolerControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "AuraCoreController.h"
#include "RGBController.h"
#include "RGBController_AuraCore.h"
@@ -43,3 +44,5 @@ void DetectAuraCoreControllers(std::vector<RGBController*>& rgb_controllers)
}
}
}
REGISTER_DETECTOR("ASUS Aura Core", DetectAuraCoreControllers);
@@ -6,6 +6,7 @@
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "Detector.h"
#include "AuraGPUController.h"
#include "RGBController.h"
#include "RGBController_AuraGPU.h"
@@ -82,4 +83,6 @@ void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
std::this_thread::sleep_for(1ms);
}
}
} /* DetectAuraGPUControllers() */
} /* DetectAuraGPUControllers() */
REGISTER_I2C_DETECTOR("ASUS Aura GPU", DetectAuraGPUControllers);
@@ -10,6 +10,21 @@
#include "AuraSMBusController.h"
#include <cstring>
static const char* aura_channels[] = /* Aura channel strings */
{
"Audio",
"Backplate",
"Back I/O",
"Center",
"Center",
"DRAM",
"PCIe",
"RGB Header",
"RGB Header 2",
"RGB Header",
"Unknown",
};
AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id dev)
{
this->bus = bus;
@@ -45,7 +60,7 @@ AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id d
{
direct_reg = AURA_REG_COLORS_DIRECT_V2;
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V1;
}
// AUMA0-E6K5-0106 - Second generation motherboard controller
else if (strcmp(device_name, "AUMA0-E6K5-0106") == 0)
@@ -68,6 +83,13 @@ AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id d
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
}
// AUMA0-E8K4-0101 - Second generation motherboard controller
else if (strcmp(device_name, "AUMA0-E8K4-0101") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT_V2;
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
}
// Assume first generation controller if string does not match
else
{
@@ -66,21 +66,6 @@ enum
AURA_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
};
static const char* aura_channels[] = /* Aura channel strings */
{
"Audio",
"Backplate",
"Back I/O",
"Center",
"Center",
"DRAM",
"PCIe",
"RGB Header",
"RGB Header 2",
"RGB Header",
"Unknown",
};
enum
{
AURA_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "AuraSMBusController.h"
#include "RGBController.h"
#include "RGBController_AuraSMBus.h"
@@ -11,7 +12,7 @@ using namespace std::chrono_literals;
/*----------------------------------------------------------------------*\
| This list contains the available SMBus addresses for mapping Aura RAM |
\*----------------------------------------------------------------------*/
#define AURA_RAM_ADDRESS_COUNT 22
#define AURA_RAM_ADDRESS_COUNT 23
static const unsigned char aura_ram_addresses[] =
{
@@ -34,6 +35,7 @@ static const unsigned char aura_ram_addresses[] =
0x66,
0x67,
0x39,
0x3A,
0x3B,
0x3C,
0x3D
@@ -187,3 +189,5 @@ void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::
}
} /* DetectAuraSMBusControllers() */
REGISTER_I2C_DETECTOR("ASUS Aura SMBus", DetectAuraSMBusControllers);
@@ -40,7 +40,7 @@ void AuraAddressableController::SetChannelLEDs(unsigned char channel, RGBColor *
leds_to_send = num_colors - leds_sent;
}
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
{
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
@@ -44,7 +44,7 @@ void AuraMainboardController::SetChannelLEDs(unsigned char channel, RGBColor * c
leds_to_send = num_colors - leds_sent;
}
for(int led_idx = 0; led_idx < leds_to_send; led_idx++)
for(unsigned int led_idx = 0; led_idx < leds_to_send; led_idx++)
{
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx + leds_sent]);
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx + leds_sent]);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "AuraAddressableController.h"
#include "AuraMainboardController.h"
#include "RGBController.h"
@@ -74,4 +75,6 @@ void DetectAuraUSBControllers(std::vector<RGBController*>& rgb_controllers)
}
}
}
}
} /* DetectAuraUSBControllers() */
REGISTER_DETECTOR("ASUS Aura USB", DetectAuraUSBControllers);
@@ -9,23 +9,40 @@
#include "CMMP750Controller.h"
static unsigned char colour_mode_data[][6] =
{
{ 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */
{ 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */
{ 0x03, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Breathing */
{ 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */
{ 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */
};
static unsigned char speed_mode_data[][9] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Blinking */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Breathing */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Colour Cycle */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 } /* Colour Breath */
};
CMMP750Controller::CMMP750Controller(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path)
{
int tmp_size = wcslen(_vendor);
std::size_t tmp_size = wcslen(_vendor);
dev = dev_handle;
location = _path;
dev = dev_handle;
for (int i=0; ( i<tmp_size && i<CM_DEVICE_NAME_SIZE); i++)
for(std::size_t i = 0; (i < tmp_size) && (i < CM_DEVICE_NAME_SIZE); i++)
{
device_name[i] = (char)_vendor[i];
}
for (int j=0; ( j<wcslen(_vendor) && tmp_size+j<CM_DEVICE_NAME_SIZE); j++)
device_name[tmp_size+j] = (char)_device_name[j];
for(std::size_t j = 0; (j < wcslen(_vendor)) && (tmp_size + j < CM_DEVICE_NAME_SIZE); j++)
{
device_name[tmp_size + j] = (char)_device_name[j];
}
location = _path;
current_mode = MP750_MODE_STATIC;
current_speed = MP750_SPEED_NORMAL;
GetStatus(); //When setting up device get current status
}
CMMP750Controller::~CMMP750Controller()
@@ -33,6 +50,38 @@ CMMP750Controller::~CMMP750Controller()
hid_close(dev);
}
void CMMP750Controller::GetStatus()
{
unsigned char buffer[0x40] = { 0x00 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
buffer[0] = 0x07;
hid_write(dev, buffer, buffer_size);
hid_read(dev, buffer, buffer_size);
if((buffer[0] == 0x80) && (buffer[1] == 0x05))
{
current_mode = buffer[2] - 1;
current_red = buffer[3];
current_green = buffer[4];
current_blue = buffer[5];
for(int i = 0; speed_mode_data[current_mode][i] >= buffer[6]; i++)
{
current_speed = i;
}
}
else
{
//Code should never reach here however just in case there is a failure set something
current_mode = MP750_MODE_COLOR_CYCLE; //Unicorn Spew
current_red = 0xFF;
current_green = 0xFF;
current_blue = 0xFF;
current_speed = MP750_SPEED_NORMAL;
}
}
char* CMMP750Controller::GetDeviceName()
{
return device_name;
@@ -48,6 +97,31 @@ std::string CMMP750Controller::GetLocation()
return location;
}
unsigned char CMMP750Controller::GetMode()
{
return current_mode;
}
unsigned char CMMP750Controller::GetLedRed()
{
return current_red;
}
unsigned char CMMP750Controller::GetLedGreen()
{
return current_green;
}
unsigned char CMMP750Controller::GetLedBlue()
{
return current_blue;
}
unsigned char CMMP750Controller::GetLedSpeed()
{
return current_speed;
}
void CMMP750Controller::SetMode(unsigned char mode, unsigned char speed)
{
current_mode = mode;
@@ -70,7 +144,7 @@ void CMMP750Controller::SendUpdate()
unsigned char buffer[0x40] = { 0x00 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
for(int i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++)
for(std::size_t i = 0; i < CM_COLOUR_MODE_DATA_SIZE; i++)
{
buffer[i] = colour_mode_data[current_mode][i];
}
@@ -78,16 +152,16 @@ void CMMP750Controller::SendUpdate()
if(current_mode > MP750_MODE_BREATHING)
{
//If the mode is random colours set SPEED at BYTE2
buffer[CM_RED_BYTE] = speed_mode_data[current_mode][current_speed];
buffer[CM_RED_BYTE] = speed_mode_data[current_mode][current_speed];
}
else
{
//Otherwise SPEED is BYTE5
buffer[CM_RED_BYTE] = current_red;
buffer[CM_GREEN_BYTE] = current_green;
buffer[CM_BLUE_BYTE] = current_blue;
buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
buffer[CM_RED_BYTE] = current_red;
buffer[CM_GREEN_BYTE] = current_green;
buffer[CM_BLUE_BYTE] = current_blue;
buffer[CM_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
}
hid_write(dev, buffer, buffer_size);
}
}
@@ -20,7 +20,7 @@
#pragma once
#define CM_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data) / sizeof(colour_mode_data[0]))
#define CM_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
#define CM_INTERRUPT_TIMEOUT 250
#define CM_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
#define CM_SERIAL_SIZE (sizeof(serial) / sizeof(serial[ 0 ]))
@@ -44,24 +44,6 @@ enum
MP750_MODE_BREATH_CYCLE = 0x04 //Breathing Cycle Mode
};
static unsigned char colour_mode_data[][6] =
{
{ 0x01, 0x04, 0xFF, 0x00, 0xFF, 0x00 }, /* Static */
{ 0x02, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Blinking */
{ 0x03, 0x04, 0xFF, 0x00, 0xFF, 0x80 }, /* Breathing */
{ 0x04, 0x04, 0x80, 0x00, 0x00, 0x00 }, /* Colour Cycle */
{ 0x05, 0x04, 0x80, 0x00, 0x00, 0x00 } /* Colour Breath */
};
static unsigned char speed_mode_data[][9] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },/* Static */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Blinking */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Breathing */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 },/* Colour Cycle */
{ 0xFF, 0xE0, 0xC0, 0xA0, 0x80, 0x60, 0x40, 0x20, 0x00 } /* Colour Breath */
};
enum
{
MP750_SPEED_SLOWEST = 0x00, /* Slowest speed */
@@ -85,6 +67,11 @@ public:
char* GetSerial();
std::string GetLocation();
unsigned char GetMode();
unsigned char GetLedRed();
unsigned char GetLedGreen();
unsigned char GetLedBlue();
unsigned char GetLedSpeed();
void SetMode(unsigned char mode, unsigned char speed);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
@@ -101,5 +88,6 @@ private:
unsigned char current_green;
unsigned char current_blue;
void GetStatus();
void SendUpdate();
};
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CMMP750Controller.h"
#include "RGBController.h"
#include "RGBController_CMMP750Controller.h"
@@ -36,14 +37,14 @@ void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
//Look for the passed in cm_pids
hid_init();
info = hid_enumerate(0x0, 0x0);
info = hid_enumerate(COOLERMASTER_VID, 0x0);
while(info)
{
hid_device* dev = NULL;
if(info->vendor_id == COOLERMASTER_VID)
{
for(int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
for(unsigned int cm_pid_idx = 0; cm_pid_idx < COOLERMASTER_NUM_DEVICES; cm_pid_idx++)
{
if((info->product_id == cm_pids[cm_pid_idx][CM_PID])
&&(info->interface_number == cm_pids[cm_pid_idx][CM_INTERFACE]))
@@ -56,11 +57,13 @@ void DetectCoolerMasterControllers(std::vector<RGBController*>& rgb_controllers)
if(dev)
{
CMMP750Controller* controller = new CMMP750Controller(dev, info->manufacturer_string, info->product_string, info->path);
CMMP750Controller* controller = new CMMP750Controller(dev, info->manufacturer_string, info->product_string, info->path);
RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller);
rgb_controllers.push_back(rgb_controller);
}
info = info->next;
}
hid_free_enumeration(info);
}
} /* DetectCoolerMasterControllers() */
REGISTER_DETECTOR("Cooler Master", DetectCoolerMasterControllers);
@@ -0,0 +1,251 @@
/*---------------------------------------------------------*\
| Processing Code for Corsair Hydro Series |
| |
| Adam Honse ([email protected]), 8/17/2020 |
\*---------------------------------------------------------*/
#include "CorsairHydroController.h"
#include <cstring>
CorsairHydroController::CorsairHydroController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
SendInit();
SendFirmwareRequest();
}
std::string CorsairHydroController::GetFirmwareString()
{
return(firmware_version);
}
void CorsairHydroController::SetBlink
(
std::vector<RGBColor> & colors,
unsigned char speed
)
{
SendColors(colors);
SendSpeed(speed);
SendApplyBlink();
}
void CorsairHydroController::SetFixed
(
std::vector<RGBColor> & colors
)
{
SendColors(colors);
/*-----------------------------------------------------*\
| Fixed mode seems to just be shift mode with the same |
| value for both colors |
\*-----------------------------------------------------*/
SendApplyShift();
}
void CorsairHydroController::SetPulse
(
std::vector<RGBColor> & colors,
unsigned char speed
)
{
SendColors(colors);
SendSpeed(speed);
SendApplyPulse();
}
void CorsairHydroController::SetShift
(
std::vector<RGBColor> & colors,
unsigned char speed
)
{
SendColors(colors);
SendSpeed(speed);
SendApplyShift();
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairHydroController::SendApplyBlink()
{
unsigned char usb_buf[3];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Apply Blink packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x58;
usb_buf[1] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
void CorsairHydroController::SendApplyPulse()
{
unsigned char usb_buf[3];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Apply Pulse packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x52;
usb_buf[1] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
void CorsairHydroController::SendApplyShift()
{
unsigned char usb_buf[3];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Apply Shift packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x55;
usb_buf[1] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
void CorsairHydroController::SendFirmwareRequest()
{
unsigned char usb_buf[8];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Firmware Request packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0xAA;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 1, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 7, &actual, 1000);
firmware_version = std::to_string(usb_buf[3]) + "." + std::to_string(usb_buf[4]) + "." + std::to_string(usb_buf[5]) + "." + std::to_string(usb_buf[6]);
}
void CorsairHydroController::SendColors
(
std::vector<RGBColor> & colors
)
{
unsigned char usb_buf[23];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Send Colors packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x56;
usb_buf[1] = colors.size();
/*---------------------------------------------------------*\
| Fill in colors from vector |
\*---------------------------------------------------------*/
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
{
usb_buf[(color_idx * 3) + 2] = RGBGetRValue(colors[color_idx]);
usb_buf[(color_idx * 3) + 3] = RGBGetGValue(colors[color_idx]);
usb_buf[(color_idx * 3) + 4] = RGBGetBValue(colors[color_idx]);
/*---------------------------------------------------------*\
| If the color vector only has one entry, duplicate it, as |
| the controller appears to require two colors in order to |
| update. |
\*---------------------------------------------------------*/
if((color_idx == 0) && colors.size() == 1)
{
usb_buf[1] = colors.size() + 1;
usb_buf[(color_idx * 3) + 5] = RGBGetRValue(colors[color_idx]);
usb_buf[(color_idx * 3) + 6] = RGBGetGValue(colors[color_idx]);
usb_buf[(color_idx * 3) + 7] = RGBGetBValue(colors[color_idx]);
}
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2 + (usb_buf[1] * 3), &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
void CorsairHydroController::SendInit()
{
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_control_transfer( dev, 0x40, 0x00, 0xffff, 0x0000, NULL, 0, 0 );
libusb_control_transfer( dev, 0x40, 0x02, 0x0002, 0x0000, NULL, 0, 0 );
}
void CorsairHydroController::SendSpeed
(
unsigned char speed
)
{
unsigned char usb_buf[3];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Send Speed packet |
\*-----------------------------------------------------*/
usb_buf[0] = 0x53;
usb_buf[1] = speed;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
@@ -0,0 +1,86 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Hydro Series |
| |
| Adam Honse ([email protected]), 8/17/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_HYDRO_CMD_READ_PUMP_SPEED = 0x31,
CORSAIR_HYDRO_CMD_WRITE_PUMP_MODE = 0x32,
CORSAIR_HYDRO_CMD_READ_PUMP_MODE = 0x33,
CORSAIR_HYDRO_CMD_READ_FAN_SPEED = 0x41,
CORSAIR_HYDRO_CMD_READ_AIO_TEMP = 0xA9,
CORSAIR_HYDRO_CMD_READ_FIRMWARE = 0xAA,
};
enum
{
CORSAIR_HYDRO_PUMP_MODE_QUIET = 0x00,
CORSAIR_HYDRO_PUMP_MODE_BALANCED = 0x01,
CORSAIR_HYDRO_PUMP_MODE_PERFORMANCE = 0x02,
};
class CorsairHydroController
{
public:
CorsairHydroController(libusb_device_handle* dev_handle);
~CorsairHydroController();
unsigned char GetFanPercent(unsigned char fan_channel);
unsigned short GetFanRPM(unsigned char fan_channel);
std::string GetFirmwareString();
void SetBlink
(
std::vector<RGBColor> & colors,
unsigned char speed
);
void SetFixed
(
std::vector<RGBColor> & colors
);
void SetPulse
(
std::vector<RGBColor> & colors,
unsigned char speed
);
void SetShift
(
std::vector<RGBColor> & colors,
unsigned char speed
);
private:
libusb_device_handle* dev;
std::string firmware_version;
void SendApplyBlink();
void SendApplyPulse();
void SendApplyShift();
void SendColors
(
std::vector<RGBColor> & colors
);
void SendFirmwareRequest();
void SendInit();
void SendSpeed
(
unsigned char speed
);
};
@@ -0,0 +1,74 @@
#include "Detector.h"
#include "CorsairHydroController.h"
#include "RGBController.h"
#include "RGBController_CorsairHydro.h"
#include <vector>
#include <libusb-1.0/libusb.h>
/*-----------------------------------------------------*\
| Corsair vendor ID |
\*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\
| Keyboard Hydro Series product IDs |
\*-----------------------------------------------------*/
#define CORSAIR_H115I_PRO_RGB_PID 0x0C13
#define CORSAIR_H100I_PRO_RGB_PID 0x0C15
#define CORSAIR_H150I_PRO_RGB_PID 0x0C12
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
const char * name;
} corsair_hydro_device;
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const corsair_hydro_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Coolers |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_H100I_PRO_RGB_PID, 0, "Corsair H100i PRO RGB" },
{ CORSAIR_VID, CORSAIR_H115I_PRO_RGB_PID, 0, "Corsair H115i PRO RGB" },
{ CORSAIR_VID, CORSAIR_H150I_PRO_RGB_PID, 0, "Corsair H150i PRO RGB" },
};
/******************************************************************************************\
* *
* DetectCorsairHydroControllers *
* *
* Tests the USB address to see if a Corsair RGB Cooler controller exists there. *
* *
\******************************************************************************************/
void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
{
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Corsair RGB Peripheral
if(dev)
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairHydroController* controller = new CorsairHydroController(dev);//, device_list[device_idx].usb_endpoint);
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
} /* DetectCorsairHydroControllers() */
REGISTER_DETECTOR("Corsair Hydro Series", DetectCorsairHydroControllers);
@@ -65,7 +65,7 @@ void CorsairLightingNodeController::KeepaliveThread()
{
while(1)
{
if((clock() - last_commit_time) > 5000)
if((std::chrono::steady_clock::now() - last_commit_time) > std::chrono::seconds(5))
{
SendCommit();
}
@@ -198,7 +198,7 @@ void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBCol
void CorsairLightingNodeController::SendFirmwareRequest()
{
int actual;
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -208,13 +208,14 @@ void CorsairLightingNodeController::SendFirmwareRequest()
/*-----------------------------------------------------*\
| Set up Firmware Version Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
actual = hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
actual = hid_read(dev, usb_buf, 17);
if(actual > 0)
{
@@ -231,7 +232,7 @@ void CorsairLightingNodeController::SendDirect
unsigned char* color_data
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -241,27 +242,28 @@ void CorsairLightingNodeController::SendDirect
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x02] = channel;
usb_buf[0x03] = start;
usb_buf[0x04] = count;
usb_buf[0x05] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
memcpy(&usb_buf[0x06], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendCommit()
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -271,19 +273,20 @@ void CorsairLightingNodeController::SendCommit()
/*-----------------------------------------------------*\
| Update last commit time |
\*-----------------------------------------------------*/
last_commit_time = clock();
last_commit_time = std::chrono::steady_clock::now();
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x02] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBegin
@@ -291,7 +294,7 @@ void CorsairLightingNodeController::SendBegin
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -301,14 +304,15 @@ void CorsairLightingNodeController::SendBegin
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendEffectConfig
@@ -334,7 +338,7 @@ void CorsairLightingNodeController::SendEffectConfig
unsigned short temperature_2
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -344,48 +348,49 @@ void CorsairLightingNodeController::SendEffectConfig
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count;
usb_buf[0x03] = led_type;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x02] = channel;
usb_buf[0x03] = count;
usb_buf[0x04] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
usb_buf[0x05] = mode;
usb_buf[0x06] = speed;
usb_buf[0x07] = direction;
usb_buf[0x08] = change_style;
usb_buf[0x09] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x0A] = color_0_green;
usb_buf[0x0B] = color_0_blue;
usb_buf[0x0C] = color_1_red;
usb_buf[0x0D] = color_1_green;
usb_buf[0x0E] = color_1_blue;
usb_buf[0x0F] = color_2_red;
usb_buf[0x10] = color_2_green;
usb_buf[0x11] = color_2_blue;
usb_buf[0x0A] = color_0_red;
usb_buf[0x0B] = color_0_green;
usb_buf[0x0C] = color_0_blue;
usb_buf[0x0D] = color_1_red;
usb_buf[0x0E] = color_1_green;
usb_buf[0x0F] = color_1_blue;
usb_buf[0x10] = color_2_red;
usb_buf[0x11] = color_2_green;
usb_buf[0x12] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
usb_buf[0x13] = (temperature_0 >> 8);
usb_buf[0x14] = (temperature_0 & 0xFF);
usb_buf[0x15] = (temperature_1 >> 8);
usb_buf[0x16] = (temperature_1 & 0xFF);
usb_buf[0x17] = (temperature_2 >> 8);
usb_buf[0x18] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendTemperature()
@@ -398,7 +403,7 @@ void CorsairLightingNodeController::SendReset
unsigned char channel
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -408,14 +413,15 @@ void CorsairLightingNodeController::SendReset
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x01] = channel;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x02] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendPortState
@@ -424,7 +430,7 @@ void CorsairLightingNodeController::SendPortState
unsigned char state
)
{
unsigned char usb_buf[64];
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -434,15 +440,16 @@ void CorsairLightingNodeController::SendPortState
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x02] = channel;
usb_buf[0x03] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 16);
hid_write(dev, usb_buf, 65);
hid_read(dev, usb_buf, 17);
}
void CorsairLightingNodeController::SendBrightness()
@@ -5,6 +5,7 @@
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <chrono>
#include <vector>
#include <hidapi/hidapi.h>
@@ -109,7 +110,7 @@ public:
private:
hid_device* dev;
std::string firmware_version;
clock_t last_commit_time;
std::chrono::time_point<std::chrono::steady_clock> last_commit_time;
void SendFirmwareRequest();
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CorsairLightingNodeController.h"
#include "RGBController.h"
#include "RGBController_CorsairLightingNode.h"
@@ -77,3 +78,5 @@ void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_contr
}
}
} /* DetectCorsairLightingNodeControllers() */
REGISTER_DETECTOR("Corsair Lighting Node", DetectCorsairLightingNodeControllers);
@@ -22,29 +22,38 @@ static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141};
static unsigned int keys_k95_plat[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141,
0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46,
144, 145, 146, 158, 160, 147, 148, 149, 150, 151, 152, 153,
154, 155, 159, 162, 161, 156, 157};
static unsigned int keys_k95[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141,
0x10, 114, 0x0a, 0x16, 0x22, 0x2e, 0x3a, 0x46, 0x52, 0x5e, 0x6a, 0x76, 0x3b, 0x47, 0x53,
0x5f, 0x6b, 0x77, 0x83, 0x8f, 0x0b, 0x17, 0x23, 0x2f};
static unsigned int st100[] = { 0x00, 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x08, 0x04 };
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
std::this_thread::sleep_for(1ms);
}
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
{
dev = dev_handle;
ReadFirmwareInfo();
SpecialFunctionControl();
LightingControl();
}
@@ -58,6 +67,16 @@ device_type CorsairPeripheralController::GetDeviceType()
return type;
}
int CorsairPeripheralController::GetPhysicalLayout()
{
return physical_layout;
}
int CorsairPeripheralController::GetLogicalLayout()
{
return logical_layout;
}
std::string CorsairPeripheralController::GetFirmwareString()
{
return firmware_version;
@@ -103,9 +122,9 @@ void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colors)
{
unsigned char red_val[144];
unsigned char grn_val[144];
unsigned char blu_val[144];
unsigned char red_val[168];
unsigned char grn_val[168];
unsigned char blu_val[168];
/*-----------------------------------------------------*\
| Zero out buffers |
@@ -120,9 +139,24 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
{
RGBColor color = colors[color_idx];
red_val[keys[color_idx]] = RGBGetRValue(color);
grn_val[keys[color_idx]] = RGBGetGValue(color);
blu_val[keys[color_idx]] = RGBGetBValue(color);
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
{
red_val[keys_k95_plat[color_idx]] = RGBGetRValue(color);
grn_val[keys_k95_plat[color_idx]] = RGBGetGValue(color);
blu_val[keys_k95_plat[color_idx]] = RGBGetBValue(color);
}
else if (logical_layout == CORSAIR_TYPE_K95)
{
red_val[keys_k95[color_idx]] = RGBGetRValue(color);
grn_val[keys_k95[color_idx]] = RGBGetGValue(color);
blu_val[keys_k95[color_idx]] = RGBGetBValue(color);
}
else
{
red_val[keys[color_idx]] = RGBGetRValue(color);
grn_val[keys[color_idx]] = RGBGetGValue(color);
blu_val[keys[color_idx]] = RGBGetBValue(color);
}
}
/*-----------------------------------------------------*\
@@ -130,7 +164,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
\*-----------------------------------------------------*/
StreamPacket(1, 60, &red_val[0]);
StreamPacket(2, 60, &red_val[60]);
StreamPacket(3, 24, &red_val[120]);
StreamPacket(3, 48, &red_val[120]);
SubmitKeyboardFullColors(1, 3, 1);
/*-----------------------------------------------------*\
@@ -138,7 +172,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
\*-----------------------------------------------------*/
StreamPacket(1, 60, &grn_val[0]);
StreamPacket(2, 60, &grn_val[60]);
StreamPacket(3, 24, &grn_val[120]);
StreamPacket(3, 48, &grn_val[120]);
SubmitKeyboardFullColors(2, 3, 1);
/*-----------------------------------------------------*\
@@ -146,7 +180,7 @@ void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colo
\*-----------------------------------------------------*/
StreamPacket(1, 60, &blu_val[0]);
StreamPacket(2, 60, &blu_val[60]);
StreamPacket(3, 24, &blu_val[120]);
StreamPacket(3, 48, &blu_val[120]);
SubmitKeyboardFullColors(3, 3, 2);
}
@@ -233,7 +267,7 @@ void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> c
void CorsairPeripheralController::LightingControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -243,9 +277,10 @@ void CorsairPeripheralController::LightingControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Lighting control byte needs to be 3 for keyboards and |
@@ -255,31 +290,31 @@ void CorsairPeripheralController::LightingControl()
{
default:
case DEVICE_TYPE_KEYBOARD:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
case DEVICE_TYPE_MOUSE:
usb_buf[0x04] = 0x01;
usb_buf[0x05] = 0x01;
break;
case DEVICE_TYPE_MOUSEMAT:
usb_buf[0x04] = 0x04;
usb_buf[0x05] = 0x04;
break;
case DEVICE_TYPE_HEADSET_STAND:
usb_buf[0x04] = 0x03;
usb_buf[0x05] = 0x03;
break;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SpecialFunctionControl()
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -289,20 +324,23 @@ void CorsairPeripheralController::SpecialFunctionControl()
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x03] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::ReadFirmwareInfo()
{
int actual;
char usb_buf[64];
char usb_buf[65];
char offset = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -312,16 +350,17 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet and try reading it using an HID read |
| If that fails, repeat the send and read the reply as |
| a feature report. |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 64, 1000);
hid_write(dev, (unsigned char*)usb_buf, 65);
actual = hid_read_timeout(dev, (unsigned char*)usb_buf, 65, 1000);
if(actual == 0)
{
@@ -333,11 +372,13 @@ void CorsairPeripheralController::ReadFirmwareInfo()
/*-------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_READ;
usb_buf[0x02] = CORSAIR_PROPERTY_FIRMWARE_INFO;
hid_write(dev, (unsigned char*)usb_buf, 64);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
hid_send_feature_report(dev, (unsigned char*)usb_buf, 65);
actual = hid_get_feature_report(dev, (unsigned char*)usb_buf, 65);
offset = 1;
}
/*-----------------------------------------------------*\
@@ -346,14 +387,32 @@ void CorsairPeripheralController::ReadFirmwareInfo()
| 0xC1 Device is a mouse |
| 0xC2 Device is a mousepad or headset stand |
\*-----------------------------------------------------*/
switch((unsigned char)usb_buf[0x14])
switch((unsigned char)usb_buf[0x14 + offset])
{
case 0xC0:
{
unsigned short pid = (unsigned short)(usb_buf[0x0F] << 8) + (unsigned char)(usb_buf[0x0E]);
switch(pid)
{
case 0x2D1B:
logical_layout = CORSAIR_TYPE_K95_PLAT;
break;
case 0x1B11:
logical_layout = CORSAIR_TYPE_K95;
break;
default:
logical_layout = CORSAIR_TYPE_NORMAL;
}
}
type = DEVICE_TYPE_KEYBOARD;
break;
case 0xC1:
type = DEVICE_TYPE_MOUSE;
SpecialFunctionControl();
break;
case 0xC2:
@@ -364,10 +423,12 @@ void CorsairPeripheralController::ReadFirmwareInfo()
{
case 0x0A34:
type = DEVICE_TYPE_HEADSET_STAND;
SpecialFunctionControl();
break;
default:
type = DEVICE_TYPE_MOUSEMAT;
SpecialFunctionControl();
break;
}
}
@@ -383,7 +444,22 @@ void CorsairPeripheralController::ReadFirmwareInfo()
\*-----------------------------------------------------*/
if(type != DEVICE_TYPE_UNKNOWN)
{
firmware_version = std::to_string(usb_buf[0x09]) + "." + std::to_string(usb_buf[0x08]);
firmware_version = std::to_string(usb_buf[0x09 + offset]) + "." + std::to_string(usb_buf[0x08 + offset]);
}
/*-----------------------------------------------------*\
| Get the correct Keyboard Layout |
\*-----------------------------------------------------*/
switch((unsigned char)usb_buf[0x17 + offset])
{
case CORSAIR_LAYOUT_ANSI:
physical_layout = CORSAIR_LAYOUT_ANSI;
break;
case CORSAIR_LAYOUT_ISO:
physical_layout = CORSAIR_LAYOUT_ISO;
break;
default:
physical_layout = CORSAIR_LAYOUT_ANSI;
}
}
@@ -394,7 +470,7 @@ void CorsairPeripheralController::StreamPacket
unsigned char* data_ptr
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -404,19 +480,20 @@ void CorsairPeripheralController::StreamPacket
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_STREAM;
usb_buf[0x02] = packet_id;
usb_buf[0x03] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
memcpy(&usb_buf[0x05], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardFullColors
@@ -426,7 +503,7 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
unsigned char finish_val
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -436,16 +513,17 @@ void CorsairPeripheralController::SubmitKeyboardFullColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x02] = color_channel;
usb_buf[0x03] = packet_count;
usb_buf[0x04] = finish_val;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x03] = color_channel;
usb_buf[0x04] = packet_count;
usb_buf[0x05] = finish_val;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitKeyboardLimitedColors
@@ -453,7 +531,7 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
unsigned char byte_count
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -463,14 +541,15 @@ void CorsairPeripheralController::SubmitKeyboardLimitedColors
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x05] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMouseColors
@@ -479,7 +558,7 @@ void CorsairPeripheralController::SubmitMouseColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -489,26 +568,27 @@ void CorsairPeripheralController::SubmitMouseColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 4) + 4] = zone_idx;
usb_buf[(zone_idx * 4) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 5] = zone_idx;
usb_buf[(zone_idx * 4) + 6] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 8] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void CorsairPeripheralController::SubmitMousematColors
@@ -517,7 +597,7 @@ void CorsairPeripheralController::SubmitMousematColors
RGBColor * color_data
)
{
char usb_buf[64];
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -527,24 +607,25 @@ void CorsairPeripheralController::SubmitMousematColors
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
usb_buf[0x00] = 0x00;
usb_buf[0x01] = CORSAIR_COMMAND_WRITE;
usb_buf[0x02] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x03] = num_zones;
usb_buf[0x04] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 3) + 4] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetBValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 7] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet using feature reports, as headset stand |
| seems to not update completely using HID writes |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_write(dev, (unsigned char *)usb_buf, 65);
}
@@ -47,12 +47,30 @@ enum
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
};
enum
{
CORSAIR_LAYOUT_ANSI = 0x00,
CORSAIR_LAYOUT_ISO = 0x01,
CORSAIR_LAYOUT_ABNT = 0x02,
CORSAIR_LAYOUT_JIS = 0x03,
CORSAIR_LAYOUT_DUBEOLSIK = 0x04
};
enum
{
CORSAIR_TYPE_NORMAL = 0,
CORSAIR_TYPE_K95_PLAT = 1,
CORSAIR_TYPE_K95 = 2
};
class CorsairPeripheralController
{
public:
CorsairPeripheralController(hid_device* dev_handle);
~CorsairPeripheralController();
int GetLogicalLayout();
int GetPhysicalLayout();
device_type GetDeviceType();
std::string GetFirmwareString();
@@ -67,6 +85,8 @@ private:
std::string firmware_version;
device_type type;
int physical_layout; //ANSI, ISO, etc.
int logical_layout; //Normal, K95 or K95 Platinum
void LightingControl();
void SpecialFunctionControl();
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CorsairPeripheralController.h"
#include "RGBController.h"
#include "RGBController_CorsairPeripheral.h"
@@ -39,8 +40,13 @@
| Mouse product IDs |
| List taken from ckb-next |
\*-----------------------------------------------------*/
#define CORSAIR_GLAIVE_RGB_PRO_PID 0x1B74
#define CORSAIR_HARPOON_RGB_PID 0x1B3C
#define CORSAIR_HARPOON_RGB_PRO_PID 0x1B75
#define CORSAIR_M65_PRO_PID 0x1B2E
#define CORSAIR_M65_RGB_ELITE_PID 0x1B5A
#define CORSAIR_SCIMITAR_PRO_RGB_PID 0x1B3E
#define CORSAIR_SABRE_RGB_PID 0x1B2F
/*-----------------------------------------------------*\
| Mousepad product IDs |
@@ -87,8 +93,13 @@ static const corsair_node_device device_list[] =
/*-----------------------------------------------------------------------------------------------------*\
| Mice |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_GLAIVE_RGB_PRO_PID, 1, "Corsair Glaive RGB PRO" },
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PID, 1, "Corsair Harpoon RGB" },
{ CORSAIR_VID, CORSAIR_HARPOON_RGB_PRO_PID, 1, "Corsair Harpoon RGB PRO" },
{ CORSAIR_VID, CORSAIR_M65_PRO_PID, 1, "Corsair M65 PRO" },
{ CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, "Corsair M65 RGB Elite" },
{ CORSAIR_VID, CORSAIR_SCIMITAR_PRO_RGB_PID, 1, "Corsair Scimitar PRO RGB" },
{ CORSAIR_VID, CORSAIR_SABRE_RGB_PID, 1, "Corsair Sabre RGB" },
/*-----------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-----------------------------------------------------------------------------------------------------*/
@@ -124,30 +135,33 @@ void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_control
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
#ifdef USE_HID_USAGE
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->usage_page == 0xFFC2))
#else
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
info = info->next;
}
}
}
} /* DetectCorsairPeripheralControllers() */
REGISTER_DETECTOR("Corsair Peripheral", DetectCorsairPeripheralControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CorsairVengeanceController.h"
#include "RGBController.h"
#include "RGBController_CorsairVengeance.h"
@@ -122,4 +123,6 @@ void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses
}
}
} /* DetectCorsairVengeanceControllers() */
} /* DetectCorsairVengeanceControllers() */
REGISTER_I2C_DETECTOR("Corsair Vengeance", DetectCorsairVengeanceControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CorsairVengeanceProController.h"
#include "RGBController.h"
#include "RGBController_CorsairVengeancePro.h"
@@ -130,4 +131,6 @@ void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &bus
}
}
} /* DetectCorsairVengeanceProControllers() */
} /* DetectCorsairVengeanceProControllers() */
REGISTER_I2C_DETECTOR("Corsair Vengeance Pro", DetectCorsairVengeanceProControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "CrucialController.h"
#include "RGBController.h"
#include "RGBController_Crucial.h"
@@ -86,3 +87,5 @@ void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
}
} /* DetectCrucialControllers() */
REGISTER_I2C_DETECTOR("Crucial", DetectCrucialControllers);
@@ -0,0 +1,187 @@
/*-----------------------------------------*\
| DuckyKeyboardController.cpp |
| |
| Driver for Ducky RGB keyboardlighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#include <cstring>
#include "DuckyKeyboardController.h"
DuckyKeyboardController::DuckyKeyboardController(hid_device* dev_handle)
{
dev = dev_handle;
SendInitialize();
}
DuckyKeyboardController::~DuckyKeyboardController()
{
}
void DuckyKeyboardController::SendColors
(
unsigned char* color_data,
unsigned int color_data_size
)
{
unsigned int bytes_sent;
unsigned char* color_data_ptr = color_data;
SendInitializeColorPacket();
for(int i = 0; i < 8; i++)
{
bytes_sent = SendColorDataPacket(i, color_data_ptr, color_data_size);
color_data_ptr += bytes_sent;
color_data_size -= bytes_sent;
}
SendTerminateColorPacket();
}
void DuckyKeyboardController::SendInitialize()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Initialize Direct Mode packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x41;
usb_buf[0x02] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
void DuckyKeyboardController::SendInitializeColorPacket()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Initialize Color packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x56;
usb_buf[0x02] = 0x81;
usb_buf[0x05] = 0x01;
usb_buf[0x09] = 0x08;
usb_buf[0x0D] = 0xAA;
usb_buf[0x0E] = 0xAA;
usb_buf[0x0F] = 0xAA;
usb_buf[0x10] = 0xAA;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
unsigned int DuckyKeyboardController::SendColorDataPacket
(
unsigned char packet_id,
unsigned char* color_data,
unsigned int color_size
)
{
unsigned int bytes_sent;
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Color Data packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x56;
usb_buf[0x02] = 0x83;
usb_buf[0x03] = packet_id;
if(packet_id == 0x00)
{
usb_buf[0x05] = 0x01;
usb_buf[0x09] = 0x80;
usb_buf[0x0A] = 0x01;
usb_buf[0x0C] = 0xC1;
usb_buf[0x11] = 0xFF;
usb_buf[0x12] = 0xFF;
usb_buf[0x13] = 0xFF;
usb_buf[0x14] = 0xFF;
}
/*-----------------------------------------------------*\
| Copy in color data |
\*-----------------------------------------------------*/
if(packet_id == 0x00)
{
bytes_sent = 65 - 0x19;
if(color_size < bytes_sent)
{
bytes_sent = color_size;
}
memcpy(&usb_buf[0x19], color_data, bytes_sent);
}
else
{
bytes_sent = 65 - 0x05;
if(color_size < bytes_sent)
{
bytes_sent = color_size;
}
memcpy(&usb_buf[0x05], color_data, bytes_sent);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
return(bytes_sent);
}
void DuckyKeyboardController::SendTerminateColorPacket()
{
char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Terminate Color packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x00;
usb_buf[0x01] = 0x51;
usb_buf[0x02] = 0x28;
usb_buf[0x05] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 65);
}
@@ -0,0 +1,41 @@
/*-----------------------------------------*\
| DuckyKeyboardController.h |
| |
| Definitions and types for Ducky RGB |
| keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/4/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class DuckyKeyboardController
{
public:
DuckyKeyboardController(hid_device* dev_handle);
~DuckyKeyboardController();
void SendColors
(
unsigned char* color_data,
unsigned int color_data_size
);
private:
hid_device* dev;
void SendInitialize();
void SendInitializeColorPacket();
unsigned int SendColorDataPacket
(
unsigned char packet_id,
unsigned char* color_data,
unsigned int color_size
);
void SendTerminateColorPacket();
};
@@ -0,0 +1,84 @@
#include "Detector.h"
#include "DuckyKeyboardController.h"
#include "RGBController.h"
#include "RGBController_DuckyKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Ducky vendor ID |
\*-----------------------------------------------------*/
#define DUCKY_VID 0x04D9
/*-----------------------------------------------------*\
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define DUCKY_SHINE_7_ONE_2_RGB_PID 0x0348
#define DUCKY_ONE_2_RGB_TKL_PID 0x0356
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
const char * name;
} ducky_device;
#define DUCKY_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const ducky_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ DUCKY_VID, DUCKY_SHINE_7_ONE_2_RGB_PID, 1, "Ducky Shine 7/Ducky One 2 RGB" },
{ DUCKY_VID, DUCKY_ONE_2_RGB_TKL_PID, 1, "Ducky One 2 RGB TKL" },
};
/******************************************************************************************\
* *
* DetectDuckyKeyboardControllers *
* *
* Tests the USB address to see if a Ducky RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectDuckyKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(std::size_t device_idx = 0; device_idx < DUCKY_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Ducky RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
if( dev )
{
DuckyKeyboardController* controller = new DuckyKeyboardController(dev);
RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
} /* DetectDuckyKeyboardControllers() */
REGISTER_DETECTOR("Ducky Keyboard", DetectDuckyKeyboardControllers);
+130
View File
@@ -0,0 +1,130 @@
/*-------------------------------------------------------------------*\
| EKController.cpp |
| |
| Driver for EK Loop Connect |
| |
| Chris M (Dr_No) 16th Jul 2020 |
| |
\*-------------------------------------------------------------------*/
#include "EKController.h"
static unsigned char colour_mode_data[][16] =
{
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x01, 0x00, 0xFF, 0x64}, // Static
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x02, 0x00, 0xFF, 0x64}, // Breathing
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x03, 0xFF, 0xFF, 0x64}, // Fading
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x04, 0x00, 0xFF, 0x64}, // Marquee
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x05, 0x00, 0xFF, 0x64}, // Covering Marquee
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x06, 0x00, 0xFF, 0x64}, // Pulse
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x07, 0x00, 0xFF, 0x64}, // Wave
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x08, 0x00, 0xFF, 0x64}, // Alternating
{ 0x10, 0x12, 0x29, 0xAA, 0x01, 0x10, 0xA2, 0x60,
0x00, 0x10, 0x20, 0x01, 0x09, 0x00, 0xFF, 0x64}, // Candle
};
static unsigned char speed_mode_data[][9] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Static
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Breathing
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Fading
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Marquee
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Covering Marquee
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Pulse
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Wave
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 }, // Alternating
{ 0x00, 0x0C, 0x19, 0x25, 0x32, 0x3E, 0x4B, 0x57, 0x64 } // Candle
};
EKController::EKController(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path)
{
std::size_t tmp_size = wcslen(_vendor);
dev = dev_handle;
for(std::size_t i = 0; (i < tmp_size) && (i < EK_DEVICE_NAME_SIZE); i++)
{
device_name[i] = (char)_vendor[i];
}
for(std::size_t j = 0; (j < wcslen(_vendor)) && ((tmp_size + j) < EK_DEVICE_NAME_SIZE); j++)
{
device_name[tmp_size + j] = (char)_device_name[j];
}
location = _path;
current_mode = EK_MODE_STATIC;
current_speed = EK_SPEED_NORMAL;
}
EKController::~EKController()
{
if(dev)
{
hid_close(dev);
}
}
char* EKController::GetDeviceName()
{
return device_name;
}
char* EKController::GetSerial()
{
return serial;
}
std::string EKController::GetLocation()
{
return location;
}
void EKController::SetMode(unsigned char mode, unsigned char speed)
{
current_mode = mode;
current_speed = speed;
SendUpdate();
}
void EKController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
current_red = red;
current_green = green;
current_blue = blue;
SendUpdate();
}
void EKController::SendUpdate()
{
unsigned char buffer[EK_PACKET_LENGTH] = { 0x00 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
for(std::size_t i = 0; i < EK_COLOUR_MODE_DATA_SIZE; i++)
{
buffer[i] = colour_mode_data[current_mode][i];
}
//Set the relevant colour info
buffer[EK_RED_BYTE] = current_red;
buffer[EK_GREEN_BYTE] = current_green;
buffer[EK_BLUE_BYTE] = current_blue;
buffer[EK_SPEED_BYTE] = speed_mode_data[current_mode][current_speed];
buffer[10] = 0x10;
buffer[47] = 0xFF;
buffer[48] = 0x00;
hid_write(dev, buffer, buffer_size);
}
+84
View File
@@ -0,0 +1,84 @@
/*-------------------------------------------------------------------*\
| EKController.h |
| |
| Driver for EK Loop Connect |
| |
| Chris M (Dr_No) 16th Jul 2020 |
| |
\*-------------------------------------------------------------------*/
#ifndef EKCONTROLLER_H
#define EKCONTROLLER_H
#include <string>
#include <hidapi/hidapi.h>
#define EK_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
#define EK_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
#define EK_PACKET_LENGTH 0x3F
enum
{
EK_MODE_BYTE = 12,
EK_SPEED_BYTE = 14,
EK_RED_BYTE = 16,
EK_GREEN_BYTE = 17,
EK_BLUE_BYTE = 18
};
enum
{
EK_MODE_STATIC = 0x00, //Static Mode
EK_MODE_BREATHING = 0x01, //Breathing Mode
EK_MODE_FADING = 0x02, //Fading Mode
EK_MODE_MARQUEE = 0x03, //Marquee Mode
EK_MODE_COVERING_MARQUEE = 0x04, //Covering Marquee Mode
EK_MODE_PULSE = 0x05, //Pulse Mode
EK_MODE_SPECTRUM_WAVE = 0x06, //Spectrum Wave Mode
EK_MODE_ALTERNATING = 0x07, //Alternating Mode
EK_MODE_CANDLE = 0x08 //Candle Mode
};
enum
{
EK_SPEED_SLOWEST = 0x00, // Slowest speed
EK_SPEED_SLOWER = 0x01, // Slower speed
EK_SPEED_SLOW = 0x02, // Slow speed
EK_SPEED_SLOWISH = 0x03, // Slowish speed
EK_SPEED_NORMAL = 0x04, // Normal speed
EK_SPEED_FASTISH = 0x05, // Fastish speed
EK_SPEED_FAST = 0x06, // Fast speed
EK_SPEED_FASTER = 0x07, // Faster speed
EK_SPEED_FASTEST = 0x08, // Fastest speed
};
class EKController
{
public:
EKController(hid_device* dev_handle, wchar_t *_vendor, wchar_t *_device_name, char *_path);
~EKController();
char* GetDeviceName();
char* GetSerial();
std::string GetLocation();
void SetMode(unsigned char mode, unsigned char speed);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
char serial[32];
std::string location;
hid_device* dev;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_red;
unsigned char current_green;
unsigned char current_blue;
void SendUpdate();
};
#endif // EKCONTROLLER_H
@@ -0,0 +1,67 @@
#include "Detector.h"
#include "EKController.h"
#include "RGBController.h"
#include "RGBController_EKController.h"
#include <hidapi/hidapi.h>
#define EK_VID 0x0483
#define EK_LOOP_CONNECT 0x5750
#define EK_NUM_DEVICES (sizeof(ek_pids) / sizeof(ek_pids[ 0 ]))
enum
{
EK_PID = 0,
EK_INTERFACE = 1
};
static const unsigned int ek_pids[][2] =
{ // PID, Interface
{ EK_LOOP_CONNECT, 0x00 } //EK Loop Connect
};
/******************************************************************************************\
* *
* DetectEKControllers *
* *
* Tests the USB address to see if any EK Controllers exists there. *
* *
\******************************************************************************************/
void DetectEKControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info = NULL;
//Look for the passed in cm_pids
hid_init();
info = hid_enumerate(EK_VID, 0x0);
while(info)
{
hid_device* dev = NULL;
if(info->vendor_id == EK_VID)
{
for(unsigned int ek_pid_idx = 0; ek_pid_idx < EK_NUM_DEVICES; ek_pid_idx++)
{
if((info->product_id == ek_pids[ek_pid_idx][EK_PID])
&&(info->interface_number == ek_pids[ek_pid_idx][EK_INTERFACE]))
{
dev = hid_open_path(info->path);
break;
}
}
}
if(dev)
{
EKController* controller = new EKController(dev, info->manufacturer_string, info->product_string, info->path);
RGBController_EKController* rgb_controller = new RGBController_EKController(controller);
rgb_controllers.push_back(rgb_controller);
}
info = info->next;
}
hid_free_enumeration(info);
} /* DetectEKControllers() */
REGISTER_DETECTOR("EK", DetectEKControllers);
@@ -0,0 +1,106 @@
/*-----------------------------------------*\
| GalaxGPUController.cpp |
| |
| Driver for Galax / KFA2 RGB on GPUs |
| |
| Niels Westphal (crashniels) 12.07.2020 |
\*-----------------------------------------*/
#include "GalaxGPUController.h"
#include <cstring>
GalaxGPUController::GalaxGPUController(i2c_smbus_interface* bus, galax_gpu_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "Galax RTX GPU"); // Would be nice to get the actual GPU name. Using this as a placeholder.
}
GalaxGPUController::~GalaxGPUController()
{
}
std::string GalaxGPUController::GetDeviceName()
{
return(device_name);
}
std::string GalaxGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char GalaxGPUController::GetLEDRed()
{
return(GalaxGPURegisterRead(GALAX_RED_REGISTER));
}
unsigned char GalaxGPUController::GetLEDGreen()
{
return(GalaxGPURegisterRead(GALAX_GREEN_REGISTER));
}
unsigned char GalaxGPUController::GetLEDBlue()
{
return(GalaxGPURegisterRead(GALAX_BLUE_REGISTER));
}
void GalaxGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes
{
GalaxGPURegisterWrite(GALAX_RED_REGISTER, red);
GalaxGPURegisterWrite(GALAX_GREEN_REGISTER, green);
GalaxGPURegisterWrite(GALAX_BLUE_REGISTER, blue);
}
void GalaxGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
GalaxGPURegisterWrite(GALAX_RED_REGISTER, red);
GalaxGPURegisterWrite(GALAX_GREEN_REGISTER, green);
GalaxGPURegisterWrite(GALAX_BLUE_REGISTER, blue);
}
void GalaxGPUController::SetMode(unsigned char mode)
{
switch(mode)
{
case 1:
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_1, GALAX_MODE_STATIC_VALUE_1);
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_2, GALAX_MODE_STATIC_VALUE_2);
break;
case 2:
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_1, GALAX_MODE_BREATHING_VALUE_1);
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_2, GALAX_MODE_BREATHING_VALUE_2);
break;
case 3:
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_1, GALAX_MODE_RAINBOW_VALUE_1);
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_2, GALAX_MODE_RAINBOW_VALUE_2);
break;
case 4:
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_1, GALAX_MODE_CYCLE_BREATHING_VALUE_1);
GalaxGPURegisterWrite(GALAX_MODE_REGISTER_2, GALAX_MODE_CYCLE_BREATHING_VALUE_2);
break;
default:
break;
}
}
unsigned char GalaxGPUController::GalaxGPURegisterRead(unsigned char reg)
{
return(bus->i2c_smbus_read_byte_data(dev, reg));
}
void GalaxGPUController::GalaxGPURegisterWrite(unsigned char reg, unsigned char val)
{
bus->i2c_smbus_write_byte_data(dev, reg, val);
}
@@ -0,0 +1,67 @@
/*-----------------------------------------*\
| GalaxGPUController.h |
| |
| Driver for Galax / KFA2 RGB on GPUs |
| |
| Niels Westphal (crashniels) 12.07.2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char galax_gpu_dev_id;
enum
{
/* RGB Registers */
GALAX_RED_REGISTER = 0x02, /* Red Register */
GALAX_GREEN_REGISTER = 0x03, /* Green Register */
GALAX_BLUE_REGISTER = 0x04, /* Blue Register */
/* MODE Registers */
GALAX_MODE_REGISTER_1 = 0x05, /* Mode Register 1 */
GALAX_MODE_REGISTER_2 = 0x06, /* Mode Register 2 */
};
enum
{
/* Static Mode Values */
GALAX_MODE_STATIC_VALUE_1 = 0x00,
GALAX_MODE_STATIC_VALUE_2 = 0x01,
/* Breathing Mode Values */
GALAX_MODE_BREATHING_VALUE_1 = 0x04,
GALAX_MODE_BREATHING_VALUE_2 = 0x00,
/* Rainbow Mode Values */
GALAX_MODE_RAINBOW_VALUE_1 = 0x84,
GALAX_MODE_RAINBOW_VALUE_2 = 0x02,
/* Cycle Breathing Mode Values */
GALAX_MODE_CYCLE_BREATHING_VALUE_1 = 0x84,
GALAX_MODE_CYCLE_BREATHING_VALUE_2 = 0x40,
};
class GalaxGPUController
{
public:
GalaxGPUController(i2c_smbus_interface* bus, galax_gpu_dev_id);
~GalaxGPUController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned char GetLEDRed();
unsigned char GetLEDGreen();
unsigned char GetLEDBlue();
void SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned char GalaxGPURegisterRead(unsigned char reg);
void GalaxGPURegisterWrite(unsigned char reg, unsigned char val);
bool direct = false; // Temporary solution to check if we are in "Direct" mode
private:
char device_name[16];
i2c_smbus_interface * bus;
galax_gpu_dev_id dev;
};
@@ -0,0 +1,71 @@
/*-----------------------------------------*\
| GalaxGPUControllerDetect.cpp |
| |
| Driver for Galax / KFA2 RGB on GPUs |
| |
| Niels Westphal (crashniels) 12.07.2020 |
\*-----------------------------------------*/
#include "Detector.h"
#include "GalaxGPUController.h"
#include "RGBController.h"
#include "RGBController_GalaxGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std::chrono_literals;
/******************************************************************************************\
* *
* TestForGalaxGPUController *
* *
* Tests the given address to see if a Galax GPU controller exists there. *
* *
\******************************************************************************************/
bool TestForGalaxGPUController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
unsigned char res = bus->i2c_smbus_read_byte_data(address, 0x00);
unsigned char res2 = bus->i2c_smbus_read_byte_data(address, 0x01);
if(res == 0x27 && res2 == 0x10)
{
pass = true;
}
return(pass);
} /* TestForGalaxGPUController() */
/******************************************************************************************\
* *
* DetectGalaxGPUControllers *
* *
* Detect Galax GPU controllers on the enumerated I2C busses. *
* *
\******************************************************************************************/
void DetectGalaxGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
GalaxGPUController* new_GalaxGPU;
RGBController_GalaxGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for GALAX controller at 0x23
if (TestForGalaxGPUController(busses[bus], 0x23))
{
new_GalaxGPU = new GalaxGPUController(busses[bus], 0x23);
new_controller = new RGBController_GalaxGPU(new_GalaxGPU);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectGalaxGPUControllers() */
REGISTER_I2C_DETECTOR("Galax GPU", DetectGalaxGPUControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "GloriousModelOController.h"
#include "RGBController.h"
#include "RGBController_GloriousModelO.h"
@@ -21,17 +22,19 @@ void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controller
hid_device* dev = NULL;
hid_init();
dev = NULL;
info = hid_enumerate(Glorious_Model_O_VID, Glorious_Model_O_PID);
//Look for Glorious Model O
while(info)
{
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
if((info->vendor_id == Glorious_Model_O_VID)
&&(info->product_id == Glorious_Model_O_PID)
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF00))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
@@ -52,4 +55,6 @@ void DetectGloriousModelOControllers(std::vector<RGBController*>& rgb_controller
rgb_controllers.push_back(rgb_controller);
}
}
} /* DetectGloriousModelOControllers() */
REGISTER_DETECTOR("Glorious Model O", DetectGloriousModelOControllers);
@@ -0,0 +1,87 @@
/*-----------------------------------------------*\
| HoltekA070Controller.cpp |
| |
| Driver for Holtek USB Gaming Mouse [04d9:a070] |
| |
| Santeri Pikarinen (santeri3700) 8/01/2020 |
\*-----------------------------------------------*/
#include "HoltekA070Controller.h"
#include <cstring>
HoltekA070Controller::HoltekA070Controller(hid_device* dev_handle)
{
dev = dev_handle;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HoltekA070Controller::SendCustomColor
(
unsigned char red,
unsigned char green,
unsigned char blue
)
{
char usb_buf[8];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up RGB Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x07; // PACKET SIZE?
usb_buf[0x01] = 0x0a; // SET RGB
usb_buf[0x02] = 0x00; // SAVE (does not work with SET RGB)
usb_buf[0x03] = red; // RED
usb_buf[0x04] = green; // GREEN
usb_buf[0x05] = blue; // BLUE
usb_buf[0x06] = 0x00; // PADDING?
usb_buf[0x07] = 0x00; // PADDING?
// So far no saving function has been discovered for the "SET RGB" command.
// Such functionality might not even exist for the A070 series.
// The chosen RGB color will therefore reset after a power cycle.
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, (unsigned char *)usb_buf, sizeof(usb_buf));
}
void HoltekA070Controller::SendMode
(
unsigned char mode
)
{
char usb_buf[8];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up lighting mode control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x07; // PACKET SIZE?
usb_buf[0x01] = 0x0b; // SET LIGHTING MODE
usb_buf[0x02] = 0x01; // SAVE
usb_buf[0x03] = mode; // MODE 01-04
usb_buf[0x04] = 0x00; // PADDING?
usb_buf[0x05] = 0x00; // PADDING?
usb_buf[0x06] = 0x00; // PADDING?
usb_buf[0x07] = 0x00; // PADDING?
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, (unsigned char *)usb_buf, sizeof(usb_buf));
}
@@ -0,0 +1,44 @@
/*---------------------------------------------------------------*\
| HoltekA070Controller.h |
| |
| Definitions and types for Holtek USB Gaming Mouse [04d9:a070] |
| |
| Santeri Pikarinen (santeri3700) 8/01/2020 |
\*---------------------------------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
HOLTEK_A070_MODE_STATIC = 0x01,
HOLTEK_A070_MODE_BREATHING_SLOW = 0x02,
HOLTEK_A070_MODE_BREATHING_MEDIUM = 0x03,
HOLTEK_A070_MODE_BREATHING_FAST = 0x04
};
class HoltekA070Controller
{
public:
HoltekA070Controller(hid_device* dev_handle);
~HoltekA070Controller();
void SendCustomColor
(
unsigned char red,
unsigned char green,
unsigned char blue
);
void SendMode
(
unsigned char mode
);
private:
hid_device* dev;
};
@@ -0,0 +1,89 @@
#include "Detector.h"
#include "HoltekA070Controller.h"
#include "RGBController.h"
#include "RGBController_HoltekA070.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Holtek Semiconductor Inc. vendor ID |
\*-----------------------------------------------------*/
#define HOLTEK_VID 0x04D9
/*-----------------------------------------------------*\
| Mouse product IDs |
\*-----------------------------------------------------*/
#define HOLTEK_A070_PID 0xA070
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
device_type type;
const char * name;
} holtek_device;
#define HOLTEK_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const holtek_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ HOLTEK_VID, HOLTEK_A070_PID, 1, DEVICE_TYPE_MOUSE, "Holtek USB Gaming Mouse" },
};
void DetectHoltekControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_init();
for(unsigned int device_idx = 0; device_idx < HOLTEK_NUM_DEVICES; device_idx++)
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_MOUSE:
{
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF00)
&&(info->usage == 2))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
switch(device_list[device_idx].usb_pid)
{
case HOLTEK_A070_PID:
{
HoltekA070Controller* controller = new HoltekA070Controller(dev);
RGBController_HoltekA070* rgb_controller = new RGBController_HoltekA070(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
}
info = info->next;
}
hid_free_enumeration(info);
}
break;
}
}
} /* DetectHoltekControllers() */
REGISTER_DETECTOR("Holtek", DetectHoltekControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "HuePlusController.h"
#include "RGBController.h"
#include "RGBController_HuePlus.h"
@@ -17,16 +18,23 @@
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
{
size_t i;
HuePlusController* new_hueplus;
RGBController_HuePlus* new_controller;
std::string portname = find_usb_serial_port(NZXT_HUE_PLUS_VID, NZXT_HUE_PLUS_PID);
if( portname != "" )
{
new_hueplus = new HuePlusController();
new_hueplus->Initialize((char *)portname.c_str());
std::vector<std::string *> ports = find_usb_serial_port(NZXT_HUE_PLUS_VID, NZXT_HUE_PLUS_PID);
new_controller = new RGBController_HuePlus(new_hueplus);
rgb_controllers.push_back(new_controller);
for (i = 0; i < ports.size(); i++)
{
if( *ports[i] != "" )
{
new_hueplus = new HuePlusController();
new_hueplus->Initialize((char *)ports[i]->c_str());
new_controller = new RGBController_HuePlus(new_hueplus);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectHuePlusControllers() */
REGISTER_DETECTOR("NZXT Hue+", DetectHuePlusControllers);
@@ -188,8 +188,8 @@ enum
static const unsigned char slot_base[4] =
{
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x51 maps to slot 1 */
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x52 maps to slot 2 */
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x51 maps to slot 2 */
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x52 maps to slot 1 */
HYPERX_REG_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
};
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "HyperXDRAMController.h"
#include "RGBController.h"
#include "RGBController_HyperXDRAM.h"
@@ -93,3 +94,5 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
}
} /* DetectHyperXDRAMControllers() */
REGISTER_I2C_DETECTOR("HyperX DRAM", DetectHyperXDRAMControllers);
@@ -0,0 +1,131 @@
/*-----------------------------------------*\
| HyperXAlloyOriginsController.cpp |
| |
| Driver for HyperX Alloy Origins RGB |
| Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#include "HyperXAlloyOriginsController.h"
#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 };
HyperXAlloyOriginsController::HyperXAlloyOriginsController(hid_device* dev_handle)
{
dev = dev_handle;
}
HyperXAlloyOriginsController::~HyperXAlloyOriginsController()
{
}
void HyperXAlloyOriginsController::SetLEDsDirect(std::vector<RGBColor> colors)
{
/*-----------------------------------------------------*\
| Insert color data for unused positions |
\*-----------------------------------------------------*/
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);
}
/*-----------------------------------------------------*\
| Set up variables to track progress of color transmit |
| Do this after inserting blanks |
\*-----------------------------------------------------*/
int colors_to_send = colors.size();
int colors_sent = 0;
SendDirectInitialization();
for(int pkt_idx = 0; pkt_idx < 9; pkt_idx++)
{
if(colors_to_send > 16)
{
SendDirectColorPacket(&colors[colors_sent], 16);
colors_sent += 16;
colors_to_send -= 16;
}
else if(colors_to_send > 0)
{
SendDirectColorPacket(&colors[colors_sent], colors_to_send);
colors_sent += colors_to_send;
colors_to_send -= colors_to_send;
}
else
{
RGBColor temp = 0x00000000;
SendDirectColorPacket(&temp, 1);
}
}
}
void HyperXAlloyOriginsController::SendDirectInitialization()
{
unsigned char buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct Initialization packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x00;
buf[0x01] = 0x04;
buf[0x02] = 0xF2;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 65);
}
void HyperXAlloyOriginsController::SendDirectColorPacket
(
RGBColor* color_data,
unsigned int color_count
)
{
unsigned char buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct Initialization packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x00;
/*-----------------------------------------------------*\
| The maximum number of colors per packet is 16 |
\*-----------------------------------------------------*/
if(color_count > 16)
{
color_count = 16;
}
/*-----------------------------------------------------*\
| Copy in color data |
\*-----------------------------------------------------*/
for(unsigned int color_idx = 0; color_idx < color_count; color_idx++)
{
buf[(color_idx * 4) + 1] = 0x81;
buf[(color_idx * 4) + 2] = RGBGetRValue(color_data[color_idx]);
buf[(color_idx * 4) + 3] = RGBGetGValue(color_data[color_idx]);
buf[(color_idx * 4) + 4] = RGBGetBValue(color_data[color_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 65);
}
@@ -0,0 +1,34 @@
/*-----------------------------------------*\
| HyperXAlloyOriginsController.h |
| |
| Definitions and types for HyperX Alloy |
| Origins RGB Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/11/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class HyperXAlloyOriginsController
{
public:
HyperXAlloyOriginsController(hid_device* dev_handle);
~HyperXAlloyOriginsController();
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
hid_device* dev;
void SendDirectInitialization();
void SendDirectColorPacket
(
RGBColor* color_data,
unsigned int color_count
);
};
@@ -401,7 +401,7 @@ void HyperXKeyboardController::SendExtendedColor
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0x08; i <= 0x93; i++)
for(int i = 0x08; i < 0x94; i++)
{
buf[i] = color_data[i];
}
@@ -431,6 +431,7 @@ void HyperXKeyboardController::SendDirect
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = color_channel;
buf[0x03] = 0xA0;
/*-----------------------------------------------------*\
| Fill in color data |
@@ -464,11 +465,12 @@ void HyperXKeyboardController::SendDirectExtended
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = HYPERX_COLOR_CHANNEL_EXTENDED;
buf[0x03] = 0xA0;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0x08; i <= 0x93; i++)
for(int i = 0x08; i < 0x94; i++)
{
buf[i] = color_data[i];
}
@@ -1,5 +1,8 @@
#include "Detector.h"
#include "HyperXAlloyOriginsController.h"
#include "HyperXKeyboardController.h"
#include "RGBController.h"
#include "RGBController_HyperXAlloyOrigins.h"
#include "RGBController_HyperXKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
@@ -7,8 +10,11 @@
/*-----------------------------------------------------*\
| HyperX keyboard vendor IDs |
\*-----------------------------------------------------*/
#define HYPERX_KEYBOARD_VID 0x0951
#define HYPERX_ALLOY_ELITE_PID 0x16BE
#define HYPERX_KEYBOARD_VID 0x0951
#define HYPERX_ALLOY_ELITE_PID 0x16BE
#define HYPERX_ALLOY_FPS_RGB_PID 0x16DC
#define HYPERX_ALLOY_ORIGINS_PID 0x16E5
#define HYPERX_ALLOY_ORIGINS_CORE_PID 0x16E6
typedef struct
{
@@ -25,7 +31,10 @@ static const hyperx_device device_list[] =
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, "HyperX Alloy Elite RGB" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID, 2, "HyperX Alloy Elite RGB" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_FPS_RGB_PID, 2, "HyperX Alloy FPS RGB" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_PID, 3, "HyperX Alloy Origins" },
{ HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ORIGINS_CORE_PID, 3, "HyperX Alloy Origins Core" },
};
/******************************************************************************************\
@@ -52,28 +61,52 @@ void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controller
//Look for HyperX RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
if((device_list[device_idx].usb_pid != HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
if((device_list[device_idx].usb_pid == HYPERX_ALLOY_ORIGINS_PID)
&&(info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
break;
if( dev )
{
HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev);
RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
}
} /* DetectHyperXKeyboardControllers() */
REGISTER_DETECTOR("HyperX Keyboard", DetectHyperXKeyboardControllers);
@@ -0,0 +1,84 @@
#include "Detector.h"
#include "HyperXPulsefireSurgeController.h"
#include "RGBController.h"
#include "RGBController_HyperXPulsefireSurge.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| HyperX keyboard vendor IDs |
\*-----------------------------------------------------*/
#define HYPERX_VID 0x0951
#define HYPERX_PULSEFIRE_SURGE_PID 0x16D3
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
const char * name;
} hyperx_device;
#define HYPERX_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const hyperx_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Mice |
\*-----------------------------------------------------------------------------------------------------*/
{ HYPERX_VID, HYPERX_PULSEFIRE_SURGE_PID, 1, "HyperX Pulsefire Surge" },
};
/******************************************************************************************\
* *
* DetectHyperXMouseControllers *
* *
* Tests the USB address to see if a HyperX Mouse controller exists there. *
* *
\******************************************************************************************/
void DetectHyperXMouseControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
for(std::size_t device_idx = 0; device_idx < HYPERX_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for HyperX RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
if( dev )
{
HyperXPulsefireSurgeController* controller = new HyperXPulsefireSurgeController(dev);
RGBController_HyperXPulsefireSurge* rgb_controller = new RGBController_HyperXPulsefireSurge(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
} /* DetectHyperXMouseControllers() */
REGISTER_DETECTOR("HyperX Mouse", DetectHyperXMouseControllers);
@@ -0,0 +1,125 @@
/*-----------------------------------------*\
| HyperXPulsefireSurgeController.cpp |
| |
| Driver for HyperX Pulsefire Surge |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/25/2020 |
\*-----------------------------------------*/
#include "HyperXPulsefireSurgeController.h"
#include <cstring>
HyperXPulsefireSurgeController::HyperXPulsefireSurgeController(hid_device* dev_handle)
{
dev = dev_handle;
}
HyperXPulsefireSurgeController::~HyperXPulsefireSurgeController()
{
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HyperXPulsefireSurgeController::SelectProfile
(
unsigned char profile
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Select Profile packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PULSEFIRE_SURGE_PACKET_ID_SELECT_PROFILE;
buf[0x02] = profile;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXPulsefireSurgeController::SetProfileBrightness
(
unsigned char profile,
unsigned char brightness
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Select Profile packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PULSEFIRE_SURGE_PACKET_ID_SET_BRIGHTNESS;
buf[0x02] = profile;
buf[0x03] = 0x01;
buf[0x04] = 0x01;
buf[0x05] = 0x01;
buf[0x06] = brightness;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXPulsefireSurgeController::SendDirect
(
RGBColor* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Select Profile packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PULSEFIRE_SURGE_PACKET_ID_DIRECT;
buf[0x03] = 0xA0;
for(int red_idx = 0; red_idx < 32; red_idx++)
{
buf[0x08 + red_idx] = RGBGetRValue(color_data[red_idx]);
}
for(int grn_idx = 0; grn_idx < 32; grn_idx++)
{
buf[0x28 + grn_idx] = RGBGetGValue(color_data[grn_idx]);
}
for(int blu_idx = 0; blu_idx < 32; blu_idx++)
{
buf[0x48 + blu_idx] = RGBGetBValue(color_data[blu_idx]);
}
buf[0x6C] = RGBGetRValue(color_data[32]);
buf[0x6D] = RGBGetGValue(color_data[32]);
buf[0x6E] = RGBGetBValue(color_data[32]);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
@@ -0,0 +1,58 @@
/*-----------------------------------------*\
| HyperXPulsefireSurgeController.h |
| |
| Definitions and types for HyperX |
| Pulsefire Surge lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/25/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
HYPERX_PULSEFIRE_SURGE_PACKET_ID_SET_CONFIGURATION = 0x01, /* Set profile configuration packet */
HYPERX_PULSEFIRE_SURGE_PACKET_ID_SET_BRIGHTNESS = 0x03, /* Set profile settings and brightness */
HYPERX_PULSEFIRE_SURGE_PACKET_ID_SELECT_PROFILE = 0x07, /* Select profile */
HYPERX_PULSEFIRE_SURGE_PACKET_ID_DIRECT = 0x14, /* Direct control packet */
};
enum
{
HYPERX_PULSEFIRE_SURGE_MODE_SOLID = 0x00, /* Solid color mode */
HYPERX_PULSEFIRE_SURGE_MODE_CYCLE = 0x01, /* Spectrum cycle mode */
HYPERX_PULSEFIRE_SURGE_MODE_BREATHING = 0x02, /* Breathing mode */
HYPERX_PULSEFIRE_SURGE_MODE_WAVE = 0x03, /* Wave mode */
HYPERX_PULSEFIRE_SURGE_MODE_TRIGGER = 0x04, /* Trigger mode */
};
class HyperXPulsefireSurgeController
{
public:
HyperXPulsefireSurgeController(hid_device* dev_handle);
~HyperXPulsefireSurgeController();
void SelectProfile
(
unsigned char profile
);
void SetProfileBrightness
(
unsigned char profile,
unsigned char brightness
);
void SendDirect
(
RGBColor* color_data
);
private:
hid_device* dev;
};
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "LEDStripController.h"
#include "RGBController.h"
#include "RGBController_LEDStrip.h"
@@ -21,7 +22,7 @@
* DetectLEDStripControllers *
* *
* Detect devices supported by the LEDStrip driver *
* * *
* *
\******************************************************************************************/
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
@@ -29,24 +30,11 @@ void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
LEDStripController* new_ledstrip;
RGBController_LEDStrip* new_controller;
//Get file path in executable directory
std::ifstream infile;
char filename[2048];
char arg1[64];
#ifdef WIN32
GetModuleFileName(NULL, filename, 2048);
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
strcat(filename, "\\ledstrip.txt");
#else
snprintf(arg1, 64, "/proc/%d/exe", getpid());
readlink(arg1, filename, 1024);
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
strcat(filename, "/ledstrip.txt");
#endif
//Open settings file
infile.open(filename);
infile.open("ledstrip.txt");
if (infile.good())
{
@@ -84,5 +72,6 @@ void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
}
}
} /* DetectLEDStripControllers() */
} /* DetectLEDStripControllers() */
REGISTER_DETECTOR("LED Strip", DetectLEDStripControllers);
@@ -1,29 +1,45 @@
#include "Detector.h"
#include "LogitechG203Controller.h"
#include "LogitechG203LController.h"
#include "LogitechG403Controller.h"
#include "LogitechG502PSController.h"
#include "LogitechG810Controller.h"
#include "LogitechGProWirelessController.h"
#include "LogitechGPowerPlayController.h"
#include "RGBController.h"
#include "RGBController_LogitechG203.h"
#include "RGBController_LogitechG203L.h"
#include "RGBController_LogitechG403.h"
#include "RGBController_LogitechG502PS.h"
#include "RGBController_LogitechG810.h"
#include "RGBController_LogitechGProWireless.h"
#include "RGBController_LogitechGPowerPlay.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Logitech vendor ID |
\*-----------------------------------------------------*/
#define LOGITECH_VID 0x046D
#define LOGITECH_VID 0x046D
/*-----------------------------------------------------*\
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define LOGITECH_G810_1_PID 0xC337
#define LOGITECH_G810_2_PID 0xC331
#define LOGITECH_G512_PID 0xC342
#define LOGITECH_G810_1_PID 0xC337
#define LOGITECH_G810_2_PID 0xC331
#define LOGITECH_G512_PID 0xC342
#define LOGITECH_G512_RGB_PID 0xC33C
/*-----------------------------------------------------*\
| Mouse product IDs |
\*-----------------------------------------------------*/
#define LOGITECH_G203_PID 0xC084
#define LOGITECH_G403_PID 0xC083
#define LOGITECH_G403H_PID 0xC08F
#define LOGITECH_G203_PID 0xC084
#define LOGITECH_G203L_PID 0xC092
#define LOGITECH_G403_PID 0xC083
#define LOGITECH_G403H_PID 0xC08F
#define LOGITECH_G502_PS_PID 0xC332
#define LOGITECH_G502H_PID 0xC08B
#define LOGITECH_G_LIGHTSPEED_WIRELESS_PID 0xC539
#define LOGITECH_GPRO_WIRELESS_PID 0xC088
#define LOGITECH_G_LIGHTSPEED_POWERPLAY_PID 0xC53A
typedef struct
{
@@ -38,21 +54,28 @@ typedef struct
static const logitech_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------*/
{ LOGITECH_VID, LOGITECH_G810_1_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
{ LOGITECH_VID, LOGITECH_G810_2_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
{ LOGITECH_VID, LOGITECH_G512_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G512" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ LOGITECH_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
{ LOGITECH_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
{ LOGITECH_VID, LOGITECH_G403H_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Hero" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
{ LOGITECH_VID, LOGITECH_G810_1_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
{ LOGITECH_VID, LOGITECH_G810_2_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
{ LOGITECH_VID, LOGITECH_G512_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G512" },
{ LOGITECH_VID, LOGITECH_G512_RGB_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G512 RGB" },
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
{ LOGITECH_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
{ LOGITECH_VID, LOGITECH_G203L_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Lightsync" },
{ LOGITECH_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
{ LOGITECH_VID, LOGITECH_G403H_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Hero" },
{ LOGITECH_VID, LOGITECH_G502_PS_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G502 Proteus Spectrum" },
{ LOGITECH_VID, LOGITECH_G502H_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G502 Hero" },
{ LOGITECH_VID, LOGITECH_G_LIGHTSPEED_WIRELESS_PID, 2, DEVICE_TYPE_MOUSE, "Logitech G Lightspeed Wireless Gaming Mouse" },
{ LOGITECH_VID, LOGITECH_GPRO_WIRELESS_PID, 2, DEVICE_TYPE_MOUSE, "Logitech G Pro Wireless Gaming Mouse (Wired)" },
{ LOGITECH_VID, LOGITECH_G_LIGHTSPEED_POWERPLAY_PID, 2, DEVICE_TYPE_MOUSE, "Logitech G Powerplay Mousepad with Lightspeed" },
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
@@ -65,78 +88,189 @@ static const logitech_device device_list[] =
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
for(unsigned int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Logitech RGB Peripheral
while(info)
switch(device_list[device_idx].type)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
/*-------------------------------------------------------------------------------------------------*\
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_KEYBOARD:
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF43)
&&(info->usage == 0x0602))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
LogitechG810Controller* controller = new LogitechG810Controller(dev);
hid_device* dev_usage_0x0602 = hid_open_path(info->path);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
if(dev_usage_0x0602)
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
#ifdef USE_HID_USAGE
hid_device_info* tmp_info_0x0604 = info;
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
while(tmp_info_0x0604)
{
if((tmp_info_0x0604->vendor_id == device_list[device_idx].usb_vid)
&&(tmp_info_0x0604->product_id == device_list[device_idx].usb_pid)
&&(tmp_info_0x0604->interface_number == device_list[device_idx].usb_interface)
&&(tmp_info_0x0604->usage_page == 0xFF43)
&&(tmp_info_0x0604->usage == 0x0604))
{
hid_device* dev_usage_0x0604 = hid_open_path(tmp_info_0x0604->path);
if(dev_usage_0x0604)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
tmp_info_0x0604 = tmp_info_0x0604->next;
}
#else
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0602);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
#endif
}
}
}
break;
info = info->next;
}
hid_free_enumeration(info);
}
break;
/*-------------------------------------------------------------------------------------------------*\
| Logitech mice use a single usage on page 0xFF00 |
\*-------------------------------------------------------------------------------------------------*/
case DEVICE_TYPE_MOUSE:
{
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == 0xFF00)
&&(info->usage == 2))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
switch(device_list[device_idx].usb_pid)
{
case LOGITECH_G203_PID:
{
LogitechG203Controller* controller = new LogitechG203Controller(dev);
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G203L_PID:
{
LogitechG203LController* controller = new LogitechG203LController(dev);
RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G403_PID:
case LOGITECH_G403H_PID:
{
LogitechG403Controller* controller = new LogitechG403Controller(dev);
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G502_PS_PID:
case LOGITECH_G502H_PID:
{
LogitechG502PSController* controller = new LogitechG502PSController(dev);
RGBController_LogitechG502PS* rgb_controller = new RGBController_LogitechG502PS(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_GPRO_WIRELESS_PID:
case LOGITECH_G_LIGHTSPEED_WIRELESS_PID:
{
LogitechGProWirelessController* controller = new LogitechGProWirelessController(dev);
RGBController_LogitechGProWireless* rgb_controller = new RGBController_LogitechGProWireless(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case LOGITECH_G_LIGHTSPEED_POWERPLAY_PID:
{
//Add mouse
LogitechGProWirelessController* mouse_controller = new LogitechGProWirelessController(dev);
RGBController_LogitechGProWireless* mouse_rgb_controller = new RGBController_LogitechGProWireless(mouse_controller);
mouse_rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(mouse_rgb_controller);
//Add Powerplay mousemat
LogitechGPowerPlayController* mousemat_controller = new LogitechGPowerPlayController(dev);
RGBController_LogitechGPowerPlay* mousemat_rgb_controller = new RGBController_LogitechGPowerPlay(mousemat_controller);
mousemat_rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(mousemat_rgb_controller);
}
break;
}
}
}
info = info->next;
}
hid_free_enumeration(info);
}
break;
}
hid_free_enumeration(info);
}
}
} /* DetectLogitechControllers() */
REGISTER_DETECTOR("Logitech", DetectLogitechControllers);
@@ -51,7 +51,7 @@ void LogitechG203Controller::SendMouseMode
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
speed = 1000 + 4750 * (LOGITECH_G203_SPEED_FASTEST - speed);
speed = 100 * speed;
if(mode == LOGITECH_G203_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
@@ -22,13 +22,15 @@ enum
LOGITECH_G203_MODE_BREATHING = 0x03,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are mutipled by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G203_SPEED_SLOWEST = 0x00, /* Slowest speed */
LOGITECH_G203_SPEED_SLOW = 0x01, /* Slow speed */
LOGITECH_G203_SPEED_NORMAL = 0x02, /* Normal speed */
LOGITECH_G203_SPEED_FAST = 0x03, /* Fast speed */
LOGITECH_G203_SPEED_FASTEST = 0x04, /* Fastest speed */
LOGITECH_G203_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G203_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G203_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechG203Controller
@@ -0,0 +1,140 @@
#include "LogitechG203LController.h"
#include <cstring>
LogitechG203LController::LogitechG203LController(hid_device* dev_handle)
{
dev = dev_handle;
}
void LogitechG203LController::SendApply()
{
unsigned char usb_buf[20];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x12;
usb_buf[0x03] = 0x7A;
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
void LogitechG203LController::SetSingleLED(int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[20];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x12;
usb_buf[0x03] = 0x19;
usb_buf[0x04] = (unsigned char)led;
usb_buf[0x05] = red;
usb_buf[0x06] = green;
usb_buf[0x07] = blue;
usb_buf[0x08] = 0xFF;
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
SendApply();
}
void LogitechG203LController::SetMode(
int mode,
int speed,
unsigned char bright,
unsigned char dir,
unsigned char red,
unsigned char green,
unsigned char blue)
{
unsigned char usb_buf[20];
memset(usb_buf, 0x00, sizeof(usb_buf));
//Header
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x0E;
usb_buf[0x03] = 0x1A;
//Common Data
usb_buf[0x04] = 0x00;
usb_buf[0x05] = (unsigned char)mode;
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
//mode specific Data and position
if(mode == LOGITECH_G203L_MODE_STATIC) usb_buf[0x09] = 0x02;
if(mode == LOGITECH_G203L_MODE_CYCLE)
{
usb_buf[0x0B] = (unsigned char)((speed>>8) & 0x000000FF);
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
usb_buf[0x0D] = bright;
}
if(mode == LOGITECH_G203L_MODE_BREATHING)
{
usb_buf[0x09] = (unsigned char)((speed>>8) & 0x000000FF);
usb_buf[0x0A] = (unsigned char)(speed & 0x000000FF);
usb_buf[0x0C] = bright;
}
if(mode == LOGITECH_G203L_MODE_WAVE)
{
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
usb_buf[0x0D] = dir ? 0x01 : 0x06; //0x01: Left->Right 0x06: Right->Left
usb_buf[0x0E] = bright;
usb_buf[0x0F] = (unsigned char)((speed>>8) & 0x000000FF);
}
if(mode == LOGITECH_G203L_MODE_COLORMIXING)
{
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
usb_buf[0x0D] = (unsigned char)((speed>>8) & 0x000000FF);
usb_buf[0x0E] = bright;
}
//END BYTE
usb_buf[0x10] = 0x01;
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
void LogitechG203LController::SetDevice(std::vector<RGBColor> colors)
{
unsigned char usb_buf[20];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x12;
usb_buf[0x03] = 0x1A;
usb_buf[0x04] = 0x01;
usb_buf[0x05] = RGBGetRValue(colors[0]);
usb_buf[0x06] = RGBGetGValue(colors[0]);
usb_buf[0x07] = RGBGetBValue(colors[0]);
usb_buf[0x08] = 0x02;
usb_buf[0x09] = RGBGetRValue(colors[1]);
usb_buf[0x0A] = RGBGetGValue(colors[1]);
usb_buf[0x0B] = RGBGetBValue(colors[1]);
usb_buf[0x0C] = 0x03;
usb_buf[0x0D] = RGBGetRValue(colors[2]);
usb_buf[0x0E] = RGBGetGValue(colors[2]);
usb_buf[0x0F] = RGBGetBValue(colors[2]);
usb_buf[0x10] = 0xFF;
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
SendApply();
}
@@ -0,0 +1,32 @@
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
LOGITECH_G203L_MODE_DIRECT = 0x07,
LOGITECH_G203L_MODE_OFF = 0x00,
LOGITECH_G203L_MODE_STATIC = 0x01,
LOGITECH_G203L_MODE_CYCLE = 0x02,
LOGITECH_G203L_MODE_WAVE = 0x03,
LOGITECH_G203L_MODE_BREATHING = 0x04,
LOGITECH_G203L_MODE_COLORMIXING = 0x06,
};
class LogitechG203LController
{
public:
LogitechG203LController(hid_device* dev_handle);
~LogitechG203LController();
void SetSingleLED(int led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(int mode, int speed, unsigned char brightness, unsigned char dir, unsigned char red, unsigned char green, unsigned char blue);
void SetDevice(std::vector<RGBColor> colors);
private:
hid_device* dev;
void SendApply();
};
@@ -53,7 +53,7 @@ void LogitechG403Controller::SendMouseMode
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
speed = 1000 + 4750 * (LOGITECH_G403_SPEED_FASTEST - speed);
speed = 100 * speed;
if(mode == LOGITECH_G403_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
@@ -22,13 +22,15 @@ enum
LOGITECH_G403_MODE_BREATHING = 0x03,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are mutipled by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G403_SPEED_SLOWEST = 0x00, /* Slowest speed */
LOGITECH_G403_SPEED_SLOW = 0x01, /* Slow speed */
LOGITECH_G403_SPEED_NORMAL = 0x02, /* Normal speed */
LOGITECH_G403_SPEED_FAST = 0x03, /* Fast speed */
LOGITECH_G403_SPEED_FASTEST = 0x04, /* Fastest speed */
LOGITECH_G403_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G403_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G403_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechG403Controller
@@ -0,0 +1,77 @@
/*-----------------------------------------*\
| Logitech502PSController.cpp |
| |
| Driver for Logitech G502 Proteus |
| Spectrum mouse lighting controller |
| |
| kernzerfall 07/28/2020 |
\*-----------------------------------------*/
#include "LogitechG502PSController.h"
#include <cstring>
LogitechG502PSController::LogitechG502PSController(hid_device* dev_handle)
{
dev = dev_handle;
}
LogitechG502PSController::~LogitechG502PSController()
{
hid_close(dev);
}
void LogitechG502PSController::SendMouseMode
(
unsigned char mode,
std::uint16_t speed,
unsigned char channel,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[20];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0xFF;
usb_buf[0x02] = 0x02;
usb_buf[0x03] = 0x3A;
usb_buf[0x04] = channel;
usb_buf[0x05] = mode;
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
speed = 100 * speed;
if(mode == LOGITECH_G502_PS_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
usb_buf[0x0D] = 0x64;
}
else if(mode == LOGITECH_G502_PS_MODE_BREATHING)
{
usb_buf[0x09] = speed >> 8;
usb_buf[0x0A] = speed & 0xFF;
usb_buf[0x0C] = 0x64;
}else if(mode == LOGITECH_G502_PS_MODE_STATIC){
usb_buf[0x09] = 0x02;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
@@ -0,0 +1,55 @@
/*-----------------------------------------*\
| Logitech502PSController.h |
| |
| Definitions and types for Logitech |
| G502 Proteus Spectrum mouse lighting |
| controller |
| |
| kernzerfall 07/28/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
LOGITECH_G502_PS_MODE_OFF = 0x00,
LOGITECH_G502_PS_MODE_STATIC = 0x01,
LOGITECH_G502_PS_MODE_CYCLE = 0x03,
LOGITECH_G502_PS_MODE_BREATHING = 0x02
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are mutipled by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G502_PS_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G502_PS_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G502_PS_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechG502PSController
{
public:
LogitechG502PSController(hid_device* dev_handle);
~LogitechG502PSController();
void SendMouseMode
(
unsigned char mode,
unsigned short speed,
unsigned char channel,
unsigned char red,
unsigned char green,
unsigned char blue
);
private:
hid_device* dev;
};
@@ -10,9 +10,10 @@
#include "LogitechG810Controller.h"
#include <cstring>
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle)
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
{
dev = dev_handle;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
}
LogitechG810Controller::~LogitechG810Controller()
@@ -74,8 +75,8 @@ void LogitechG810Controller::SendCommit()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendDirectFrame
@@ -110,8 +111,8 @@ void LogitechG810Controller::SendDirectFrame
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x12, (unsigned char *)usb_buf, 64);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
void LogitechG810Controller::SendMode
@@ -163,6 +164,6 @@ void LogitechG810Controller::SendMode
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 20);
hid_read(dev, (unsigned char *)usb_buf, 20);
hid_write(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
hid_read(dev_pkt_0x11, (unsigned char *)usb_buf, 20);
}
@@ -49,7 +49,7 @@ enum
class LogitechG810Controller
{
public:
LogitechG810Controller(hid_device* dev_handle);
LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
~LogitechG810Controller();
void Commit();
@@ -71,7 +71,8 @@ public:
);
private:
hid_device* dev;
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
void SendDirectFrame
(
@@ -0,0 +1,82 @@
/*-----------------------------------------*\
| LogitechGPowerPlayController.cpp |
| |
| Driver for Logitech G PowerPlay Wireless |
| Charging System |
| |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#include "LogitechGPowerPlayController.h"
#include <cstring>
LogitechGPowerPlayController::LogitechGPowerPlayController(hid_device* dev_handle)
{
dev = dev_handle;
}
LogitechGPowerPlayController::~LogitechGPowerPlayController()
{
hid_close(dev);
}
void LogitechGPowerPlayController::SendMouseMatMode
(
unsigned char mode,
std::uint16_t speed,
unsigned char zone,
unsigned char red,
unsigned char green,
unsigned char blue
// unsigned char brightness
)
{
unsigned char usb_buf[20];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0x07;
usb_buf[0x02] = 0x0B;
usb_buf[0x03] = 0x3E;
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_G_POWERPLAY_MODE_STATIC)
{
usb_buf[0x09] = 0x02;
}
if(mode == LOGITECH_G_POWERPLAY_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
//usb_buf[0x0D] = brightness;
usb_buf[0x0D] = 0x64;
}
else if(mode == LOGITECH_G_POWERPLAY_MODE_BREATHING)
{
usb_buf[0x09] = speed >> 8;
usb_buf[0x0A] = speed & 0xFF;
//usb_buf[0x0C] = brightness;
usb_buf[0x0C] = 0x64;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
@@ -0,0 +1,55 @@
/*-----------------------------------------*\
| LogitechGPowerPlayController.h |
| |
| Definitions and types for Logitech G |
| PowerPlay Wireless lighting controller |
| |
| TheRogueZeta 8/31/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
LOGITECH_G_POWERPLAY_MODE_OFF = 0x00,
LOGITECH_G_POWERPLAY_MODE_STATIC = 0x01,
LOGITECH_G_POWERPLAY_MODE_CYCLE = 0x02,
LOGITECH_G_POWERPLAY_MODE_BREATHING = 0x03,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are mutipled by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G_POWERPLAY_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G_POWERPLAY_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G_POWERPLAY_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechGPowerPlayController
{
public:
LogitechGPowerPlayController(hid_device* dev_handle);
~LogitechGPowerPlayController();
void SendMouseMatMode
(
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;
};
@@ -0,0 +1,82 @@
/*-----------------------------------------*\
| LogitechGProWirelessController.cpp |
| |
| Driver for Logitech G Pro Wireless Gaming|
| Mouse lighting controller |
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#include "LogitechGProWirelessController.h"
#include <cstring>
LogitechGProWirelessController::LogitechGProWirelessController(hid_device* dev_handle)
{
dev = dev_handle;
}
LogitechGProWirelessController::~LogitechGProWirelessController()
{
hid_close(dev);
}
void LogitechGProWirelessController::SendMouseMode
(
unsigned char mode,
std::uint16_t speed,
unsigned char zone,
unsigned char red,
unsigned char green,
unsigned char blue
// unsigned char brightness
)
{
unsigned char usb_buf[20];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x11;
usb_buf[0x01] = 0x01;
usb_buf[0x02] = 0x07;
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_G_PRO_WIRELESS_MODE_STATIC)
{
usb_buf[0x09] = 0x02;
}
if(mode == LOGITECH_G_PRO_WIRELESS_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
//usb_buf[0x0D] = brightness;
usb_buf[0x0D] = 0x64;
}
else if(mode == LOGITECH_G_PRO_WIRELESS_MODE_BREATHING)
{
usb_buf[0x09] = speed >> 8;
usb_buf[0x0A] = speed & 0xFF;
//usb_buf[0x0C] = brightness;
usb_buf[0x0C] = 0x64;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
@@ -0,0 +1,55 @@
/*-----------------------------------------*\
| LogitechGProWirelessController.h |
| |
| Definitions and types for Logitech G Pro |
| Wireless Gaming Mouse lighting controller|
| |
| TheRogueZeta 8/5/2020 |
\*-----------------------------------------*/
#include "RGBController.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 mutipled 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 LogitechGProWirelessController
{
public:
LogitechGProWirelessController(hid_device* dev_handle);
~LogitechGProWirelessController();
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;
};
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "MSI3ZoneController.h"
#include "RGBController.h"
#include "RGBController_MSI3Zone.h"
@@ -33,4 +34,6 @@ void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers)
rgb_controllers.push_back(rgb_controller);
}
}
} /* DetectMSI3ZoneControllers() */
REGISTER_DETECTOR("MSI 3-Zone Laptop", DetectMSI3ZoneControllers);
@@ -0,0 +1,67 @@
/*-----------------------------------------*\
| MSIGPUController.cpp |
| |
| Driver for MSI GPUs |
| |
\*-----------------------------------------*/
#include "MSIGPUController.h"
#include <cstring>
MSIGPUController::MSIGPUController(i2c_smbus_interface* bus)
{
this->bus = bus;
this->dev = 0x68;
}
MSIGPUController::~MSIGPUController()
{
}
std::string MSIGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
void MSIGPUController::SetRGB1(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R1, red);
MSIGPURegisterWrite(MSI_GPU_REG_G1, green);
MSIGPURegisterWrite(MSI_GPU_REG_B1, blue);
}
void MSIGPUController::SetRGB2(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R2, red);
MSIGPURegisterWrite(MSI_GPU_REG_G2, green);
MSIGPURegisterWrite(MSI_GPU_REG_B2, blue);
}
void MSIGPUController::SetRGB3(unsigned char red, unsigned char green, unsigned char blue)
{
MSIGPURegisterWrite(MSI_GPU_REG_R3, red);
MSIGPURegisterWrite(MSI_GPU_REG_G3, green);
MSIGPURegisterWrite(MSI_GPU_REG_B3, blue);
}
void MSIGPUController::SetMode(unsigned char mode)
{
MSIGPURegisterWrite(MSI_GPU_REG_MODE, mode);
MSIGPURegisterWrite(MSI_GPU_REG_APPLY, 0x01);
}
unsigned char MSIGPUController::MSIGPURegisterRead(unsigned char reg)
{
return(bus->i2c_smbus_read_byte_data(dev, reg));
}
void MSIGPUController::MSIGPURegisterWrite(unsigned char reg, unsigned char val)
{
bus->i2c_smbus_write_byte_data(dev, reg, val);
}
@@ -0,0 +1,77 @@
/*-----------------------------------------*\
| MSIGPUController.h |
| |
| Definitions for MSI GPUs |
| |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char msi_gpu_dev_id;
enum
{
MSI_GPU_REG_BRIGHTNESS = 0x36, /* MSI GPU Brightness Register */
MSI_GPU_REG_SPEED = 0x38, /* MSI GPU Speed Register */
MSI_GPU_REG_UNKNOWN = 0x26, /* MSI GPU Unknown Register */
MSI_GPU_REG_R1 = 0x30, /* MSI GPU R1 Register */
MSI_GPU_REG_G1 = 0x31, /* MSI GPU G1 Register */
MSI_GPU_REG_B1 = 0x32, /* MSI GPU B1 Register */
MSI_GPU_REG_R2 = 0x27, /* MSI GPU R2 Register */
MSI_GPU_REG_G2 = 0x28, /* MSI GPU G2 Register */
MSI_GPU_REG_B2 = 0x29, /* MSI GPU B2 Register */
MSI_GPU_REG_R3 = 0x2a, /* MSI GPU R3 Register */
MSI_GPU_REG_G3 = 0x2b, /* MSI GPU G3 Register */
MSI_GPU_REG_B3 = 0x2c, /* MSI GPU B3 Register */
MSI_GPU_REG_MODE = 0x22, /* MSI GPU Mode Selection Register */
MSI_GPU_REG_APPLY = 0x3f, /* MSI GPU Apply Changes Register */
};
enum
{
MSI_GPU_MODE_OFF = 0x01, /* OFF mode */
MSI_GPU_MODE_RAINBOW = 0x08, /* Rainbow effect mode */
MSI_GPU_MODE_STATIC = 0x13, /* Static color mode */
MSI_GPU_MODE_RAINDROP = 0x1a, /* Raindrop effect mode */
MSI_GPU_MODE_MAGIC = 0x07, /* Magic effect mode */
MSI_GPU_MODE_PATROLLING = 0x05, /* Patrolling effect mode */
MSI_GPU_MODE_STREAMING = 0x06, /* Streaming effect mode */
MSI_GPU_MODE_LIGHTNING = 0x15, /* Lightning effect mode */
MSI_GPU_MODE_WAVE = 0x1f, /* Wave effect mode */
MSI_GPU_MODE_METEOR = 0x16, /* Meteor effect mode */
MSI_GPU_MODE_STACK = 0x0d, /* Stack effect mode */
MSI_GPU_MODE_RHYTHM = 0x0b, /* Rhythm effect mode */
MSI_GPU_MODE_FLOWING = 0x09, /* Flowing effect mode */
MSI_GPU_MODE_WHIRLING = 0x0f, /* Whirling effect mode */
MSI_GPU_MODE_TWISTING = 0x11, /* Twisting effect mode */
MSI_GPU_MODE_LAMINATING = 0x1d, /* Laminating effect mode */
MSI_GPU_MODE_FADEIN = 0x14, /* Fadein effect mode */
MSI_GPU_MODE_BREATHING = 0x04, /* Breathing effect mode */
MSI_GPU_MODE_FLASHING = 0x02, /* Flashing effect mode */
MSI_GPU_MODE_DOUBLEFLASHING = 0x03, /* Doubleflashing effect mode */
};
class MSIGPUController
{
public:
MSIGPUController(i2c_smbus_interface* bus);
~MSIGPUController();
std::string GetDeviceLocation();
void SetRGB1(unsigned char red, unsigned char green, unsigned char blue);
void SetRGB2(unsigned char red, unsigned char green, unsigned char blue);
void SetRGB3(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned char MSIGPURegisterRead(unsigned char reg);
void MSIGPURegisterWrite(unsigned char reg, unsigned char val);
private:
i2c_smbus_interface * bus;
msi_gpu_dev_id dev;
};
@@ -0,0 +1,121 @@
/*-----------------------------------------*\
| MSIGPUControllerDetect.cpp |
| |
| Driver for MSI GPUs |
| |
\*-----------------------------------------*/
#include "Detector.h"
#include "MSIGPUController.h"
#include "RGBController.h"
#include "RGBController_MSIGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/*-----------------------------------------------------*\
| NVidia vendor ID |
\*-----------------------------------------------------*/
#define NVIDIA_VEN 0x10DE
/*-----------------------------------------------------*\
| NVidia device IDs |
\*-----------------------------------------------------*/
#define NVIDIA_GTX1070_DEV 0x1B81
#define NVIDIA_RTX2060_DEV 0x1F08
#define NVIDIA_RTX2060S_DEV 0x1F06
#define NVIDIA_RTX2070_DEV 0x1F02
#define NVIDIA_RTX2070S_DEV 0x1E84
#define NVIDIA_RTX2080_DEV 0x1E87
#define NVIDIA_RTX2080S_DEV 0x1E81
#define NVIDIA_RTX2080TI_DEV 0x1E07
/*-----------------------------------------------------*\
| MSI sub-vendor ID |
\*-----------------------------------------------------*/
#define MSI_SUB_VEN 0x1462
/*-----------------------------------------------------*\
| MSI sub-device IDs |
\*-----------------------------------------------------*/
#define MSI_GTX1070_GAMING_X_SUB_DEV 0x3306
#define MSI_RTX2060S_GAMING_X_SUB_DEV 0xC752
#define MSI_RTX2070S_GAMING_X_SUB_DEV 0x373e
#define MSI_RTX2070S_GAMING_X_TRIO_SUB_DEV 0xC726
#define MSI_RTX2080_GAMING_X_TRIO_SUB_DEV 0x3726
#define MSI_RTX2080S_GAMING_X_TRIO_SUB_DEV 0xC724
#define MSI_RTX2080TI_GAMING_X_TRIO_SUB_DEV 0x3715
#define MSI_RTX2060_GAMING_Z_6G_SUB_DEV 0x3754
#define MSI_RTX2060_GAMING_Z_6G_SUB_DEV_2 0x3752
#define MSI_RTX2070_ARMOR_SUB_DEV 0x3734
#define MSI_RTX2060S_ARMOR_OC_SUB_DEV 0xC754
#define MSI_RTX2080_SEA_HAWK_EK_X_SUB_DEV 0x3728
#define MSI_RTX2080TI_SEA_HAWK_EK_X_SUB_DEV 0x3717
typedef struct
{
int pci_vendor;
int pci_device;
int pci_subsystem_vendor;
int pci_subsystem_device;
const char * name;
} msi_gpu_pci_device;
#define MSI_GPU_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const msi_gpu_pci_device device_list[] =
{
{ NVIDIA_VEN, NVIDIA_GTX1070_DEV, MSI_SUB_VEN, MSI_GTX1070_GAMING_X_SUB_DEV, "MSI GeForce GTX 1070 Gaming X" },
{ NVIDIA_VEN, NVIDIA_RTX2060S_DEV, MSI_SUB_VEN, MSI_RTX2060S_GAMING_X_SUB_DEV, "MSI GeForce RTX 2060 Super Gaming X" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, MSI_SUB_VEN, MSI_RTX2070S_GAMING_X_SUB_DEV, "MSI GeForce RTX 2070 Super Gaming X" },
{ NVIDIA_VEN, NVIDIA_RTX2070S_DEV, MSI_SUB_VEN, MSI_RTX2070S_GAMING_X_TRIO_SUB_DEV, "MSI GeForce RTX 2070 Super Gaming X Trio" },
{ NVIDIA_VEN, NVIDIA_RTX2080_DEV, MSI_SUB_VEN, MSI_RTX2080_GAMING_X_TRIO_SUB_DEV, "MSI GeForce RTX 2080 Gaming X Trio" },
{ NVIDIA_VEN, NVIDIA_RTX2080S_DEV, MSI_SUB_VEN, MSI_RTX2080S_GAMING_X_TRIO_SUB_DEV, "MSI GeForce RTX 2080 Super Gaming X Trio" },
{ NVIDIA_VEN, NVIDIA_RTX2080TI_DEV, MSI_SUB_VEN, MSI_RTX2080TI_GAMING_X_TRIO_SUB_DEV, "MSI GeForce RTX 2080Ti Gaming X Trio" },
{ NVIDIA_VEN, NVIDIA_RTX2060_DEV, MSI_SUB_VEN, MSI_RTX2060_GAMING_Z_6G_SUB_DEV, "MSI GeForce RTX 2060 Gaming Z 6G" },
{ NVIDIA_VEN, NVIDIA_RTX2060_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_ARMOR_OC_SUB_DEV, "MSI GeForce RTX 2060 Super ARMOR OC" },
{ NVIDIA_VEN, NVIDIA_RTX2070_DEV, MSI_SUB_VEN, MSI_RTX2070_ARMOR_SUB_DEV, "MSI GeForce RTX 2070 ARMOR" },
{ NVIDIA_VEN, NVIDIA_RTX2080_DEV, MSI_SUB_VEN, MSI_RTX2080_SEA_HAWK_EK_X_SUB_DEV, "MSI GeForce RTX 2080 Sea Hawk EK X" },
{ NVIDIA_VEN, NVIDIA_RTX2080TI_DEV, MSI_SUB_VEN, MSI_RTX2080TI_SEA_HAWK_EK_X_SUB_DEV, "MSI GeForce RTX 2080Ti Sea Hawk EK X" },
};
/******************************************************************************************\
* *
* DetectMSIGPUControllers *
* *
* Detect MSI GPU controllers on the enumerated I2C busses. *
* *
\******************************************************************************************/
void DetectMSIGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
MSIGPUController* new_msi_gpu;
RGBController_MSIGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
for(unsigned int dev_idx = 0; dev_idx < MSI_GPU_NUM_DEVICES; dev_idx++)
{
if (busses[bus]->port_id != 1)
{
break;
}
if(busses[bus]->pci_vendor == device_list[dev_idx].pci_vendor &&
busses[bus]->pci_device == device_list[dev_idx].pci_device &&
busses[bus]->pci_subsystem_vendor == device_list[dev_idx].pci_subsystem_vendor &&
busses[bus]->pci_subsystem_device == device_list[dev_idx].pci_subsystem_device)
{
new_msi_gpu = new MSIGPUController(busses[bus]);
new_controller = new RGBController_MSIGPU(new_msi_gpu);
new_controller->name = device_list[dev_idx].name;
rgb_controllers.push_back(new_controller);
}
}
}
} /* DetectMSIGPUControllers() */
REGISTER_I2C_DETECTOR("MSI GPU", DetectMSIGPUControllers);
@@ -35,25 +35,34 @@ MSIMysticLightController::~MSIMysticLightController()
}
}
unsigned int MSIMysticLightController::GetZoneMinLedCount(ZONE /*zone*/)
unsigned int MSIMysticLightController::GetZoneMinLedCount
(
MSI_ZONE /*zone*/
)
{
return 1u;
return 1;
}
unsigned int MSIMysticLightController::GetZoneMaxLedCount(ZONE zone)
unsigned int MSIMysticLightController::GetZoneMaxLedCount
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RAINBOW_1:
case J_RAINBOW_2:
case J_CORSAIR:
return 4u; // TODO: It can be different by zone and by mobo
case MSI_ZONE_J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_2:
case MSI_ZONE_J_CORSAIR:
return 4; // TODO: It can be different by zone and by mobo
default:
return 1u;
return 1;
}
}
unsigned int MSIMysticLightController::GetZoneLedCount(ZONE zone)
unsigned int MSIMysticLightController::GetZoneLedCount
(
MSI_ZONE zone
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -65,7 +74,11 @@ unsigned int MSIMysticLightController::GetZoneLedCount(ZONE zone)
return requestedZone->cycle_or_led_num;
}
void MSIMysticLightController::SetZoneLedCount(ZONE zone, unsigned int led_count)
void MSIMysticLightController::SetZoneLedCount
(
MSI_ZONE zone,
unsigned int led_count
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -78,7 +91,14 @@ void MSIMysticLightController::SetZoneLedCount(ZONE zone, unsigned int led_count
requestedZone->cycle_or_led_num = led_count;
}
void MSIMysticLightController::SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color)
void MSIMysticLightController::SetMode
(
MSI_ZONE zone,
MSI_MODE mode,
MSI_SPEED speed,
MSI_BRIGHTNESS brightness,
bool rainbow_color
)
{
ZoneData* zoneData = GetZoneData(zone);
if(!zoneData)
@@ -113,12 +133,18 @@ std::string MSIMysticLightController::GetSerial()
bool MSIMysticLightController::ReadSettings()
{
return hid_get_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
/*-----------------------------------------------------*\
| Read packet from hardware, return true if successful |
\*-----------------------------------------------------*/
return(hid_get_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data);
}
bool MSIMysticLightController::Update()
{
return hid_send_feature_report(dev, reinterpret_cast<unsigned char *>(&data), sizeof data) == sizeof data;
/*-----------------------------------------------------*\
| Send packet to hardware, return true if successful |
\*-----------------------------------------------------*/
return(hid_send_feature_report(dev, (unsigned char *)&data, sizeof(data)) == sizeof data);
}
void MSIMysticLightController::SaveOnUpdate(bool save)
@@ -126,26 +152,40 @@ void MSIMysticLightController::SaveOnUpdate(bool save)
data.save_data = save;
}
void MSIMysticLightController::SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2)
void MSIMysticLightController::SetZoneColor
(
MSI_ZONE zone,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
ZoneData* zoneData = GetZoneData(zone);
if(!zoneData)
{
return;
}
zoneData->color.R = r1;
zoneData->color.G = g1;
zoneData->color.B = b1;
zoneData->color.R = red1;
zoneData->color.G = grn1;
zoneData->color.B = blu1;
zoneData->color2.R = r2;
zoneData->color2.G = g2;
zoneData->color2.B = b2;
zoneData->color2.R = red2;
zoneData->color2.G = grn2;
zoneData->color2.B = blu2;
}
std::pair<Color, Color> MSIMysticLightController::GetZoneColor(ZONE zone)
std::pair<Color, Color> MSIMysticLightController::GetZoneColor
(
MSI_ZONE zone
)
{
ZoneData *zoneData = GetZoneData(zone);
if (!zoneData)
{
return std::make_pair(Color{}, Color{});
@@ -158,61 +198,67 @@ std::pair<Color, Color> MSIMysticLightController::GetZoneColor(ZONE zone)
Color{zoneData->color2.R, zoneData->color2.G, zoneData->color2.B});
}
ZoneData *MSIMysticLightController::GetZoneData(ZONE zone)
ZoneData *MSIMysticLightController::GetZoneData
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RGB_1:
case MSI_ZONE_J_RGB_1:
return &data.j_rgb_1;
case J_RGB_2:
case MSI_ZONE_J_RGB_2:
return &data.j_rgb_2;
case J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_1:
return &data.j_rainbow_1;
case J_RAINBOW_2:
case MSI_ZONE_J_RAINBOW_2:
return &data.j_rainbow_2;
case J_PIPE_1:
case MSI_ZONE_J_PIPE_1:
return &data.j_pipe_1;
case J_PIPE_2:
case MSI_ZONE_J_PIPE_2:
return &data.j_pipe_2;
case ON_BOARD_LED:
case MSI_ZONE_ON_BOARD_LED:
return &data.on_board_led;
case ON_BOARD_LED_1:
case MSI_ZONE_ON_BOARD_LED_1:
return &data.on_board_led_1;
case ON_BOARD_LED_2:
case MSI_ZONE_ON_BOARD_LED_2:
return &data.on_board_led_2;
case ON_BOARD_LED_3:
case MSI_ZONE_ON_BOARD_LED_3:
return &data.on_board_led_3;
case ON_BOARD_LED_4:
case MSI_ZONE_ON_BOARD_LED_4:
return &data.on_board_led_4;
case ON_BOARD_LED_5:
case MSI_ZONE_ON_BOARD_LED_5:
return &data.on_board_led_5;
case ON_BOARD_LED_6:
case MSI_ZONE_ON_BOARD_LED_6:
return &data.on_board_led_6;
case ON_BOARD_LED_7:
case MSI_ZONE_ON_BOARD_LED_7:
return &data.on_board_led_7;
case ON_BOARD_LED_8:
case MSI_ZONE_ON_BOARD_LED_8:
return &data.on_board_led_8;
case ON_BOARD_LED_9:
case MSI_ZONE_ON_BOARD_LED_9:
return &data.on_board_led_9;
case J_CORSAIR_OUTERLL120:
case MSI_ZONE_J_CORSAIR_OUTERLL120:
return &data.j_corsair_outerll120;
default:
case J_CORSAIR:
case MSI_ZONE_J_CORSAIR:
break;
}
return nullptr;
}
RainbowZoneData *MSIMysticLightController::GetRainbowZoneData(ZONE zone)
RainbowZoneData *MSIMysticLightController::GetRainbowZoneData
(
MSI_ZONE zone
)
{
switch (zone)
switch(zone)
{
case J_RAINBOW_1:
case MSI_ZONE_J_RAINBOW_1:
return &data.j_rainbow_1;
case J_RAINBOW_2:
case MSI_ZONE_J_RAINBOW_2:
return &data.j_rainbow_2;
case J_CORSAIR:
case MSI_ZONE_J_CORSAIR:
default:
return nullptr;
}
@@ -220,39 +266,98 @@ RainbowZoneData *MSIMysticLightController::GetRainbowZoneData(ZONE zone)
bool MSIMysticLightController::ReadFwVersion()
{
// First read the APROM
// Checksum also available at report ID 180, with highCheksum stored at index 8, and low at 9
int num = 1;
unsigned char request[64] = {1, 176};
unsigned char request[64];
unsigned char response[64];
int ret_val = 64;
std::fill_n(request + 2, sizeof request - 2, 204);
num &= hid_write(dev, request, 64);
num &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| First read the APROM |
| Checksum also available at report ID 180, with MSB |
| stored at index 0x08 and LSB at 0x09 |
\*-----------------------------------------------------*/
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(request, 0x00, sizeof(request));
memset(response, 0x00, sizeof(response));
/*-----------------------------------------------------*\
| Set up APROM Firmware Version Request packet |
\*-----------------------------------------------------*/
request[0x00] = 0x01;
request[0x01] = 0xB0;
/*-----------------------------------------------------*\
| Fill request from 0x02 to 0x61 with 0xCC |
\*-----------------------------------------------------*/
memset(&request[0x02], 0xCC, sizeof(request) - 2);
/*-----------------------------------------------------*\
| Send request and receive response packets |
\*-----------------------------------------------------*/
ret_val &= hid_write(dev, request, 64);
ret_val &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| Extract high and low values from response |
\*-----------------------------------------------------*/
unsigned char highValue = response[2] >> 4;
unsigned char lowValue = response[2] & 15;
unsigned char lowValue = response[2] & 0x0F;
/*-----------------------------------------------------*\
| Build firmware string <high>.<low> |
\*-----------------------------------------------------*/
version_APROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
// Now read the LDROM
// Checksum also available at report ID 184, with highCheksum stored at index 8, and low at 9
request[1] = 182u;
num &= hid_write(dev, request, 64);
num &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| First read the LDROM |
| Checksum also available at report ID 184, with MSB |
| stored at index 0x08 and LSB at 0x09 |
\*-----------------------------------------------------*/
highValue = response[2] >> 4u;
lowValue = response[2] & 15u;
/*-----------------------------------------------------*\
| Set up LDROM Firmware Version Request packet |
\*-----------------------------------------------------*/
request[0x00] = 0x01;
request[0x01] = 0xB6;
/*-----------------------------------------------------*\
| Send request and receive response packets |
\*-----------------------------------------------------*/
ret_val &= hid_write(dev, request, 64);
ret_val &= hid_read(dev, response, 64);
/*-----------------------------------------------------*\
| Extract high and low values from response |
\*-----------------------------------------------------*/
highValue = response[2] >> 4;
lowValue = response[2] & 0x0F;
/*-----------------------------------------------------*\
| Build firmware string <high>.<low> |
\*-----------------------------------------------------*/
version_LDROM = std::to_string(static_cast<int>(highValue)).append(".").append(std::to_string(static_cast<int>(lowValue)));
return num == 1;
/*-----------------------------------------------------*\
| If return value is zero it means an HID transfer |
| failed |
\*-----------------------------------------------------*/
return(ret_val > 0);
}
void MSIMysticLightController::ReadSerial()
{
wchar_t serial[256];
/*-----------------------------------------------------*\
| Get the serial number string from HID |
\*-----------------------------------------------------*/
hid_get_serial_number_string(dev, serial, 256);
/*-----------------------------------------------------*\
| Convert wchar_t into std::wstring into std::string |
\*-----------------------------------------------------*/
std::wstring wserial = std::wstring(serial);
chip_id = std::string(wserial.begin(), wserial.end());
}
@@ -260,27 +365,53 @@ void MSIMysticLightController::ReadSerial()
void MSIMysticLightController::ReadName()
{
wchar_t tname[256];
/*-----------------------------------------------------*\
| Get the manufacturer string from HID |
\*-----------------------------------------------------*/
hid_get_manufacturer_string(dev, tname, 256);
/*-----------------------------------------------------*\
| Convert wchar_t into std::wstring into std::string |
\*-----------------------------------------------------*/
std::wstring wname = std::wstring(tname);
name = std::string(wname.begin(), wname.end());
/*-----------------------------------------------------*\
| Get the product string from HID |
\*-----------------------------------------------------*/
hid_get_product_string(dev, tname, 256);
/*-----------------------------------------------------*\
| Append the product string to the manufacturer string |
\*-----------------------------------------------------*/
wname = std::wstring(tname);
name.append(" ").append(std::string(wname.begin(), wname.end()));
}
void MSIMysticLightController::SetDeviceSettings(bool is_fan, FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual)
void MSIMysticLightController::SetDeviceSettings
(
bool is_fan,
MSI_FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual
)
{
// If is_fan false, it is a stripe
CorsairZoneData &settingsZone = data.j_corsair;
settingsZone.fan_flags = (settingsZone.fan_flags & 128u) | fan_type << 1u | is_fan;
settingsZone.corsair_quantity = corsair_device_quantity << 2u;
settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0u);
/*-----------------------------------------------------*\
| If is_fan is false, it is an LED strip |
\*-----------------------------------------------------*/
CorsairZoneData &settingsZone = data.j_corsair;
settingsZone.fan_flags = (settingsZone.fan_flags & 0x80) | fan_type << 1 | is_fan;
settingsZone.corsair_quantity = corsair_device_quantity << 2;
settingsZone.is_individual = BitSet(settingsZone.is_individual, is_LL120Outer_individual, 0);
}
bool MSIMysticLightController::SetVolume(unsigned char main, unsigned char left, unsigned char right)
bool MSIMysticLightController::SetVolume
(
unsigned char main,
unsigned char left,
unsigned char right
)
{
unsigned char packet[64];
std::fill_n(packet, sizeof packet, 204u);
@@ -309,41 +440,78 @@ bool MSIMysticLightController::SetVolume(unsigned char main, unsigned char left,
return hid_write(dev, packet, sizeof packet);
}
void MSIMysticLightController::SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1,
bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2,
bool combine_crossair)
void MSIMysticLightController::SetBoardSyncSettings
(
bool onboard_sync,
bool combine_JRGB,
bool combine_JPIPE1,
bool combine_JPIPE2,
bool combine_JRAINBOW1,
bool combine_JRAINBOW2,
bool combine_crossair
)
{
ZoneData &syncZone = data.on_board_led;
syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4u);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5u);
syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7u);
/*-----------------------------------------------------*\
| Set sync flags for on-board LED zone |
\*-----------------------------------------------------*/
syncZone.colorFlags = BitSet(syncZone.colorFlags, onboard_sync, 0);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW1, 1);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JRAINBOW2, 2);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_crossair, 3);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE1, 4);
syncZone.colorFlags = BitSet(syncZone.colorFlags, combine_JPIPE2, 5);
syncZone.speedAndBrightnessFlags = BitSet(syncZone.speedAndBrightnessFlags, combine_JRGB, 7);
}
void MSIMysticLightController::GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color)
void MSIMysticLightController::GetMode
(
MSI_ZONE zone,
MSI_MODE &mode,
MSI_SPEED &speed,
MSI_BRIGHTNESS &brightness,
bool &rainbow_color
)
{
/*-----------------------------------------------------*\
| Get data for given zone |
\*-----------------------------------------------------*/
ZoneData *zoneData = GetZoneData(zone);
/*-----------------------------------------------------*\
| Return if zone is invalid |
\*-----------------------------------------------------*/
if (!zoneData)
{
return;
}
mode = static_cast<EFFECT>(zoneData->effect);
speed = static_cast<SPEED>(zoneData->speedAndBrightnessFlags & 3u);
brightness = static_cast<BRIGHTNESS>((zoneData->speedAndBrightnessFlags >> 2u) & 31u);
rainbow_color = (zoneData->colorFlags & 128u) >> 7u;
/*-----------------------------------------------------*\
| Update pointers with data |
\*-----------------------------------------------------*/
mode = (MSI_MODE)(zoneData->effect);
speed = (MSI_SPEED)(zoneData->speedAndBrightnessFlags & 0x03);
brightness = (MSI_BRIGHTNESS)((zoneData->speedAndBrightnessFlags >> 2) & 0x1F);
rainbow_color = (zoneData->colorFlags & 0x80) >> 7;
}
unsigned char MSIMysticLightController::BitSet(unsigned char value, bool bit, unsigned int position)
unsigned char MSIMysticLightController::BitSet
(
unsigned char value,
bool bit,
unsigned int position
)
{
return static_cast<unsigned char>(std::bitset<8>(value).set(position, bit).to_ulong());
}
void MSIMysticLightController::SetCycleCount(ZONE zone, unsigned char cycle_num)
void MSIMysticLightController::SetCycleCount
(
MSI_ZONE zone,
unsigned char cycle_num
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -355,7 +523,10 @@ void MSIMysticLightController::SetCycleCount(ZONE zone, unsigned char cycle_num)
requestedZone->cycle_or_led_num = cycle_num;
}
unsigned char MSIMysticLightController::GetCycleCount(ZONE zone)
unsigned char MSIMysticLightController::GetCycleCount
(
MSI_ZONE zone
)
{
RainbowZoneData *requestedZone = GetRainbowZoneData(zone);
@@ -367,28 +538,43 @@ unsigned char MSIMysticLightController::GetCycleCount(ZONE zone)
return requestedZone->cycle_or_led_num;
}
void MSIMysticLightController::GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1,
bool &combine_JPIPE2, bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2, bool &combine_crossair)
void MSIMysticLightController::GetBoardSyncSettings
(
bool &onboard_sync,
bool &combine_JRGB,
bool &combine_JPIPE1,
bool &combine_JPIPE2,
bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2,
bool &combine_crossair
)
{
ZoneData &syncZone = data.on_board_led;
onboard_sync = syncZone.colorFlags & 1u;
combine_JRAINBOW1 = syncZone.colorFlags >> 1u & 1u;
combine_JRAINBOW2 = syncZone.colorFlags >> 1u & 1u;
combine_crossair = syncZone.colorFlags >> 3u & 1u;
combine_JPIPE1 = syncZone.colorFlags >> 4u & 1u;
combine_JPIPE2 = syncZone.colorFlags >> 5u & 1u;
combine_JRGB = (syncZone.speedAndBrightnessFlags & 128u) >> 7u;
/*-----------------------------------------------------*\
| Get sync flags for on-board LED zone |
\*-----------------------------------------------------*/
onboard_sync = (syncZone.colorFlags >> 0) & 0x01;
combine_JRAINBOW1 = (syncZone.colorFlags >> 1) & 0x01;
combine_JRAINBOW2 = (syncZone.colorFlags >> 2) & 0x01;
combine_crossair = (syncZone.colorFlags >> 3) & 0x01;
combine_JPIPE1 = (syncZone.colorFlags >> 4) & 0x01;
combine_JPIPE2 = (syncZone.colorFlags >> 5) & 0x01;
combine_JRGB = (syncZone.speedAndBrightnessFlags & 0x80) >> 7;
}
void MSIMysticLightController::GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual)
void MSIMysticLightController::GetDeviceSettings
(
bool &stripe_or_fan,
MSI_FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual
)
{
CorsairZoneData &settingsZone = data.j_corsair;
stripe_or_fan = settingsZone.fan_flags & 1u;
fan_type = static_cast<FAN_TYPE >((settingsZone.fan_flags & 14u) >> 1u);
corsair_device_quantity = (settingsZone.corsair_quantity & 252u) >> 2u;
is_LL120Outer_individual = settingsZone.is_individual & 1u;
CorsairZoneData &settingsZone = data.j_corsair;
stripe_or_fan = settingsZone.fan_flags & 0x01;
fan_type = (MSI_FAN_TYPE )((settingsZone.fan_flags & 14u) >> 1);
corsair_device_quantity = (settingsZone.corsair_quantity & 0xFC) >> 2;
is_LL120Outer_individual = settingsZone.is_individual & 0x01;
}
@@ -14,105 +14,105 @@
#pragma once
enum ZONE
enum MSI_ZONE
{
J_RGB_1 = 1,
J_RGB_2 = 174,
J_PIPE_1 = 11,
J_PIPE_2 = 21,
J_RAINBOW_1 = 31,
J_RAINBOW_2 = 42,
J_CORSAIR = 53,
J_CORSAIR_OUTERLL120 = 64,
ON_BOARD_LED = 74,
ON_BOARD_LED_1 = 84,
ON_BOARD_LED_2 = 94,
ON_BOARD_LED_3 = 104,
ON_BOARD_LED_4 = 114,
ON_BOARD_LED_5 = 124,
ON_BOARD_LED_6 = 134,
ON_BOARD_LED_7 = 144,
ON_BOARD_LED_8 = 154,
ON_BOARD_LED_9 = 164
MSI_ZONE_J_RGB_1 = 1,
MSI_ZONE_J_RGB_2 = 174,
MSI_ZONE_J_PIPE_1 = 11,
MSI_ZONE_J_PIPE_2 = 21,
MSI_ZONE_J_RAINBOW_1 = 31,
MSI_ZONE_J_RAINBOW_2 = 42,
MSI_ZONE_J_CORSAIR = 53,
MSI_ZONE_J_CORSAIR_OUTERLL120 = 64,
MSI_ZONE_ON_BOARD_LED = 74,
MSI_ZONE_ON_BOARD_LED_1 = 84,
MSI_ZONE_ON_BOARD_LED_2 = 94,
MSI_ZONE_ON_BOARD_LED_3 = 104,
MSI_ZONE_ON_BOARD_LED_4 = 114,
MSI_ZONE_ON_BOARD_LED_5 = 124,
MSI_ZONE_ON_BOARD_LED_6 = 134,
MSI_ZONE_ON_BOARD_LED_7 = 144,
MSI_ZONE_ON_BOARD_LED_8 = 154,
MSI_ZONE_ON_BOARD_LED_9 = 164
};
struct ZoneDescription
{
std::string name;
ZONE value;
MSI_ZONE value;
};
enum EFFECT
enum MSI_MODE
{
DISABLE,
STATIC,
BREATHING,
FLASHING,
DOUBLE_FLASHING,
LIGHTNING,
MSI_MARQUEE,
METEOR,
WATER_DROP,
MSI_RAINBOW,
POP,
RAP,
JAZZ,
PLAY,
MOVIE,
COLOR_RING,
PLANETARY,
DOUBLE_METEOR,
ENERGY,
BLINK,
CLOCK,
COLOR_PULSE,
COLOR_SHIFT,
COLOR_WAVE,
MARQUEE,
RAINBOW,
RAINBOW_WAVE,
VISOR,
JRAINBOW,
RAINBOW_FLASHING,
RAINBOW_DOUBLE_FLASHING,
RANDOM,
FAN_CONTROL,
DISABLE_2,
COLOR_RING_FLASHING,
COLOR_RING_DOUBLE_FLASHING,
STACK,
CORSAIR_QUE,
FIRE,
LAVA
MSI_MODE_DISABLE = 0,
MSI_MODE_STATIC = 1,
MSI_MODE_BREATHING = 2,
MSI_MODE_FLASHING = 3,
MSI_MODE_DOUBLE_FLASHING = 4,
MSI_MODE_LIGHTNING = 5,
MSI_MODE_MSI_MARQUEE = 6,
MSI_MODE_METEOR = 7,
MSI_MODE_WATER_DROP = 8,
MSI_MODE_MSI_RAINBOW = 9,
MSI_MODE_POP = 10,
MSI_MODE_RAP = 11,
MSI_MODE_JAZZ = 12,
MSI_MODE_PLAY = 13,
MSI_MODE_MOVIE = 14,
MSI_MODE_COLOR_RING = 15,
MSI_MODE_PLANETARY = 16,
MSI_MODE_DOUBLE_METEOR = 17,
MSI_MODE_ENERGY = 18,
MSI_MODE_BLINK = 19,
MSI_MODE_CLOCK = 20,
MSI_MODE_COLOR_PULSE = 21,
MSI_MODE_COLOR_SHIFT = 22,
MSI_MODE_COLOR_WAVE = 23,
MSI_MODE_MARQUEE = 24,
MSI_MODE_RAINBOW = 25,
MSI_MODE_RAINBOW_WAVE = 26,
MSI_MODE_VISOR = 27,
MSI_MODE_JRAINBOW = 28,
MSI_MODE_RAINBOW_FLASHING = 29,
MSI_MODE_RAINBOW_DOUBLE_FLASHING = 30,
MSI_MODE_RANDOM = 31,
MSI_MODE_FAN_CONTROL = 32,
MSI_MODE_DISABLE_2 = 33,
MSI_MODE_COLOR_RING_FLASHING = 34,
MSI_MODE_COLOR_RING_DOUBLE_FLASHING = 35,
MSI_MODE_STACK = 36,
MSI_MODE_CORSAIR_QUE = 37,
MSI_MODE_FIRE = 38,
MSI_MODE_LAVA = 39,
};
enum SPEED
enum MSI_SPEED
{
LOW,
MEDIUM,
HIGH
MSI_SPEED_LOW = 0,
MSI_SPEED_MEDIUM = 1,
MSI_SPEED_HIGH = 2,
};
enum FAN_TYPE
enum MSI_FAN_TYPE
{
SP,
HD,
LL
MSI_FAN_TYPE_SP = 0,
MSI_FAN_TYPE_HD = 1,
MSI_FAN_TYPE_LL = 2,
};
enum BRIGHTNESS
enum MSI_BRIGHTNESS
{
OFF,
LEVEL_10,
LEVEL_20,
LEVEL_30,
LEVEL_40,
LEVEL_50,
LEVEL_60,
LEVEL_70,
LEVEL_80,
LEVEL_90,
LEVEL_100
MSI_BRIGHTNESS_OFF = 0,
MSI_BRIGHTNESS_LEVEL_10 = 1,
MSI_BRIGHTNESS_LEVEL_20 = 2,
MSI_BRIGHTNESS_LEVEL_30 = 3,
MSI_BRIGHTNESS_LEVEL_40 = 4,
MSI_BRIGHTNESS_LEVEL_50 = 5,
MSI_BRIGHTNESS_LEVEL_60 = 6,
MSI_BRIGHTNESS_LEVEL_70 = 7,
MSI_BRIGHTNESS_LEVEL_80 = 8,
MSI_BRIGHTNESS_LEVEL_90 = 9,
MSI_BRIGHTNESS_LEVEL_100 = 10,
};
struct Color
@@ -124,54 +124,51 @@ struct Color
struct CorsairZoneData
{
unsigned char effect = EFFECT::STATIC;
Color color { std::numeric_limits<unsigned char>::max(), 0, 0 };
unsigned char fan_flags = 40;
unsigned char effect = MSI_MODE_STATIC;
Color color { 0, 0, 0 };
unsigned char fan_flags = 40;
unsigned char corsair_quantity;
unsigned char padding[3];
unsigned char is_individual = 0;
unsigned char is_individual = 0;
};
struct ZoneData
{
unsigned char effect = EFFECT::STATIC;
Color color { std::numeric_limits<unsigned char>::max(), 0u, 0u };
unsigned char speedAndBrightnessFlags = 40u;
Color color2 { 0, std::numeric_limits<unsigned char>::max(), 0u };
unsigned char colorFlags = 128u;
const unsigned char padding = 0u;
unsigned char effect = MSI_MODE_STATIC;
Color color { 0, 0, 0 };
unsigned char speedAndBrightnessFlags = 40;
Color color2 { 0, 0, 0 };
unsigned char colorFlags = 128;
const unsigned char padding = 0;
};
struct RainbowZoneData : ZoneData
{
unsigned char cycle_or_led_num = 20u;
unsigned char cycle_or_led_num = 20;
};
struct FeaturePacket
{
const unsigned char report_id = 82u; // Report ID
ZoneData j_rgb_1; // 1
ZoneData j_pipe_1; // 11
ZoneData j_pipe_2; // 21
RainbowZoneData j_rainbow_1; // 31
RainbowZoneData j_rainbow_2; // 42
CorsairZoneData j_corsair; // 53
ZoneData j_corsair_outerll120; // 64
ZoneData on_board_led; // 74
ZoneData on_board_led_1; // 84
ZoneData on_board_led_2; // 94
ZoneData on_board_led_3; // 104
ZoneData on_board_led_4; // 114
ZoneData on_board_led_5; // 124
ZoneData on_board_led_6; // 134
ZoneData on_board_led_7; // 144
ZoneData on_board_led_8; // 154
ZoneData on_board_led_9; // 164
ZoneData j_rgb_2; // 174
unsigned char save_data = 0u; // 184
const unsigned char report_id = 0x52; // Report ID
ZoneData j_rgb_1; // 1
ZoneData j_pipe_1; // 11
ZoneData j_pipe_2; // 21
RainbowZoneData j_rainbow_1; // 31
RainbowZoneData j_rainbow_2; // 42
CorsairZoneData j_corsair; // 53
ZoneData j_corsair_outerll120; // 64
ZoneData on_board_led; // 74
ZoneData on_board_led_1; // 84
ZoneData on_board_led_2; // 94
ZoneData on_board_led_3; // 104
ZoneData on_board_led_4; // 114
ZoneData on_board_led_5; // 124
ZoneData on_board_led_6; // 134
ZoneData on_board_led_7; // 144
ZoneData on_board_led_8; // 154
ZoneData on_board_led_9; // 164
ZoneData j_rgb_2; // 174
unsigned char save_data = 0; // 184
};
@@ -181,25 +178,116 @@ public:
MSIMysticLightController(hid_device* handle, const char *path);
~MSIMysticLightController();
unsigned int GetZoneMinLedCount(ZONE zone);
unsigned int GetZoneMaxLedCount(ZONE zone);
unsigned int GetZoneLedCount(ZONE zone);
void SetZoneLedCount(ZONE zone, unsigned int led_count);
unsigned int GetZoneMinLedCount
(
MSI_ZONE zone
);
unsigned int GetZoneMaxLedCount
(
MSI_ZONE zone
);
unsigned int GetZoneLedCount
(
MSI_ZONE zone
);
void SetZoneLedCount
(
MSI_ZONE zone,
unsigned int led_count
);
void SetMode
(
MSI_ZONE zone,
MSI_MODE mode,
MSI_SPEED speed,
MSI_BRIGHTNESS brightness,
bool rainbow_color
);
void GetMode
(
MSI_ZONE zone,
MSI_MODE &mode,
MSI_SPEED &speed,
MSI_BRIGHTNESS &brightness,
bool &rainbow_color
);
void SetZoneColor
(
MSI_ZONE zone,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetCycleCount
(
MSI_ZONE zone,
unsigned char cycle_num
);
unsigned char GetCycleCount
(
MSI_ZONE zone
);
void SetMode(ZONE zone, EFFECT mode, SPEED speed, BRIGHTNESS brightness, bool rainbow_color);
void GetMode(ZONE zone, EFFECT &mode, SPEED &speed, BRIGHTNESS &brightness, bool &rainbow_color);
void SetZoneColor(ZONE zone, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
void SetCycleCount(ZONE zone, unsigned char cycle_num);
unsigned char GetCycleCount(ZONE zone);
std::pair<Color, Color>
GetZoneColor(ZONE zone);
GetZoneColor(MSI_ZONE zone);
bool Update();
void SetDeviceSettings(bool stripe_or_fan, FAN_TYPE fan_type, unsigned char corsair_device_quantity, bool is_LL120Outer_individual);
void GetDeviceSettings(bool &stripe_or_fan, FAN_TYPE &fan_type, unsigned char &corsair_device_quantity, bool &is_LL120Outer_individual);
bool SetVolume(unsigned char main, unsigned char left, unsigned char right);
void SetBoardSyncSettings(bool onboard_sync, bool combine_JRGB, bool combine_JPIPE1, bool combine_JPIPE2, bool combine_JRAINBOW1, bool combine_JRAINBOW2, bool combine_crossair);
void GetBoardSyncSettings(bool &onboard_sync, bool &combine_JRGB, bool &combine_JPIPE1, bool &combine_JPIPE2, bool &combine_JRAINBOW1, bool &combine_JRAINBOW2, bool &combine_crossair);
void SetDeviceSettings
(
bool stripe_or_fan,
MSI_FAN_TYPE fan_type,
unsigned char corsair_device_quantity,
bool is_LL120Outer_individual
);
void GetDeviceSettings
(
bool &stripe_or_fan,
MSI_FAN_TYPE &fan_type,
unsigned char &corsair_device_quantity,
bool &is_LL120Outer_individual
);
bool SetVolume
(
unsigned char main,
unsigned char left,
unsigned char right
);
void SetBoardSyncSettings
(
bool onboard_sync,
bool combine_JRGB,
bool combine_JPIPE1,
bool combine_JPIPE2,
bool combine_JRAINBOW1,
bool combine_JRAINBOW2,
bool combine_crossair
);
void GetBoardSyncSettings
(
bool &onboard_sync,
bool &combine_JRGB,
bool &combine_JPIPE1,
bool &combine_JPIPE2,
bool &combine_JRAINBOW1,
bool &combine_JRAINBOW2,
bool &combine_crossair
);
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -212,9 +300,9 @@ private:
bool ReadFwVersion();
void ReadSerial();
void ReadName();
ZoneData* GetZoneData(ZONE zone);
ZoneData* GetZoneData(MSI_ZONE zone);
RainbowZoneData*
GetRainbowZoneData(ZONE zone);
GetRainbowZoneData(MSI_ZONE zone);
static unsigned char BitSet(unsigned char value, bool bit, unsigned int position);
hid_device* dev;
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "MSIMysticLightController.h"
#include "RGBController_MSIMysticLight.h"
@@ -7,20 +8,23 @@
static const unsigned short msi_pid_table[] =
{
0x7C67, // MS_7C67
0x3EA4, // MS_3EA4
0x4559, // MS_4459
0x7B10, // MS_7B10
0x7C87, // MS_7C87
0x7B93, // MS_7B93
0x7B93, // MSI B450 Gaming Pro Carbon AC
0x7B94, // MS_7B94
0x7B96, // MS_7B96
0x7C34, // MS_7C34
0x7C35, // MS_7C35
0x7C36, // MS_7C36
0x7C37, // MS_7C37
0x7C42, // MS_7C42
0x7C84, // MS_7C84
0x7B94, // MS_7B94
0x7B96, // MS_7B96
0x7C56, // MS_7C56
0x7C59, // MS_7C59
0x7C60, // MS_7C60
0x7C67, // MS_7C67
0x7C70, // MS_7C70
0x7C71, // MS_7C71
0x7C73, // MS_7C73
@@ -29,25 +33,25 @@ static const unsigned short msi_pid_table[] =
0x7C77, // MS_7C77
0x7C79, // MS_7C79
0x7C80, // MS_7C80
0x7C98, // MS_7C98
0x7C99, // MS_7C99
0x7C81, // MS_7C81
0x7C82, // MS_7C82
0x7C83, // MS_7C83
0x7C84, // MS_7C84
0x7C85, // MS_7C85
0x7C86, // MS_7C86
0x7C87, // MS_7C87
0x7C88, // MS_7C88
0x7C89, // MS_7C89
0x4559, // MS_4459
0x3EA4, // MS_3EA4
0x905D, // MS_905D
0x7C90, // MS_7C90
0x7C91, // MS_7C91
0x7C92, // MS_7C92
0x7C94, // MS_7C94
0x7C95, // MS_7C95
0x7C96, // MS_7C96
0x7C56 // MS_7C56
0x7C98, // MS_7C98
0x7C99, // MS_7C99
0x905D // MS_905D
};
/******************************************************************************************\
@@ -95,4 +99,8 @@ void DetectMSIMysticLightControllers(std::vector<RGBController*> &rgb_controller
rgb_controllers.push_back(rgb_controller);
}
}
}
} /* DetectMSIMysticLightControllers() */
// The MSI Mystic Light controller is disabled due to bricking risk
// Uncomment this line to enable. Do so at your own risk.
//REGISTER_DETECTOR("MSI Mystic Light", DetectMSIMysticLightControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "MSIRGBController.h"
#include "RGBController.h"
#include "RGBController_MSIRGB.h"
@@ -38,3 +39,5 @@ void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
}
}
} /* DetectMSIRGBControllers() */
REGISTER_DETECTOR("MSI-RGB", DetectMSIRGBControllers);
@@ -11,12 +11,19 @@
#include <string>
#include <cstring>
NZXTHue2Controller::NZXTHue2Controller(hid_device* dev_handle)
NZXTHue2Controller::NZXTHue2Controller(hid_device* dev_handle, unsigned int rgb_channels, unsigned int fan_channels)
{
dev = dev_handle;
num_fan_channels = fan_channels;
num_rgb_channels = rgb_channels;
SendFirmwareRequest();
GetStripsOnChannel(HUE_2_CHANNEL_1);
UpdateDeviceList();
fan_cmd.resize(num_fan_channels);
fan_rpm.resize(num_fan_channels);
UpdateStatus();
}
NZXTHue2Controller::~NZXTHue2Controller()
@@ -24,39 +31,96 @@ NZXTHue2Controller::~NZXTHue2Controller()
}
unsigned char NZXTHue2Controller::GetFanCommand
(
unsigned char fan_channel
)
{
return(fan_cmd[fan_channel]);
}
unsigned short NZXTHue2Controller::GetFanRPM
(
unsigned char fan_channel
)
{
return(fan_rpm[fan_channel]);
}
unsigned int NZXTHue2Controller::GetNumFanChannels()
{
return(num_fan_channels);
}
unsigned int NZXTHue2Controller::GetNumRGBChannels()
{
return(num_rgb_channels);
}
std::string NZXTHue2Controller::GetFirmwareVersion()
{
return(firmware_version);
}
unsigned int NZXTHue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
void NZXTHue2Controller::SendFan
(
unsigned char port,
unsigned char /*mode*/,
unsigned char speed
)
{
unsigned int ret_val = 0;
unsigned char usb_buf[64];
unsigned char usb_buf[] =
{
0x20, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x62;
usb_buf[0x01] = 0x01;
usb_buf[0x02] = 1 << port;
usb_buf[port + 3] = speed;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
}
for(int chan = 0; chan < 4; chan++)
void NZXTHue2Controller::UpdateDeviceList()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Device Information Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x20;
usb_buf[0x01] = 0x03;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Receive packets until 0x21 0x03 is received |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x21) || (usb_buf[1] != 0x03) );
for(unsigned int chan = 0; chan < num_rgb_channels; chan++)
{
unsigned int start = 0x0F + (6 * chan);
unsigned int num_leds_on_channel = 0;
@@ -90,7 +154,43 @@ unsigned int NZXTHue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
}
channel_leds[chan] = num_leds_on_channel;
}
return(ret_val);
}
void NZXTHue2Controller::UpdateStatus()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
if(false)//num_fan_channels > 0)
{
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Read packet |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x67) || (usb_buf[1] != 0x02) );
/*-----------------------------------------------------*\
| Extract fan information |
\*-----------------------------------------------------*/
for(unsigned int fan_idx = 0; fan_idx < num_fan_channels; fan_idx++)
{
unsigned char cmd;
unsigned short rpm;
cmd = usb_buf[40 + fan_idx];
rpm = ( usb_buf[25 + (2 * fan_idx)] << 8 ) | usb_buf[24 + (2 * fan_idx)];
fan_cmd[fan_idx] = cmd;
fan_rpm[fan_idx] = rpm;
}
}
}
void NZXTHue2Controller::SetChannelEffect
@@ -195,7 +295,7 @@ void NZXTHue2Controller::SendApply
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendDirect
@@ -230,7 +330,7 @@ void NZXTHue2Controller::SendDirect
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendEffect
@@ -284,20 +384,34 @@ void NZXTHue2Controller::SendEffect
memcpy(&usb_buf[0x0A], color_data, color_count * 3);
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
//hid_read(dev, usb_buf, 64);
}
void NZXTHue2Controller::SendFirmwareRequest()
{
unsigned char usb_buf[64];
unsigned int ret_val = 0;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Firmware Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x10;
usb_buf[0x01] = 0x01;
hid_write(dev, usb_buf, 64);
hid_read(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Receive packets until 0x11 0x01 is received |
\*-----------------------------------------------------*/
do
{
ret_val = hid_read(dev, usb_buf, sizeof(usb_buf));
} while( (ret_val != 64) || (usb_buf[0] != 0x11) || (usb_buf[1] != 0x01) );
snprintf(firmware_version, 16, "%u.%u.%u", usb_buf[0x11], usb_buf[0x12], usb_buf[0x13]);
}
@@ -54,14 +54,30 @@ enum
class NZXTHue2Controller
{
public:
NZXTHue2Controller(hid_device* dev_handle);
NZXTHue2Controller(hid_device* dev_handle, unsigned int rgb_channels, unsigned int fan_channels);
~NZXTHue2Controller();
std::string GetFirmwareVersion();
unsigned int GetStripsOnChannel
unsigned char GetFanCommand
(
unsigned int channel
unsigned char fan_channel
);
unsigned short GetFanRPM
(
unsigned char fan_channel
);
unsigned int GetNumFanChannels();
unsigned int GetNumRGBChannels();
void SendFan
(
unsigned char port,
unsigned char mode,
unsigned char speed
);
void SetChannelEffect
@@ -80,12 +96,22 @@ public:
RGBColor * colors,
unsigned int num_colors
);
void UpdateDeviceList();
void UpdateStatus();
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
private:
hid_device* dev;
std::vector<unsigned char> fan_cmd;
std::vector<unsigned short> fan_rpm;
char firmware_version[16];
unsigned int num_fan_channels;
unsigned int num_rgb_channels;
void SendApply
(
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "NZXTHue2Controller.h"
#include "RGBController.h"
#include "RGBController_NZXTHue2.h"
@@ -14,6 +15,8 @@ typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned int num_rgb_channels;
unsigned int num_fan_channels;
const char * name;
} nzxt_hue_2_device;
@@ -24,10 +27,10 @@ static const nzxt_hue_2_device device_list[] =
/*-----------------------------------------------------------------------------------------------------*\
| NZXT Hue 2 devices |
\*-----------------------------------------------------------------------------------------------------*/
{ NZXT_VID, NZXT_HUE_2_PID, "NZXT Hue 2" },
{ NZXT_VID, NZXT_HUE_2_AMBIENT_PID, "NZXT Hue 2 Ambient" },
{ NZXT_VID, NZXT_SMART_DEVICE_V2_PID, "NZXT Smart Device V2" },
{ NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID, "NZXT RGB & Fan Controller" },
{ NZXT_VID, NZXT_HUE_2_PID, 4, 0, "NZXT Hue 2" },
{ NZXT_VID, NZXT_HUE_2_AMBIENT_PID, 2, 0, "NZXT Hue 2 Ambient" },
{ NZXT_VID, NZXT_SMART_DEVICE_V2_PID, 2, 3, "NZXT Smart Device V2" },
{ NZXT_VID, NZXT_RGB_FAN_CONTROLLER_PID, 2, 3, "NZXT RGB & Fan Controller" },
};
/******************************************************************************************\
@@ -58,23 +61,21 @@ void DetectNZXTHue2Controllers(std::vector<RGBController*> &rgb_controllers)
&&(info->product_id == device_list[device_idx].usb_pid))
{
dev = hid_open_path(info->path);
break;
if( dev )
{
NZXTHue2Controller* controller = new NZXTHue2Controller(dev, device_list[device_idx].num_rgb_channels, device_list[device_idx].num_fan_channels);
RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
NZXTHue2Controller* controller = new NZXTHue2Controller(dev);
RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
info = info->next;
}
}
} /* DetectNZXTHue2Controllers() */
REGISTER_DETECTOR("NZXT Hue 2", DetectNZXTHue2Controllers);
@@ -50,9 +50,16 @@ std::string NZXTKrakenController::GetFirmwareVersion()
void NZXTKrakenController::UpdateStatus()
{
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0, sizeof(usb_buf));
hid_read(dev, usb_buf, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Read packet |
\*-----------------------------------------------------*/
hid_read(dev, usb_buf, 64);
/*-----------------------------------------------------*\
| Extract cooler information |
@@ -83,14 +90,28 @@ void NZXTKrakenController::UpdateEffect
)
{
unsigned char color_data[9 * 3];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(color_data, 0, sizeof(color_data));
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
if(!colors.empty() && channel != NZXT_KRAKEN_CHANNEL_RING)
{
colors[0] = ToLogoColor(colors[0]);
}
/*-----------------------------------------------------*\
| Update color data |
\*-----------------------------------------------------*/
SetColor(colors, color_data);
/*-----------------------------------------------------*\
| Send update packet |
\*-----------------------------------------------------*/
SendEffect(channel, mode, direction, color_data, speed, false, seq);
}
@@ -106,7 +127,7 @@ void NZXTKrakenController::SendEffect
int size /* = 0 */
)
{
unsigned char usb_buf[65];
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
@@ -149,5 +170,5 @@ void NZXTKrakenController::SendEffect
/*-----------------------------------------------------*\
| Send effect |
\*-----------------------------------------------------*/
hid_write(dev, usb_buf, sizeof(usb_buf));
hid_write(dev, usb_buf, 64);
}
@@ -1,33 +1,75 @@
#include "Detector.h"
#include "NZXTKrakenController.h"
#include "RGBController.h"
#include "RGBController_NZXTKraken.h"
#include <vector>
#include <hidapi/hidapi.h>
#define NZXT_KRAKEN_VID 0x1E71
#define NZXT_KRAKEN_PID 0x170E
#define NZXT_KRAKEN_VID 0x1E71
#define NZXT_KRAKEN_X2_PID 0x170E
#define NZXT_KRAKEN_M2_PID 0x1715
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
const char * name;
} nzxt_kraken_device;
#define NZXT_KRAKEN_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const nzxt_kraken_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| NZXT Hue 2 devices |
\*-----------------------------------------------------------------------------------------------------*/
{ NZXT_KRAKEN_VID, NZXT_KRAKEN_X2_PID, "NZXT Kraken X2" },
{ NZXT_KRAKEN_VID, NZXT_KRAKEN_M2_PID, "NZXT Kraken M2" },
};
/******************************************************************************************\
* *
* DetectNZXTKrakenControllers *
* *
* Detect devices supported by the NZXTKraken driver *
* * *
* *
\******************************************************************************************/
void DetectNZXTKrakenControllers(std::vector<RGBController*> &rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
hid_device* dev = hid_open(NZXT_KRAKEN_VID, NZXT_KRAKEN_PID, nullptr);
if( dev )
for(std::size_t device_idx = 0; device_idx < NZXT_KRAKEN_NUM_DEVICES; device_idx++)
{
NZXTKrakenController* controller = new NZXTKrakenController(dev);
dev = NULL;
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
rgb_controllers.push_back(rgb_controller);
//Look for NZXT Kraken devices
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid))
{
dev = hid_open_path(info->path);
if( dev )
{
NZXTKrakenController* controller = new NZXTKrakenController(dev);
RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
} /* DetectNZXTKrakenControllers() */
}
REGISTER_DETECTOR("NZXT Kraken", DetectNZXTKrakenControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "PatriotViperController.h"
#include "RGBController.h"
#include "RGBController_PatriotViper.h"
@@ -70,3 +71,5 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
}
} /* DetectPatriotViperControllers() */
REGISTER_I2C_DETECTOR("Patriot Viper", DetectPatriotViperControllers);
@@ -10,14 +10,15 @@
#include "PolychromeController.h"
#include <cstring>
using namespace std::chrono_literals;
PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev)
{
this->bus = bus;
this->dev = dev;
unsigned short fw_version = GetFirmwareVersion();
unsigned short fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
unsigned char minor_version = fw_version & 0xFF;
/*-----------------------------------------------------*\
| Determine whether the device uses ASR LED or |
@@ -25,23 +26,30 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
| Versions 1.xx and 2.xx use ASR LED, 3.xx uses |
| Polychrome |
\*-----------------------------------------------------*/
if((major_version < 0x03) && (major_version > 0x00))
switch(major_version)
{
snprintf(device_name, 32, "ASRock ASR LED FW %d.%02d", major_version, minor_version);
led_count = 1;
asr_led = true;
case ASROCK_TYPE_ASRLED:
device_name = "ASRock ASR LED";
asrock_type = ASROCK_TYPE_ASRLED;
memset(zone_led_count, 0, sizeof(zone_led_count));
break;
case ASROCK_TYPE_POLYCHROME_V1:
device_name = "ASRock Polychrome V1";
asrock_type = ASROCK_TYPE_POLYCHROME_V1;
ReadLEDConfiguration();
break;
case ASROCK_TYPE_POLYCHROME_V2:
device_name = "ASRock Polychrome V2";
asrock_type = ASROCK_TYPE_POLYCHROME_V2;
ReadLEDConfiguration();
break;
default:
asrock_type = ASROCK_TYPE_UNKNOWN;
break;
}
else if(major_version == 0x03)
{
snprintf(device_name, 32, "ASRock Polychrome FW %d.%02d", major_version, minor_version);
led_count = 1;
asr_led = false;
}
else
{
led_count = 0;
}
}
PolychromeController::~PolychromeController()
@@ -49,18 +57,44 @@ PolychromeController::~PolychromeController()
}
char* PolychromeController::GetDeviceName()
unsigned int PolychromeController::GetASRockType()
{
return(asrock_type);
}
std::string PolychromeController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
std::string PolychromeController::GetDeviceName()
{
return(device_name);
}
unsigned short PolychromeController::GetFirmwareVersion()
std::string PolychromeController::GetFirmwareVersion()
{
unsigned short fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
unsigned char minor_version = fw_version & 0xFF;
return(std::to_string(major_version) + "." + std::to_string(minor_version));
}
unsigned short PolychromeController::ReadFirmwareVersion()
{
// The firmware register holds two bytes, so the first read should return 2
// If not, report invalid firmware revision FFFF
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_FIRMWARE_VER) == 0x02)
if (bus->i2c_smbus_read_byte_data(dev, ASROCK_REG_FIRMWARE_VER) == 0x02)
{
std::this_thread::sleep_for(1ms);
unsigned char major = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
unsigned char minor = bus->i2c_smbus_read_byte(dev);
return((major << 8) | minor);
@@ -71,9 +105,31 @@ unsigned short PolychromeController::GetFirmwareVersion()
}
}
unsigned int PolychromeController::GetLEDCount()
void PolychromeController::ReadLEDConfiguration()
{
return(led_count);
/*---------------------------------------------------------------------------------*\
| The LED configuration register holds 6 bytes, so the first read should return 6 |
| If not, set all zone sizes to zero |
\*---------------------------------------------------------------------------------*/
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_LED_CONFIG) == 0x06)
{
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_1] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_2] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_3] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_4] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_5] = bus->i2c_smbus_read_byte(dev);
std::this_thread::sleep_for(1ms);
zone_led_count[POLYCHROME_ZONE_ADDRESSABLE] = bus->i2c_smbus_read_byte(dev);
}
else
{
memset(zone_led_count, 0, sizeof(zone_led_count));
}
}
unsigned int PolychromeController::GetMode()
@@ -81,35 +137,203 @@ unsigned int PolychromeController::GetMode()
return(active_mode);
}
bool PolychromeController::IsAsrLed()
void PolychromeController::SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue)
{
return(asr_led);
}
void PolychromeController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, green, blue };
if (asr_led)
unsigned char color_speed_pkt[4] = { red, green, blue, active_speed };
unsigned char select_led_pkt[1] = { led };
switch(asrock_type)
{
bus->i2c_smbus_write_block_data(dev, active_mode, 3, colors);
}
else
{
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
case ASROCK_TYPE_ASRLED:
/*-----------------------------------------------------*\
| Select LED |
\*-----------------------------------------------------*/
if(active_mode != ASRLED_MODE_OFF)
{
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
std::this_thread::sleep_for(1ms);
}
switch(active_mode)
{
/*-----------------------------------------------------*\
| These modes take 4 bytes in R/G/B/S order |
\*-----------------------------------------------------*/
case ASRLED_MODE_BREATHING:
case ASRLED_MODE_STROBE:
case ASRLED_MODE_SPECTRUM_CYCLE:
bus->i2c_smbus_write_block_data(dev, active_mode, 4, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 3 bytes in R/G/B order |
\*-----------------------------------------------------*/
default:
case ASRLED_MODE_STATIC:
case ASRLED_MODE_MUSIC:
bus->i2c_smbus_write_block_data(dev, active_mode, 3, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 1 byte - speed |
\*-----------------------------------------------------*/
case ASRLED_MODE_RANDOM:
case ASRLED_MODE_WAVE:
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &active_speed);
break;
/*-----------------------------------------------------*\
| These modes take no bytes |
\*-----------------------------------------------------*/
case ASRLED_MODE_OFF:
break;
}
std::this_thread::sleep_for(1ms);
break;
case ASROCK_TYPE_POLYCHROME_V1:
/*-----------------------------------------------------*\
| Select LED |
\*-----------------------------------------------------*/
if(active_mode != ASRLED_MODE_OFF)
{
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
std::this_thread::sleep_for(1ms);
}
switch(active_mode)
{
/*-----------------------------------------------------*\
| These modes take 4 bytes in R/G/B/S order |
\*-----------------------------------------------------*/
case POLYCHROME_V1_MODE_BREATHING:
case POLYCHROME_V1_MODE_STROBE:
case POLYCHROME_V1_MODE_SPECTRUM_CYCLE:
case POLYCHROME_V1_MODE_SPRING:
case POLYCHROME_V1_MODE_METEOR:
case POLYCHROME_V1_MODE_STACK:
case POLYCHROME_V1_MODE_CRAM:
case POLYCHROME_V1_MODE_SCAN:
case POLYCHROME_V1_MODE_NEON:
case POLYCHROME_V1_MODE_WATER:
bus->i2c_smbus_write_block_data(dev, active_mode, 4, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 3 bytes in R/G/B order |
\*-----------------------------------------------------*/
default:
case POLYCHROME_V1_MODE_STATIC:
case POLYCHROME_V1_MODE_MUSIC:
bus->i2c_smbus_write_block_data(dev, active_mode, 3, color_speed_pkt);
break;
/*-----------------------------------------------------*\
| These modes take 1 byte - speed |
\*-----------------------------------------------------*/
case POLYCHROME_V1_MODE_RANDOM:
case POLYCHROME_V1_MODE_WAVE:
case POLYCHROME_V1_MODE_RAINBOW:
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &active_speed);
break;
/*-----------------------------------------------------*\
| These modes take no bytes |
\*-----------------------------------------------------*/
case POLYCHROME_V1_MODE_OFF:
break;
}
std::this_thread::sleep_for(1ms);
break;
case ASROCK_TYPE_POLYCHROME_V2:
/*-----------------------------------------------------*\
| Select LED |
\*-----------------------------------------------------*/
switch(active_mode)
{
case POLYCHROME_V2_MODE_OFF:
case POLYCHROME_V2_MODE_RAINBOW:
case POLYCHROME_V2_MODE_SPECTRUM_CYCLE:
break;
default:
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, select_led_pkt);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Polychrome firmware always writes color to fixed reg |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V2_REG_COLOR, 3, color_speed_pkt);
std::this_thread::sleep_for(1ms);
break;
}
break;
}
}
void PolychromeController::SetMode(unsigned char mode)
void PolychromeController::SetMode(unsigned char zone,unsigned char mode, unsigned char speed)
{
active_mode = mode;
unsigned char led_count_pkt[1] = { 0x00 };
active_zone = zone;
active_mode = mode;
active_speed = speed;
if (asr_led)
switch(asrock_type)
{
bus->i2c_smbus_write_block_data(dev, ASRLED_REG_MODE, 1, &active_mode);
}
else
{
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_MODE, 1, &active_mode);
case ASROCK_TYPE_ASRLED:
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
std::this_thread::sleep_for(1ms);
break;
case ASROCK_TYPE_POLYCHROME_V1:
/*-----------------------------------------------------*\
| Make sure set all register is set to 0 |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V1_REG_SET_ALL, 1, led_count_pkt);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Set the zone we are working on |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_LED_SELECT, 1, &active_zone);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Write the mode |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
std::this_thread::sleep_for(1ms);
break;
case ASROCK_TYPE_POLYCHROME_V2:
bus->i2c_smbus_write_block_data(dev, ASROCK_REG_MODE, 1, &active_mode);
std::this_thread::sleep_for(1ms);
/*-----------------------------------------------------*\
| Select a single LED |
\*-----------------------------------------------------*/
bus->i2c_smbus_write_block_data(dev, POLYCHROME_V2_REG_LED_COUNT, 0, led_count_pkt);
std::this_thread::sleep_for(1ms);
switch(active_mode)
{
/*-----------------------------------------------------*\
| These modes don't take a speed |
\*-----------------------------------------------------*/
case POLYCHROME_V2_MODE_OFF:
case POLYCHROME_V2_MODE_STATIC:
break;
/*-----------------------------------------------------*\
| All other modes, write speed to active mode register |
\*-----------------------------------------------------*/
default:
bus->i2c_smbus_write_block_data(dev, active_mode, 1, &speed);
std::this_thread::sleep_for(1ms);
break;
}
break;
}
}
@@ -9,6 +9,7 @@
\*-----------------------------------------*/
#include "i2c_smbus.h"
#include <string>
#pragma once
@@ -16,49 +17,178 @@ typedef unsigned char polychrome_dev_id;
enum
{
ASRLED_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
ASRLED_REG_MODE = 0x30, /* Mode selection register */
};
#define ASRLED_NUM_MODES 8 /* Number of ASR LED modes */
enum
{
ASRLED_MODE_OFF = 0x10, /* OFF mode */
ASRLED_MODE_STATIC = 0x11, /* Static color mode */
ASRLED_MODE_BREATHING = 0x12, /* Breathing effect mode */
ASRLED_MODE_FLASHING = 0x13, /* Flashing effect mode */
ASRLED_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
ASRLED_MODE_RANDOM = 0x15, /* Random effect mode */
ASRLED_MODE_MUSIC = 0x17, /* Music effect mode */
ASRLED_MODE_WAVE = 0x18, /* Wave effect mode */
ASROCK_TYPE_UNKNOWN = 0x00, /* Unknown Type or Not ASRock Device */
ASROCK_TYPE_ASRLED = 0x01, /* ASRock Firmware 1.x - ASR LED */
ASROCK_TYPE_POLYCHROME_V1 = 0x02, /* ASRock Firmware 2.x - Polychrome V1 */
ASROCK_TYPE_POLYCHROME_V2 = 0x03, /* ASRock Firmware 3.x - Polychrome V2 */
};
enum
{
POLYCHROME_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
POLYCHROME_REG_MODE = 0x30, /* Mode selection register */
POLYCHROME_REG_COLOR = 0x34, /* Color register: Red, Green, Blue */
/*------------------------------------------------------------------------------------------*\
| ASRock Common Registers |
\*------------------------------------------------------------------------------------------*/
ASROCK_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
ASROCK_REG_MODE = 0x30, /* Mode selection register */
ASROCK_REG_LED_SELECT = 0x31, /* LED selection register */
/*------------------------------------------------------------------------------------------*\
| ASRock Polychrome V1/V2 Common Registers |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_REG_LED_CONFIG = 0x33, /* LED configuration register */
/*------------------------------------------------------------------------------------------*\
| ASRock Polychrome V1 (Firmware 2.x) Registers |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_REG_SET_ALL = 0x32, /* Set All register 0x1 = set all */
POLYCHROME_V1_REG_ARGB_GRB = 0x35, /* ARGB bistream reversing register */
/*------------------------------------------------------------------------------------------*\
| ASRock Polychrome V2 (Firmware 3.x) Registers |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V2_REG_LED_COUNT = 0x32, /* Additional LED count register */
POLYCHROME_V2_REG_COLOR = 0x34, /* Color register: Red, Green, Blue */
POLYCHROME_V2_REG_ARGB_GRB = 0x35, /* ARGB bistream reversing register */
};
#define POLYCHROME_NUM_MODES 14 /* Number of Polychrome modes */
enum
{
POLYCHROME_MODE_OFF = 0x10, /* OFF mode */
POLYCHROME_MODE_STATIC = 0x11, /* Static color mode */
POLYCHROME_MODE_BREATHING = 0x12, /* Breating effect mode */
POLYCHROME_MODE_FLASHING = 0x13, /* Flashing effect mode */
POLYCHROME_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
POLYCHROME_MODE_RANDOM = 0x15, /* Random effect mode */
POLYCHROME_MODE_WAVE = 0x17, /* Wave effect mode */
POLYCHROME_MODE_SPRING = 0x18, /* Spring effect mode */
POLYCHROME_MODE_STACK = 0x19, /* Stack effect mode */
POLYCHROME_MODE_CRAM = 0x1A, /* Cram effect mode */
POLYCHROME_MODE_SCAN = 0x1B, /* Scan effect mode */
POLYCHROME_MODE_NEON = 0x1C, /* Neon effect mode */
POLYCHROME_MODE_WATER = 0x1D, /* Water effect mode */
POLYCHROME_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
POLYCHROME_ZONE_1 = 0x00, /* RGB LED 1 Header */
POLYCHROME_ZONE_2 = 0x01, /* RGB LED 2 Header */
POLYCHROME_ZONE_3 = 0x02, /* Audio/PCH Zone LEDs */
POLYCHROME_ZONE_4 = 0x03, /* Audio/PCH Zone LEDs */
POLYCHROME_ZONE_5 = 0x04, /* IO Cover Zone LEDs */
POLYCHROME_ZONE_ADDRESSABLE = 0x05, /* Addressable LED header */
POLYCHROME_ZONE_COUNT = 0x06, /* Total number of zones */
POLYCHROME_ZONE_ADDRESSABLE_MAX = 0x64, /* Maxinum number of ARGB LEDs */
};
/*----------------------------------------------------------------------------------------------*\
| Definitions for ASR LED |
\*----------------------------------------------------------------------------------------------*/
#define ASRLED_NUM_MODES 8 /* Number of ASR LED modes */
enum
{
ASRLED_MODE_OFF = 0x10, /* OFF mode */
ASRLED_MODE_STATIC = 0x11, /* Static color mode */
ASRLED_MODE_BREATHING = 0x12, /* Breathing effect mode */
ASRLED_MODE_STROBE = 0x13, /* Strobe effect mode */
ASRLED_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
ASRLED_MODE_RANDOM = 0x15, /* Random effect mode */
ASRLED_MODE_MUSIC = 0x17, /* Music effect mode */
ASRLED_MODE_WAVE = 0x18, /* Wave effect mode */
};
enum
{
ASRLED_SPEED_MIN = 0x05, /* Slowest speed */
ASRLED_SPEED_DEFAULT = 0x03, /* Default speed */
ASRLED_SPEED_MAX = 0x00, /* Fastest speed */
};
/*----------------------------------------------------------------------------------------------*\
| Definitions for Polychrome V1 |
\*----------------------------------------------------------------------------------------------*/
#define POLYCHROME_V1_NUM_MODES 16 /* Number of Polychrome V1 modes */
enum
{
POLYCHROME_V1_MODE_OFF = 0x10, /* OFF mode */
POLYCHROME_V1_MODE_STATIC = 0x11, /* Static color mode */
POLYCHROME_V1_MODE_BREATHING = 0x12, /* Breating effect mode */
POLYCHROME_V1_MODE_STROBE = 0x13, /* Strobe effect mode */
POLYCHROME_V1_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
POLYCHROME_V1_MODE_RANDOM = 0x15, /* Random effect mode */
POLYCHROME_V1_MODE_MUSIC = 0x17, /* Music effect mode */
POLYCHROME_V1_MODE_WAVE = 0x18, /* Wave effect mode */
/*------------------------------------------------------------------------------------------*\
| Modes only available on ARGB headers |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_MODE_SPRING = 0x19, /* Spring effect mode */
POLYCHROME_V1_MODE_METEOR = 0x1A, /* Meteor effect mode */
POLYCHROME_V1_MODE_STACK = 0x1B, /* Stack effect mode */
POLYCHROME_V1_MODE_CRAM = 0x1C, /* Cram effect mode */
POLYCHROME_V1_MODE_SCAN = 0x1D, /* Scan effect mode */
POLYCHROME_V1_MODE_NEON = 0x1E, /* Neon effect mode */
POLYCHROME_V1_MODE_WATER = 0x1F, /* Water effect mode */
POLYCHROME_V1_MODE_RAINBOW = 0x20, /* Rainbow chase effect mode */
};
enum
{
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_BREATHING |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_BREATHING = 0x0A, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_BREATHING = 0x02, /* Default speed */
POLYCHROME_V1_SPEED_MAX_BREATHING = 0x02, /* Fastest speed */
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_STROBE |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_STROBE = 0xA0, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_STROBE = 0x14, /* Default speed */
POLYCHROME_V1_SPEED_MAX_STROBE = 0x05, /* Fastest speed */
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_SPECTRUM_CYCLE |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_CYCLE = 0xA0, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_CYCLE = 0x14, /* Default speed */
POLYCHROME_V1_SPEED_MAX_CYCLE = 0x0A, /* Fastest speed */
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_RANDOM |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_RANDOM = 0xA0, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_RANDOM = 0x28, /* Default speed */
POLYCHROME_V1_SPEED_MAX_RANDOM = 0x05, /* Fastest speed */
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_WAVE |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_WAVE = 0x06, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_WAVE = 0x02, /* Default speed */
POLYCHROME_V1_SPEED_MAX_WAVE = 0x01, /* Fastest speed */
POLYCHROME_V1_SPEED_DEFAULT_SPRING = 0x04, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_METEOR = 0x0A, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_STACK = 0x04, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_CRAM = 0x04, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_SCAN = 0x0A, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_NEON = 0x20, /* Default speed */
POLYCHROME_V1_SPEED_DEFAULT_WATER = 0x0A, /* Default speed */
/*------------------------------------------------------------------------------------------*\
| POLYCHROME_V1_MODE_RAINBOW |
\*------------------------------------------------------------------------------------------*/
POLYCHROME_V1_SPEED_MIN_RAINBOW = 0x12, /* Slowest speed */
POLYCHROME_V1_SPEED_DEFAULT_RAINBOW = 0x0A, /* Default speed */
POLYCHROME_V1_SPEED_MAX_RAINBOW = 0x01, /* Fastest speed */
POLYCHROME_V1_SPEED_MIN_ARGB = 0x20, /* Slowest speed */
POLYCHROME_V1_SPEED_MAX_ARGB = 0x02, /* Fastest speed */
};
/*----------------------------------------------------------------------------------------------*\
| Definitions for Polychrome V2 |
\*----------------------------------------------------------------------------------------------*/
#define POLYCHROME_V2_NUM_MODES 14 /* Number of Polychrome V2 modes */
enum
{
POLYCHROME_V2_MODE_OFF = 0x10, /* OFF mode */
POLYCHROME_V2_MODE_STATIC = 0x11, /* Static color mode */
POLYCHROME_V2_MODE_BREATHING = 0x12, /* Breating effect mode */
POLYCHROME_V2_MODE_STROBE = 0x13, /* Strobe effect mode */
POLYCHROME_V2_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
POLYCHROME_V2_MODE_RANDOM = 0x15, /* Random effect mode */
POLYCHROME_V2_MODE_WAVE = 0x17, /* Wave effect mode */
POLYCHROME_V2_MODE_SPRING = 0x18, /* Spring effect mode */
POLYCHROME_V2_MODE_STACK = 0x19, /* Stack effect mode */
POLYCHROME_V2_MODE_CRAM = 0x1A, /* Cram effect mode */
POLYCHROME_V2_MODE_SCAN = 0x1B, /* Scan effect mode */
POLYCHROME_V2_MODE_NEON = 0x1C, /* Neon effect mode */
POLYCHROME_V2_MODE_WATER = 0x1D, /* Water effect mode */
POLYCHROME_V2_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
};
enum
{
POLYCHROME_V2_SPEED_MIN = 0x05, /* Slowest speed */
POLYCHROME_V2_SPEED_DEFAULT = 0x03, /* Default speed */
POLYCHROME_V2_SPEED_MAX = 0x00, /* Fastest speed */
};
class PolychromeController
@@ -67,20 +197,25 @@ public:
PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev);
~PolychromeController();
char* GetDeviceName();
unsigned int GetLEDCount();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetFirmwareVersion();
unsigned int GetMode();
bool IsAsrLed();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned short GetFirmwareVersion();
unsigned int GetASRockType();
void SetColorsAndSpeed(unsigned char led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char zone, unsigned char mode, unsigned char speed);
unsigned char zone_led_count[6];
private:
bool asr_led;
char device_name[32];
unsigned int led_count;
unsigned int asrock_type;
std::string device_name;
unsigned char active_zone;
unsigned char active_mode;
unsigned char active_speed;
i2c_smbus_interface* bus;
polychrome_dev_id dev;
unsigned short ReadFirmwareVersion();
void ReadLEDConfiguration();
};
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "PolychromeController.h"
#include "RGBController.h"
#include "RGBController_Polychrome.h"
@@ -54,7 +55,7 @@ void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std:
{
new_polychrome = new PolychromeController(busses[bus], 0x6A);
if(new_polychrome->GetLEDCount() != 0)
if(new_polychrome->GetASRockType() != ASROCK_TYPE_UNKNOWN)
{
new_controller = new RGBController_Polychrome(new_polychrome);
rgb_controllers.push_back(new_controller);
@@ -62,8 +63,10 @@ void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std:
else
{
delete new_polychrome;
}
}
}
}
} /* DetectPolychromeControllers() */
REGISTER_I2C_DETECTOR("ASRock Polychrome", DetectPolychromeControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "PoseidonZRGBController.h"
#include "RGBController.h"
#include "RGBController_PoseidonZRGB.h"
@@ -30,23 +31,26 @@ void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
{
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
&&(info->interface_number == 2))
#ifdef USE_HID_USAGE
&&(info->interface_number == 1)
&&(info->usage_page == 0xFF01))
#else
&&(info->interface_number == 1))
#endif
{
dev = hid_open_path(info->path);
break;
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
else
{
info = info->next;
}
}
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
} /* DetectPoseidonZRGBControllers() */
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
REGISTER_DETECTOR("Thermaltake Poseidon Z RGB", DetectPoseidonZRGBControllers);
@@ -61,9 +61,9 @@ void RGBFusion2DRAMController::Apply()
void RGBFusion2DRAMController::SetLEDEffect
(
unsigned int led,
unsigned int /*led*/,
int mode,
unsigned int speed,
unsigned int /*speed*/,
unsigned char red,
unsigned char green,
unsigned char blue
@@ -75,4 +75,4 @@ void RGBFusion2DRAMController::SetLEDEffect
led_data[RGB_FUSION_2_DRAM_IDX_BLUE] = blue;
bus->i2c_smbus_write_block_data(dev, RGB_FUSION_2_DRAM_LED_START_ADDR, 32, led_data);
}
}
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "RGBFusion2DRAMController.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2DRAM.h"
@@ -65,3 +66,6 @@ void DetectRGBFusion2DRAMControllers(std::vector<i2c_smbus_interface*>& busses,
}
} /* DetectRGBFusion2DRAMControllers() */
// This detector is disabled as proper detection isn't implemented
//REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion 2 DRAM", DetectRGBFusion2DRAMControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "RGBFusion2SMBusController.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2SMBus.h"
@@ -6,6 +7,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "dependencies/dmiinfo.h"
typedef struct
{
const std::string manufacturer;
const std::string motherboard;
} motherboard_info;
#define RGB_FUSION_2_SMBUS_NUM_DEVICES (sizeof(rgb_fusion_2_smbus_motherboards) / sizeof(rgb_fusion_2_smbus_motherboards[ 0 ]))
const motherboard_info rgb_fusion_2_smbus_motherboards[] =
{
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS ELITE" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS ULTRA GAMING-CF" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS ULTRA GAMING" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS GAMING 5 WIFI" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS M" },
{ "Gigabyte Technology Co., Ltd.", "X399 AORUS XTREME-CF" },
{ "Gigabyte Technology Co., Ltd.", "X399 DESIGNARE EX-CF" },
{ "Gigabyte Technology Co., Ltd.", "B450 I AORUS PRO WIFI-CF" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS PRO-CF4" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS GAMING 7 WIFI-CF" },
};
/******************************************************************************************\
* *
@@ -21,18 +45,12 @@ bool TestForRGBFusion2SMBusController(i2c_smbus_interface* bus, unsigned char ad
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
// res = bus->i2c_smbus_read_byte_data(address, 0xF2);
// if (res != 0xC4)
// {
// pass = false;
// }
}
return(pass);
} /* TestForRGBFusion2SMBusController() */
@@ -53,21 +71,38 @@ void DetectRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses,
RGBFusion2SMBusController* new_rgb_fusion;
RGBController_RGBFusion2SMBus* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
DMIInfo dmi;
bool found = false;
for(unsigned int mb_idx = 0; mb_idx < RGB_FUSION_2_SMBUS_NUM_DEVICES; mb_idx++)
{
// TODO - Is this necessary? Or an artifact of my own system?
// Skip dmcd devices
std::string device_name = std::string(busses[bus]->device_name);
if (device_name.find("dmdc") == std::string::npos)
if( ( dmi.getManufacturer() == rgb_fusion_2_smbus_motherboards[mb_idx].manufacturer )
&& ( dmi.getMainboard() == rgb_fusion_2_smbus_motherboards[mb_idx].motherboard ) )
{
// Check for RGB Fusion 2 controller at 0x68
if (TestForRGBFusion2SMBusController(busses[bus], 0x68))
found = true;
}
}
if(found)
{
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// TODO - Is this necessary? Or an artifact of my own system?
// Skip dmcd devices
std::string device_name = std::string(busses[bus]->device_name);
if (device_name.find("dmdc") == std::string::npos)
{
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68);
new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion);
rgb_controllers.push_back(new_controller);
// Check for RGB Fusion 2 controller at 0x68
if (TestForRGBFusion2SMBusController(busses[bus], 0x68))
{
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68);
new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion);
rgb_controllers.push_back(new_controller);
}
}
}
}
} /* DetectRGBFusion2SMBusControllers() */
REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion 2 SMBus", DetectRGBFusion2SMBusControllers);
@@ -27,16 +27,17 @@ static LEDCount LedCountToEnum(unsigned int c)
return(LEDS_1024);
}
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path) : dev(handle)
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name) : dev(handle)
{
int res = 0;
char text[64] {};
unsigned char buffer[64] {};
if( dev ) {
int res = 0;
char text[64] = { 0x00 };
unsigned char buffer[64] = { 0x00 };
if( dev )
{
SetCalibration();
name = mb_name;
// hid report read needs 0x60 packet or it gives IO error
SendPacket(0x60, 0x00);
@@ -46,8 +47,8 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
{
report = *reinterpret_cast<IT8297Report*>(buffer);
name = std::string(report.str_product, 32);
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
description = std::string(report.str_product, 32);
//description.erase(std::find(description.begin(), description.end(), '\0'), name.end());
snprintf(text, 11, "0x%08X", report.fw_ver);
version = text;
@@ -55,7 +56,6 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
snprintf(text, 11, "0x%08X", report.chip_id);
chip_id = text;
}
loc = path;
EnableBeat(false);
@@ -84,13 +84,13 @@ void RGBFusion2USBController::SetCalibration()
buffer[0] = report_id;
buffer[1] = 0x33;
// D_LED1 WS2812 GRB, 0x00RRGGBB to 0x00GGRRBB
// D_LED1 WS2812 GRB, 0x00RRGGBB to 0x00GGRRBB
buffer[2] = 0x02; // B
buffer[3] = 0x00; // G
buffer[4] = 0x01; // R
buffer[5] = 0x00;
// D_LED2 WS2812 GRB
// D_LED2 WS2812 GRB
buffer[6] = 0x02;
buffer[7] = 0x00;
buffer[8] = 0x01;
@@ -102,6 +102,12 @@ void RGBFusion2USBController::SetCalibration()
buffer[12] = 0x02;
buffer[13] = 0x00;
// Spare set seen in some Motherboard models
buffer[14] = 0x00;
buffer[15] = 0x01;
buffer[16] = 0x02;
buffer[17] = 0x00;
SendPacket(buffer);
}
@@ -135,6 +141,11 @@ std::string RGBFusion2USBController::GetDeviceName()
return(name);
}
std::string RGBFusion2USBController::GetDeviceDescription()
{
return(description);
}
std::string RGBFusion2USBController::GetFWVersion()
{
return(version);
@@ -157,7 +157,7 @@ struct IT8297Report
class RGBFusion2USBController
{
public:
RGBFusion2USBController(hid_device* handle, const char *path);
RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name);
~RGBFusion2USBController();
void SetStripColors
@@ -175,6 +175,7 @@ public:
bool DisableBuiltinEffect(int enable_bit, int mask);
void SetCalibration();
std::string GetDeviceName();
std::string GetDeviceDescription();
std::string GetDeviceLocation();
std::string GetFWVersion();
std::string GetSerial();
@@ -188,6 +189,7 @@ private:
int mode;
IT8297Report report;
std::string name;
std::string description;
std::string loc;
std::string version;
std::string chip_id;
@@ -1,8 +1,19 @@
#include "Detector.h"
#include "RGBFusion2USBController.h"
#include "RGBController_RGBFusion2USB.h"
#include "dependencies/dmiinfo.h"
#define IT8297_VID 0x048D
#define IT8297_PID 0x8297
#define IT8297_VID 0x048D
#define IT8297_IFC 0
#define IT8297_U 0xCC
#define IT8297_UPG 0xFF89
#define COUNT_RGBFUSION2_PIDS (sizeof(RGBFusion2_pids) / sizeof(RGBFusion2_pids[ 0 ]))
static const unsigned short RGBFusion2_pids[] =
{
0x8297, //PID for the ITE 8595 found on the X570
0x5702 //PID for the ITE 8595 found on the B550
};
/******************************************************************************************\
* *
@@ -14,24 +25,49 @@
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
DMIInfo MB_info;
unsigned short tmpPID;
if (hid_init() < 0)
return;
hid_device_info * device_list = hid_enumerate(IT8297_VID, IT8297_PID);
if (!device_list)
return;
hid_device_info * device = device_list;
while (device)
{
hid_device * dev = hid_open_path(device->path);
if (dev) {
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, device_list->path);
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
rgb_controllers.push_back(rgb_controller);
}
device = device->next;
return;
}
hid_free_enumeration(device_list);
}
for(unsigned int dev_idx = 0; dev_idx < COUNT_RGBFUSION2_PIDS; dev_idx++)
{
dev = NULL;
tmpPID = RGBFusion2_pids[dev_idx];
info = hid_enumerate(IT8297_VID, tmpPID);
while(info)
{
if((info->vendor_id == IT8297_VID)
#ifdef USE_HID_USAGE
&&(info->product_id == tmpPID)
&&(info->usage == IT8297_U) //Usage and usage page required to get the correct interface
&&(info->usage_page == IT8297_UPG))
#else
&&(info->interface_number == IT8297_IFC) //Interface is only valid on Windows where there is > 1 interface
&&(info->product_id == tmpPID))
#endif
{
dev = hid_open_path(info->path);
if (dev)
{
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard());
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
hid_free_enumeration(info);
} /* DetectRGBFusion2USBControllers() */
REGISTER_DETECTOR("Gigabyte RGB Fusion 2 USB", DetectRGBFusion2USBControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "RGBFusionController.h"
#include "RGBController.h"
#include "RGBController_RGBFusion.h"
@@ -64,4 +65,6 @@ void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::
}
}
} /* DetectRGBFusionControllers() */
} /* DetectRGBFusionControllers() */
REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion", DetectRGBFusionControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "RGBFusionGPUController.h"
#include "RGBController.h"
#include "RGBController_RGBFusionGPU.h"
@@ -81,3 +82,5 @@ void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, st
}
} /* DetectRGBFusionGPUControllers() */
REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion GPU", DetectRGBFusionGPUControllers);
@@ -1,3 +1,4 @@
#include "Detector.h"
#include "RedragonK556Controller.h"
#include "RedragonM711Controller.h"
#include "RGBController.h"
@@ -10,6 +11,7 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_KEYBOARD_VID 0x0C45
#define REDRAGON_KEYBOARD_USAGE_PAGE 0xFF1C
#define REDRAGON_K550_PID 0x5204
#define REDRAGON_K552_PID 0x5104
#define REDRAGON_K556_PID 0x5004
@@ -20,6 +22,7 @@
| Mouse product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_MOUSE_VID 0x04D9
#define REDRAGON_MOUSE_USAGE_PAGE 0xFFA0
#define REDRAGON_M711_PID 0xFC30
#define REDRAGON_M715_PID 0xFC39
@@ -28,6 +31,7 @@ typedef struct
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
unsigned short usb_usage_page;
device_type type;
const char * name;
} redragon_device;
@@ -36,22 +40,22 @@ typedef struct
static const redragon_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
@@ -69,7 +73,7 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
hid_init();
for(int device_idx = 0; device_idx < REDRAGON_NUM_DEVICES; device_idx++)
for(unsigned int device_idx = 0; device_idx < REDRAGON_NUM_DEVICES; device_idx++)
{
dev = NULL;
@@ -78,45 +82,48 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
//Look for Redragon RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
#ifdef USE_HID_USAGE
&&(info->interface_number == device_list[device_idx].usb_interface)
&&(info->usage_page == device_list[device_idx].usb_usage_page))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
if( dev )
{
switch(device_list[device_idx].type)
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
case DEVICE_TYPE_KEYBOARD:
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
info = info->next;
}
}
}
} /* DetectRedragonControllers() */
REGISTER_DETECTOR("Redragon Peripheral", DetectRedragonControllers);
@@ -63,7 +63,7 @@ enum
enum
{
REDRAGON_K556_BRIGHTNESS_LOWEST = 0x00, /* Lowest brightness (off) */
REDRAGON_K556_BRIGHTNESS_HIGHEST = 0x05, /* Highest brightness */
REDRAGON_K556_BRIGHTNESS_HIGHEST = 0x04, /* Highest brightness */
};
enum
@@ -2,21 +2,6 @@
#include <cstring>
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
{
char* usb_pkt = new char[size + 1];
usb_pkt[0] = 0x00;
for(int i = 1; i < size + 1; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
hid_send_feature_report(dev, (unsigned char *)usb_pkt, size + 1);
delete usb_pkt;
}
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
{
dev = dev_handle;
@@ -103,7 +88,7 @@ void RedragonM711Controller::SendMouseApply()
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}
void RedragonM711Controller::SendWritePacket
@@ -137,5 +122,5 @@ void RedragonM711Controller::SendWritePacket
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
hid_send_feature_report(dev, (unsigned char *)usb_buf, 16);
}
@@ -0,0 +1,58 @@
/*-----------------------------------------*\
| SapphireGPUController.cpp |
| |
| Driver for Sapphire Nitro Glow GPU RGB |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/15/2020 |
\*-----------------------------------------*/
#include "SapphireGPUController.h"
SapphireGPUController::SapphireGPUController(i2c_smbus_interface* bus, sapphire_dev_id dev)
{
this->bus = bus;
this->dev = dev;
}
SapphireGPUController::~SapphireGPUController()
{
}
std::string SapphireGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char SapphireGPUController::GetRed()
{
return(bus->i2c_smbus_read_byte_data(dev, SAPPHIRE_GPU_REG_RED));
}
unsigned char SapphireGPUController::GetGreen()
{
return(bus->i2c_smbus_read_byte_data(dev, SAPPHIRE_GPU_REG_GREEN));
}
unsigned char SapphireGPUController::GetBlue()
{
return(bus->i2c_smbus_read_byte_data(dev, SAPPHIRE_GPU_REG_BLUE));
}
void SapphireGPUController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_RED, red);
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_GREEN, green);
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_BLUE, blue);
}
void SapphireGPUController::SetMode(unsigned char mode, unsigned char /*speed*/)
{
bus->i2c_smbus_write_byte_data(dev, SAPPHIRE_GPU_REG_MODE, mode);
}
@@ -0,0 +1,55 @@
/*-----------------------------------------*\
| SapphireGPUController.h |
| |
| Definitions and types for Sapphire Nitro |
| Glow GPU RGB lighting controller |
| |
| Adam Honse (CalcProgrammer1) 7/15/2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char sapphire_dev_id;
enum
{
SAPPHIRE_GPU_REG_MODE = 0x00,
SAPPHIRE_GPU_REG_BRIGHTNESS = 0x01,
SAPPHIRE_GPU_REG_RED = 0x03,
SAPPHIRE_GPU_REG_GREEN = 0x04,
SAPPHIRE_GPU_REG_BLUE = 0x05,
};
enum
{
SAPPHIRE_GPU_MODE_SAPPHIRE_BLUE = 0x00,
SAPPHIRE_GPU_MODE_RAINBOW = 0x01,
SAPPHIRE_GPU_MODE_BOARD_TEMPERATURE = 0x02,
SAPPHIRE_GPU_MODE_FAN_SPEED = 0x03,
SAPPHIRE_GPU_MODE_CUSTOM = 0x04,
SAPPHIRE_GPU_MODE_OFF = 0x05,
};
class SapphireGPUController
{
public:
SapphireGPUController(i2c_smbus_interface* bus, sapphire_dev_id dev);
~SapphireGPUController();
std::string GetDeviceLocation();
unsigned char GetRed();
unsigned char GetGreen();
unsigned char GetBlue();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode, unsigned char speed);
private:
i2c_smbus_interface* bus;
sapphire_dev_id dev;
};

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