diff --git a/include/panda_qt/main_window.hpp b/include/panda_qt/main_window.hpp index 21ad4fa3..b5b93d56 100644 --- a/include/panda_qt/main_window.hpp +++ b/include/panda_qt/main_window.hpp @@ -1,7 +1,5 @@ #pragma once -#include - #include #include #include @@ -39,9 +37,6 @@ class MainWindow : public QMainWindow { QComboBox* themeSelect = nullptr; QMenuBar* menuBar = nullptr; - SDL_GameController* gameController = nullptr; - int gameControllerID; - Theme currentTheme; void setTheme(Theme theme); void swapEmuBuffer(); diff --git a/include/panda_sdl/frontend_sdl.hpp b/include/panda_sdl/frontend_sdl.hpp index 4918d84e..d0df3560 100644 --- a/include/panda_sdl/frontend_sdl.hpp +++ b/include/panda_sdl/frontend_sdl.hpp @@ -4,16 +4,18 @@ #include "emulator.hpp" -struct FrontendSDL { +class FrontendSDL { + Emulator emu; +#ifdef PANDA3DS_ENABLE_OPENGL + SDL_GLContext glContext; +#endif + + public: FrontendSDL(); bool loadROM(const std::filesystem::path& path); void run(); - Emulator emu; SDL_Window* window = nullptr; -#ifdef PANDA3DS_ENABLE_OPENGL - SDL_GLContext glContext; -#endif SDL_GameController* gameController = nullptr; int gameControllerID; }; \ No newline at end of file diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 20f5c9be..2c2cc64f 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -51,24 +51,6 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) usingGL = (rendererType == RendererType::OpenGL || rendererType == RendererType::Software || rendererType == RendererType::Null); usingVk = (rendererType == RendererType::Vulkan); - if (SDL_Init(SDL_INIT_EVENTS) < 0) { - Helpers::panic("Failed to initialize SDL2"); - } - - // Make SDL use consistent positional button mapping - SDL_SetHint(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0"); - if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0) { - Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError()); - } - - if (SDL_WasInit(SDL_INIT_GAMECONTROLLER)) { - gameController = SDL_GameControllerOpen(0); - - if (gameController != nullptr) { - SDL_Joystick* stick = SDL_GameControllerGetJoystick(gameController); - gameControllerID = SDL_JoystickInstanceID(stick); - } - } if (usingGL) { // Make GL context current for this thread, enable VSync GL::Context* glContext = screen.getGLContext(); diff --git a/src/panda_sdl/frontend_sdl.cpp b/src/panda_sdl/frontend_sdl.cpp index 3368a12e..d1076d9d 100644 --- a/src/panda_sdl/frontend_sdl.cpp +++ b/src/panda_sdl/frontend_sdl.cpp @@ -75,7 +75,6 @@ FrontendSDL::FrontendSDL() { } bool FrontendSDL::loadROM(const std::filesystem::path& path) { return emu.loadROM(path); } - void FrontendSDL::run() { emu.run(this); } void Emulator::run(void* frontend) { @@ -352,7 +351,6 @@ void Emulator::run(void* frontend) { // TODO: Should this be uncommented? // kernel.evalReschedule(); - // Update inputs in the HID module SDL_GL_SwapWindow(frontendSDL->window); } } diff --git a/src/panda_sdl/main.cpp b/src/panda_sdl/main.cpp index 001148c7..ef354c61 100644 --- a/src/panda_sdl/main.cpp +++ b/src/panda_sdl/main.cpp @@ -1,11 +1,11 @@ #include "panda_sdl/frontend_sdl.hpp" int main(int argc, char *argv[]) { - FrontendSDL frontend; + FrontendSDL app; if (argc > 1) { auto romPath = std::filesystem::current_path() / argv[1]; - if (!frontend.loadROM(romPath)) { + if (!app.loadROM(romPath)) { // For some reason just .c_str() doesn't show the proper path Helpers::panic("Failed to load ROM file: %s", romPath.string().c_str()); } @@ -13,5 +13,5 @@ int main(int argc, char *argv[]) { printf("No ROM inserted! Load a ROM by dragging and dropping it into the emulator window!\n"); } - frontend.run(); + app.run(); }