The input system manages external input devices like a mouse and a keyboard.
Keyboard and mouse button input is done through a class called BinaryInput
.
Binary input is an interface over a rebindable control scheme, with each having one or multiple asset-defined activators (keyboard or mouse buttons).
Binary inputs can be requested from the asset system:
#include "input/binary_input.h"
#include "managers/asset_manager.h"
const BinaryInput* jump_input = AssetManager::request<BinaryInput>("jump.keybind.xml");
bool still_jumping = jump_input->get_pushed();
bool just_jumped = jump_input->poll_pushed();
bool just_stopped_jumping = jump_input->poll_released();
.keybind.xml
assets have the following format:
<keybind>
<input code="KEY_SPACE"/>
<input code="BTN_LEFT"/>
</keybind>
Keyboard an mouse input codes can be found at the end of this document.
Mouse movement input can be retrieved from the InputController
class.
#include "input/input_controller.h"
double mouse_pos_x = InputController::get_mouse_x();
double mouse_pos_y = InputController::get_mouse_y();
double mouse_shift_x = InputController::get_mouse_delta_x();
double mouse_shift_y = InputController::get_mouse_delta_y();
It is possible that in the future the system will be replaced with an event-based system.
It is also possible that a text input system will be added.
BTN_LEFT
BTN_RIGHT
BTN_MIDDLE
BTN_4
BTN_5
BTN_6
BTN_7
BTN_8
KEY_SPACE
KEY_APOSTROPHE
KEY_COMMA
KEY_MINUS
KEY_PERIOD
KEY_SLASH
KEY_0
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_SEMICOLON
KEY_EQUAL
KEY_A
KEY_B
KEY_C
KEY_D
KEY_E
KEY_F
KEY_G
KEY_H
KEY_I
KEY_J
KEY_K
KEY_L
KEY_M
KEY_N
KEY_O
KEY_P
KEY_Q
KEY_R
KEY_S
KEY_T
KEY_U
KEY_V
KEY_W
KEY_X
KEY_Y
KEY_Z
KEY_LEFT_BRACKET
KEY_BACKSLASH
KEY_RIGHT_BRACKET
KEY_GRAVE_ACCENT
KEY_WORLD_1
KEY_WORLD_2
KEY_ESCAPE
KEY_ENTER
KEY_TAB
KEY_BACKSPACE
KEY_INSERT
KEY_DELETE
KEY_RIGHT
KEY_LEFT
KEY_DOW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