-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputSystem.h
More file actions
53 lines (41 loc) · 1.25 KB
/
InputSystem.h
File metadata and controls
53 lines (41 loc) · 1.25 KB
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
49
50
51
52
#pragma once
#include <iostream>
#include "InputListener.h"
#include <Windows.h>
#include <vector>
#include "Point.h"
class InputSystem
{
public:
static InputSystem* getInstance();
static void initialize();
static void destroy();
void addListener(InputListener* listener);
void removeListener(InputListener* listener);
void update();
// Global methods for checking key input status
bool isKeyDown(int key);
bool isKeyUp(int key);
private:
static InputSystem* sharedInstance;
// Keyboard helper methods
void callOnKeyDown(int key);
void callOnKeyUp(int key);
// Mouse helper methods
void callOnMouseMove(Point deltaPt);
void callOnLeftMouseDown(Point deltaPt);
void callOnLeftMouseUp(Point deltaPt);
void callOnRightMouseDown(Point deltaPt);
void callOnRightMouseUp(Point deltaPt);
std::vector<InputListener*> inputListenerList;
// keyboard data
unsigned char keyStates[256] = {};
unsigned char oldKeyStates[256] = {};
// mouse data
Point oldMousePos;
bool firstTimeCall = true;
InputSystem();
~InputSystem();
InputSystem(InputSystem const&) {}; // copy constructor is private. You can also do `... = delete`
InputSystem& operator=(InputSystem const&) {}; // assignment operator is private. You can also do `... = delete`
};