-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDIInputHandler.h
47 lines (38 loc) · 1.3 KB
/
DIInputHandler.h
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
#ifndef DIINPUTHANDLER_H
#define DIINPUTHANDLER_H
#include <dinput.h>
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
class DIInputHandler
{
//Enums
public:
enum KEY_STATE{ KEY_DOWN, KEY_PRESSED, KEY_UP, KEY_RELEASED };
enum KEYBOARD{ W, A, S, D, SPACE, LCTRL, F1, F2, F3, F4, NUM_KEYB_KEYS };
enum MOUSE_KEY{ M_LBTN, M_MBTN, M_RBTN, NUM_MOUSE_KEYS };
enum MOUSE{ X, Y, NUM_MOUSE_AXIS };
private:
HINSTANCE* hInstance;
HWND* hWnd;
LPDIRECTINPUT8 din; // the pointer to our DirectInput interface
LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device
LPDIRECTINPUTDEVICE8 dinmouse; // the pointer to the mouse device
BYTE keystate[256]; // the storage for the key-information
DIMOUSESTATE mousestate; // the storage for the mouse-information
bool keys[NUM_KEYB_KEYS];
long mouse[NUM_MOUSE_AXIS];
int m_mouseKeys[NUM_MOUSE_KEYS];
// For the debug GUI
bool autoRotate;
float mouseSpeedX;
public:
DIInputHandler(HINSTANCE* hInstance, HWND* hWnd); // sets up and initializes DirectInput
~DIInputHandler(); //closes DirectInput and releases memory
void reset();
void detectInput(void); // gets the current input state
void update();
bool getKey(int key);
int getMouseKeyState( int p_key);
long getMouse(int axis);
};
#endif //INPUTHANDLER_H