mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-06 23:03:59 +00:00
PowerControl: Properly detect internal displays being connected
This commit is contained in:
parent
64f4050de5
commit
7c1099be48
3 changed files with 380 additions and 71 deletions
|
|
@ -17,9 +17,6 @@ namespace PowerControl
|
|||
public const int KeyPressRepeatTime = 400;
|
||||
public const int KeyPressNextRepeatTime = 90;
|
||||
|
||||
private SynchronizationContext? context;
|
||||
System.Windows.Forms.Timer contextTimer;
|
||||
|
||||
Container components = new Container();
|
||||
System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
StartupManager startupManager = new StartupManager(Title);
|
||||
|
|
@ -29,6 +26,8 @@ namespace PowerControl
|
|||
System.Windows.Forms.Timer osdDismissTimer;
|
||||
bool isOSDToggled = false;
|
||||
|
||||
bool wasInternalDisplayConnected;
|
||||
|
||||
hidapi.HidDevice neptuneDevice = new hidapi.HidDevice(0x28de, 0x1205, 64);
|
||||
SDCInput neptuneDeviceState = new SDCInput();
|
||||
DateTime? neptuneDeviceNextKey;
|
||||
|
|
@ -38,8 +37,8 @@ namespace PowerControl
|
|||
|
||||
static Controller()
|
||||
{
|
||||
Dependencies.ValidateHidapi(TitleWithVersion);
|
||||
Dependencies.ValidateRTSSSharedMemoryNET(TitleWithVersion);
|
||||
//Dependencies.ValidateHidapi(TitleWithVersion);
|
||||
//Dependencies.ValidateRTSSSharedMemoryNET(TitleWithVersion);
|
||||
}
|
||||
|
||||
public Controller()
|
||||
|
|
@ -55,11 +54,6 @@ namespace PowerControl
|
|||
if (Instance.WantsRunOnStartup)
|
||||
startupManager.Startup = true;
|
||||
|
||||
InitializeDisplayContext();
|
||||
contextTimer?.Start();
|
||||
|
||||
SystemEvents.DisplaySettingsChanged += DisplayChangesHandler;
|
||||
|
||||
var contextMenu = new System.Windows.Forms.ContextMenuStrip(components);
|
||||
|
||||
rootMenu.Init();
|
||||
|
|
@ -205,6 +199,9 @@ namespace PowerControl
|
|||
dismissNeptuneInput();
|
||||
});
|
||||
}
|
||||
|
||||
wasInternalDisplayConnected = ExternalHelpers.DisplayConfig.IsInternalConnected.GetValueOrDefault(false);
|
||||
SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
|
||||
}
|
||||
|
||||
private void OsdTimer_Tick(object? sender, EventArgs e)
|
||||
|
|
@ -399,27 +396,22 @@ namespace PowerControl
|
|||
}
|
||||
}
|
||||
|
||||
private void InitializeDisplayContext()
|
||||
{
|
||||
DeviceManager.LoadDisplays();
|
||||
contextTimer = new System.Windows.Forms.Timer();
|
||||
contextTimer.Interval = 200;
|
||||
contextTimer.Tick += (_, _) =>
|
||||
{
|
||||
context = SynchronizationContext.Current;
|
||||
contextTimer.Stop();
|
||||
};
|
||||
}
|
||||
|
||||
private void DisplayChangesHandler(object? sender, EventArgs e)
|
||||
private void SystemEvents_DisplaySettingsChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (DeviceManager.RefreshDisplays())
|
||||
{
|
||||
context?.Post((object? state) =>
|
||||
var isInternalDisplayConnected = ExternalHelpers.DisplayConfig.IsInternalConnected.GetValueOrDefault(false);
|
||||
if (wasInternalDisplayConnected == isInternalDisplayConnected)
|
||||
return;
|
||||
|
||||
Log.TraceLine("SystemEvents_DisplaySettingsChanged: wasConnected={0}, isConnected={1}",
|
||||
wasInternalDisplayConnected, isInternalDisplayConnected);
|
||||
|
||||
wasInternalDisplayConnected = isInternalDisplayConnected;
|
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(
|
||||
new Action(() =>
|
||||
{
|
||||
rootMenu.Update();
|
||||
}, null);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue