Skip to main content

GLFWGamepadLookup Namespace

Definition

namespace helios::ext::glfw::input::GLFWGamepadLookup { ... }

Functions Index

constexpr unsigned inttoArrayIndex (const helios::input::types::Gamepad gamepadId) noexcept

Internal method to safely compute an array index for the specified gamepadId, adhering to the logic arrayIndex = log_2(gamepadId). More...

intfrom (const helios::input::types::Gamepad gamepadId) noexcept

Provides a lookup for converting helios gamepad ids glfw-specific gamepad ids. More...

Functions

from()

int helios::ext::glfw::input::GLFWGamepadLookup::from (const helios::input::types::Gamepad gamepadId)
inline noexcept

Provides a lookup for converting helios gamepad ids glfw-specific gamepad ids.

Parameters
gamepadId

The helios gamepad id to map to the gamepad ids registered by GLFW

Returns

A gamepad-id in glfw space.

Definition at line 37 of file GLFWGamepadLookup.ixx.

37 inline int from(const helios::input::types::Gamepad gamepadId) noexcept {
38
39 static constexpr std::array<int, helios::input::types::Gamepad::size_> HELIOS_GAMEPAD_TO_GLFW=[] {
40 std::array<int, helios::input::types::Gamepad::size_> map{};
41
46
47 return map;
48 }();
49
50 return HELIOS_GAMEPAD_TO_GLFW[toArrayIndex(gamepadId)];
51 }

References helios::input::types::FOUR, helios::input::types::ONE, helios::input::types::THREE, toArrayIndex and helios::input::types::TWO.

Referenced by helios::ext::glfw::input::GLFWInputAdapter::isConnected and helios::ext::glfw::input::GLFWInputAdapter::updateGamepadState.

toArrayIndex()

unsigned int helios::ext::glfw::input::GLFWGamepadLookup::toArrayIndex (const helios::input::types::Gamepad gamepadId)
constexpr noexcept

Internal method to safely compute an array index for the specified gamepadId, adhering to the logic arrayIndex = log_2(gamepadId).

Parameters
gamepadId

The gamepadId for which the array index should be returned.

Returns

the array index for the specified gamepadId.

Definition at line 25 of file GLFWGamepadLookup.ixx.

25 constexpr unsigned int toArrayIndex(const helios::input::types::Gamepad gamepadId) noexcept {
26 return std::bit_width(static_cast<unsigned int>(gamepadId))-1;
27 }

Referenced by from and helios::ext::glfw::input::GLFWInputAdapter::gamepadState.


The documentation for this namespace was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.