From 7292a8a7be49720267ee273c9a24256227cebbfa Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 20 Mar 2024 21:58:43 +0300 Subject: [PATCH] more mouse fixes --- CyberXeSS/CyberXeSS.vcxproj | 2 +- CyberXeSS/Util.cpp | 8 ++++---- CyberXeSS/imgui/Imgui_Base.cpp | 35 ++++++++++++++++++++++------------ 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/CyberXeSS/CyberXeSS.vcxproj b/CyberXeSS/CyberXeSS.vcxproj index e6c94112..748c0db3 100644 --- a/CyberXeSS/CyberXeSS.vcxproj +++ b/CyberXeSS/CyberXeSS.vcxproj @@ -82,7 +82,7 @@ $(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(IncludePath) $(SolutionDir)CyberXess\cas\lib;$(SolutionDir)CyberXess\fsr2\lib;$(SolutionDir)CyberXess\fsr2_212\lib;$(SolutionDir)CyberXess\vulkan;$(SolutionDir)external\xess\lib;C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) nvngx - D:\Folders\Games\Cyberpunk 2077\bin\x64\ + E:\Games\Deep Rock Galactic\FSD\Binaries\Win64\ .\x64\Debug diff --git a/CyberXeSS/Util.cpp b/CyberXeSS/Util.cpp index 4a6224b6..a7e59c7e 100644 --- a/CyberXeSS/Util.cpp +++ b/CyberXeSS/Util.cpp @@ -58,10 +58,10 @@ HWND Util::GetProcessWindow() { HWND hwnd = nullptr; EnumWindows(EnumWindowsCallback, (LPARAM)&hwnd); - while (!hwnd) { - EnumWindows(EnumWindowsCallback, (LPARAM)&hwnd); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - } + //while (!hwnd) { + // EnumWindows(EnumWindowsCallback, (LPARAM)&hwnd); + // std::this_thread::sleep_for(std::chrono::milliseconds(500)); + //} return hwnd; } \ No newline at end of file diff --git a/CyberXeSS/imgui/Imgui_Base.cpp b/CyberXeSS/imgui/Imgui_Base.cpp index 0ccfa1a3..687e4010 100644 --- a/CyberXeSS/imgui/Imgui_Base.cpp +++ b/CyberXeSS/imgui/Imgui_Base.cpp @@ -3,6 +3,7 @@ #include "imgui/imgui_impl_win32.h" #include "../detours/detours.h" +#include "../Util.h" #pragma comment(lib, "../detours/detours.lib") PFN_SetCursorPos pfn_SetPhysicalCursorPos = nullptr; @@ -22,7 +23,7 @@ WNDPROC _oWndProc = nullptr; LRESULT WINAPI hkSendMessageW(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { if (_isVisible && Msg == 0x0020) - return TRUE; + return true; else return pfn_SendMessageW(hWnd, Msg, wParam, lParam); } @@ -54,7 +55,7 @@ void WINAPI hkmouse_event(DWORD dwFlags, DWORD dx, DWORD dy, DWORD dwData, ULONG UINT WINAPI hkSendInput(UINT cInputs, LPINPUT pInputs, int cbSize) { if (_isVisible) - return 0; + return TRUE; else return pfn_SendInput(cInputs, pInputs, cbSize); } @@ -63,7 +64,7 @@ void AttachHooks() { DetourTransactionBegin(); DetourUpdateThread(GetCurrentThread()); - + // Detour the functions pfn_SetPhysicalCursorPos = reinterpret_cast(DetourFindFunction("user32.dll", "SetPhysicalCursorPos")); pfn_SetCursorPos = reinterpret_cast(DetourFindFunction("user32.dll", "SetCursorPos")); @@ -133,21 +134,21 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) ImGuiIO& io = ImGui::GetIO(); (void)io; // CTRL + HOME - if (msg == WM_KEYDOWN && wParam == VK_HOME && (GetKeyState(VK_CONTROL) & 0x8000)) + if (msg == WM_KEYDOWN && wParam == VK_INSERT) // && (GetKeyState(VK_CONTROL) & 0x8000)) { _isVisible = !_isVisible; io.MouseDrawCursor = _isVisible; io.WantCaptureKeyboard = _isVisible; io.WantCaptureMouse = _isVisible; - return true; + return TRUE; } // Imgui if (_isVisible) { if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) - return true; + return TRUE; switch (msg) { @@ -157,18 +158,28 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: - case WM_MOUSEWHEEL: - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: + case WM_KEYDOWN: + case WM_KEYUP: + case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_MOUSEMOVE: case WM_SETCURSOR: - return true; + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDBLCLK: + case WM_MBUTTONDBLCLK: + case WM_XBUTTONDOWN: + case WM_XBUTTONUP: + case WM_XBUTTONDBLCLK: + case WM_MOUSELAST: + case WM_INPUT: + return TRUE; default: break; } + + auto log = std::format("WNDPROC MSG : {}", msg); + OutputDebugStringA(log.c_str()); } return CallWindowProc(_oWndProc, hWnd, msg, wParam, lParam); @@ -662,7 +673,7 @@ void Imgui_Base::RenderMenu() bool Imgui_Base::IsHandleDifferent() { - HWND frontWindow = GetForegroundWindow(); + HWND frontWindow = Util::GetProcessWindow(); // GetForegroundWindow(); if (frontWindow == _handle) return false;