Compare commits

...
Author SHA1 Message Date
Adam Honse 7811a11a34 Copy OpenRazer.dll to build directory on Windows 2020-02-13 11:31:27 -06:00
Adam Honse f257437e4e Add openrazer-win32 dependency with pre-built DLL 2020-02-13 09:36:49 -06:00
Adam Honse bb449bbd1a OpenRazer improvements 2020-02-13 09:07:59 -06:00
Adam Honse a615b08a63 Get rid of razerchromahdk driver as it was never merged and use razeraccessory instead 2020-02-13 09:07:59 -06:00
Adam Honse a5ff88f676 Add direction control to OpenRazer Wave mode 2020-02-13 09:07:59 -06:00
Adam Honse 2e99502179 Fix the OpenRazer build on Linux 2020-02-13 09:07:59 -06:00
Adam Honse 272fcd3867 Add missing file 2020-02-13 09:07:59 -06:00
Adam Honse 379261f2b1 Clean up Linux OpenRazer code to match Windows and break out device list into a shared header file 2020-02-13 09:07:59 -06:00
Adam Honse 55cb312330 Get OpenRazer Windows driver working with new mode API and detect modes based on razer functions structure 2020-02-13 09:07:58 -06:00
Adam Honse 9457d4010a Add support for Razer Nommo Pro and Chroma 2020-02-13 09:07:58 -06:00
Adam Honse 3400f35f93 Rename ChromaDLL.dll to OpenRazer.dll and add Mamba Elite and Base Station Chroma to device list 2020-02-13 09:07:58 -06:00
Adam Honse 80dd2336b9 Update OpenRazer Windows to latest OpenRazer version, add Huntsman Elite to device list 2020-02-13 09:07:58 -06:00
Adam Honse aa229f72f3 Add kraken and core drivers to initialization 2020-02-13 09:07:58 -06:00
Adam Honse 9f2d4ec36a Start working on implementing rsandoz's Windows port of OpenRazer. Firefly, mice, and keyboards should work 2020-02-13 09:07:58 -06:00
Adam Honse fd59f83556 Update Crucial controller to new RGBController format 2020-02-12 14:51:07 -06:00
Adam Honse 7adcfa77fa Add function for setting Crucial Ballistix RGB colors in direct mode 2020-02-12 14:39:44 -06:00
Adam Honse b338fbca3c Initial driver for Crucial Ballistix RGB 2020-02-12 14:39:44 -06:00
Adam Honse aba3a3fd23 Add 0x39, 0x3B, 0x3C, and 0x3D to Aura DRAM search addresses list 2020-02-12 13:23:35 -06:00
Adam Honse cb680508a5 Add Polychrome firmware 2.08 to supported firmware list 2020-02-12 13:02:28 -06:00
Adam Honse 2104c975be Update RGB Fusion 2 to build with latest RGBController format 2020-02-12 12:27:15 -06:00
Adam Honse 339e1e14c2 Swap red and blue channels in RGB Fusion 2.0 packet after it was found that they were reversed 2020-02-12 12:20:50 -06:00
Adam Honse dca3b0d733 Forgot to send the apply packet 2020-02-12 12:20:30 -06:00
Adam Honse c52eb528ea RGB Fusion 2.0 driver based on summerblind's code 2020-02-12 12:20:30 -06:00
Adam Honse 3948e74711 Use /dev/port to make Super IO functions work on Linux 2020-02-11 20:25:28 -06:00
Adam Honse 4672d4a686 Move Super IO functionality to its own file to make it easier to write an MSI-RGB driver 2020-02-11 19:58:13 -06:00
Adam Honse befa9baf20 Update the ThermaltakeRiing driver to just set the active_mode variable instead of actually sending mode updates on SetCustomMode 2020-02-11 18:07:57 -06:00
Adam Honse 077cda545e Clean up the Corsair keyboard driver with some private packet sending functions 2020-02-11 18:01:31 -06:00
Adam Honse e934ce2c23 Add addresses 0x5E and 0x5F to Corsair DRAM detection 2020-02-11 16:18:39 -06:00
Adam Honse b10ff42df2 Add addresses 0x5E and 0x5F to Corsair Pro DRAM detection 2020-02-11 16:18:38 -06:00
Adam Honse afb6ff6a74 Update the rest of the RGBController drivers to just set the active_mode variable instead of actually sending mode updates on SetCustomMode 2020-02-10 00:26:18 -06:00
Adam Honse 6828335dc5 Just set active_mode rather than call SetMode for SetCustomModefunction. Implement for a few tested devices only for now. Fix some user interface issues with custom mode selection. 2020-02-10 00:17:02 -06:00
Adam Honse 966297710b Fix custom mode setting in UI 2020-02-09 19:55:26 -06:00
Adam Honse 443d558ac2 Remove compiler warning that is treated as error on some systems 2020-02-09 19:06:50 -06:00
Adam Honse 2cd0b64251 Add mode control to Thermaltake Riing controller 2020-02-09 15:26:20 -06:00
Adam Honse 7ad3c18e3f Remove unused declarations 2020-02-09 14:43:24 -06:00
Adam Honse fc11427019 Remove serial port include for USB controllers that were copied from the Hue+ driver 2020-02-09 14:37:50 -06:00
Adam Honse 2f00fb9186 Add initial driver for Thermaltake Riing controller. Fixed configuration has 9 LEDs for channels 1, 2, and 3 but will make this configurable in the future. Only direct mode supported so far 2020-02-09 14:34:26 -06:00
Adam Honse ea1f21106c Fix Linux build of CorsairKeyboardController (missing include for memset) 2020-02-06 16:37:21 -06:00
Adam Honse 47ca068628 Number the LEDs in E131 and LEDStrip controllers 2020-02-06 12:26:14 -06:00
Adam Honse f07cc134bb Add zones and LEDs to Corsair keyboard controller, but keys don't line up with zones yet 2020-02-05 21:05:55 -06:00
Adam Honse 1d98ce063c Add zones and LEDs to Poseidon Z RGB controller 2020-02-05 17:34:08 -06:00
Adam Honse 9ddb9f04ce Add zones and LEDs to HyperX Keyboard controller 2020-02-05 13:09:39 -06:00
Adam Honse 8aee3c427b Fix segfault 2020-02-04 20:22:01 -06:00
Adam Honse 6a6ad0dda6 Keyboard fixes for Linux 2020-02-04 20:20:45 -06:00
Adam Honse 12116c70ee Big Keyboard Update! HyperX Alloy Elite support, Poseidon Z RGB modes, and Corsair K70 RGB 2020-02-04 20:17:09 -06:00
Adam Honse 7d6699cf9c Use ASR LED mode for Polychrome 2.10 firmware 2020-02-02 00:34:11 -06:00
Adam Honse 48b9be3f76 Add Polychrome firmware 2.10 to list 2020-02-01 20:38:52 -06:00
Adam Honse 760c57c29c Only show LEDs for selected Zone, add an All Zones option to Zone box 2020-02-01 12:54:51 -06:00
Adam Honse c6cc88ba7b The color boxes got moved around during the UI rework. Move them back to their proper rainbow order 2020-01-31 18:32:22 -06:00
Adam Honse 779471e3e4 Detect NZXT Smart Device V2 and use the Hue 2 driver for it 2020-01-31 11:08:33 -06:00
Adam Honse adb9a6e59f Add support for Aer 2 140mm fan on Hue 2 2020-01-30 10:42:43 -06:00
Adam Honse d48bcec5ba Block write Polychrome mode value instead of byte write 2020-01-29 13:02:00 -06:00
Adam Honse 80d2282313 Add modes and additional set functions to Polychrome controller 2020-01-29 12:32:32 -06:00
k1-801 a4474602d8 Add basic support for Asus TUF laptop keyboards through Faustus 2020-01-28 09:10:34 -06:00
Marco Zanin (B--B) d28be0640e Qt: fix layout issues on KDE
Use GridLayout and allow app resize when user resize/expand the window
Also fixes some buttons size

TEST: compiled on KDE 5.17.90, after this commit all pages
      resize correctly when window is resized

Signed-off-by: Marco Zanin (B--B) <[email protected]>
2020-01-27 19:41:31 -06:00
Adam Honse 5b17833c6e Remove some detection checks for Corsair Vengeance RGB Pro detection as it was no longer detecting my modules with them 2020-01-25 17:37:32 -06:00
Adam Honse e8e9a1e7e5 Set custom mode when applying color to all devices 2020-01-25 17:37:32 -06:00
Adam Honse d7740c2d28 Move Get/Set mode functions to generic RGBController.cpp functions and add device-specific UpdateMode function to use active_mode value 2020-01-25 17:37:32 -06:00
Adam Honse f110589f91 Fix some small issues with AMD Wraith Prism driver 2020-01-25 17:37:32 -06:00
Adam Honse b3c1cdf63d Fix issues with inverted speed and random flag 2020-01-25 17:37:32 -06:00
Adam Honse 6b789be1e1 Add speed control to HyperX driver 2020-01-25 17:37:32 -06:00
Adam Honse 12f307228b Clean up speed values for Patriot Viper RGB 2020-01-25 17:37:32 -06:00
Adam Honse 848ea8b064 Shifted the wrong way... 2020-01-25 17:37:32 -06:00
Adam Honse 438c3840a7 Add speed control to RGB Fusion 1.0 driver 2020-01-25 17:37:32 -06:00
Adam Honse fef6f4cba3 Add delay to improve Corsair Pro detection, default modes to down instead of left, clean up Wraith Prism initialization 2020-01-25 17:37:32 -06:00
Adam Honse d38543a820 Finish AMD Wraith Prism mode updates including working speed table, working random color flag, and appropriate fan/logo modes for ring-specific effects 2020-01-25 17:37:32 -06:00
Adam Honse 2a76201ca4 Implement a speed table for AMD Wraith Prism to use the values taken from the official software. Interpolation was causing strange issues. 2020-01-25 17:37:32 -06:00
Adam Honse 2e84e9808c Start adding modes to AMD Wraith Prism driver. Speed and random bit implemented, but it seems to have issues. Speeds way too fast 2020-01-25 17:37:32 -06:00
Adam Honse ee492632ac Prepare AMD Wraith Prism driver for mode control 2020-01-25 17:37:32 -06:00
Adam Honse fd16bc3053 Add direction support to Corsair Vengeance RGB Pro 2020-01-25 17:37:32 -06:00
Adam Honse 64f11b42f4 Add direction support for NZXT Hue 2 2020-01-25 17:37:32 -06:00
Adam Honse 7ba610df77 Add direction support to Corsair Commander/Lighting Node Pro 2020-01-25 17:37:32 -06:00
Adam Honse a76bd7b974 Add direction support for NZXT Hue+ 2020-01-25 17:37:32 -06:00
Adam Honse 7999620db2 Fix Corsair Commander Pro/Lighting Node Pro on Linux 2020-01-25 17:37:32 -06:00
Adam Honse 585eb8a5a3 Add direction support 2020-01-25 17:37:32 -06:00
Adam Honse f1523adcdf Add the rest of the Corsair Commander/Lighting Node Pro modes 2020-01-25 17:37:32 -06:00
Adam Honse 1113c7874f Add label to Speed slider 2020-01-25 17:37:32 -06:00
Adam Honse ab03311717 Copy Corsair Commander Pro updates to Lighting Node Pro driver. Need to consolidate these eventually 2020-01-25 17:37:32 -06:00
Adam Honse d13971b7ce Add inverted speed flag to device UI to handle devices where slowest speed is a larger value than fastest speed 2020-01-25 17:37:32 -06:00
Adam Honse 5bc94fd677 Speed values are reversed on Corsair Commander Pro. Removed all references to SendKeepalive function. 2020-01-25 17:37:32 -06:00
Adam Honse 90dfa5678b Clean up Corsair Commander Pro code and get effects mode working 2020-01-25 17:37:32 -06:00
Adam Honse 48ba8435b1 Initial Corsair Commander Pro support, it's the same protocol as the Lighting Node Pro but on a different endpoint 2020-01-25 17:37:32 -06:00
Adam Honse cf2c2d6b93 Add speed control to Hue 2 2020-01-25 17:37:32 -06:00
Adam Honse 4b8668e0ef Add speed control for Hue+ and add support for Wings mode 2020-01-25 17:37:32 -06:00
Adam Honse 0bc5982970 Add random color modes for HyperX Predator RGB 2020-01-25 17:37:32 -06:00
Adam Honse 2ae74c1e7f Add slider for speed control, add min/max speed parameters to mode information, update Corsair Pro and Patriot Viper drivers to include speed control 2020-01-25 17:37:32 -06:00
Adam Honse abd4c87b1e Fix Corsair Pro mode initialization 2020-01-25 17:37:32 -06:00
Adam Honse fb3103e458 Add mode parameters to Corsair Vengeance RGB Pro controller 2020-01-25 17:37:32 -06:00
Adam Honse c70943da18 Add Random Color checkbox and combine Aura fixed-color and cycling ("random") modes to use this new checkbox 2020-01-25 17:37:32 -06:00
Adam Honse 2efd0dc81d Add additional mode parameters to RGBController API and update most of the RGBController drivers' mode specifications to match 2020-01-25 17:37:32 -06:00
Adam Honse 8b8012a431 Update README.md 2020-01-15 22:43:22 +00:00
Adam Honse 0716f55880 Remove debug printout that was left in Hue code 2020-01-12 23:10:25 -06:00
Adam Honse bcc95abe53 Add keepalive thread to Corsair Lighting Node Pro driver 2020-01-12 22:57:30 -06:00
Adam Honse bb7852a3e4 Remove list of devices from README and replace it with a link to the wiki. The wiki is more up to date. 2020-01-13 04:33:00 +00:00
Adam Honse d79c7e9c04 Initial driver for Corsair Lighting Node Pro 2020-01-12 14:04:01 -06:00
Adam Honse fa4d9ebbf6 Get hidapi stuff building on Linux 2020-01-09 19:13:19 -06:00
Adam Honse ec8cdf1e26 Bring in USB HID device support with hidapi and add support for two new HID devices - MSI/SteelSeries 3-zone laptop keyboard and Thermaltake TtEsports Poseidon Z RGB keyboard 2020-01-09 19:00:08 -06:00
Adam Honse 1d6e0cf6a4 Fix mode initialization, fix mode map for Corsair Pro 2020-01-09 13:36:06 -06:00
Adam Honse b06d56bb2d Add Aer 1 fan support to NZXT Hue 2 and Hue+ 2020-01-08 21:21:11 -06:00
Adam Honse 50c9f7b84b More color vector initialization improvements 2020-01-08 21:20:54 -06:00
Adam Honse dd6a6ca85a Increase timeout after sending Hue+ packet so it works in Linux as well as Windows 2020-01-07 23:17:13 -06:00
Adam Honse 4d5003f49d Some code cleanup - set colors vector size for improved performance and add sleep to fix Hue Plus device update 2020-01-07 21:00:02 -06:00
Adam Honse 7226a4164f Hue 2 channel is a bitfield rather than a value 2020-01-06 23:01:51 -06:00
Adam Honse c7030ad47d Rework the RGBController API to handle the colors vector outside of device specific implementations 2020-01-06 21:23:26 -06:00
Adam Honse 11770aaa3a Add Quick Colors to tray icon 2020-01-06 16:25:01 -06:00
Adam Honse f8212ca59e Add Lights Off option to tray icon menu 2020-01-06 15:30:45 -06:00
Adam Honse dbf3dd86b4 Add tray icon with options to show/hide and exit 2020-01-06 12:31:37 -06:00
Adam Honse 0fe3adc267 Add UpdateLEDs function support to HyperX controller 2020-01-05 18:29:40 -06:00
Adam Honse f45b20602b Add UpdateLEDs function support for Viper, Hue2, Hue+, Wraith Prism 2020-01-05 18:07:47 -06:00
Adam Honse f6bf044ba0 Add functions for setting Hue+ and Hue 2 effect modes 2020-01-05 17:22:43 -06:00
Adam Honse 420e4dc077 Fix bug in NZXT Hue 2 code 2020-01-05 13:49:30 -06:00
Adam Honse 3c77c1a9a8 Add support on Hue 2 for Aer 2 fans 2020-01-05 13:38:57 -06:00
Adam Honse 5074a923d1 Add functions to get serial port path from USB VID/PID for both Windows and Linux. Use this function to automatically detect the presence of an NZXT Hue+. 2020-01-05 12:52:33 -06:00
Adam Honse bfd8030438 Send apply command on AMD Wraith Prism to enable ring LEDs 2020-01-05 02:49:44 -06:00
Adam Honse af84c5bb00 Add Aorus GPU detect file to Windows build 2020-01-05 01:28:15 -06:00
Adam Honse 3de7150408 Add effect mode and effect color controls to Patriot Viper RGB driver 2020-01-05 01:16:03 -06:00
Adam Honse 6fdf34e16f Update README to reflect need to initialize submodules for Windows now that E131 is used on both 2020-01-02 21:28:19 -06:00
Adam Honse 7bdf19387d Add Windows support for E1.31 Streaming ACN protocol devices 2020-01-02 21:23:56 -06:00
Adam Honse a27c614a8b Fix some issues with the Aura initialization and detection and add a new driver for Patriot Viper RGB RAM 2020-01-01 23:32:58 -06:00
Adam Honse b7b93ad606 Fix build error in windows 2020-01-01 18:26:08 -06:00
Steven Franzen dbf796256b Fix most compiler warnings 2019-12-31 19:18:24 -06:00
Adam Honse f38b90ad52 Use a list of motherboard addresses to detect Aura motherboards 2019-12-31 18:44:09 -06:00
Adam Honse 5f3fe509a4 Fix unbounded array access in Aura RAM detection that caused segfaults on certain systems 2019-12-31 18:37:09 -06:00
Adam Honse 189bf0d7a4 Support for original Hue Plus strips on Hue 2, fix bug when less than 20 LEDs connected to channel 2019-12-29 15:21:30 -06:00
Adam Honse 60531bbf07 Initial driver for NZXT Hue 2 2019-12-29 12:29:29 -06:00
Adam Honse fd9134c911 Rename OpenAuraSDK.cpp to OpenRGB.cpp and remove old unused code 2019-12-28 15:24:40 -06:00
Adam Honse f33f00d8a9 Fix bank IDs in RGB Fusion code and set 0x02 register which seems to enable device if disabled. 2019-12-27 19:53:02 -06:00
Adam Honse f2d35466a5 Get Aura address skipping working 2019-12-27 16:23:37 -06:00
Adam Honse bce9fc929e Skip in-use addresses for Aura RAM initialization 2019-12-27 15:53:49 -06:00
Adam Honse cdaae5fb9f Fix previous commit 2019-12-27 12:28:18 -06:00
Adam Honse 9fc9059b0b Add detection code for ASRock ASR LED and Polychrome controllers 2019-12-27 12:24:04 -06:00
Adam Honse 2c1fe31211 Update README 2019-12-27 12:08:20 -06:00
Adam Honse 13f53ae4f8 Remove 0x67 and 0x68 checks from HyperX detection - should allow detection of Fury RGB RAM. Change suggested by Sam Cheng of Kingston/HyperX 2019-12-27 12:06:04 -06:00
Adam Honse eac739fdb4 Get libusb-1.0 building on Windows, pull in libusb-1.0.22 dependency. You need Zadig to set up individual devices for use 2019-12-25 02:26:18 -06:00
Adam Honse 5ae3de993d Add capability to set ring color 2019-12-25 01:21:18 -06:00
Adam Honse e79c97c4d0 RGBController interface for Wraith Prism now can change static colors for logo and fan 2019-12-25 01:08:28 -06:00
Adam Honse 45c7bc8008 Add an RGBController interface for AMD Wraith Prism 2019-12-25 00:54:45 -06:00
Adam Honse 7de0b2549b Add function to retrieve firmware version string on Wraith Prism 2019-12-24 19:26:40 -06:00
Adam Honse 39b52326b6 Add function to set all ring LEDs to a given effect channel 2019-12-24 15:04:30 -06:00
Adam Honse b35c900fae Add function to get effect string for a channel 2019-12-24 14:56:49 -06:00
Adam Honse 7cea74e466 AMD Wraith Prism controller file with some statically coded packets 2019-12-24 01:13:25 -06:00
Adam Honse 5f3e43e7b8 Only build Aorus GPU files on Windows 2019-12-23 17:37:31 -06:00
Adam Honse a84407b609 Bring PolychromeController into the build 2019-12-23 17:12:18 -06:00
Adam Honse 000511deff Update Aorus GPU files 2019-12-23 17:08:44 -06:00
Adam Honse fe37c261a2 Move Set Color buttons up for better alignment 2019-12-23 16:51:10 -06:00
Adam Honse cbdbb71d79 Add Set All Devices button 2019-12-23 16:17:00 -06:00
Adam Honse 5f786e649a Fix Hue+ initialization on Windows 2019-12-23 15:37:15 -06:00
Adam Honse f76bf34d8d HyperX zones per slot, set Hue Plus zones as linear type 2019-12-23 12:35:42 -06:00
Adam Honse e799574730 Add additional information to OpenRazer, set SPD to page 1 for proper HyperX detection 2019-12-23 02:52:09 -06:00
Adam Honse 1a5b12c7a0 OAdd strip autodetection to NZXT Hue+ interface, group zones into channels 2019-12-23 02:21:20 -06:00
Adam Honse d2acc75ba8 Report correct device types on OpenRazer interface 2019-12-22 23:11:11 -06:00
Adam Honse 74bcfbd940 Make Sleep function static on linux to avoid compile errors 2019-12-22 22:44:28 -06:00
Adam Honse 1db45f2cf2 Update slot addresses for HyperX Predator RGB and set brightness on effect modes 2019-12-22 21:27:27 -06:00
Adam Honse 6e467fe8cd Initial work on direct mode for HyperX Predator RGB 2019-12-22 02:18:20 -06:00
Adam Honse 441c462e59 Add SMBus/I2C dumping tool to System Information page 2019-12-22 00:02:08 -06:00
Adam Honse 89b4716012 Fix Aura DRAM detection and move firmware name to Version field 2019-12-20 14:28:42 -06:00
Adam Honse e51e9a71a0 Add name and serial number information fields to UI 2019-12-20 14:03:37 -06:00
Adam Honse 02273a3601 Exclude SMBus addresses from detection matching upstream i2c-tools code 2019-12-20 13:07:21 -06:00
Adam Honse e0018b23aa Use monospace font in system information box 2019-12-20 12:45:29 -06:00
Adam Honse b06f384350 System information page with i2c detect 2019-12-20 12:22:14 -06:00
Adam Honse 7dddb9d111 Start work on Information page and add information fields to RGBController API 2019-12-20 00:54:37 -06:00
Adam Honse 0d38154134 Fix DRAM type detection for some Aura based RAM Modules 2019-12-18 23:08:48 -06:00
Adam Honse 7dd84c7ac8 First round of user interface rework changes 2019-12-18 20:33:55 -06:00
Adam Honse ffd0088378 Rename dialog components from OpenAuraSDK to OpenRGB 2019-12-17 20:23:36 -06:00
Adam Honse f0c486c30d Rename OpenAuraSDK to OpenRGB for kernel patch and project file 2019-12-17 20:11:43 -06:00
Adam Honse 010ab1182d Move OpenAuraSDK_Win.pro to OpenAuraSDK.pro to unify the two project files for good 2019-12-17 19:57:06 -06:00
Adam Honse 7e64ca1f83 Merge QT project files in OpenAuraSDK_Win.pro 2019-12-17 19:51:34 -06:00
Adam Honse 2fcff92523 Add icon to Windows Qt project 2019-12-17 19:00:07 -06:00
Adam Honse 8beeb5f7b2 Get Qt project building on Windows, remove Visual Studio files 2019-12-17 18:57:53 -06:00
Adam Honse 7d2b5f285f More work on ASR LED/Polychrome support 2019-12-15 02:12:12 -06:00
Adam Honse b8eb4e9bcb Initial work on ASRock Polychrome/ASR LED interface. Does not function yet. 2019-12-14 11:15:55 -06:00
Adam Honse 733b904ec4 Undo commenting out of custom mode set function 2019-12-11 21:43:51 -06:00
Adam Honse 59a3b41480 Initial support for Gigabyte Aorus RGB Fusion motherboards 2019-12-11 20:19:21 -06:00
Adam Honse 28b41451f8 Fix typo in Aura header 2019-12-11 19:38:28 -06:00
Adam Honse 126c9295ac Add OpenRGB icon 2019-10-26 22:47:21 -05:00
Steven Franzen 0e4a162667 Change search path for i2c devices on linux
Looking for devices by bus instead of class should fix issues where the
class is named differently, e.g. i2c-dev instead of i2c-adapter.
2019-10-26 21:46:10 -05:00
Adam Honse 15fd537fa8 Add support for RGB E1.31 Streaming ACN multicast devices using libe131. Linux only for now. 2019-10-26 21:34:25 -05:00
Adam Honse 557c9df9a0 Rewrite OpenRazer support to use static constant device mapping table instead of big switch/case. Add support for some extra Razer devices. Use "ledstrip.txt" for LED strip settings 2019-10-26 18:21:02 -05:00
Adam Honse 68b0dc9e2e Fix LED Strips on Windows 2019-09-03 20:29:32 -05:00
Adam Honse c8a1363b35 Use generic interfaces for Razer Chroma SDK, get mouse and Chroma HDK working 2019-09-03 20:13:54 -05:00
Adam Honse 0a61e38ee1 Start writing an RGBController interface for the Razer Chroma SDK on Windows 2019-09-03 00:38:56 -05:00
Adam Honse b5f687c402 Get project building on Windows again 2019-09-02 17:48:34 -05:00
Adam Honse 50875fc698 Add 2D matrix support to OpenRazer RGB interface, add support for Chroma HDK 2019-09-02 17:16:49 -05:00
Adam Honse 802d444d9d Add net port files 2019-09-01 15:43:42 -05:00
Adam Honse a8c83e5688 Add interface for NZXT Hue+ based on KeyboardVisualizer code and add support for UDP LED strips. Clean up LEDStrip code. 2019-08-28 12:25:49 -05:00
Adam Honse 63bf13faac Add color buffer vector to all RGBController drivers, so that color patterns may be filled in by the application and updated all at once via an UpdateLEDs function 2019-08-23 01:31:39 -05:00
Adam Honse 5bc80cce96 Get reorganized code building on Windows 2019-08-22 21:07:13 -05:00
Adam Honse 3c34a659a0 Rename nct6793d to nct6775 to align with nct6775 naming convention from hwmon-based Linux driver 2019-08-22 19:03:59 -05:00
Adam Honse efed3faaf4 Add kernel patch for SMBus driver fixes to repository 2019-08-22 18:50:36 -05:00
Adam Honse 155ad165b1 Reorganization! Move all controllers into their own folders, move all RGBController wrappers into one folder, move i2c_smbus and serial_port dependencies into folders, and move main application/UI stuff into folders. Should help lead into creating a proper library 2019-08-22 18:43:17 -05:00
Adam Honse ef79de6c7c Fix LED strip length in RGBController_LEDStrip 2019-08-22 18:19:10 -05:00
Adam Honse 854d7d0ec5 Fix colors on LED strip 2019-08-22 18:13:41 -05:00
Adam Honse 727516e712 Initial LED strip settings.txt configuration (similar to KeyboardVisualizer) 2019-08-22 18:02:48 -05:00
Adam Honse 9126ded32e Move detection functions into their own files 2019-08-18 01:24:11 -05:00
Adam Honse d5a32eb743 Add more OpenRazer devices 2019-08-18 00:47:09 -05:00
Adam Honse 1bfeb59d6a Get OpenRazer autodetection working, add support for more devices 2019-08-18 00:24:44 -05:00
Adam Honse fd7d956913 Update detection for Corsair Vengeance Pro RGB 2019-08-16 18:46:12 -05:00
Adam Honse 50942d11b1 Update README 2019-08-16 18:30:25 -05:00
Network Silence aebffd9e48 Fixed readme for the project 2019-08-16 18:30:21 -05:00
Adam Honse ae77e44f73 Update README.md 2019-08-16 18:30:17 -05:00
Adam Honse 675eb40b94 Rudimentary detection for different types of RGB RAM, based on apparently static data from i2cdump 2019-08-15 23:41:56 -05:00
Adam Honse 7f09b14f50 Fix -0104 controller zone detection 2019-08-15 12:02:25 -05:00
Adam Honse b17d87a15b Add compile flags around Windows-specific code 2019-08-14 20:23:50 -05:00
Adam Honse 9e963e5cc7 Update Linux project file 2019-08-14 19:42:57 -05:00
Adam Honse fa8f06f273 Initial Corsair Vengeance Pro RGB support 2019-08-13 16:03:25 -05:00
Adam Honse 9c1d0e1a79 Add support for AUMA0-E6K5-0104 2019-08-07 12:19:45 -05:00
Adam Honse 60b9fd08bb Initial work on interface for HyperX Predator RGB, color and mode setting works 2019-06-30 11:57:08 -05:00
Adam Honse 9c5f592618 Add LEDStrip interface from KeyboardVisualizer 2019-06-20 22:43:26 -05:00
Adam Honse 8f96f9535d Add quick colors to Linux GUI 2019-06-20 12:27:01 -05:00
Adam Honse d94d6eb569 Fix Linux build 2019-06-20 00:03:55 -05:00
Adam Honse 06f21865c6 Move main function to its own file, add checks to prevent UI updates if no devices were detected 2019-06-19 12:31:58 -05:00
Adam Honse 18bf0ce013 Update Linux GUI to match changes to Windows one 2019-06-19 00:07:23 -05:00
Adam Honse af0bfde610 Set all devices at once with Set All button, add common function to set device to custom mode 2019-06-18 12:26:06 -05:00
Adam Honse ab4a07244a Add quick and dirty RGBController interface for Gigabyte Aorus 1080Ti Xtreme using GvDisplay.dll hack 2019-06-17 20:52:37 -05:00
Adam Honse 08532dc56c Add Razer DeathStalker Chroma 2019-06-16 15:16:22 -05:00
Adam Honse c69d8c4680 Initial support for DeathAdder Chroma 2019-06-16 14:24:02 -05:00
Adam Honse e9cf421719 Start writing a generic RGB wrapper for OpenRazer 2019-06-15 23:28:20 -05:00
Adam Honse 4887e9a11e Fix set LED button on Windows, rearrange Windows GUI to match Linux GUI 2019-06-15 21:34:43 -05:00
Adam Honse f71f325a97 Update Linux UI for generic RGB interface branch 2019-06-15 17:59:35 -05:00
Adam Honse 7ba607be8a Minor fixes - populate Mode box correctly on initialization and reorder operations for setting Aura mode to improve reliability 2019-06-15 12:38:57 -05:00
Adam Honse 4714aec6dd Start work on configuration table parsing for Aura devices. Process all channels with same type into their own zones 2019-06-15 12:16:21 -05:00
Adam Honse 7554e366f4 Add functions for setting single LED and all LEDs in a zone to a color, add zone dropdown to GUI 2019-06-14 23:31:23 -05:00
Adam Honse d60936b2e5 Use 32-bit RGBColor type (COLORREF compatible) instead of discrete red, green, and blue channels in generic RGB interface 2019-06-14 12:24:07 -05:00
Adam Honse 90b57e1846 Split RGBController classes into their own files 2019-06-13 23:24:05 -05:00
Adam Honse 8c3acbe889 Mode selection and Set All Colors working using generic RGB interface for Aura and Corsair Vengeance RGB 2019-06-13 23:02:27 -05:00
Adam Honse f5d7f2e537 Generic RGB development 2019-06-13 20:23:22 -05:00
Stavros Avramidis 234b006bee Add time-out on query enumeration
Signed-off-by: Stavros Avramidis <[email protected]>
2019-06-02 12:35:31 -05:00
Adam Honse 9c4bbec686 Add 0x4F and 0x66 to detected Aura addresses 2019-05-29 12:23:58 -05:00
Adam Honse 25d85a1db0 Re-add Super IO ID mask 2019-05-27 14:58:51 -05:00
Adam Honse dde0292719 Add a few more Nuvoton Super IO chips to the supported list including NCT6796D, clean up the Nuvoton detection code 2019-05-27 11:44:51 -05:00
Adam Honse 9d1745c0d0 Get SMBus base address from NCT6793D configuration registers 2019-05-27 04:14:22 -05:00
Adam Honse 559f1e9bcc Add preliminary probe functionality for NCT6793D, remove SMBus block read from NCT6793D SMBus driver as I haven't written this functionality yet 2019-05-23 00:05:28 -05:00
Adam Honse 3c95f9fe21 Fix block writes on Nuvoton NCT6793D SMBus driver 2019-05-22 00:01:58 -05:00
Adam Honse c2e384ab39 Add README.md 2019-05-21 03:55:04 +00:00
Adam Honse fe7d7df29b Initial SMBus driver for Nuvoton NCT6793D Super IO chip used on Prime Z270-A (and other Intel boards) 2019-05-20 22:21:10 -05:00
Thomas Berger 73d91b9494 Add support for 970 PRO GAMING/AURA
the Aura controller is located on 0x40 of the SMBus for
this board.
2019-04-23 20:30:02 -05:00
Adam Honse a2cdfc5aec Add Dump Aura button to Linux Qt dialog 2019-03-13 22:08:23 -05:00
Adam Honse 484e4e9770 Move Qt project file up to root directory 2019-03-13 19:49:36 -05:00
Adam Honse c45001b810 Initial files for Corsair Vengeance RGB RAM support 2019-03-09 00:18:35 -06:00
Adam Honse e3dcb9e87d Add button to dump Aura device memory 2019-03-06 21:48:48 -06:00
Adam Honse 75cf8b6aa8 Add support for AUMA0-E6K5-0105 2019-03-06 13:52:21 -06:00
Adam Honse 35ec4f5e90 cstring not string, oops 2019-03-06 12:47:16 -06:00
Adam Honse ab03edb6ce Add AUMA0-E6K5-0106 to device list and use v2 registers 2019-03-06 12:30:56 -06:00
Adam Honse 022871c5c5 Allow alternative color register locations for newer Aura chips. Select registers based on device string 2019-03-05 22:07:13 -06:00
Adam Honse dc3009bcaf Add some sanity checking to Aura device detection. Aura devices appear to read incrementing values at 0xA0 if no register written 2019-02-25 22:10:38 -06:00
Adam Honse 0941f25a8d Check for "INTEL" manufacturer string, per issue comment 10#note_144867740 by @F-Lehmann 2019-02-25 21:19:33 -06:00
Adam Honse 20fa1f4b1a vector not used on Linux, move to Windows ifdef block 2019-02-20 23:16:22 -06:00
Adam Honse f1be1c9a8f Add Qt GUI, builds and runs on Linux 2019-02-20 20:19:08 -06:00
241 changed files with 30011 additions and 1301 deletions
+1
View File
@@ -0,0 +1 @@
*.pro.user*
+6
View File
@@ -0,0 +1,6 @@
[submodule "dependencies/libe131"]
path = dependencies/libe131
url = https://github.com/CalcProgrammer1/libe131
[submodule "razer-drivers-win32"]
path = razer-drivers-win32
url = https://github.com/rsandoz/razer-drivers-win32
@@ -0,0 +1,348 @@
/*-----------------------------------------*\
| AMDWraithPrismController.h |
| |
| Driver for AMD Wraith Prism RGB lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 12/6/2019 |
\*-----------------------------------------*/
#include "AMDWraithPrismController.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
strcpy(device_name, "AMD Wraith Prism");
current_fan_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
current_fan_speed = 0xFF;
current_fan_random_color = false;
current_logo_mode = AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC;
current_logo_speed = 0xFF;
current_logo_random_color = false;
current_ring_mode = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
current_ring_speed = 0xFF;
current_ring_direction = false;
SendEnableCommand();
}
AMDWraithPrismController::~AMDWraithPrismController()
{
}
char* AMDWraithPrismController::GetDeviceName()
{
return device_name;
}
std::string AMDWraithPrismController::GetEffectChannelString(unsigned char channel)
{
std::string ret_string = "";
unsigned char usb_buf[] =
{
0x40, 0x21, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
int actual;
usb_buf[0x02] = channel;
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
ret_string.append((char *)&usb_buf[0x08]);
return(ret_string);
}
std::string AMDWraithPrismController::GetFirmwareVersionString()
{
std::string ret_string = "";
unsigned char usb_buf[] =
{
0x12, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
int actual;
unsigned char fw_buf[16] = {0x00};
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
for(int char_idx = 0; char_idx < 16; char_idx+=2)
{
if(usb_buf[char_idx + 0x08] != 0)
{
fw_buf[char_idx / 2] = usb_buf[char_idx + 0x08];
}
else
{
break;
}
}
ret_string.append((char *)fw_buf);
return(ret_string);
}
void AMDWraithPrismController::SetFanMode(unsigned char mode, unsigned char speed, bool random_color)
{
current_fan_mode = mode;
current_fan_speed = speed_values_fan_logo[mode][speed];
current_fan_random_color = random_color;
}
void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue)
{
SendEffectChannelUpdate
(
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED,
current_fan_speed,
false,
current_fan_random_color,
current_fan_mode,
max_brightness_fan_logo[current_fan_mode],
red,
green,
blue
);
}
void AMDWraithPrismController::SetLogoMode(unsigned char mode, unsigned char speed, bool random_color)
{
current_logo_mode = mode;
current_logo_speed = speed_values_fan_logo[mode][speed];
current_logo_random_color = random_color;
}
void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue)
{
SendEffectChannelUpdate
(
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED,
current_logo_speed,
false,
current_logo_random_color,
current_logo_mode,
max_brightness_fan_logo[current_logo_mode],
red,
green,
blue
);
}
void AMDWraithPrismController::SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color)
{
current_ring_mode = mode;
current_ring_speed = speed_values_ring[mode][speed];
current_ring_direction = direction;
current_ring_random_color = random_color;
}
void AMDWraithPrismController::SetRingColor(unsigned char red, unsigned char green, unsigned char blue)
{
SetRingEffectChannel(current_ring_mode);
SendEffectChannelUpdate
(
current_ring_mode,
current_ring_speed,
current_ring_direction,
current_ring_random_color,
mode_value_ring[current_ring_mode],
max_brightness_ring[current_ring_mode],
red,
green,
blue
);
SendApplyCommand();
}
void AMDWraithPrismController::SetRingEffectChannel(unsigned char channel)
{
SendChannelRemap(channel, AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED, AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED);
}
void AMDWraithPrismController::SendEnableCommand()
{
unsigned char usb_buf[] =
{
0x41, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
int actual;
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
}
void AMDWraithPrismController::SendApplyCommand()
{
unsigned char usb_buf[] =
{
0x51, 0x28, 0x00, 0x00,
0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
int actual;
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
}
void AMDWraithPrismController::SendEffectChannelUpdate
(
unsigned char effect_channel,
unsigned char speed,
bool direction,
bool random_color,
unsigned char mode,
unsigned char brightness,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
unsigned char usb_buf[] =
{
0x51, 0x2C, 0x01, 0x00,
0x05, 0xFF, 0x00, 0x01,
0xFF, 0xFF, 0x00, 0xFF,
0x00, 0x00, 0x00, 0x00,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF
};
int actual;
usb_buf[0x04] = effect_channel;
usb_buf[0x05] = speed;
usb_buf[0x06] = (direction ? 0x01 : 0x00) | (random_color ? 0x80 : 0x00);
usb_buf[0x07] = mode;
usb_buf[0x09] = brightness;
usb_buf[0x0A] = red;
usb_buf[0x0B] = green;
usb_buf[0x0C] = blue;
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
}
void AMDWraithPrismController::SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel)
{
unsigned char usb_buf[] =
{
0x51, 0xA0, 0x01, 0x00,
0x00, 0x03, 0x00, 0x00,
0x05, 0x06, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07,
0x07, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
int actual;
usb_buf[0x08] = logo_channel;
usb_buf[0x09] = fan_channel;
for(int led = 0x0A; led <= 0x18; led++)
{
usb_buf[led] = ring_channel;
}
libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0);
}
@@ -0,0 +1,166 @@
/*-----------------------------------------*\
| AMDWraithPrismController.h |
| |
| Definitions and types for AMD Wraith |
| Prism lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/6/2019 |
\*-----------------------------------------*/
#include <string>
#include <libusb-1.0/libusb.h>
#pragma once
static const unsigned char max_brightness_fan_logo[] =
{
0x00,
0xFF,
0x7F,
0xFF
};
static const unsigned char speed_values_fan_logo[][5] =
{
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
};
static const unsigned char max_brightness_ring[] =
{
0xFF,
0xFF,
0x7F,
0x00,
0x00,
0x00,
0x00,
0xFF,
0xFF,
0xFF,
0xFF,
0xFF
};
static const unsigned char mode_value_ring[] =
{
0xFF,
0x03,
0xFF,
0x00,
0x00,
0x00,
0x00,
0x05,
0xFF,
0xC3,
0x4A,
0x05
};
static const unsigned char speed_values_ring[][5] =
{
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }, /* Static */
{ 0x3C, 0x37, 0x31, 0x2C, 0x26 }, /* Breathing */
{ 0x96, 0x8C, 0x80, 0x6E, 0x68 }, /* Color Cycle */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* */
{ 0x72, 0x68, 0x64, 0x62, 0x61 }, /* Rainbow */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Bounce */
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Chase */
{ 0x77, 0x74, 0x6E, 0x6B, 0x67 }, /* Swirl */
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, /* Morse Code */
};
enum
{
AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC = 0x01, /* Fan/Logo Static Mode */
AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE = 0x02, /* Fan/Logo Color Cycle Mode */
AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING = 0x03, /* Fan/Logo Breathing Mode */
};
enum
{
AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC = 0x00, /* Static effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING = 0x01, /* Breathing effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE = 0x02, /* Color cycle effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_LOGO_LED = 0x05, /* Logo LED effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_FAN_LED = 0x06, /* Fan LED effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW = 0x07, /* Rainbow effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE = 0x08, /* Bounce effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE = 0x09, /* Chase effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL = 0x0A, /* Swirl effect channel */
AMD_WRAITH_PRISM_EFFECT_CHANNEL_MORSE = 0x0B, /* Morse code effect channel */
};
enum
{
AMD_WRAITH_PRISM_SPEED_SLOWEST = 0x00, /* Slowest speed */
AMD_WRAITH_PRISM_SPEED_SLOW = 0x01, /* Slow speed */
AMD_WRAITH_PRISM_SPEED_NORMAL = 0x02, /* Normal speed */
AMD_WRAITH_PRISM_SPEED_FAST = 0x03, /* Fast speed */
AMD_WRAITH_PRISM_SPEED_FASTEST = 0x04, /* Fastest speed */
};
class AMDWraithPrismController
{
public:
AMDWraithPrismController(libusb_device_handle* dev_handle);
~AMDWraithPrismController();
char* GetDeviceName();
std::string GetEffectChannelString(unsigned char channel);
std::string GetFirmwareVersionString();
void SetRingEffectChannel(unsigned char channel);
void SetFanMode(unsigned char mode, unsigned char speed, bool random_color);
void SetFanColor(unsigned char red, unsigned char green, unsigned char blue);
void SetLogoMode(unsigned char mode, unsigned char speed, bool random_color);
void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue);
void SetRingMode(unsigned char mode, unsigned char speed, bool direction, bool random_color);
void SetRingColor(unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
libusb_device_handle* dev;
unsigned char current_fan_mode;
unsigned char current_fan_speed;
bool current_fan_random_color;
unsigned char current_logo_mode;
unsigned char current_logo_speed;
bool current_logo_random_color;
unsigned char current_ring_mode;
unsigned char current_ring_speed;
bool current_ring_direction;
bool current_ring_random_color;
void SendEnableCommand();
void SendApplyCommand();
void SendEffectChannelUpdate
(
unsigned char effect_channel,
unsigned char speed,
bool direction,
bool random_color,
unsigned char mode,
unsigned char brightness,
unsigned char red,
unsigned char green,
unsigned char blue
);
void SendChannelRemap(unsigned char ring_channel, unsigned char logo_channel, unsigned char fan_channel);
};
@@ -0,0 +1,37 @@
#include "AMDWraithPrismController.h"
#include "RGBController.h"
#include "RGBController_AMDWraithPrism.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define AMD_WRAITH_PRISM_VID 0x2516
#define AMD_WRAITH_PRISM_PID 0x0051
/******************************************************************************************\
* *
* DetectAMDWraithPrismControllers *
* *
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
* *
\******************************************************************************************/
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for AMD Wraith Prism
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID);
if( dev )
{
libusb_detach_kernel_driver(dev, 1);
libusb_claim_interface(dev, 1);
AMDWraithPrismController* controller = new AMDWraithPrismController(dev);
RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -0,0 +1,273 @@
/*-----------------------------------------*\
| AuraController.cpp |
| |
| Driver for ASUS Aura RGB lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include "AuraController.h"
#include <cstring>
AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
{
this->bus = bus;
this->dev = dev;
AuraUpdateDeviceName();
// Read the device configuration table
for (int i = 0; i < 64; i++)
{
config_table[i] = AuraRegisterRead(AURA_REG_CONFIG_TABLE + i);
}
// Read LED count from configuration table
led_count = config_table[AURA_CONFIG_LED_COUNT];
// LED-0116 - First generation motherboard controller
if (strcmp(device_name, "LED-0116") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT;
effect_reg = AURA_REG_COLORS_EFFECT;
channel_cfg = AURA_CONFIG_CHANNEL_V1;
}
// DIMM_LED-0102 - First generation DRAM controller (Trident Z RGB)
else if (strcmp(device_name, "DIMM_LED-0102") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT;
effect_reg = AURA_REG_COLORS_EFFECT;
channel_cfg = AURA_CONFIG_CHANNEL_V1;
}
// AUDA0-E6K5-0101 - Second generation DRAM controller (Geil Super Luce)
else if (strcmp(device_name, "AUDA0-E6K5-0101") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT_V2;
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
}
// AUMA0-E6K5-0106 - Second generation motherboard controller
else if (strcmp(device_name, "AUMA0-E6K5-0106") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT_V2;
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
}
// AUMA0-E6K5-0105 - Second generation motherboard controller
else if (strcmp(device_name, "AUMA0-E6K5-0105") == 0)
{
direct_reg = AURA_REG_COLORS_DIRECT_V2;
effect_reg = AURA_REG_COLORS_EFFECT_V2;
channel_cfg = AURA_CONFIG_CHANNEL_V2;
}
// AUMA0-E6K5-0104 - Second generation motherboard controller
else if (strcmp(device_name, "AUMA0-E6K5-0104") == 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
{
direct_reg = AURA_REG_COLORS_DIRECT;
effect_reg = AURA_REG_COLORS_EFFECT;
channel_cfg = AURA_CONFIG_CHANNEL_V1;
}
}
AuraController::~AuraController()
{
}
std::string AuraController::GetDeviceName()
{
return(device_name);
}
std::string AuraController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char AuraController::GetChannel(unsigned int led)
{
return(config_table[channel_cfg + led]);
}
const char * AuraController::GetChannelName(unsigned int led)
{
switch (config_table[channel_cfg + led])
{
case (unsigned char)AURA_LED_CHANNEL_AUDIO:
return(aura_channels[0]);
break;
case (unsigned char)AURA_LED_CHANNEL_BACKPLATE:
return(aura_channels[1]);
break;
case (unsigned char)AURA_LED_CHANNEL_BACK_IO:
return(aura_channels[2]);
break;
case (unsigned char)AURA_LED_CHANNEL_CENTER:
return(aura_channels[3]);
break;
case (unsigned char)AURA_LED_CHANNEL_CENTER_START:
return(aura_channels[4]);
break;
case (unsigned char)AURA_LED_CHANNEL_DRAM:
return(aura_channels[5]);
break;
case (unsigned char)AURA_LED_CHANNEL_PCIE:
return(aura_channels[6]);
break;
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER:
return(aura_channels[7]);
break;
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_2:
return(aura_channels[8]);
break;
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_3:
return(aura_channels[9]);
break;
default:
return(aura_channels[10]);
break;
}
}
unsigned int AuraController::GetLEDCount()
{
return(led_count);
}
unsigned char AuraController::GetLEDRed(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led )));
}
unsigned char AuraController::GetLEDGreen(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
}
unsigned char AuraController::GetLEDBlue(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
}
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
for (unsigned int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
}
AuraRegisterWriteBlock(direct_reg, colors, led_count * 3);
delete colors;
}
void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
for (unsigned int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
}
AuraRegisterWriteBlock(effect_reg, colors, led_count * 3);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
delete[] colors;
}
void AuraController::SetDirect(unsigned char direct)
{
AuraRegisterWrite(AURA_REG_DIRECT, direct);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
AuraRegisterWriteBlock(direct_reg + ( 3 * led ), colors, 3);
}
void AuraController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
AuraRegisterWriteBlock(effect_reg + (3 * led), colors, 3);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetMode(unsigned char mode)
{
AuraRegisterWrite(AURA_REG_MODE, mode);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::AuraUpdateDeviceName()
{
for (int i = 0; i < 16; i++)
{
device_name[i] = AuraRegisterRead(AURA_REG_DEVICE_NAME + i);
}
}
unsigned char AuraController::AuraRegisterRead(aura_register reg)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Read Aura value
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
}
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Aura value
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
}
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Aura block data
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
}
@@ -7,6 +7,7 @@
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
@@ -19,6 +20,7 @@ typedef unsigned short aura_register;
enum
{
AURA_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
AURA_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
AURA_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
@@ -26,6 +28,8 @@ enum
AURA_REG_APPLY = 0x80A0, /* AURA Apply Changes Register */
AURA_REG_SLOT_INDEX = 0x80F8, /* AURA Slot Index Register (RAM only) */
AURA_REG_I2C_ADDRESS = 0x80F9, /* AURA I2C Address Register (RAM only) */
AURA_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
AURA_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
};
enum
@@ -44,6 +48,44 @@ enum
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
AURA_NUMBER_MODES /* Number of Aura modes */
};
enum
{
AURA_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
AURA_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
AURA_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
AURA_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
AURA_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
AURA_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
AURA_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
AURA_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
AURA_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
AURA_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
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 */
AURA_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
};
class AuraController
@@ -52,8 +94,14 @@ public:
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
~AuraController();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned char GetChannel(unsigned int led);
const char* GetChannelName(unsigned int led);
unsigned int GetLEDCount();
unsigned char GetLEDRed(unsigned int led);
unsigned char GetLEDGreen(unsigned int led);
unsigned char GetLEDBlue(unsigned int led);
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetDirect(unsigned char direct);
@@ -63,15 +111,18 @@ public:
void AuraUpdateDeviceName();
unsigned char AuraRegisterRead(aura_register reg);
void AuraRegisterWrite(aura_register reg, unsigned char val);
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
unsigned char AuraRegisterRead(aura_register reg);
void AuraRegisterWrite(aura_register reg, unsigned char val);
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
private:
char device_name[16];
unsigned char config_table[64];
unsigned int led_count;
aura_register direct_reg;
aura_register effect_reg;
unsigned char channel_cfg;
i2c_smbus_interface * bus;
aura_dev_id dev;
};
};
@@ -0,0 +1,194 @@
#include "AuraController.h"
#include "RGBController.h"
#include "RGBController_Aura.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/*----------------------------------------------------------------------*\
| This list contains the available SMBus addresses for mapping Aura RAM |
\*----------------------------------------------------------------------*/
#define AURA_RAM_ADDRESS_COUNT 21
static const unsigned char aura_ram_addresses[] =
{
0x70,
0x71,
0x73,
0x74,
0x75,
0x76,
0x78,
0x79,
0x7A,
0x7B,
0x7C,
0x7D,
0x7E,
0x7F,
0x4F,
0x66,
0x67,
0x39,
0x3B,
0x3C,
0x3D
};
/*---------------------------------------------------------------------------------*\
| This list contains the available SMBus addresses for mapping Aura motherboards |
\*---------------------------------------------------------------------------------*/
#define AURA_MOBO_ADDRESS_COUNT 4
static const unsigned char aura_mobo_addresses[] =
{
0x40,
0x4E,
0x4F,
0x66
};
/******************************************************************************************\
* *
* AuraRegisterWrite *
* *
* A standalone version of the AuraController::AuraRegisterWrite function for access *
* to Aura devices without instancing the AuraController class or reading the config *
* table from the device. *
* *
\******************************************************************************************/
void AuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register reg, unsigned char val)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Aura value
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
}
/******************************************************************************************\
* *
* TestForAuraController *
* *
* Tests the given address to see if an Aura controller exists there. First does a *
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
* for incrementing values 0...F which was observed at this location during data dump *
* *
\******************************************************************************************/
bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
for (int i = 0xA0; i < 0xB0; i++)
{
res = bus->i2c_smbus_read_byte_data(address, i);
if (res != (i - 0xA0))
{
pass = false;
}
}
}
return(pass);
} /* TestForAuraController() */
/******************************************************************************************\
* *
* DetectAuraControllers *
* *
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
* at their correct initialized addresses. Also looks for motherboard controller at *
* address 0x4E. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
AuraController* new_aura;
RGBController_Aura* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
int address_list_idx = 0;
// Remap Aura-enabled RAM modules on 0x77
for (unsigned int slot = 0; slot < 8; slot++)
{
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
if (res < 0)
{
break;
}
do
{
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
{
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
address_list_idx++;
}
else
{
break;
}
} while (res >= 0);
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
}
// Add Aura-enabled controllers at their remapped addresses
for (unsigned int address_list_idx = 0; address_list_idx < AURA_RAM_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraController(busses[bus], aura_ram_addresses[address_list_idx]))
{
new_aura = new AuraController(busses[bus], aura_ram_addresses[address_list_idx]);
new_controller = new RGBController_Aura(new_aura);
rgb_controllers.push_back(new_controller);
}
Sleep(1);
}
// Add Aura-enabled motherboard controllers
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraController(busses[bus], aura_mobo_addresses[address_list_idx]))
{
new_aura = new AuraController(busses[bus], aura_mobo_addresses[address_list_idx]);
new_controller = new RGBController_Aura(new_aura);
rgb_controllers.push_back(new_controller);
}
Sleep(1);
}
}
} /* DetectAuraControllers() */
@@ -0,0 +1,504 @@
/*---------------------------------------------------------*\
| Processing Code for Corsair Commander Pro |
| |
| Adam Honse ([email protected]), 1/16/2020 |
\*---------------------------------------------------------*/
#include "CorsairCmdrProController.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
CorsairCmdrProController* corsair = static_cast<CorsairCmdrProController*>(param);
corsair->KeepaliveThread();
THREADRETURN
}
CorsairCmdrProController::CorsairCmdrProController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
channel_leds[0] = 60;
channel_leds[1] = 60;
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
}
CorsairCmdrProController::~CorsairCmdrProController()
{
}
void CorsairCmdrProController::KeepaliveThread()
{
while(1)
{
SendCommit();
Sleep(5000);
}
}
void CorsairCmdrProController::SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
/*-----------------------------------------------------*\
| Send Reset packet |
\*-----------------------------------------------------*/
SendReset(channel);
/*-----------------------------------------------------*\
| Send Begin packet |
\*-----------------------------------------------------*/
SendBegin(channel);
/*-----------------------------------------------------*\
| Set Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
/*-----------------------------------------------------*\
| Set Effect Configuration packet |
\*-----------------------------------------------------*/
SendEffectConfig
(
channel,
0,
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
mode,
speed,
direction,
random,
red1,
grn1,
blu1,
red2,
grn2,
blu2,
0,
0,
0,
0,
0,
0
);
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
void CorsairCmdrProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
/*-----------------------------------------------------*\
| Send Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
}
/*-----------------------------------------------------*\
| Send green channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
| Send blue channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
}
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairCmdrProController::SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendCommit()
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBegin
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count * 10;
usb_buf[0x03] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x10] = color_0_green;
usb_buf[0x11] = color_0_blue;
usb_buf[0x12] = color_1_red;
usb_buf[0x13] = color_1_green;
usb_buf[0x14] = color_1_blue;
usb_buf[0x15] = color_2_red;
usb_buf[0x16] = color_2_green;
usb_buf[0x17] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendTemperature()
{
}
void CorsairCmdrProController::SendReset
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendPortState
(
unsigned char channel,
unsigned char state
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBrightness()
{
}
void CorsairCmdrProController::SendLEDCount()
{
}
void CorsairCmdrProController::SendProtocol()
{
}
@@ -0,0 +1,163 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Commander Pro |
| |
| Adam Honse ([email protected]), 1/16/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
};
enum
{
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
class CorsairCmdrProController
{
public:
CorsairCmdrProController(libusb_device_handle* dev_handle);
~CorsairCmdrProController();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
void KeepaliveThread();
private:
libusb_device_handle* dev;
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};
@@ -0,0 +1,37 @@
#include "CorsairCmdrProController.h"
#include "RGBController.h"
#include "RGBController_CorsairCmdrPro.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define CORSAIR_COMMANDER_PRO_VID 0x1B1C
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
/******************************************************************************************\
* *
* DetectCorsairCmdrProControllers *
* *
* Detect devices supported by the Corsair Commander Pro driver *
* * *
\******************************************************************************************/
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for Corsair Commander Pro
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_COMMANDER_PRO_VID, CORSAIR_COMMANDER_PRO_PID);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairCmdrProController* controller = new CorsairCmdrProController(dev);
RGBController_CorsairCmdrPro* rgb_controller = new RGBController_CorsairCmdrPro(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectCorsairCmdrProControllers() */
@@ -0,0 +1,59 @@
/*-----------------------------------------*\
| CorsairController.h |
| |
| Driver for Corsair Vengeance RGB RAM |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 3/8/2019 |
\*-----------------------------------------*/
#include "CorsairController.h"
#include <cstring>
CorsairController::CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "Corsair Vengeance RGB");
led_count = 1;
}
CorsairController::~CorsairController()
{
}
std::string CorsairController::GetDeviceName()
{
return(device_name);
}
std::string CorsairController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int CorsairController::GetLEDCount()
{
return(led_count);
}
void CorsairController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_RED_VAL, red);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL, green);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL, blue);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
}
void CorsairController::SetMode(unsigned char /*mode*/)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
}
@@ -0,0 +1,54 @@
/*-----------------------------------------*\
| CorsairController.h |
| |
| Definitions and types for Corsair |
| Vengeance RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 3/8/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char corsair_dev_id;
typedef unsigned char corsair_cmd;
enum
{
CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME = 0xA4, /* Fade Time, 0 for Static */
CORSAIR_VENGEANCE_RGB_CMD_HOLD_TIME = 0xA5, /* Hold Time */
CORSAIR_VENGEANCE_RGB_CMD_MODE = 0xA6, /* Mode Control Value */
CORSAIR_VENGEANCE_RGB_CMD_RED_VAL = 0xB0, /* Red Color Value */
CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL = 0xB1, /* Green Color Value */
CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL = 0xB2, /* Blue Color Value */
};
enum
{
CORSAIR_VENGEANCE_RGB_MODE_SINGLE = 0x00, /* Single Color Effect Mode */
CORSAIR_VENGEANCE_RGB_MODE_FADE = 0x01, /* Fade Through Colors */
CORSAIR_VENGEANCE_RGB_MODE_PULSE = 0x02, /* Pulse Through Colors */
CORSAIR_NUMBER_MODES /* Number of Corsair modes */
};
class CorsairController
{
public:
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetMode(unsigned char mode);
void SetLEDColor(unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
unsigned int led_count;
i2c_smbus_interface * bus;
corsair_dev_id dev;
};
@@ -0,0 +1,125 @@
#include "CorsairController.h"
#include "RGBController.h"
#include "RGBController_Corsair.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* TestForCorsairController *
* *
* Tests the given address to see if a Corsair controller exists there. *
* *
\******************************************************************************************/
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
for (int i = 0xA0; i < 0xB0; i++)
{
res = bus->i2c_smbus_read_byte_data(address, i);
if (res != 0xBA)
{
pass = false;
}
}
}
return(pass);
} /* TestForCorsairController() */
/******************************************************************************************\
* *
* DetectCorsairControllers *
* *
* Detect Corsair controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
CorsairController* new_corsair;
RGBController_Corsair* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for Corsair controller at 0x58
if (TestForCorsairController(busses[bus], 0x58))
{
new_corsair = new CorsairController(busses[bus], 0x58);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x59
if (TestForCorsairController(busses[bus], 0x59))
{
new_corsair = new CorsairController(busses[bus], 0x59);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairController(busses[bus], 0x5A))
{
new_corsair = new CorsairController(busses[bus], 0x5A);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairController(busses[bus], 0x5B))
{
new_corsair = new CorsairController(busses[bus], 0x5B);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairController(busses[bus], 0x5C))
{
new_corsair = new CorsairController(busses[bus], 0x5C);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairController(busses[bus], 0x5D))
{
new_corsair = new CorsairController(busses[bus], 0x5D);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairController(busses[bus], 0x5E))
{
new_corsair = new CorsairController(busses[bus], 0x5E);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairController(busses[bus], 0x5F))
{
new_corsair = new CorsairController(busses[bus], 0x5F);
new_controller = new RGBController_Corsair(new_corsair);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectCorsairControllers() */
@@ -0,0 +1,253 @@
/*-----------------------------------------*\
| CorsairKeyboardController.cpp |
| |
| Driver for Corsair RGB keyboard lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "CorsairKeyboardController.h"
#include <cstring>
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141};
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
}
static void get_usb_msg(hid_device* dev, char* data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_get_feature_report(dev, (unsigned char*)data_pkt, 64);
bytes++;
}
CorsairKeyboardController::CorsairKeyboardController(hid_device* dev_handle)
{
dev = dev_handle;
char data_pkt[64] = { 0 };
LightingControl();
}
CorsairKeyboardController::~CorsairKeyboardController()
{
}
void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char data_pkt[216];
unsigned char red_val[144];
unsigned char grn_val[144];
unsigned char blu_val[144];
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(data_pkt, 0x00, sizeof( data_pkt ));
memset(red_val, 0x00, sizeof( red_val ));
memset(grn_val, 0x00, sizeof( grn_val ));
memset(blu_val, 0x00, sizeof( blu_val ));
/*-----------------------------------------------------*\
| Scale color values to 9-bit |
\*-----------------------------------------------------*/
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
{
RGBColor color = colors[color_idx];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if( red > 7 ) red = 7;
if( grn > 7 ) grn = 7;
if( blu > 7 ) blu = 7;
red = 7 - red;
grn = 7 - grn;
blu = 7 - blu;
red_val[keys[color_idx]] = red;
grn_val[keys[color_idx]] = grn;
blu_val[keys[color_idx]] = blu;
}
/*-----------------------------------------------------*\
| Pack the color values, 2 values per byte |
\*-----------------------------------------------------*/
for(int red_idx = 0; red_idx < 72; red_idx++)
{
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
}
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
{
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
}
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
{
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
}
/*-----------------------------------------------------*\
| Send the packets |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &data_pkt[0]);
StreamPacket(2, 60, &data_pkt[60]);
StreamPacket(3, 60, &data_pkt[120]);
StreamPacket(4, 36, &data_pkt[180]);
SubmitLimitedColors(216);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairKeyboardController::LightingControl()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x04] = 0x03;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::ReadFirmwareInfo()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
get_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::StreamPacket
(
unsigned char packet_id,
unsigned char data_sz,
unsigned char* data_ptr
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::SubmitColors()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::SubmitLimitedColors
(
unsigned char byte_count
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
@@ -0,0 +1,78 @@
/*-----------------------------------------*\
| CorsairKeyboardController.h |
| |
| Definitions and types for Corsair RGB |
| keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
CORSAIR_COMMAND_WRITE = 0x07,
CORSAIR_COMMAND_READ = 0x0E,
CORSAIR_COMMAND_STREAM = 0x7F
};
enum
{
CORSAIR_PROPERTY_FIRMWARE_INFO = 0x01,
CORSAIR_PROPERTY_RESET = 0x02,
CORSAIR_PROPERTY_SPECIAL_FUNCTION = 0x04,
CORSAIR_PROPERTY_LIGHTING_CONTROL = 0x05,
CORSAIR_PROPERTY_HARDWARE_PROFILE = 0x13,
CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR = 0x22,
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9 = 0x27,
CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24 = 0x28,
};
enum
{
CORSAIR_LIGHTING_CONTROL_HARDWARE = 0x01,
CORSAIR_LIGHTING_CONTROL_SOFTWARE = 0x02
};
enum
{
CORSAIR_COLOR_CHANNEL_RED = 0x01,
CORSAIR_COLOR_CHANNEL_GREEN = 0x02,
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
};
class CorsairKeyboardController
{
public:
CorsairKeyboardController(hid_device* dev_handle);
~CorsairKeyboardController();
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetLEDs(std::vector<RGBColor> colors);
private:
hid_device* dev;
void LightingControl();
void ReadFirmwareInfo();
void StreamPacket
(
unsigned char packet_id,
unsigned char data_sz,
unsigned char* data_ptr
);
void SubmitColors();
void SubmitLimitedColors
(
unsigned char byte_count
);
};
@@ -0,0 +1,52 @@
#include "CorsairKeyboardController.h"
#include "RGBController.h"
#include "RGBController_CorsairKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
#define CORSAIR_RGB_KEYBOARD_VID 0x1B1C
#define CORSAIR_RGB_KEYBOARD_K70_PID 0x1B13
#define CORSAIR_RGB_KEYBOARD_K95_PID 0x1B11
/******************************************************************************************\
* *
* DetectCorsairKeyboardControllers *
* *
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
info = hid_enumerate(CORSAIR_RGB_KEYBOARD_VID, CORSAIR_RGB_KEYBOARD_K70_PID);
//Look for Corsair RGB Keyboard, interface 1
while(info)
{
if((info->vendor_id == CORSAIR_RGB_KEYBOARD_VID)
&&(info->product_id == CORSAIR_RGB_KEYBOARD_K70_PID)
&&(info->interface_number == 1))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairKeyboardController* controller = new CorsairKeyboardController(dev);
RGBController_CorsairKeyboard* rgb_controller = new RGBController_CorsairKeyboard(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -0,0 +1,504 @@
/*---------------------------------------------------------*\
| Processing Code for Corsair Lighting Node Pro |
| |
| Adam Honse ([email protected]), 1/12/2020 |
\*---------------------------------------------------------*/
#include "CorsairNodeProController.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
CorsairNodeProController* corsair = static_cast<CorsairNodeProController*>(param);
corsair->KeepaliveThread();
THREADRETURN
}
CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
channel_leds[0] = 60;
channel_leds[1] = 60;
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
}
CorsairNodeProController::~CorsairNodeProController()
{
}
void CorsairNodeProController::KeepaliveThread()
{
while(1)
{
SendCommit();
Sleep(5000);
}
}
void CorsairNodeProController::SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
/*-----------------------------------------------------*\
| Send Reset packet |
\*-----------------------------------------------------*/
SendReset(channel);
/*-----------------------------------------------------*\
| Send Begin packet |
\*-----------------------------------------------------*/
SendBegin(channel);
/*-----------------------------------------------------*\
| Set Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
/*-----------------------------------------------------*\
| Set Effect Configuration packet |
\*-----------------------------------------------------*/
SendEffectConfig
(
channel,
0,
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
mode,
speed,
direction,
random,
red1,
grn1,
blu1,
red2,
grn2,
blu2,
0,
0,
0,
0,
0,
0
);
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
/*-----------------------------------------------------*\
| Send Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
}
/*-----------------------------------------------------*\
| Send green channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
| Send blue channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
}
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairNodeProController::SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendCommit()
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendBegin
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count * 10;
usb_buf[0x03] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x10] = color_0_green;
usb_buf[0x11] = color_0_blue;
usb_buf[0x12] = color_1_red;
usb_buf[0x13] = color_1_green;
usb_buf[0x14] = color_1_blue;
usb_buf[0x15] = color_2_red;
usb_buf[0x16] = color_2_green;
usb_buf[0x17] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendTemperature()
{
}
void CorsairNodeProController::SendReset
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendPortState
(
unsigned char channel,
unsigned char state
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendBrightness()
{
}
void CorsairNodeProController::SendLEDCount()
{
}
void CorsairNodeProController::SendProtocol()
{
}
@@ -0,0 +1,170 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Lighting Node Pro |
| |
| Adam Honse ([email protected]), 1/12/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
};
enum
{
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
enum
{
CORSAIR_NODE_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_NODE_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_NODE_PRO_NUM_CHANNELS = 0x02 /* Number of channels */
};
class CorsairNodeProController
{
public:
CorsairNodeProController(libusb_device_handle* dev_handle);
~CorsairNodeProController();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
unsigned int channel_leds[CORSAIR_NODE_PRO_NUM_CHANNELS];
void KeepaliveThread();
private:
libusb_device_handle* dev;
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};
@@ -0,0 +1,37 @@
#include "CorsairNodeProController.h"
#include "RGBController.h"
#include "RGBController_CorsairNodePro.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define CORSAIR_LIGHTING_NODE_PRO_VID 0x1B1C
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
/******************************************************************************************\
* *
* DetectCorsairNodeProControllers *
* *
* Detect devices supported by the Corsair Lighting Node Pro driver *
* * *
\******************************************************************************************/
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for Corsair Lighting Node Pro
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_LIGHTING_NODE_PRO_VID, CORSAIR_LIGHTING_NODE_PRO_PID);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairNodeProController* controller = new CorsairNodeProController(dev);
RGBController_CorsairNodePro* rgb_controller = new RGBController_CorsairNodePro(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectCorsairNodeProControllers() */
@@ -0,0 +1,172 @@
/*-----------------------------------------*\
| CorsairProController.cpp |
| |
| Definitions and types for Corsair |
| Vengeance Pro RGB RAM lighting controller|
| |
| Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/
#include "CorsairProController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "Corsair Vengeance Pro RGB");
led_count = CORSAIR_PRO_LED_COUNT;
effect_mode = CORSAIR_PRO_MODE_STATIC;
for (unsigned int i = 0; i < led_count; i++)
{
led_red[i] = 0;
led_green[i] = 0;
led_blue[i] = 0;
}
}
CorsairProController::~CorsairProController()
{
}
std::string CorsairProController::GetDeviceName()
{
return(device_name);
}
std::string CorsairProController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned int CorsairProController::GetLEDCount()
{
return(led_count);
}
unsigned char CorsairProController::GetEffect()
{
return(effect_mode);
}
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
for (unsigned int i = 0; i < led_count; i++)
{
led_red[i] = red;
led_green[i] = green;
led_blue[i] = blue;
}
}
void CorsairProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
led_red[led] = red;
led_green[led] = green;
led_blue[led] = blue;
}
void CorsairProController::ApplyColors()
{
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
Sleep(1);
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
Sleep(1);
for (int i = 0; i < 10; i++)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_red[i]);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_green[i]);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_blue[i]);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
}
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
}
void CorsairProController::SetEffect(unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
)
{
effect_mode = mode;
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
Sleep(1);
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
Sleep(1);
unsigned char random_byte;
if(random)
{
random_byte = CORSAIR_PRO_EFFECT_RANDOM_COLORS;
}
else
{
random_byte = CORSAIR_PRO_EFFECT_CUSTOM_COLORS;
}
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, effect_mode); //Mode
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, speed); //Speed
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, random_byte); //Custom color
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, direction); //Direction
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red1); // Custom color 1 red
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn1); // Custom color 1 green
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu1); // Custom color 1 blue
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, red2); // Custom color 2 red
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, grn2); // Custom color 2 green
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, blu2); // Custom color 2 blue
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x01);
WaitReady();
}
bool CorsairProController::WaitReady()
{
int i = 0;
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
{
i++;
Sleep(1);
}
return false;
}
@@ -0,0 +1,100 @@
/*-----------------------------------------*\
| CorsairProController.h |
| |
| Definitions and types for Corsair |
| Vengeance Pro RGB RAM lighting controller|
| |
| Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char corsair_dev_id;
#define CORSAIR_PRO_LED_COUNT ( 10 )
enum
{
CORSAIR_PRO_REG_COMMAND = 0x20, /* Command write register */
};
enum
{
CORSAIR_PRO_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */
CORSAIR_PRO_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */
CORSAIR_PRO_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */
CORSAIR_PRO_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */
CORSAIR_PRO_MODE_VISOR = 0x05, /* Visor mode */
CORSAIR_PRO_MODE_RAIN = 0x06, /* Rain mode */
CORSAIR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_PRO_MODE_RAINBOW = 0x08, /* Rainbow mode */
CORSAIR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_PRO_MODE_STATIC = 0x10, /* Static mode */
CORSAIR_PRO_NUMBER_MODES = 10, /* Number of Corsair Pro modes */
};
enum
{
CORSAIR_PRO_SPEED_SLOW = 0x00, /* Slow speed */
CORSAIR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_PRO_SPEED_FAST = 0x02, /* Fast speed */
};
enum
{
CORSAIR_PRO_EFFECT_RANDOM_COLORS = 0x00, /* Random colors */
CORSAIR_PRO_EFFECT_CUSTOM_COLORS = 0x01, /* Custom colors */
};
enum
{
CORSAIR_PRO_DIRECTION_UP = 0x00, /* Up direction */
CORSAIR_PRO_DIRECTION_DOWN = 0x01, /* Down direction */
CORSAIR_PRO_DIRECTION_LEFT = 0x02, /* Left direction */
CORSAIR_PRO_DIRECTION_RIGHT = 0x03, /* Right direction */
CORSAIR_PRO_DIRECTION_VERTICAL = 0x01, /* Vertical direction */
CORSAIR_PRO_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */
};
class CorsairProController
{
public:
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairProController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned char GetEffect();
void SetEffect(unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2
);
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void ApplyColors();
bool WaitReady();
private:
char device_name[32];
unsigned int led_count;
unsigned char effect_mode;
unsigned char led_red[CORSAIR_PRO_LED_COUNT];
unsigned char led_green[CORSAIR_PRO_LED_COUNT];
unsigned char led_blue[CORSAIR_PRO_LED_COUNT];
i2c_smbus_interface* bus;
corsair_dev_id dev;
};
@@ -0,0 +1,142 @@
#include "CorsairProController.h"
#include "RGBController.h"
#include "RGBController_CorsairPro.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/******************************************************************************************\
* *
* TestForCorsairProController *
* *
* Tests the given address to see if a Corsair Pro controller exists there. *
* *
\******************************************************************************************/
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
res = bus->i2c_smbus_read_byte_data(address, 0x43);
if (res != 0x1C)
{
pass = false;
}
res = bus->i2c_smbus_read_byte_data(address, 0x44);
if (res != 0x03)
{
pass = false;
}
}
Sleep(10);
return(pass);
} /* TestForCorsairProController() */
/******************************************************************************************\
* *
* DetectCorsairProControllers *
* *
* Detect Corsair Pro controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
CorsairProController* new_corsair_pro;
RGBController_CorsairPro* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for Corsair controller at 0x58
if (TestForCorsairProController(busses[bus], 0x58))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x58);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x59
if (TestForCorsairProController(busses[bus], 0x59))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x59);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairProController(busses[bus], 0x5A))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairProController(busses[bus], 0x5B))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairProController(busses[bus], 0x5C))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairProController(busses[bus], 0x5D))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairProController(busses[bus], 0x5E))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairProController(busses[bus], 0x5F))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectCorsairProControllers() */
@@ -0,0 +1,133 @@
/*-----------------------------------------*\
| CrucialController.cpp |
| |
| Driver for Crucial Ballistix RGB lighting|
| controller |
| |
| Adam Honse (CalcProgrammer1) 1/19/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "CrucialController.h"
#include <cstring>
CrucialController::CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev)
{
this->bus = bus;
this->dev = dev;
}
CrucialController::~CrucialController()
{
}
std::string CrucialController::GetDeviceName()
{
return(device_name);
}
std::string CrucialController::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 int CrucialController::GetLEDCount()
{
return(led_count);
}
void CrucialController::SetMode(unsigned char mode)
{
SendEffectMode(mode, 0x10);
}
void CrucialController::SetAllColorsDirect(RGBColor* colors)
{
SendDirectColors(colors);
}
void CrucialController::SendEffectColors(unsigned char red, unsigned char green, unsigned char blue)
{
CrucialRegisterWrite(0x82E9, 0xFF);
CrucialRegisterWrite(0x82EA, 0x00);
CrucialRegisterWrite(0x82EB, 0x00);
CrucialRegisterWrite(0x82EC, 0x00);
CrucialRegisterWrite(0x82ED, red);
CrucialRegisterWrite(0x82EE, green);
CrucialRegisterWrite(0x82EF, blue);
CrucialRegisterWrite(0x82F0, 0x01);
}
void CrucialController::SendBrightness(unsigned char brightness)
{
CrucialRegisterWrite(0x82EE, 0xFF);
CrucialRegisterWrite(0x82EF, brightness);
CrucialRegisterWrite(0x82F0, 0x83);
}
void CrucialController::SendEffectMode(unsigned char mode, unsigned char speed)
{
CrucialRegisterWrite(0x820F, mode);
CrucialRegisterWrite(0x82EE, 0x00);
CrucialRegisterWrite(0x82EF, speed);
CrucialRegisterWrite(0x82F0, 0x84);
}
void CrucialController::SendDirectColors(RGBColor* color_buf)
{
//Red Channels
CrucialRegisterWrite(0x8300, RGBGetRValue(color_buf[0]));
CrucialRegisterWrite(0x8301, RGBGetRValue(color_buf[1]));
CrucialRegisterWrite(0x8302, RGBGetRValue(color_buf[2]));
CrucialRegisterWrite(0x8303, RGBGetRValue(color_buf[3]));
CrucialRegisterWrite(0x8304, RGBGetRValue(color_buf[4]));
CrucialRegisterWrite(0x8305, RGBGetRValue(color_buf[5]));
CrucialRegisterWrite(0x8306, RGBGetRValue(color_buf[6]));
CrucialRegisterWrite(0x8307, RGBGetRValue(color_buf[7]));
//Green Channels
CrucialRegisterWrite(0x8340, RGBGetGValue(color_buf[0]));
CrucialRegisterWrite(0x8341, RGBGetGValue(color_buf[1]));
CrucialRegisterWrite(0x8342, RGBGetGValue(color_buf[2]));
CrucialRegisterWrite(0x8343, RGBGetGValue(color_buf[3]));
CrucialRegisterWrite(0x8344, RGBGetGValue(color_buf[4]));
CrucialRegisterWrite(0x8345, RGBGetGValue(color_buf[5]));
CrucialRegisterWrite(0x8346, RGBGetGValue(color_buf[6]));
CrucialRegisterWrite(0x8347, RGBGetGValue(color_buf[7]));
//Blue Channels
CrucialRegisterWrite(0x8380, RGBGetBValue(color_buf[0]));
CrucialRegisterWrite(0x8381, RGBGetBValue(color_buf[1]));
CrucialRegisterWrite(0x8382, RGBGetBValue(color_buf[2]));
CrucialRegisterWrite(0x8383, RGBGetBValue(color_buf[3]));
CrucialRegisterWrite(0x8384, RGBGetBValue(color_buf[4]));
CrucialRegisterWrite(0x8385, RGBGetBValue(color_buf[5]));
CrucialRegisterWrite(0x8386, RGBGetBValue(color_buf[6]));
CrucialRegisterWrite(0x8387, RGBGetBValue(color_buf[7]));
}
unsigned char CrucialController::CrucialRegisterRead(crucial_register reg)
{
//Write Crucial register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Read Crucial value
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
}
void CrucialController::CrucialRegisterWrite(crucial_register reg, unsigned char val)
{
//Write Crucial register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Crucial value
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
}
@@ -0,0 +1,62 @@
/*-----------------------------------------*\
| CrucialController.h |
| |
| Definitions and types for Crucial |
| Ballistix RGB lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/19/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char crucial_dev_id;
typedef unsigned short crucial_register;
enum
{
CRUCIAL_MODE_SHIFT = 0x1F, /* Shift effect mode */
CRUCIAL_MODE_GRADIENT_SHIFT = 0x2F, /* Gradient shift mode */
CRUCIAL_MODE_FILL = 0x3F, /* Fill effect mode */
CRUCIAL_MODE_STACK = 0x4F, /* Stack effect mode */
CRUCIAL_MODE_DOUBLE_STACK = 0x5F, /* Double stack effect mode */
CRUCIAL_MODE_BREATHING = 0x6F, /* Breathing effect mode */
CRUCIAL_MODE_MOTION_POINT = 0x7F, /* Motion point effect mode */
CRUCIAL_MODE_INSIDE_OUT = 0x8F, /* Inside out effect mode */
CRUCIAL_MODE_COLOR_STEP = 0x9F, /* Color step effect mode */
CRUCIAL_MODE_WATER_WAVE = 0xAF, /* Water wave effect mode */
CRUCIAL_MODE_FLASHING = 0xBF, /* Flashing effect mode */
CRUCIAL_MODE_STATIC = 0xCF, /* Static effect mode */
};
class CrucialController
{
public:
CrucialController(i2c_smbus_interface* bus, crucial_dev_id dev);
~CrucialController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetAllColorsDirect(RGBColor* colors);
void SetMode(unsigned char mode);
unsigned char CrucialRegisterRead(crucial_register reg);
void CrucialRegisterWrite(crucial_register reg, unsigned char val);
private:
char device_name[16];
unsigned char config_table[64];
unsigned int led_count;
unsigned char channel_cfg;
i2c_smbus_interface * bus;
crucial_dev_id dev;
void SendDirectColors(RGBColor* color_buf);
void SendEffectColors(unsigned char red, unsigned char green, unsigned char blue);
void SendBrightness(unsigned char brightness);
void SendEffectMode(unsigned char mode, unsigned char speed);
};
@@ -0,0 +1,88 @@
#include "CrucialController.h"
#include "RGBController.h"
#include "RGBController_Crucial.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/*----------------------------------------------------------------------*\
| This list contains the available SMBus addresses for Crucial RAM |
\*----------------------------------------------------------------------*/
#define CRUCIAL_ADDRESS_COUNT 4
static const unsigned char crucial_addresses[] =
{
0x20,
0x21,
0x22,
0x23
};
/******************************************************************************************\
* *
* TestForCrucialController *
* *
* Tests the given address to see if an Crucial controller exists there. First does a*
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
* for incrementing values 0...F which was observed at this location during data dump *
* *
\******************************************************************************************/
bool TestForCrucialController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
for (int i = 0xA0; i < 0xB0; i++)
{
res = bus->i2c_smbus_read_byte_data(address, i);
if (res != (i - 0xA0))
{
pass = false;
}
}
}
return(pass);
} /* TestForCrucialController() */
/******************************************************************************************\
* *
* DetectCrucialControllers *
* *
* Detect Crucial controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
CrucialController* new_crucial;
RGBController_Crucial* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Add Crucial controllers
for (unsigned int address_list_idx = 0; address_list_idx < CRUCIAL_ADDRESS_COUNT; address_list_idx++)
{
if (TestForCrucialController(busses[bus], crucial_addresses[address_list_idx]))
{
new_crucial = new CrucialController(busses[bus], crucial_addresses[address_list_idx]);
new_controller = new RGBController_Crucial(new_crucial);
rgb_controllers.push_back(new_controller);
}
}
}
} /* DetectCrucialControllers() */
@@ -0,0 +1,161 @@
/*---------------------------------------------------------*\
| Processing Code for NZXT Hue 2 |
| |
| Adam Honse ([email protected]), 12/29/2016 |
\*---------------------------------------------------------*/
#include "Hue2Controller.h"
#include <fstream>
#include <iostream>
#include <string>
Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
{
dev = dev_handle;
GetStripsOnChannel(HUE_2_CHANNEL_1);
}
Hue2Controller::~Hue2Controller()
{
current_mode = HUE_2_MODE_FIXED;
current_speed = HUE_2_SPEED_NORMAL;
current_direction = false;
}
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
{
unsigned int ret_val = 0;
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
};
int actual = 0;
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
for(int chan = 0; chan < 4; chan++)
{
unsigned int start = 0x0F + (6 * chan);
unsigned int num_leds_on_channel = 0;
for(int dev = 0; dev < 6; dev++)
{
switch(usb_buf[start + dev])
{
case 0x01: //Hue 1 strip
num_leds_on_channel += 10;
break;
case 0x02: //Aer 1 fan
num_leds_on_channel += 8;
break;
case 0x04: //Hue 2 strip
num_leds_on_channel += 10;
break;
case 0x0B: //Aer 2 fan (120mm)
num_leds_on_channel += 8;
break;
case 0x0C: //Aer 2 fan (140mm)
num_leds_on_channel += 8;
break;
default:
break;
}
}
channel_leds[chan] = num_leds_on_channel;
}
return(ret_val);
}
void Hue2Controller::SetMode(unsigned char mode, unsigned char speed, bool direction)
{
current_mode = mode;
current_speed = speed;
current_direction = direction;
}
void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char usb_buf[] =
{
0x28, 0x03, 0x00, 0x28,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
int actual = 0;
/*-----------------------------------------------------*\
| Set channel in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x02] = 1 << channel;
/*-----------------------------------------------------*\
| Set mode in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x04] = current_mode;
/*-----------------------------------------------------*\
| Set speed in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x05] = current_speed;
/*-----------------------------------------------------*\
| Set direction in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x06] = current_direction ? 0x01 : 0x00;
/*-----------------------------------------------------*\
| Set color count in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x08] = colors.size();
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < colors.size(); idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
usb_buf[pixel_idx + 0x0A] = RGBGetGValue(color);
usb_buf[pixel_idx + 0x0B] = RGBGetRValue(color);
usb_buf[pixel_idx + 0x0C] = RGBGetBValue(color);
}
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
@@ -0,0 +1,71 @@
/*---------------------------------------------------------*\
| Definitions for NZXT Hue 2 |
| |
| Adam Honse ([email protected]), 12/29/2016 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
HUE_2_CHANNEL_ALL = 0x00, /* All channels */
HUE_2_CHANNEL_1 = 0x01, /* Channel 1 */
HUE_2_CHANNEL_2 = 0x02, /* Channel 2 */
HUE_2_CHANNEL_3 = 0x03, /* Channel 3 */
HUE_2_CHANNEL_4 = 0x04, /* Channel 4 */
HUE_2_NUM_CHANNELS = 0x04 /* Number of channels */
};
enum
{
HUE_2_CHANNEL_1_IDX = 0x00, /* Channel 1 array index */
HUE_2_CHANNEL_2_IDX = 0x01, /* Channel 2 array index */
HUE_2_CHANNEL_3_IDX = 0x01, /* Channel 3 array index */
HUE_2_CHANNEL_4_IDX = 0x01, /* Channel 4 array index */
};
enum
{
HUE_2_SPEED_SLOWEST = 0x00, /* Slowest speed */
HUE_2_SPEED_SLOW = 0x01, /* Slow speed */
HUE_2_SPEED_NORMAL = 0x02, /* Normal speed */
HUE_2_SPEED_FAST = 0x03, /* Fast speed */
HUE_2_SPEED_FASTEST = 0x04, /* Fastest speed */
};
enum
{
HUE_2_MODE_FIXED = 0x00, /* Fixed colors mode */
HUE_2_MODE_FADING = 0x01, /* Fading mode */
HUE_2_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
HUE_2_MODE_MARQUEE = 0x03, /* Marquee mode */
HUE_2_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
HUE_2_MODE_ALTERNATING = 0x05, /* Alternating mode */
HUE_2_MODE_PULSING = 0x06, /* Pulsing mode */
HUE_2_MODE_BREATHING = 0x07, /* Breathing mode */
HUE_2_NUM_MODES /* Number of Hue 2 modes */
};
class Hue2Controller
{
public:
Hue2Controller(libusb_device_handle* dev_handle);
~Hue2Controller();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed, bool direction);
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
private:
libusb_device_handle* dev;
unsigned char current_mode;
unsigned char current_speed;
bool current_direction;
};
@@ -0,0 +1,53 @@
#include "Hue2Controller.h"
#include "RGBController.h"
#include "RGBController_Hue2.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define NZXT_HUE_2_VID 0x1E71
#define NZXT_HUE_2_PID 0x2001
#define NZXT_SMART_DEVICE_V2_PID 0x2006
/******************************************************************************************\
* *
* DetectHue2Controllers *
* *
* Detect devices supported by the Hue2 driver *
* * *
\******************************************************************************************/
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for NZXT Hue 2
libusb_device_handle * hue_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_HUE_2_PID);
if( hue_2_dev )
{
libusb_detach_kernel_driver(hue_2_dev, 0);
libusb_claim_interface(hue_2_dev, 0);
Hue2Controller* controller = new Hue2Controller(hue_2_dev);
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
rgb_controllers.push_back(rgb_controller);
}
//Look for NZXT Smart Device V2
libusb_device_handle * smart_dev_2_dev = libusb_open_device_with_vid_pid(ctx, NZXT_HUE_2_VID, NZXT_SMART_DEVICE_V2_PID);
if( smart_dev_2_dev )
{
libusb_detach_kernel_driver(smart_dev_2_dev, 0);
libusb_claim_interface(smart_dev_2_dev, 0);
Hue2Controller* controller = new Hue2Controller(smart_dev_2_dev);
RGBController_Hue2* rgb_controller = new RGBController_Hue2(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectHuePlusControllers() */
@@ -0,0 +1,170 @@
/*---------------------------------------------------------*\
| Processing Code for NZXT Hue+ |
| |
| Adam Honse ([email protected]), 12/11/2016 |
\*---------------------------------------------------------*/
#include "HuePlusController.h"
#include <fstream>
#include <iostream>
#include <string>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
HuePlusController::HuePlusController()
{
current_mode = HUE_PLUS_MODE_FIXED;
current_speed = HUE_PLUS_SPEED_NORMAL;
current_direction = false;
}
HuePlusController::~HuePlusController()
{
}
void HuePlusController::Initialize(char* port)
{
strcpy(port_name, port);
serialport = new serial_port(port_name, HUE_PLUS_BAUD);
channel_leds[HUE_PLUS_CHANNEL_1_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_1);
channel_leds[HUE_PLUS_CHANNEL_2_IDX] = GetLEDsOnChannel(HUE_PLUS_CHANNEL_2);
}
char* HuePlusController::GetLocation()
{
return(port_name);
}
unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
{
unsigned char serial_buf[] =
{
0x8D, 0x00, 0x00, 0x00, 0x00
};
unsigned int ret_val = 0;
/*-----------------------------------------------------*\
| Set channel in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x01] = channel;
serialport->serial_flush_rx();
serialport->serial_write((char *)serial_buf, 2);
serialport->serial_flush_tx();
Sleep(50);
int bytes_read = serialport->serial_read((char *)serial_buf, 5);
if(bytes_read == 5)
{
if(serial_buf[3] == 0x01)
{
ret_val = serial_buf[4] * 8;
}
else
{
ret_val += serial_buf[4] * 10;
}
}
return(ret_val);
}
void HuePlusController::SetMode(unsigned char mode, unsigned char speed, bool direction)
{
current_mode = mode;
current_speed = speed;
current_direction = direction;
}
void HuePlusController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char serial_buf[] =
{
0x4B, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00
};
/*-----------------------------------------------------*\
| Set channel in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Set mode in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x02] = current_mode;
/*-----------------------------------------------------*\
| Set options bitfield in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x03] = 0;
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
/*-----------------------------------------------------*\
| Set speed in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x04] = current_speed;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < colors.size(); idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
serial_buf[pixel_idx + 0x05] = RGBGetGValue(color);
serial_buf[pixel_idx + 0x06] = RGBGetRValue(color);
serial_buf[pixel_idx + 0x07] = RGBGetBValue(color);
}
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
serialport->serial_flush_tx();
Sleep(10);
}
@@ -0,0 +1,90 @@
/*---------------------------------------------------------*\
| Definitions for NZXT Hue+ |
| |
| Adam Honse ([email protected]), 12/11/2016 |
\*---------------------------------------------------------*/
#ifndef LED_STRIP_H
#define LED_STRIP_H
#include "RGBController.h"
#include "serial_port.h"
#include <vector>
#ifndef TRUE
#define TRUE true
#define FALSE false
#endif
#ifndef WIN32
#define LPSTR char *
#define strtok_s strtok_r
#endif
#define HUE_PLUS_BAUD 256000
#define HUE_PLUS_PACKET_SIZE 125
enum
{
HUE_PLUS_CHANNEL_BOTH = 0x00, /* Both channels */
HUE_PLUS_CHANNEL_1 = 0x01, /* Channel 1 */
HUE_PLUS_CHANNEL_2 = 0x02, /* Channel 2 */
HUE_PLUS_NUM_CHANNELS = 0x02 /* Number of channels */
};
enum
{
HUE_PLUS_CHANNEL_1_IDX = 0x00, /* Channel 1 array index */
HUE_PLUS_CHANNEL_2_IDX = 0x01, /* Channel 2 array index */
};
enum
{
HUE_PLUS_SPEED_SLOWEST = 0x00, /* Slowest speed */
HUE_PLUS_SPEED_SLOW = 0x01, /* Slow speed */
HUE_PLUS_SPEED_NORMAL = 0x02, /* Normal speed */
HUE_PLUS_SPEED_FAST = 0x03, /* Fast speed */
HUE_PLUS_SPEED_FASTEST = 0x04, /* Fastest speed */
};
enum
{
HUE_PLUS_MODE_FIXED = 0x00, /* Fixed colors mode */
HUE_PLUS_MODE_FADING = 0x01, /* Fading mode */
HUE_PLUS_MODE_SPECTRUM = 0x02, /* Spectrum cycle mode */
HUE_PLUS_MODE_MARQUEE = 0x03, /* Marquee mode */
HUE_PLUS_MODE_COVER_MARQUEE = 0x04, /* Cover marquee mode */
HUE_PLUS_MODE_ALTERNATING = 0x05, /* Alternating mode */
HUE_PLUS_MODE_PULSING = 0x06, /* Pulsing mode */
HUE_PLUS_MODE_BREATHING = 0x07, /* Breathing mode */
HUE_PLUS_MODE_ALERT = 0x08, /* Alert mode */
HUE_PLUS_MODE_CANDLELIGHT = 0x09, /* Candlelight mode */
HUE_PLUS_MODE_WINGS = 0x0C, /* Wings mode */
HUE_PLUS_MODE_WAVE = 0x0D, /* Wave mode */
};
class HuePlusController
{
public:
HuePlusController();
~HuePlusController();
void Initialize(char* port);
char* GetLocation();
unsigned int GetLEDsOnChannel(unsigned int channel);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed, bool direction);
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
private:
char port_name[128];
serial_port *serialport;
unsigned char current_mode;
unsigned char current_speed;
bool current_direction;
};
#endif
@@ -0,0 +1,32 @@
#include "HuePlusController.h"
#include "RGBController.h"
#include "RGBController_HuePlus.h"
#include "find_usb_serial_port.h"
#include <vector>
#define NZXT_HUE_PLUS_VID 0x04D8
#define NZXT_HUE_PLUS_PID 0x00DF
/******************************************************************************************\
* *
* DetectHuePlusControllers *
* *
* Detect devices supported by the HuePlus driver *
* *
\******************************************************************************************/
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
{
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());
new_controller = new RGBController_HuePlus(new_hueplus);
rgb_controllers.push_back(new_controller);
}
} /* DetectHuePlusControllers() */
@@ -0,0 +1,287 @@
/*-----------------------------------------*\
| HyperXController.cpp |
| |
| Definitions and types for HyperX Predator|
| RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
#include "HyperXController.h"
#include <cstring>
HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots)
{
this->bus = bus;
this->dev = dev;
slots_valid = slots;
strcpy(device_name, "HyperX Predator RGB");
led_count = 0;
for(int i = 0; i < 8; i++)
{
if((slots_valid & (1 << i)) != 0)
{
led_count += 5;
}
}
mode = HYPERX_MODE_DIRECT;
}
HyperXController::~HyperXController()
{
}
std::string HyperXController::GetDeviceName()
{
return(device_name);
}
std::string HyperXController::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 int HyperXController::GetLEDCount()
{
return(led_count);
}
unsigned int HyperXController::GetSlotCount()
{
unsigned int slot_count = 0;
for(int slot = 0; slot < 4; slot++)
{
if((slots_valid & (1 << slot)) != 0)
{
slot_count++;
}
}
return(slot_count);
}
unsigned int HyperXController::GetMode()
{
return(mode);
}
void HyperXController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_RED, red );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_GREEN, green);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_BLUE, blue );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_EFFECT_BRIGHTNESS, 0x64 );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
/*-----------------------------------------------------*\
| Loop through all slots and only set those which are |
| active. |
\*-----------------------------------------------------*/
for(int slot = 0; slot < 4; slot++)
{
if((slots_valid & (1 << slot)) != 0)
{
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
unsigned char green_base = base + 0x01;
unsigned char blue_base = base + 0x02;
unsigned char bright_base = base + 0x10;
if(mode == HYPERX_MODE_DIRECT)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
}
for(int led = 0; led < 5; led++)
{
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
}
}
}
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| led_slot - the unmapped slot ID for the given LED |
| led - the LED ID within that slot |
| slot_id - counts enabled slots |
| slot - the mapped slot ID for the given LED |
\*-----------------------------------------------------*/
int led_slot = led / 5;
int slot_id = -1;
int slot;
led -= (led_slot * 5);
/*-----------------------------------------------------*\
| Loop through all possible slots and only count those |
| which are active. |
\*-----------------------------------------------------*/
for(slot = 0; slot < 4; slot++)
{
if((slots_valid & ( 1 << slot)) != 0)
{
slot_id++;
}
if(slot_id == led_slot)
{
break;
}
}
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
unsigned char green_base = base + 0x01;
unsigned char blue_base = base + 0x02;
unsigned char bright_base = base + 0x10;
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
unsigned char green_base = base + 0x01;
unsigned char blue_base = base + 0x02;
unsigned char bright_base = base + 0x10;
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
{
mode = new_mode;
speed = new_speed;
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
/*-----------------------------------------------------*\
| Determine which mode register to use. |
| If set to random color mode, use Mode1. |
| If set to fixed color mode, use Mode2. |
\*-----------------------------------------------------*/
unsigned char mode_reg;
if(random)
{
mode_reg = HYPERX_REG_MODE_RANDOM;
}
else
{
mode_reg = HYPERX_REG_MODE_CUSTOM;
}
switch (mode)
{
case HYPERX_MODE_DIRECT:
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_INDEPENDENT, HYPERX_MODE3_DIRECT);
break;
case HYPERX_MODE_STATIC:
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_CUSTOM, HYPERX_MODE2_STATIC);
break;
case HYPERX_MODE_RAINBOW:
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_RAINBOW);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
break;
case HYPERX_MODE_COMET:
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_COMET);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
break;
case HYPERX_MODE_HEARTBEAT:
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_HEARTBEAT);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_MSB, 0x03);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_DELAY_TIME_LSB, 0xE8);
break;
case HYPERX_MODE_CYCLE:
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE_RANDOM, HYPERX_MODE1_CYCLE);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_CHANGE_TIME_LSB, speed & 0xFF);
break;
case HYPERX_MODE_BREATHING:
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BREATHING);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_IN_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_FADE_OUT_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, 0x00);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, 0x00);
break;
case HYPERX_MODE_BOUNCE:
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BOUNCE);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_TIMER_LSB, speed & 0xFF);
break;
case HYPERX_MODE_BLINK:
bus->i2c_smbus_write_byte_data(dev, mode_reg, HYPERX_MODE2_BLINK);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_MSB, speed >> 8);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_OFF_TIME_LSB, speed & 0xFF);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_MSB, 0x07);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_ON_TIME_LSB, 0xD4);
break;
}
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
@@ -0,0 +1,222 @@
/*-----------------------------------------*\
| HyperXController.h |
| |
| Definitions and types for HyperX Predator|
| RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char hyperx_dev_id;
typedef unsigned short hyperx_register;
enum
{
HYPERX_REG_SLOT0_LED0_RED = 0x11, /* R color register for LED 0, Slot 0 */
HYPERX_REG_SLOT0_LED0_GREEN = 0x12, /* G color register for LED 0, Slot 0 */
HYPERX_REG_SLOT0_LED0_BLUE = 0x13, /* B color register for LED 0, Slot 0 */
HYPERX_REG_SLOT0_LED1_RED = 0x14, /* R color register for LED 1, Slot 0 */
HYPERX_REG_SLOT0_LED1_GREEN = 0x15, /* G color register for LED 1, Slot 0 */
HYPERX_REG_SLOT0_LED1_BLUE = 0x16, /* B color register for LED 1, Slot 0 */
HYPERX_REG_SLOT0_LED2_RED = 0x17, /* R color register for LED 2, Slot 0 */
HYPERX_REG_SLOT0_LED2_GREEN = 0x18, /* G color register for LED 2, Slot 0 */
HYPERX_REG_SLOT0_LED2_BLUE = 0x19, /* B color register for LED 2, Slot 0 */
HYPERX_REG_SLOT0_LED3_RED = 0x1A, /* R color register for LED 3, Slot 0 */
HYPERX_REG_SLOT0_LED3_GREEN = 0x1B, /* G color register for LED 3, Slot 0 */
HYPERX_REG_SLOT0_LED3_BLUE = 0x1C, /* B color register for LED 3, Slot 0 */
HYPERX_REG_SLOT0_LED4_RED = 0x1D, /* R color register for LED 4, Slot 0 */
HYPERX_REG_SLOT0_LED4_GREEN = 0x1E, /* G color register for LED 4, Slot 0 */
HYPERX_REG_SLOT0_LED4_BLUE = 0x1F, /* B color register for LED 4, Slot 0 */
HYPERX_REG_SLOT0_LED0_BRIGHTNESS = 0x21, /* Brightness for LED 0, Slot 0 (0-100) */
HYPERX_REG_SLOT0_LED1_BRIGHTNESS = 0x24, /* Brightness for LED 1, Slot 0 (0-100) */
HYPERX_REG_SLOT0_LED2_BRIGHTNESS = 0x27, /* Brightness for LED 2, Slot 0 (0-100) */
HYPERX_REG_SLOT0_LED3_BRIGHTNESS = 0x2A, /* Brightness for LED 3, Slot 0 (0-100) */
HYPERX_REG_SLOT0_LED4_BRIGHTNESS = 0x2D, /* Brightness for LED 4, Slot 0 (0-100) */
HYPERX_REG_SLOT1_LED0_RED = 0x41, /* R color register for LED 0, Slot 1 */
HYPERX_REG_SLOT1_LED0_GREEN = 0x42, /* G color register for LED 0, Slot 1 */
HYPERX_REG_SLOT1_LED0_BLUE = 0x43, /* B color register for LED 0, Slot 1 */
HYPERX_REG_SLOT1_LED1_RED = 0x44, /* R color register for LED 1, Slot 1 */
HYPERX_REG_SLOT1_LED1_GREEN = 0x45, /* G color register for LED 1, Slot 1 */
HYPERX_REG_SLOT1_LED1_BLUE = 0x46, /* B color register for LED 1, Slot 1 */
HYPERX_REG_SLOT1_LED2_RED = 0x47, /* R color register for LED 2, Slot 1 */
HYPERX_REG_SLOT1_LED2_GREEN = 0x48, /* G color register for LED 2, Slot 1 */
HYPERX_REG_SLOT1_LED2_BLUE = 0x49, /* B color register for LED 2, Slot 1 */
HYPERX_REG_SLOT1_LED3_RED = 0x4A, /* R color register for LED 3, Slot 1 */
HYPERX_REG_SLOT1_LED3_GREEN = 0x4B, /* G color register for LED 3, Slot 1 */
HYPERX_REG_SLOT1_LED3_BLUE = 0x4C, /* B color register for LED 3, Slot 1 */
HYPERX_REG_SLOT1_LED4_RED = 0x4D, /* R color register for LED 4, Slot 1 */
HYPERX_REG_SLOT1_LED4_GREEN = 0x4E, /* G color register for LED 4, Slot 1 */
HYPERX_REG_SLOT1_LED4_BLUE = 0x4F, /* B color register for LED 4, Slot 1 */
HYPERX_REG_SLOT1_LED0_BRIGHTNESS = 0x51, /* Brightness for LED 0, Slot 1 (0-100) */
HYPERX_REG_SLOT1_LED1_BRIGHTNESS = 0x54, /* Brightness for LED 1, Slot 1 (0-100) */
HYPERX_REG_SLOT1_LED2_BRIGHTNESS = 0x57, /* Brightness for LED 2, Slot 1 (0-100) */
HYPERX_REG_SLOT1_LED3_BRIGHTNESS = 0x5A, /* Brightness for LED 3, Slot 1 (0-100) */
HYPERX_REG_SLOT1_LED4_BRIGHTNESS = 0x5D, /* Brightness for LED 4, Slot 1 (0-100) */
HYPERX_REG_SLOT2_LED0_RED = 0x71, /* R color register for LED 0, Slot 2 */
HYPERX_REG_SLOT2_LED0_GREEN = 0x72, /* G color register for LED 0, Slot 2 */
HYPERX_REG_SLOT2_LED0_BLUE = 0x73, /* B color register for LED 0, Slot 2 */
HYPERX_REG_SLOT2_LED1_RED = 0x74, /* R color register for LED 1, Slot 2 */
HYPERX_REG_SLOT2_LED1_GREEN = 0x75, /* G color register for LED 1, Slot 2 */
HYPERX_REG_SLOT2_LED1_BLUE = 0x76, /* B color register for LED 1, Slot 2 */
HYPERX_REG_SLOT2_LED2_RED = 0x77, /* R color register for LED 2, Slot 2 */
HYPERX_REG_SLOT2_LED2_GREEN = 0x78, /* G color register for LED 2, Slot 2 */
HYPERX_REG_SLOT2_LED2_BLUE = 0x79, /* B color register for LED 2, Slot 2 */
HYPERX_REG_SLOT2_LED3_RED = 0x7A, /* R color register for LED 3, Slot 2 */
HYPERX_REG_SLOT2_LED3_GREEN = 0x7B, /* G color register for LED 3, Slot 2 */
HYPERX_REG_SLOT2_LED3_BLUE = 0x7C, /* B color register for LED 3, Slot 2 */
HYPERX_REG_SLOT2_LED4_RED = 0x7D, /* R color register for LED 4, Slot 2 */
HYPERX_REG_SLOT2_LED4_GREEN = 0x7E, /* G color register for LED 4, Slot 2 */
HYPERX_REG_SLOT2_LED4_BLUE = 0x7F, /* B color register for LED 4, Slot 2 */
HYPERX_REG_SLOT2_LED0_BRIGHTNESS = 0x81, /* Brightness for LED 0, Slot 2 (0-100) */
HYPERX_REG_SLOT2_LED1_BRIGHTNESS = 0x84, /* Brightness for LED 1, Slot 2 (0-100) */
HYPERX_REG_SLOT2_LED2_BRIGHTNESS = 0x87, /* Brightness for LED 2, Slot 2 (0-100) */
HYPERX_REG_SLOT2_LED3_BRIGHTNESS = 0x8A, /* Brightness for LED 3, Slot 2 (0-100) */
HYPERX_REG_SLOT2_LED4_BRIGHTNESS = 0x8D, /* Brightness for LED 4, Slot 2 (0-100) */
HYPERX_REG_SLOT3_LED0_RED = 0xA1, /* R color register for LED 0, Slot 3 */
HYPERX_REG_SLOT3_LED0_GREEN = 0xA2, /* G color register for LED 0, Slot 3 */
HYPERX_REG_SLOT3_LED0_BLUE = 0xA3, /* B color register for LED 0, Slot 3 */
HYPERX_REG_SLOT3_LED1_RED = 0xA4, /* R color register for LED 1, Slot 3 */
HYPERX_REG_SLOT3_LED1_GREEN = 0xA5, /* G color register for LED 1, Slot 3 */
HYPERX_REG_SLOT3_LED1_BLUE = 0xA6, /* B color register for LED 1, Slot 3 */
HYPERX_REG_SLOT3_LED2_RED = 0xA7, /* R color register for LED 2, Slot 3 */
HYPERX_REG_SLOT3_LED2_GREEN = 0xA8, /* G color register for LED 2, Slot 3 */
HYPERX_REG_SLOT3_LED2_BLUE = 0xA9, /* B color register for LED 2, Slot 3 */
HYPERX_REG_SLOT3_LED3_RED = 0xAA, /* R color register for LED 3, Slot 3 */
HYPERX_REG_SLOT3_LED3_GREEN = 0xAB, /* G color register for LED 3, Slot 3 */
HYPERX_REG_SLOT3_LED3_BLUE = 0xAC, /* B color register for LED 3, Slot 3 */
HYPERX_REG_SLOT3_LED4_RED = 0xAD, /* R color register for LED 4, Slot 3 */
HYPERX_REG_SLOT3_LED4_GREEN = 0xAE, /* G color register for LED 4, Slot 3 */
HYPERX_REG_SLOT3_LED4_BLUE = 0xAF, /* B color register for LED 4, Slot 3 */
HYPERX_REG_SLOT3_LED0_BRIGHTNESS = 0xB1, /* Brightness for LED 0, Slot 3 (0-100) */
HYPERX_REG_SLOT3_LED1_BRIGHTNESS = 0xB4, /* Brightness for LED 1, Slot 3 (0-100) */
HYPERX_REG_SLOT3_LED2_BRIGHTNESS = 0xB7, /* Brightness for LED 2, Slot 3 (0-100) */
HYPERX_REG_SLOT3_LED3_BRIGHTNESS = 0xBA, /* Brightness for LED 3, Slot 3 (0-100) */
HYPERX_REG_SLOT3_LED4_BRIGHTNESS = 0xBD, /* Brightness for LED 4, Slot 3 (0-100) */
HYPERX_REG_TIMER_MSB = 0xD1, /* Timer MSB */
HYPERX_REG_TIMER_LSB = 0xD2, /* Timer LSB */
HYPERX_REG_ON_TIME_MSB = 0xD3, /* Effect on time MSB */
HYPERX_REG_ON_TIME_LSB = 0xD4, /* Effect on time LSB */
HYPERX_REG_CHANGE_TIME_MSB = 0xD5, /* Change time MSB */
HYPERX_REG_CHANGE_TIME_LSB = 0xD6, /* Change time LSB */
HYPERX_REG_FADE_IN_TIME_MSB = 0xD7, /* Fade in time MSB */
HYPERX_REG_FADE_IN_TIME_LSB = 0xD8, /* Fade in time LSB */
HYPERX_REG_FADE_OUT_TIME_MSB = 0xD9, /* Fade out time MSB */
HYPERX_REG_FADE_OUT_TIME_LSB = 0xDA, /* Fade out time LSB */
HYPERX_REG_OFF_TIME_MSB = 0xDB, /* Effect off time MSB */
HYPERX_REG_OFF_TIME_LSB = 0xDC, /* Effect off time LSB */
HYPERX_REG_EFFECT_BRIGHTNESS = 0xDD, /* Brightness for effects (0-100) */
HYPERX_REG_APPLY = 0xE1, /* Apply changes register */
HYPERX_REG_MODE_RANDOM = 0xE3, /* Mode control register, random colors */
HYPERX_REG_MODE_CUSTOM = 0xE4, /* Mode control register, custom colors */
HYPERX_REG_MODE_INDEPENDENT = 0xE5, /* Mode control register, independent */
HYPERX_REG_DELAY_TIME_MSB = 0xEA, /* Delay time MSB */
HYPERX_REG_DELAY_TIME_LSB = 0xEB, /* Delay time LSB */
HYPERX_REG_EFFECT_RED = 0xEC, /* Red color register for effects */
HYPERX_REG_EFFECT_GREEN = 0xED, /* Green color register for effects */
HYPERX_REG_EFFECT_BLUE = 0xEE, /* Blue color register for effects */
};
enum
{
HYPERX_MODE1_RAINBOW = 0x05, /* Mode 1 rainbow effect */
HYPERX_MODE1_CYCLE = 0x04, /* Mode 1 cycle effect */
};
enum
{
HYPERX_MODE2_BOUNCE = 0x02, /* Mode 2 bounce effect */
HYPERX_MODE2_BREATHING = 0x03, /* Mode 2 breathing effect */
HYPERX_MODE2_BLINK = 0x06, /* Mode 2 blink effect */
HYPERX_MODE2_HEARTBEAT = 0x07, /* Mode 2 heartbeat effect */
HYPERX_MODE2_COMET = 0x08, /* Mode 2 comet effect */
HYPERX_MODE2_STATIC = 0x09, /* Mode 2 static effect */
};
enum
{
HYPERX_MODE3_DIRECT = 0x21, /* Mode 3 direct control */
};
enum
{
HYPERX_MODE_DIRECT = 0, /* Direct control mode */
HYPERX_MODE_STATIC = 1, /* Static color mode */
HYPERX_MODE_RAINBOW = 2, /* Rainbow wave mode */
HYPERX_MODE_COMET = 3, /* Comet (chase) mode */
HYPERX_MODE_HEARTBEAT = 4, /* Heartbeat (pulsing) mode */
HYPERX_MODE_CYCLE = 5, /* Spectrum cycle mode */
HYPERX_MODE_BREATHING = 6, /* Breathing mode */
HYPERX_MODE_BOUNCE = 7, /* Bounce mode */
HYPERX_MODE_BLINK = 8, /* Blinking mode */
HYPERX_NUMBER_MODES /* Number of HyperX modes */
};
enum
{
HYPERX_SPEED_BOUNCE_SLOW = 0x07D0, /* Slowest speed for bounce mode */
HYPERX_SPEED_BOUNCE_NORMAL = 0x07D0, /* Normal speed for bounce mode */
HYPERX_SPEED_BOUNCE_FAST = 0x0064, /* Fastest speed for bounce mode */
HYPERX_SPEED_BREATHING_SLOW = 0x07D0, /* Slowest speed for breathing mode */
HYPERX_SPEED_BREATHING_NORMAL = 0x07D0, /* Normal speed for breathing mode */
HYPERX_SPEED_BREATHING_FAST = 0x0064, /* Fastest speed for breathing mode */
HYPERX_SPEED_CYCLE_SLOW = 0x05DC, /* Slowest speed for cycle mode */
HYPERX_SPEED_CYCLE_NORMAL = 0x05DC, /* Normal speed for cycle mode */
HYPERX_SPEED_CYCLE_FAST = 0x00FA, /* Fastest speed for cycle mode */
HYPERX_SPEED_RAINBOW_SLOW = 0x07D0, /* Slowest speed for rainbow mode */
HYPERX_SPEED_RAINBOW_NORMAL = 0x07D0, /* Normal speed for rainbow mode */
HYPERX_SPEED_RAINBOW_FAST = 0x0064, /* Fastest speed for rainbow mode */
HYPERX_SPEED_BLINK_SLOW = 0x07D0, /* Slowest speed for blink mode */
HYPERX_SPEED_BLINK_NORMAL = 0x07D0, /* Normal speed for blink mode */
HYPERX_SPEED_BLINK_FAST = 0x01F4, /* Fastest speed for blink mode */
HYPERX_SPEED_HEARTBEAT_SLOW = 0x07D0, /* Slowest speed for heartbeat mode */
HYPERX_SPEED_HEARTBEAT_NORMAL = 0x07D0, /* Normal speed for heartbeat mode */
HYPERX_SPEED_HEARTBEAT_FAST = 0x01F4, /* Fastest speed for heartbeat mode */
HYPERX_SPEED_COMET_SLOW = 0x07D0, /* Slowest speed for comet mode */
HYPERX_SPEED_COMET_NORMAL = 0x07D0, /* Normal speed for comet mode */
HYPERX_SPEED_COMET_FAST = 0x0064, /* Fastest speed for comet mode */
};
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_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
};
class HyperXController
{
public:
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots);
~HyperXController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned int GetSlotCount();
unsigned int GetMode();
void SetMode(unsigned char new_mode, bool random, unsigned short new_speed);
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
unsigned int led_count;
unsigned char slots_valid;
i2c_smbus_interface* bus;
hyperx_dev_id dev;
unsigned int mode;
unsigned short speed;
};
@@ -0,0 +1,104 @@
#include "HyperXController.h"
#include "RGBController.h"
#include "RGBController_HyperX.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/******************************************************************************************\
* *
* TestForHyperXController *
* *
* Tests the given address to see if a HyperX controller exists there. *
* *
\******************************************************************************************/
bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
for (int i = 0xA0; i < 0xB0; i++)
{
res = bus->i2c_smbus_read_byte_data(address, i);
if (res != i)
{
pass = false;
}
}
}
return(pass);
} /* TestForHyperXController() */
/******************************************************************************************\
* *
* DetectHyperXControllers *
* *
* Detect HyperX controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
HyperXController* new_hyperx;
RGBController_HyperX* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
unsigned char slots_valid = 0x00;
// Check for HyperX controller at 0x27
if (TestForHyperXController(busses[bus], 0x27))
{
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
Sleep(1);
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
{
// Test for HyperX SPD at slot_addr
// This test was copied from NGENUITY software
// Tests SPD addresses in order: 0x40, 0x41
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x01)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x98))
{
slots_valid |= (1 << (slot_addr - 0x50));
}
Sleep(1);
}
if(slots_valid != 0)
{
new_hyperx = new HyperXController(busses[bus], 0x27, slots_valid);
new_controller = new RGBController_HyperX(new_hyperx);
rgb_controllers.push_back(new_controller);
}
}
}
} /* DetectHyperXControllers() */
@@ -0,0 +1,414 @@
/*-----------------------------------------*\
| HyperXKeyboardController.cpp |
| |
| Driver for HyperX RGB Keyboard lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 1/30/2020 |
\*-----------------------------------------*/
#include "HyperXKeyboardController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x20, 0x21, 0x22, 0x23, 0x24,
0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
0x33, 0x34, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x41, 0x44, 0x45,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x51, 0x54, 0x55, 0x58, 0x59,
0x5A, 0x5B, 0x5C, 0x5E, 0x5F, 0x61, 0x64, 0x65, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
0x6E, 0x6F, 0x74, 0x75, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x81,
0x84, 0x85, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91, 0x94, 0x95 };
static unsigned int extended_red[] = {0x08, 0x48, 0x88, 0x09, 0x89, 0x0A, 0x8A, 0x0B, 0x8B, 0x0C, 0x8C, 0x0D, 0x8D, 0x0E, 0x8F, 0x8E, 0x0F, 0x4F, 0x92, 0x13, 0x93, 0x12 };
static unsigned int extended_grn[] = {0x29, 0x28, 0x78, 0x19, 0x79, 0x1A, 0x7A, 0x1B, 0x7B, 0x1C, 0x7C, 0x1D, 0x7D, 0x1E, 0x6E, 0x7E, 0x1F, 0x6F, 0x82, 0x23, 0x83, 0x22 };
static unsigned int extended_blu[] = {0x39, 0x38, 0x68, 0x3A, 0x69, 0x2A, 0x6A, 0x2B, 0x6B, 0x2C, 0x6C, 0x2D, 0x6D, 0x2E, 0x5E, 0x5D, 0x2F, 0x5F, 0x72, 0x33, 0x73, 0x32 };
HyperXKeyboardController::HyperXKeyboardController(hid_device* dev_handle)
{
dev = dev_handle;
}
HyperXKeyboardController::~HyperXKeyboardController()
{
}
void HyperXKeyboardController::SetMode(unsigned char mode, unsigned char direction, unsigned char speed)
{
active_mode = mode;
active_direction = direction;
active_speed = speed;
SendEffect
(
0x01,
active_mode,
active_direction,
HYPERX_REACTIVE_MODE_NONE,
active_speed,
HYPERX_COLOR_MODE_SPECTRUM
);
}
void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char red_color_data[104];
unsigned char grn_color_data[104];
unsigned char blu_color_data[104];
unsigned char ext_color_data[150];
for(std::size_t i = 0; i < 104; i++)
{
red_color_data[i] = RGBGetRValue(colors[i]);
grn_color_data[i] = RGBGetGValue(colors[i]);
blu_color_data[i] = RGBGetBValue(colors[i]);
}
for(std::size_t i = 0; i < 22; i++)
{
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
}
SendDirect
(
HYPERX_COLOR_CHANNEL_RED,
red_color_data
);
Sleep(2);
SendDirect
(
HYPERX_COLOR_CHANNEL_GREEN,
grn_color_data
);
Sleep(2);
SendDirect
(
HYPERX_COLOR_CHANNEL_BLUE,
blu_color_data
);
Sleep(2);
SendDirectExtended
(
ext_color_data
);
}
void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char red_color_data[104];
unsigned char grn_color_data[104];
unsigned char blu_color_data[104];
unsigned char ext_color_data[150];
for(std::size_t i = 0; i < 104; i++)
{
red_color_data[i] = RGBGetRValue(colors[i]);
grn_color_data[i] = RGBGetGValue(colors[i]);
blu_color_data[i] = RGBGetBValue(colors[i]);
}
for(std::size_t i = 0; i < 22; i++)
{
ext_color_data[extended_red[i]] = RGBGetRValue(colors[i + 104]);
ext_color_data[extended_grn[i]] = RGBGetGValue(colors[i + 104]);
ext_color_data[extended_blu[i]] = RGBGetBValue(colors[i + 104]);
}
SendColor
(
0x01,
HYPERX_COLOR_CHANNEL_RED,
red_color_data
);
SendColor
(
0x01,
HYPERX_COLOR_CHANNEL_GREEN,
grn_color_data
);
SendColor
(
0x01,
HYPERX_COLOR_CHANNEL_BLUE,
blu_color_data
);
SendExtendedColor
(
0x01,
ext_color_data
);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HyperXKeyboardController::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] = 0x01;
buf[0x02] = profile;
buf[0x06] = 0x03;
buf[0x07] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXKeyboardController::SendEffect
(
unsigned char profile,
unsigned char mode,
unsigned char direction,
unsigned char reactive_mode,
unsigned char speed,
unsigned char color_mode
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Effect packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_SET_EFFECT;
buf[0x02] = profile;
/*-----------------------------------------------------*\
| Set mode |
\*-----------------------------------------------------*/
buf[0x09] = 0x01;
buf[0x0A] = mode;
/*-----------------------------------------------------*\
| Set direction |
\*-----------------------------------------------------*/
buf[0x0D] = direction;
buf[0x0E] = direction;
/*-----------------------------------------------------*\
| Set reactive mode |
\*-----------------------------------------------------*/
buf[0x1B] = reactive_mode;
buf[0x1C] = reactive_mode;
buf[0x1D] = reactive_mode;
buf[0x1E] = reactive_mode;
buf[0x1F] = reactive_mode;
buf[0x20] = reactive_mode;
buf[0x21] = reactive_mode;
buf[0x22] = reactive_mode;
buf[0x6B] = 0x09;
buf[0x6C] = 0x09;
buf[0x6D] = 0x05;
buf[0x6E] = 0x05;
buf[0x6F] = 0x06;
buf[0x70] = 0x05;
/*-----------------------------------------------------*\
| Set speed |
\*-----------------------------------------------------*/
buf[0x71] = speed;
buf[0x72] = 0x09;
/*-----------------------------------------------------*\
| Set color mode |
\*-----------------------------------------------------*/
buf[0x73] = color_mode;
buf[0x74] = color_mode;
buf[0x75] = color_mode;
buf[0x76] = color_mode;
buf[0x77] = color_mode;
buf[0x78] = color_mode;
buf[0x79] = color_mode;
buf[0x7A] = color_mode;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXKeyboardController::SendColor
(
unsigned char profile,
unsigned char color_channel,
unsigned char* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Color packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
buf[0x02] = profile;
buf[0x03] = color_channel;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = color_data[i];
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXKeyboardController::SendExtendedColor
(
unsigned char profile,
unsigned char* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Color packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_SET_COLOR;
buf[0x02] = profile;
buf[0x03] = HYPERX_COLOR_CHANNEL_EXTENDED;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0x08; i <= 0x93; i++)
{
buf[i] = color_data[i];
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXKeyboardController::SendDirect
(
unsigned char color_channel,
unsigned char* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = color_channel;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = color_data[i];
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void HyperXKeyboardController::SendDirectExtended
(
unsigned char* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = HYPERX_PACKET_ID_DIRECT;
buf[0x02] = HYPERX_COLOR_CHANNEL_EXTENDED;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0x08; i <= 0x93; i++)
{
buf[i] = color_data[i];
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
@@ -0,0 +1,119 @@
/*-----------------------------------------*\
| HyperXKeyboardController.h |
| |
| Definitions and types for HyperX RGB |
| Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/30/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
HYPERX_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
HYPERX_PACKET_ID_SET_COLOR = 0x06, /* Set profile color packet */
HYPERX_PACKET_ID_DIRECT = 0x16, /* Direct control packet */
};
enum
{
HYPERX_DIRECTION_RIGHT = 0x00,
HYPERX_DIRECTION_LEFT = 0x01,
HYPERX_DIRECTION_UP = 0x02,
HYPERX_DIRECTION_DOWN = 0x03,
HYPERX_DIRECTION_IN = 0x04,
HYPERX_DIRECTION_OUT = 0x05
};
enum
{
HYPERX_MODE_WAVE = 0x00,
HYPERX_MODE_STATIC = 0x01,
HYPERX_MODE_BREATHING = 0x02,
};
enum
{
HYPERX_REACTIVE_MODE_TRIGGER = 0x03,
HYPERX_REACTIVE_MODE_EXPLOSION = 0x04,
HYPERX_REACTIVE_MODE_HYPERX_FLAME = 0x05,
HYPERX_REACTIVE_MODE_NONE = 0xFF
};
enum
{
HYPERX_COLOR_MODE_SINGLE = 0x00,
HYPERX_COLOR_MODE_DUAL = 0x01,
HYPERX_COLOR_MODE_SPECTRUM = 0x02
};
enum
{
HYPERX_COLOR_CHANNEL_RED = 0x01,
HYPERX_COLOR_CHANNEL_GREEN = 0x02,
HYPERX_COLOR_CHANNEL_BLUE = 0x03,
HYPERX_COLOR_CHANNEL_EXTENDED = 0x04
};
class HyperXKeyboardController
{
public:
HyperXKeyboardController(hid_device* dev_handle);
~HyperXKeyboardController();
void SetMode(unsigned char mode, unsigned char direction, unsigned char speed);
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetLEDs(std::vector<RGBColor> colors);
private:
hid_device* dev;
unsigned char active_mode;
unsigned char active_direction;
unsigned char active_speed;
void SelectProfile
(
unsigned char profile
);
void SendEffect
(
unsigned char profile,
unsigned char mode,
unsigned char direction,
unsigned char reactive_mode,
unsigned char speed,
unsigned char color_mode
);
void SendColor
(
unsigned char profile,
unsigned char color_channel,
unsigned char* color_data
);
void SendExtendedColor
(
unsigned char profile,
unsigned char* color_data
);
void SendDirect
(
unsigned char color_channel,
unsigned char* color_data
);
void SendDirectExtended
(
unsigned char* color_data
);
};
@@ -0,0 +1,51 @@
#include "HyperXKeyboardController.h"
#include "RGBController.h"
#include "RGBController_HyperXKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
#define HYPERX_KEYBOARD_VID 0x0951
#define HYPERX_ALLOY_ELITE_PID 0x16BE
/******************************************************************************************\
* *
* DetectHyperXKeyboardControllers *
* *
* Tests the USB address to see if a HyperX Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
info = hid_enumerate(HYPERX_KEYBOARD_VID, HYPERX_ALLOY_ELITE_PID);
//Look for HyperX Keyboard, Interface 2
while(info)
{
if((info->vendor_id == HYPERX_KEYBOARD_VID)
&&(info->product_id == HYPERX_ALLOY_ELITE_PID)
&&(info->interface_number == 2))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
HyperXKeyboardController* controller = new HyperXKeyboardController(dev);
RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -0,0 +1,147 @@
/*---------------------------------------------------------*\
| Processing Code for Generic LED Strip Interface |
| |
| Adam Honse ([email protected]), 12/11/2016 |
\*---------------------------------------------------------*/
#include "LEDStripController.h"
#include <fstream>
#include <iostream>
#include <string>
LEDStripController::LEDStripController()
{
}
LEDStripController::~LEDStripController()
{
}
void LEDStripController::Initialize(char* ledstring)
{
LPSTR numleds = NULL;
LPSTR source = NULL;
LPSTR udpport_baud = NULL;
LPSTR next = NULL;
//Assume serial device unless a different protocol is specified
bool serial = TRUE;
source = strtok_s(ledstring, ",", &next);
//Check if we are setting up a Keyboard Visualizer UDP protocol device
if (strncmp(source, "udp:", 4) == 0)
{
source = source + 4;
serial = FALSE;
}
//Check for either the UDP port or the serial baud rate
if (strlen(next))
{
udpport_baud = strtok_s(next, ",", &next);
}
//Check for the number of LEDs
if (strlen(next))
{
numleds = strtok_s(next, ",", &next);
}
if (serial)
{
if (udpport_baud == NULL)
{
//Initialize with default baud rate
InitializeSerial(source, 115200);
}
else
{
//Initialize with custom baud rate
InitializeSerial(source, atoi(udpport_baud));
}
}
else
{
if (udpport_baud == NULL)
{
//Do something
}
else
{
//Initialize UDP port
InitializeUDP(source, udpport_baud);
}
}
if (numleds != NULL && strlen(numleds))
{
num_leds = atoi(numleds);
}
}
void LEDStripController::InitializeSerial(char* portname, int baud)
{
portname = strtok(portname, "\r");
strcpy(port_name, portname);
baud_rate = baud;
serialport = new serial_port(port_name, baud_rate);
udpport = NULL;
}
void LEDStripController::InitializeUDP(char * clientname, char * port)
{
strcpy(client_name, clientname);
strcpy(port_name, port);
udpport = new net_port(client_name, port_name);
serialport = NULL;
}
char* LEDStripController::GetLEDString()
{
return(led_string);
}
void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char *serial_buf;
serial_buf = new unsigned char[(num_leds * 3) + 3];
serial_buf[0] = 0xAA;
for (int idx = 0; idx < (num_leds * 3); idx += 3)
{
int pixel_idx = idx / 3;
RGBColor color = colors[pixel_idx];
serial_buf[idx + 1] = RGBGetRValue(color);
serial_buf[idx + 2] = RGBGetGValue(color);
serial_buf[idx + 3] = RGBGetBValue(color);
}
unsigned short sum = 0;
for (int i = 0; i < (num_leds * 3) + 1; i++)
{
sum += serial_buf[i];
}
serial_buf[(num_leds * 3) + 1] = sum >> 8;
serial_buf[(num_leds * 3) + 2] = sum & 0x00FF;
if (serialport != NULL)
{
serialport->serial_write((char *)serial_buf, (num_leds * 3) + 3);
serialport->serial_flush_tx();
}
else if (udpport != NULL)
{
udpport->udp_write((char *)serial_buf, (num_leds * 3) + 3);
}
delete[] serial_buf;
}
@@ -0,0 +1,50 @@
/*---------------------------------------------------------*\
| Definitions for Generic LED Strip Interface |
| |
| Adam Honse ([email protected]), 12/11/2016 |
\*---------------------------------------------------------*/
#ifndef LED_STRIP_H
#define LED_STRIP_H
#include "RGBController.h"
#include "serial_port.h"
#include "net_port.h"
#include <vector>
#ifndef TRUE
#define TRUE true
#define FALSE false
#endif
#ifndef WIN32
#define LPSTR char *
#define strtok_s strtok_r
#endif
class LEDStripController
{
public:
LEDStripController();
~LEDStripController();
void Initialize(char* ledstring);
void InitializeSerial(char* portname, int baud);
void InitializeUDP(char* clientname, char* port);
char* GetLEDString();
void SetLEDs(std::vector<RGBColor> colors);
int num_leds;
private:
int baud_rate;
char led_string[1024];
char port_name[128];
char client_name[1024];
serial_port *serialport;
net_port *udpport;
};
#endif
@@ -0,0 +1,88 @@
#include "LEDStripController.h"
#include "RGBController.h"
#include "RGBController_LEDStrip.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <fstream>
#include <iostream>
#include <string>
#ifndef WIN32
#include <unistd.h>
#include <dirent.h>
#endif
/******************************************************************************************\
* *
* DetectLEDStripControllers *
* *
* Detect devices supported by the LEDStrip driver *
* * *
\******************************************************************************************/
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);
if (infile.good())
{
for (std::string line; std::getline(infile, line); )
{
if (line == "")
{
continue;
}
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
{
char * argument;
char * value;
value = (char *)line.c_str();
argument = strtok_s(value, "=", &value);
//Strip off new line characters if present
argument = strtok(argument, "\r\n");
value = strtok(value, "\r\n");
if(argument)
{
if (strcmp(argument, "ledstrip") == 0)
{
new_ledstrip = new LEDStripController();
new_ledstrip->Initialize(value);
new_controller = new RGBController_LEDStrip(new_ledstrip);
rgb_controllers.push_back(new_controller);
}
}
}
}
}
} /* DetectLEDStripControllers() */
@@ -0,0 +1,78 @@
/*-----------------------------------------*\
| MSI3ZoneController.cpp |
| |
| Driver for MSI/Steelseries 3-Zone |
| Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#include "MSI3ZoneController.h"
MSI3ZoneController::MSI3ZoneController(hid_device* dev_handle)
{
dev = dev_handle;
//strcpy(device_name, "MSI 3-Zone Keyboard");
}
MSI3ZoneController::~MSI3ZoneController()
{
}
char* MSI3ZoneController::GetDeviceName()
{
return device_name;
}
void MSI3ZoneController::SetLEDs(std::vector<RGBColor> colors)
{
//Shout out to bparker06 for reverse engineering the MSI keyboard USB protocol!
// https://github.com/bparker06/msi-keyboard/blob/master/keyboard.cpp for original implementation
unsigned char buf[8] = { 0 };
buf[0] = 1;
buf[1] = 2;
buf[2] = 64;
buf[3] = 1;
buf[4] = RGBGetRValue(colors[0]);
buf[5] = RGBGetGValue(colors[0]);
buf[6] = RGBGetBValue(colors[0]);
buf[7] = 236;
hid_send_feature_report(dev, buf, 8);
buf[3] = 2;
buf[4] = RGBGetRValue(colors[1]);
buf[5] = RGBGetGValue(colors[1]);
buf[6] = RGBGetBValue(colors[1]);
hid_send_feature_report(dev, buf, 8);
buf[3] = 3;
buf[4] = RGBGetRValue(colors[2]);
buf[5] = RGBGetGValue(colors[2]);
buf[6] = RGBGetBValue(colors[2]);
hid_send_feature_report(dev, buf, 8);
buf[3] = 4;
buf[4] = RGBGetRValue(colors[3]);
buf[5] = RGBGetGValue(colors[3]);
buf[6] = RGBGetBValue(colors[3]);
hid_send_feature_report(dev, buf, 8);
buf[3] = 5;
hid_send_feature_report(dev, buf, 8);
buf[3] = 6;
hid_send_feature_report(dev, buf, 8);
buf[3] = 7;
hid_send_feature_report(dev, buf, 8);
}
@@ -0,0 +1,30 @@
/*-----------------------------------------*\
| MSI3ZoneController.h |
| |
| Definitions and types for MSI/Steelseries|
| 3-Zone Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class MSI3ZoneController
{
public:
MSI3ZoneController(hid_device* dev_handle);
~MSI3ZoneController();
char* GetDeviceName();
void SetLEDs(std::vector<RGBColor> colors);
private:
char device_name[32];
hid_device* dev;
};
@@ -0,0 +1,36 @@
#include "MSI3ZoneController.h"
#include "RGBController.h"
#include "RGBController_MSI3Zone.h"
#include <vector>
#include <hidapi/hidapi.h>
#define MSI_3_ZONE_KEYBOARD_VID 0x1770
#define MSI_3_ZONE_KEYBOARD_PID 0xFF00
/******************************************************************************************\
* *
* DetectMSI3ZoneControllers *
* *
* Tests the USB address to see if an MSI/SteelSeries 3-zone Keyboard controller *
* exists there. *
* *
\******************************************************************************************/
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device* dev;
//Look for MSI/Steelseries 3-zone Keyboard
hid_init();
dev = hid_open(MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID, 0);
if( dev )
{
MSI3ZoneController* controller = new MSI3ZoneController(dev);
RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -0,0 +1,176 @@
/*-----------------------------------------*\
| PatriotViperController.cpp |
| |
| Definitions and types for Patriot Viper |
| RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/1/2020 |
\*-----------------------------------------*/
#include "PatriotViperController.h"
#include <cstring>
PatriotViperController::PatriotViperController(i2c_smbus_interface* bus, viper_dev_id dev, unsigned char slots)
{
this->bus = bus;
this->dev = dev;
slots_valid = slots;
strcpy(device_name, "Patriot Viper RGB");
led_count = 0;
for(int i = 0; i < 8; i++)
{
if((slots_valid & (1 << i)) != 0)
{
led_count += 5;
}
}
}
PatriotViperController::~PatriotViperController()
{
}
std::string PatriotViperController::GetDeviceName()
{
return(device_name);
}
std::string PatriotViperController::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 int PatriotViperController::GetLEDCount()
{
return(led_count);
}
unsigned int PatriotViperController::GetSlotCount()
{
unsigned int slot_count = 0;
for(int slot = 0; slot < 4; slot++)
{
if((slots_valid & (1 << slot)) != 0)
{
slot_count++;
}
}
return(slot_count);
}
unsigned int PatriotViperController::GetMode()
{
return(mode);
}
void PatriotViperController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED1_EFFECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED2_EFFECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED3_EFFECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED4_EFFECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED1_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED2_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED3_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_LED4_DIRECT_COLOR, red, blue, green);
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
}
void PatriotViperController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR + led, red, blue, green);
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
}
void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_DIRECT_COLOR + led, red, blue, green);
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
}
void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_LED0_EFFECT_COLOR + led, red, blue, green);
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetMode(unsigned char new_mode, unsigned char new_speed)
{
direct = false;
mode = new_mode;
speed = new_speed;
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, mode, 0x00, speed);
ViperRegisterWrite(VIPER_REG_MODE, 0xAA, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetDirect()
{
direct = true;
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
}
void PatriotViperController::ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2)
{
bus->i2c_smbus_write_byte_data(dev, reg, val0);
bus->i2c_smbus_write_byte_data(dev, val2, val1);
}
@@ -0,0 +1,90 @@
/*-----------------------------------------*\
| PatriotViperController.h |
| |
| Definitions and types for Patriot Viper |
| RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/1/2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char viper_dev_id;
typedef unsigned short viper_register;
enum
{
VIPER_REG_STATIC = 0x01, /* Set static mode */
VIPER_REG_MODE = 0x03, /* Mode register */
VIPER_REG_LED0_DIRECT_COLOR = 0x30, /* LED 0 Color (R, B, G) */
VIPER_REG_LED1_DIRECT_COLOR = 0x31, /* LED 1 Color (R, B, G) */
VIPER_REG_LED2_DIRECT_COLOR = 0x32, /* LED 2 Color (R, B, G) */
VIPER_REG_LED3_DIRECT_COLOR = 0x33, /* LED 3 Color (R, B, G) */
VIPER_REG_LED4_DIRECT_COLOR = 0x34, /* LED 4 Color (R, B, G) */
VIPER_REG_APPLY = 0x35, /* Apply Changes (0x01, 0x00, 0x00) */
VIPER_REG_LED0_EFFECT_COLOR = 0x3B, /* LED 0 Color (R, B, G) */
VIPER_REG_LED1_EFFECT_COLOR = 0x3C, /* LED 1 Color (R, B, G) */
VIPER_REG_LED2_EFFECT_COLOR = 0x3D, /* LED 2 Color (R, B, G) */
VIPER_REG_LED3_EFFECT_COLOR = 0x3E, /* LED 3 Color (R, B, G) */
VIPER_REG_LED4_EFFECT_COLOR = 0x3F, /* LED 4 Color (R, B, G) */
VIPER_REG_START = 0xFF, /* Start Frame (0xFF, 0xFF, 0xFF) */
};
enum
{
VIPER_MODE_DARK = 0x00, /* Dark mode */
VIPER_MODE_BREATHING = 0x01, /* Breathing mode */
VIPER_MODE_VIPER = 0x02, /* Viper mode */
VIPER_MODE_HEARTBEAT = 0x03, /* Heartbeat mode */
VIPER_MODE_MARQUEE = 0x04, /* Marquee mode */
VIPER_MODE_RAINDROP = 0x05, /* Raindrop mode */
VIPER_MODE_AURORA = 0x06, /* Aurora mode */
VIPER_MODE_NEON = 0x08, /* Neon mode */
};
enum
{
VIPER_SPEED_MIN = 0xC8, /* Slowest speed for non-breathing mode */
VIPER_SPEED_DEFAULT = 0x64, /* Default speed for non-breathing mode */
VIPER_SPEED_MAX = 0x14, /* Fastest speed for non-breathing mode */
VIPER_SPEED_BREATHING_MIN = 0xFF, /* Slowest speed for breathing mode */
VIPER_SPEED_BREATHING_DEFAULT = 0x0C, /* Default speed for breathing mode */
VIPER_SPEED_BREATHING_MAX = 0x00, /* Fastest speed for breathing mode */
};
class PatriotViperController
{
public:
PatriotViperController(i2c_smbus_interface* bus, viper_dev_id dev, unsigned char slots);
~PatriotViperController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned int GetSlotCount();
unsigned int GetMode();
void SetMode(unsigned char new_mode, unsigned char new_speed);
void SetDirect();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetEffectColor(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDEffectColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void ViperRegisterWrite(viper_register reg, unsigned char val0, unsigned char val1, unsigned char val2);
bool direct;
private:
char device_name[32];
unsigned int led_count;
unsigned char slots_valid;
i2c_smbus_interface* bus;
viper_dev_id dev;
unsigned char mode;
unsigned char speed;
};
@@ -0,0 +1,81 @@
#include "PatriotViperController.h"
#include "RGBController.h"
#include "RGBController_PatriotViper.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/******************************************************************************************\
* *
* DetectPatriotViperControllers *
* *
* Detect Patriot Viper RGB controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
PatriotViperController* new_viper;
RGBController_PatriotViper* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
unsigned char slots_valid = 0x00;
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
{
// Test for Patriot Viper RGB SPD at slot_addr
// This test was copied from Viper RGB software
// Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF);
Sleep(1);
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
{
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
Sleep(1);
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x85)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x02)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x61) == 0x4D)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x62) == 0x49)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x63) == 0x43)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x64) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x65) == 0x59)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x66) == 0x53)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x5f)
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x68) == 0x44))
{
slots_valid |= (1 << (slot_addr - 0x50));
}
}
Sleep(1);
}
if(slots_valid != 0)
{
new_viper = new PatriotViperController(busses[bus], 0x77, slots_valid);
new_controller = new RGBController_PatriotViper(new_viper);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectPatriotViperControllers() */
@@ -0,0 +1,125 @@
/*-----------------------------------------*\
| PolychromeController.cpp |
| |
| Driver for for ASRock ASR LED and |
| Polychrome RGB lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/14/2019 |
\*-----------------------------------------*/
#include "PolychromeController.h"
#include <cstring>
PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev)
{
this->bus = bus;
this->dev = dev;
switch (GetFirmwareVersion())
{
case FIRMWARE_VER_1_PT_10:
led_count = 1;
asr_led = true;
strcpy(device_name, "ASRock ASR LED FW 1.10");
break;
case FIRMWARE_VER_2_PT_00:
led_count = 1;
asr_led = false;
strcpy(device_name, "ASRock Polychrome FW 2.00");
break;
case FIRMWARE_VER_2_PT_08:
led_count = 1;
asr_led = false;
strcpy(device_name, "ASRock Polychrome FW 2.08");
break;
case FIRMWARE_VER_2_PT_10:
led_count = 1;
asr_led = true;
strcpy(device_name, "ASRock Polychrome FW 2.10");
break;
case FIRMWARE_VER_3_PT_00:
led_count = 1;
asr_led = false;
strcpy(device_name, "ASRock Polychrome FW 3.00");
break;
default:
led_count = 0;
strcpy(device_name, "");
break;
}
}
PolychromeController::~PolychromeController()
{
}
char* PolychromeController::GetDeviceName()
{
return(device_name);
}
unsigned short PolychromeController::GetFirmwareVersion()
{
// 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)
{
unsigned char major = bus->i2c_smbus_read_byte(dev);
unsigned char minor = bus->i2c_smbus_read_byte(dev);
return((major << 8) | minor);
}
else
{
return(0xFFFF);
}
}
unsigned int PolychromeController::GetLEDCount()
{
return(led_count);
}
unsigned int PolychromeController::GetMode()
{
return(active_mode);
}
bool PolychromeController::IsAsrLed()
{
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)
{
bus->i2c_smbus_write_block_data(dev, active_mode, 3, colors);
}
else
{
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
}
}
void PolychromeController::SetMode(unsigned char mode)
{
active_mode = mode;
if (asr_led)
{
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);
}
}
@@ -0,0 +1,95 @@
/*-----------------------------------------*\
| PolychromeController.h |
| |
| Definitions and types for ASRock |
| ASR LED and Polychrome RGB lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 12/13/2019 |
\*-----------------------------------------*/
#include "i2c_smbus.h"
#pragma once
typedef unsigned char polychrome_dev_id;
enum
{
FIRMWARE_VER_1_PT_10 = 0x010A, /* Firmware nu51_1.10 */
FIRMWARE_VER_2_PT_00 = 0x0200, /* Firmware nu51_2.00 */
FIRMWARE_VER_2_PT_08 = 0x0208, /* Firmware nu51_2.08 */
FIRMWARE_VER_2_PT_10 = 0x020A, /* Firmware nu51_2.10 */
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
};
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 */
};
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 */
};
#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 */
};
class PolychromeController
{
public:
PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev);
~PolychromeController();
char* GetDeviceName();
unsigned int GetLEDCount();
unsigned int GetMode();
bool IsAsrLed();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned short GetFirmwareVersion();
private:
bool asr_led;
char device_name[32];
unsigned int led_count;
unsigned char active_mode;
i2c_smbus_interface* bus;
polychrome_dev_id dev;
};
@@ -0,0 +1,69 @@
#include "PolychromeController.h"
#include "RGBController.h"
#include "RGBController_Polychrome.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* TestForPolychromeController *
* *
* Tests the given address to see if an ASRock Polychrome RGB controller exists there.*
* First does a quick write to test for a response *
* *
\******************************************************************************************/
bool TestForPolychromeController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
}
return(pass);
} /* TestForPolychromeController() */
/******************************************************************************************\
* *
* DetectPolychromeControllers *
* *
* Detect ASRock Polychrome RGB controllers on the enumerated I2C busses at address *
* 0x6A. *
* *
* bus - pointer to i2c_smbus_interface where Polychrome device is connected *
* dev - I2C address of Polychrome device *
* *
\******************************************************************************************/
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
{
PolychromeController* new_polychrome;
RGBController_Polychrome* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for Polychrome controller at 0x6A
if (TestForPolychromeController(busses[bus], 0x6A))
{
new_polychrome = new PolychromeController(busses[bus], 0x6A);
if(new_polychrome->GetLEDCount() != 0)
{
new_controller = new RGBController_Polychrome(new_polychrome);
rgb_controllers.push_back(new_controller);
}
else
{
delete new_polychrome;
}
}
}
} /* DetectPolychromeControllers() */
@@ -0,0 +1,236 @@
/*-----------------------------------------*\
| PoseidonZRGBController.cpp |
| |
| Driver for Thermaltake Poseidon Z RGB |
| Keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#include "PoseidonZRGBController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15,
0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
0x24, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x40,
0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x66, 0x67, 0x68, 0x69, 0x6A,
0x6C, 0x6D, 0x6F, 0x70, 0x72, 0x73, 0x75, 0x76, 0x77, 0x78, 0x7C, 0x80, 0x81 };
PoseidonZRGBController::PoseidonZRGBController(hid_device* dev_handle)
{
dev = dev_handle;
}
PoseidonZRGBController::~PoseidonZRGBController()
{
}
void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction, unsigned char speed)
{
active_mode = mode;
active_direction = direction;
active_speed = speed;
SendControl
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_PROFILE_P1,
active_direction,
active_mode,
POSEIDONZ_BRIGHTNESS_MAX,
active_speed
);
}
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char red_grn_buf[264];
unsigned char blu_buf[264];
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(red_grn_buf, 0x00, sizeof(red_grn_buf));
memset(blu_buf, 0x00, sizeof(blu_buf));
/*-----------------------------------------------------*\
| Set up Direct packets |
\*-----------------------------------------------------*/
red_grn_buf[0] = 0x07;
red_grn_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
red_grn_buf[2] = POSEIDONZ_PROFILE_P1;
red_grn_buf[3] = POSEIDONZ_DIRECT_RED_GREEN;
red_grn_buf[4] = 0x00;
red_grn_buf[5] = 0x00;
red_grn_buf[6] = 0x00;
red_grn_buf[7] = 0x00;
blu_buf[0] = 0x07;
blu_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
blu_buf[2] = POSEIDONZ_PROFILE_P1;
blu_buf[3] = POSEIDONZ_DIRECT_BLUE;
blu_buf[4] = 0x00;
blu_buf[5] = 0x00;
blu_buf[6] = 0x00;
blu_buf[7] = 0x00;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(std::size_t i = 0; i < 104; i++)
{
red_grn_buf[keys[i] ] = RGBGetRValue(colors[i]);
red_grn_buf[keys[i] + 128] = RGBGetGValue(colors[i]);
blu_buf[ keys[i] ] = RGBGetBValue(colors[i]);
}
/*-----------------------------------------------------*\
| Send packets |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, red_grn_buf, 264);
hid_send_feature_report(dev, blu_buf, 264);
}
void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char red_color_data[104];
unsigned char grn_color_data[104];
unsigned char blu_color_data[104];
for(std::size_t i = 0; i < 104; i++)
{
red_color_data[i] = RGBGetRValue(colors[i]);
grn_color_data[i] = RGBGetGValue(colors[i]);
blu_color_data[i] = RGBGetBValue(colors[i]);
}
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_RED,
red_color_data
);
Sleep(10);
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_GREEN,
grn_color_data
);
Sleep(10);
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_BLUE,
blu_color_data
);
Sleep(10);
SendControl
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_PROFILE_P1,
active_direction,
active_mode,
POSEIDONZ_BRIGHTNESS_MAX,
active_speed
);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void PoseidonZRGBController::SendColor
(
unsigned char profile_to_edit,
unsigned char color_channel,
unsigned char* color_data
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Color packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = POSEIDONZ_PACKET_ID_SET_COLOR;
buf[0x02] = profile_to_edit;
buf[0x03] = color_channel;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = color_data[i];
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
void PoseidonZRGBController::SendControl
(
unsigned char profile_to_activate,
unsigned char profile_to_edit,
unsigned char direction,
unsigned char mode,
unsigned char brightness,
unsigned char speed
)
{
unsigned char buf[264];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(buf, 0x00, sizeof(buf));
/*-----------------------------------------------------*\
| Set up Effect packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x07;
buf[0x01] = POSEIDONZ_PACKET_ID_SET_EFFECT;
buf[0x02] = profile_to_activate;
buf[0x08] = profile_to_edit;
buf[0x0A] = direction;
buf[0x0C] = mode;
buf[0x0D] = brightness;
buf[0x10] = 0x08;
buf[0x12] = speed;
buf[0x13] = 0x50;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 264);
}
@@ -0,0 +1,106 @@
/*-----------------------------------------*\
| PoseidonZRGBController.h |
| |
| Definitions and types for Thermaltake |
| Poseidon Z RGB Keyboard lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
#define POSEIDONZ_START 0x07
#define POSEIDONZ_PROFILE 0x01
#define POSEIDONZ_LED_CMD 0x0E
#define POSEIDONZ_RED_GRN_CH 0x01
#define POSEIDONZ_BLU_CH 0x02
enum
{
POSEIDONZ_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
POSEIDONZ_PACKET_ID_SET_COLOR = 0x09, /* Set profile color packet */
POSEIDONZ_PACKET_ID_SET_DIRECT = 0x0E, /* Set direct color packet */
};
enum
{
POSEIDONZ_MODE_STATIC = 0x00,
POSEIDONZ_MODE_REACTIVE = 0x01,
POSEIDONZ_MODE_ARROW_FLOW = 0x02,
POSEIDONZ_MODE_WAVE = 0x03,
POSEIDONZ_MODE_RIPPLE = 0x04
};
enum
{
POSEIDONZ_PROFILE_P1 = 0x01,
POSEIDONZ_PROFILE_P2 = 0x02,
POSEIDONZ_PROFILE_P3 = 0x03,
POSEIDONZ_PROFILE_P4 = 0x04,
POSEIDONZ_PROFILE_P5 = 0x05
};
enum
{
POSEIDONZ_BRIGHTNESS_MIN = 0x00,
POSEIDONZ_BRIGHTNESS_MAX = 0x04
};
enum
{
POSEIDONZ_COLOR_RED = 0x01,
POSEIDONZ_COLOR_GREEN = 0x02,
POSEIDONZ_COLOR_BLUE = 0x03
};
enum
{
POSEIDONZ_DIRECT_RED_GREEN = 0x01,
POSEIDONZ_DIRECT_BLUE = 0x02
};
enum
{
POSEIDONZ_SPEED_SLOW = 0x10,
POSEIDONZ_SPEED_FAST = 0x05
};
class PoseidonZRGBController
{
public:
PoseidonZRGBController(hid_device* dev_handle);
~PoseidonZRGBController();
void SetMode(unsigned char mode, unsigned char direction, unsigned char speed);
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetLEDs(std::vector<RGBColor> colors);
private:
hid_device* dev;
unsigned char active_mode;
unsigned char active_direction;
unsigned char active_speed;
void SendControl
(
unsigned char profile_to_activate,
unsigned char profile_to_edit,
unsigned char direction,
unsigned char mode,
unsigned char brightness,
unsigned char speed
);
void SendColor
(
unsigned char profile_to_edit,
unsigned char color_channel,
unsigned char* color_data
);
};
@@ -0,0 +1,52 @@
#include "PoseidonZRGBController.h"
#include "RGBController.h"
#include "RGBController_PoseidonZRGB.h"
#include <vector>
#include <hidapi/hidapi.h>
#define TT_POSEIDON_Z_RGB_VID 0x264A
#define TT_POSEIDON_Z_RGB_PID 0x3006
/******************************************************************************************\
* *
* DetectPoseidonZRGBControllers *
* *
* Tests the USB address to see if a Thermaltake Poseidon Z RGB Keyboard controller *
* exists there. *
* *
\******************************************************************************************/
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
info = hid_enumerate(TT_POSEIDON_Z_RGB_VID, TT_POSEIDON_Z_RGB_PID);
//Look for Thermaltake Poseidon Z RGB, Interface 2
while(info)
{
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
&&(info->interface_number == 2))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
PoseidonZRGBController* controller = new PoseidonZRGBController(dev);
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -0,0 +1,121 @@
/*-----------------------------------------*\
| RGBFusion2Controller.cpp |
| |
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBFusion2Controller.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
RGBFusion2Controller::RGBFusion2Controller(hid_device* dev_handle)
{
dev = dev_handle;
// Set Device name
strcpy(device_name, "Gigabyte Motherboard");
// Set LED count
led_count = 8;
}
RGBFusion2Controller::~RGBFusion2Controller()
{
}
std::string RGBFusion2Controller::GetDeviceName()
{
return(device_name);
}
std::string RGBFusion2Controller::GetDeviceLocation()
{
return("");
}
unsigned int RGBFusion2Controller::GetLEDCount()
{
return(led_count);
}
unsigned char RGBFusion2Controller::GetMode()
{
return(0);
}
void RGBFusion2Controller::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
}
void RGBFusion2Controller::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[] =
{
0xCC, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x5A, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
usb_buf[0x01] = (0x20 | led);
usb_buf[0x02] = (0x01 << led );
usb_buf[0x0E] = blue;
usb_buf[0x0F] = green;
usb_buf[0x10] = red;
hid_send_feature_report(dev, usb_buf, 64);
SendApply();
}
void RGBFusion2Controller::SendApply()
{
unsigned char usb_buf[] =
{
0xCC, 0x28, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
hid_send_feature_report(dev, usb_buf, 64);
}
void RGBFusion2Controller::SetMode(unsigned char mode)
{
}
void RGBFusion2Controller::dump()
{
}
@@ -0,0 +1,39 @@
/*-----------------------------------------*\
| RGBFusion2Controller.h |
| |
| Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class RGBFusion2Controller
{
public:
RGBFusion2Controller(hid_device* dev_handle);
~RGBFusion2Controller();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned char GetMode();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
private:
void dump();
char device_name[32];
unsigned int led_count;
void SendApply();
hid_device* dev;
};
@@ -0,0 +1,36 @@
#include "RGBFusion2Controller.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2.h"
#include <vector>
#include <hidapi/hidapi.h>
#define RGB_FUSION_2_VID 0x048D
#define RGB_FUSION_2_PID 0x8297
/******************************************************************************************\
* *
* DetectRGBFusion2Controllers *
* *
* Detect RGB Fusion 2.0 controllers on the USB interface. *
* *
\******************************************************************************************/
void DetectRGBFusion2Controllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device* dev;
//Look for RGB Fusion 2.0 Controller
hid_init();
dev = hid_open(RGB_FUSION_2_VID, RGB_FUSION_2_PID, 0);
if( dev )
{
RGBFusion2Controller* controller = new RGBFusion2Controller(dev);
RGBController_RGBFusion2* rgb_controller = new RGBController_RGBFusion2(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectRGBFusionControllers() */
@@ -0,0 +1,194 @@
/*-----------------------------------------*\
| RGBFusionController.cpp |
| |
| Driver for Gigabyte Aorus RGB Fusion |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/10/2019 |
\*-----------------------------------------*/
#include "RGBFusionController.h"
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
RGBFusionController::RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
{
this->bus = bus;
this->dev = dev;
// Set Device name
strcpy(device_name, "Gigabyte Motherboard");
// Set LED count
led_count = 2;
// Enable control
switch_bank(0);
bus->i2c_smbus_write_byte_data(dev, 0x02, 0x09);
}
RGBFusionController::~RGBFusionController()
{
}
std::string RGBFusionController::GetDeviceName()
{
return(device_name);
}
std::string RGBFusionController::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 int RGBFusionController::GetLEDCount()
{
return(led_count);
}
unsigned char RGBFusionController::GetMode()
{
switch_bank(0);
return(get_mode_ch_0());
}
void RGBFusionController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char mode_ch_0;
unsigned char mode_ch_1;
switch_bank(1);
set_color_ch_0(red, green, blue);
set_color_ch_1(red, green, blue);
switch_bank(0);
mode_ch_0 = get_mode_ch_0();
mode_ch_1 = get_mode_ch_1();
set_mode_ch_0(mode_ch_0);
set_mode_ch_1(mode_ch_1);
}
void RGBFusionController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char mode;
switch (led)
{
case 0:
switch_bank(1);
set_color_ch_0(red, green, blue);
switch_bank(0);
mode = get_mode_ch_0();
set_mode_ch_0(mode);
break;
case 1:
switch_bank(1);
set_color_ch_1(red, green, blue);
switch_bank(0);
mode = get_mode_ch_1();
set_mode_ch_1(mode);
break;
}
}
void RGBFusionController::SetMode(unsigned char mode, unsigned char speed)
{
switch_bank(0);
set_mode_ch_0(mode);
set_timers_ch_0(speed_table[0][speed], speed_table[1][speed]);
set_mode_ch_1(mode);
set_timers_ch_1(speed_table[0][speed], speed_table[1][speed]);
}
void RGBFusionController::dump()
{
int i, j;
int start = 0x00;
FILE* file = freopen("rgb_fusion_dump.txt", "a", stdout);
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
for (i = 0; i < 0xFF; i += 16)
{
printf("%04x: ", i + start);
for (j = 0; j < 16; j++)
{
printf("%02x ", bus->i2c_smbus_read_byte_data(dev, (start + i + j)));
}
printf("\r\n");
}
fclose(file);
}
unsigned char RGBFusionController::get_mode_ch_0()
{
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_MODE));
}
unsigned char RGBFusionController::get_mode_ch_1()
{
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE));
}
void RGBFusionController::set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_R, red);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_G, green);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_B, blue);
bus->i2c_smbus_write_byte_data(dev, 0x03, 0x01);
}
void RGBFusionController::set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_R, red);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_G, green);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_B, blue);
bus->i2c_smbus_write_byte_data(dev, 0x0B, 0x01);
}
void RGBFusionController::set_mode_ch_0(unsigned char mode)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
}
void RGBFusionController::set_mode_ch_1(unsigned char mode)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
}
void RGBFusionController::set_timers_ch_0(unsigned short timer0, unsigned short timer1)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB, timer0 >> 8);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB, timer0 & 0xFF);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB, timer1 >> 8);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB, timer1 & 0xFF);
}
void RGBFusionController::set_timers_ch_1(unsigned short timer0, unsigned short timer1)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB, timer0 >> 8);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB, timer0 & 0xFF);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB, timer1 >> 8);
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB, timer1 & 0xFF);
}
void RGBFusionController::switch_bank(unsigned char bank)
{
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
}
@@ -0,0 +1,102 @@
/*-----------------------------------------*\
| RGBFusionController.h |
| |
| Definitions and types for Gigabyte Aorus |
| RGB Fusion lighting controller |
| |
| Adam Honse (CalcProgrammer1) 12/10/2019 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char rgb_fusion_dev_id;
enum
{
RGB_FUSION_BANK_0_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_MSB
= 0x06, /* Channel 0 Timer 0 MSB */
RGB_FUSION_BANK_0_REG_CH_0_TIMER_0_LSB
= 0x07, /* Channel 0 Timer 0 LSB */
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_MSB
= 0x08, /* Channel 0 Timer 1 MSB */
RGB_FUSION_BANK_0_REG_CH_0_TIMER_1_LSB
= 0x09, /* Channel 0 Timer 1 LSB */
RGB_FUSION_BANK_0_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_MSB
= 0x16, /* Channel 1 Timer 0 MSB */
RGB_FUSION_BANK_0_REG_CH_1_TIMER_0_LSB
= 0x17, /* Channel 1 Timer 0 LSB */
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_MSB
= 0x18, /* Channel 1 Timer 1 MSB */
RGB_FUSION_BANK_0_REG_CH_1_TIMER_1_LSB
= 0x19, /* Channel 1 Timer 1 LSB */
RGB_FUSION_BANK_1_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
RGB_FUSION_BANK_1_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
RGB_FUSION_BANK_1_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
RGB_FUSION_BANK_1_REG_CH_1_R = 0x08, /* Channel 1 Red Value */
RGB_FUSION_BANK_1_REG_CH_1_G = 0x09, /* Channel 1 Green Value */
RGB_FUSION_BANK_1_REG_CH_1_B = 0x0A, /* Channel 1 Blue Value */
RGB_FUSION_BANK_SWITCH_REG = 0xF0, /* Bank Switch Register */
};
enum
{
RGB_FUSION_SPEED_SLOW = 0x00, /* Slowest speed */
RGB_FUSION_SPEED_NORMAL = 0x01, /* Normal speed */
RGB_FUSION_SPEED_FAST = 0x02, /* Fastest speed */
};
static const short speed_table[2][3] =
{
{ 0x01E0, 0x00F0, 0x0078 },
{ 0x4000, 0x2000, 0x1000 }
};
#define RGB_FUSION_NUMBER_MODES 3 /* Number of RGB Fusion modes */
#define RGB_FUSION_WRITE_MODE_OFST 0x10 /* offset to add when writing mode */
enum
{
RGB_FUSION_MODE_STATIC = 0x00, /* Static color mode */
RGB_FUSION_MODE_BREATHING = 0x01, /* Breathing effect mode */
RGB_FUSION_MODE_FLASHING = 0x02, /* Flashing effect mode */
};
class RGBFusionController
{
public:
RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
~RGBFusionController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned char GetMode();
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode, unsigned char speed);
private:
void dump();
unsigned char get_mode_ch_0();
unsigned char get_mode_ch_1();
void set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue);
void set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue);
void set_mode_ch_0(unsigned char mode);
void set_mode_ch_1(unsigned char mode);
void set_timers_ch_0(unsigned short timer0, unsigned short timer1);
void set_timers_ch_1(unsigned short timer0, unsigned short timer1);
void switch_bank(unsigned char bank);
char device_name[32];
unsigned int led_count;
i2c_smbus_interface* bus;
rgb_fusion_dev_id dev;
};
@@ -0,0 +1,67 @@
#include "RGBFusionController.h"
#include "RGBController.h"
#include "RGBController_RGBFusion.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* TestForRGBFusionController *
* *
* Tests the given address to see if an RGB Fusion controller exists there. First *
* does a quick write to test for a response *
* *
\******************************************************************************************/
bool TestForRGBFusionController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
if (res >= 0)
{
pass = true;
res = bus->i2c_smbus_read_byte_data(address, 0xF2);
if (res != 0xC4)
{
pass = false;
}
}
return(pass);
} /* TestForRGBFusionController() */
/******************************************************************************************\
* *
* DetectRGBFusionControllers *
* *
* Detect RGB Fusion controllers on the enumerated I2C busses at address 0x28. *
* *
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
* dev - I2C address of RGB Fusion device *
* *
\******************************************************************************************/
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
{
RGBFusionController* new_rgb_fusion;
RGBController_RGBFusion* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for RGB Fusion controller at 0x28
if (TestForRGBFusionController(busses[bus], 0x28))
{
new_rgb_fusion = new RGBFusionController(busses[bus], 0x28);
new_controller = new RGBController_RGBFusion(new_rgb_fusion);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectRGBFusionControllers() */
@@ -0,0 +1,117 @@
/*-----------------------------------------*\
| ThermaltakeRiingController.cpp |
| |
| Definitions and types for Thermaltake |
| Riing Plus lighting controller |
| |
| Adam Honse (CalcProgrammer1) 2/7/2020 |
\*-----------------------------------------*/
#include "ThermaltakeRiingController.h"
#include <cstring>
ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
SendInit();
channel_leds[0] = 9;
channel_leds[1] = 9;
channel_leds[2] = 9;
channel_leds[3] = 0;
channel_leds[4] = 0;
}
ThermaltakeRiingController::~ThermaltakeRiingController()
{
}
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char* color_data = new unsigned char[3 * colors.size()];
for(int color = 0; color < colors.size(); color++)
{
int color_idx = color * 3;
color_data[color_idx + 0] = RGBGetGValue(colors[color]);
color_data[color_idx + 1] = RGBGetRValue(colors[color]);
color_data[color_idx + 2] = RGBGetBValue(colors[color]);
}
SendRGB(channel, current_mode, current_speed, colors.size(), color_data);
delete[] color_data;
}
void ThermaltakeRiingController::SetMode(unsigned char mode, unsigned char speed)
{
current_mode = mode;
current_speed = speed;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void ThermaltakeRiingController::SendInit()
{
unsigned char usb_buf[64];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Init packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xFE;
usb_buf[0x01] = 0x33;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
void ThermaltakeRiingController::SendRGB
(
unsigned char port,
unsigned char mode,
unsigned char speed,
unsigned char num_colors,
unsigned char* color_data
)
{
unsigned char usb_buf[64];
int actual;
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up RGB packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x32;
usb_buf[0x01] = 0x52;
usb_buf[0x02] = port;
usb_buf[0x03] = mode + ( speed & 0x03 );
/*-----------------------------------------------------*\
| Copy in GRB color data |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], color_data, (num_colors * 3));
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
@@ -0,0 +1,75 @@
/*-----------------------------------------*\
| ThermaltakeRiingController.h |
| |
| Definitions and types for Thermaltake |
| Riing Plus lighting controller |
| |
| Adam Honse (CalcProgrammer1) 2/7/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
THERMALTAKE_PORT_1 = 0x01,
THERMALTAKE_PORT_2 = 0x02,
THERMALTAKE_PORT_3 = 0x03,
THERMALTAKE_PORT_4 = 0x04,
THERMALTAKE_PORT_5 = 0x05
};
enum
{
THERMALTAKE_MODE_FLOW = 0x00,
THERMALTAKE_MODE_SPECTRUM = 0x04,
THERMALTAKE_MODE_RIPPLE = 0x08,
THERMALTAKE_MODE_BLINK = 0x0C,
THERMALTAKE_MODE_PULSE = 0x10,
THERMALTAKE_MODE_WAVE = 0x14,
THERMALTAKE_MODE_PER_LED = 0x18,
THERMALTAKE_MODE_FULL = 0x19
};
enum
{
THERMALTAKE_SPEED_SLOW = 0x03,
THERMALTAKE_SPEED_NORMAL = 0x02,
THERMALTAKE_SPEED_FAST = 0x01,
THERMALTAKE_SPEED_EXTREME = 0x00
};
class ThermaltakeRiingController
{
public:
ThermaltakeRiingController(libusb_device_handle* dev_handle);
~ThermaltakeRiingController();
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed);
unsigned int channel_leds[5];
private:
libusb_device_handle* dev;
unsigned char current_mode;
unsigned char current_speed;
void SendInit();
void SendRGB
(
unsigned char port,
unsigned char mode,
unsigned char speed,
unsigned char num_colors,
unsigned char* color_data
);
void SendFan();
void SendSave();
};
@@ -0,0 +1,41 @@
#include "ThermaltakeRiingController.h"
#include "RGBController.h"
#include "RGBController_ThermaltakeRiing.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define THERMALTAKE_RIING_VID 0x264A
#define THERMALTAKE_RIING_PID_BEGIN 0x1FA5
#define THERMALTAKE_RIING_PID_END 0x1FB5
/******************************************************************************************\
* *
* DetectThermaltakeRiingControllers *
* *
* Tests the USB address to see if an AMD Wraith Prism controller exists there. *
* *
\******************************************************************************************/
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
for(int pid = THERMALTAKE_RIING_PID_BEGIN; pid <= THERMALTAKE_RIING_PID_END; pid++)
{
//Look for Thermaltake Riing device
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, THERMALTAKE_RIING_VID, pid);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
ThermaltakeRiingController* controller = new ThermaltakeRiingController(dev);
RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller);
rgb_controllers.push_back(rgb_controller);
}
}
}
-31
View File
@@ -1,31 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenAuraSDK", "OpenAuraSDK\OpenAuraSDK.vcxproj", "{6D22BFF3-C1DF-407A-8816-05D63919A991}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.ActiveCfg = Debug|x64
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.Build.0 = Debug|x64
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.ActiveCfg = Debug|Win32
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.Build.0 = Debug|Win32
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.ActiveCfg = Release|x64
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.Build.0 = Release|x64
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.ActiveCfg = Release|Win32
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A2BB3E13-D506-413D-900E-F2B1323B3BB3}
EndGlobalSection
EndGlobal
-135
View File
@@ -1,135 +0,0 @@
/*-----------------------------------------*\
| AuraController.h |
| |
| Driver for ASUS Aura RGB lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include "AuraController.h"
AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
{
this->bus = bus;
this->dev = dev;
AuraUpdateDeviceName();
led_count = 5; //temporary, some controllers have more channels
}
AuraController::~AuraController()
{
}
char * AuraController::GetDeviceName()
{
return(device_name);
}
unsigned int AuraController::GetLEDCount()
{
return(led_count);
}
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
for (int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
}
AuraRegisterWriteBlock(AURA_REG_COLORS_DIRECT, colors, led_count * 3);
delete colors;
}
void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
for (int i = 0; i < (led_count * 3); i += 3)
{
colors[i + 0] = red;
colors[i + 1] = blue;
colors[i + 2] = green;
}
AuraRegisterWriteBlock(AURA_REG_COLORS_EFFECT, colors, led_count * 3);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
delete colors;
}
void AuraController::SetDirect(unsigned char direct)
{
AuraRegisterWrite(AURA_REG_DIRECT, direct);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
AuraRegisterWriteBlock(AURA_REG_COLORS_DIRECT + ( 3 * led ), colors, 3);
}
void AuraController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
AuraRegisterWriteBlock(AURA_REG_COLORS_EFFECT + (3 * led), colors, 3);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetMode(unsigned char mode)
{
AuraRegisterWrite(AURA_REG_MODE, mode);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::AuraUpdateDeviceName()
{
for (int i = 0; i < 16; i++)
{
device_name[i] = AuraRegisterRead(AURA_REG_DEVICE_NAME + i);
}
}
unsigned char AuraController::AuraRegisterRead(aura_register reg)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Read Aura value
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
}
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Aura value
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
}
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
//Write Aura block data
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
}
-50
View File
@@ -1,50 +0,0 @@
#include "I2CDetectDialog.h"
#include "OpenAuraSDK.h"
IMPLEMENT_DYNAMIC(I2CDetectDialog, CDialogEx)
I2CDetectDialog::I2CDetectDialog(std::vector<i2c_smbus_interface *>& bus, CWnd* pParent)
: CDialogEx(IDD_DIALOG_I2C_DETECT, pParent), busses(bus)
{
}
I2CDetectDialog::~I2CDetectDialog()
{
}
void I2CDetectDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(I2CDetectDialog, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_I2C_DETECT, &I2CDetectDialog::OnBnClickedButtonI2cDetect)
END_MESSAGE_MAP()
BOOL I2CDetectDialog::OnInitDialog()
{
CComboBox* i2c_bus_box = (CComboBox*)GetDlgItem(IDC_COMBO_I2C_BUS);
for (int i = 0; i < busses.size(); i++)
{
i2c_bus_box->AddString(busses[i]->device_name);
}
i2c_bus_box->SetCurSel(0);
CFont* myFont = new CFont();
myFont->CreateFontA(16, 0, 0, 0, FW_DONTCARE, false, false, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, _T("Consolas"));
CEdit* edit = (CEdit*)GetDlgItem(IDC_EDIT_I2C_DETECT);
edit->SetFont(myFont);
return TRUE;
}
void I2CDetectDialog::OnBnClickedButtonI2cDetect()
{
i2c_smbus_interface* bus = busses[((CComboBox*)GetDlgItem(IDC_COMBO_I2C_BUS))->GetCurSel()];
SetDlgItemText(IDC_EDIT_I2C_DETECT, DetectI2C(bus, MODE_QUICK).c_str());
}
-28
View File
@@ -1,28 +0,0 @@
#ifndef I2CDETECT_DIALOG_H
#define I2CDETECT_DIALOG_H
#include <afxdialogex.h>
#include <vector>
#include "i2c_smbus.h"
#include "resource.h"
class I2CDetectDialog : public CDialogEx
{
DECLARE_DYNAMIC(I2CDetectDialog)
public:
I2CDetectDialog(std::vector<i2c_smbus_interface *>& bus, CWnd* pParent = NULL);
virtual ~I2CDetectDialog();
virtual BOOL OnInitDialog();
private:
protected:
std::vector<i2c_smbus_interface *>& busses;
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonI2cDetect();
};
#endif
-9
View File
@@ -1,9 +0,0 @@
#include <string>
#include "i2c_smbus.h"
#define MODE_AUTO 0
#define MODE_QUICK 1
#define MODE_READ 2
#define MODE_FUNC 3
std::string DetectI2C(i2c_smbus_interface * bus, int mode);
-17
View File
@@ -1,17 +0,0 @@
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += \
i2c_smbus.cpp \
AuraController.cpp \
OpenAuraSDK.cpp \
i2c_smbus_linux.cpp
HEADERS += \
i2c_smbus.h \
i2c_smbus_linux.h \
AuraController.h
FORMS +=
-207
View File
@@ -1,207 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{6D22BFF3-C1DF-407A-8816-05D63919A991}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>OpenAuraSDK</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>Dynamic</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.exe</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_AFXDLL</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile />
<PrecompiledHeaderOutputFile />
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="AuraController.h" />
<ClInclude Include="I2CDetectDialog.h" />
<ClInclude Include="i2c_smbus.h" />
<ClInclude Include="i2c_smbus_i801.h" />
<ClInclude Include="i2c_smbus_piix4.h" />
<ClInclude Include="OpenAuraSDK.h" />
<ClInclude Include="OpenAuraSDKDialog.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="wmi.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AuraController.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="I2CDetectDialog.cpp" />
<ClCompile Include="i2c_smbus.cpp" />
<ClCompile Include="i2c_smbus_i801.cpp" />
<ClCompile Include="i2c_smbus_piix4.cpp" />
<ClCompile Include="OpenAuraSDKDialog.cpp" />
<ClCompile Include="wmi.cpp" />
<ClCompile Include="OpenAuraSDK.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
-80
View File
@@ -1,80 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="i2c_smbus.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="i2c_smbus_piix4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="AuraController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="i2c_smbus_i801.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wmi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="OpenAuraSDKDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="OpenAuraSDK.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="I2CDetectDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="OpenAuraSDK.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="i2c_smbus_piix4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="AuraController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="i2c_smbus_i801.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="i2c_smbus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wmi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="OpenAuraSDKDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="I2CDetectDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resource.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
-428
View File
@@ -1,428 +0,0 @@
#include "OpenAuraSDKDialog.h"
#include "OpenAuraSDK.h"
#include "I2CDetectDialog.h"
IMPLEMENT_DYNAMIC(OpenAuraSDKDialog, CDialogEx)
OpenAuraSDKDialog::OpenAuraSDKDialog(std::vector<i2c_smbus_interface *>& bus, std::vector<AuraController *>& control, CWnd* pParent)
: CDialogEx(IDD_DIALOG_OPENAURASDK, pParent), busses(bus), controllers (control)
{
}
OpenAuraSDKDialog::~OpenAuraSDKDialog()
{
}
void OpenAuraSDKDialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(OpenAuraSDKDialog, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_OPENAURASDK_I2CDETECT, &OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkI2cdetect)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_DIRECT_MODE, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkDirectMode)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_MODE, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectMode)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_OFF, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectOff)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_STATIC, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectStatic)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_BREATHING, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectBreathing)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_FLASHING, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectFlashing)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_SPECTRUM_CYCLE, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectSpectrumCycle)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_RAINBOW, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectRainbow)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_BREATHING_SPECTRUM, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkBreathingSpectrum)
ON_BN_CLICKED(IDC_RADIO_OPENAURASDK_EFFECT_CHASE_FADE, &OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectChaseFade)
ON_BN_CLICKED(IDC_BUTTON_OPENAURASDK_SET_COLORS, &OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColors)
ON_CBN_CLOSEUP(IDC_COMBO_OPENAURASDK_DEVICE, &OpenAuraSDKDialog::OnCbnCloseupComboOpenaurasdkDevice)
ON_BN_CLICKED(IDC_BUTTON_OPENAURASDK_SET_COLORS_ALL, &OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColorsAll)
END_MESSAGE_MAP()
BOOL OpenAuraSDKDialog::OnInitDialog()
{
CComboBox* aura_device_box = (CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE);
aura_device_box->AddString("All Devices");
for (int i = 0; i < controllers.size(); i++)
{
aura_device_box->AddString(controllers[i]->GetDeviceName());
}
aura_device_box->SetCurSel(0);
CFont* myFont = new CFont();
myFont->CreateFontA(16, 0, 0, 0, FW_DONTCARE, false, false, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, _T("Consolas"));
return TRUE;
}
void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkI2cdetect()
{
I2CDetectDialog dlg(busses);
dlg.DoModal();
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkDirectMode()
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if ( aura_device == 0)
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetDirect(true);
}
}
else
{
controllers[aura_device - 1]->SetDirect(true);
}
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectMode()
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if (aura_device == 0)
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetDirect(false);
}
}
else
{
controllers[aura_device - 1]->SetDirect(false);
}
}
void OpenAuraSDKDialog::setMode(unsigned char mode_val)
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if (aura_device == 0)
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetMode(mode_val);
}
}
else
{
controllers[aura_device - 1]->SetMode(mode_val);
}
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectOff()
{
setMode(AURA_MODE_OFF);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectStatic()
{
setMode(AURA_MODE_STATIC);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectBreathing()
{
setMode(AURA_MODE_BREATHING);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectFlashing()
{
setMode(AURA_MODE_FLASHING);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectSpectrumCycle()
{
setMode(AURA_MODE_SPECTRUM_CYCLE);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectRainbow()
{
setMode(AURA_MODE_RAINBOW);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkBreathingSpectrum()
{
setMode(AURA_MODE_SPECTRUM_CYCLE_BREATHING);
}
void OpenAuraSDKDialog::OnBnClickedRadioOpenaurasdkEffectChaseFade()
{
setMode(AURA_MODE_CHASE_FADE);
}
void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColors()
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if (aura_device == 0)
{
unsigned char direct = ((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_DIRECT_MODE))->GetCheck();
if (direct == 0)
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetLEDColorEffect( 0,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B) );
controllers[i]->SetLEDColorEffect( 1,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B) );
controllers[i]->SetLEDColorEffect( 2,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B) );
controllers[i]->SetLEDColorEffect( 3,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B) );
controllers[i]->SetLEDColorEffect( 4,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B) );
controllers[i]->SetDirect(false);
}
}
else
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetLEDColorDirect( 0,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B) );
controllers[i]->SetLEDColorDirect( 1,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B) );
controllers[i]->SetLEDColorDirect( 2,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B) );
controllers[i]->SetLEDColorDirect( 3,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B) );
controllers[i]->SetLEDColorDirect( 4,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B) );
controllers[i]->SetDirect(true);
}
}
}
else
{
unsigned char direct = controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_DIRECT);
if (direct == 0)
{
controllers[aura_device - 1]->SetLEDColorEffect( 0,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B) );
controllers[aura_device - 1]->SetLEDColorEffect( 1,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B) );
controllers[aura_device - 1]->SetLEDColorEffect( 2,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B) );
controllers[aura_device - 1]->SetLEDColorEffect( 3,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B) );
controllers[aura_device - 1]->SetLEDColorEffect( 4,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B) );
}
else
{
controllers[aura_device - 1]->SetLEDColorDirect( 0,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B) );
controllers[aura_device - 1]->SetLEDColorDirect( 1,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B) );
controllers[aura_device - 1]->SetLEDColorDirect( 2,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B) );
controllers[aura_device - 1]->SetLEDColorDirect( 3,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B) );
controllers[aura_device - 1]->SetLEDColorDirect( 4,
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B) );
}
}
}
void OpenAuraSDKDialog::OnBnClickedButtonOpenaurasdkSetColorsAll()
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if (aura_device == 0)
{
unsigned char direct = ((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_DIRECT_MODE))->GetCheck();
if (direct == 0)
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetAllColorsEffect(GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B));
controllers[i]->SetDirect(false);
}
}
else
{
for (int i = 0; i < controllers.size(); i++)
{
controllers[i]->SetAllColorsDirect(GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B));
controllers[i]->SetDirect(true);
}
}
}
else
{
unsigned char direct = controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_DIRECT);
if (direct == 0)
{
controllers[aura_device - 1]->SetAllColorsEffect(GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B));
}
else
{
controllers[aura_device - 1]->SetAllColorsDirect(GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G),
GetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B));
}
}
}
void OpenAuraSDKDialog::OnCbnCloseupComboOpenaurasdkDevice()
{
unsigned int aura_device = ((CComboBox*)GetDlgItem(IDC_COMBO_OPENAURASDK_DEVICE))->GetCurSel();
if (aura_device == 0)
{
/*((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_DIRECT_MODE))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_MODE))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_OFF))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_STATIC))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_BREATHING))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_FLASHING))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_SPECTRUM_CYCLE))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_RAINBOW))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_BREATHING_SPECTRUM))->SetCheck(false);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_CHASE_FADE))->SetCheck(false);
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_0_R, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_0_G, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_0_B, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_1_R, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_1_G, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_1_B, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_2_R, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_2_G, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_2_B, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_3_R, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_3_G, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_3_B, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_4_R, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_4_G, "");
SetDlgItemText(IDC_EDIT_OPENAURASDK_LED_4_B, "");*/
}
else
{
unsigned char direct = controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_DIRECT);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_DIRECT_MODE))->SetCheck(direct != 0);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_MODE))->SetCheck(direct == 0);
unsigned char mode = controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_MODE);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_OFF))->SetCheck(mode == AURA_MODE_OFF);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_STATIC))->SetCheck(mode == AURA_MODE_STATIC);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_BREATHING))->SetCheck(mode == AURA_MODE_BREATHING);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_FLASHING))->SetCheck(mode == AURA_MODE_FLASHING);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_SPECTRUM_CYCLE))->SetCheck(mode == AURA_MODE_SPECTRUM_CYCLE);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_RAINBOW))->SetCheck(mode == AURA_MODE_RAINBOW);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_BREATHING_SPECTRUM))->SetCheck(mode == AURA_MODE_SPECTRUM_CYCLE_BREATHING);
((CButton*)GetDlgItem(IDC_RADIO_OPENAURASDK_EFFECT_CHASE_FADE))->SetCheck(mode == AURA_MODE_CHASE_FADE);
if (direct == 0)
{
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 0));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 2));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 1));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 3));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 5));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 4));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 6));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 8));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 7));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 9));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 11));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 10));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 12));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 14));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_EFFECT + 13));
}
else
{
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 0));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 2));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_0_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 1));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 3));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 5));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_1_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 4));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 6));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 8));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_2_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 7));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 9));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 11));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_3_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 10));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_R, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 12));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_G, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 14));
SetDlgItemInt(IDC_EDIT_OPENAURASDK_LED_4_B, controllers[aura_device - 1]->AuraRegisterRead(AURA_REG_COLORS_DIRECT + 13));
}
}
}
-45
View File
@@ -1,45 +0,0 @@
#ifndef OPENAURASDK_DIALOG_H
#define OPENAURASDK_DIALOG_H
#include <afxdialogex.h>
#include <vector>
#include "i2c_smbus.h"
#include "AuraController.h"
#include "resource.h"
class OpenAuraSDKDialog : public CDialogEx
{
DECLARE_DYNAMIC(OpenAuraSDKDialog)
public:
OpenAuraSDKDialog(std::vector<i2c_smbus_interface *>& bus, std::vector<AuraController *>& control, CWnd* pParent = NULL);
virtual ~OpenAuraSDKDialog();
virtual BOOL OnInitDialog();
private:
void setMode(unsigned char mode_val);
protected:
std::vector<i2c_smbus_interface *>& busses;
std::vector<AuraController *>& controllers;
virtual void DoDataExchange(CDataExchange* pDX);
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedButtonOpenaurasdkI2cdetect();
afx_msg void OnBnClickedRadioOpenaurasdkDirectMode();
afx_msg void OnBnClickedRadioOpenaurasdkEffectMode();
afx_msg void OnBnClickedRadioOpenaurasdkEffectOff();
afx_msg void OnBnClickedRadioOpenaurasdkEffectStatic();
afx_msg void OnBnClickedRadioOpenaurasdkEffectBreathing();
afx_msg void OnBnClickedRadioOpenaurasdkEffectFlashing();
afx_msg void OnBnClickedRadioOpenaurasdkEffectSpectrumCycle();
afx_msg void OnBnClickedRadioOpenaurasdkEffectRainbow();
afx_msg void OnBnClickedRadioOpenaurasdkBreathingSpectrum();
afx_msg void OnBnClickedRadioOpenaurasdkEffectChaseFade();
afx_msg void OnBnClickedButtonOpenaurasdkSetColors();
afx_msg void OnCbnCloseupComboOpenaurasdkDevice();
afx_msg void OnBnClickedButtonOpenaurasdkSetColorsAll();
};
#endif
Binary file not shown.
Binary file not shown.
-50
View File
@@ -1,50 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Resource.rc
//
#define IDD_DIALOG_I2C_DETECT 101
#define IDD_DIALOG_OPENAURASDK 103
#define IDC_COMBO_I2C_BUS 1001
#define IDC_BUTTON_I2C_DETECT 1002
#define IDC_EDIT_I2C_DETECT 1003
#define IDC_BUTTON_OPENAURASDK_I2CDETECT 1004
#define IDC_RADIO_OPENAURASDK_DIRECT_MODE 1006
#define IDC_RADIO_OPENAURASDK_EFFECT_MODE 1007
#define IDC_RADIO_OPENAURASDK_EFFECT_STATIC 1008
#define IDC_RADIO_OPENAURASDK_EFFECT_OFF 1009
#define IDC_RADIO_OPENAURASDK_EFFECT_BREATHING 1010
#define IDC_RADIO_OPENAURASDK_EFFECT_FLASHING 1011
#define IDC_RADIO_OPENAURASDK_EFFECT_SPECTRUM_CYCLE 1012
#define IDC_RADIO_OPENAURASDK_EFFECT_RAINBOW 1013
#define IDC_RADIO_OPENAURASDK_BREATHING_SPECTRUM 1014
#define IDC_RADIO_OPENAURASDK_EFFECT_CHASE_FADE 1015
#define IDC_EDIT_OPENAURASDK_LED_0_R 1016
#define IDC_EDIT_OPENAURASDK_LED_0_G 1017
#define IDC_EDIT_OPENAURASDK_LED_0_B 1018
#define IDC_BUTTON_OPENAURASDK_SET_COLORS_ALL 1019
#define IDC_COMBO_OPENAURASDK_DEVICE 1020
#define IDC_EDIT_OPENAURASDK_LED_1_R 1021
#define IDC_EDIT_OPENAURASDK_LED_1_G 1022
#define IDC_EDIT_OPENAURASDK_LED_1_B 1023
#define IDC_EDIT_OPENAURASDK_LED_2_R 1024
#define IDC_EDIT_OPENAURASDK_LED_2_G 1025
#define IDC_EDIT_OPENAURASDK_LED_2_B 1026
#define IDC_EDIT_OPENAURASDK_LED_3_R 1027
#define IDC_EDIT_OPENAURASDK_LED_3_G 1028
#define IDC_EDIT_OPENAURASDK_LED_3_B 1029
#define IDC_EDIT_OPENAURASDK_LED_4_R 1030
#define IDC_EDIT_OPENAURASDK_LED_4_G 1031
#define IDC_EDIT_OPENAURASDK_LED_4_B 1032
#define IDC_BUTTON_OPENAURASDK_SET_COLORS2 1034
#define IDC_BUTTON_OPENAURASDK_SET_COLORS 1034
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1021
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
+134 -214
View File
@@ -1,40 +1,93 @@
/******************************************************************************************\
* *
* OpenAuraSDK.cpp *
* OpenRGB.cpp *
* *
* Functions for communicating with Asus Aura devices on Windows and Linux *
* Functions for communicating with RGBController API devices on Windows and Linux *
* *
\******************************************************************************************/
#include "AuraController.h"
#include "RGBController.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include "OpenAuraSDKDialog.h"
#include "I2CDetectDialog.h"
#ifdef WIN32
#include <regex>
#include "i2c_smbus_piix4.h"
#include "i2c_smbus_i801.h"
#include "i2c_smbus_nct6775.h"
#include "super_io.h"
#include "wmi.h"
#else /* WIN32 */
#include "i2c_smbus_linux.h"
#include <regex>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
#endif /* WIN32 */
std::vector<AuraController *> controllers;
std::vector<i2c_smbus_interface *> busses;
std::vector<i2c_smbus_interface*> busses;
std::vector<RGBController*> rgb_controllers;
#ifdef WIN32
/******************************************************************************************\
* *
* DetectNuvotonI2CBusses (Windows) *
* *
* Detects available Nuvoton Super IO SMBUS adapters and enumerates *
* i2c_smbus_interface objects for them *
* *
\******************************************************************************************/
void DetectNuvotonI2CBusses()
{
i2c_smbus_interface* bus;
int sioaddr = 0x2E;
superio_enter(sioaddr);
int val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) | superio_inb(sioaddr, SIO_REG_DEVID + 1);
switch (val & SIO_ID_MASK)
{
case SIO_NCT5577_ID:
case SIO_NCT6102_ID:
case SIO_NCT6793_ID:
case SIO_NCT6796_ID:
bus = new i2c_smbus_nct6775();
// Set logical device register to get SMBus base address
superio_outb(sioaddr, SIO_REG_LOGDEV, SIO_LOGDEV_SMBUS);
// Get SMBus base address from configuration register
int smba = (superio_inb(sioaddr, SIO_REG_SMBA) << 8) | superio_inb(sioaddr, SIO_REG_SMBA + 1);
((i2c_smbus_nct6775*)bus)->nct6775_smba = smba;
// Set device name string
switch (val & SIO_ID_MASK)
{
case SIO_NCT5577_ID:
sprintf(bus->device_name, "Nuvoton NCT5577D SMBus at %X", smba);
break;
case SIO_NCT6102_ID:
sprintf(bus->device_name, "Nuvoton NCT6102D/NCT6106D SMBus at %X", smba);
break;
case SIO_NCT6793_ID:
sprintf(bus->device_name, "Nuvoton NCT6793D SMBus at %X", smba);
break;
case SIO_NCT6796_ID:
sprintf(bus->device_name, "Nuvoton NCT6796D SMBus at %X", smba);
break;
}
busses.push_back(bus);
}
} /* DetectNuvotonI2CBusses() */
/******************************************************************************************\
* *
* DetectI2CBusses (Windows) *
@@ -86,7 +139,8 @@ void DetectI2CBusses()
// Analysis of many Intel boards has shown that Intel SMBus adapter I/O space varies between boards
// We can query Win32_PnPAllocatedResource entries and look up the PCI device ID to find the allocated I/O space
// Intel SMBus adapters use the i801 driver
else if (i["Manufacturer"].find("Intel") != std::string::npos)
else if ((i["Manufacturer"].find("Intel") != std::string::npos)
|| (i["Manufacturer"].find("INTEL") != std::string::npos))
{
std::string rgx1 = ".+" + q_res_PnPSignedDriver[0]["DeviceID"].substr(4, 33) + ".+";
@@ -113,6 +167,9 @@ void DetectI2CBusses()
}
}
// Detect Nuvoton Super IO SMBus adapters
DetectNuvotonI2CBusses();
} /* DetectI2CBusses() */
#else /* WIN32 */
@@ -135,8 +192,8 @@ void DetectI2CBusses()
struct dirent * ent;
int test_fd;
// Start looking for I2C adapters in /sys/class/i2c-adapter/
strcpy(driver_path, "/sys/class/i2c-adapter/");
// Start looking for I2C adapters in /sys/bus/i2c/devices/
strcpy(driver_path, "/sys/bus/i2c/devices/");
dir = opendir(driver_path);
if(dir == NULL)
@@ -195,217 +252,80 @@ void DetectI2CBusses()
#endif /* WIN32 */
/******************************************************************************************\
* *
* DetectAuraControllers *
* *
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
* at their correct initialized addresses. Also looks for motherboard controller at *
* address 0x4E. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectAuraControllers()
{
AuraController* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Remap Aura-enabled RAM modules on 0x77
for (unsigned int slot = 0; slot < 8; slot++)
{
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
if (res < 0)
{
break;
}
AuraController temp_controller(busses[bus], 0x77);
temp_controller.AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
temp_controller.AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + (slot << 1));
}
// Add Aura-enabled controllers at their remapped addresses
for (unsigned int slot = 0; slot < 8; slot++)
{
int res = busses[bus]->i2c_smbus_write_quick(0x70 + slot, I2C_SMBUS_WRITE);
if (res >= 0)
{
new_controller = new AuraController(busses[bus], 0x70 + slot);
controllers.push_back(new_controller);
}
}
// Check for Aura controller at 0x4E
int res = busses[bus]->i2c_smbus_write_quick(0x4E, I2C_SMBUS_WRITE);
if (res >= 0)
{
new_controller = new AuraController(busses[bus], 0x4E);
controllers.push_back(new_controller);
}
}
} /* DetectAuraControllers() */
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
void DetectRazerChromaSDKControllers(std::vector<RGBController*>& rgb_controllers);
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers);
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
/******************************************************************************************\
* *
* DetectI2C *
* DetectRGBConrollers *
* *
* Prints a list of all detected I2C addresses on the given bus *
* *
* bus - pointer to i2c_smbus_interface to scan *
* mode - one of AUTO, QUICK, READ, FUNC - method of access *
* *
* Code adapted from i2cdetect.c from i2c-tools Linux package *
* Detect and populate RGB Controllers vector *
* *
\******************************************************************************************/
#define MODE_AUTO 0
#define MODE_QUICK 1
#define MODE_READ 2
#define MODE_FUNC 3
std::string DetectI2C(i2c_smbus_interface * bus, int mode)
void DetectRGBControllers(void)
{
int i, j;
int res;
int slave_addr;
char line[128];
std::string text;
freopen("i2cdetect.txt", "a", stdout);
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
text.append(line);
for (i = 0; i < 128; i += 16)
{
sprintf(line, "%02x: ", i);
text.append(line);
for (j = 0; j < 16; j++)
{
/* Set slave address */
slave_addr = i + j;
/* Probe this address */
switch (mode)
{
case MODE_QUICK:
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
break;
case MODE_READ:
res = bus->i2c_smbus_read_byte(slave_addr);
break;
default:
if ((i + j >= 0x30 && i + j <= 0x37)
|| (i + j >= 0x50 && i + j <= 0x5F))
res = bus->i2c_smbus_read_byte(slave_addr);
else
res = bus->i2c_smbus_write_quick(slave_addr, I2C_SMBUS_WRITE);
break;
}
if (res < 0)
{
sprintf(line, "-- ");
text.append(line);
}
else
{
sprintf(line, "%02x ", i + j);
text.append(line);
}
}
sprintf(line, "\r\n");
text.append(line);
}
return text;
} /* DetectI2C() */
/******************************************************************************************\
* *
* DumpAuraRegisters *
* *
* Dumps register values from an Aura device *
* *
\******************************************************************************************/
void DumpAuraRegisters(AuraController * controller)
{
int i, j;
int start = 0x0000;
freopen("auradump.txt", "a", stdout);
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
for (i = 0; i < 0xFFFF; i += 16)
{
printf("%04x: ", i + start);
for (j = 0; j < 16; j++)
{
printf("%02x ", controller->AuraRegisterRead(start + i + j));
}
printf("\r\n");
}
} /* DumpAuraRegisters() */
/******************************************************************************************\
* *
* main/WinMain *
* *
* Main function. Has no defined purpose yet, but is where you can call the other *
* functions in this project to test them out *
* *
* Currently, this program will enumerate all detected SMBus adapters and then detect *
* all attached devices, similar to i2cdetect on Linux *
* *
\******************************************************************************************/
int main()
{
// Colors Array R B G
unsigned char colors[15] = { 255, 0, 0,
0, 255, 0,
0, 0, 255,
255, 0, 255,
255, 255, 255 };
DetectI2CBusses();
DetectAuraControllers();
DetectAuraControllers(busses, rgb_controllers);
DetectCorsairControllers(busses, rgb_controllers);
DetectCorsairProControllers(busses, rgb_controllers);
DetectCrucialControllers(busses, rgb_controllers);
DetectHyperXControllers(busses, rgb_controllers);
DetectPatriotViperControllers(busses, rgb_controllers);
DetectPolychromeControllers(busses, rgb_controllers);
DetectRGBFusionControllers(busses, rgb_controllers);
OpenAuraSDKDialog dlg(busses, controllers);
dlg.DoModal();
DetectLEDStripControllers(rgb_controllers);
DetectHue2Controllers(rgb_controllers);
DetectHuePlusControllers(rgb_controllers);
/*for (unsigned int i = 0; i < controllers.size(); i++)
{
controllers[i]->AuraRegisterWrite(AURA_REG_DIRECT, 1);
controllers[i]->AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
DetectAMDWraithPrismControllers(rgb_controllers);
DetectMSI3ZoneControllers(rgb_controllers);
DetectPoseidonZRGBControllers(rgb_controllers);
DetectHyperXKeyboardControllers(rgb_controllers);
DetectCorsairCmdrProControllers(rgb_controllers);
DetectCorsairKeyboardControllers(rgb_controllers);
DetectCorsairNodeProControllers(rgb_controllers);
DetectThermaltakeRiingControllers(rgb_controllers);
DetectE131Controllers(rgb_controllers);
for (unsigned int i = 0; i < controllers.size(); i++)
{
controllers[i]->AuraRegisterWriteBlock(AURA_REG_COLORS_DIRECT, colors, 15);
}
/*-------------------------------------*\
| Windows-only devices |
\*-------------------------------------*/
#ifdef WIN32
// DetectRazerChromaSDKControllers(rgb_controllers);
DetectAorusGPUControllers(rgb_controllers);
DetectOpenRazerControllers(rgb_controllers);
/*-------------------------------------*\
| Linux-only devices |
\*-------------------------------------*/
#else
DetectOpenRazerControllers(rgb_controllers);
DetectFaustusControllers(rgb_controllers);
#endif
DumpAuraRegisters(controllers[4]);*/
return 1;
}
} /* DetectRGBControllers() */
+1
View File
@@ -0,0 +1 @@
void DetectRGBControllers();
+685
View File
@@ -0,0 +1,685 @@
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 09367fc014c3..25c0e02b3344 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -216,6 +216,15 @@ config I2C_CHT_WC
combined with a FUSB302 Type-C port-controller as such it is advised
to also select CONFIG_TYPEC_FUSB302=m.
+config I2C_NCT6775
+ tristate "Nuvoton NCT6775 and compatible SMBus controller"
+ help
+ If you say yes to this option, support will be included for the
+ Nuvoton NCT6775 and compatible SMBus controllers.
+
+ This driver can also be built as a module. If so, the module
+ will be called i2c-nct6775.
+
config I2C_NFORCE2
tristate "Nvidia nForce2, nForce3 and nForce4"
depends on PCI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 80c23895eaaf..57a2daf0b94e 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_CHT_WC) += i2c-cht-wc.o
obj-$(CONFIG_I2C_I801) += i2c-i801.o
obj-$(CONFIG_I2C_ISCH) += i2c-isch.o
obj-$(CONFIG_I2C_ISMT) += i2c-ismt.o
+obj-$(CONFIG_I2C_NCT6775) += i2c-nct6775.o
obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
obj-$(CONFIG_I2C_NFORCE2_S4985) += i2c-nforce2-s4985.o
obj-$(CONFIG_I2C_NVIDIA_GPU) += i2c-nvidia-gpu.o
diff --git a/drivers/i2c/busses/i2c-nct6775.c b/drivers/i2c/busses/i2c-nct6775.c
new file mode 100644
index 000000000000..e2b491a4b9f6
--- /dev/null
+++ b/drivers/i2c/busses/i2c-nct6775.c
@@ -0,0 +1,617 @@
+/*
+ * i2c-nct6775 - Driver for the SMBus master functionality of
+ * Nuvoton NCT677x Super-I/O chips
+ *
+ * Copyright (C) 2019 Adam Honse <[email protected]>
+ *
+ * Derived from nct6775 hwmon driver
+ * Copyright (C) 2012 Guenter Roeck <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/platform_device.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/ioport.h>
+#include <linux/i2c.h>
+#include <linux/acpi.h>
+#include <linux/bitops.h>
+#include <linux/dmi.h>
+#include <linux/io.h>
+#include <linux/nospec.h>
+
+#define DRVNAME "i2c-nct6775"
+
+/* Nuvoton SMBus address offsets */
+#define SMBHSTDAT (0 + nuvoton_nct6793d_smba)
+#define SMBBLKSZ (1 + nuvoton_nct6793d_smba)
+#define SMBHSTCMD (2 + nuvoton_nct6793d_smba)
+#define SMBHSTIDX (3 + nuvoton_nct6793d_smba) //Index field is the Command field on other controllers
+#define SMBHSTCTL (4 + nuvoton_nct6793d_smba)
+#define SMBHSTADD (5 + nuvoton_nct6793d_smba)
+#define SMBHSTERR (9 + nuvoton_nct6793d_smba)
+#define SMBHSTSTS (0xE + nuvoton_nct6793d_smba)
+
+/* Command register */
+#define NCT6793D_READ_BYTE 0
+#define NCT6793D_READ_WORD 1
+#define NCT6793D_READ_BLOCK 2
+#define NCT6793D_BLOCK_WRITE_READ_PROC_CALL 3
+#define NCT6793D_PROC_CALL 4
+#define NCT6793D_WRITE_BYTE 8
+#define NCT6793D_WRITE_WORD 9
+#define NCT6793D_WRITE_BLOCK 10
+
+/* Control register */
+#define NCT6793D_MANUAL_START 128
+#define NCT6793D_SOFT_RESET 64
+
+/* Error register */
+#define NCT6793D_NO_ACK 32
+
+/* Status register */
+#define NCT6793D_FIFO_EMPTY 1
+#define NCT6793D_FIFO_FULL 2
+#define NCT6793D_MANUAL_ACTIVE 4
+
+#define NCT6775_LD_SMBUS 0x0B
+
+enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793,
+ nct6795, nct6796, nct6798 };
+
+struct nct6775_sio_data {
+ int sioreg;
+ enum kinds kind;
+};
+
+/* used to set data->name = nct6775_device_names[data->sio_kind] */
+static const char * const nct6775_device_names[] = {
+ "nct6106",
+ "nct6775",
+ "nct6776",
+ "nct6779",
+ "nct6791",
+ "nct6792",
+ "nct6793",
+ "nct6795",
+ "nct6796",
+ "nct6798",
+};
+
+static const char * const nct6775_sio_names[] __initconst = {
+ "NCT6106D",
+ "NCT6775F",
+ "NCT6776D/F",
+ "NCT6779D",
+ "NCT6791D",
+ "NCT6792D",
+ "NCT6793D",
+ "NCT6795D",
+ "NCT6796D",
+ "NCT6798D",
+};
+
+#define SIO_REG_LDSEL 0x07 /* Logical device select */
+#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
+#define SIO_REG_SMBA 0x62 /* SMBus base address register */
+
+#define SIO_NCT6106_ID 0xc450
+#define SIO_NCT6775_ID 0xb470
+#define SIO_NCT6776_ID 0xc330
+#define SIO_NCT6779_ID 0xc560
+#define SIO_NCT6791_ID 0xc800
+#define SIO_NCT6792_ID 0xc910
+#define SIO_NCT6793_ID 0xd120
+#define SIO_NCT6795_ID 0xd350
+#define SIO_NCT6796_ID 0xd420
+#define SIO_NCT6798_ID 0xd428
+#define SIO_ID_MASK 0xFFF0
+
+static inline void
+superio_outb(int ioreg, int reg, int val)
+{
+ outb(reg, ioreg);
+ outb(val, ioreg + 1);
+}
+
+static inline int
+superio_inb(int ioreg, int reg)
+{
+ outb(reg, ioreg);
+ return inb(ioreg + 1);
+}
+
+static inline void
+superio_select(int ioreg, int ld)
+{
+ outb(SIO_REG_LDSEL, ioreg);
+ outb(ld, ioreg + 1);
+}
+
+static inline int
+superio_enter(int ioreg)
+{
+ /*
+ * Try to reserve <ioreg> and <ioreg + 1> for exclusive access.
+ */
+ if (!request_muxed_region(ioreg, 2, DRVNAME))
+ return -EBUSY;
+
+ outb(0x87, ioreg);
+ outb(0x87, ioreg);
+
+ return 0;
+}
+
+static inline void
+superio_exit(int ioreg)
+{
+ outb(0xaa, ioreg);
+ outb(0x02, ioreg);
+ outb(0x02, ioreg + 1);
+ release_region(ioreg, 2);
+}
+
+/*
+ * ISA constants
+ */
+
+#define IOREGION_ALIGNMENT (~7)
+#define IOREGION_LENGTH 2
+#define ADDR_REG_OFFSET 0
+#define DATA_REG_OFFSET 1
+
+#define NCT6775_REG_BANK 0x4E
+#define NCT6775_REG_CONFIG 0x40
+
+static struct i2c_adapter *nct6775_adapter;
+
+struct i2c_nct6775_adapdata {
+ unsigned short smba;
+};
+
+/* Return negative errno on error. */
+static s32 nct6775_access(struct i2c_adapter * adap, u16 addr,
+ unsigned short flags, char read_write,
+ u8 command, int size, union i2c_smbus_data * data)
+{
+ struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
+ unsigned short nuvoton_nct6793d_smba = adapdata->smba;
+ int i, len, cnt;
+
+ cnt = 0;
+ len = 0;
+
+ outb_p(NCT6793D_SOFT_RESET, SMBHSTCTL);
+
+ switch (size) {
+ case I2C_SMBUS_QUICK:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ break;
+ case I2C_SMBUS_BYTE:
+ case I2C_SMBUS_BYTE_DATA:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ outb_p(command, SMBHSTIDX);
+ if (read_write == I2C_SMBUS_WRITE) {
+ outb_p(data->byte, SMBHSTDAT);
+ outb_p(NCT6793D_WRITE_BYTE, SMBHSTCMD);
+ }
+ else {
+ outb_p(NCT6793D_READ_BYTE, SMBHSTCMD);
+ }
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ outb_p(command, SMBHSTIDX);
+ if (read_write == I2C_SMBUS_WRITE) {
+ outb_p(data->word & 0xff, SMBHSTDAT);
+ outb_p((data->word & 0xff00) >> 8, SMBHSTDAT);
+ outb_p(NCT6793D_WRITE_WORD, SMBHSTCMD);
+ }
+ else {
+ outb_p(NCT6793D_READ_WORD, SMBHSTCMD);
+ }
+ break;
+ case I2C_SMBUS_BLOCK_DATA:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ outb_p(command, SMBHSTIDX);
+ if (read_write == I2C_SMBUS_WRITE) {
+ len = data->block[0];
+ if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
+ return -EINVAL;
+ outb_p(len, SMBBLKSZ);
+
+ cnt = 1;
+ if (len >= 4) {
+ for (i = cnt; i <= 4; i++) {
+ outb_p(data->block[i], SMBHSTDAT);
+ }
+
+ len -= 4;
+ cnt += 4;
+ }
+ else {
+ for (i = cnt; i <= len; i++ ) {
+ outb_p(data->block[i], SMBHSTDAT);
+ }
+
+ len = 0;
+ }
+
+ outb_p(NCT6793D_WRITE_BLOCK, SMBHSTCMD);
+ }
+ else {
+ return -ENOTSUPP;
+ }
+ break;
+ default:
+ dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ return -EOPNOTSUPP;
+ }
+
+ outb_p(NCT6793D_MANUAL_START, SMBHSTCTL);
+
+ while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0)) {
+ if (read_write == I2C_SMBUS_WRITE) {
+ while ((inb_p(SMBHSTSTS) & NCT6793D_FIFO_EMPTY) == 0);
+
+ //Load more bytes into FIFO
+ if (len >= 4) {
+ for (i = cnt; i <= (cnt + 4); i++) {
+ outb_p(data->block[i], SMBHSTDAT);
+ }
+
+ len -= 4;
+ cnt += 4;
+ }
+ else {
+ for (i = cnt; i <= (cnt + len); i++) {
+ outb_p(data->block[i], SMBHSTDAT);
+ }
+
+ len = 0;
+ }
+ }
+ }
+
+ //wait for manual mode to complete
+ while ((inb_p(SMBHSTSTS) & NCT6793D_MANUAL_ACTIVE) != 0);
+
+ if ((inb_p(SMBHSTERR) & NCT6793D_NO_ACK) != 0) {
+ return -ENXIO;
+ }
+ else if ((read_write == I2C_SMBUS_WRITE) || (size == I2C_SMBUS_QUICK)) {
+ return 0;
+ }
+
+ switch (size) {
+ case I2C_SMBUS_QUICK:
+ case I2C_SMBUS_BYTE_DATA:
+ data->byte = inb_p(SMBHSTDAT);
+ break;
+ case I2C_SMBUS_WORD_DATA:
+ data->word = inb_p(SMBHSTDAT) + (inb_p(SMBHSTDAT) << 8);
+ break;
+ }
+ return 0;
+}
+
+static u32 nct6775_func(struct i2c_adapter *adapter)
+{
+ return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
+ I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
+ I2C_FUNC_SMBUS_BLOCK_DATA;
+}
+
+static const struct i2c_algorithm smbus_algorithm = {
+ .smbus_xfer = nct6775_access,
+ .functionality = nct6775_func,
+};
+
+static int nct6775_add_adapter(unsigned short smba, const char *name, struct i2c_adapter **padap)
+{
+ struct i2c_adapter *adap;
+ struct i2c_nct6775_adapdata *adapdata;
+ int retval;
+
+ adap = kzalloc(sizeof(*adap), GFP_KERNEL);
+ if (adap == NULL) {
+ return -ENOMEM;
+ }
+
+ adap->owner = THIS_MODULE;
+ adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
+ adap->algo = &smbus_algorithm;
+
+ adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL);
+ if (adapdata == NULL) {
+ kfree(adap);
+ return -ENOMEM;
+ }
+
+ adapdata->smba = smba;
+
+ snprintf(adap->name, sizeof(adap->name),
+ "SMBus NCT67xx adapter%s at %04x", name, smba);
+
+ i2c_set_adapdata(adap, adapdata);
+
+ retval = i2c_add_adapter(adap);
+ if (retval) {
+ kfree(adapdata);
+ kfree(adap);
+ return retval;
+ }
+
+ *padap = adap;
+ return 0;
+}
+
+static void nct6775_remove_adapter(struct i2c_adapter *adap)
+{
+ struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
+
+ if (adapdata->smba) {
+ i2c_del_adapter(adap);
+ kfree(adapdata);
+ kfree(adap);
+ }
+}
+
+//static SIMPLE_DEV_PM_OPS(nct6775_dev_pm_ops, nct6775_suspend, nct6775_resume);
+
+/*
+ * when Super-I/O functions move to a separate file, the Super-I/O
+ * bus will manage the lifetime of the device and this module will only keep
+ * track of the nct6775 driver. But since we use platform_device_alloc(), we
+ * must keep track of the device
+ */
+static struct platform_device *pdev[2];
+
+static int nct6775_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct nct6775_sio_data *sio_data = dev_get_platdata(dev);
+ struct resource *res;
+
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
+ DRVNAME))
+ return -EBUSY;
+
+ switch (sio_data->kind) {
+ case nct6791:
+ case nct6792:
+ case nct6793:
+ case nct6795:
+ case nct6796:
+ case nct6798:
+ nct6775_add_adapter(res->start, "", &nct6775_adapter);
+ break;
+ default:
+ return -ENODEV;
+ }
+
+ return 0;
+}
+/*
+static void nct6791_enable_io_mapping(int sioaddr)
+{
+ int val;
+
+ val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE);
+ if (val & 0x10) {
+ pr_info("Enabling hardware monitor logical device mappings.\n");
+ superio_outb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE,
+ val & ~0x10);
+ }
+}*/
+
+static struct platform_driver i2c_nct6775_driver = {
+ .driver = {
+ .name = DRVNAME,
+// .pm = &nct6775_dev_pm_ops,
+ },
+ .probe = nct6775_probe,
+};
+
+static void __exit i2c_nct6775_exit(void)
+{
+ int i;
+
+ if(nct6775_adapter)
+ nct6775_remove_adapter(nct6775_adapter);
+
+ for (i = 0; i < ARRAY_SIZE(pdev); i++) {
+ if (pdev[i])
+ platform_device_unregister(pdev[i]);
+ }
+ platform_driver_unregister(&i2c_nct6775_driver);
+}
+
+/* nct6775_find() looks for a '627 in the Super-I/O config space */
+static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
+{
+ u16 val;
+ int err;
+ int addr;
+
+ err = superio_enter(sioaddr);
+ if (err)
+ return err;
+
+ val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) |
+ superio_inb(sioaddr, SIO_REG_DEVID + 1);
+
+ switch (val & SIO_ID_MASK) {
+ case SIO_NCT6106_ID:
+ sio_data->kind = nct6106;
+ break;
+ case SIO_NCT6775_ID:
+ sio_data->kind = nct6775;
+ break;
+ case SIO_NCT6776_ID:
+ sio_data->kind = nct6776;
+ break;
+ case SIO_NCT6779_ID:
+ sio_data->kind = nct6779;
+ break;
+ case SIO_NCT6791_ID:
+ sio_data->kind = nct6791;
+ break;
+ case SIO_NCT6792_ID:
+ sio_data->kind = nct6792;
+ break;
+ case SIO_NCT6793_ID:
+ sio_data->kind = nct6793;
+ break;
+ case SIO_NCT6795_ID:
+ sio_data->kind = nct6795;
+ break;
+ case SIO_NCT6796_ID:
+ sio_data->kind = nct6796;
+ break;
+ case SIO_NCT6798_ID:
+ sio_data->kind = nct6798;
+ break;
+ default:
+ if (val != 0xffff)
+ pr_debug("unsupported chip ID: 0x%04x\n", val);
+ superio_exit(sioaddr);
+ return -ENODEV;
+ }
+
+ /* We have a known chip, find the SMBus I/O address */
+ superio_select(sioaddr, NCT6775_LD_SMBUS);
+ val = (superio_inb(sioaddr, SIO_REG_SMBA) << 8)
+ | superio_inb(sioaddr, SIO_REG_SMBA + 1);
+ addr = val & IOREGION_ALIGNMENT;
+ if (addr == 0) {
+ pr_err("Refusing to enable a Super-I/O device with a base I/O port 0\n");
+ superio_exit(sioaddr);
+ return -ENODEV;
+ }
+
+ //if (sio_data->kind == nct6791 || sio_data->kind == nct6792 ||
+ // sio_data->kind == nct6793 || sio_data->kind == nct6795 ||
+ // sio_data->kind == nct6796)
+ // nct6791_enable_io_mapping(sioaddr);
+
+ superio_exit(sioaddr);
+ pr_info("Found %s or compatible chip at %#x:%#x\n",
+ nct6775_sio_names[sio_data->kind], sioaddr, addr);
+ sio_data->sioreg = sioaddr;
+
+ return addr;
+}
+
+static int __init i2c_nct6775_init(void)
+{
+ int i, err;
+ bool found = false;
+ int address;
+ struct resource res;
+ struct nct6775_sio_data sio_data;
+ int sioaddr[2] = { 0x2e, 0x4e };
+
+ err = platform_driver_register(&i2c_nct6775_driver);
+ if (err)
+ return err;
+
+ /*
+ * initialize sio_data->kind and sio_data->sioreg.
+ *
+ * when Super-I/O functions move to a separate file, the Super-I/O
+ * driver will probe 0x2e and 0x4e and auto-detect the presence of a
+ * nct6775 hardware monitor, and call probe()
+ */
+ for (i = 0; i < ARRAY_SIZE(pdev); i++) {
+ address = nct6775_find(sioaddr[i], &sio_data);
+ if (address <= 0)
+ continue;
+
+ found = true;
+
+ pdev[i] = platform_device_alloc(DRVNAME, address);
+ if (!pdev[i]) {
+ err = -ENOMEM;
+ goto exit_device_unregister;
+ }
+
+ err = platform_device_add_data(pdev[i], &sio_data,
+ sizeof(struct nct6775_sio_data));
+ if (err)
+ goto exit_device_put;
+
+ memset(&res, 0, sizeof(res));
+ res.name = DRVNAME;
+ res.start = address;
+ res.end = address + IOREGION_LENGTH - 1;
+ res.flags = IORESOURCE_IO;
+
+ err = acpi_check_resource_conflict(&res);
+ if (err) {
+ platform_device_put(pdev[i]);
+ pdev[i] = NULL;
+ continue;
+ }
+
+ err = platform_device_add_resources(pdev[i], &res, 1);
+ if (err)
+ goto exit_device_put;
+
+ /* platform_device_add calls probe() */
+ err = platform_device_add(pdev[i]);
+ if (err)
+ goto exit_device_put;
+ }
+ if (!found) {
+ err = -ENODEV;
+ goto exit_unregister;
+ }
+
+ return 0;
+
+exit_device_put:
+ platform_device_put(pdev[i]);
+exit_device_unregister:
+ while (--i >= 0) {
+ if (pdev[i])
+ platform_device_unregister(pdev[i]);
+ }
+exit_unregister:
+ platform_driver_unregister(&i2c_nct6775_driver);
+ return err;
+}
+
+MODULE_AUTHOR("Adam Honse <[email protected]>");
+MODULE_DESCRIPTION("SMBus driver for NCT6775F and compatible chips");
+MODULE_LICENSE("GPL");
+
+module_init(i2c_nct6775_init);
+module_exit(i2c_nct6775_exit);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index c46c4bddc7ca..8565d08178a2 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -468,11 +468,11 @@ static int piix4_transaction(struct i2c_adapter *piix4_adapter)
if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
usleep_range(2000, 2100);
else
- usleep_range(250, 500);
+ usleep_range(25, 50);
while ((++timeout < MAX_TIMEOUT) &&
((temp = inb_p(SMBHSTSTS)) & 0x01))
- usleep_range(250, 500);
+ usleep_range(25, 50);
/* If the SMBus is still busy, we give up */
if (timeout == MAX_TIMEOUT) {
@@ -963,6 +963,11 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
retval = piix4_setup_sb800(dev, id, 1);
}
+ if (dev->vendor == PCI_VENDOR_ID_AMD &&
+ dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) {
+ retval = piix4_setup_sb800(dev, id, 1);
+ }
+
if (retval > 0) {
/* Try to add the aux adapter if it exists,
* piix4_add_adapter will clean up if this fails */
+269
View File
@@ -0,0 +1,269 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenRGB
TEMPLATE = app
INCLUDEPATH += \
dependencies/libe131/src/ \
i2c_smbus/ \
i2c_tools/ \
net_port/ \
serial_port/ \
super_io/ \
Controllers/AMDWraithPrismController/ \
Controllers/AuraController/ \
Controllers/CorsairController/ \
Controllers/CorsairCmdrProController/ \
Controllers/CorsairKeyboardController/ \
Controllers/CorsairNodeProController/ \
Controllers/CorsairProController/ \
Controllers/CrucialController/ \
Controllers/Hue2Controller/ \
Controllers/HuePlusController/ \
Controllers/HyperXController/ \
Controllers/HyperXKeyboardController/ \
Controllers/LEDStripController/ \
Controllers/MSI3ZoneController/ \
Controllers/PatriotViperController/ \
Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \
Controllers/RGBFusionController/ \
Controllers/RGBFusion2Controller/ \
Controllers/ThermaltakeRiingController/ \
RGBController/ \
qt/
SOURCES += \
dependencies/libe131/src/e131.c \
main.cpp \
OpenRGB.cpp \
qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \
qt/OpenRGBDialog.cpp \
i2c_smbus/i2c_smbus.cpp \
i2c_tools/i2c_tools.cpp \
net_port/net_port.cpp \
qt/OpenRGBDialog2.cpp \
qt/OpenRGBSystemInfoPage.cpp \
qt/hsv.cpp \
serial_port/serial_port.cpp \
super_io/super_io.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
Controllers/AuraController/AuraController.cpp \
Controllers/AuraController/AuraControllerDetect.cpp \
Controllers/CorsairController/CorsairController.cpp \
Controllers/CorsairController/CorsairControllerDetect.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProControllerDetect.cpp \
Controllers/CorsairKeyboardController/CorsairKeyboardController.cpp \
Controllers/CorsairKeyboardController/CorsairKeyboardControllerDetect.cpp \
Controllers/CorsairNodeProController/CorsairNodeProController.cpp \
Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp \
Controllers/CorsairProController/CorsairProController.cpp \
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
Controllers/CrucialController/CrucialController.cpp \
Controllers/CrucialController/CrucialControllerDetect.cpp \
Controllers/Hue2Controller/Hue2Controller.cpp \
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
Controllers/HuePlusController/HuePlusController.cpp \
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
Controllers/HyperXController/HyperXController.cpp \
Controllers/HyperXController/HyperXControllerDetect.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \
Controllers/LEDStripController/LEDStripController.cpp \
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
Controllers/PatriotViperController/PatriotViperController.cpp \
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
Controllers/PolychromeController/PolychromeController.cpp \
Controllers/PolychromeController/PolychromeControllerDetect.cpp \
Controllers/PoseidonZRGBController/PoseidonZRGBController.cpp \
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
Controllers/RGBFusionController/RGBFusionController.cpp \
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
Controllers/RGBFusion2Controller/RGBFusion2Controller.cpp \
Controllers/RGBFusion2Controller/RGBFusion2ControllerDetect.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
RGBController/RGBController.cpp \
RGBController/E131ControllerDetect.cpp \
RGBController/RGBController_AMDWraithPrism.cpp \
RGBController/RGBController_Aura.cpp \
RGBController/RGBController_Corsair.cpp \
RGBController/RGBController_CorsairCmdrPro.cpp \
RGBController/RGBController_CorsairKeyboard.cpp \
RGBController/RGBController_CorsairNodePro.cpp \
RGBController/RGBController_CorsairPro.cpp \
RGBController/RGBController_Crucial.cpp \
RGBController/RGBController_Hue2.cpp \
RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperX.cpp \
RGBController/RGBController_HyperXKeyboard.cpp \
RGBController/RGBController_E131.cpp \
RGBController/RGBController_LEDStrip.cpp \
RGBController/RGBController_MSI3Zone.cpp \
RGBController/RGBController_PatriotViper.cpp \
RGBController/RGBController_Polychrome.cpp \
RGBController/RGBController_PoseidonZRGB.cpp \
RGBController/RGBController_RGBFusion.cpp \
RGBController/RGBController_RGBFusion2.cpp \
RGBController/RGBController_ThermaltakeRiing.cpp \
HEADERS += \
qt/OpenRGBDeviceInfoPage.h \
qt/OpenRGBDevicePage.h \
qt/OpenRGBDialog.h \
i2c_smbus/i2c_smbus.h \
i2c_tools/i2c_tools.h \
net_port/net_port.h \
qt/OpenRGBDialog2.h \
qt/OpenRGBSystemInfoPage.h \
serial_port/find_usb_serial_port.h \
serial_port/serial_port.h \
super_io/super_io.h \
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
Controllers/AuraController/AuraController.h \
Controllers/CorsairController/CorsairController.h \
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
Controllers/CorsairNodeProController/CorsairNodeProController.h \
Controllers/CorsairProController/CorsairProController.h \
Controllers/CrucialController/CrucialController.h \
Controllers/Hue2Controller/Hue2Controller.h \
Controllers/HuePlusController/HuePlusController.h \
Controllers/HyperXController/HyperXController.h \
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
Controllers/LEDStripController/LEDStripController.h \
Controllers/MSI3ZoneController/MSI3ZoneController.h \
Controllers/PatriotViperController/PatriotViperController.h \
Controllers/PolychromeController/PolychromeController.h \
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
Controllers/RGBFusionController/RGBFusionController.h \
Controllers/RGBFusion2Controller/RGBFusion2Controller.h \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
RGBController/RGBController_Aura.h \
RGBController/RGBController_Corsair.h \
RGBController/RGBController_CorsairCmdrPro.h \
RGBController/RGBController_CorsairNodePro.h \
RGBController/RGBController_CorsairPro.h \
RGBController/RGBController_Crucial.h \
RGBController/RGBController_E131.h \
RGBController/RGBController_Hue2.h \
RGBController/RGBController_HuePlus.h \
RGBController/RGBController_HyperX.h \
RGBController/RGBController_HyperXKeyboard.h \
RGBController/RGBController_LEDStrip.h \
RGBController/RGBController_MSI3Zone.h \
RGBController/RGBController_PatriotViper.h \
RGBController/RGBController_Polychrome.h \
RGBController/RGBController_PoseidonZRGB.h \
RGBController/RGBController_RGBFusion.h \
RGBController/RGBController_RGBFusion2.h \
RGBController/RGBController_ThermaltakeRiing.h \
RESOURCES += \
qt/resources.qrc
FORMS += \
qt/OpenRGBDeviceInfoPage.ui \
qt/OpenRGBDevicePage.ui \
qt/OpenRGBDialog.ui \
qt/OpenRGBDialog2.ui \
qt/OpenRGBSystemInfoPage.ui
#-----------------------------------------------
# Windows specific project configuration
#-----------------------------------------------
win32:INCLUDEPATH += \
dependencies/inpout32_1501/Win32/ \
dependencies/razer-chroma-2.9.0/inc \
dependencies/libusb-1.0.22/include \
dependencies/hidapi \
dependencies/openrazer-win32 \
wmi/ \
win32:SOURCES += \
i2c_smbus/i2c_smbus_i801.cpp \
i2c_smbus/i2c_smbus_nct6775.cpp \
i2c_smbus/i2c_smbus_piix4.cpp \
serial_port/find_usb_serial_port_win.cpp \
wmi/wmi.cpp \
RGBController/AorusGPUDetect.cpp \
RGBController/OpenRazerWindowsDetect.cpp \
RGBController/RGBController_AorusGPU.cpp \
RGBController/RGBController_OpenRazerWindows.cpp \
# RGBController/RazerChromaSDKDetect.cpp \
# RGBController/RGBController_RazerChromaSDK.cpp \
win32:HEADERS += \
dependencies/inpout32_1501/Win32/inpout32.h \
i2c_smbus/i2c_smbus_i801.h \
i2c_smbus/i2c_smbus_nct6775.h \
i2c_smbus/i2c_smbus_piix4.h \
wmi/wmi.h \
RGBController/RGBController_AorusGPU.h \
RGBController/RGBController_OpenRazerWindows.h \
# RGBController/RGBController_RazerChromaSDK.h \
win32:LIBS += \
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
win32:DEFINES -= \
UNICODE
win32:DEFINES += \
_MBCS \
WIN32 \
_CRT_SECURE_NO_WARNINGS \
_WINSOCK_DEPRECATED_NO_WARNINGS \
WIN32_LEAN_AND_MEAN
# Copy OpenRazer.dll to output directory
win32
{
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer.dll)\" \"$$shell_path($$OUT_PWD)\"
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
}
#-----------------------------------------------
# Linux specific project configuration
#-----------------------------------------------
unix:INCLUDEPATH += \
unix:HEADERS += \
i2c_smbus/i2c_smbus_linux.h \
RGBController/RGBController_Faustus.h \
unix:LIBS += \
-lusb-1.0 \
packagesExist(hidapi-libusb){
unix:LIBS += -lhidapi-libusb
} else {
packagesExist(hidapi) {
unix:LIBS += -lhidapi
} else {
unix:LIBS += -lhidapi-libusb
}
}
unix:SOURCES += \
i2c_smbus/i2c_smbus_linux.cpp \
serial_port/find_usb_serial_port_linux.cpp \
RGBController/OpenRazerDetect.cpp \
RGBController/RGBController_Faustus.cpp \
RGBController/RGBController_OpenRazer.cpp \
+56
View File
@@ -0,0 +1,56 @@
# OpenRGB (formerly OpenAuraSDK)
The goal of this project is to create an easy-to-use open source software program and library for accessing and controlling RGB lights on various PC hardware including motherboards, RAM modules, graphics cards, cooling devices, and peripherals.
This project originally focused only on ASUS Aura. It was spun off of Keyboard Visualizer's AsusAuraWindows branch to learn more about the details behind the Aura protocol and to develop a more flexible, compatible, and reliable driver for Aura. Our Aura implementation is now quite solid and supports multiple generations of Aura controller across both Intel and AMD platforms. It also supports Aura-compatible controllers used across multiple manufacturers of RGB memory modules including G.Skill Trident Z RGB and others. It is still lacking a few capabilities, namely saving settings to persist across reboots, but the core functionality of setting colors and modes is there.
After getting a solid Aura implementation, the project branched out into other manufacturers and categories of RGB devices. A major focus was to develop a software API that could reliably represent as many RGB devices as possible, exposing their various modes and describing their LED layouts via zones, that was generic enough to write a user application without specifically targeting any one manufacturer. To this extent, the generic_rgb_interface_test branch was created which became the foundation of OpenRGB. The goal of OpenRGB is to both develop new drivers for unsupported devices and integrate existing open source drivers for devices that do have some sort of open support. The goal is to be the one-stop solution to open source RGB lighting control!
## Supported Devices
See the [Project Wiki](https://gitlab.com/CalcProgrammer1/OpenRGB/-/wikis/home) for the current list of supported devices.
## Installation
#### Windows
1. Download the latest Visual Studio Community Edition and Qt Creator.
2. Update the submodules: git submodule update --init --recursive
3. Open the OpenRGB_Win.pro project.
4. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
5. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe along with the Qt libraries.
**You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
#### Linux:
1. Either open the project using QT Creator or build it using qmake. You will need the libusb-1.0-0 (or equivalent) and libhidapi development packages from your distribution's package manager installed.
* sudo apt install qt5-default libusb-1.0-0-dev libhidapi-dev
* git clone https://gitlab.com/CalcProgrammer1/OpenRGB
* cd OpenRGB
* git submodule update --init --recursive
* qmake OpenRGB.pro
* make -j8
* ./OpenRGB
2. Allow access to SMBus:<br>
- This can be identified by your motherboard
##### Intel
- `modprobe i2c-dev i2c-i801`
- Asus used the SMBus controller on the Super IO chip for on-board Aura chips on Intel motherboards. I have a kernel patch to add a driver for this chip [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/22). After patching the kernel, enable the Nuvoton NCT67xx SMBus driver in your kernel configuration. The driver may be loaded with `modprobe i2c-nct6775`
##### AMD
- `modprobe i2c-dev i2c-piix4`
- The second SMBus isn't currently picked up by the kernel driver and that seems to be where Asus wired the Aura controllers so I have a kernel patch [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/9) that will allow the kernel to use the second bus (at `0x0b20`).
- You'll have to enable user access to your SMbus if you don't run as root.
- List all SMBus controllers: `sudo i2cdetect -l`
- Find out which control your Aura devices (PIIX4, I801, and NCT67xx)
- Give user access to those controllers, for instance: `sudo chmod 777 /dev/i2c-0`
+21
View File
@@ -0,0 +1,21 @@
#include "RGBController.h"
#include "RGBController_AorusGPU.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* DetectAorusGPUControllers *
* *
* Detect devices supported by the Aorus GPU driver *
* * *
\******************************************************************************************/
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers)
{
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
rgb_controllers.push_back(aorus_rgb);
} /* DetectLEDStripControllers() */
+172
View File
@@ -0,0 +1,172 @@
#include "RGBController.h"
#include "RGBController_E131.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <fstream>
#include <iostream>
#include <string>
#ifndef WIN32
#include <unistd.h>
#include <dirent.h>
#else
#include <windows.h>
#endif
#ifndef WIN32
#define LPSTR char *
#define strtok_s strtok_r
#endif
/******************************************************************************************\
* *
* DetectE131Controllers *
* *
* Detect devices supported by the E131 driver *
* * *
\******************************************************************************************/
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
{
RGBController_E131* 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, "\\e131.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, "/e131.txt");
#endif
E131Device dev;
std::vector<E131Device> devices;
bool new_device = false;
//Open settings file
infile.open(filename);
if (infile.good())
{
for (std::string line; std::getline(infile, line); )
{
if (new_device)
{
dev.name = line;
new_device = false;
}
if (line == "")
{
continue;
}
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
{
char * argument;
char * value;
value = (char *)line.c_str();
argument = strtok_s(value, "=", &value);
//Strip off new line characters if present
argument = strtok(argument, "\r\n");
value = strtok(value, "\r\n");
if(argument)
{
if (strcmp(argument, "e131_device_start") == 0)
{
new_device = true;
}
else if(strcmp(argument, "num_leds") == 0)
{
dev.num_leds = atoi(value);
}
else if(strcmp(argument, "start_universe") == 0)
{
dev.start_universe = atoi(value);
}
else if(strcmp(argument, "start_channel") == 0)
{
dev.start_channel = atoi(value);
}
else if(strcmp(argument, "rgb_order") == 0)
{
if(strcmp(value, "RGB") == 0)
{
dev.rgb_order = E131_RGB_ORDER_RGB;
}
else if(strcmp(value, "RBG") == 0)
{
dev.rgb_order = E131_RGB_ORDER_RBG;
}
else if(strcmp(value, "GRB") == 0)
{
dev.rgb_order = E131_RGB_ORDER_GRB;
}
else if(strcmp(value, "GBR") == 0)
{
dev.rgb_order = E131_RGB_ORDER_GBR;
}
else if(strcmp(value, "BRG") == 0)
{
dev.rgb_order = E131_RGB_ORDER_BRG;
}
else if(strcmp(value, "BGR") == 0)
{
dev.rgb_order = E131_RGB_ORDER_BGR;
}
else
{
dev.rgb_order = atoi(value);
}
}
else if(strcmp(argument, "type") == 0)
{
if(strcmp(value, "SINGLE") == 0)
{
dev.type = ZONE_TYPE_SINGLE;
}
else if(strcmp(value, "LINEAR") == 0)
{
dev.type = ZONE_TYPE_LINEAR;
}
else if(strcmp(value, "MATRIX") == 0)
{
dev.type = ZONE_TYPE_MATRIX;
}
else
{
dev.type = atoi(value);
}
}
else if(strcmp(argument, "e131_device_end") == 0)
{
devices.push_back(dev);
}
}
}
}
if(devices.size() > 0)
{
new_controller = new RGBController_E131(devices);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectE131Controllers() */
+125
View File
@@ -0,0 +1,125 @@
#include "RGBController.h"
#include "RGBController_OpenRazer.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
/******************************************************************************************\
* *
* DetectOpenRazerControllers *
* *
* Detect devices supported by the OpenRazer kernel drivers *
* * *
\******************************************************************************************/
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
{
char driver_path[512];
DIR *dir;
struct dirent *ent;
bool done = false;
int driver_to_read = 0;
while(driver_to_read < 8)
{
switch(driver_to_read)
{
case 0:
strcpy(driver_path, "/sys/bus/hid/drivers/razerkbd/");
break;
case 1:
strcpy(driver_path, "/sys/bus/hid/drivers/razermouse/");
break;
case 2:
strcpy(driver_path, "/sys/bus/hid/drivers/razerfirefly/");
break;
case 3:
strcpy(driver_path, "/sys/bus/hid/drivers/razermug/");
break;
case 4:
strcpy(driver_path, "/sys/bus/hid/drivers/razercore/");
break;
case 5:
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
break;
case 6:
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
break;
case 7:
strcpy(driver_path, "/sys/bus/hid/drivers/razeraccessory/");
break;
}
done = false;
dir = opendir(driver_path);
if(dir == NULL)
{
closedir(dir);
driver_to_read++;
continue;
}
ent = readdir(dir);
while(ent != NULL)
{
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
{
if(!strcmp(ent->d_name, "."))
{
if(done == false)
{
done = true;
}
else
{
break;
}
}
else if(!strcmp(ent->d_name, "..") || !strcmp(ent->d_name, "module"))
{
}
else
{
char device_string[1024];
strcpy(device_string, driver_path);
strcat(device_string, ent->d_name);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
}
ent = readdir(dir);
}
closedir(dir);
driver_to_read++;
}
} /* DetectOpenRazerControllers() */
File diff suppressed because it is too large Load Diff
+387
View File
@@ -0,0 +1,387 @@
#include "RGBController.h"
#include "RGBController_OpenRazerWindows.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/hid.h>
#ifdef _WIN64
#define OPENRAZERDLL "OpenRazer64.dll"
#elif WIN32
#define OPENRAZERDLL "OpenRazer.dll"
#endif
/******************************************************************************************\
* *
* DetectOpenRazerControllers *
* *
* Detect devices supported by the OpenRazer kernel drivers *
* *
\******************************************************************************************/
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
{
static HMODULE module = LoadLibrary(OPENRAZERDLL);
if(module == nullptr)
{
return;
}
// map DLL calls
typedef unsigned int(*INITRAZERDRIVER)(struct hid_device** hdev);
INITRAZERDRIVER init_razer_kbd_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kbd_driver"));
static struct device_attribute devkbd_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_type"));
static struct device_attribute devkbd_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_device_serial"));
static struct device_attribute devkbd_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_firmware_version"));
static struct device_attribute devkbd_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_custom"));
static struct device_attribute devkbd_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_custom_frame"));
static struct device_attribute devkbd_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_brightness"));
static struct device_attribute devkbd_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_none"));
static struct device_attribute devkbd_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_static"));
static struct device_attribute devkbd_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_breath"));
static struct device_attribute devkbd_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_spectrum"));
static struct device_attribute devkbd_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_reactive"));
static struct device_attribute devkbd_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkbd_attr_matrix_effect_wave"));
INITRAZERDRIVER init_razer_mousemat_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mousemat_driver"));
static struct device_attribute devmousemat_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_type"));
static struct device_attribute devmousemat_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_device_serial"));
static struct device_attribute devmousemat_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_firmware_version"));
static struct device_attribute devmousemat_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_custom"));
static struct device_attribute devmousemat_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_custom_frame"));
static struct device_attribute devmousemat_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_brightness"));
static struct device_attribute devmousemat_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_none"));
static struct device_attribute devmousemat_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_static"));
static struct device_attribute devmousemat_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_breath"));
static struct device_attribute devmousemat_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_spectrum"));
static struct device_attribute devmousemat_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_reactive"));
static struct device_attribute devmousemat_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmousemat_attr_matrix_effect_wave"));
INITRAZERDRIVER init_razer_mouse_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mouse_driver"));
static struct device_attribute devmouse_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_type"));
static struct device_attribute devmouse_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_device_serial"));
static struct device_attribute devmouse_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_firmware_version"));
static struct device_attribute devmouse_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_custom"));
static struct device_attribute devmouse_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_custom_frame"));
static struct device_attribute devmouse_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_brightness"));
static struct device_attribute devmouse_attr_logo_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_led_brightness"));
static struct device_attribute devmouse_attr_scroll_led_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_brightness"));
static struct device_attribute devmouse_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_none"));
static struct device_attribute devmouse_attr_logo_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_none"));
static struct device_attribute devmouse_attr_scroll_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_none"));
static struct device_attribute devmouse_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_static"));
static struct device_attribute devmouse_attr_logo_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_static"));
static struct device_attribute devmouse_attr_scroll_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_static"));
static struct device_attribute devmouse_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_breath"));
static struct device_attribute devmouse_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_spectrum"));
static struct device_attribute devmouse_attr_logo_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_spectrum"));
static struct device_attribute devmouse_attr_scroll_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_spectrum"));
static struct device_attribute devmouse_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_reactive"));
static struct device_attribute devmouse_attr_logo_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_logo_matrix_effect_reactive"));
static struct device_attribute devmouse_attr_scroll_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_matrix_effect_reactive"));
static struct device_attribute devmouse_attr_scroll_led_effect = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_effect"));
static struct device_attribute devmouse_attr_scroll_led_rgb = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_rgb"));
static struct device_attribute devmouse_attr_scroll_led_state = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_scroll_led_state"));
static struct device_attribute devmouse_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devmouse_attr_matrix_effect_wave"));
INITRAZERDRIVER init_razer_accessory_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_accessory_driver"));
static struct device_attribute devaccessory_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_type"));
static struct device_attribute devaccessory_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_device_serial"));
static struct device_attribute devaccessory_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_firmware_version"));
static struct device_attribute devaccessory_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_custom"));
static struct device_attribute devaccessory_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_custom_frame"));
static struct device_attribute devaccessory_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_brightness"));
static struct device_attribute devaccessory_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_none"));
static struct device_attribute devaccessory_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_static"));
static struct device_attribute devaccessory_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_breath"));
static struct device_attribute devaccessory_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_spectrum"));
//static struct device_attribute devaccessory_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_reactive"));
static struct device_attribute devaccessory_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devaccessory_attr_matrix_effect_wave"));
INITRAZERDRIVER init_razer_kraken_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kraken_driver"));
static struct device_attribute devkraken_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_type"));
static struct device_attribute devkraken_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_device_serial"));
static struct device_attribute devkraken_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_firmware_version"));
static struct device_attribute devkraken_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_custom"));
//static struct device_attribute devkraken_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_custom_frame"));
//static struct device_attribute devkraken_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_brightness"));
static struct device_attribute devkraken_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_none"));
static struct device_attribute devkraken_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_static"));
static struct device_attribute devkraken_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_breath"));
static struct device_attribute devkraken_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devkraken_attr_matrix_effect_spectrum"));
INITRAZERDRIVER init_razer_core_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_core_driver"));
static struct device_attribute devcore_attr_device_type = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_type"));
static struct device_attribute devcore_attr_device_serial = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_device_serial"));
static struct device_attribute devcore_attr_firmware_version = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_firmware_version"));
static struct device_attribute devcore_attr_matrix_effect_custom = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_custom"));
static struct device_attribute devcore_attr_matrix_custom_frame = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_custom_frame"));
static struct device_attribute devcore_attr_matrix_brightness = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_brightness"));
static struct device_attribute devcore_attr_matrix_effect_none = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_none"));
static struct device_attribute devcore_attr_matrix_effect_static = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_static"));
static struct device_attribute devcore_attr_matrix_effect_breath = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_breath"));
static struct device_attribute devcore_attr_matrix_effect_spectrum = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_spectrum"));
static struct device_attribute devcore_attr_matrix_effect_reactive = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_reactive"));
static struct device_attribute devcore_attr_matrix_effect_wave = *(struct device_attribute*)reinterpret_cast<void*>(GetProcAddress(module, "devcore_attr_matrix_effect_wave"));
struct hid_device* hdev;
unsigned int num;
hdev = NULL;
num = init_razer_kbd_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devkbd_attr_device_type;
device_fn->device_serial = &devkbd_attr_device_serial;
device_fn->firmware_version = &devkbd_attr_firmware_version;
device_fn->matrix_effect_custom = &devkbd_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devkbd_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devkbd_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkbd_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkbd_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkbd_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkbd_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devkbd_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devkbd_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
hdev = NULL;
num = init_razer_mouse_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devmouse_attr_device_type;
device_fn->device_serial = &devmouse_attr_device_serial;
device_fn->firmware_version = &devmouse_attr_firmware_version;
device_fn->matrix_effect_custom = &devmouse_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmouse_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmouse_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmouse_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmouse_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmouse_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmouse_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmouse_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmouse_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
hdev = NULL;
num = init_razer_mousemat_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devmousemat_attr_device_type;
device_fn->device_serial = &devmousemat_attr_device_serial;
device_fn->firmware_version = &devmousemat_attr_firmware_version;
device_fn->matrix_effect_custom = &devmousemat_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmousemat_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmousemat_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmousemat_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmousemat_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmousemat_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmousemat_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmousemat_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmousemat_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
hdev = NULL;
num = init_razer_accessory_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devaccessory_attr_device_type;
device_fn->device_serial = &devaccessory_attr_device_serial;
device_fn->firmware_version = &devaccessory_attr_firmware_version;
device_fn->matrix_effect_custom = &devaccessory_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devaccessory_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devaccessory_attr_matrix_brightness;
device_fn->matrix_effect_none = &devaccessory_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devaccessory_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devaccessory_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devaccessory_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devaccessory_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devaccessory_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
hdev = NULL;
num = init_razer_kraken_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devkraken_attr_device_type;
device_fn->device_serial = &devkraken_attr_device_serial;
device_fn->firmware_version = &devkraken_attr_firmware_version;
device_fn->matrix_effect_custom = &devkraken_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = NULL;//&devkraken_attr_matrix_custom_frame;
device_fn->matrix_brightness = NULL;//&devkraken_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkraken_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkraken_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkraken_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkraken_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devkraken_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = NULL;//&devkraken_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
hdev = NULL;
num = init_razer_core_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devcore_attr_device_type;
device_fn->device_serial = &devcore_attr_device_serial;
device_fn->firmware_version = &devcore_attr_firmware_version;
device_fn->matrix_effect_custom = &devcore_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devcore_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devcore_attr_matrix_brightness;
device_fn->matrix_effect_none = &devcore_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devcore_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devcore_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devcore_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devcore_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devcore_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}
else
{
delete razer_rgb;
}
}
} /* DetectOpenRazerControllers() */
+58
View File
@@ -0,0 +1,58 @@
#include "RGBController.h"
RGBColor RGBController::GetLED(int led)
{
if(led < colors.size())
{
return(colors[led]);
}
else
{
return(0x00000000);
}
}
void RGBController::SetLED(int led, RGBColor color)
{
if(led < colors.size())
{
colors[led] = color;
UpdateSingleLED(led);
}
}
void RGBController::SetAllLEDs(RGBColor color)
{
for(int led = 0; led < colors.size(); led++)
{
colors[led] = color;
}
UpdateLEDs();
}
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
colors[zones[zone].map[x][y]] = color;
}
}
UpdateZoneLEDs(zone);
}
int RGBController::GetMode()
{
return(active_mode);
}
void RGBController::SetMode(int mode)
{
active_mode = mode;
UpdateMode();
}
+148
View File
@@ -0,0 +1,148 @@
/*-----------------------------------------*\
| RGBController.h |
| |
| Definitions and types for generic RGB |
| lighting controller interface |
| |
| Adam Honse (CalcProgrammer1) 6/2/2019 |
\*-----------------------------------------*/
#pragma once
#include <vector>
#include <string>
typedef unsigned int RGBColor;
#define RGBGetRValue(rgb) (rgb & 0x000000FF)
#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF)
#define RGBGetBValue(rgb) ((rgb >> 16) & 0x000000FF)
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
/*------------------------------------------------------------------*\
| Mode Flags |
\*------------------------------------------------------------------*/
enum
{
MODE_FLAG_HAS_SPEED = (1 << 0), /* Mode has speed parameter */
MODE_FLAG_HAS_DIRECTION_LR = (1 << 1), /* Mode has left/right parameter */
MODE_FLAG_HAS_DIRECTION_UD = (1 << 2), /* Mode has up/down parameter */
MODE_FLAG_HAS_DIRECTION_HV = (1 << 3), /* Mode has horiz/vert parameter */
MODE_FLAG_HAS_BRIGHTNESS = (1 << 4), /* Mode has brightness parameter */
MODE_FLAG_HAS_COLOR = (1 << 5), /* Mode has custom color parameter */
MODE_FLAG_RANDOM_COLOR = (1 << 6), /* Mode has random color option */
MODE_FLAG_PER_LED_COLOR = (1 << 7), /* Mode uses device LED colors */
};
/*------------------------------------------------------------------*\
| Mode Directions |
\*------------------------------------------------------------------*/
enum
{
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
MODE_DIRECTION_UP = 2, /* Mode direction up */
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
};
/*------------------------------------------------------------------*\
| Mode Type |
\*------------------------------------------------------------------*/
typedef struct
{
/*--------------------------------------------------------------*\
| Mode Information |
\*--------------------------------------------------------------*/
std::string name; /* Mode name */
int value; /* Device-specific mode value */
unsigned int flags; /* Mode flags bitfield */
unsigned int speed_min; /* speed minimum value */
unsigned int speed_max; /* speed maximum value */
/*--------------------------------------------------------------*\
| Mode Settings |
\*--------------------------------------------------------------*/
unsigned int speed; /* Mode speed parameter value */
unsigned int direction; /* Mode direction value */
bool random; /* Random color mode enabled */
} mode;
typedef struct
{
std::string name; /* LED name */
} led;
typedef int zone_type;
enum
{
ZONE_TYPE_SINGLE,
ZONE_TYPE_LINEAR,
ZONE_TYPE_MATRIX
};
typedef int device_type;
enum
{
DEVICE_TYPE_MOTHERBOARD,
DEVICE_TYPE_DRAM,
DEVICE_TYPE_GPU,
DEVICE_TYPE_COOLER,
DEVICE_TYPE_LEDSTRIP,
DEVICE_TYPE_KEYBOARD,
DEVICE_TYPE_MOUSE,
DEVICE_TYPE_MOUSEMAT,
DEVICE_TYPE_HEADSET,
DEVICE_TYPE_UNKNOWN
};
typedef struct
{
std::string name; /* Zone name */
zone_type type; /* Zone type */
std::vector<std::vector<int>>
map; /* LED index map */
} zone;
class RGBController
{
public:
std::string name; /* controller name */
std::string description; /* controller description */
std::string version; /* controller version */
std::string serial; /* controller serial number */
std::string location; /* controller location */
std::vector<led> leds; /* LEDs */
std::vector<zone> zones; /* Zones */
std::vector<mode> modes; /* Modes */
std::vector<RGBColor> colors; /* Color buffer */
device_type type; /* device type */
int active_mode = 0;/* active mode */
virtual ~RGBController() = default;
/*---------------------------------------------------------*\
| Generic functions implemented in RGBController.cpp |
\*---------------------------------------------------------*/
RGBColor GetLED(int led);
void SetLED(int led, RGBColor color);
void SetAllLEDs(RGBColor color);
void SetAllZoneLEDs(int zone, RGBColor color);
int GetMode();
void SetMode(int mode);
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
virtual void UpdateLEDs() = 0;
virtual void UpdateZoneLEDs(int zone) = 0;
virtual void UpdateSingleLED(int led) = 0;
virtual void SetCustomMode() = 0;
virtual void UpdateMode() = 0;
};
@@ -0,0 +1,214 @@
/*-----------------------------------------*\
| RGBController_AMDWraithPrism.cpp |
| |
| Generic RGB Interface for AMD Wraith |
| Prism |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#include "RGBController_AMDWraithPrism.h"
RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr)
{
wraith = wraith_ptr;
name = "AMD Wraith Prism";
type = DEVICE_TYPE_COOLER;
version = wraith->GetFirmwareVersionString();
mode Static;
Static.name = "Static";
Static.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_STATIC;
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
Static.random = false;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
Breathing.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Breathing.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Breathing.random = false;
Breathing.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Breathing);
mode ColorCycle;
ColorCycle.name = "Color Cycle";
ColorCycle.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE;
ColorCycle.flags = MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
ColorCycle.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
ColorCycle.random = false;
ColorCycle.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(ColorCycle);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Rainbow.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Rainbow.random = false;
Rainbow.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Rainbow);
mode Bounce;
Bounce.name = "Bounce";
Bounce.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE;
Bounce.flags = MODE_FLAG_HAS_SPEED;
Bounce.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Bounce.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Bounce.random = true;
Bounce.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Bounce);
mode Chase;
Chase.name = "Chase";
Chase.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_CHASE;
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
Chase.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Chase.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Chase.random = false;
Chase.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Chase);
mode Swirl;
Swirl.name = "Swirl";
Swirl.value = AMD_WRAITH_PRISM_EFFECT_CHANNEL_SWIRL;
Swirl.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR | MODE_FLAG_RANDOM_COLOR;
Swirl.speed_min = AMD_WRAITH_PRISM_SPEED_SLOWEST;
Swirl.speed_max = AMD_WRAITH_PRISM_SPEED_FASTEST;
Swirl.random = false;
Swirl.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Swirl);
led logo_led;
logo_led.name = "Logo";
leds.push_back(logo_led);
colors.push_back(0x00000000);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> logo_zone_map;
logo_zone_map.push_back(0);
logo_zone.map.push_back(logo_zone_map);
zones.push_back(logo_zone);
led fan_led;
fan_led.name = "Fan";
leds.push_back(fan_led);
colors.push_back(0x00000000);
zone fan_zone;
fan_zone.name = "Fan";
fan_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> fan_zone_map;
fan_zone_map.push_back(1);
fan_zone.map.push_back(fan_zone_map);
zones.push_back(fan_zone);
led ring_led;
ring_led.name = "Ring";
leds.push_back(ring_led);
colors.push_back(0x00000000);
zone ring_zone;
ring_zone.name = "Ring";
ring_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> ring_zone_map;
ring_zone_map.push_back(2);
ring_zone.map.push_back(ring_zone_map);
zones.push_back(ring_zone);
}
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
{
}
void RGBController_AMDWraithPrism::UpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
wraith->SetLogoColor(red, grn, blu);
red = RGBGetRValue(colors[1]);
grn = RGBGetGValue(colors[1]);
blu = RGBGetBValue(colors[1]);
wraith->SetFanColor(red, grn, blu);
red = RGBGetRValue(colors[2]);
grn = RGBGetGValue(colors[2]);
blu = RGBGetBValue(colors[2]);
wraith->SetRingColor(red, grn, blu);
}
void RGBController_AMDWraithPrism::UpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(zone == 0)
{
wraith->SetLogoColor(red, grn, blu);
}
else if(zone == 1)
{
wraith->SetFanColor(red, grn, blu);
}
else if(zone == 2)
{
wraith->SetRingColor(red, grn, blu);
}
}
void RGBController_AMDWraithPrism::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_AMDWraithPrism::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AMDWraithPrism::UpdateMode()
{
wraith->SetRingMode(modes[active_mode].value, modes[active_mode].speed, modes[active_mode].direction, modes[active_mode].random);
switch(modes[active_mode].value)
{
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_COLOR_CYCLE:
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_RAINBOW:
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BOUNCE:
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
break;
case AMD_WRAITH_PRISM_EFFECT_CHANNEL_BREATHING:
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_BREATHING, modes[active_mode].speed, modes[active_mode].random);
break;
default:
if(modes[active_mode].random)
{
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_COLOR_CYCLE, modes[active_mode].speed, modes[active_mode].random);
}
else
{
wraith->SetFanMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].random);
wraith->SetLogoMode(AMD_WRAITH_PRISM_FAN_LOGO_MODE_STATIC, modes[active_mode].speed, modes[active_mode].random);
}
break;
}
UpdateLEDs();
}
@@ -0,0 +1,28 @@
/*-----------------------------------------*\
| RGBController_AMDWraithPrism.h |
| |
| Generic RGB Interface for AMD Wraith |
| Prism |
| |
| Adam Honse (CalcProgrammer1) 12/25/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AMDWraithPrismController.h"
class RGBController_AMDWraithPrism : public RGBController
{
public:
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
~RGBController_AMDWraithPrism();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
AMDWraithPrismController* wraith;
};
+83
View File
@@ -0,0 +1,83 @@
/*-----------------------------------------*\
| RGBController_AorusGPU.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Aorus GPU |
| |
| Adam Honse (CalcProgrammer1) 6/17/2019 |
\*-----------------------------------------*/
#include "RGBController_AorusGPU.h"
#include <Windows.h>
static HMODULE handle;
static unsigned char data[] = { 0x8E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x64, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00 };
void RGBController_AorusGPU::UpdateLEDs()
{
RGBColor color = colors[0];
data[9] = RGBGetRValue(color);
data[10] = RGBGetGValue(color);
data[11] = RGBGetBValue(color);
GvWriteI2C(0x00000000, data, 0x00000000);
}
void RGBController_AorusGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AorusGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_AorusGPU::RGBController_AorusGPU()
{
name = "Aorus GPU";
type = DEVICE_TYPE_GPU;
handle = LoadLibrary("GvDisplay.dll");
GvWriteI2C = (_GvWriteI2C)GetProcAddress(handle, "GvWriteI2C");
GvFreeDispLib = (_GvFreeDispLib)GetProcAddress(handle, "GvFreeDispLib");
GvInitDispLib = (_GvInitDispLib)GetProcAddress(handle, "GvInitDispLib");
GvFreeDispLib();
GvInitDispLib();
colors.push_back(0x00000000);
mode aorus_mode;
aorus_mode.name = "Static";
modes.push_back(aorus_mode);
led aorus_led;
aorus_led.name = "GPU LED";
leds.push_back(aorus_led);
zone aorus_zone;
aorus_zone.name = "GPU LED";
std::vector<int> aorus_zone_map;
aorus_zone_map.push_back(0);
aorus_zone.map.push_back(aorus_zone_map);
zones.push_back(aorus_zone);
}
void RGBController_AorusGPU::SetCustomMode()
{
}
void RGBController_AorusGPU::UpdateMode()
{
}
+33
View File
@@ -0,0 +1,33 @@
/*-----------------------------------------*\
| RGBController_AorusGPU.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Aorus GPU |
| |
| Adam Honse (CalcProgrammer1) 6/17/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
typedef unsigned int uint32;
typedef uint32(*_GvWriteI2C)(uint32, void*, uint32);
typedef void (*_GvFreeDispLib)();
typedef void (*_GvInitDispLib)();
class RGBController_AorusGPU : public RGBController
{
public:
RGBController_AorusGPU();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
_GvWriteI2C GvWriteI2C;
_GvFreeDispLib GvFreeDispLib;
_GvInitDispLib GvInitDispLib;
};
+294
View File
@@ -0,0 +1,294 @@
/*-----------------------------------------*\
| RGBController_Aura.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Asus Aura driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#include "RGBController_Aura.h"
int RGBController_Aura::GetDeviceMode()
{
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
bool random = false;
switch(dev_mode)
{
case AURA_MODE_SPECTRUM_CYCLE_CHASE:
dev_mode = AURA_MODE_CHASE;
random = true;
break;
case AURA_MODE_SPECTRUM_CYCLE_BREATHING:
dev_mode = AURA_MODE_BREATHING;
random = true;
break;
case AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE:
dev_mode = AURA_MODE_CHASE_FADE;
random = true;
break;
}
if (aura->AuraRegisterRead(AURA_REG_DIRECT))
{
dev_mode = 0xFFFF;
}
for(int mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
active_mode = mode;
modes[mode].random = random;
}
}
return(active_mode);
}
void RGBController_Aura::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
}
}
void RGBController_Aura::UpdateZoneLEDs(int zone)
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
int led = zones[zone].map[x][y];
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
}
}
}
void RGBController_Aura::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
}
RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
{
std::vector<unsigned char> aura_channels;
aura = aura_ptr;
version = aura->GetDeviceName();
location = aura->GetDeviceLocation();
if((version.find("DIMM_LED") != std::string::npos) || (version.find("AUDA") != std::string::npos) )
{
type = DEVICE_TYPE_DRAM;
name = "ASUS Aura DRAM";
}
else
{
type = DEVICE_TYPE_MOTHERBOARD;
name = "ASUS Aura Motherboard";
}
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = AURA_MODE_OFF;
Off.flags = 0;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Flashing);
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = 0;
modes.push_back(SpectrumCycle);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = AURA_MODE_RAINBOW;
Rainbow.flags = 0;
modes.push_back(Rainbow);
mode ChaseFade;
ChaseFade.name = "Chase Fade";
ChaseFade.value = AURA_MODE_CHASE_FADE;
ChaseFade.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(ChaseFade);
mode Chase;
Chase.name = "Chase";
Chase.value = AURA_MODE_CHASE;
Chase.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Chase);
mode RandomFlicker;
RandomFlicker.name = "Random Flicker";
RandomFlicker.value = AURA_MODE_RANDOM_FLICKER;
RandomFlicker.flags = 0;
modes.push_back(RandomFlicker);
colors.resize(aura->GetLEDCount());
for (std::size_t i = 0; i < aura->GetLEDCount(); i++)
{
aura_channels.push_back(aura->GetChannel(i));
led* new_led = new led();
new_led->name = aura->GetChannelName(i);
leds.push_back(*new_led);
unsigned char red = aura->GetLEDRed(i);
unsigned char grn = aura->GetLEDGreen(i);
unsigned char blu = aura->GetLEDBlue(i);
colors[i] = ToRGBColor(red, grn, blu);
}
std::vector<unsigned char> aura_zones;
// Search through all LEDs and create zones for each channel type
for (std::size_t i = 0; i < aura_channels.size(); i++)
{
bool matched = false;
// Search through existing zones to make sure we don't create a duplicate zone
for (std::size_t j = 0; j < aura_zones.size(); j++)
{
if (aura_channels[i] == aura_zones[j])
{
matched = true;
}
}
// If zone does not already exist, create it
if (matched == false)
{
zone* new_zone = new zone();
std::vector<int>* zone_row = new std::vector<int>();
// Set zone name to channel name
new_zone->name = aura->GetChannelName(i);
// Find all LEDs with this channel type and add them to zone
for (std::size_t j = 0; j < aura->GetLEDCount(); j++)
{
if (aura->GetChannel(j) == aura_channels[i])
{
zone_row->push_back(j);
}
}
// Aura devices can be either single or linear, never matrix
// That means only one row is needed
new_zone->map.push_back(*zone_row);
// Save channel to aura_zones so we know not to create another zone with this channel
aura_zones.push_back(aura_channels[i]);
// Push new zone to zones vector
zones.push_back(*new_zone);
}
}
// Initialize active mode
active_mode = GetDeviceMode();
}
void RGBController_Aura::SetCustomMode()
{
active_mode = 0;
}
void RGBController_Aura::UpdateMode()
{
if (modes[active_mode].value == 0xFFFF)
{
aura->SetDirect(true);
}
else
{
int new_mode = modes[active_mode].value;
if(modes[active_mode].random == true)
{
switch(new_mode)
{
case AURA_MODE_CHASE:
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE;
break;
case AURA_MODE_BREATHING:
new_mode = AURA_MODE_SPECTRUM_CYCLE_BREATHING;
break;
case AURA_MODE_CHASE_FADE:
new_mode = AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE;
break;
}
}
aura->SetMode(new_mode);
aura->SetDirect(false);
}
}
+30
View File
@@ -0,0 +1,30 @@
/*-----------------------------------------*\
| RGBController_Aura.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Asus Aura driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AuraController.h"
class RGBController_Aura : public RGBController
{
public:
RGBController_Aura(AuraController* aura_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
AuraController* aura;
int GetDeviceMode();
};
+94
View File
@@ -0,0 +1,94 @@
/*-----------------------------------------*\
| RGBController_Corsair.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#include "RGBController_Corsair.h"
void RGBController_Corsair::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(red, grn, blu);
}
void RGBController_Corsair::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_Corsair::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
{
corsair = corsair_ptr;
name = corsair->GetDeviceName();
location = corsair->GetDeviceLocation();
type = DEVICE_TYPE_DRAM;
mode Static;
Static.name = "Static";
Static.value = CORSAIR_VENGEANCE_RGB_MODE_SINGLE;
Static.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Static);
mode Fade;
Fade.name = "Fade";
Fade.value = CORSAIR_VENGEANCE_RGB_MODE_FADE;
Fade.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Fade);
mode Pulse;
Pulse.name = "Pulse";
Pulse.value = CORSAIR_VENGEANCE_RGB_MODE_PULSE;
Pulse.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Pulse);
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
{
led* new_led = new led();
new_led->name = "Corsair LED";
leds.push_back(*new_led);
colors.push_back(0x00000000);
}
zone new_zone;
new_zone.name = "Corsair Zone";
new_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> zone_row;
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
{
zone_row.push_back(i);
}
new_zone.map.push_back(zone_row);
zones.push_back(new_zone);
}
void RGBController_Corsair::SetCustomMode()
{
active_mode = 0;
}
void RGBController_Corsair::UpdateMode()
{
corsair->SetMode(modes[active_mode].value);
}
+28
View File
@@ -0,0 +1,28 @@
/*-----------------------------------------*\
| RGBController_Corsair.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairController.h"
class RGBController_Corsair : public RGBController
{
public:
RGBController_Corsair(CorsairController* corsair_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
CorsairController* corsair;
};
@@ -0,0 +1,276 @@
/*-----------------------------------------*\
| RGBController_CorsairCmdrPro.cpp |
| |
| Generic RGB Interface for Corsair |
| Commander Pro |
| |
| Adam Honse (CalcProgrammer1) 1/16/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairCmdrPro.h"
RGBController_CorsairCmdrPro::RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair Commander Pro";
type = DEVICE_TYPE_LEDSTRIP;
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Direct);
mode RainbowWave;
RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
RainbowWave.direction = MODE_DIRECTION_RIGHT;
modes.push_back(RainbowWave);
mode ColorShift;
ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorShift);
mode ColorPulse;
ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorPulse);
mode ColorWave;
ColorWave.name = "Color Wave";
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorWave.direction = MODE_DIRECTION_RIGHT;
modes.push_back(ColorWave);
mode Static;
Static.name = "Static";
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_COLOR;
modes.push_back(Static);
mode Temperature;
Temperature.name = "Temperature";
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
Temperature.flags = MODE_FLAG_HAS_COLOR;
modes.push_back(Temperature);
mode Visor;
Visor.name = "Visor";
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Visor);
mode Marquee;
Marquee.name = "Marquee";
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Marquee.direction = MODE_DIRECTION_RIGHT;
modes.push_back(Marquee);
mode Blink;
Blink.name = "Blink";
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Blink);
mode Sequential;
Sequential.name = "Sequential";
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Sequential.direction = MODE_DIRECTION_RIGHT;
modes.push_back(Sequential);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Rainbow);
/*-------------------------------------------------*\
| Set size of colors array |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
{
led_count += corsair->channel_leds[channel_idx];
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
{
if(corsair->channel_leds[channel_idx] > 0)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Corsair Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx);
}
}
}
void RGBController_CorsairCmdrPro::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
}
void RGBController_CorsairCmdrPro::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairCmdrPro::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairCmdrPro::SetCustomMode()
{
active_mode = 9;
}
void RGBController_CorsairCmdrPro::UpdateMode()
{
if(modes[active_mode].value == 0xFFFF)
{
UpdateLEDs();
}
else
{
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
{
unsigned int direction = 0;
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
{
direction = 1;
}
corsair->SetChannelEffect(channel,
modes[active_mode].value,
modes[active_mode].speed,
direction,
modes[active_mode].random,
RGBGetRValue(colors[0]),
RGBGetGValue(colors[0]),
RGBGetBValue(colors[0]),
RGBGetRValue(colors[1]),
RGBGetGValue(colors[1]),
RGBGetBValue(colors[1]));
}
}
}
@@ -0,0 +1,29 @@
/*-----------------------------------------*\
| RGBController_CorsairCmdrPro.h |
| |
| Generic RGB Interface for Corsair |
| Commander Pro |
| |
| Adam Honse (CalcProgrammer1) 1/16/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairCmdrProController.h"
class RGBController_CorsairCmdrPro : public RGBController
{
public:
RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
CorsairCmdrProController* corsair;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
@@ -0,0 +1,208 @@
/*-----------------------------------------*\
| RGBController_CorsairKeyboard.cpp |
| |
| Generic RGB Interface for Corsair RGB |
| keyboards |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairKeyboard.h"
static const char* zone_names[] =
{
"Keyboard",
"Media Keys"
};
static const unsigned int zone_sizes[] =
{
104,
7
};
static const char* led_names[] =
{
"Key: Escape", //0
"Key: `", //1
"Key: Tab", //2
"Key: Caps Lock", //3
"Key: Left Shift", //4
"Key: Left Control", //5
"Key: F12", //6
"Key: =", //7
"Key: Lock", //8
"Key: Number Pad 7", //9
"Key: F1", //12
"Key: 1", //13
"Key: Q", //14
"Key: A", //15
"Key: Left Windows", //17
"Key: Print Screen", //18
"Media Mute", //20
"Key: Number Pad 8", //21
"Key: F2", //24
"Key: 2", //25
"Key: W", //26
"Key: S", //27
"Key: Z", //28
"Key: Left Alt", //29
"Key: Scroll Lock", //30
"Key: Backspace", //31
"Media Stop", //32
"Key: Number Pad 9", //33
"Key: F3", //36
"Key: 3", //37
"Key: E", //38
"Key: D", //39
"Key: X", //40
"Key: Pause/Break", //42
"Key: Delete", //43
"Media Previous", //44
"Key: F4", //48
"Key: 4", //49
"Key: R", //50
"Key: F", //51
"Key: C", //52
"Key: Space", //53
"Key: Insert", //54
"Key: End", //55
"Media Play/Pause", //56
"Key: Number Pad 4", //57
"Key: F5", //60
"Key: 5", //61
"Key: T", //62
"Key: G", //63
"Key: V", //64
"Key: Home", //66
"Key: Page Down", //67
"Media Next", //68
"Key: Number Pad 5", //69
"Key: F6", //72
"Key: 6", //73
"Key: Y", //74
"Key: H", //75
"Key: B", //76
"Key: Page Up", //78
"Key: Right Shift", //79
"Key: Num Lock", //80
"Key: Number Pad 6", //81
"Key: F7", //84
"Key: 7", //85
"Key: U", //86
"Key: J", //87
"Key: N", //88
"Key: Right Alt", //89
"Key: ]", //90
"Key: Right Control", //91
"Key: Number Pad /", //92
"Key: Number Pad 1", //93
"Key: F8", //96
"Key: 8", //97
"Key: I", //98
"Key: K", //99
"Key: M", //100
"Key: Right Windows", //101
"Key: \\", //102
"Key: Up Arrow", //103
"Key: Number Pad *", //104
"Key: Number Pad 2", //105
"Key: F9", //108
"Key: 9", //109
"Key: O", //110
"Key: L", //111
"Key: ,", //112
"Key: Context", //113
"Key: Left Arrow", //115
"Key: Number Pad -", //116
"Key: Number Pad 3", //117
"Key: F10", //120
"Key: 0", //121
"Key: P", //122
"Key: ;", //123
"Key: .", //124
"Key: Enter", //126
"Key: Down Arrow", //127
"Key: Number Pad +", //128
"Key: Number Pad 0", //129
"Key: F11", //132
"Key: -", //133
"Key: [", //134
"Key: '", //135
"Key: /", //136
"Key: Brightness", //137
"Key: Right Arrow", //139
"Key: Number Pad Enter",//140
"Key: Number Pad .", //141
"Key: F12"
};
RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair RGB Keyboard";
type = DEVICE_TYPE_KEYBOARD;
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Direct);
colors.resize(111);
unsigned int led_idx = 0;
for(unsigned int zone_idx = 0; zone_idx < 2; zone_idx++)
{
zone new_zone;
new_zone.name.append(zone_names[zone_idx]);
std::vector<int> new_zone_map;
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
{
led new_led;
new_led.name.append(led_names[led_idx]);
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
led_idx++;
}
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
}
}
RGBController_CorsairKeyboard::~RGBController_CorsairKeyboard()
{
}
void RGBController_CorsairKeyboard::UpdateLEDs()
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::UpdateZoneLEDs(int zone)
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::UpdateSingleLED(int led)
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::SetCustomMode()
{
active_mode = 0;
}
void RGBController_CorsairKeyboard::UpdateMode()
{
}
@@ -0,0 +1,29 @@
/*-----------------------------------------*\
| RGBController_CorsairKeyboard.h |
| |
| Generic RGB Interface for Corsair RGB |
| keyboards |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairKeyboardController.h"
class RGBController_CorsairKeyboard : public RGBController
{
public:
RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr);
~RGBController_CorsairKeyboard();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
CorsairKeyboardController* corsair;
};
@@ -0,0 +1,276 @@
/*-----------------------------------------*\
| RGBController_CorsairNodePro.cpp |
| |
| Generic RGB Interface for Corsair |
| Lighting Node Pro |
| |
| Adam Honse (CalcProgrammer1) 1/12/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairNodePro.h"
RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair Lighting Node Pro";
type = DEVICE_TYPE_LEDSTRIP;
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Direct);
mode RainbowWave;
RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
RainbowWave.direction = MODE_DIRECTION_RIGHT;
modes.push_back(RainbowWave);
mode ColorShift;
ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorShift);
mode ColorPulse;
ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(ColorPulse);
mode ColorWave;
ColorWave.name = "Color Wave";
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorWave.direction = MODE_DIRECTION_RIGHT;
modes.push_back(ColorWave);
mode Static;
Static.name = "Static";
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_COLOR;
modes.push_back(Static);
mode Temperature;
Temperature.name = "Temperature";
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
Temperature.flags = MODE_FLAG_HAS_COLOR;
modes.push_back(Temperature);
mode Visor;
Visor.name = "Visor";
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Visor);
mode Marquee;
Marquee.name = "Marquee";
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Marquee.direction = MODE_DIRECTION_RIGHT;
modes.push_back(Marquee);
mode Blink;
Blink.name = "Blink";
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Blink);
mode Sequential;
Sequential.name = "Sequential";
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Sequential.direction = MODE_DIRECTION_RIGHT;
modes.push_back(Sequential);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
modes.push_back(Rainbow);
/*-------------------------------------------------*\
| Set size of colors array |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
{
led_count += corsair->channel_leds[channel_idx];
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
{
if(corsair->channel_leds[channel_idx] > 0)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Corsair Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx);
}
}
}
void RGBController_CorsairNodePro::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
}
void RGBController_CorsairNodePro::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairNodePro::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairNodePro::SetCustomMode()
{
active_mode = 9;
}
void RGBController_CorsairNodePro::UpdateMode()
{
if(modes[active_mode].value == 0xFFFF)
{
UpdateLEDs();
}
else
{
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
{
unsigned int direction = 0;
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
{
direction = 1;
}
corsair->SetChannelEffect(channel,
modes[active_mode].value,
modes[active_mode].speed,
direction,
modes[active_mode].random,
RGBGetRValue(colors[0]),
RGBGetGValue(colors[0]),
RGBGetBValue(colors[0]),
RGBGetRValue(colors[1]),
RGBGetGValue(colors[1]),
RGBGetBValue(colors[1]));
}
}
}

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