Gamedev Framework (gf)  0.8.0
A C++14 framework for 2D games
Controls.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_CONTROLS_H
22 #define GF_CONTROLS_H
23 
24 #include "Control.h"
25 #include "Gamepad.h"
26 #include "Keyboard.h"
27 #include "Mouse.h"
28 #include "Portability.h"
29 
30 namespace gf {
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 inline namespace v1 {
33 #endif
34 
39  class GF_API KeycodeKeyControl : public Control {
40  public:
46  explicit KeycodeKeyControl(Keycode code);
47 
48  virtual void processEvent(const Event& event) override;
49 
50  private:
51  Keycode m_code;
52  };
53 
58  class GF_API ScancodeKeyControl : public Control {
59  public:
65  explicit ScancodeKeyControl(Scancode code);
66 
67  virtual void processEvent(const Event& event) override;
68 
69  private:
70  Scancode m_code;
71  };
72 
77  class GF_API MouseButtonControl : public Control {
78  public:
84  explicit MouseButtonControl(MouseButton button);
85 
86  virtual void processEvent(const Event& event) override;
87 
88  private:
89  MouseButton m_button;
90  };
91 
96  class GF_API GamepadButtonControl : public Control {
97  public:
106 
107  virtual void processEvent(const Event& event) override;
108 
109  private:
110  GamepadId m_id;
111  GamepadButton m_button;
112  };
113 
118  class GF_API GamepadAxisControl : public Control {
119  public:
129 
130  virtual void processEvent(const Event& event) override;
131 
132  private:
133  GamepadId m_id;
134  GamepadAxis m_axis;
135  GamepadAxisDirection m_dir;
136  };
137 
143  class GF_API CloseControl : public Control {
144  public:
148  CloseControl();
149 
150  virtual void processEvent(const Event& event) override;
151  };
152 
160  class GF_API KonamiKeyboardControl : public Control {
161  public:
166 
167  virtual void processEvent(const Event& event) override;
168 
169  private:
170  int m_index;
171  enum { Released, Pressed } m_state;
172  };
173 
181  class GF_API KonamiGamepadControl : public Control {
182  public:
189 
190  virtual void processEvent(const Event& event) override;
191 
192  private:
193  GamepadId m_id;
194  int m_index;
195  enum { Released, Pressed } m_state;
196  };
197 
198 
199 #ifndef DOXYGEN_SHOULD_SKIP_THIS
200 }
201 #endif
202 }
203 
204 #endif // GF_CONTROLS_H
GamepadAxisDirection
A gamepad axis direction.
Definition: Gamepad.h:89
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:43
A mouse button control.
Definition: Controls.h:77
Scancode
Scancodes.
Definition: Keyboard.h:59
A gamepad button control.
Definition: Controls.h:96
A physical control.
Definition: Control.h:38
GamepadAxis
The gamepad axis.
Definition: Gamepad.h:71
The Konami code control for keyboard.
Definition: Controls.h:160
The namespace for gf classes.
Definition: Action.h:34
The Konami code control for gamepad.
Definition: Controls.h:181
GamepadId
A gamepad identifier.
Definition: Gamepad.h:121
A key control based on keycode.
Definition: Controls.h:39
A key control based on scancode.
Definition: Controls.h:58
A gamepad axis control.
Definition: Controls.h:118
MouseButton
Mouse buttons.
Definition: Mouse.h:36
Defines a system event and its parameters.
Definition: Event.h:118
A close control.
Definition: Controls.h:143
Keycode
Keycodes.
Definition: Keyboard.h:288