Skip to content

Commit

Permalink
fix: alt+tab input sticking (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentalimbed authored Aug 9, 2024
1 parent 9f9ab0f commit 6277a6c
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,27 +308,15 @@ namespace Hooks
{
static LRESULT thunk(HWND a_hwnd, UINT a_msg, WPARAM a_wParam, LPARAM a_lParam)
{
if (a_msg == WM_KILLFOCUS) {
if (a_msg == WM_KILLFOCUS || a_msg == WM_SETFOCUS) {
Menu::GetSingleton()->OnFocusLost();
auto& io = ImGui::GetIO();
io.ClearInputKeys();
io.ClearEventsQueue();
}
return func(a_hwnd, a_msg, a_wParam, a_lParam);
}
static inline REL::Relocation<decltype(thunk)> func;
};

struct RegisterClassA_Hook
{
static ATOM thunk(WNDCLASSA* a_wndClass)
{
WndProcHandler_Hook::func = reinterpret_cast<uintptr_t>(a_wndClass->lpfnWndProc);
a_wndClass->lpfnWndProc = &WndProcHandler_Hook::thunk;

return func(a_wndClass);
}
static inline REL::Relocation<decltype(thunk)> func;
static inline WNDPROC func;
};

struct CreateRenderTarget_Main
Expand Down Expand Up @@ -473,7 +461,11 @@ namespace Hooks
stl::write_thunk_call<BSGraphics_Renderer_Init_InitD3D>(REL::RelocationID(75595, 77226).address() + REL::Relocate(0x50, 0x2BC));

logger::info("Hooking WndProcHandler");
stl::write_thunk_call_6<RegisterClassA_Hook>(REL::VariantID(75591, 77226, 0xDC4B90).address() + REL::VariantOffset(0x8E, 0x15C, 0x99).offset());
WndProcHandler_Hook::func = reinterpret_cast<WNDPROC>(
SetWindowLongPtrA(
RE::BSGraphics::Renderer::GetSingleton()->GetRuntimeData().renderWindows[0].hWnd,
GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(WndProcHandler_Hook::thunk)));

//logger::info("Hooking D3D11CreateDeviceAndSwapChain");
//*(FARPROC*)&ptrD3D11CreateDeviceAndSwapChain = GetProcAddress(GetModuleHandleA("d3d11.dll"), "D3D11CreateDeviceAndSwapChain");
Expand Down

0 comments on commit 6277a6c

Please sign in to comment.