forked from flareteam/flare-engine
/
InputState.h
102 lines (82 loc) · 2.13 KB
/
InputState.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Copyright © 2011-2012 Clint Bellanger
This file is part of FLARE.
FLARE is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
FLARE. If not, see http://www.gnu.org/licenses/
*/
#ifndef INPUT_STATE_H
#define INPUT_STATE_H
#include "Utils.h"
#include <SDL.h>
#include <string>
#define JOY_DEADZONE 100
#define JOY_POS_CENTER 0
#define JOY_POS_LEFT -1
#define JOY_POS_RIGHT 1
#define JOY_POS_UP -1
#define JOY_POS_DOWN 1
// Input commands enum
const int CANCEL = 0;
const int ACCEPT = 1;
const int UP = 2;
const int DOWN = 3;
const int LEFT = 4;
const int RIGHT = 5;
const int BAR_1 = 6;
const int BAR_2 = 7;
const int BAR_3 = 8;
const int BAR_4 = 9;
const int BAR_5 = 10;
const int BAR_6 = 11;
const int BAR_7 = 12;
const int BAR_8 = 13;
const int BAR_9 = 14;
const int BAR_0 = 15;
const int CHARACTER = 16;
const int INVENTORY = 17;
const int POWERS = 18;
const int LOG = 19;
const int MAIN1 = 20;
const int MAIN2 = 21;
const int CTRL = 22;
const int SHIFT = 23;
const int DEL = 24;
/**
* class InputState
*
* Handles keyboard and mouse states
*/
class InputState {
public:
static const int key_count = 25;
static const int joy_key_count = 2;
int binding[key_count];
int binding_alt[key_count];
int joy_binding[joy_key_count];
std::string binding_name[25];
std::string mouse_button[7];
InputState(void);
~InputState();
void defaultQwertyKeyBindings();
void loadKeyBindings();
void saveKeyBindings();
void handle(bool dump_event);
void resetScroll();
bool pressing[key_count];
bool lock[key_count];
bool joy_pressing[joy_key_count];
bool done;
Point mouse;
std::string inkeys;
int last_key;
int last_button;
bool scroll_up;
bool scroll_down;
};
#endif