i6engine  1.0
InputFacade.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_API_INPUTFACADE_H__
26 #define __I6ENGINE_API_INPUTFACADE_H__
27 
28 #include <map>
29 
31 
32 #include "boost/function.hpp"
33 #include "boost/thread/mutex.hpp"
34 
35 namespace i6e {
36 namespace api {
37 
38  enum class KeyCode : uint32_t;
39 
43  enum class ISIXE_MODULES_API KeyState : uint16_t {
46  KEY_HOLD = 2
47  };
48 
53  typedef std::map<const KeyCode, std::string> mapKeymap;
54 
55  public:
56  InputFacade();
57  ~InputFacade();
58 
64  void setKeyMapping(const KeyCode id, const std::string & strAction);
65 
70  void removeKeyMapping(const KeyCode id);
71 
77  std::string getKeyMapping(const KeyCode id) const;
78 
85  void subscribeKeyEvent(const KeyCode name, const KeyState type, const boost::function<void(void)> & f) const;
86 
92  void unsubscribeKeyEvent(const KeyCode name, const KeyState type) const;
93 
97  void resetSubSystem();
98 
99  private:
100  mapKeymap _keymap;
101 
102  mutable boost::mutex _lock;
103 
107  InputFacade(const InputFacade &) = delete;
108 
112  InputFacade & operator=(const InputFacade &) = delete;
113  };
114 
115 } /* namespace api */
116 } /* namespace i6e */
117 
118 #endif /* __I6ENGINE_API_INPUTFACADE_H__ */
119 
#define ISIXE_MODULES_API
KEY_PRESSED
key was released
Definition: InputFacade.h:45
KEY_RELEASED
Definition: InputFacade.h:44