3#include "imgui/imgui.h"
16 LOG_WARN(
"InputBackend",
"SDL3 backend already initialized");
28 LOG_INFO(
"InputBackend",
"SDL3 Gamepad connected for player 1");
33 LOG_INFO(
"InputBackend",
"SDL3 Input Backend initialized");
40 for (
int i = 0; i < 4; ++i) {
47 LOG_INFO(
"InputBackend",
"SDL3 Input Backend shut down");
62 ImGuiIO& io = ImGui::GetIO();
90 keyboard_state, SDL_GetScancodeFromKey(
config_.
key_up,
nullptr)));
134 int gamepad_index = (player > 0 && player <= 4) ? player - 1 : 0;
137 if (!gamepad)
return;
201 SDL_Event* sdl_event =
static_cast<SDL_Event*
>(event);
219 if (event.type == SDL_EVENT_GAMEPAD_ADDED) {
221 for (
int i = 0; i < 4; ++i) {
223 gamepads_[i] = SDL_OpenGamepad(event.gdevice.which);
225 LOG_INFO(
"InputBackend",
"SDL3 Gamepad connected for player %d", i + 1);
230 }
else if (event.type == SDL_EVENT_GAMEPAD_REMOVED) {
232 for (
int i = 0; i < 4; ++i) {
234 SDL_GetGamepadID(
gamepads_[i]) == event.gdevice.which) {
237 LOG_INFO(
"InputBackend",
"SDL3 Gamepad disconnected for player %d", i + 1);
244 if (event.type == SDL_CONTROLLERDEVICEADDED) {
245 for (
int i = 0; i < 4; ++i) {
249 LOG_INFO(
"InputBackend",
"Gamepad connected for player " +
250 std::to_string(i + 1));
255 }
else if (event.type == SDL_CONTROLLERDEVICEREMOVED) {
256 for (
int i = 0; i < 4; ++i) {
257 if (
gamepads_[i] && SDL_JoystickInstanceID(
258 SDL_GameControllerGetJoystick(
gamepads_[i])) ==
259 event.cdevice.which) {
262 LOG_INFO(
"InputBackend",
"Gamepad disconnected for player " +
263 std::to_string(i + 1));
308 LOG_INFO(
"InputBackend",
"SDL3 Gamepad connected for player 1");
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)