FifeGUI
0.2.0
A C++ GUI library designed for games.
fifechan
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
#include <cstdint>
9
10
#include "fifechan/key.hpp"
11
#include "fifechan/platform.hpp"
12
13
namespace
fcn
14
{
27
class
FIFEGUI_API
KeyInput
28
{
29
public
:
35
enum class
Type
: std::uint8_t
36
{
37
Pressed = 0,
38
Released
39
};
40
44
KeyInput
() =
default
;
45
52
KeyInput
(
Key
const
& key,
Type
type);
53
60
void
setType
(
Type
type);
61
68
Type
getType
()
const
;
69
76
void
setKey
(
Key
const
& key);
77
84
Key
const
&
getKey
()
const
;
85
93
bool
isShiftPressed
()
const
;
94
102
void
setShiftPressed
(
bool
pressed);
103
111
bool
isControlPressed
()
const
;
112
120
void
setControlPressed
(
bool
pressed);
121
129
bool
isAltPressed
()
const
;
130
139
void
setAltPressed
(
bool
pressed);
140
148
bool
isMetaPressed
()
const
;
149
158
void
setMetaPressed
(
bool
pressed);
159
167
bool
isNumericPad
()
const
;
168
176
void
setNumericPad
(
bool
numpad);
177
178
protected
:
182
Key
mKey
;
183
187
Type
mType
{Type::Released};
188
193
bool
mShiftPressed
{
false
};
194
199
bool
mControlPressed
{
false
};
200
205
bool
mAltPressed
{
false
};
206
211
bool
mMetaPressed
{
false
};
212
217
bool
mNumericPad
{
false
};
218
};
219
}
// namespace fcn
220
221
#endif
// INCLUDE_FIFECHAN_KEYINPUT_HPP_
fcn::KeyInput::isAltPressed
bool isAltPressed() const
Checks if alt is pressed.
Definition
keyinput.cpp:53
fcn::KeyInput::setType
void setType(Type type)
Sets the type of the key input.
Definition
keyinput.cpp:13
fcn::KeyInput::Type
Type
Key input event types.
Definition
keyinput.hpp:36
fcn::KeyInput::mMetaPressed
bool mMetaPressed
True if meta was pressed at the same time as the key, false otherwise.
Definition
keyinput.hpp:211
fcn::KeyInput::isNumericPad
bool isNumericPad() const
Checks if the key was pressed at the numeric pad.
Definition
keyinput.cpp:73
fcn::KeyInput::getType
Type getType() const
Gets the type of the key input.
Definition
keyinput.cpp:18
fcn::KeyInput::mControlPressed
bool mControlPressed
True if control was pressed at the same time as the key, false otherwise.
Definition
keyinput.hpp:199
fcn::KeyInput::isControlPressed
bool isControlPressed() const
Checks if control is pressed.
Definition
keyinput.cpp:43
fcn::KeyInput::KeyInput
KeyInput()=default
Constructor.
fcn::KeyInput::setAltPressed
void setAltPressed(bool pressed)
Sets the alt to be pressed at the same time as the key, or not.
Definition
keyinput.cpp:58
fcn::KeyInput::setNumericPad
void setNumericPad(bool numpad)
Sets the key to be pressed at the numeric pad.
Definition
keyinput.cpp:78
fcn::KeyInput::setControlPressed
void setControlPressed(bool pressed)
Sets control to be pressed at the same time as the key, or not.
Definition
keyinput.cpp:48
fcn::KeyInput::setKey
void setKey(Key const &key)
Sets the key of the key input.
Definition
keyinput.cpp:23
fcn::KeyInput::mNumericPad
bool mNumericPad
True if the numeric pad was used when the key was pressed, false otherwise.
Definition
keyinput.hpp:217
fcn::KeyInput::mShiftPressed
bool mShiftPressed
True if shift was pressed at the same time as the key, false otherwise.
Definition
keyinput.hpp:193
fcn::KeyInput::mKey
Key mKey
Holds the key of the key input.
Definition
keyinput.hpp:182
fcn::KeyInput::isMetaPressed
bool isMetaPressed() const
Checks if meta is pressed.
Definition
keyinput.cpp:63
fcn::KeyInput::setMetaPressed
void setMetaPressed(bool pressed)
Sets meta to be pressed at the same time as the key, or not.
Definition
keyinput.cpp:68
fcn::KeyInput::setShiftPressed
void setShiftPressed(bool pressed)
Sets shift to be pressed at the same time as the key, or not.
Definition
keyinput.cpp:38
fcn::KeyInput::mType
Type mType
Holds the type of the key input.
Definition
keyinput.hpp:187
fcn::KeyInput::getKey
Key const & getKey() const
Gets the key of the key input.
Definition
keyinput.cpp:28
fcn::KeyInput::isShiftPressed
bool isShiftPressed() const
Checks if shift is pressed.
Definition
keyinput.cpp:33
fcn::KeyInput::mAltPressed
bool mAltPressed
True if alt was pressed at the same time as the key, false otherwise.
Definition
keyinput.hpp:205
fcn::Key
Represents a keyboard key or character code.
Definition
key.hpp:20
Generated by
1.16.1