Toast Engine
Loading...
Searching...
No Matches
keycodes.hpp File Reference
#include <cstdint>
#include <string_view>
#include <toast/export.hpp>
Include dependency graph for keycodes.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  input::KeyCode
 A parsed keycode resolved to a device, kind and numeric code. More...

Enumerations

enum class  input::Device : uint8_t { none , keyboard , mouse , controller }
 Physical device a keycode belongs to.
enum class  input::ModifierKey : uint8_t { none = 0 , shift = 0b001 , control = 0b010 , alt = 0b100 }
 Bit flags for the keyboard modifier keys held during an input.
enum class  input::InputKind : uint8_t {
  button , axis1d , axis2d , scroll ,
  cursor
}
 Dimensionality of an input, used by the input system to pick a sampling path. More...

Functions

constexpr auto input::operator| (ModifierKey a, ModifierKey b) -> ModifierKey
constexpr auto input::operator& (ModifierKey a, ModifierKey b) -> ModifierKey
auto input::parseKeycode (std::string_view str) -> KeyCode
 Parses a textual keycode such as "keyboard/a", "mouse/left" or "controller/left_stick".

Variables

constexpr int input::controller_stick_left = 0
 Controller stick indices used as the code for InputKind::axis2d controller inputs.
constexpr int input::controller_stick_right = 1
constexpr int input::controller_touchpad = 2
constexpr int input::controller_gyro_x = 100
 Gyro axis codes used as the code for the controller gyro_x/y/z inputs.
constexpr int input::controller_gyro_y = 101
constexpr int input::controller_gyro_z = 102

Detailed Description

Author
Xein
Date
13 Dec 2025

Enumeration Type Documentation

◆ InputKind

enum class input::InputKind : uint8_t
strong

Dimensionality of an input, used by the input system to pick a sampling path.

Enumerator
button 

on/off input such as a key or a gamepad button

axis1d 

single-axis analog input such as a trigger or one stick axis

axis2d 

two-axis analog input such as a full stick or the touchpad

scroll 

mouse wheel; code 0 is vertical, code 1 is horizontal

cursor 

mouse cursor position or delta

Function Documentation

◆ parseKeycode()

auto TOAST_API input::parseKeycode ( std::string_view str) -> KeyCode
nodiscard

Parses a textual keycode such as "keyboard/a", "mouse/left" or "controller/left_stick".

Parameters
strThe keycode string; the device prefix selects the parsing path
Returns
A KeyCode with valid set to true on success, or valid false when the string is unknown