i6engine  1.0
MouseListener.h
Go to the documentation of this file.
1 /*
2  * i6engine
3  * Copyright (2016) Daniel Bonrath, Michael Baer, All rights reserved.
4  *
5  * This file is part of i6engine; i6engine is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
25 #ifndef __I6ENGINE_MODULES_MOUSELISTENER_H__
26 #define __I6ENGINE_MODULES_MOUSELISTENER_H__
27 
28 #include <array>
29 #include <cstdint>
30 #include <map>
31 
33 
34 #include "i6engine/api/KeyCodes.h"
36 
37 #include "OIS/OISMouse.h"
38 
39 namespace OIS {
40  class MouseEvent;
41 } /* namespace OIS */
42 
43 namespace i6e {
44 namespace modules {
45 
46  class InputManager;
47 
52  class MouseListener : public OIS::MouseListener {
53  friend class InputManager;
54 
55  typedef std::map<std::pair<api::KeyCode, api::KeyState>, boost::function<void(void)>> InputKeyFunctions;
56 
57  private:
58  std::array<api::KeyState, size_t(api::KeyCode::COUNT)> _keyStates;
59  std::array<char, size_t(api::KeyCode::COUNT)> _keyTexts;
60 
61  InputKeyFunctions _objInputKeyFunctions;
62 
66  int32_t _lastWheelPos;
67 
71  MouseListener();
72 
76  ~MouseListener() {}
77 
82  bool mouseMoved(const OIS::MouseEvent & objMouseEvent);
83 
89  bool mousePressed(const OIS::MouseEvent & objMouseEvent, OIS::MouseButtonID id);
90 
96  bool mouseReleased(const OIS::MouseEvent & objMouseEvent, OIS::MouseButtonID id);
97 
105  void setKeyFunction(const api::KeyCode name, const api::KeyState type, const boost::function<void(void)> & ptrEventMethod);
106 
113  void removeKeyFunction(const api::KeyCode name, const api::KeyState type);
114 
123  void triggerKeyFunction(const api::KeyCode keyCode, const api::KeyState type);
124 
128  void Tick();
129 
133  typedef std::map<const OIS::MouseButtonID, std::string> mapMouseButtonMap;
134 
138  MouseListener(const MouseListener &) = delete;
139 
143  MouseListener & operator=(const MouseListener &) = delete;
144 
146  };
147 
148 } /* namespace modules */
149 } /* namespace i6e */
150 
151 #endif /* __I6ENGINE_MODULES_MOUSELISTENER_H__ */
152 
#define ASSERT_THREAD_SAFETY_HEADER
Monitors buttonpresses and sends the corresponding messages to the "Mouse" message channel...
Definition: MouseListener.h:52