00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://ogre.sourceforge.net/ 00006 00007 Copyright © 2000-2002 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 #ifndef __Input_H__ 00026 #define __Input_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 #include "OgreInputEvent.h" 00030 00031 namespace Ogre { 00032 00035 enum KeyCode 00036 { 00037 KC_ESCAPE =0x01, 00038 KC_1 =0x02, 00039 KC_2 =0x03, 00040 KC_3 =0x04, 00041 KC_4 =0x05, 00042 KC_5 =0x06, 00043 KC_6 =0x07, 00044 KC_7 =0x08, 00045 KC_8 =0x09, 00046 KC_9 =0x0A, 00047 KC_0 =0x0B, 00048 KC_MINUS =0x0C, /* - on main keyboard */ 00049 KC_EQUALS =0x0D, 00050 KC_BACK =0x0E, /* backspace */ 00051 KC_TAB =0x0F, 00052 KC_Q =0x10, 00053 KC_W =0x11, 00054 KC_E =0x12, 00055 KC_R =0x13, 00056 KC_T =0x14, 00057 KC_Y =0x15, 00058 KC_U =0x16, 00059 KC_I =0x17, 00060 KC_O =0x18, 00061 KC_P =0x19, 00062 KC_LBRACKET =0x1A, 00063 KC_RBRACKET =0x1B, 00064 KC_RETURN =0x1C, /* Enter on main keyboard */ 00065 KC_LCONTROL =0x1D, 00066 KC_A =0x1E, 00067 KC_S =0x1F, 00068 KC_D =0x20, 00069 KC_F =0x21, 00070 KC_G =0x22, 00071 KC_H =0x23, 00072 KC_J =0x24, 00073 KC_K =0x25, 00074 KC_L =0x26, 00075 KC_SEMICOLON =0x27, 00076 KC_APOSTROPHE =0x28, 00077 KC_GRAVE =0x29, /* accent grave */ 00078 KC_LSHIFT =0x2A, 00079 KC_BACKSLASH =0x2B, 00080 KC_Z =0x2C, 00081 KC_X =0x2D, 00082 KC_C =0x2E, 00083 KC_V =0x2F, 00084 KC_B =0x30, 00085 KC_N =0x31, 00086 KC_M =0x32, 00087 KC_COMMA =0x33, 00088 KC_PERIOD =0x34, /* . on main keyboard */ 00089 KC_SLASH =0x35, /* '/' on main keyboard */ 00090 KC_RSHIFT =0x36, 00091 KC_MULTIPLY =0x37, /* * on numeric keypad */ 00092 KC_LMENU =0x38, /* left Alt */ 00093 KC_SPACE =0x39, 00094 KC_CAPITAL =0x3A, 00095 KC_F1 =0x3B, 00096 KC_F2 =0x3C, 00097 KC_F3 =0x3D, 00098 KC_F4 =0x3E, 00099 KC_F5 =0x3F, 00100 KC_F6 =0x40, 00101 KC_F7 =0x41, 00102 KC_F8 =0x42, 00103 KC_F9 =0x43, 00104 KC_F10 =0x44, 00105 KC_NUMLOCK =0x45, 00106 KC_SCROLL =0x46, /* Scroll Lock */ 00107 KC_NUMPAD7 =0x47, 00108 KC_NUMPAD8 =0x48, 00109 KC_NUMPAD9 =0x49, 00110 KC_SUBTRACT =0x4A, /* - on numeric keypad */ 00111 KC_NUMPAD4 =0x4B, 00112 KC_NUMPAD5 =0x4C, 00113 KC_NUMPAD6 =0x4D, 00114 KC_ADD =0x4E, /* + on numeric keypad */ 00115 KC_NUMPAD1 =0x4F, 00116 KC_NUMPAD2 =0x50, 00117 KC_NUMPAD3 =0x51, 00118 KC_NUMPAD0 =0x52, 00119 KC_DECIMAL =0x53, /* . on numeric keypad */ 00120 KC_OEM_102 =0x56, /* < > | on UK/Germany keyboards */ 00121 KC_F11 =0x57, 00122 KC_F12 =0x58, 00123 KC_F13 =0x64, /* (NEC PC98) */ 00124 KC_F14 =0x65, /* (NEC PC98) */ 00125 KC_F15 =0x66, /* (NEC PC98) */ 00126 KC_KANA =0x70, /* (Japanese keyboard) */ 00127 KC_ABNT_C1 =0x73, /* / ? on Portugese (Brazilian) keyboards */ 00128 KC_CONVERT =0x79, /* (Japanese keyboard) */ 00129 KC_NOCONVERT =0x7B, /* (Japanese keyboard) */ 00130 KC_YEN =0x7D, /* (Japanese keyboard) */ 00131 KC_ABNT_C2 =0x7E, /* Numpad . on Portugese (Brazilian) keyboards */ 00132 KC_NUMPADEQUALS =0x8D, /* = on numeric keypad (NEC PC98) */ 00133 KC_PREVTRACK =0x90, /* Previous Track (KC_CIRCUMFLEX on Japanese keyboard) */ 00134 KC_AT =0x91, /* (NEC PC98) */ 00135 KC_COLON =0x92, /* (NEC PC98) */ 00136 KC_UNDERLINE =0x93, /* (NEC PC98) */ 00137 KC_KANJI =0x94, /* (Japanese keyboard) */ 00138 KC_STOP =0x95, /* (NEC PC98) */ 00139 KC_AX =0x96, /* (Japan AX) */ 00140 KC_UNLABELED =0x97, /* (J3100) */ 00141 KC_NEXTTRACK =0x99, /* Next Track */ 00142 KC_NUMPADENTER =0x9C, /* Enter on numeric keypad */ 00143 KC_RCONTROL =0x9D, 00144 KC_MUTE =0xA0, /* Mute */ 00145 KC_CALCULATOR =0xA1, /* Calculator */ 00146 KC_PLAYPAUSE =0xA2, /* Play / Pause */ 00147 KC_MEDIASTOP =0xA4, /* Media Stop */ 00148 KC_VOLUMEDOWN =0xAE, /* Volume - */ 00149 KC_VOLUMEUP =0xB0, /* Volume + */ 00150 KC_WEBHOME =0xB2, /* Web home */ 00151 KC_NUMPADCOMMA =0xB3, /* , on numeric keypad (NEC PC98) */ 00152 KC_DIVIDE =0xB5, /* / on numeric keypad */ 00153 KC_SYSRQ =0xB7, 00154 KC_RMENU =0xB8, /* right Alt */ 00155 KC_PAUSE =0xC5, /* Pause */ 00156 KC_HOME =0xC7, /* Home on arrow keypad */ 00157 KC_UP =0xC8, /* UpArrow on arrow keypad */ 00158 KC_PGUP =0xC9, /* PgUp on arrow keypad */ 00159 KC_LEFT =0xCB, /* LeftArrow on arrow keypad */ 00160 KC_RIGHT =0xCD, /* RightArrow on arrow keypad */ 00161 KC_END =0xCF, /* End on arrow keypad */ 00162 KC_DOWN =0xD0, /* DownArrow on arrow keypad */ 00163 KC_PGDOWN =0xD1, /* PgDn on arrow keypad */ 00164 KC_INSERT =0xD2, /* Insert on arrow keypad */ 00165 KC_DELETE =0xD3, /* Delete on arrow keypad */ 00166 KC_LWIN =0xDB, /* Left Windows key */ 00167 KC_RWIN =0xDC, /* Right Windows key */ 00168 KC_APPS =0xDD, /* AppMenu key */ 00169 KC_POWER =0xDE, /* System Power */ 00170 KC_SLEEP =0xDF, /* System Sleep */ 00171 KC_WAKE =0xE3, /* System Wake */ 00172 KC_WEBSEARCH =0xE5, /* Web Search */ 00173 KC_WEBFAVORITES =0xE6, /* Web Favorites */ 00174 KC_WEBREFRESH =0xE7, /* Web Refresh */ 00175 KC_WEBSTOP =0xE8, /* Web Stop */ 00176 KC_WEBFORWARD =0xE9, /* Web Forward */ 00177 KC_WEBBACK =0xEA, /* Web Back */ 00178 KC_MYCOMPUTER =0xEB, /* My Computer */ 00179 KC_MAIL =0xEC, /* Mail */ 00180 KC_MEDIASELECT =0xED /* Media Select */ 00181 }; 00182 00185 struct _OgreExport MouseState 00186 { 00188 long Xabs, Yabs, Zabs; 00190 long Xrel, Yrel, Zrel; 00193 long Buttons; 00194 00196 inline long isButtonDown( uchar button ) const 00197 { 00198 return Buttons & ( 1 << button ); 00199 } 00200 }; 00201 00213 class _OgreExport InputReader 00214 { 00215 public: 00216 InputReader(); 00217 virtual ~InputReader(); 00218 00225 void useBufferedInput( EventQueue* pEventQueue ); 00226 00239 virtual void initialise( 00240 RenderWindow* pWindow, 00241 bool useKeyboard = true, 00242 bool useMouse = true, 00243 bool useGameController = false ) = 0; 00244 00254 virtual void capture() = 0; 00255 00260 virtual bool isKeyDown( KeyCode kc ) const = 0; 00261 00264 virtual long getMouseRelativeX() const { return getMouseRelX(); } 00265 00268 virtual long getMouseRelativeY() const { return getMouseRelY(); } 00269 00272 virtual long getMouseRelativeZ() const { return getMouseRelZ(); } 00273 00276 virtual long getMouseRelX() const = 0; 00277 00280 virtual long getMouseRelY() const = 0; 00281 00284 virtual long getMouseRelZ() const = 0; 00285 00287 virtual long getMouseAbsX() const = 0; 00289 virtual long getMouseAbsY() const = 0; 00291 virtual long getMouseAbsZ() const = 0; 00292 00294 virtual void getMouseState( MouseState& state ) const = 0; 00295 00297 virtual bool getMouseButton( uchar button ) const = 0; 00298 00301 void addCursorMoveListener( MouseMotionListener* c ); 00302 00305 void removeCursorMoveListener( MouseMotionListener* c ); 00306 00307 protected: 00308 00311 long mModifiers; 00312 00318 Cursor* mCursor; 00319 00321 EventQueue* mEventQueue; 00322 00326 bool mUseBuffered; 00327 00329 MouseState mMouseState; 00330 00331 protected: 00333 void mouseMoved(); 00334 00337 void createMouseEvent(int id, int button); 00338 00340 void triggerMouseButton(int nMouseCode, bool mousePressed); 00341 }; 00342 00343 00351 typedef void (*DLL_CREATEINPUTREADER)(InputReader** ppReader); 00352 00353 } 00354 00355 #endif
Copyright © 2002 by The OGRE Team