feat: Implement input management system with SDL2 support

- Introduced a new input management system utilizing SDL2 for continuous polling of SNES controller states, enhancing responsiveness and gameplay experience.
- Replaced the previous ImGui-based event handling with a more robust input manager that supports multiple backends and configurations.
- Added a dedicated input backend for SDL2, allowing for flexible key mapping and improved input handling.
- Updated the Emulator class to integrate the new input manager, ensuring seamless interaction with the emulator's UI and game logic.
- Refactored keyboard configuration UI to facilitate easy remapping of SNES controller buttons, improving user accessibility.
This commit is contained in:
scawful
2025-10-08 21:40:21 -04:00
parent ba70176ee2
commit 0579fc2c65
11 changed files with 878 additions and 224 deletions

View File

@@ -8,6 +8,7 @@
#include "app/emu/audio/audio_backend.h"
#include "app/emu/debug/breakpoint_manager.h"
#include "app/emu/debug/disassembly_viewer.h"
#include "app/emu/input/input_manager.h"
#include "app/rom.h"
namespace yaze {
@@ -21,20 +22,8 @@ class IRenderer;
*/
namespace emu {
struct EmulatorKeybindings {
ImGuiKey a_button = ImGuiKey_Z;
ImGuiKey b_button = ImGuiKey_A;
ImGuiKey x_button = ImGuiKey_S;
ImGuiKey y_button = ImGuiKey_X;
ImGuiKey l_button = ImGuiKey_Q;
ImGuiKey r_button = ImGuiKey_W;
ImGuiKey start_button = ImGuiKey_Enter;
ImGuiKey select_button = ImGuiKey_Backspace;
ImGuiKey up_button = ImGuiKey_UpArrow;
ImGuiKey down_button = ImGuiKey_DownArrow;
ImGuiKey left_button = ImGuiKey_LeftArrow;
ImGuiKey right_button = ImGuiKey_RightArrow;
};
// REMOVED: EmulatorKeybindings (ImGuiKey-based)
// Now using ui::InputHandler with SDL_GetKeyboardState() for proper continuous polling
/**
* @class Emulator
@@ -98,7 +87,6 @@ class Emulator {
private:
void RenderNavBar();
void HandleEvents();
void RenderEmulatorInterface();
void RenderSnesPpu();
@@ -161,7 +149,8 @@ class Emulator {
std::vector<uint8_t> rom_data_;
EmulatorKeybindings keybindings_;
// Input handling (abstracted for SDL2/SDL3/custom backends)
input::InputManager input_manager_;
};
} // namespace emu