Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: alt+tab input sticking #403

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading