Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.blamite
The core library for the Blamite Game Engine.
SdlInputHandler.h
Go to the documentation of this file.
1 
2 //Thanks to Jordan Milne and Scrawl for allowing to use their
3 //sdlinputwrapper files as base under the MIT license
4 
5 #ifndef _Demo_SdlInputHandler_H_
6 #define _Demo_SdlInputHandler_H_
7 
8 #include "BaseSystem.h"
9 #include "OGRE/OgrePrerequisites.h"
10 #include "SdlEmulationLayer.h"
11 
12 #if OGRE_USE_SDL2
13 
14 #include <SDL2/SDL.h>
15 
16 namespace Demo
17 {
18  class MouseListener;
19  class KeyboardListener;
20  class JoystickListener;
21 
22  class SdlInputHandler
23  {
24  SDL_Window *mSdlWindow;
25 
26  BaseSystem *mGraphicsSystem;
27  BaseSystem *mLogicSystem;
28  MouseListener *mMouseListener;
29  KeyboardListener *mKeyboardListener;
30  JoystickListener *mJoystickListener;
31 
32  // User settings
37  bool mWantRelative;
39  bool mWantMouseGrab;
41  bool mWantMouseVisible;
42 
43  // Describes internal state.
44  bool mIsMouseRelative;
46  bool mWrapPointerManually;
47  bool mGrabPointer;
48  bool mMouseInWindow;
49  bool mWindowHasFocus;
50 
51  int mWarpX;
52  int mWarpY;
53  bool mWarpCompensate;
54 
55  void updateMouseSettings(void);
56 
57  void handleWindowEvent( const SDL_Event& evt );
58 
60  void warpMouse( int x, int y);
61 
63  void wrapMousePointer( const SDL_MouseMotionEvent& evt );
64 
67  bool handleWarpMotion( const SDL_MouseMotionEvent& evt );
68 
69  public:
70  SdlInputHandler( SDL_Window *sdlWindow,
71  MouseListener *mouseListener,
72  KeyboardListener *keyboardListener,
73  JoystickListener *joystickListener );
74  virtual ~SdlInputHandler();
75 
76  void _handleSdlEvents( const SDL_Event& evt );
77 
79  void setGrabMousePointer( bool grab );
80 
87  void setMouseRelative( bool relative );
88 
90  void setMouseVisible( bool visible );
91 
92  void _overrideKeyboardListener( KeyboardListener *listener );
93  void _overrideMouseListener( MouseListener *listener );
94  KeyboardListener *getKeyboardListener( void );
95  MouseListener *getMouseListener( void );
96  };
97 }
98 
99 #endif
100 
101 #endif
InputListeners.h
SDL_MouseMotionEvent
Mouse motion event structure (event.motion.
Definition: SdlEmulationLayer.h:691
Demo::Mq::SDL_EVENT
@ SDL_EVENT
Definition: MqMessages.h:21
SDL_Event::motion
SDL_MouseMotionEvent motion
Mouse motion event data.
Definition: SdlEmulationLayer.h:739
SDL_Event::button
SDL_MouseButtonEvent button
Mouse button event data.
Definition: SdlEmulationLayer.h:740
width
int width
Definition: bgfx.cpp:19
Demo
Definition: BaseSystem.cpp:5
y
font DisplayOffset y
Definition: README.txt:68
SdlEmulationLayer.h
SDL_Event::key
SDL_KeyboardEvent key
Keyboard event data.
Definition: SdlEmulationLayer.h:738
SDL_MouseButtonEvent::button
Ogre::uint8 button
The mouse button index.
Definition: SdlEmulationLayer.h:713
height
int height
Definition: bgfx.cpp:20
BaseSystem.h
x
config GlyphExtraSpacing x
Definition: README.txt:30
SdlInputHandler.h
SDL_MouseMotionEvent::y
Ogre::int32 y
Y coordinate, relative to window.
Definition: SdlEmulationLayer.h:699
SDL_Event::type
Ogre::uint32 type
Event type, shared with all events.
Definition: SdlEmulationLayer.h:737
SDL_MouseMotionEvent::x
Ogre::int32 x
X coordinate, relative to window.
Definition: SdlEmulationLayer.h:698
SDL_Event
Definition: SdlEmulationLayer.h:735
SDL_KeyboardEvent::repeat
Ogre::uint8 repeat
Non-zero if this is a key repeat.
Definition: SdlEmulationLayer.h:682