| 1 |
#ifndef HEADER_KEYSTROKE_H |
| 2 |
#define HEADER_KEYSTROKE_H |
| 3 |
|
| 4 |
#include "SDL.h" |
| 5 |
#include <string> |
| 6 |
|
| 7 |
/** |
| 8 |
* KeyStroke. |
| 9 |
*/ |
| 10 |
class KeyStroke { |
| 11 |
private: |
| 12 |
static const int STROKE_IGNORE = ~(KMOD_CTRL|KMOD_ALT); |
| 13 |
SDLKey m_sym; |
| 14 |
int m_mod; |
| 15 |
Uint16 m_unicode; |
| 16 |
private: |
| 17 |
static int modStrip(int mod); |
| 18 |
public: |
| 19 |
KeyStroke(const SDL_keysym &keysym); |
| 20 |
KeyStroke(SDLKey sym, int mod); |
| 21 |
|
| 22 |
SDLKey getKey() const { return m_sym; } |
| 23 |
Uint16 getUnicode() const { return m_unicode; } |
| 24 |
bool less(const KeyStroke &other) const; |
| 25 |
bool equals(const KeyStroke &other) const; |
| 26 |
std::string toString() const; |
| 27 |
}; |
| 28 |
|
| 29 |
/** |
| 30 |
* KeyStroke comparation. |
| 31 |
*/ |
| 32 |
struct stroke_less |
| 33 |
{ |
| 34 |
bool operator()(const KeyStroke &left, const KeyStroke &right) const |
| 35 |
{ |
| 36 |
return left.less(right); |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
#endif |