core::systems::input class

handles all inputs and sends out generic events that can be subscribed to.

the input class is responsible for translating platform specific input events to a more generalised format, and sending out events that have been subscribed to. for example it will translate all keyboard input messages into a generic key message that remains the same for all platforms. You can however reverse-translate back into the platform specific key messages. Every input instance is tied to a core::os::surface, and all its data (such as mouse coordinates) is invariably tied to that regardless if the actual platform only has a singleton input system.

types

classes

mouse_coordinate
absolute mouse coordinates that also contain the surface width/height.
mouse_delta
contains the mouse delta coordinates in respect to the last message tick.
scroll_delta
delta information for the mouse scroll wheel.

enums

mousecode
codes for the various mouse buttons.
enum classclasspublicpublic
keycode : uint8_t
contains the generic keycodes that platform specific key codes get translated to.
enum classclasspublicpublic

static variables

keycode_names
array that maps keyboard keycodes to string.
constexprconstexprpublicpublicstaticstatic

member-functions

subscribe<…>
automatically subscribes to all the events the target has method signatures for.
public
unsubscribe<…>
automatically unsubscribes to all the events the target has method signatures for.
public
cursor
const public noexcept

Function documentation

template<typename Type>
void core::systems::input::subscribe(Type target)

Brief

automatically subscribes to all the events the target has method signatures for.

Details

The input system checks the target that tries to subscribe itself for several different signatures that satisfy the callbacks. These are:

  • T::on_key_pressed(keycode) => when a keycode is pressed (first frame only)
  • T::on_key_released(keycode) => when a keycode is released (one frame)
  • T::on_key_held(keycode) => when a keycode is held (first frame after pressed)
  • T::on_moude_pressed(mousecode) => when a mousecode is pressed (first frame only)
  • T::on_mouse_released(mousecode) => when a mousecode is released (one frame)
  • T::on_mouse_held(mousecode) => when a mousecode is held (first frame after pressed)
  • T::on_mouse_move(mouse_delta) => when the mouse moves, sends the relative coordinates (difference from last tick)
  • T::on_mouse_move(mouse_coordinate) => when the mouse moves, sends the absolute coordinates
  • T::on_mouse_scroll(scroll_delta) => when the mouse moves, sends the delta change of the scroll in respect to last tick

const mouse_coordinate& core::systems::input::cursor() const noexcept

Returns the current mouse coordinate information