Skip to content

Commit df379a0

Browse files
committed
Block gamepad input to games while the Windows/Xbox Game Bar is active, since it cannot do so itself.
1 parent 96dda47 commit df379a0

6 files changed

Lines changed: 39 additions & 9 deletions

File tree

CHANGELOG.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
26.4.18.2
1+
26.4.18.3
2+
=========
3+
+ Block gamepad input to games while the Windows/Xbox Game Bar is active,
4+
since it cannot do so itself.
5+
+ Prevent toggling SK's control panel while another overlay is active and
6+
SK is hiding itself.
7+
8+
26.4.18.2
29
=========
310
+ Fixed weird problem with Galaxy's DRM (not an April Fool's joke this time);
411
gog_1_112::UnauthorizedAccessError would continuously throw exceptions if

include/SpecialK/DLL_VERSION.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#define SK_YEAR 26
44
#define SK_MONTH 4
55
#define SK_DATE 18
6-
#define SK_REV_N 2
7-
#define SK_REV 2
6+
#define SK_REV_N 3
7+
#define SK_REV 3
88

99
#ifndef _A2
1010
#define _A2(a) #a

include/imgui/imgui_user.inl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,13 @@ SK_ImGui_ToggleEx ( bool& toggle_ui,
16241624
if (SK_ImGuiEx_Visible)
16251625
return SK_ImGui_Active ();
16261626

1627+
// Do not allow toggling SK's overlay while another overlay is hiding SK.
1628+
if ( config.platform.overlay_hides_sk_osd &&
1629+
SK_GetStoreOverlayState (true) )
1630+
{
1631+
return false;
1632+
}
1633+
16271634
//
16281635
// Only allow one toggle per-frame, even if we wind up calling
16291636
// this function multiple times to translate HID to XInput...

src/core.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,6 +5352,14 @@ SK_GetStoreOverlayState (bool bReal) noexcept
53525352
SK_Platform_GetOverlayState (bReal) ||
53535353
SK_ReShadeAddOn_IsOverlayActive ();
53545354

5355+
// The Xbox overlay cannot block PlayStation controller input to games,
5356+
// but Special K can... so if it's open, update gamepad capture state.
5357+
//
5358+
// Normally we would want the eopposite behavior, because most overlays
5359+
// run inside the game process, but Xbox's overlay is external.
5360+
if (ret && SK_Xbox_GetOverlayState (true))
5361+
SK_ImGui_WantGamepadCapture (true);
5362+
53555363
s_LastState.store (ret);
53565364
s_LastFrame.store (SK_GetFramesDrawn ());
53575365

src/input/input.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ SK_ImGui_WantGamepadCapture (bool update) noexcept
5959
return false;
6060
}
6161

62-
if (! SK_GImDefaultContext ())
62+
// Xbox Overlay skips this scenario, whether or not ImGui can draw anything,
63+
// we nmed to block input to the game on Xbox's behalf, since game bar does
64+
// not run any code inside the game to do this itself.
65+
if (! SK_Xbox_GetOverlayState (true))
6366
{
64-
capture.store (false);
65-
return false;
67+
if (! SK_GImDefaultContext ())
68+
{
69+
capture.store (false);
70+
return false;
71+
}
6672
}
6773

6874
auto _Return = [](BOOL bCapture) ->

src/storefront/xbox.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ SK_Xbox_GetOverlayState (bool real)
8080

8181
// This is a heavy API that requires IPC, ensure this is done at most
8282
// a single time per-frame...
83-
static bool last_state = false;
84-
static UINT64 last_frame = UINT64_MAX;
83+
static bool last_state = false;
84+
static UINT64 last_frame = 0;
8585

86-
if (last_frame == SK_GetFramesDrawn ())
86+
// Actually, throttle it even more... once every 10 frames.
87+
// - It's not cheap, and a callback would be better.
88+
if (last_frame > SK_GetFramesDrawn () - 10)
8789
return last_state;
8890

8991
if (SK_GameBar_Statics != nullptr)

0 commit comments

Comments
 (0)