From 458e0005690ea9d579588a0a12368fc2c2c9a93a Mon Sep 17 00:00:00 2001 From: untodesu Date: Tue, 1 Jul 2025 03:08:39 +0500 Subject: I hyper-focued on refactoring again - I put a cool-sounding "we are number one" remix on repeat and straight up grinded the entire repository to a better state until 03:09 AM. I guess I have something wrong in my brain that makes me do this shit --- game/client/io/gamepad.hh | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 game/client/io/gamepad.hh (limited to 'game/client/io/gamepad.hh') diff --git a/game/client/io/gamepad.hh b/game/client/io/gamepad.hh new file mode 100644 index 0000000..4200037 --- /dev/null +++ b/game/client/io/gamepad.hh @@ -0,0 +1,54 @@ +#ifndef CLIENT_GAMEPAD_HH +#define CLIENT_GAMEPAD_HH 1 +#pragma once + +namespace io +{ +constexpr static int INVALID_GAMEPAD_AXIS = INT_MAX; +constexpr static int INVALID_GAMEPAD_BUTTON = INT_MAX; +} // namespace io + +namespace config +{ +class Boolean; +class Float; +} // namespace config + +struct GLFWgamepadstate; + +namespace io::gamepad +{ +extern bool available; +extern config::Float deadzone; +extern config::Boolean active; +extern GLFWgamepadstate state; +extern GLFWgamepadstate last_state; +} // namespace io::gamepad + +namespace io::gamepad +{ +void init(void); +void update_late(void); +} // namespace io::gamepad + +namespace io +{ +// 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; +}; +} // namespace io + +#endif // CLIENT_GAMEPAD_HH -- cgit