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

OgreGLXInput.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 
00026 #ifndef __GLXInputReader_H__
00027 #define __GLXInputReader_H__
00028 
00029 #include "OgreInput.h"
00030 #include "OgreInputEvent.h"
00031 #include "OgreRenderWindow.h"
00032 
00033 #include <map>
00034 #include <set>
00035 
00036 #include <X11/Xlib.h>
00037 #include <X11/Xutil.h>
00038 #include <X11/keysym.h>
00039 #include <X11/Xproto.h>
00040 namespace Ogre {
00041 class GLXInput : public InputReader {
00042 public:
00043     GLXInput();
00044     virtual ~GLXInput();
00045 
00046     void initialise( RenderWindow* pWindow, bool useKeyboard = true, bool useMouse = true, bool useGameController = false );
00047     void capture();
00048 
00049 
00050     /*
00051      * Mouse getters
00052      */
00053     virtual long getMouseRelX() const;
00054     virtual long getMouseRelY() const;
00055     virtual long getMouseRelZ() const;
00056 
00057     virtual long getMouseAbsX() const;
00058     virtual long getMouseAbsY() const;
00059     virtual long getMouseAbsZ() const;
00060 
00061     virtual void getMouseState( MouseState& state ) const;
00062 
00063     virtual bool getMouseButton( uchar button ) const;
00064 
00065 private:
00066     CARD32 mHiddenCursor;
00067 
00068     // Map of X keys -> Ogre keys
00069     typedef std::map<KeySym, KeyCode> InputKeyMap;
00070     InputKeyMap _key_map;
00071 
00072     // Map of currently pressed keys
00073     typedef std::set<KeyCode> KeyPressedSet;
00074     KeyPressedSet _key_pressed_set;
00075 
00076     // Does the ogre input system want to capture the mouse (set with useMouse flag
00077     // on initialise)
00078     bool captureMouse;
00079     // Is mouse currently warped (captured within window?)
00080     bool warpMouse;
00081     int mouseLastX, mouseLastY;
00082 
00083     // Display and window, for event pumping
00084     Display *mDisplay;
00085     Window mWindow;
00086     RenderWindow *mRenderWindow;
00087 
00088     static const unsigned int mWheelStep = 100;
00089 
00090     void GrabCursor(bool grab);
00091 
00092     bool isKeyDownImmediate( KeyCode kc ) const;
00093 };
00094 
00095 }; // Namespace
00096 
00097 #endif
00098 

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:41 2006