-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathInputSys.hpp
48 lines (36 loc) · 1.03 KB
/
InputSys.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <functional>
enum class KeyState
{
None = 1,
Down,
Up,
Pressed /*Down and then up*/
};
class InputSys
{
InputSys();
~InputSys();
public:
void Initialize( IDirect3DDevice9* device );
HWND GetMainWindow() const { return m_hTargetWindow; }
KeyState GetKeyState( uint32_t vk );
bool IsKeyDown( uint32_t vk );
bool WasKeyPressed( uint32_t vk );
void RegisterHotkey( uint32_t vk, std::function<void( void )> f );
void RemoveHotkey( uint32_t vk );
static InputSys& ins()
{
static InputSys i;
return i;
}
static LRESULT CALLBACK hkWndProc( const HWND hwnd, const UINT message, const WPARAM w_param, const LPARAM l_param );
private:
bool ProcessMessage( UINT uMsg, WPARAM wParam, LPARAM lParam );
bool ProcessMouseMessage( UINT uMsg, WPARAM wParam, LPARAM lParam );
bool ProcessKeybdMessage( UINT uMsg, WPARAM wParam, LPARAM lParam );
HWND m_hTargetWindow;
LONG_PTR m_ulOldWndProc;
KeyState m_iKeyMap[ 256 ];
std::function<void( void )> m_Hotkeys[ 256 ];
};