Skip to content

Commit

Permalink
Remove unnecessary warnings for SDL and Nixxes games about Windows.Ga…
Browse files Browse the repository at this point in the history
…ming.Input
  • Loading branch information
Kaldaien committed Dec 15, 2024
1 parent 8a5913e commit 27ebc46
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 30 deletions.
1 change: 1 addition & 0 deletions include/SpecialK/render/backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ class SK_RenderBackend_V2 : public SK_RenderBackend_V1
bool capcom = false;
bool sdl = false;
bool atlus = false;
bool nixxes = false;

void setFocus (HWND hWndFocus);
void setDevice (HWND hWndRender);
Expand Down
51 changes: 33 additions & 18 deletions src/input/windows.gaming.input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,25 +1003,40 @@ RoGetActivationFactory_Detour ( _In_ HSTRING activatableClassId,

if (bHasPlayStationControllers)
{
if ((! config.input.gamepad.xinput.emulate) && SK_GetCurrentGameID () != SK_GAME_ID::HorizonForbiddenWest &&
SK_GetCurrentGameID () != SK_GAME_ID::RatchetAndClank_RiftApart &&
SK_GetCurrentGameID () != SK_GAME_ID::ForzaHorizon5 &&
SK_GetCurrentGameID () != SK_GAME_ID::StarWarsOutlaws &&
(! SK_GetCurrentRenderBackend ().windows.sdl))
if ((! config.input.gamepad.xinput.emulate) && SK_GetCurrentGameID () != SK_GAME_ID::ForzaHorizon5 &&
SK_GetCurrentGameID () != SK_GAME_ID::StarWarsOutlaws &&
(! SK_GetCurrentRenderBackend ().windows.sdl) &&
(! SK_GetCurrentRenderBackend ().windows.nixxes))
{
SK_ImGui_CreateNotification ( "WindowsGamingInput.Compatibility",
SK_ImGui_Toast::Warning,
"This game uses Windows.Gaming.Input\r\n\r\n "
ICON_FA_PLAYSTATION " "
"Your PlayStation controller may not work unless Xbox Mode is"
" enabled\r\n\r\n\t(Input Management | PlayStation > Xbox Mode)"
" and restart the game.",
"Windows.Gaming.Input Incompatibility Detected",
15000UL,
SK_ImGui_Toast::UseDuration |
SK_ImGui_Toast::ShowTitle |
SK_ImGui_Toast::ShowCaption |
SK_ImGui_Toast::ShowOnce );
SK_RunOnce (SK_Thread_CreateEx([](LPVOID)->DWORD
{
while (game_window.hWnd == 0 || !IsWindow (game_window.hWnd))
{
SK_SleepEx (5, FALSE);
}

if ((! SK_GetCurrentRenderBackend ().windows.sdl) &&
(! SK_GetCurrentRenderBackend ().windows.nixxes))
{
SK_ImGui_CreateNotification ( "WindowsGamingInput.Compatibility",
SK_ImGui_Toast::Warning,
"This game uses Windows.Gaming.Input\r\n\r\n "
ICON_FA_PLAYSTATION " "
"Your PlayStation controller may not work unless Xbox Mode is"
" enabled\r\n\r\n\t(Input Management | PlayStation > Xbox Mode)"
" and restart the game.",
"Windows.Gaming.Input Incompatibility Detected",
15000UL,
SK_ImGui_Toast::UseDuration |
SK_ImGui_Toast::ShowTitle |
SK_ImGui_Toast::ShowCaption |
SK_ImGui_Toast::ShowOnce );
}

SK_Thread_CloseSelf ();

return 0;
}, L"[SK] Windows.Gaming.Input Warning Thread"));
}
}

Expand Down
34 changes: 22 additions & 12 deletions src/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ SK_MMCS_ApplyPendingTaskPriority (SK_TLS **ppTLS = nullptr)
}
}

void
bool
SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TLS **ppTLS)
{
UNREFERENCED_PARAMETER (ppTLS);
Expand All @@ -117,7 +117,7 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
bAlertable
);

return;
return 0;
}

//#define SK_DISPATCH_SLEEP
Expand Down Expand Up @@ -237,7 +237,7 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
dwMilliseconds = ReadAcquire (&_SK_NIER_RAD_InputPollingPeriod);

SK_SleepEx (dwMilliseconds, bAlertable);
return;
return 0;
}
}
#endif
Expand Down Expand Up @@ -318,10 +318,10 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
if (dwMaxWait < 5000UL)
{
if (! bGUIThread)
return;
return 0;

if (dwMaxWait <= (DWORD)config.render.framerate.max_delta_time)
return;
return 0;

DWORD dwWaitState =
MsgWaitForMultipleObjectsEx (
Expand All @@ -335,7 +335,7 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
if ( dwWaitState == WAIT_IO_COMPLETION)
{ ////SK_ReleaseAssert ( "WAIT_IO_COMPLETION"
//// && bAlertable );
return;
return 0;
}

// Waiting messages
Expand All @@ -345,19 +345,19 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
PeekAndDispatch ();
// ...
#endif
return;
return 1;
}

// DLL Shutdown
else if (dwWaitState == WAIT_OBJECT_0)
{
return;
return 0;
}

// Embarassing
else if (dwWaitState == WAIT_TIMEOUT)
{
return;
return 0;
}

// ???
Expand All @@ -369,19 +369,21 @@ SK_Thread_WaitWhilePumpingMessages (DWORD dwMilliseconds, BOOL bAlertable, SK_TL
}

if (dwMilliseconds == 0)
return;
return 1;
}

else
{
SK_SleepEx (dwMaxWait, bAlertable);
return;
return 0;
}

now =
SK_CurrentPerf ().QuadPart;
}
while (now < end);

return 1;
}

float
Expand Down Expand Up @@ -1278,7 +1280,8 @@ SleepEx_Detour (DWORD dwMilliseconds, BOOL bAlertable)
if (bRenderThread && SK_ImGui_Visible)
SK::Framerate::events.getMessagePumpStats ().wake (std::max (1UL, dwMilliseconds));

SK_Thread_WaitWhilePumpingMessages (dwMilliseconds, bAlertable, &pTLS);
auto skip_sleep =
SK_Thread_WaitWhilePumpingMessages (0, bAlertable, &pTLS);

// Check for I/O Wait Completion Before Going Sleepless
if (bAlertable)
Expand All @@ -1287,6 +1290,13 @@ SleepEx_Detour (DWORD dwMilliseconds, BOOL bAlertable)
return WAIT_IO_COMPLETION;
}

#ifndef SK_DISPATCH_SLEEP
//if (! skip_sleep)
// SwitchToThread ();
#endif

std::ignore = skip_sleep;

return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7496,6 +7496,11 @@ SK_MakeWindowHook (WNDPROC class_proc, WNDPROC wnd_proc, HWND hWnd)
SK_GetCurrentRenderBackend ().windows.sdl = true;
}

else if (!_wcsicmp(wszClassName, L"GameNxApp"))
{
SK_GetCurrentRenderBackend ().windows.nixxes = true;
}

else if (SK_GetCurrentGameID () == SK_GAME_ID::Metaphor ||
SK_GetCurrentGameID () == SK_GAME_ID::Persona4 ||
SK_GetCurrentGameID () == SK_GAME_ID::Persona5 ||
Expand Down

0 comments on commit 27ebc46

Please sign in to comment.