CorsairOfficial / cue-sdk

Corsair iCUE SDK
https://corsairofficial.github.io/cue-sdk/
222 stars 25 forks source link

Documentation: Recommended actions after resume from sleep/hibernation? #5

Open xoblite opened 4 years ago

xoblite commented 4 years ago

Hi Corsair & Co,

I am working on an SDK client application for Windows 10, using the default shared access mode (i.e. no CorsairRequestControl / CorsairReleaseControl needed), which will typically be running for longer periods of time.

As this topic is not currently [or at least not explicitly] covered by the documentation, do you happen to have any recommendations with regards to what actions to perform when the system is e.g. resuming from sleep/hibernation? Should I perform a new CorsairPerformProtocolHandshake then for example? Anything else one should be aware of?

Thanks for making the SDK available; keep up the good work!

BR//KHH (@xoblite)

xoblite commented 4 years ago

Update:

I have now tried a few different approaches, including initiating a new handshake/update upon WM_POWERBROADCAST / PBT_APMRESUMEAUTOMATIC (i.e. resume from low power notification) as well as WM_WTSSESSION_CHANGE / WTS_SESSION_UNLOCK (i.e. screen unlock notification).

However, the only semi-working one I've found so far is by also setting a two second delay timer (read: enough delay on my pretty fast computer at least) upon WM_WTSSESSION_CHANGE / WTS_SESSION_UNLOCK, after which I attempt a new handshake with the CUE SDK, and if successful updating the device LEDs etc via regular means, i.e. pretty much like a regular application startup. Any thoughts?

I'm using the latest CUE SDK v3.0.301 (CUESDK_2013.dll) + the latest iCUE version 3.26.95.

BR//KHH (@xoblite)

RobertBeekman commented 4 years ago

Hello,

I'd recommend releasing the library handle on hibernate with FreeLibrary and reinstantiating with LoadLibrary on wake.

That way you shouldn't run into any race conditions

xoblite commented 4 years ago

Hi @SpoinkyNL ,

unfortunately this is not an option for this particular application, but thanks for the suggestion.

BR//KHH (@xoblite)