SDL3 input backend implementation. More...
#include <sdl3_input_backend.h>


Public Member Functions | |
| SDL3InputBackend () | |
| ~SDL3InputBackend () override | |
| bool | Initialize (const InputConfig &config) override |
| Initialize the input backend. | |
| void | Shutdown () override |
| Shutdown the input backend. | |
| ControllerState | Poll (int player=1) override |
| Poll current input state (call every frame) | |
| void | ProcessEvent (void *event) override |
| Process platform-specific events (optional) | |
| InputConfig | GetConfig () const override |
| Get current configuration. | |
| void | SetConfig (const InputConfig &config) override |
| Update configuration (hot-reload) | |
| std::string | GetBackendName () const override |
| Get backend name for debugging. | |
| bool | IsInitialized () const override |
| Check if backend is initialized. | |
Public Member Functions inherited from yaze::emu::input::IInputBackend | |
| virtual | ~IInputBackend ()=default |
Private Member Functions | |
| void | UpdateEventState (int keycode, bool pressed) |
| Update event state from keyboard event. | |
| void | PollGamepad (ControllerState &state, int player) |
| Poll gamepad state and update controller state. | |
| void | HandleGamepadEvent (const SDL_Event &event) |
| Handle gamepad connection/disconnection. | |
Private Attributes | |
| InputConfig | config_ |
| bool | initialized_ = false |
| ControllerState | event_state_ |
| platform::GamepadHandle | gamepads_ [4] = {nullptr, nullptr, nullptr, nullptr} |
Static Private Attributes | |
| static constexpr int16_t | kAxisDeadzone = 8000 |
SDL3 input backend implementation.
Implements the IInputBackend interface using SDL3 APIs. Key differences from SDL2:
Definition at line 21 of file sdl3_input_backend.h.
|
default |
|
override |
Definition at line 12 of file sdl3_input_backend.cc.
References Shutdown().

|
overridevirtual |
Initialize the input backend.
Implements yaze::emu::input::IInputBackend.
Definition at line 14 of file sdl3_input_backend.cc.
References yaze::emu::input::ApplyDefaultKeyBindings(), config_, yaze::emu::input::InputConfig::enable_gamepad, yaze::emu::input::InputConfig::gamepad_index, gamepads_, initialized_, LOG_INFO, LOG_WARN, and yaze::platform::OpenGamepad().

|
overridevirtual |
Shutdown the input backend.
Implements yaze::emu::input::IInputBackend.
Definition at line 37 of file sdl3_input_backend.cc.
References yaze::platform::CloseGamepad(), gamepads_, initialized_, and LOG_INFO.
Referenced by ~SDL3InputBackend().

|
overridevirtual |
Poll current input state (call every frame)
| player | Player number (1-4) |
Implements yaze::emu::input::IInputBackend.
Definition at line 51 of file sdl3_input_backend.cc.
References yaze::emu::input::A, yaze::emu::input::B, config_, yaze::emu::input::InputConfig::continuous_polling, yaze::emu::input::DOWN, yaze::emu::input::InputConfig::enable_gamepad, event_state_, yaze::emu::input::InputConfig::ignore_imgui_text_input, initialized_, yaze::platform::IsKeyPressed(), yaze::emu::input::InputConfig::key_a, yaze::emu::input::InputConfig::key_b, yaze::emu::input::InputConfig::key_down, yaze::emu::input::InputConfig::key_l, yaze::emu::input::InputConfig::key_left, yaze::emu::input::InputConfig::key_r, yaze::emu::input::InputConfig::key_right, yaze::emu::input::InputConfig::key_select, yaze::emu::input::InputConfig::key_start, yaze::emu::input::InputConfig::key_up, yaze::emu::input::InputConfig::key_x, yaze::emu::input::InputConfig::key_y, yaze::emu::input::L, yaze::emu::input::LEFT, PollGamepad(), yaze::emu::input::R, yaze::emu::input::RIGHT, yaze::emu::input::SELECT, yaze::emu::input::ControllerState::SetButton(), yaze::emu::input::START, yaze::emu::input::UP, yaze::emu::input::X, and yaze::emu::input::Y.

|
overridevirtual |
Process platform-specific events (optional)
| event | Platform-specific event data (e.g., SDL_Event*) |
Implements yaze::emu::input::IInputBackend.
Definition at line 198 of file sdl3_input_backend.cc.
References yaze::platform::GetKeyFromEvent(), HandleGamepadEvent(), initialized_, yaze::platform::kEventKeyDown, yaze::platform::kEventKeyUp, and UpdateEventState().

|
overridevirtual |
Get current configuration.
Implements yaze::emu::input::IInputBackend.
Definition at line 299 of file sdl3_input_backend.cc.
References config_.
|
overridevirtual |
Update configuration (hot-reload)
Implements yaze::emu::input::IInputBackend.
Definition at line 301 of file sdl3_input_backend.cc.
References yaze::platform::CloseGamepad(), config_, yaze::emu::input::InputConfig::enable_gamepad, yaze::emu::input::InputConfig::gamepad_index, gamepads_, LOG_INFO, and yaze::platform::OpenGamepad().

|
overridevirtual |
Get backend name for debugging.
Implements yaze::emu::input::IInputBackend.
Definition at line 316 of file sdl3_input_backend.cc.
|
overridevirtual |
Check if backend is initialized.
Implements yaze::emu::input::IInputBackend.
Definition at line 318 of file sdl3_input_backend.cc.
References initialized_.
|
private |
Update event state from keyboard event.
| keycode | The keycode from the event |
| pressed | Whether the key is pressed |
Definition at line 271 of file sdl3_input_backend.cc.
References yaze::emu::input::A, yaze::emu::input::B, config_, yaze::emu::input::DOWN, event_state_, yaze::emu::input::InputConfig::key_a, yaze::emu::input::InputConfig::key_b, yaze::emu::input::InputConfig::key_down, yaze::emu::input::InputConfig::key_l, yaze::emu::input::InputConfig::key_left, yaze::emu::input::InputConfig::key_r, yaze::emu::input::InputConfig::key_right, yaze::emu::input::InputConfig::key_select, yaze::emu::input::InputConfig::key_start, yaze::emu::input::InputConfig::key_up, yaze::emu::input::InputConfig::key_x, yaze::emu::input::InputConfig::key_y, yaze::emu::input::L, yaze::emu::input::LEFT, yaze::emu::input::R, yaze::emu::input::RIGHT, yaze::emu::input::SELECT, yaze::emu::input::ControllerState::SetButton(), yaze::emu::input::START, yaze::emu::input::UP, yaze::emu::input::X, and yaze::emu::input::Y.
Referenced by ProcessEvent().

|
private |
Poll gamepad state and update controller state.
| state | The controller state to update |
| player | The player number (1-4) |
Definition at line 133 of file sdl3_input_backend.cc.
References yaze::emu::input::A, yaze::emu::input::B, yaze::emu::input::DOWN, gamepads_, yaze::platform::GetGamepadAxis(), yaze::platform::GetGamepadButton(), kAxisDeadzone, yaze::platform::kGamepadAxisLeftX, yaze::platform::kGamepadAxisLeftY, yaze::platform::kGamepadButtonA, yaze::platform::kGamepadButtonB, yaze::platform::kGamepadButtonBack, yaze::platform::kGamepadButtonDpadDown, yaze::platform::kGamepadButtonDpadLeft, yaze::platform::kGamepadButtonDpadRight, yaze::platform::kGamepadButtonDpadUp, yaze::platform::kGamepadButtonLeftShoulder, yaze::platform::kGamepadButtonRightShoulder, yaze::platform::kGamepadButtonStart, yaze::platform::kGamepadButtonX, yaze::platform::kGamepadButtonY, yaze::emu::input::L, yaze::emu::input::LEFT, yaze::emu::input::R, yaze::emu::input::RIGHT, yaze::emu::input::SELECT, yaze::emu::input::ControllerState::SetButton(), yaze::emu::input::START, yaze::emu::input::UP, yaze::emu::input::X, and yaze::emu::input::Y.
Referenced by Poll().

|
private |
Handle gamepad connection/disconnection.
| event | The SDL event |
Definition at line 216 of file sdl3_input_backend.cc.
References yaze::platform::CloseGamepad(), gamepads_, LOG_INFO, and yaze::platform::OpenGamepad().
Referenced by ProcessEvent().

|
private |
Definition at line 57 of file sdl3_input_backend.h.
Referenced by GetConfig(), Initialize(), Poll(), SetConfig(), and UpdateEventState().
|
private |
Definition at line 58 of file sdl3_input_backend.h.
Referenced by Initialize(), IsInitialized(), Poll(), ProcessEvent(), and Shutdown().
|
private |
Definition at line 59 of file sdl3_input_backend.h.
Referenced by Poll(), and UpdateEventState().
|
private |
Definition at line 62 of file sdl3_input_backend.h.
Referenced by HandleGamepadEvent(), Initialize(), PollGamepad(), SetConfig(), and Shutdown().
|
staticconstexprprivate |
Definition at line 65 of file sdl3_input_backend.h.
Referenced by PollGamepad().