Jump to content
Corsair Community

[Help] Change iCUE Profile from a program


Macca_Cool

Recommended Posts

Hi there,

 

I'm looking to create a program to allow for game integration similar to the Far Cry 5 setup with iCUE but for other games. From what I've seen, the Far Cry setup switches iCUE between different profiles (stored in iCUE install dir) based on the game state. I would like to do the same however the iCUE SDK does not appear to support switching of iCUE profiles, and I have had no luck googling for alternative methods.

 

So I'm asking here, is there any method of changing iCUE's active profile to a profile stored on disk via a program (be that command line, SDK, or other).

 

Thanks heaps, Macca

Link to comment
Share on other sites

Hi there,

 

I'm looking to create a program to allow for game integration similar to the Far Cry 5 setup with iCUE but for other games. From what I've seen, the Far Cry setup switches iCUE between different profiles (stored in iCUE install dir) based on the game state. I would like to do the same however the iCUE SDK does not appear to support switching of iCUE profiles, and I have had no luck googling for alternative methods.

 

So I'm asking here, is there any method of changing iCUE's active profile to a profile stored on disk via a program (be that command line, SDK, or other).

 

Thanks heaps, Macca

 

While their is a SDK for iCUE, there is no CLI tool for iCUE. Farcry is setup a little differently as it does use the SDK to load some profiles based on events within Farcry.

 

However you can also set the profiles to load based on process, you just create a profile and use the setting within the profile to have it switch to that profile, when the process is active. Though there is no other way to dynamically change the profile currently.

Link to comment
Share on other sites

Alright then, thanks for the answer. Any word on if this is a planned feature or if the Far Cry workings would ever be publicised?

 

RGB lighting is fairly new, while some other games have integration with RGB devices, I think Farcry 5 is the first time Corsair has had it work like this for the game. I am sure there will be other games, I know other companies have done this as well. This is pretty new to the industry in general and I betting extra effort has to go in from both Corsair and game developers to get this working properly. I am not a developer, though I assume there are hooks inside of the game interact with the SDK. The profiles for Farcry5 are store in the Farcry5 directory. I think in the future game developers in general will develop some type of standard to allow different devices to interact with it. There are some cool open source tools like Aurora: https://github.com/antonpup/Aurora

 

Though it looks like it is limited to Keyboard, Mice, mouse pad, and the headphone stand. There is no support for other devices like LNP and CoPro. I do like to tinker, though haven't tried Aurora as I do really like iCUE a lot.

Link to comment
Share on other sites

You are very much correct, it is very new and I (as a Software Developer) would really love to be able to make something similar to the Far Cry lighting. Yesterday I had only read the documentation for the SDK, but as it is still in development it is potentially not complete, so I will have a better look at it today and post any findings.

 

As for Project Aurora, I had already looked at its inner workings. It's limited to common peripherals across brands, as that is their main aim "unified lighting." Aurora has support for a lot of games and lighting based on game-states, exactly what Far Cry has but far more limited and all the information regarding it can be found at: https://github.com/antonpup/Aurora/tree/master/Project-Aurora/Project-Aurora/Profiles Upon inspection of these files, Aurora also lifts game support directly from another lighting project called Artemis, with Artemis' game support found: https://github.com/SpoinkyNL/Artemis/tree/master/Artemis/Artemis/Modules/Games

 

For most of these games the game-state is found by either reading values from memory (ie. Health/Mana in Terraria, boost in Rocket League) or through the use of .dll injectors or other modifications (see Witcher 3, Euro Truck Sim 2). In the case of CS:GO, Valve actually gives us direct access to relevant (and fair) data as to avoid people trying to 'hack' into the game, this is outlined here: https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Game_State_Integration and is what I think we'd all love to see more developers doing.

 

Anyway, that's for those who are interested in how Aurora and Artemis work, and how the practise will probably work in the future. I'm going to have a better poke around at the iCUE SDK and .dll packaged with Far Cry and I'll post any findings regarding loading iCUE profiles similar to Far Cry, because that's the only missing piece. Once that's possible, we can easily make awesome dynamic lighting setups!

Link to comment
Share on other sites

So upon further inspection, the iCUE SDK documentation seems to be pretty complete. It only has functions for getting device and LED info and setting LED colours. As the Far Cry setup actually uses iCUE profiles (you can import them from the iCUE install dir) I doubt they use the iCUE SDK (or at least the public version of it).

 

Far Cry has a dll signed by Corsair, "CgSDK.x64_2015.dll" which has functions for setting and clearing 'states' as well as setting the current 'game'. My bet is that this dll must interact with iCUE in some way, however my knowledge of C++ is quite limited so I'm unsure of how this dll could be used. As the iCUE profiles are stored in the iCUE install, it's possible that the functionality is entirely built into iCUE and this CgSDK just tells iCUE which profile to switch too, in which case we (as not Corsair employees) probably can't tap into that functionality.

 

I read that both "Homefront the Revolution" and "Diablo 3" had similar RGB functionality to Far Cry. The Homefront one appears to be lighting individual keys that are relevant (see http://forum.corsair.com/v3/showthread.php?t=162886) apparently it also shows the American flag (possibly the same profile Far Cry uses for the main menu). The keys are do-able with the iCUE SDK, but I don't have access to the Homefront files, so can't check if it also has CgSDK. Diablo seems to have very limited functionality (again I don't have access to look at files though) that is do-able with the iCUE SDK, probably won't have CgSDK.

 

Would really love to hear any information from Corsair or anyone who knows of the functionality given by this CgSDK and how we can use iCUE to do this cool stuff. Any info, hit me up!

 

CorsairDllFunctions.png

Edited by Macca_Cool
Added image that I had forgot
Link to comment
Share on other sites

Yes heavy heavy ditto. I and others have asked for this as well in many other threads for unpteen reasons. Radio silence on dev side. My only fix is via gui and autohotkey but it really isn’t a fix and I am sure it is so easy to add on their end and I’d literally mail them a check if I had an address? Or whatever.

 

Respect to your function calls above and (ends == means) except in future releases that may not work the same way?

Link to comment
Share on other sites

Yeah it really does suck that this functionality isn't public. I just found this post from the iCUE Product Manager (http://forum.corsair.com/v3/showpost.php?p=947359&postcount=3) and it confirms that all Far Cry 5 does is "ping" the SDK to play the profile in the iCUE install directory. Judging by the functions for CgSDK I am sure that it is the SDK that he mentions as the SDK Effects folder has a FarCry5 directory, implying usage of CgSdkSetGame. This would also infer that the priorities.cfg found in that dir (which dictates which profile is more important) would be required per game. I would also assume that the SDK Set/Clear State functions would be used to enable each profile (probably by their name). Set Event lacks a Clear Event function, so not sure of its functionality. Same with Progress Bar, no ideas there. Anyone who knows C++ maybe have a tinker with it and try to trigger the Far Cry profiles using CgSDK. I'm going to see what I can do with my limited C++ knowledge.
Link to comment
Share on other sites

So, I had a look at CgSDK again and I'm sure that it is how the Far Cry game integration works. Unfortunently it would appear that without the header and library files for the SDK, we have no way of using it without reverse engineering it (a massive pain and probs breaches user agreements and whatnot). So that kinda sucks. I'd love to hear from any Corsair employees working on iCUE to if releasing CgSDK to the public is planned (ETA?), would really love to see this happen. Even if there isn't proper documentation for it, I'd love to at least hear more about the SDK as it would be awesome to allow us to make full dynamic lighting setups.
Link to comment
Share on other sites

Yeah it really does suck that this functionality isn't public. I just found this post from the iCUE Product Manager (http://forum.corsair.com/v3/showpost.php?p=947359&postcount=3) and it confirms that all Far Cry 5 does is "ping" the SDK to play the profile in the iCUE install directory. Judging by the functions for CgSDK I am sure that it is the SDK that he mentions as the SDK Effects folder has a FarCry5 directory, implying usage of CgSdkSetGame. This would also infer that the priorities.cfg found in that dir (which dictates which profile is more important) would be required per game. I would also assume that the SDK Set/Clear State functions would be used to enable each profile (probably by their name). Set Event lacks a Clear Event function, so not sure of its functionality. Same with Progress Bar, no ideas there. Anyone who knows C++ maybe have a tinker with it and try to trigger the Far Cry profiles using CgSDK. I'm going to see what I can do with my limited C++ knowledge.

 

Good thoughts. I can try sometime soon (maybe this evening) a simple DLLCall in Autohotkey or also use visual studio to include that corsair.dll in the references in an SDK project and see if there's a way to just say "using cgsdk" in the namespace declarations and then it may be as simple as running these functions to experiment like CgSdkSetGame() and see what parameters it may take by sending some in or not and jotting down what happens.

 

We may need to address the namespace but that might just be like CgSDK::CgSdkSetGame()

Link to comment
Share on other sites

...hastegag -> what you are proposing won't work at all. These are C++ exported functions. You need to use P/Invoke to access these functions.

 

Thank you that saves headaches, thank you DevBiker!

 

https://msdn.microsoft.com/en-us/library/55d3thsc.aspx

and this

https://en.wikipedia.org/wiki/Platform_Invocation_Services#Pitfalls

 

seem to detail the basics. I'll give it a shot, why not.

Link to comment
Share on other sites

So this gent was kind enough to detail the platform invoke process and I got his example working:

 

https://manski.net/2012/05/pinvoke-tutorial-basics-part-1/

 

I realized after trying to open the CgSDK.x64_2015.dll the same way that it is 64 bit. I needed to run some updates to my VS install to get Csharp to compile 64 bit vs x86 and that install is taking its sweet time.

 

I had tried switching it over to cpp instead (as that was installed) but it wasn't translating easy. I tried a couple things but I figure converting the known good quantity in c# will be easier. Will share if i figure anything out.

 

Edit so no I get the same error compiling in x64. Probably because it is an un managed dll and may have different .net version? You can probably use LoadLibrary and GetProcAddress to get it done, but I had trouble with the second part of that in C++, I was able to prototype the function properly (I think) and use LoadLibrary and save the handle to the loaded dll (I assume that was a pointer to its base address once loaded) but the next parts I was lost. This all assumes a whole lot - even if it is all set up properly, calling something like CgSdkSetState("FC_AnimalAttack"); might have no effect...especially if you do not sequence it all properly like performprotocolhandshake, clearall and then setstate

Edited by hastegag
eh
Link to comment
Share on other sites

I had my own look into it today after having a break from the project. Gotta say, I'm happy with my results. I was able to make the required .lib and header files required to use the CgSDK dll file by modelling them off of the publicly available iCUE SDK. Yesterday I had noticed common functions between both SDKs (see PerformProtocolHandshake, Request/ReleaseContol functions).

 

Using the iCUE SDK documentation and header files, I just copied them over and they're exactly the same across the two SDKs. After a whole load of C++ bs I got everything compiled and got this output: SuccessfulHandshake.png

The first set of text shows the various properties of the output struct from the Handshake function. It shows an SDK version that is just behind the current iCUE SDK (indicating that perhaps this functionality is part of it after all, but is just being blocked from the public release currently) and a "server version" which is equivalent to the current iCUE version I have installed. Below that is my experimenting with input/outputs of the SetGame and SetState functions, no luck so far.

 

This shows us two things: 1) The functionality given by CgSDK to Far Cry 5 is probably going to be included in a future iCUE SDK release, which is awesome, shows the radio-silence isn't in bad faith. 2) With some good guesswork and experimentation, it's totally possible for us to get this functionality beforehand and start to experiment with it. In the meantime, I'm gonna keep at it and see if I can trigger the Far Cry lighting effects via the SDK.

Link to comment
Share on other sites

You are awesome and better than I! While I have some quick questions on your implementation, I wont bother you with it.

 

That said, in thinking about it, I suspect the whole farcry style integration just changes lighting. I do think (or hope rather), they are aware the ability to change the actual profile in the application would be equally advantageous with all the affiliated settings (remaps, macros, dpi, audio stuff, etc).

 

While lighting linking like this is incredibly powerful (especially if you have mobos or other non cue rgb goods, or perhaps phillips hue lighting etc), I think it is good to fix this once and for all with the ability to choose the profile as desired outside the program, not via the gui (my noob fix http://forum.corsair.com/v3/showthread.php?t=180961).

 

Just a real short list of the benefits:

- link lighting with other incompatible or 3rd party hardware

- allow their own elgato devices to change profiles

- fix the issue where users with a group of profiles (cuefolder) associated with a single application get stuck on one of these profiles when application focus is lost or for any other reason. (for example, I've got modifier lighting in CUE setup to indicate certain visual reminders/mnemonics in a Photoshop group that says to me as a user, hey you are in shift profile so this does blank and then somewhere along the way it gets stuck there. I cannot be the only person that would love the application to revert to the default, even after a period of time, just so I don't have to hit a key.

- Allow Cue to offer title matching or other conditional and context sensitive profile switching that extends beyond the current functionality.

Link to comment
Share on other sites

So @hastegag asked me how I got to here, and I'm a little stuck, so I'm posting a walkthrough to get to this stage so other interested parties can quickly hop to here and work on the hard stuff.

 

Tools: You're gonna need Visual Studio for C++ (or something similar, a C++ IDE). And you need the CgSDK dll file (in the Far Cry 5 install, "CgSDK.x64_2015.dll").

 

Getting a lib file: In the Visual C++ install directory there are a bunch of tools we need (actually just one for now). My directory is: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\". Make a folder in there called something like "input" and give yourself read/write perms (makes the next part easier). In that folder make a file called "CgSDK.x64_2015.def" it's contents will look like so: https://pastebin.com/DEx48dFG

As you can see, it's just the names of all the functions we viewed earlier. Because they aren't mangled (a C++ compiler thing, for security I assume, against this very thing ::pirate::) it's super easy. Then you want to open a command prompt window in the bin folder. Now run two commands:

vcvars32.bat
lib /def:./input/CgSDK.x64_2015.def /out:./input/CgSDK.x64_2015.lib /machine:X64

Which should generate a lib file (among other things) that you can link in your Visual C++ project. In the root of my project, I made a folder called "CgSDK" and have the dll, lib and headers in it. Now in the project settings you have to import the lib. So under C/C++ -> General -> Additional Include Directories add "$(SolutionDir)CgSDK\;" (use the correct path for you). Under Linker -> General -> Additional Library Directories add the same. I also needed to add "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10150.0\ucrt\x64;" for a reference to the ucrt file, it was a dependancy for something(?) in both my project and sample iCUE SDK projects. Under Linker -> Input -> Additional Dependancies add "CgSDK.x64_2015.lib;" and it's all setup.

 

Header files: As I mentioned earlier, I looked at CgSDK functions and iCUE SDK functions and noticed some common ones. Those we will already know the prototypes (input/output) for. The rest we will need to be guessing essentially (more on that later). So we have 2 header files, one for all the function and one for loading the dll. They are as follows:

(CgSDK.x64_2015Global.h) https://pastebin.com/TAVLxgAE

(CgSDK.x64_2015.h) https://pastebin.com/wbKDHc4d

 

Note that for the header (not global one) I have assumed boolean outputs for the CgSDK functions, this is probably not correct. Also note missing inputs. We don't know anything about them yet! In any case, throw both headers into the "CgSDK" folder and you can safely import them with:

#include "CgSDK.x64_2015.h"

 

Where to from here: Now we can use the functions that we know are correct (the first 4) in our program, mine looks like this: https://pastebin.com/U4e0Wtyk

Try building with my program to make sure it is all working as intended. You should be getting the same output I had (save the last 2 lines). From here we need to actually miraculously guess inputs and outputs, try a whole bunch of them, or doing something more cunning. I've already used a program called Snowman to view the Assembly code of CgSDK.dll and reconstructed C++, however all types are generic so it is almost useless to us, however we might need Assembly later. My idea to progress would be using DLL Injection. The simplest means would be to make our own CgSDK.dll (using the same header files, might need to edit global one) and then replacing (or renaming) the one in the Far Cry 5 install. Our dll would need functions that could take any input (does C++ ellipsis work?) and would attempt to parse inputs as common things (integers, char*, booleans, basically anything we've seen in the iCUE SDK. Structs will be an issue) and dump them to a text file. It will probably also need to call the functions from the actual dll with the given inputs and return their outputs (dumping them on the way). We will know it works if Far Cry lighting still works while using our dll.

 

No idea how plausable that is but it's the best option I can see. Good luck to anyone picking this project up.

Edited by Macca_Cool
Fixed error in lib command
Link to comment
Share on other sites

Forgot to add, for replacing CgSDK in the Far Cry 5 install, our dll will need to have the correct functions accessible from the same location as the original dll . Those locations are available through the use of "DLL Export Viewer" (they were just cut-off in the screenshot I posted). I can probably post these to pastebin if anyone wants them. When I looked at the Assembly code, these locations were all jump commands that went to the function elsewhere in the dll. Our dll would need to do something similar where at these locations are jump commands to our logging functions. Doing this might require us compiling our dll and then modifying it's Assembly code to fit this, which might be a huge pain because we need to ensure that the original locations are free of any of our program.
Link to comment
Share on other sites

Wow dude, you are awesome. With your help, I got a proof of concept going! I suspect it does not carry over DPI and macros. That said, maybe it could? I would say we could compare the FarCry5 profiles with other profiles and see if they even contain those .

 

Video Link here [ame]

[/ame]

 

I did everything you did except started from an SDK example (had to comment out some of the repeated enums and structs in the include) and most importantly added character pointers as what was sent into CgSdkSetGame() and sent in simply FarCry5 (the name of the directory icue has the cueprofiles in).

 

With the events and states I did the same and named the profiles in the directory. It seems to work but there must be a difference between events and states (maybe one is able to overlap the other). As a note, I have far cry 5 but at this point I am not sure it really matters, since this seems to get us off to a good start.

 

CORSAIR_GAME_SDK bool CgSdkSetGame(char *gamename);
CORSAIR_GAME_SDK bool CgSdkSetState(char *statename);
CORSAIR_GAME_SDK bool CgSdkSetEvent(char *eventname);

 

I don't know if it mattered, but I requested non exclusive control even though the sdk docs say it is unnecessary. It also may not have mattered that I used an sdk example project to start off.

Edited by hastegag
Link to comment
Share on other sites

Awesome work! I think this is just the motivation I need to get back on it after that whole Assembly mistake. I suspect that DPI and macros would overlap as they surely don't remove your macros when you're playing Far Cry also on importing (in iCUE) there are options to not import those. As for the events vs states thing, I suspect that a state is something that you're in for a while, think when you are on fire "FC_Fire", when you're in the water "FC_Water" or in the menu "FC_Menu". I believe events will be 1 time trigger profiles, think the profiles that have "play once" set: "FC_AnimalAttack", "FC_ArcadeCoin", "FC_Explosion", etc. After these finish playing the lighting profile should switch back to the highest priority state currently active (see the priorities.cfg which will also show that overlap probably doesn't happen - does the "FC_AnimalAttack" overlap or does the keyboard go black first when in-game?). I think I tried with those same function definitions the first time without success (or at the very least, a boolean wasn't returned) but I'll have another go. The DLL Injection route may not be needed, but if I don't make any headway I'll probably give it a go and hope structs don't show up.
Link to comment
Share on other sites

Done! States are working on my side, can load up any of them as states and it prioritises them accordingly. We could have been here last week, but I made a silly mistake. I needed to check for errors after every command, because that actually tells us what's going wrong. Just needed to request exclusive access (might be specific to my setup though, because I'm using the demo devices in iCUE - only own the Void headset). For anyone else reading this, my motivation is to get this working for my mate's desk pc that's full of Corsair stuff. It's gonna be sick!

 

From here I guess I'll try getting events working and then we'll try the other functions. But with just events and states, it's already a SUPER powerful tool for dynamic lighting. So I guess we've solved the thread topic too now! But we'll keep our progress here I think.

Link to comment
Share on other sites

http://www.smithany.com/ProfileAsArgument.rar

 

So I spent some more time on it this evening and could get events and states working and the clearallevents and clearallstates seems to work correctly to give it back to CUE, and I could put custom profiles in, even with custom names, provided however that the name at the top matches the name of the file (cueprofile) and it needed to be present with a legit and non redundant value in priorities.cfg having the same name. As written, the profile name can be passed in as plaintext as an argument to the ProfileArgument.exe located in x64\Release\.

 

So if you make an icue profile called "something" and export the lighting and be sure the name in the tree is also "something" and then save it into the Corsair farcry5 install directory, probably: C:\Program Files (x86)\Corsair\CORSAIR iCUE Software\GameSdkEffects\FarCry5\. You also need to be sure "something" is present in the profiles.cfg file. If that fails be sure the <name> part near the top of the of the qml something.cueprofile is "something" without quotes.

 

Keep in mind you should make a backup of that folder especially if you play farcry5 on occasion (as i do as well) or you could end up breaking or over writing something.

 

I couldn't get the threading right to allow folks to cancel it as needed but it opens a window and sniffs for the q key every 2 seconds and should quit and release it back to icue when pressed.

 

This should save some steps, but keep in mind it does not handle: dpi, timers, macros, or anything else, just straight forward lighting. There are many other things that can be done and I could only get this to work when lighting effects were set to start with profile and never stop, but this may be helpful to some as we may evolve it.

Link to comment
Share on other sites

Awesome work man. I ended up wrapping up the functions we know for C# (albeit very poorly wrapped) and set it up to work with the CS:GO Game Integration provided by Valve. So I can confirm that using a custom game CgSdkSetGame(char* name) works and will correctly navigate to a folder by that name in the GameSdkEffects folder. With that we've got custom profiles (both states and events) to work with the SDK from C#. So in total we can use SetGame, SetState, SetEvent, ClearState, ClearAllStates, ClearAllEvents, GetLastError, PerformProtocolHandshake and the Release/RequestControl functions. I still want to look into SetState/EventWithKey. My thoughts are that it either enables hidden lighting effects within the profile or it controls blending options. The latter comes from our attempt at a flashed profile for CSGO. When we trigger the CS_Flashed event there is an approx. 1 second period where the LEDs interpolate from their current state into the flash profile, essentially blending them together. Having the ability to immediately switch would be nice and potentially part of that function. On that, the FC_AnimalAtack profile for Far Cry 5, do you know if it has a delay before showing?
Link to comment
Share on other sites

  • 1 year later...
Yeah man, it's been a while since this post. I ended up creating a HTTP server, sort-of-frontend for the game integration SDK functions, which you'll find in its own thread. My main goal was to avoid having to deal with the C++ stuff that I don't really understand, and to expose the functionality as HTTP GET requests because they're pretty much universally supported, so you can then use the SDK from wherever you like.
Link to comment
Share on other sites

  • 2 months later...
×
×
  • Create New...