-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeyboard.h
More file actions
66 lines (58 loc) · 1.4 KB
/
Keyboard.h
File metadata and controls
66 lines (58 loc) · 1.4 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Keyboard.h
* --------
* This header file contains definitions for methods used to encapsulate SDL's
* keyboard functionality. Hopefully this will make things like keyboard settings
* or even gamepad support easy.
*/
#ifndef KEYBOARD_H
#define KEYBOARD_H
// Each player is given at most, an NES controller's worth of buttons.
// This forces control simplicity, allows gamepad flexibility, and
// lets us cram 2 people onto a single keyboard.
typedef enum
{
ESCAPE_KEY,
P1_UP,
P1_DOWN,
P1_LEFT,
P1_RIGHT,
P1_A,
P1_B,
P1_START,
P1_SELECT,
P2_UP,
P2_DOWN,
P2_LEFT,
P2_RIGHT,
P2_A,
P2_B,
P2_START,
P2_SELECT
} gameKey;
/* pollKeyboard()
* Purpose: Updates the keyboard in memory. Should be called once every frame. Provides accurate gameKeys at that instant
* Returns: n/a
*/
void pollKeyboard();
/* setKey()
* Purpose: Sets a specific player key to a certain gameKey
* Returns: n/a
*/
void setKey(SDLKey input, gameKey key);
/* getKey()
* Purpose: Determines if a gameKey is pressed or not.
* Returns: -1 if pollKeyboard has never been called; 1 if specified key is down; 0 otherwise
*/
int getKey(gameKey key);
/* isEnterKey()
* Purpose: Checks if enter is down
* Returns: 0 if no, 1 if yes
*/
int isEnterKey();
/* getSDLKeyValue()
* Purpose: Determines what key is pressed corresponds to what gameKey
* Returns: SDLKey of specified gameKey
*/
SDLKey getSDLKeyValue(gameKey key);
#endif