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

# OgreSDLInput.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 © 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
    00026
    00027 #ifndef __SDLInputReader_H__
    00028 #define __SDLInputReader_H__
    00029
    00030 #include "OgreInput.h"
    00031 #include "OgreInputEvent.h"
    00032 #include "OgreRenderWindow.h"
    00033
    00034 #include <map>
    00035
    00036 #if OGRE_PLATFORM == PLATFORM_APPLE
    00037 #   include <SDL/sdl.h>
    00038 #else
    00039 #   include <SDL.h>
    00040 #endif
    00041
    00042 namespace Ogre {
    00043     enum GrabMode
    00044     {
    00045         GRAB_NONE,
    00046         GRAB_MOUSE_OVER,
    00047         GRAB_MOUSE_CLICK   // this is the default
    00048     };
    00049
    00050     class SDLInput : public InputReader
    00051     {
    00052     public:
    00053         SDLInput();
    00054         virtual ~SDLInput();
    00055
    00056         void initialise( RenderWindow* pWindow, bool useKeyboard = true, bool useMouse = true, bool useGameController = false );
    00057         void capture();
    00058
    00064         void setGrabMode( GrabMode mode ) { mGrabMode = mode; }
    00065
    00066         /*
    00067          * Mouse getters
    00068          */
    00069         virtual long getMouseRelX() const;
    00070         virtual long getMouseRelY() const;
    00071         virtual long getMouseRelZ() const;
    00072
    00073         virtual long getMouseAbsX() const;
    00074         virtual long getMouseAbsY() const;
    00075         virtual long getMouseAbsZ() const;
    00076
    00077         virtual void getMouseState( MouseState& state ) const;
    00078
    00079         virtual bool getMouseButton( uchar button ) const;
    00080
    00081     private:
    00082         // State at last 'capture' call
    00083         Uint8* mKeyboardBuffer;
    00084         int mMaxKey;
    00085         int mMouseX, mMouseY;
    00086         int mMouseRelativeX, mMouseRelativeY, mMouseRelativeZ;
    00087         Real mScale;
    00088         Uint8 mMouseKeys;
    00089         bool _visible;
    00090
    00091         bool mMouseGrabbed;  // true if Ogre has control over the mouse input
    00092         bool mUseMouse;   // true if initialise() is called with useMouse == true
    00093         bool mGrabMouse;  // grab the mouse input if the situation specified by mGrabMode arises
    00094         bool mMouseLeft;  // true if the mouse pointer has left the window after calling releaseMouse(). Needed for
    00095                           // mGrabMode == GRAB_MOUSE_BUTTON.
    00096         int mGrabMode;    // when/how to grab the mouse
    00097
    00098         typedef std::map<SDLKey, KeyCode> InputKeyMap;
    00099         InputKeyMap _key_map;
    00100         bool warpMouse;
    00101
    00102         // the value that is added to mMouseRelativeZ when the wheel
    00103         // is moved one step (this value is actually added
    00104         // twice per movement since a wheel movement triggers a
    00105         // MOUSEBUTTONUP and a MOUSEBUTTONDOWN event).
    00106         // The value is chosen according to the windoze value.
    00107         static const unsigned int mWheelStep = 60;
    00108
    00109         void processBufferedKeyboard();
    00110         void processBufferedMouse();
    00111
    00112         void _grabMouse();
    00113         void _releaseMouse();
    00114         bool isKeyDownImmediate( KeyCode kc ) const;
    00115     };
    00116 }
    00117
    00118 #endif
    00119

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:46 2004