FifeGUI 0.2.0
A C++ GUI library designed for games.
keyinput.cpp
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#include "fifechan/keyinput.hpp"
6
7#include "fifechan/key.hpp"
8
9namespace fcn
10{
11 KeyInput::KeyInput(Key const & key, Type type) : mKey(key), mType(type) { }
12
14 {
15 mType = type;
16 }
17
19 {
20 return mType;
21 }
22
23 void KeyInput::setKey(Key const & key)
24 {
25 mKey = key;
26 }
27
28 Key const & KeyInput::getKey() const
29 {
30 return mKey;
31 }
32
34 {
35 return mShiftPressed;
36 }
37
38 void KeyInput::setShiftPressed(bool pressed)
39 {
40 mShiftPressed = pressed;
41 }
42
44 {
45 return mControlPressed;
46 }
47
48 void KeyInput::setControlPressed(bool pressed)
49 {
50 mControlPressed = pressed;
51 }
52
54 {
55 return mAltPressed;
56 }
57
58 void KeyInput::setAltPressed(bool pressed)
59 {
60 mAltPressed = pressed;
61 }
62
64 {
65 return mMetaPressed;
66 }
67
68 void KeyInput::setMetaPressed(bool pressed)
69 {
70 mMetaPressed = pressed;
71 }
72
74 {
75 return mNumericPad;
76 }
77
78 void KeyInput::setNumericPad(bool numpad)
79 {
80 mNumericPad = numpad;
81 }
82} // namespace fcn
bool isAltPressed() const
Checks if alt is pressed.
Definition keyinput.cpp:53
void setType(Type type)
Sets the type of the key input.
Definition keyinput.cpp:13
Type
Key input event types.
Definition keyinput.hpp:36
bool mMetaPressed
True if meta was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:211
bool isNumericPad() const
Checks if the key was pressed at the numeric pad.
Definition keyinput.cpp:73
Type getType() const
Gets the type of the key input.
Definition keyinput.cpp:18
bool mControlPressed
True if control was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:199
bool isControlPressed() const
Checks if control is pressed.
Definition keyinput.cpp:43
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:58
void setNumericPad(bool numpad)
Sets the key to be pressed at the numeric pad.
Definition keyinput.cpp:78
void setControlPressed(bool pressed)
Sets control to be pressed at the same time as the key, or not.
Definition keyinput.cpp:48
void setKey(Key const &key)
Sets the key of the key input.
Definition keyinput.cpp:23
bool mNumericPad
True if the numeric pad was used when the key was pressed, false otherwise.
Definition keyinput.hpp:217
bool mShiftPressed
True if shift was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:193
Key mKey
Holds the key of the key input.
Definition keyinput.hpp:182
bool isMetaPressed() const
Checks if meta is pressed.
Definition keyinput.cpp:63
void setMetaPressed(bool pressed)
Sets meta to be pressed at the same time as the key, or not.
Definition keyinput.cpp:68
void setShiftPressed(bool pressed)
Sets shift to be pressed at the same time as the key, or not.
Definition keyinput.cpp:38
Type mType
Holds the type of the key input.
Definition keyinput.hpp:187
Key const & getKey() const
Gets the key of the key input.
Definition keyinput.cpp:28
bool isShiftPressed() const
Checks if shift is pressed.
Definition keyinput.cpp:33
bool mAltPressed
True if alt was pressed at the same time as the key, false otherwise.
Definition keyinput.hpp:205
Represents a keyboard key or character code.
Definition key.hpp:20