Pulse-Eight / cec-dotnet

.Net implementations using libCEC
Other
24 stars 10 forks source link

added: ApplicationAction to suspend PC #10

Open rbares opened 4 years ago

rbares commented 4 years ago

Fixes #9.

Although the "sleep" button mapping does not work correctly in newer versions of Windows, reliable APIs are available for doing so. This diff adds a new action (alongside "close CECTray" and "start application") which enables the user to configure libCECTray to suspend their PC via a button mapping. This follows the same mechanism as other ApplicationActions but calls Application.SetSuspendState when triggered. The parameters used trigger a suspend (i.e. sleep as opposed to hibernate), forcing the suspend to occur immediately, and ensuring wake events are not disabled when doing so.

rbares commented 4 years ago

If you see value in this I'd like to propose an additional PR providing a checkbox in the "Configuration" tab to automatically suspend the PC if the TV changes to a different source. This could work well in use-cases (like mine) where the user interacting with the TV remote should have authority over the PC, rather than the current mechanisms offered by libCECTray which mostly give the PC authority (waking TV, changing active source to PC, putting TV into standby).

Please let me know if this PR and/or the proposed checkbox fit your current intentions for the project.

rbares commented 4 years ago

I suspect this PR may benefit from a change to bring it in-line with StopTvStandby as used in CECController.ReceiveCommand. This would send a Stop keypress to each ApplicationController, disable callbacks, and then do a non-forcing suspend. Will wait to hear your view.