-
Notifications
You must be signed in to change notification settings - Fork 5
/
InputManager.h
48 lines (39 loc) · 1.22 KB
/
InputManager.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
48
#ifndef InputManagerH
#define InputManagerH
#include "basetypes.h"
#include <windows.h>
#include <tchar.h>
struct Joystick
{
GUID guid;
TCHAR tszName[MAX_PATH];
};
class InputManager
{
protected:
InputManager() {}
public:
enum InputType {
// When modifying, update StrToInputType().
KEY,
JOYPOV,
JOYAXIS,
JOYBUT,
};
static InputManager* Create();
static bool StrToInputType(const char* str, InputType* type);
static const char* InputTypeToStr(InputType type);
typedef void (*CONTROLLER_CALLBACK)(unsigned int controllerIdx, uint16 buttons);
typedef void (*ANYPRESSED_CALLBACK)(void* ctx, InputType type, int idx, int subIdx);
virtual ~InputManager() = 0;
virtual bool Init(HWND hDisplayWnd) = 0;
virtual void Activate() = 0;
virtual bool SetJoystick(size_t idx) = 0;
virtual void UpdateState(CONTROLLER_CALLBACK applyState, ANYPRESSED_CALLBACK anyPressed, void* anyCtx) = 0;
virtual void keyDown(CONTROLLER_CALLBACK applyState, int16 vkey) = 0;
virtual void keyUp(CONTROLLER_CALLBACK applyState, int16 vkey) = 0;
virtual bool GrabJoystick(HWND hWnd, size_t i) = 0;
virtual void UngrabJoystick() = 0;
virtual const Joystick* EnumJoysticks(size_t* pNumJoysticks) = 0;
};
#endif