FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
librocketinputprocessor.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_GUI_LIBROCKETINPUTPROCESSOR_H
23 #define FIFE_GUI_LIBROCKETINPUTPROCESSOR_H
24 
25 // Standard C++ library includes
26 #include <map>
27 
28 // 3rd party library includes
29 #include <Rocket/Core/Input.h>
30 #include <Rocket/Core/Types.h>
31 #include <SDL/SDL_events.h>
32 
33 // FIFE includes
34 // These includes are split up in two parts, separated by one empty line
35 // First block: files included from the FIFE root src directory
36 // Second block: files included from the same folder
37 #include "util/base/fife_stdint.h"
38 
39 namespace Rocket {
40  namespace Core {
41  class Context;
42  }
43 }
44 
45 namespace FIFE {
46 
48  public:
49 
52  LibRocketInputProcessor(Rocket::Core::Context* context);
53 
57 
66  bool onSdlEvent(SDL_Event &evt);
67 
71  void turn();
72 
73  private:
74 
77  void updateKeyModState();
78 
81  bool processMouseMotion(SDL_Event& event);
82 
85  bool processMouseInput(SDL_Event& event);
86 
89  bool processMouseWheelMotion(SDL_Event& event);
90 
93  bool processKeyInput(SDL_Event& event);
94 
97  void populateKeyMap();
98 
101  Rocket::Core::Context* m_context;
102 
106 
111  int32_t m_wheelCounter;
112 
115  std::map<SDLKey, Rocket::Core::Input::KeyIdentifier> m_keyMap;
116  };
117 
118 };
119 
120 #endif //FIFE_GUI_LIBROCKETINPUTPROCESSOR_H
bool onSdlEvent(SDL_Event &evt)
Processes SDL input and converts it to librocket input, then forwards it to the librocket context...
bool processMouseWheelMotion(SDL_Event &event)
Process a mouse wheel motion event.
bool processKeyInput(SDL_Event &event)
Process a key input event.
bool processMouseInput(SDL_Event &event)
Process a mouse input event.
LibRocketInputProcessor(Rocket::Core::Context *context)
Constructor.
void populateKeyMap()
Creates the key map.
void updateKeyModState()
Updates the key mod state bitmask.
uint32_t m_keyModState
Bitmask that stores key modifiers.
bool processMouseMotion(SDL_Event &event)
Process a mouse motion event.
int32_t m_wheelCounter
Counts how many times the wheel has been moved.
void turn()
Called each frame to perform update operations.
std::map< SDLKey, Rocket::Core::Input::KeyIdentifier > m_keyMap
Keymap to convert SDL key to Librocket key.
Rocket::Core::Context * m_context
Reference to librocket's context.
unsigned int uint32_t
Definition: core.h:40