diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 3f3313bc..1338abfe 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(snes9x-qt VERSION 1.61) +project(snes9x-qt VERSION 1.62) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -102,8 +102,15 @@ list(APPEND INCLUDES ${SDL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}) list(APPEND FLAGS ${SDL_COMPILE_FLAGS} ${ZLIB_COMPILE_FLAGS}) if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - list(APPEND LIBS opengl32 libSDL2.a libz.a libc++.a) - list(APPEND LIBS gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 dinput8) + if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + message("Clang compiler, using libc++.") + list(APPEND LIBS libc++.a) + elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") + message("GNU compiler, using libstdc++.") + list(APPEND LIBS libstdc++.a) + endif() + + list(APPEND LIBS libSDL2.a libz.a opengl32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32 dinput8) list(APPEND DEFINES SDL_MAIN_HANDLED) list(APPEND PLATFORM_SOURCES ../common/video/wgl_context.cpp diff --git a/qt/src/ControllerPanel.cpp b/qt/src/ControllerPanel.cpp index 3cb14c3e..162f92f4 100644 --- a/qt/src/ControllerPanel.cpp +++ b/qt/src/ControllerPanel.cpp @@ -7,8 +7,8 @@ #include #include -ControllerPanel::ControllerPanel(EmuApplication *app) - : BindingPanel(app) +ControllerPanel::ControllerPanel(EmuApplication *app_) + : BindingPanel(app_) { setupUi(this); QObject::connect(controllerComboBox, &QComboBox::currentIndexChanged, [&](int index) { @@ -57,6 +57,11 @@ ControllerPanel::ControllerPanel(EmuApplication *app) recreateAutoAssignMenu(); onJoypadsChanged([&]{ recreateAutoAssignMenu(); }); + + connect(portComboBox, &QComboBox::currentIndexChanged, [&](int index) { + this->app->config->port_configuration = index; + app->updateBindings(); + }); } void ControllerPanel::recreateAutoAssignMenu() @@ -166,6 +171,7 @@ void ControllerPanel::showEvent(QShowEvent *event) { BindingPanel::showEvent(event); recreateAutoAssignMenu(); + portComboBox->setCurrentIndex(app->config->port_configuration); } ControllerPanel::~ControllerPanel() diff --git a/qt/src/ControllerPanel.ui b/qt/src/ControllerPanel.ui index c4f726a9..9ec2e90c 100644 --- a/qt/src/ControllerPanel.ui +++ b/qt/src/ControllerPanel.ui @@ -14,6 +14,52 @@ Form + + + + + + + 0 + 0 + + + + Controller Ports: + + + + + + + + One Controller + + + + + Two Controllers + + + + + Mouse + Controller + + + + + SuperScope + Controller + + + + + Controller + Multitap + + + + + + @@ -58,7 +104,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -86,7 +132,7 @@ Edit - QToolButton::DelayedPopup + QToolButton::ToolButtonPopupMode::DelayedPopup @@ -118,7 +164,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -136,10 +182,10 @@ <html><head/><body><p>This box lists keyboard keys and gamepad buttons mapped to the SNES controller. There are 4 slots, so you can assign 4 different keys or buttons to one SNES button.</p><p>To set a binding, click a box or highlight it with the keyboard and press Enter/Return. The box will show three dots &quot;...&quot;. Press the desired key or gamepad button to assign it to that box. The Escape key will clear the box.</p></body></html> - QAbstractItemView::NoEditTriggers + QAbstractItemView::EditTrigger::NoEditTriggers - QAbstractItemView::SingleSelection + QAbstractItemView::SelectionMode::SingleSelection true diff --git a/qt/src/EmuConfig.cpp b/qt/src/EmuConfig.cpp index 1ab06bae..b019e6da 100644 --- a/qt/src/EmuConfig.cpp +++ b/qt/src/EmuConfig.cpp @@ -286,6 +286,7 @@ bool EmuConfig::setDefaults(int section) if (section == -1 || section == 4) { // Controllers + port_configuration = 0; memset(binding.controller, 0, sizeof(binding.controller)); const char *button_list[] = { "Up", "Down", "Left", "Right", "d", "c", "s", "x", "z", "a", "Return", "Space" }; @@ -494,6 +495,10 @@ void EmuConfig::config(std::string filename, bool write) Enum("SoundFilter", sound_filter, { "Gaussian", "Nearest", "Linear", "Cubic", "Sinc" }); EndSection(); + BeginSection("Ports"); + Enum("PortConfiguration", port_configuration, { "OneController", "TwoControllers", "Mouse", "SuperScope", "Multitap" }); + EndSection(); + const char *names[] = { "Up", "Down", "Left", "Right", "A", "B", "X", "Y", "L", "R", "Start", "Select", "Turbo_A", "Turbo_B", "Turbo_X", "Turbo_Y", "Turbo_L", "Turbo_R" }; for (int c = 0; c < 5; c++) { diff --git a/qt/src/EmuConfig.hpp b/qt/src/EmuConfig.hpp index 9fed4592..17953d67 100644 --- a/qt/src/EmuConfig.hpp +++ b/qt/src/EmuConfig.hpp @@ -157,6 +157,16 @@ struct EmuConfig int sram_save_interval; + enum PortConfiguration + { + eOneController = 0, + eTwoControllers, + eMousePlusController, + eSuperScopePlusController, + eControllerPlusMultitap + }; + int port_configuration; + static const int allowed_bindings = 4; static const int num_controller_bindings = 18; static const int num_shortcuts = 55; diff --git a/qt/src/Snes9xController.cpp b/qt/src/Snes9xController.cpp index 65337bbf..c5641089 100644 --- a/qt/src/Snes9xController.cpp +++ b/qt/src/Snes9xController.cpp @@ -1,4 +1,5 @@ #include "Snes9xController.hpp" +#include "EmuConfig.hpp" #include "SoftwareScalers.hpp" #include #include @@ -610,8 +611,28 @@ void Snes9xController::updateBindings(const EmuConfig *const config) S9xUnmapAllControls(); - S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); - S9xSetController(1, CTL_JOYPAD, 1, 1, 1, 1); + switch (config->port_configuration) + { + case EmuConfig::eTwoControllers: + S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController(1, CTL_JOYPAD, 1, 1, 1, 1); + break; + case EmuConfig::eMousePlusController: + S9xSetController(0, CTL_MOUSE, 0, 0, 0, 0); + S9xSetController(1, CTL_JOYPAD, 0, 0, 0, 0); + break; + case EmuConfig::eSuperScopePlusController: + S9xSetController(0, CTL_SUPERSCOPE, 0, 0, 0, 0); + S9xSetController(1, CTL_JOYPAD, 0, 0, 0, 0); + break; + case EmuConfig::eControllerPlusMultitap: + S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController(1, CTL_MP5, 1, 2, 3, 4); + break; + default: + S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); + S9xSetController(1, CTL_NONE, 0, 0, 0, 0); + } for (int controller_number = 0; controller_number < 5; controller_number++) {