Core » Input and output module

Provides a window API abstraction.

Files

file cursor.hpp
Class cubos::core::io::Cursor.
file gamepad.hpp
Struct cubos::core::io::GamepadState and related enums.
file keyboard.hpp
Enums cubos::core::io::Key and cubos::core::io::Modifiers.
file window.hpp
Class cubos::core::io::Window and related types.

Classes

class cubos::core::io::Cursor
Handle for a custom mouse cursor.
struct cubos::core::io::GamepadState
Holds the state of a gamepad.
struct cubos::core::io::KeyEvent
Event sent when a key is pressed or released.
struct cubos::core::io::ModifiersEvent
Event sent when the modifiers change.
struct cubos::core::io::MouseButtonEvent
Event sent when a mouse button state changes.
struct cubos::core::io::MouseMoveEvent
Event sent when the mouse cursor moves.
struct cubos::core::io::MouseScrollEvent
Event sent when the mouse wheel is scrolled.
struct cubos::core::io::ResizeEvent
Event sent when the window framebuffer is resized.
struct cubos::core::io::TextEvent
Event sent when a unicode character is input.
struct cubos::core::io::GamepadConnectionEvent
Event sent when a gamepad is connected or disconnected.
class cubos::core::io::BaseWindow
Interface used to wrap low-level window API implementations.

Enums

enum class GamepadButton { Invalid = -1, A, B, X, Y, LBumper, RBumper, Back, Start, Guide, LThumb, RThumb, Up, Right, Down, Left, Count }
Gamepad buttons.
enum class GamepadAxis { Invalid = -1, LX, LY, RX, RY, LTrigger, RTrigger, Count }
Gamepad axes.
enum class Key { Invalid = -1, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7, Num8, Num9, Escape, LControl, LShift, LAlt, LSystem, RControl, RShift, RAlt, RSystem, Menu, LBracket, RBracket, SemiColon, Comma, Period, Quote, Slash, BackSlash, Tilde, Equal, Dash, Space, Return, BackSpace, Tab, PageUp, PageDown, End, Home, Insert, Delete, Add, Subtract, Multiply, Divide, Left, Right, Up, Down, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5, Numpad6, Numpad7, Numpad8, Numpad9, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, Pause, Count }
Keyboard key codes enum.
enum class Modifiers { None = 0, Control = 1, Shift = 2, Alt = 4, System = 8 }
Keyboard modifier flags enum.
enum class MouseButton { Invalid = -1, Left, Right, Middle, Extra1, Extra2 }
Mouse buttons enum.
enum class MouseAxis { X, Y, Scroll }
Mouse axes enums.
enum class MouseState { Default, Locked, Hidden }
Possible mouse states.

Typedefs

using WindowEvent = std::variant<KeyEvent, ModifiersEvent, MouseButtonEvent, MouseMoveEvent, MouseScrollEvent, ResizeEvent, TextEvent, GamepadConnectionEvent>
Variant that can hold any of the window events.
using Window = std::shared_ptr<BaseWindow>
Handle to a window.

Functions

auto gamepadButtonToString(GamepadButton button) -> CUBOS_CORE_API std::string
Converts a GamepadButton enum to a string.
auto stringToGamepadButton(const std::string& str) -> CUBOS_CORE_API GamepadButton
Converts a string to a GamepadButton.
auto gamepadAxisToString(GamepadAxis axis) -> CUBOS_CORE_API std::string
Convert a GamepadAxis to a string.
auto stringToGamepadAxis(const std::string& str) -> CUBOS_CORE_API GamepadAxis
Convert a string to a GamepadAxis.
auto openWindow(const std::string& title = "Cubos", const glm::ivec2& size = {800, 600}, bool vSync = true) -> CUBOS_CORE_API Window
Opens a new window.
auto mouseButtonToString(MouseButton button) -> CUBOS_CORE_API std::string
Converts a MouseButton enum to a string.
auto stringToMouseButton(const std::string& str) -> CUBOS_CORE_API MouseButton
Convert a string to a MouseButton enum.

Enum documentation

enum class GamepadButton

Gamepad buttons.

enum class GamepadAxis

Gamepad axes.

enum class Key

Keyboard key codes enum.

enum class Modifiers

Keyboard modifier flags enum.

enum class MouseButton

Mouse buttons enum.

Enumerators
Invalid

Used for unknown mouse buttons.

Left
Right
Middle
Extra1
Extra2

enum class MouseAxis

Mouse axes enums.

enum class MouseState

Possible mouse states.

Enumerators
Default

Default mouse state, mouse will function as is specified by the OS.

Locked

Mouse cursor will be hidden and locked to the center of the window, useful for control schemes that require infinite mouse movement.

Hidden

Mouse cursor will be hidden when over the window, otherwise functioning in the same way as MouseState::Default.

Typedef documentation

using WindowEvent = std::variant<KeyEvent, ModifiersEvent, MouseButtonEvent, MouseMoveEvent, MouseScrollEvent, ResizeEvent, TextEvent, GamepadConnectionEvent>

Variant that can hold any of the window events.

using Window = std::shared_ptr<BaseWindow>

Handle to a window.

Function documentation

CUBOS_CORE_API std::string gamepadButtonToString(GamepadButton button)

Converts a GamepadButton enum to a string.

Parameters
button Button to convert.
Returns String representation.

CUBOS_CORE_API GamepadButton stringToGamepadButton(const std::string& str)

Converts a string to a GamepadButton.

Parameters
str String to convert.
Returns Button.

CUBOS_CORE_API std::string gamepadAxisToString(GamepadAxis axis)

Convert a GamepadAxis to a string.

Parameters
axis Axis to convert.
Returns String representation.

CUBOS_CORE_API GamepadAxis stringToGamepadAxis(const std::string& str)

Convert a string to a GamepadAxis.

Parameters
str String to convert.
Returns Axis.

CUBOS_CORE_API Window openWindow(const std::string& title = "Cubos", const glm::ivec2& size = {800, 600}, bool vSync = true)

Opens a new window.

Parameters
title Window title.
size Window size, in screen coordinates.
vSync Whether to enable vertical synchronization.
Returns New window, or nullptr on failure.

CUBOS_CORE_API std::string mouseButtonToString(MouseButton button)

Converts a MouseButton enum to a string.

Parameters
button MouseButton to convert.
Returns String representation.

CUBOS_CORE_API MouseButton stringToMouseButton(const std::string& str)

Convert a string to a MouseButton enum.

Parameters
str The string to convert.
Returns MouseButton.