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");
67 ImGuiIO& io = ImGui::GetIO();
95 keyboard_state, SDL_GetScancodeFromKey(
config_.
key_up,
nullptr)));
139 int gamepad_index = (player > 0 && player <= 4) ? player - 1 : 0;
142 if (!gamepad)
return;
206 SDL_Event* sdl_event =
static_cast<SDL_Event*
>(event);
224 if (event.type == SDL_EVENT_GAMEPAD_ADDED) {
226 for (
int i = 0; i < 4; ++i) {
228 gamepads_[i] = SDL_OpenGamepad(event.gdevice.which);
230 LOG_INFO(
"InputBackend",
"SDL3 Gamepad connected for player %d", i + 1);
235 }
else if (event.type == SDL_EVENT_GAMEPAD_REMOVED) {
237 for (
int i = 0; i < 4; ++i) {
239 SDL_GetGamepadID(
gamepads_[i]) == event.gdevice.which) {
242 LOG_INFO(
"InputBackend",
"SDL3 Gamepad disconnected for player %d", i + 1);
249 if (event.type == SDL_CONTROLLERDEVICEADDED) {
250 for (
int i = 0; i < 4; ++i) {
254 LOG_INFO(
"InputBackend",
"Gamepad connected for player " +
255 std::to_string(i + 1));
260 }
else if (event.type == SDL_CONTROLLERDEVICEREMOVED) {
261 for (
int i = 0; i < 4; ++i) {
262 if (
gamepads_[i] && SDL_JoystickInstanceID(
263 SDL_GameControllerGetJoystick(
gamepads_[i])) ==
264 event.cdevice.which) {
267 LOG_INFO(
"InputBackend",
"Gamepad disconnected for player " +
268 std::to_string(i + 1));
313 LOG_INFO(
"InputBackend",
"SDL3 Gamepad connected for player 1");
#define LOG_WARN(category, format,...)
#define LOG_INFO(category, format,...)