source: OGRE/trunk/ogrenew/PlatformManagers/SDL/include/OgreSDLInput.h @ 657

Revision 657, 3.9 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25
26
27#ifndef __SDLInputReader_H__
28#define __SDLInputReader_H__
29
30#include "OgreInput.h"
31#include "OgreInputEvent.h"
32#include "OgreRenderWindow.h"
33
34#include <map>
35
36#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
37#       include <SDL/sdl.h>
38#else
39#       include <SDL.h>
40#endif
41
42namespace Ogre {
43        enum GrabMode
44        {
45                GRAB_NONE,
46                GRAB_MOUSE_OVER,
47                GRAB_MOUSE_CLICK   // this is the default
48        };
49
50    class SDLInput : public InputReader
51    {
52    public:
53        SDLInput();
54        virtual ~SDLInput();
55
56        void initialise( RenderWindow* pWindow, bool useKeyboard = true, bool useMouse = true, bool useGameController = false );
57        void capture();
58
59                /** Sets how to grab the mouse. Possible values for mode are GRAB_MOUSE_OVER
60                        or GRAB_MOUSE_BUTTON. The first will grab the mouse if the pointer is over the
61                        application window and the latter will wait for a mouse button click to aquire
62                        the mouse. Default is GRAB_MOUSE_CLICK.
63                 */
64                void setGrabMode( GrabMode mode ) { mGrabMode = mode; }
65
66        /*
67         * Mouse getters
68         */
69        virtual long getMouseRelX() const;
70        virtual long getMouseRelY() const;
71        virtual long getMouseRelZ() const;
72
73        virtual long getMouseAbsX() const;
74        virtual long getMouseAbsY() const;
75        virtual long getMouseAbsZ() const;
76
77        virtual void getMouseState( MouseState& state ) const;
78
79        virtual bool getMouseButton( uchar button ) const;
80
81    private:
82        // State at last 'capture' call
83        Uint8* mKeyboardBuffer;
84        int mMaxKey;
85        int mMouseX, mMouseY;
86        int mMouseRelativeX, mMouseRelativeY, mMouseRelativeZ;
87        Real mScale;
88        Uint8 mMouseKeys;
89        bool _visible;
90               
91                bool mMouseGrabbed;  // true if Ogre has control over the mouse input
92                bool mUseMouse;   // true if initialise() is called with useMouse == true
93                bool mGrabMouse;  // grab the mouse input if the situation specified by mGrabMode arises
94                bool mMouseLeft;  // true if the mouse pointer has left the window after calling releaseMouse(). Needed for
95                                  // mGrabMode == GRAB_MOUSE_BUTTON.
96                int mGrabMode;    // when/how to grab the mouse
97
98        typedef std::map<SDLKey, KeyCode> InputKeyMap;
99        InputKeyMap _key_map;
100        bool warpMouse;
101
102                // the value that is added to mMouseRelativeZ when the wheel
103                // is moved one step (this value is actually added
104                // twice per movement since a wheel movement triggers a
105                // MOUSEBUTTONUP and a MOUSEBUTTONDOWN event).
106                // The value is chosen according to the windoze value.
107        static const unsigned int mWheelStep = 60;
108
109        void processBufferedKeyboard();
110        void processBufferedMouse();
111
112                void _grabMouse();
113                void _releaseMouse();
114        bool isKeyDownImmediate( KeyCode kc ) const;
115    };
116}
117
118#endif
119
Note: See TracBrowser for help on using the repository browser.