E:/Download/ois-1.0RC1/includes/OISKeyboard.h

Go to the documentation of this file.
00001 /*
00002 The zlib/libpng License
00003 
00004 Copyright (c) 2006 Phillip Castaneda (pjcast -- www.wreckedgames.com)
00005 
00006 This software is provided 'as-is', without any express or implied warranty. In no event will
00007 the authors be held liable for any damages arising from the use of this software.
00008 
00009 Permission is granted to anyone to use this software for any purpose, including commercial 
00010 applications, and to alter it and redistribute it freely, subject to the following
00011 restrictions:
00012 
00013     1. The origin of this software must not be misrepresented; you must not claim that 
00014                 you wrote the original software. If you use this software in a product, 
00015                 an acknowledgment in the product documentation would be appreciated but is 
00016                 not required.
00017 
00018     2. Altered source versions must be plainly marked as such, and must not be 
00019                 misrepresented as being the original software.
00020 
00021     3. This notice may not be removed or altered from any source distribution.
00022 */
00023 #ifndef OIS_Keyboard_H
00024 #define OIS_Keyboard_H
00025 #include "OISObject.h"
00026 #include "OISEvents.h"
00027 
00028 namespace OIS
00029 {
00031         enum KeyCode
00032         {
00033                 KC_UNASSIGNED  = 0x00,
00034                 KC_ESCAPE      = 0x01,
00035                 KC_1           = 0x02,
00036                 KC_2           = 0x03,
00037                 KC_3           = 0x04,
00038                 KC_4           = 0x05,
00039                 KC_5           = 0x06,
00040                 KC_6           = 0x07,
00041                 KC_7           = 0x08,
00042                 KC_8           = 0x09,
00043                 KC_9           = 0x0A,
00044                 KC_0           = 0x0B,
00045                 KC_MINUS       = 0x0C,    // - on main keyboard
00046                 KC_EQUALS      = 0x0D,
00047                 KC_BACK        = 0x0E,    // backspace
00048                 KC_TAB         = 0x0F,
00049                 KC_Q           = 0x10,
00050                 KC_W           = 0x11,
00051                 KC_E           = 0x12,
00052                 KC_R           = 0x13,
00053                 KC_T           = 0x14,
00054                 KC_Y           = 0x15,
00055                 KC_U           = 0x16,
00056                 KC_I           = 0x17,
00057                 KC_O           = 0x18,
00058                 KC_P           = 0x19,
00059                 KC_LBRACKET    = 0x1A,
00060                 KC_RBRACKET    = 0x1B,
00061                 KC_RETURN      = 0x1C,    // Enter on main keyboard
00062                 KC_LCONTROL    = 0x1D,
00063                 KC_A           = 0x1E,
00064                 KC_S           = 0x1F,
00065                 KC_D           = 0x20,
00066                 KC_F           = 0x21,
00067                 KC_G           = 0x22,
00068                 KC_H           = 0x23,
00069                 KC_J           = 0x24,
00070                 KC_K           = 0x25,
00071                 KC_L           = 0x26,
00072                 KC_SEMICOLON   = 0x27,
00073                 KC_APOSTROPHE  = 0x28,
00074                 KC_GRAVE       = 0x29,    // accent
00075                 KC_LSHIFT      = 0x2A,
00076                 KC_BACKSLASH   = 0x2B,
00077                 KC_Z           = 0x2C,
00078                 KC_X           = 0x2D,
00079                 KC_C           = 0x2E,
00080                 KC_V           = 0x2F,
00081                 KC_B           = 0x30,
00082                 KC_N           = 0x31,
00083                 KC_M           = 0x32,
00084                 KC_COMMA       = 0x33,
00085                 KC_PERIOD      = 0x34,    // . on main keyboard
00086                 KC_SLASH       = 0x35,    // / on main keyboard
00087                 KC_RSHIFT      = 0x36,
00088                 KC_MULTIPLY    = 0x37,    // * on numeric keypad
00089                 KC_LMENU       = 0x38,    // left Alt
00090                 KC_SPACE       = 0x39,
00091                 KC_CAPITAL     = 0x3A,
00092                 KC_F1          = 0x3B,
00093                 KC_F2          = 0x3C,
00094                 KC_F3          = 0x3D,
00095                 KC_F4          = 0x3E,
00096                 KC_F5          = 0x3F,
00097                 KC_F6          = 0x40,
00098                 KC_F7          = 0x41,
00099                 KC_F8          = 0x42,
00100                 KC_F9          = 0x43,
00101                 KC_F10         = 0x44,
00102                 KC_NUMLOCK     = 0x45,
00103                 KC_SCROLL      = 0x46,    // Scroll Lock
00104                 KC_NUMPAD7     = 0x47,
00105                 KC_NUMPAD8     = 0x48,
00106                 KC_NUMPAD9     = 0x49,
00107                 KC_SUBTRACT    = 0x4A,    // - on numeric keypad
00108                 KC_NUMPAD4     = 0x4B,
00109                 KC_NUMPAD5     = 0x4C,
00110                 KC_NUMPAD6     = 0x4D,
00111                 KC_ADD         = 0x4E,    // + on numeric keypad
00112                 KC_NUMPAD1     = 0x4F,
00113                 KC_NUMPAD2     = 0x50,
00114                 KC_NUMPAD3     = 0x51,
00115                 KC_NUMPAD0     = 0x52,
00116                 KC_DECIMAL     = 0x53,    // . on numeric keypad
00117                 KC_OEM_102     = 0x56,    // < > | on UK/Germany keyboards
00118                 KC_F11         = 0x57,
00119                 KC_F12         = 0x58,
00120                 KC_F13         = 0x64,    //                     (NEC PC98)
00121                 KC_F14         = 0x65,    //                     (NEC PC98)
00122                 KC_F15         = 0x66,    //                     (NEC PC98)
00123                 KC_KANA        = 0x70,    // (Japanese keyboard)
00124                 KC_ABNT_C1     = 0x73,    // / ? on Portugese (Brazilian) keyboards
00125                 KC_CONVERT     = 0x79,    // (Japanese keyboard)
00126                 KC_NOCONVERT   = 0x7B,    // (Japanese keyboard)
00127                 KC_YEN         = 0x7D,    // (Japanese keyboard)
00128                 KC_ABNT_C2     = 0x7E,    // Numpad . on Portugese (Brazilian) keyboards
00129                 KC_NUMPADEQUALS= 0x8D,    // = on numeric keypad (NEC PC98)
00130                 KC_PREVTRACK   = 0x90,    // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
00131                 KC_AT          = 0x91,    //                     (NEC PC98)
00132                 KC_COLON       = 0x92,    //                     (NEC PC98)
00133                 KC_UNDERLINE   = 0x93,    //                     (NEC PC98)
00134                 KC_KANJI       = 0x94,    // (Japanese keyboard)
00135                 KC_STOP        = 0x95,    //                     (NEC PC98)
00136                 KC_AX          = 0x96,    //                     (Japan AX)
00137                 KC_UNLABELED   = 0x97,    //                        (J3100)
00138                 KC_NEXTTRACK   = 0x99,    // Next Track
00139                 KC_NUMPADENTER = 0x9C,    // Enter on numeric keypad
00140                 KC_RCONTROL    = 0x9D,
00141                 KC_MUTE        = 0xA0,    // Mute
00142                 KC_CALCULATOR  = 0xA1,    // Calculator
00143                 KC_PLAYPAUSE   = 0xA2,    // Play / Pause
00144                 KC_MEDIASTOP   = 0xA4,    // Media Stop
00145                 KC_VOLUMEDOWN  = 0xAE,    // Volume -
00146                 KC_VOLUMEUP    = 0xB0,    // Volume +
00147                 KC_WEBHOME     = 0xB2,    // Web home
00148                 KC_NUMPADCOMMA = 0xB3,    // , on numeric keypad (NEC PC98)
00149                 KC_DIVIDE      = 0xB5,    // / on numeric keypad
00150                 KC_SYSRQ       = 0xB7,
00151                 KC_RMENU       = 0xB8,    // right Alt
00152                 KC_PAUSE       = 0xC5,    // Pause
00153                 KC_HOME        = 0xC7,    // Home on arrow keypad
00154                 KC_UP          = 0xC8,    // UpArrow on arrow keypad
00155                 KC_PGUP        = 0xC9,    // PgUp on arrow keypad
00156                 KC_LEFT        = 0xCB,    // LeftArrow on arrow keypad
00157                 KC_RIGHT       = 0xCD,    // RightArrow on arrow keypad
00158                 KC_END         = 0xCF,    // End on arrow keypad
00159                 KC_DOWN        = 0xD0,    // DownArrow on arrow keypad
00160                 KC_PGDOWN      = 0xD1,    // PgDn on arrow keypad
00161                 KC_INSERT      = 0xD2,    // Insert on arrow keypad
00162                 KC_DELETE      = 0xD3,    // Delete on arrow keypad
00163                 KC_LWIN        = 0xDB,    // Left Windows key
00164                 KC_RWIN        = 0xDC,    // Right Windows key
00165                 KC_APPS        = 0xDD,    // AppMenu key
00166                 KC_POWER       = 0xDE,    // System Power
00167                 KC_SLEEP       = 0xDF,    // System Sleep
00168                 KC_WAKE        = 0xE3,    // System Wake
00169                 KC_WEBSEARCH   = 0xE5,    // Web Search
00170                 KC_WEBFAVORITES= 0xE6,    // Web Favorites
00171                 KC_WEBREFRESH  = 0xE7,    // Web Refresh
00172                 KC_WEBSTOP     = 0xE8,    // Web Stop
00173                 KC_WEBFORWARD  = 0xE9,    // Web Forward
00174                 KC_WEBBACK     = 0xEA,    // Web Back
00175                 KC_MYCOMPUTER  = 0xEB,    // My Computer
00176                 KC_MAIL        = 0xEC,    // Mail
00177                 KC_MEDIASELECT = 0xED     // Media Select
00178         };
00179 
00183         class _OISExport KeyEvent : public EventArg
00184         {
00185         public:
00186                 KeyEvent( Object* obj, KeyCode kc, unsigned int txt ) : EventArg(obj), key(kc), text(txt) {}
00187                 virtual ~KeyEvent() {}
00188 
00190                 const KeyCode key;
00192                 unsigned int text;
00193         };
00194 
00199         class _OISExport KeyListener
00200         {
00201         public:
00202                 virtual ~KeyListener() {}
00203                 virtual bool keyPressed( const KeyEvent &arg ) = 0;
00204                 virtual bool keyReleased( const KeyEvent &arg ) = 0;            
00205         };
00206 
00211         class _OISExport Keyboard : public Object
00212         {
00213         public:
00214                 virtual ~Keyboard() {};
00215                 
00222                 virtual bool isKeyDown( KeyCode key ) = 0;
00223 
00231                 virtual void setEventCallback( KeyListener *keyListener ) {listener=keyListener;}
00232 
00237                 KeyListener* getEventCallback() {return listener;}
00238 
00240                 enum TextTranslationMode
00241                 {
00242                         Off,
00243                         Unicode,
00244                         Ascii
00245                 };
00246 
00256                 virtual void setTextTranslation( TextTranslationMode mode );
00257 
00262                 TextTranslationMode getTextTranslation(){return mTextMode;}
00263                 
00274                 virtual const std::string& getAsString( KeyCode kc ) = 0;
00275 
00277                 enum Modifier
00278                 {
00279                         Shift = 0x0000001,
00280                         Ctrl  = 0x0000010,
00281                         Alt   = 0x0000100
00282                 };
00283 
00288                 bool isModifierDown( Modifier mod );
00289 
00295                 virtual void copyKeyStates( char keys[256] ) = 0;
00296                 
00297         protected:
00298                 Keyboard();
00299 
00301                 unsigned int mModifiers;
00302 
00304                 KeyListener *listener;
00305 
00307                 TextTranslationMode mTextMode;
00308         };
00309 }
00310 #endif

Generated on Sat Dec 1 20:13:51 2007 for OIS by  doxygen 1.5.4