summaryrefslogtreecommitdiffstats
path: root/KeyboardController.h
blob: 0a1916593c537bb27f62cd3adb897fc9ace2360b (plain)
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
#ifndef _KEYBOARD_CONTROLLER_H
#define _KEYBOARD_CONTROLLER_H

#include "Controller.h"
#include "types.h"

// Compatible with glut values
typedef enum
{
	KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
	KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
	KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
	KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T,
	KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y,
	KEY_Z,
	KEY_0, KEY_1, KEY_2, KEY_3,
	KEY_4, KEY_5, KEY_6, KEY_7, KEY_8,
	KEY_9,
	KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT
} KeyCode;

class MainWindow;

/**
 * A class that links keybard inputs and player moves
 **/
class KeyboardController :
	public Controller
{
		typedef enum
		{
			NO_MOVE,
			MOVE_LEFT,
			MOVE_RIGHT
		} NextMove;
public:
	KeyboardController(Player* pPlayer, uint leftKey, uint rightKey);
	virtual ~KeyboardController(void);

public:
	/**
	 * Is called when a key is pressed
	 **/
	void PressKey(KeyCode key);
	/**
	 * Is called when a decision is required
	 **/
	void think();
	/**
	 * Resets the controller (does nothing here)
	 **/
	void reset();

private:
	const uint m_leftKey;
	const uint m_rightKey;
	NextMove m_nextMove;
};


#endif