Skip to content

Commit dbb55fe

Browse files
committed
InputManager: fix exclusive fullscreen with SDL
1 parent 7622b34 commit dbb55fe

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/hooks_graphics.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ class WindowedBorderless : public Hook
407407
Settings::WindowPositionX, Settings::WindowPositionY,
408408
Game::screen_resolution->x, Game::screen_resolution->y,
409409
0x40);
410-
411-
void InputManager_Init(HWND);
412-
InputManager_Init(window);
413410
}
414411

415412
public:

src/input_manager.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,20 @@ class InputManager
205205

206206
SDL_Init(SDL_INIT_GAMEPAD | SDL_INIT_VIDEO);
207207

208+
// Need to setup SDL_Window for SDL to see keyboard events
208209
SDL_PropertiesID props = SDL_CreateProperties();
209-
if (props == 0)
210-
{
211-
spdlog::error(__FUNCTION__ ": failed to create properties ({})", SDL_GetError());
212-
}
213-
else
210+
if (props)
214211
{
215212
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, "OutRun2006Tweaks");
216213
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, true);
217214
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, 1280);
218215
SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, 720);
219216
SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER, hwnd);
220217

221-
window = SDL_CreateWindowWithProperties(props); // Needed for SDL keyboard events
218+
window = SDL_CreateWindowWithProperties(props);
222219
}
220+
else
221+
spdlog::error(__FUNCTION__ ": failed to create properties ({}), keyboard might not work with UseNewInput properly!", SDL_GetError());
223222

224223
setupKeyboardBindings();
225224
}
@@ -488,12 +487,6 @@ class InputManager
488487
};
489488
InputManager InputManager::instance;
490489

491-
void InputManager_Init(HWND window)
492-
{
493-
if (Settings::UseNewInput)
494-
InputManager::instance.init(window);
495-
}
496-
497490
void InputManager_Update()
498491
{
499492
if (Settings::UseNewInput)
@@ -559,6 +552,13 @@ class NewInputHook : public Hook
559552
return VolumeSwitch_hook.ccall<int>(volumeId);
560553
}
561554

555+
inline static SafetyHookMid WindowInit_hook = {};
556+
static void WindowInit_dest(SafetyHookContext& ctx)
557+
{
558+
if (Settings::UseNewInput)
559+
InputManager::instance.init((HWND)ctx.ebp);
560+
}
561+
562562
public:
563563
std::string_view description() override
564564
{
@@ -577,6 +577,7 @@ class NewInputHook : public Hook
577577
GetVolume_hook = safetyhook::create_inline(Module::exe_ptr(0x53720), GetVolume_dest);
578578
GetVolumeOld_hook = safetyhook::create_inline(Module::exe_ptr(0x53750), GetVolumeOld_dest);
579579
VolumeSwitch_hook = safetyhook::create_inline(Module::exe_ptr(0x53780), VolumeSwitch_dest);
580+
WindowInit_hook = safetyhook::create_mid(Module::exe_ptr(0xEB2B), WindowInit_dest);
580581

581582
return true;
582583
}

0 commit comments

Comments
 (0)