Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
8 KB
Referenced Files
None
Subscribers
None
diff --git a/util/keyboard.h b/util/keyboard.h
index cd485ea1..afe219d5 100644
--- a/util/keyboard.h
+++ b/util/keyboard.h
@@ -1,196 +1,198 @@
#ifndef _keyboard_h
#define _keyboard_h
#include <map>
#include <vector>
/* handles allegro key[] array better than keypressed()
* and readkey()
*/
class Keyboard{
public:
+ typedef const int KeyType;
+
Keyboard();
/* poll:
* Put the keys in Allegro's key[] array into our map of int -> bool
*/
void poll();
/* wait for all keys to be released */
void wait();
/* []:
* Extract a boolean value given a key number
*/
inline const bool operator[] ( const int i ){
/* if the key has been pressed for the first time return true */
if ( my_keys[ i ] < 0 ){
my_keys[ i ] = 1;
return true;
}
bool b = my_keys[ i ] > key_delay[ i ];
if ( b ){
my_keys[ i ] = 1;
}
return b;
}
/* keypressed:
* Returns true if a key is pressed
*/
const bool keypressed();
/* readKeys:
* Store all pressed keys in a user supplied vector
*/
void readKeys( std::vector< int > & all_keys );
const int readKey();
void clear();
void setDelay( const int key, const int delay );
void setAllDelay( const int delay );
static const char * keyToName( int key );
static const bool isNumber( int key );
static const bool isChar( int key );
static const bool isAlpha( int key );
- static const int Key_A;
- static const int Key_B;
- static const int Key_C;
- static const int Key_D;
- static const int Key_E;
- static const int Key_F;
- static const int Key_G;
- static const int Key_H;
- static const int Key_I;
- static const int Key_J;
- static const int Key_K;
- static const int Key_L;
- static const int Key_M;
- static const int Key_N;
- static const int Key_O;
- static const int Key_P;
- static const int Key_Q;
- static const int Key_R;
- static const int Key_S;
- static const int Key_T;
- static const int Key_U;
- static const int Key_V;
- static const int Key_W;
- static const int Key_X;
- static const int Key_Y;
- static const int Key_Z;
- static const int Key_0;
- static const int Key_1;
- static const int Key_2;
- static const int Key_3;
- static const int Key_4;
- static const int Key_5;
- static const int Key_6;
- static const int Key_7;
- static const int Key_8;
- static const int Key_9;
- static const int Key_0_PAD;
- static const int Key_1_PAD;
- static const int Key_2_PAD;
- static const int Key_3_PAD;
- static const int Key_4_PAD;
- static const int Key_5_PAD;
- static const int Key_6_PAD;
- static const int Key_7_PAD;
- static const int Key_8_PAD;
- static const int Key_9_PAD;
- static const int Key_F1;
- static const int Key_F2;
- static const int Key_F3;
- static const int Key_F4;
- static const int Key_F5;
- static const int Key_F6;
- static const int Key_F7;
- static const int Key_F8;
- static const int Key_F9;
- static const int Key_F10;
- static const int Key_F11;
- static const int Key_F12;
- static const int Key_ESC;
- static const int Key_TILDE;
- static const int Key_MINUS;
- static const int Key_EQUALS;
- static const int Key_BACKSPACE;
- static const int Key_TAB;
- static const int Key_OPENBRACE;
- static const int Key_CLOSEBRACE;
- static const int Key_ENTER;
- static const int Key_COLON;
- static const int Key_QUOTE;
- static const int Key_BACKSLASH;
- static const int Key_BACKSLASH2;
- static const int Key_COMMA;
- static const int Key_STOP;
- static const int Key_SLASH;
- static const int Key_SPACE;
- static const int Key_INSERT;
- static const int Key_DEL;
- static const int Key_HOME;
- static const int Key_END;
- static const int Key_PGUP;
- static const int Key_PGDN;
- static const int Key_LEFT;
- static const int Key_RIGHT;
- static const int Key_UP;
- static const int Key_DOWN;
- static const int Key_SLASH_PAD;
- static const int Key_ASTERISK;
- static const int Key_MINUS_PAD;
- static const int Key_PLUS_PAD;
- static const int Key_DEL_PAD;
- static const int Key_ENTER_PAD;
- static const int Key_PRTSCR;
- static const int Key_PAUSE;
- static const int Key_ABNT_C1;
- static const int Key_YEN;
- static const int Key_KANA;
- static const int Key_CONVERT;
- static const int Key_NOCONVERT;
- static const int Key_AT;
- static const int Key_CIRCUMFLEX;
- static const int Key_COLON2;
- static const int Key_KANJI;
- static const int Key_EQUALS_PAD;
- static const int Key_BACKQUOTE;
- static const int Key_SEMICOLON;
- static const int Key_COMMAND;
- static const int Key_UNKNOWN1;
- static const int Key_UNKNOWN2;
- static const int Key_UNKNOWN3;
- static const int Key_UNKNOWN4;
- static const int Key_UNKNOWN5;
- static const int Key_UNKNOWN6;
- static const int Key_UNKNOWN7;
- static const int Key_UNKNOWN8;
- static const int Key_MODIFIERS;
- static const int Key_LSHIFT;
- static const int Key_RSHIFT;
- static const int Key_LCONTROL;
- static const int Key_RCONTROL;
- static const int Key_ALT;
- static const int Key_ALTGR;
- static const int Key_LWIN;
- static const int Key_RWIN;
- static const int Key_MENU;
- static const int Key_SCRLOCK;
- static const int Key_NUMLOCK;
- static const int Key_CAPSLOCK;
+ static KeyType Key_A;
+ static KeyType Key_B;
+ static KeyType Key_C;
+ static KeyType Key_D;
+ static KeyType Key_E;
+ static KeyType Key_F;
+ static KeyType Key_G;
+ static KeyType Key_H;
+ static KeyType Key_I;
+ static KeyType Key_J;
+ static KeyType Key_K;
+ static KeyType Key_L;
+ static KeyType Key_M;
+ static KeyType Key_N;
+ static KeyType Key_O;
+ static KeyType Key_P;
+ static KeyType Key_Q;
+ static KeyType Key_R;
+ static KeyType Key_S;
+ static KeyType Key_T;
+ static KeyType Key_U;
+ static KeyType Key_V;
+ static KeyType Key_W;
+ static KeyType Key_X;
+ static KeyType Key_Y;
+ static KeyType Key_Z;
+ static KeyType Key_0;
+ static KeyType Key_1;
+ static KeyType Key_2;
+ static KeyType Key_3;
+ static KeyType Key_4;
+ static KeyType Key_5;
+ static KeyType Key_6;
+ static KeyType Key_7;
+ static KeyType Key_8;
+ static KeyType Key_9;
+ static KeyType Key_0_PAD;
+ static KeyType Key_1_PAD;
+ static KeyType Key_2_PAD;
+ static KeyType Key_3_PAD;
+ static KeyType Key_4_PAD;
+ static KeyType Key_5_PAD;
+ static KeyType Key_6_PAD;
+ static KeyType Key_7_PAD;
+ static KeyType Key_8_PAD;
+ static KeyType Key_9_PAD;
+ static KeyType Key_F1;
+ static KeyType Key_F2;
+ static KeyType Key_F3;
+ static KeyType Key_F4;
+ static KeyType Key_F5;
+ static KeyType Key_F6;
+ static KeyType Key_F7;
+ static KeyType Key_F8;
+ static KeyType Key_F9;
+ static KeyType Key_F10;
+ static KeyType Key_F11;
+ static KeyType Key_F12;
+ static KeyType Key_ESC;
+ static KeyType Key_TILDE;
+ static KeyType Key_MINUS;
+ static KeyType Key_EQUALS;
+ static KeyType Key_BACKSPACE;
+ static KeyType Key_TAB;
+ static KeyType Key_OPENBRACE;
+ static KeyType Key_CLOSEBRACE;
+ static KeyType Key_ENTER;
+ static KeyType Key_COLON;
+ static KeyType Key_QUOTE;
+ static KeyType Key_BACKSLASH;
+ static KeyType Key_BACKSLASH2;
+ static KeyType Key_COMMA;
+ static KeyType Key_STOP;
+ static KeyType Key_SLASH;
+ static KeyType Key_SPACE;
+ static KeyType Key_INSERT;
+ static KeyType Key_DEL;
+ static KeyType Key_HOME;
+ static KeyType Key_END;
+ static KeyType Key_PGUP;
+ static KeyType Key_PGDN;
+ static KeyType Key_LEFT;
+ static KeyType Key_RIGHT;
+ static KeyType Key_UP;
+ static KeyType Key_DOWN;
+ static KeyType Key_SLASH_PAD;
+ static KeyType Key_ASTERISK;
+ static KeyType Key_MINUS_PAD;
+ static KeyType Key_PLUS_PAD;
+ static KeyType Key_DEL_PAD;
+ static KeyType Key_ENTER_PAD;
+ static KeyType Key_PRTSCR;
+ static KeyType Key_PAUSE;
+ static KeyType Key_ABNT_C1;
+ static KeyType Key_YEN;
+ static KeyType Key_KANA;
+ static KeyType Key_CONVERT;
+ static KeyType Key_NOCONVERT;
+ static KeyType Key_AT;
+ static KeyType Key_CIRCUMFLEX;
+ static KeyType Key_COLON2;
+ static KeyType Key_KANJI;
+ static KeyType Key_EQUALS_PAD;
+ static KeyType Key_BACKQUOTE;
+ static KeyType Key_SEMICOLON;
+ static KeyType Key_COMMAND;
+ static KeyType Key_UNKNOWN1;
+ static KeyType Key_UNKNOWN2;
+ static KeyType Key_UNKNOWN3;
+ static KeyType Key_UNKNOWN4;
+ static KeyType Key_UNKNOWN5;
+ static KeyType Key_UNKNOWN6;
+ static KeyType Key_UNKNOWN7;
+ static KeyType Key_UNKNOWN8;
+ static KeyType Key_MODIFIERS;
+ static KeyType Key_LSHIFT;
+ static KeyType Key_RSHIFT;
+ static KeyType Key_LCONTROL;
+ static KeyType Key_RCONTROL;
+ static KeyType Key_ALT;
+ static KeyType Key_ALTGR;
+ static KeyType Key_LWIN;
+ static KeyType Key_RWIN;
+ static KeyType Key_MENU;
+ static KeyType Key_SCRLOCK;
+ static KeyType Key_NUMLOCK;
+ static KeyType Key_CAPSLOCK;
protected:
std::map<int,int> my_keys;
std::map<int,int> key_delay;
};
#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 1:37 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
69282
Default Alt Text
(8 KB)

Event Timeline