Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreInput.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 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 
00030 namespace Ogre {
00031 
00034     enum KeyCode
00035     {
00036         KC_ESCAPE          =0x01,
00037         KC_1               =0x02,
00038         KC_2               =0x03,
00039         KC_3               =0x04,
00040         KC_4               =0x05,
00041         KC_5               =0x06,
00042         KC_6               =0x07,
00043         KC_7               =0x08,
00044         KC_8               =0x09,
00045         KC_9               =0x0A,
00046         KC_0               =0x0B,
00047         KC_MINUS           =0x0C,    /* - on main keyboard */
00048         KC_EQUALS          =0x0D,
00049         KC_BACK            =0x0E,    /* backspace */
00050         KC_TAB             =0x0F,
00051         KC_Q               =0x10,
00052         KC_W               =0x11,
00053         KC_E               =0x12,
00054         KC_R               =0x13,
00055         KC_T               =0x14,
00056         KC_Y               =0x15,
00057         KC_U               =0x16,
00058         KC_I               =0x17,
00059         KC_O               =0x18,
00060         KC_P               =0x19,
00061         KC_LBRACKET        =0x1A,
00062         KC_RBRACKET        =0x1B,
00063         KC_RETURN          =0x1C,    /* Enter on main keyboard */
00064         KC_LCONTROL        =0x1D,
00065         KC_A               =0x1E,
00066         KC_S               =0x1F,
00067         KC_D               =0x20,
00068         KC_F               =0x21,
00069         KC_G               =0x22,
00070         KC_H               =0x23,
00071         KC_J               =0x24,
00072         KC_K               =0x25,
00073         KC_L               =0x26,
00074         KC_SEMICOLON       =0x27,
00075         KC_APOSTROPHE      =0x28,
00076         KC_GRAVE           =0x29,    /* accent grave */
00077         KC_LSHIFT          =0x2A,
00078         KC_BACKSLASH       =0x2B,
00079         KC_Z               =0x2C,
00080         KC_X               =0x2D,
00081         KC_C               =0x2E,
00082         KC_V               =0x2F,
00083         KC_B               =0x30,
00084         KC_N               =0x31,
00085         KC_M               =0x32,
00086         KC_COMMA           =0x33,
00087         KC_PERIOD          =0x34,    /* . on main keyboard */
00088         KC_SLASH           =0x35,    /* '/' on main keyboard */
00089         KC_RSHIFT          =0x36,
00090         KC_MULTIPLY        =0x37,    /* * on numeric keypad */
00091         KC_LMENU           =0x38,    /* left Alt */
00092         KC_SPACE           =0x39,
00093         KC_CAPITAL         =0x3A,
00094         KC_F1              =0x3B,
00095         KC_F2              =0x3C,
00096         KC_F3              =0x3D,
00097         KC_F4              =0x3E,
00098         KC_F5              =0x3F,
00099         KC_F6              =0x40,
00100         KC_F7              =0x41,
00101         KC_F8              =0x42,
00102         KC_F9              =0x43,
00103         KC_F10             =0x44,
00104         KC_NUMLOCK         =0x45,
00105         KC_SCROLL          =0x46,    /* Scroll Lock */
00106         KC_NUMPAD7         =0x47,
00107         KC_NUMPAD8         =0x48,
00108         KC_NUMPAD9         =0x49,
00109         KC_SUBTRACT        =0x4A,    /* - on numeric keypad */
00110         KC_NUMPAD4         =0x4B,
00111         KC_NUMPAD5         =0x4C,
00112         KC_NUMPAD6         =0x4D,
00113         KC_ADD             =0x4E,    /* + on numeric keypad */
00114         KC_NUMPAD1         =0x4F,
00115         KC_NUMPAD2         =0x50,
00116         KC_NUMPAD3         =0x51,
00117         KC_NUMPAD0         =0x52,
00118         KC_DECIMAL         =0x53,    /* . on numeric keypad */
00119         KC_OEM_102         =0x56,    /* < > | on UK/Germany keyboards */
00120         KC_F11             =0x57,
00121         KC_F12             =0x58,
00122         KC_F13             =0x64,    /*                     (NEC PC98) */
00123         KC_F14             =0x65,    /*                     (NEC PC98) */
00124         KC_F15             =0x66,    /*                     (NEC PC98) */
00125         KC_KANA            =0x70,    /* (Japanese keyboard)            */
00126         KC_ABNT_C1         =0x73,    /* / ? on Portugese (Brazilian) keyboards */
00127         KC_CONVERT         =0x79,    /* (Japanese keyboard)            */
00128         KC_NOCONVERT       =0x7B,    /* (Japanese keyboard)            */
00129         KC_YEN             =0x7D,    /* (Japanese keyboard)            */
00130         KC_ABNT_C2         =0x7E,    /* Numpad . on Portugese (Brazilian) keyboards */
00131         KC_NUMPADEQUALS    =0x8D,    /* = on numeric keypad (NEC PC98) */
00132         KC_PREVTRACK       =0x90,    /* Previous Track (KC_CIRCUMFLEX on Japanese keyboard) */
00133         KC_AT              =0x91,    /*                     (NEC PC98) */
00134         KC_COLON           =0x92,    /*                     (NEC PC98) */
00135         KC_UNDERLINE       =0x93,    /*                     (NEC PC98) */
00136         KC_KANJI           =0x94,    /* (Japanese keyboard)            */
00137         KC_STOP            =0x95,    /*                     (NEC PC98) */
00138         KC_AX              =0x96,    /*                     (Japan AX) */
00139         KC_UNLABELED       =0x97,    /*                        (J3100) */
00140         KC_NEXTTRACK       =0x99,    /* Next Track */
00141         KC_NUMPADENTER     =0x9C,    /* Enter on numeric keypad */
00142         KC_RCONTROL        =0x9D,
00143         KC_MUTE            =0xA0,    /* Mute */
00144         KC_CALCULATOR      =0xA1,    /* Calculator */
00145         KC_PLAYPAUSE       =0xA2,    /* Play / Pause */
00146         KC_MEDIASTOP       =0xA4,    /* Media Stop */
00147         KC_VOLUMEDOWN      =0xAE,    /* Volume - */
00148         KC_VOLUMEUP        =0xB0,    /* Volume + */
00149         KC_WEBHOME         =0xB2,    /* Web home */
00150         KC_NUMPADCOMMA     =0xB3,    /* , on numeric keypad (NEC PC98) */
00151         KC_DIVIDE          =0xB5,    /* / on numeric keypad */
00152         KC_SYSRQ           =0xB7,
00153         KC_RMENU           =0xB8,    /* right Alt */
00154         KC_PAUSE           =0xC5,    /* Pause */
00155         KC_HOME            =0xC7,    /* Home on arrow keypad */
00156         KC_UP              =0xC8,    /* UpArrow on arrow keypad */
00157         KC_PGUP            =0xC9,    /* PgUp on arrow keypad */
00158         KC_LEFT            =0xCB,    /* LeftArrow on arrow keypad */
00159         KC_RIGHT           =0xCD,    /* RightArrow on arrow keypad */
00160         KC_END             =0xCF,    /* End on arrow keypad */
00161         KC_DOWN            =0xD0,    /* DownArrow on arrow keypad */
00162         KC_PGDOWN          =0xD1,    /* PgDn on arrow keypad */
00163         KC_INSERT          =0xD2,    /* Insert on arrow keypad */
00164         KC_DELETE          =0xD3,    /* Delete on arrow keypad */
00165         KC_LWIN            =0xDB,    /* Left Windows key */
00166         KC_RWIN            =0xDC,    /* Right Windows key */
00167         KC_APPS            =0xDD,    /* AppMenu key */
00168         KC_POWER           =0xDE,    /* System Power */
00169         KC_SLEEP           =0xDF,    /* System Sleep */
00170         KC_WAKE            =0xE3,    /* System Wake */
00171         KC_WEBSEARCH       =0xE5,    /* Web Search */
00172         KC_WEBFAVORITES    =0xE6,    /* Web Favorites */
00173         KC_WEBREFRESH      =0xE7,    /* Web Refresh */
00174         KC_WEBSTOP         =0xE8,    /* Web Stop */
00175         KC_WEBFORWARD      =0xE9,    /* Web Forward */
00176         KC_WEBBACK         =0xEA,    /* Web Back */
00177         KC_MYCOMPUTER      =0xEB,    /* My Computer */
00178         KC_MAIL            =0xEC,    /* Mail */
00179         KC_MEDIASELECT     =0xED     /* Media Select */
00180     };
00181 
00184     struct _OgreExport MouseState
00185     {
00187         long Xabs, Yabs, Zabs;
00189         long Xrel, Yrel, Zrel;
00192         long Buttons;
00193 
00195         inline long isButtonDown( uchar button ) const
00196         {
00197             return Buttons & ( 1 << button );
00198         }
00199     };
00200 
00212     class _OgreExport InputReader
00213     {
00214     public:
00215         InputReader();
00216         virtual ~InputReader();
00217 
00224         void useBufferedInput(EventQueue* pEventQueue, bool keys = true, bool mouse = true) ;
00225 
00226         virtual void setBufferedInput(bool keys, bool mouse) ;
00227             
00228 
00241         virtual void initialise( 
00242             RenderWindow* pWindow, 
00243             bool useKeyboard = true, 
00244             bool useMouse = true, 
00245             bool useGameController = false ) = 0;
00246 
00256         virtual void capture() = 0;
00257 
00262         virtual bool isKeyDown( KeyCode kc ) const;
00263 
00266         virtual long getMouseRelativeX() const { return getMouseRelX(); }
00267 
00270         virtual long getMouseRelativeY() const { return getMouseRelY(); }
00271 
00274         virtual long getMouseRelativeZ() const { return getMouseRelZ(); }
00275 
00278         virtual long getMouseRelX() const = 0;
00279 
00282         virtual long getMouseRelY() const = 0;
00283 
00286         virtual long getMouseRelZ() const = 0;
00287 
00289         virtual long getMouseAbsX() const = 0;
00291         virtual long getMouseAbsY() const = 0;
00293         virtual long getMouseAbsZ() const = 0;
00294 
00296         virtual void getMouseState( MouseState& state ) const = 0;
00297 
00299         virtual bool getMouseButton( uchar button ) const = 0;
00300 
00303         void addCursorMoveListener( MouseMotionListener* c );
00304     
00307         void removeCursorMoveListener( MouseMotionListener* c );
00308         static char getKeyChar(int keyCode, long modifiers = 0);
00309 
00313         virtual void setMouseScale( Real scale ) { mMouseScale = scale; }
00314         
00317         virtual Real getMouseScale( void ) const { return mMouseScale; }
00318         
00319 
00320 
00321     protected:
00322 
00325         long mModifiers;
00326 
00328         Real mMouseScale;
00329 
00336         Cursor* mCursor;
00337 
00339         EventQueue* mEventQueue;
00340 
00344         bool mUseBufferedKeys, mUseBufferedMouse;
00345 
00347         MouseState mMouseState;
00348 
00350         typedef std::set<KeyCode> BufferedKeysDownSet;
00351         BufferedKeysDownSet mBufferedKeysDown;
00352 
00354         void mouseMoved();
00355 
00358         void createMouseEvent(int id, int button);
00359 
00361         void triggerMouseButton(int nMouseCode, bool mousePressed);
00362 
00363         void createKeyEvent(int id, int key);
00364         void keyChanged(int key, bool down);
00365         
00367         virtual bool isKeyDownImmediate( KeyCode kc ) const = 0;
00368     };
00369 
00370 
00378     typedef void (*DLL_CREATEINPUTREADER)(InputReader** ppReader);
00379 
00380 }
00381 
00382 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:43 2006