Open v00d00m4n opened 1 year ago
I agree with this suggestions. Current implementation is good if you launch executable directly but you will miss out on achievements, overlay integration or something else. I would have just proposed to add some sort of conditions for pre-,post- and finalizing steps. As example right now I can launch Cyberpunk 2077 exe with ColorControl with enabling HDR before game starts and then going back to SDR after game has exited but it is not possible to revert back to SDR properly if you use steam URI.
Thanks for the suggestion. While monitoring would be better for launchers, it currently would prevent changing some settings from working properly. If the game starts and CC would have to change the Windows HDR setting or NVIDIA driver settings, it's already too late. Maybe a lower time interval will solve this, but not 100%. SpecialK works around this by injecting itself into the game via DirectX DLL's, but I think that's a bit too much/intrusive for CC. Another option would be low level Windows API calls that act whenever a process is starting, but that requires me to write a driver which can temporarily block the execution of the process (like a virus scanner's real-time protection). But if you or anyone else has a simple solution fot this I'm all ears! I can easily add a configurable time interval for monitoring though.
Well, right now I daisy-chained CC into launching autohotkey script which in turn launches Steam URI. This autohotkey is waiting for game process to appear and then waits for its exit. Once game exe exits, the script itself terminates and then CC notices it and performs finalizing steps (turns screen back to SDR). Works well for me in turning screen to HDR before launching Cyberpunk 2077 through Steam even if Steam is closed. So in this case autohotkey is doing the monitoring part. Although this certainly will not work for media player example as described in first post.
Thanks for the suggestion. While monitoring would be better for launchers, it currently would prevent changing some settings from working properly. If the game starts and CC would have to change the Windows HDR setting or NVIDIA driver settings, it's already too late. Maybe a lower time interval will solve this, but not 100%. SpecialK works around this by injecting itself into the game via DirectX DLL's, but I think that's a bit too much/intrusive for CC. Another option would be low level Windows API calls that act whenever a process is starting, but that requires me to write a driver which can temporarily block the execution of the process (like a virus scanner's real-time protection). But if you or anyone else has a simple solution fot this I'm all ears! I can easily add a configurable time interval for monitoring though.
Steam and many games load slow enough to manage to change something. Surely some things may be a little slow to do but a lot of things will work, for example setting any TV settings will work like charm no matter when game started, but i suggest you to not limit anything and let it work as is.
Also i have idea that may be non intrusive, yet may help to solve "late on party" problem same way i did years ago with my universal launcher and monitor for steam and other launchers (it allowed me to chain texmod, and some other mod launchers while game was started from steam and other launchers, also it help me to do game specific tasks on launch and post launch, like setting different resolution, running some helpful software like FOV memory patchers, and stuff like that, also i used that to close origin and uplay before they got feature that allowed them to autoclose on game exit):
You detect launched exe from white list or\and path pattern (like in special k), save their launch parameters, including working folder and local environment variables, kill process via system api (for save kill) and then immediately start same exe with same parameters, but i suggest to add option with checkboxes like "keep arguments" "Keep work dir" "keep env vars", because in some cases its better to loose them and let steam set them again.
Also i suggest to add option like "start game directly" or "start game via parent launcher" so we can choose if we want exe to be launched directly or via steam or whatever started it. This is needed because some games dont use steam stub and dont launch steam automatically, other launchers like gog also drm free and will not connect to launcher if launched directly.
As for getting id to launch non intrusive way for any launcher - this can usually be extracted from launch arguments and env variables of launched exe on 1st detection. By name of argument or protocol or by id you can easily detect type of launcher that was used and regexp id and other arguments from it.
But there are cases when people like me love to launch everything from one launcher like steam or gog galaxy or even somethings like playnite (i personally prefer to add non steam games), in this case launcher generates other type of id for non native games, and sometimes you can recognize such game by different types of id, but its not the bulletproof solution as some games may loose root launcher ids on launch of other launcher, so you can and need to actually detect whole chain of parent processes to get idea what was initial launcher that started whole chain.
This parent process detection will be also helpful for cases when game native to one launcher but also use another launcher - like any Rockstar, Ubisoft or EA games, so detection of chain of parent processes (with white list, preferably editable to be possible to add some rare unknown launcher and its recognition patterns like pathes, ids regexp, launch arguments, exe names etc) is necessary to properly recreate whole chain after termination of process.
In result you dont inject any code into game and just using monitoring of process tree starting from known launchers and getting necessary information to restart properly whole chain after you applied all profile related settings. Same monitoring sub routines will help you to detect when game is closed to restore previous settings.
And just in case of system crash or something - always save some cache of previous settings when you apply something else, and if ther was no restored on close of game because some system crash happened, next time colorcontrol launches it should restore them to cached state, most likely it will happen after reboot, also would be nice to ask and show what was changed and what will be restored, with checkbox - dont ask again and do it automatically!
I believe you know how to do it, yet if you need i may check my old archives for remains of some autoit (yeah its different syntax, but its easy to understand logic and port it) code i did for monitoring that did almost everything i described that may be helpful to get started, but no promises, because my old hdds are file dumps and i may not find anything.
Wow, thanks for the information! There's sure a lot of useful stuff in there. I'll keep this information in mind when implementing this feature. It can take a while to implement it, though. This is probably a good example of a "time sink" if you want to cover all situations😁
Launcher behavior is pretty much useless because everyone using shortcuts or Steam and other Launchers to start games.
While this option could stay as option (like some toggle in profile settings) i suggest to change default behavior to monitoring, so once exe with set up name or path (full or just partial with regexp match) or window title (also preferable with monitoring of entire chain of child processess to avoid switching too often in chained launches that may include main exe > launcher exe > some other exe > main exe again or any other , so that profile coulb be active since launch of game until it main exe and all of its child processes, with exception of possible services and something manually added to ignore list - will close ) is started - ColorControl should to pre launch actions, once game closed - post close actions such is reverting to previou state should be performed.
Basically, this is how Nvidia Control Pannel profiles get applied per game, same goes for SpecialK game monitoring (actually you can look for its source code and borrow whole game monitoring code from it, its pretty much ready to use solution for monitoring steam and other game launchers and games they launch, including child processes, it also has white and black lists).
Also could be nice if you can add global profile - basically any game from steam or other path (again see how its done in special k source code) turn on global profile, which can be overridden if specific game profile exist.
Example of usage - using full color range for desktop, setting display to limited range while game running to fix 99% of games that was designed for consoles and limited color range and has incorrect colors on PC because games are still limited withing full range, and setting display to limited does proper limited to full expansion in games and makes them look correct and equal to console versions.
Another example - use sdr for desktop, switch to hdr for specific games that support it.
One more example - set desktop display refresh rate to 30hz when running games that are limited to 30 fps, as 30 fps games runs smoother on 30hz while on 60hz or 120hz games in 30fps look very stuttery and choppy.
It also may be used for video players like MPC, this is why Title matching monitoring could be useful, especially with regext, that may help to detect words like HDR in title and switch to HDR (but there should also be composite match where both some path or exe name and title match patterns, with white and black list, to avoid triggering profile for lets say HDR word while you have opened browser and looking at page with HDR in title). Or even could be used to apply specific profile for some specific file name that is displayed in video player title.
Oh, one more thing - please add configurable time interval for monitoring, to let us choose between more immediate action or lesser load of CPU (i did several process monitors like that and in some cases 100 or 500 ms was necessary, but CPU load was higher, in other cases 1-5 seconds was enough, just let us choose and set this up, and use 1 second as default interval).