FifeGUI 0.3.0
A C++ GUI library designed for games.
fcn::KeyInput Class Reference

#include <keyinput.hpp>

Public Types

enum class  Type : std::uint8_t { Pressed = 0 , Released }

Public Member Functions

Key const & getKey () const
Type getType () const
bool isAltPressed () const
bool isControlPressed () const
bool isMetaPressed () const
bool isNumericPad () const
bool isShiftPressed () const
 KeyInput ()=default
 KeyInput (Key const &key, Type type)
void setAltPressed (bool pressed)
void setControlPressed (bool pressed)
void setKey (Key const &key)
void setMetaPressed (bool pressed)
void setNumericPad (bool numpad)
void setShiftPressed (bool pressed)
void setType (Type type)

Protected Attributes

bool mAltPressed {false}
bool mControlPressed {false}
Key mKey
bool mMetaPressed {false}
bool mNumericPad {false}
bool mShiftPressed {false}
Type mType {Type::Pressed}

Detailed Description

Internal class representing raw keyboard input data.

This class is used to represent key input events. It holds information about the key that was pressed or released, the type of the key input event and if any modifier keys were pressed at the same time as the key.

The class is relevant if you want to implement an Input class for a backend.

Definition at line 31 of file keyinput.hpp.

Member Enumeration Documentation

◆ Type

enum class fcn::KeyInput::Type : std::uint8_t
strong

Key input event types.

This enum corresponds to the enum with event types on KeyEvent for easy mapping.

Definition at line 39 of file keyinput.hpp.

Constructor & Destructor Documentation

◆ KeyInput()

fcn::KeyInput::KeyInput ( Key const & key,
Type type )

Constructor.

Parameters
keyThe key of the key input.
typeThe type of key input.

Definition at line 16 of file keyinput.cpp.

References mKey, and mType.

Member Function Documentation

◆ getKey()

Key const & fcn::KeyInput::getKey ( ) const

Gets the key of the key input.

Returns
The key of the key input.
See also
setKey

Definition at line 41 of file keyinput.cpp.

References mKey.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ getType()

KeyInput::Type fcn::KeyInput::getType ( ) const

Gets the type of the key input.

Returns
the input type.
See also
setType

Definition at line 29 of file keyinput.cpp.

References mType.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ isAltPressed()

bool fcn::KeyInput::isAltPressed ( ) const

Checks if alt is pressed.

Returns
True if alt was pressed at the same time as the key, false otherwise.
See also
setAltPressed

Definition at line 66 of file keyinput.cpp.

References mAltPressed.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ isControlPressed()

bool fcn::KeyInput::isControlPressed ( ) const

Checks if control is pressed.

Returns
True if control was pressed at the same time as the key, false otherwise.
See also
setControlPressed

Definition at line 56 of file keyinput.cpp.

References mControlPressed.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ isMetaPressed()

bool fcn::KeyInput::isMetaPressed ( ) const

Checks if meta is pressed.

Returns
True if meta was pressed at the same time as the key, false otherwise.
See also
setMetaPressed

Definition at line 76 of file keyinput.cpp.

References mMetaPressed.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ isNumericPad()

bool fcn::KeyInput::isNumericPad ( ) const

Checks if the key was pressed at the numeric pad.

Returns
True if key pressed at the numeric pad, false otherwise.
See also
setNumericPad

Definition at line 86 of file keyinput.cpp.

References mNumericPad.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ isShiftPressed()

bool fcn::KeyInput::isShiftPressed ( ) const

Checks if shift is pressed.

Returns
True if shift was pressed at the same time as the key, false otherwise.
See also
setShiftPressed

Definition at line 46 of file keyinput.cpp.

References mShiftPressed.

Referenced by fcn::Gui::handleKeyInput(), and KeyInput().

◆ setAltPressed()

void fcn::KeyInput::setAltPressed ( bool pressed)

Sets the alt to be pressed at the same time as the key, or not.

Parameters
pressedTrue if alt is pressed at the same time as the key, , false otherwise.
See also
isAltPressed

Definition at line 71 of file keyinput.cpp.

References mAltPressed.

Referenced by KeyInput(), and fcn::sdl3::Input::pushInput().

◆ setControlPressed()

void fcn::KeyInput::setControlPressed ( bool pressed)

Sets control to be pressed at the same time as the key, or not.

Parameters
pressedTrue if control is pressed, false otherwise.
See also
isControlPressed

Definition at line 61 of file keyinput.cpp.

References mControlPressed.

Referenced by KeyInput(), and fcn::sdl3::Input::pushInput().

◆ setKey()

void fcn::KeyInput::setKey ( Key const & key)

Sets the key of the key input.

Parameters
keyThe key of the key input.
See also
getKey

Definition at line 34 of file keyinput.cpp.

References mKey.

Referenced by KeyInput(), fcn::sdl3::Input::pushInput(), fcn::GenericInput::pushKeyPressed(), and fcn::GenericInput::pushKeyReleased().

◆ setMetaPressed()

void fcn::KeyInput::setMetaPressed ( bool pressed)

Sets meta to be pressed at the same time as the key, or not.

Parameters
pressedTrue if meta is pressed at the same time as the key, false otherwise.
See also
isMetaPressed

Definition at line 81 of file keyinput.cpp.

References mMetaPressed.

Referenced by KeyInput(), and fcn::sdl3::Input::pushInput().

◆ setNumericPad()

void fcn::KeyInput::setNumericPad ( bool numpad)

Sets the key to be pressed at the numeric pad.

Parameters
numpadTrue if the key was pressed at the numeric pad, false otherwise.
See also
isNumericPad

Definition at line 91 of file keyinput.cpp.

References mNumericPad.

Referenced by KeyInput(), and fcn::sdl3::Input::pushInput().

◆ setShiftPressed()

void fcn::KeyInput::setShiftPressed ( bool pressed)

Sets shift to be pressed at the same time as the key, or not.

Parameters
pressedTrue if shift is pressed, false otherwise.
See also
isShiftPressed

Definition at line 51 of file keyinput.cpp.

References mShiftPressed.

Referenced by KeyInput(), and fcn::sdl3::Input::pushInput().

◆ setType()

void fcn::KeyInput::setType ( Type type)

Sets the type of the key input.

Parameters
typeThe type of key input.
See also
getType

Definition at line 22 of file keyinput.cpp.

References mType.

Referenced by KeyInput(), fcn::sdl3::Input::pushInput(), fcn::GenericInput::pushKeyPressed(), and fcn::GenericInput::pushKeyReleased().

Member Data Documentation

◆ mAltPressed

bool fcn::KeyInput::mAltPressed {false}
protected

True if alt was pressed at the same time as the key, false otherwise.

Definition at line 209 of file keyinput.hpp.

Referenced by isAltPressed(), and setAltPressed().

◆ mControlPressed

bool fcn::KeyInput::mControlPressed {false}
protected

True if control was pressed at the same time as the key, false otherwise.

Definition at line 203 of file keyinput.hpp.

Referenced by isControlPressed(), and setControlPressed().

◆ mKey

Key fcn::KeyInput::mKey
protected

Holds the key of the key input.

Definition at line 186 of file keyinput.hpp.

Referenced by getKey(), KeyInput(), and setKey().

◆ mMetaPressed

bool fcn::KeyInput::mMetaPressed {false}
protected

True if meta was pressed at the same time as the key, false otherwise.

Definition at line 215 of file keyinput.hpp.

Referenced by isMetaPressed(), and setMetaPressed().

◆ mNumericPad

bool fcn::KeyInput::mNumericPad {false}
protected

True if the numeric pad was used when the key was pressed, false otherwise.

Definition at line 221 of file keyinput.hpp.

Referenced by isNumericPad(), and setNumericPad().

◆ mShiftPressed

bool fcn::KeyInput::mShiftPressed {false}
protected

True if shift was pressed at the same time as the key, false otherwise.

Definition at line 197 of file keyinput.hpp.

Referenced by isShiftPressed(), and setShiftPressed().

◆ mType

Type fcn::KeyInput::mType {Type::Pressed}
protected

Holds the type of the key input.

Definition at line 191 of file keyinput.hpp.

Referenced by getType(), KeyInput(), and setType().


The documentation for this class was generated from the following files: