From 6cd00aacfa22fed6a54a9b812f6b069ad16feec0 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 29 Jun 2025 22:24:42 +0500 Subject: Move game sources into src subdirectory --- src/game/client/gamepad.hh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/game/client/gamepad.hh (limited to 'src/game/client/gamepad.hh') diff --git a/src/game/client/gamepad.hh b/src/game/client/gamepad.hh new file mode 100644 index 0000000..d2483b7 --- /dev/null +++ b/src/game/client/gamepad.hh @@ -0,0 +1,45 @@ +#ifndef CLIENT_GAMEPAD_HH +#define CLIENT_GAMEPAD_HH 1 +#pragma once + +constexpr static int INVALID_GAMEPAD_AXIS = INT_MAX; +constexpr static int INVALID_GAMEPAD_BUTTON = INT_MAX; + +class ConfigBoolean; +class ConfigFloat; + +struct GLFWgamepadstate; + +namespace gamepad +{ +extern bool available; +extern ConfigFloat deadzone; +extern ConfigBoolean active; +extern GLFWgamepadstate state; +extern GLFWgamepadstate last_state; +} // namespace gamepad + +namespace gamepad +{ +void init(void); +void update_late(void); +} // namespace gamepad + +// This simulates buttons using axes. When an axis +// value exceeds 1.5 times the deadzone, the event is +// queued with a GLFW_PRESS action, when it falls back +// below the threshold, the event is queued with GLFW_RELEASE action +struct GamepadAxisEvent final { + int action; + int axis; +}; + +// This smears GLFW event sugar over gamepad polling +// system. Whenever it detects a state change, the event +// is queued with an appropriate action +struct GamepadButtonEvent final { + int action; + int button; +}; + +#endif /* CLIENT_GAMEPAD_HH */ -- cgit