Maybe will show notification on controller changed

This commit is contained in:
Kamil Trzciński 2022-11-26 14:27:21 +01:00
parent 17a71dc110
commit b977003efa
6 changed files with 36 additions and 10 deletions

View file

@ -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 |

View file

@ -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

View file

@ -26,6 +26,8 @@ namespace SteamController
public bool SteamRunning { get; set; } = false;
public bool SteamUsesController { get; set; } = false;
public event Action<Profiles.Profile> 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);
}
}
}

View file

@ -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);

View file

@ -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);
}
}
}

View file

@ -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;
}