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

Revision 692, 3.9 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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        Uint8 mMouseKeys;
88        bool _visible;
89               
90                bool mMouseGrabbed;  // true if Ogre has control over the mouse input
91                bool mUseMouse;   // true if initialise() is called with useMouse == true
92                bool mGrabMouse;  // grab the mouse input if the situation specified by mGrabMode arises
93                bool mMouseLeft;  // true if the mouse pointer has left the window after calling releaseMouse(). Needed for
94                                  // mGrabMode == GRAB_MOUSE_BUTTON.
95                int mGrabMode;    // when/how to grab the mouse
96
97        typedef std::map<SDLKey, KeyCode> InputKeyMap;
98        InputKeyMap _key_map;
99        bool warpMouse;
100
101                // the value that is added to mMouseRelativeZ when the wheel
102                // is moved one step (this value is actually added
103                // twice per movement since a wheel movement triggers a
104                // MOUSEBUTTONUP and a MOUSEBUTTONDOWN event).
105                // The value is chosen according to the windoze value.
106        static const unsigned int mWheelStep = 60;
107
108        void processBufferedKeyboard();
109        void processBufferedMouse();
110
111                void _grabMouse();
112                void _releaseMouse();
113        bool isKeyDownImmediate( KeyCode kc ) const;
114    };
115}
116
117#endif
118
Note: See TracBrowser for help on using the repository browser.