diff --git a/README.md b/README.md index 875ae4d..82ba8f6 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ Of course you will have access to all described shortcuts. |----------------------------|------------------------|------------------------|------------------------|------------------------| | X360 Controller | Not connected | Connected | Not connected | Not connected | | Options (hold for 1s) | Switch to next profile | Switch to next profile | Switch to next profile | Switch to next profile | -| Options (hold for 3s) | | Switch to desktop | | | +| Options (hold for 3s) | Toggle desktop mode | Toggle desktop mode | | | | STEAM + Menu | WIN + Tab | WIN + Tab | WIN + Tab | WIN + Tab | | STEAM + Options | F11 | F11 | F11 | F11 | | STEAM + A | RETURN | RETURN | | RETURN | diff --git a/RELEASE.md b/RELEASE.md index d29e834..3e78478 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,6 +5,7 @@ - Fix incorrect `CurrentProfile` of `SteamController` - Fix right stick serving as mouse in `X360` mode - Improve build scripts in `scripts/` +- Show notification on controller changed ## 0.4.x diff --git a/SteamController/Context.cs b/SteamController/Context.cs index c58dae6..cd5a943 100644 --- a/SteamController/Context.cs +++ b/SteamController/Context.cs @@ -26,6 +26,8 @@ namespace SteamController public bool SteamRunning { get; set; } = false; public bool SteamUsesController { get; set; } = false; + public event Action ProfileChanged; + public bool Enabled { get { return RequestEnable; } @@ -55,6 +57,8 @@ namespace SteamController X360 = new Devices.Xbox360Controller(); Keyboard = new Devices.KeyboardController(); Mouse = new Devices.MouseController(); + + ProfileChanged += (_) => X360.Beep(); } public void Dispose() @@ -141,7 +145,9 @@ namespace SteamController list.Remove(profile); list.Insert(0, profile); RequestDesktopMode = profile.IsDesktop; - Beep(); + + if (profile.Selected(this)) + ProfileChanged(profile); return true; } @@ -163,16 +169,24 @@ namespace SteamController list.Remove(profile); list.Insert(0, profile); - Beep(); + ProfileChanged(profile); return true; } return false; } - public void Beep() + public void ToggleDesktopMode(bool? forceState = null) { - X360.Beep(); + var oldProfile = GetCurrentProfile(); + if (forceState is null) + RequestDesktopMode = !RequestDesktopMode; + else + RequestDesktopMode = forceState.Value; + + var newProfile = GetCurrentProfile(); + if (oldProfile != newProfile && newProfile is not null) + ProfileChanged(newProfile); } } } diff --git a/SteamController/Controller.cs b/SteamController/Controller.cs index 46827cf..cee954a 100644 --- a/SteamController/Controller.cs +++ b/SteamController/Controller.cs @@ -1,6 +1,5 @@ using CommonHelpers; using ExternalHelpers; -using SteamController.Helpers; using SteamController.Profiles; using System.ComponentModel; using System.Diagnostics; @@ -118,6 +117,18 @@ namespace SteamController contextStateUpdate.Enabled = true; contextStateUpdate.Tick += ContextStateUpdate_Tick; + context.ProfileChanged += (profile) => + { +#if false + notifyIcon.ShowBalloonTip( + 1000, + TitleWithVersion, + String.Format("Selected profile: {0}", profile.Name), + ToolTipIcon.Info + ); +#endif + }; + stopwatch.Start(); contextThread = new Thread(ContextState_Update); diff --git a/SteamController/Managers/ProcessManager.cs b/SteamController/Managers/ProcessManager.cs index 122c0b3..3cb91fe 100644 --- a/SteamController/Managers/ProcessManager.cs +++ b/SteamController/Managers/ProcessManager.cs @@ -31,7 +31,7 @@ namespace SteamController.Managers if (!activated) { activated = true; - context.RequestDesktopMode = false; + context.ToggleDesktopMode(false); } } else @@ -39,7 +39,7 @@ namespace SteamController.Managers if (activated) { activated = false; - context.RequestDesktopMode = true; + context.ToggleDesktopMode(true); } } } diff --git a/SteamController/Profiles/DefaultShortcutsProfile.cs b/SteamController/Profiles/DefaultShortcutsProfile.cs index 080a69a..8177636 100644 --- a/SteamController/Profiles/DefaultShortcutsProfile.cs +++ b/SteamController/Profiles/DefaultShortcutsProfile.cs @@ -28,13 +28,13 @@ namespace SteamController.Profiles { if (!c.SelectNext()) { - c.RequestDesktopMode = !c.RequestDesktopMode; + c.ToggleDesktopMode(); } return Status.Done; } else if (c.Steam.BtnOptions.HoldNext(HoldToSwitchDesktop, ShortcutConsumed, "SwitchToDesktop")) { - c.RequestDesktopMode = !c.RequestDesktopMode; + c.ToggleDesktopMode(); return Status.Done; }