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     float mMouseSpeed;  // Speed of mouse
00067     CARD32 mHiddenCursor;
00068 
00069     // Map of X keys -> Ogre keys
00070     typedef std::map<KeySym, KeyCode> InputKeyMap;
00071     InputKeyMap _key_map;
00072 
00073     // Map of currently pressed keys
00074     typedef std::set<KeyCode> KeyPressedSet;
00075     KeyPressedSet _key_pressed_set;
00076 
00077     // Does the ogre input system want to capture the mouse (set with useMouse flag
00078     // on initialise)
00079     bool captureMouse;
00080     // Is mouse currently warped (captured within window?)
00081     bool warpMouse;
00082     int mouseLastX, mouseLastY;
00083 
00084     // Display and window, for event pumping
00085     Display *mDisplay;
00086     Window mWindow;
00087     RenderWindow *mRenderWindow;
00088 
00089     static const unsigned int mWheelStep = 100;
00090 
00091     void GrabCursor(bool grab);
00092 
00093     bool isKeyDownImmediate( KeyCode kc ) const;
00094 };
00095 
00096 }; // Namespace
00097 
00098 #endif
00099 

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 Feb 12 12:59:45 2006