yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::input::SDL3InputBackend Class Reference

SDL3 input backend implementation. More...

#include <sdl3_input_backend.h>

Inheritance diagram for yaze::emu::input::SDL3InputBackend:
Collaboration diagram for yaze::emu::input::SDL3InputBackend:

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
 

Detailed Description

SDL3 input backend implementation.

Implements the IInputBackend interface using SDL3 APIs. Key differences from SDL2:

  • SDL_GetKeyboardState() returns bool* instead of Uint8*
  • SDL_GameController is replaced with SDL_Gamepad
  • Event types use SDL_EVENT_* prefix instead of SDL_*
  • event.key.keysym.sym is replaced with event.key.key

Definition at line 21 of file sdl3_input_backend.h.

Constructor & Destructor Documentation

◆ SDL3InputBackend()

yaze::emu::input::SDL3InputBackend::SDL3InputBackend ( )
default

◆ ~SDL3InputBackend()

yaze::emu::input::SDL3InputBackend::~SDL3InputBackend ( )
override

Definition at line 12 of file sdl3_input_backend.cc.

References Shutdown().

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

bool yaze::emu::input::SDL3InputBackend::Initialize ( const InputConfig & config)
overridevirtual

◆ Shutdown()

void yaze::emu::input::SDL3InputBackend::Shutdown ( )
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().

Here is the call graph for this function:

◆ Poll()

◆ ProcessEvent()

void yaze::emu::input::SDL3InputBackend::ProcessEvent ( void * event)
overridevirtual

Process platform-specific events (optional)

Parameters
eventPlatform-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().

Here is the call graph for this function:

◆ GetConfig()

InputConfig yaze::emu::input::SDL3InputBackend::GetConfig ( ) const
overridevirtual

Get current configuration.

Implements yaze::emu::input::IInputBackend.

Definition at line 299 of file sdl3_input_backend.cc.

References config_.

◆ SetConfig()

void yaze::emu::input::SDL3InputBackend::SetConfig ( const InputConfig & config)
overridevirtual

◆ GetBackendName()

std::string yaze::emu::input::SDL3InputBackend::GetBackendName ( ) const
overridevirtual

Get backend name for debugging.

Implements yaze::emu::input::IInputBackend.

Definition at line 316 of file sdl3_input_backend.cc.

◆ IsInitialized()

bool yaze::emu::input::SDL3InputBackend::IsInitialized ( ) const
overridevirtual

Check if backend is initialized.

Implements yaze::emu::input::IInputBackend.

Definition at line 318 of file sdl3_input_backend.cc.

References initialized_.

◆ UpdateEventState()

◆ PollGamepad()

◆ HandleGamepadEvent()

void yaze::emu::input::SDL3InputBackend::HandleGamepadEvent ( const SDL_Event & event)
private

Handle gamepad connection/disconnection.

Parameters
eventThe 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().

Here is the call graph for this function:

Member Data Documentation

◆ config_

InputConfig yaze::emu::input::SDL3InputBackend::config_
private

Definition at line 57 of file sdl3_input_backend.h.

Referenced by GetConfig(), Initialize(), Poll(), SetConfig(), and UpdateEventState().

◆ initialized_

bool yaze::emu::input::SDL3InputBackend::initialized_ = false
private

Definition at line 58 of file sdl3_input_backend.h.

Referenced by Initialize(), IsInitialized(), Poll(), ProcessEvent(), and Shutdown().

◆ event_state_

ControllerState yaze::emu::input::SDL3InputBackend::event_state_
private

Definition at line 59 of file sdl3_input_backend.h.

Referenced by Poll(), and UpdateEventState().

◆ gamepads_

platform::GamepadHandle yaze::emu::input::SDL3InputBackend::gamepads_[4] = {nullptr, nullptr, nullptr, nullptr}
private

Definition at line 62 of file sdl3_input_backend.h.

Referenced by HandleGamepadEvent(), Initialize(), PollGamepad(), SetConfig(), and Shutdown().

◆ kAxisDeadzone

constexpr int16_t yaze::emu::input::SDL3InputBackend::kAxisDeadzone = 8000
staticconstexprprivate

Definition at line 65 of file sdl3_input_backend.h.

Referenced by PollGamepad().


The documentation for this class was generated from the following files: