Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Controls.h
1/*
2 * Gamedev Framework (gf)
3 * Copyright (C) 2016-2022 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 "GraphicsApi.h"
27#include "Keyboard.h"
28#include "Mouse.h"
29
30namespace gf {
31#ifndef DOXYGEN_SHOULD_SKIP_THIS
32inline namespace v1 {
33#endif
34
39 class GF_GRAPHICS_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_GRAPHICS_API ScancodeKeyControl : public Control {
59 public:
66
67 virtual void processEvent(const Event& event) override;
68
69 private:
70 Scancode m_code;
71 };
72
77 class GF_GRAPHICS_API MouseButtonControl : public Control {
78 public:
85
86 virtual void processEvent(const Event& event) override;
87
88 private:
89 MouseButton m_button;
90 };
91
96 class GF_GRAPHICS_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_GRAPHICS_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;
136 bool m_repeated;
137 };
138
144 class GF_GRAPHICS_API CloseControl : public Control {
145 public:
150
151 virtual void processEvent(const Event& event) override;
152 };
153
161 class GF_GRAPHICS_API KonamiKeyboardControl : public Control {
162 public:
167
168 virtual void processEvent(const Event& event) override;
169
170 private:
171 int m_index;
172 enum { Released, Pressed } m_state;
173 };
174
182 class GF_GRAPHICS_API KonamiGamepadControl : public Control {
183 public:
190
191 virtual void processEvent(const Event& event) override;
192
193 private:
194 GamepadId m_id;
195 int m_index;
196 enum { Released, Pressed } m_state;
197 };
198
199
200#ifndef DOXYGEN_SHOULD_SKIP_THIS
201}
202#endif
203}
204
205#endif // GF_CONTROLS_H
A close control.
Definition: Controls.h:144
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
CloseControl()
Construct a close control.
A physical control.
Definition: Control.h:38
A gamepad axis control.
Definition: Controls.h:118
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
GamepadAxisControl(GamepadId id, GamepadAxis axis, GamepadAxisDirection dir)
Construct a gamepad axis control.
A gamepad button control.
Definition: Controls.h:96
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
GamepadButtonControl(GamepadId id, GamepadButton button)
Contruct a gamepad button control.
A key control based on keycode.
Definition: Controls.h:39
KeycodeKeyControl(Keycode code)
Construct a key control.
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
The Konami code control for gamepad.
Definition: Controls.h:182
KonamiGamepadControl(GamepadId id)
Construct a Konami control.
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
The Konami code control for keyboard.
Definition: Controls.h:161
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
KonamiKeyboardControl()
Construct a Konami control.
A mouse button control.
Definition: Controls.h:77
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
MouseButtonControl(MouseButton button)
Construct a mouse button control.
A key control based on scancode.
Definition: Controls.h:58
ScancodeKeyControl(Scancode code)
Construct a key control.
virtual void processEvent(const Event &event) override
Update the state of the control thanks to an event.
GamepadId
A gamepad identifier.
Definition: Gamepad.h:123
GamepadAxis
The gamepad axis.
Definition: Gamepad.h:71
MouseButton
Mouse buttons.
Definition: Mouse.h:36
GamepadButton
The gamepad buttons.
Definition: Gamepad.h:43
Scancode
Scancodes.
Definition: Keyboard.h:51
GamepadAxisDirection
A gamepad axis direction.
Definition: Gamepad.h:89
Keycode
Keycodes.
Definition: Keyboard.h:280
The namespace for gf classes.
Defines a system event and its parameters.
Definition: Event.h:224