FifeGUI 0.3.0
A C++ GUI library designed for games.
keyinput.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_KEYINPUT_HPP_
6#define INCLUDE_FIFECHAN_KEYINPUT_HPP_
7
8// Standard library includes
9#include <cstdint>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14// Project headers (subdirs before local)
15#include "fifechan/key.hpp"
16
17namespace fcn
18{
31 class FIFEGUI_API KeyInput
32 {
33 public:
39 enum class Type : std::uint8_t
40 {
41 Pressed = 0,
42 Released
43 };
44
48 KeyInput() = default;
49
56 KeyInput(Key const & key, Type type);
57
64 void setType(Type type);
65
72 Type getType() const;
73
80 void setKey(Key const & key);
81
88 Key const & getKey() const;
89
97 bool isShiftPressed() const;
98
106 void setShiftPressed(bool pressed);
107
115 bool isControlPressed() const;
116
124 void setControlPressed(bool pressed);
125
133 bool isAltPressed() const;
134
143 void setAltPressed(bool pressed);
144
152 bool isMetaPressed() const;
153
162 void setMetaPressed(bool pressed);
163
171 bool isNumericPad() const;
172
180 void setNumericPad(bool numpad);
181
182 protected:
186 Key mKey;
187
191 Type mType{Type::Pressed};
192
197 bool mShiftPressed{false};
198
203 bool mControlPressed{false};
204
209 bool mAltPressed{false};
210
215 bool mMetaPressed{false};
216
221 bool mNumericPad{false};
222 };
223} // namespace fcn
224
225#endif // INCLUDE_FIFECHAN_KEYINPUT_HPP_
bool isAltPressed() const
Checks if alt is pressed.
Definition keyinput.cpp:66
void setType(Type type)
Sets the type of the key input.
Definition keyinput.cpp:22
Type
Key input event types.
Definition keyinput.hpp:40
bool mMetaPressed
True if meta was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:215
bool isNumericPad() const
Checks if the key was pressed at the numeric pad.
Definition keyinput.cpp:86
Type getType() const
Gets the type of the key input.
Definition keyinput.cpp:29
bool mControlPressed
True if control was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:203
bool isControlPressed() const
Checks if control is pressed.
Definition keyinput.cpp:56
KeyInput()=default
Constructor.
void setAltPressed(bool pressed)
Sets the alt to be pressed at the same time as the key, or not.
Definition keyinput.cpp:71
void setNumericPad(bool numpad)
Sets the key to be pressed at the numeric pad.
Definition keyinput.cpp:91
void setControlPressed(bool pressed)
Sets control to be pressed at the same time as the key, or not.
Definition keyinput.cpp:61
void setKey(Key const &key)
Sets the key of the key input.
Definition keyinput.cpp:34
bool mNumericPad
True if the numeric pad was used when the key was pressed, false otherwise.
Definition keyinput.hpp:221
bool mShiftPressed
True if shift was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:197
Key mKey
Holds the key of the key input.
Definition keyinput.hpp:186
bool isMetaPressed() const
Checks if meta is pressed.
Definition keyinput.cpp:76
void setMetaPressed(bool pressed)
Sets meta to be pressed at the same time as the key, or not.
Definition keyinput.cpp:81
void setShiftPressed(bool pressed)
Sets shift to be pressed at the same time as the key, or not.
Definition keyinput.cpp:51
Type mType
Holds the type of the key input.
Definition keyinput.hpp:191
Key const & getKey() const
Gets the key of the key input.
Definition keyinput.cpp:41
bool isShiftPressed() const
Checks if shift is pressed.
Definition keyinput.cpp:46
bool mAltPressed
True if alt was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:209
Used replacement tokens by configure_file():