blob: fb9efaf2544d4f82d9985af17992f4068ca846fd (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
client/keyboard.h
This file is part of the Osirion project and is distributed under
the terms and conditions of the GNU General Public License version 2
*/
#ifndef __INCLUDED_CLIENT_KEYBOARD_H__
#define __INCLUDED_CLIENT_KEYBOARD_H__
#include <string>
#include <map>
#include "SDL/SDL.h"
#include "client/key.h"
namespace client {
class Keyboard
{
public:
Keyboard();
~Keyboard();
/// find a key on a keysym
Key *find(unsigned int keysym);
/// find a key on name
Key *find(std::string const & name);
/// bind a string to a key
void bind(std::string const &name, const std::string str);
/// clear the string bound to a key
void unbind(std::string const &name);
/// list keyboard key names
void list_keys();
/// list keyboard binds
void list_binds();
/// load keyboard binds
void load_binds();
/// save keyboard binds
void save_binds();
/// a key has been pressed
Key *press(unsigned int sym);
/// a key has been pressed
Key *release(unsigned int sym);
private:
typedef std::map<unsigned int, Key *>::iterator iterator;
inline iterator begin() { return keys.begin(); }
inline iterator end() { return keys.end(); }
void add_key(const char *name, const unsigned int keysym, const char ascii=0, const char *bind=0);
std::map<unsigned int, Key *> keys;
bool numlock;
bool capslock;
};
/// convert SDL_keysym to a keystroke
unsigned int translate_keysym(const SDL_keysym &keysym);
/// set the keyboard input mode
/** @param input true for console input, false for game input
*/
void setkeyboardmode(bool input);
}
#endif // __INCLUDED_CLIENT_KEYBOARD_H__
|