yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sdl3_input_backend.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EMU_INPUT_SDL3_INPUT_BACKEND_H_
2#define YAZE_APP_EMU_INPUT_SDL3_INPUT_BACKEND_H_
3
6
7namespace yaze {
8namespace emu {
9namespace input {
10
22 public:
24 ~SDL3InputBackend() override;
25
26 // IInputBackend interface
27 bool Initialize(const InputConfig& config) override;
28 void Shutdown() override;
29 ControllerState Poll(int player = 1) override;
30 void ProcessEvent(void* event) override;
31 InputConfig GetConfig() const override;
32 void SetConfig(const InputConfig& config) override;
33 std::string GetBackendName() const override;
34 bool IsInitialized() const override;
35
36 private:
42 void UpdateEventState(int keycode, bool pressed);
43
49 void PollGamepad(ControllerState& state, int player);
50
55 void HandleGamepadEvent(const SDL_Event& event);
56
58 bool initialized_ = false;
59 ControllerState event_state_; // Cached state for event-based mode
60
61 // Gamepad handles for up to 4 players
62 platform::GamepadHandle gamepads_[4] = {nullptr, nullptr, nullptr, nullptr};
63
64 // Axis deadzone for analog sticks
65 static constexpr int16_t kAxisDeadzone = 8000;
66};
67
68} // namespace input
69} // namespace emu
70} // namespace yaze
71
72#endif // YAZE_APP_EMU_INPUT_SDL3_INPUT_BACKEND_H_
Abstract input backend interface.
SDL3 input backend implementation.
void ProcessEvent(void *event) override
Process platform-specific events (optional)
void SetConfig(const InputConfig &config) override
Update configuration (hot-reload)
static constexpr int16_t kAxisDeadzone
platform::GamepadHandle gamepads_[4]
void PollGamepad(ControllerState &state, int player)
Poll gamepad state and update controller state.
InputConfig GetConfig() const override
Get current configuration.
std::string GetBackendName() const override
Get backend name for debugging.
void HandleGamepadEvent(const SDL_Event &event)
Handle gamepad connection/disconnection.
void Shutdown() override
Shutdown the input backend.
bool Initialize(const InputConfig &config) override
Initialize the input backend.
ControllerState Poll(int player=1) override
Poll current input state (call every frame)
void UpdateEventState(int keycode, bool pressed)
Update event state from keyboard event.
bool IsInitialized() const override
Check if backend is initialized.
SDL_GameController * GamepadHandle
Definition sdl_compat.h:193
SDL2/SDL3 compatibility layer.
Controller state (16-bit SNES controller format)
Input configuration (platform-agnostic key codes)