-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e3adb9
commit 0d085e4
Showing
10 changed files
with
159 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "Input.h" | ||
|
||
void Input::DisableInput(bool disable) | ||
{ | ||
*(bool*)0x8551A9 = disable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
class Input | ||
{ | ||
public: | ||
static void DisableInput(bool disable); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "MessageHook.h" | ||
|
||
#include "cdc/render/PCDeviceManager.h" | ||
|
||
static std::function<void(HWND, UINT, WPARAM, LPARAM)> s_callback; | ||
static WNDPROC s_original; | ||
|
||
static LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||
{ | ||
s_callback(hWnd, msg, wParam, lParam); | ||
|
||
return CallWindowProc(s_original, hWnd, msg, wParam, lParam); | ||
} | ||
|
||
void MessageHook::OnMessage(std::function<void(HWND, UINT, WPARAM, LPARAM)> callback) | ||
{ | ||
// Get the window handle | ||
auto hWnd = cdc::PCDeviceManager::s_pInstance->GetWindow(); | ||
|
||
// Set the new message handler to our handler | ||
s_original = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)WndProc); | ||
|
||
s_callback = callback; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
|
||
#include <Windows.h> | ||
#include <functional> | ||
|
||
class MessageHook | ||
{ | ||
public: | ||
static void OnMessage(std::function<void(HWND, UINT, WPARAM, LPARAM)> callback); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <Windows.h> | ||
#include <MinHook.h> | ||
|
||
#include "MouseHook.h" | ||
|
||
static bool s_disabled; | ||
static BOOL(WINAPI* s_SetCursorPos)(int, int); | ||
|
||
BOOL WINAPI SetCursorPosHook(int X, int Y) | ||
{ | ||
if (s_disabled) | ||
{ | ||
return TRUE; | ||
} | ||
|
||
return s_SetCursorPos(X, Y); | ||
} | ||
|
||
void MouseHook::Init() | ||
{ | ||
MH_CreateHookApi(L"user32", "SetCursorPos", SetCursorPosHook, (void**)&s_SetCursorPos); | ||
MH_EnableHook(MH_ALL_HOOKS); | ||
} | ||
|
||
void MouseHook::DisableCursorLock(bool disable) | ||
{ | ||
s_disabled = disable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
class MouseHook | ||
{ | ||
public: | ||
static void Init(); | ||
static void DisableCursorLock(bool disable); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
#pragma once | ||
|
||
#include <Windows.h> | ||
|
||
#include "cdc/render/PCInternalResource.h" | ||
|
||
class Menu : public cdc::PCInternalResource | ||
{ | ||
private: | ||
bool m_initialized = false; | ||
bool m_focus = false; | ||
|
||
public: | ||
Menu(); | ||
|
||
void OnPresent(); | ||
void OnMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); | ||
|
||
bool OnCreateDevice(); | ||
void OnDestroyDevice(); | ||
|
||
void SetFocus(bool focus); | ||
bool HasFocus(); | ||
|
||
private: | ||
void Draw(); | ||
}; |