diff --git a/RetroFE/Source/CMakeLists.txt b/RetroFE/Source/CMakeLists.txt index 62030f020..c878557ba 100644 --- a/RetroFE/Source/CMakeLists.txt +++ b/RetroFE/Source/CMakeLists.txt @@ -55,21 +55,21 @@ if(WIN32) endif() -if(WIN32) - find_package(Glib2 REQUIRED) - find_package(GStreamer REQUIRED) - find_package(SDL2 REQUIRED) - find_package(SDL2_image REQUIRED) - find_package(SDL2_mixer REQUIRED) +if(WIN32) + find_package(Glib2 REQUIRED) + find_package(GStreamer REQUIRED) + find_package(SDL3 REQUIRED) + find_package(SDL2_image REQUIRED) + find_package(SDL2_mixer REQUIRED) find_package(SDL2_ttf REQUIRED) find_package(ZLIB REQUIRED) -elseif(APPLE) - find_package(Glib2 REQUIRED) - find_package(GStreamer REQUIRED) - find_package(SDL2 REQUIRED) - find_package(SDL2_image REQUIRED) - find_package(SDL2_mixer REQUIRED) +elseif(APPLE) + find_package(Glib2 REQUIRED) + find_package(GStreamer REQUIRED) + find_package(SDL3 REQUIRED) + find_package(SDL2_image REQUIRED) + find_package(SDL2_mixer REQUIRED) find_package(SDL2_ttf REQUIRED) find_package(ZLIB REQUIRED) find_library(COREFOUNDATION CoreFoundation) @@ -84,10 +84,10 @@ elseif(APPLE) else() include(FindPkgConfig) - # Find necessary libraries using pkg-config - pkg_search_module(SDL2 REQUIRED sdl2) - pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) - pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer) + # Find necessary libraries using pkg-config + pkg_search_module(SDL3 REQUIRED sdl3) + pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) + pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer) pkg_search_module(SDL2_TTF REQUIRED SDL2_ttf) pkg_search_module(ZLIB REQUIRED zlib) pkg_search_module(MINIZIP REQUIRED minizip) @@ -100,11 +100,11 @@ else() pkg_search_module(LIBSERIALPORT REQUIRED libserialport) find_package(Threads REQUIRED) - # Include directories for all found libraries - include_directories( - ${SDL2_INCLUDE_DIRS} - ${SDL2_IMAGE_INCLUDE_DIRS} - ${SDL2_MIXER_INCLUDE_DIRS} + # Include directories for all found libraries + include_directories( + ${SDL3_INCLUDE_DIRS} + ${SDL2_IMAGE_INCLUDE_DIRS} + ${SDL2_MIXER_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${MINIZIP_INCLUDE_DIRS} @@ -118,11 +118,11 @@ else() ${LIBSERIALPORT_INCLUDE_DIRS} ) - # Link directories (optional, mostly handled by pkg-config) - link_directories( - ${SDL2_LIBRARY_DIRS} - ${SDL2_IMAGE_LIBRARY_DIRS} - ${SDL2_MIXER_LIBRARY_DIRS} + # Link directories (optional, mostly handled by pkg-config) + link_directories( + ${SDL3_LIBRARY_DIRS} + ${SDL2_IMAGE_LIBRARY_DIRS} + ${SDL2_MIXER_LIBRARY_DIRS} ${SDL2_TTF_LIBRARY_DIRS} ${ZLIB_LIBRARY_DIRS} ${MINIZIP_LIBRARY_DIRS} @@ -134,11 +134,11 @@ else() ${LIBSERIALPORT_LIBRARY_DIRS} ) - # Append the necessary libraries to be linked - list(APPEND RETROFE_LIBRARIES - ${SDL2_LIBRARIES} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} + # Append the necessary libraries to be linked + list(APPEND RETROFE_LIBRARIES + ${SDL3_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_MIXER_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} @@ -155,12 +155,12 @@ else() add_definitions(${LIBEVDEV_CFLAGS_OTHER}) endif() -set(RETROFE_INCLUDE_DIRS - "${GLIB2_INCLUDE_DIRS}" - "${GSTREAMER_INCLUDE_DIRS}" - "${SDL2_INCLUDE_DIRS}" - "${SDL2_IMAGE_INCLUDE_DIRS}" - "${SDL2_MIXER_INCLUDE_DIRS}" +set(RETROFE_INCLUDE_DIRS + "${GLIB2_INCLUDE_DIRS}" + "${GSTREAMER_INCLUDE_DIRS}" + "${SDL3_INCLUDE_DIRS}" + "${SDL2_IMAGE_INCLUDE_DIRS}" + "${SDL2_MIXER_INCLUDE_DIRS}" "${SDL2_TTF_INCLUDE_DIRS}" "${ZLIB_INCLUDE_DIRS}" "${WEBP_INCLUDE_DIRS}" @@ -173,12 +173,12 @@ set(RETROFE_INCLUDE_DIRS # Link PacDrive library if on Windows if(WIN32) - set(RETROFE_LIBRARIES - ${GLIB2_LIBRARIES} - ${GSTREAMER_LIBRARIES} - ${SDL2_LIBRARIES} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} + set(RETROFE_LIBRARIES + ${GLIB2_LIBRARIES} + ${GSTREAMER_LIBRARIES} + ${SDL3_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_MIXER_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${ZLIB_LIBRARIES} ) @@ -397,12 +397,12 @@ endif() target_link_libraries(retrofe ${RETROFE_LIBRARIES}) if(APPLE) - target_link_libraries(retrofe - ${COREFOUNDATION} - ${IOKIT} - ${SDL2_LIBRARIES} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_MIXER_LIBRARIES} + target_link_libraries(retrofe + ${COREFOUNDATION} + ${IOKIT} + ${SDL3_LIBRARIES} + ${SDL2_IMAGE_LIBRARIES} + ${SDL2_MIXER_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${LIBUSB_LIBRARY} ${GLIB2_LIBRARIES} diff --git a/RetroFE/Source/Control/InputHandler.h b/RetroFE/Source/Control/InputHandler.h index 82b70189c..ff1a2cba0 100644 --- a/RetroFE/Source/Control/InputHandler.h +++ b/RetroFE/Source/Control/InputHandler.h @@ -1,6 +1,6 @@ #pragma once -#include +#include class InputHandler { diff --git a/RetroFE/Source/Control/JoyAxisHandler.cpp b/RetroFE/Source/Control/JoyAxisHandler.cpp index 106bcfca9..68ca2591e 100644 --- a/RetroFE/Source/Control/JoyAxisHandler.cpp +++ b/RetroFE/Source/Control/JoyAxisHandler.cpp @@ -15,7 +15,7 @@ void JoyAxisHandler::reset() bool JoyAxisHandler::update(SDL_Event &e) { - if(e.type != SDL_JOYAXISMOTION || (joyid_ != -1 && e.jaxis.which != joyid_) || e.jaxis.axis != axis_) return false; + if(e.type != SDL_EVENT_JOYSTICK_AXIS_MOTION || (joyid_ != -1 && e.jaxis.which != joyid_) || e.jaxis.axis != axis_) return false; pressed_ = (min_ <= e.jaxis.value && e.jaxis.value <= max_); return true; diff --git a/RetroFE/Source/Control/JoyButtonHandler.cpp b/RetroFE/Source/Control/JoyButtonHandler.cpp index 74d41d732..22023daa2 100644 --- a/RetroFE/Source/Control/JoyButtonHandler.cpp +++ b/RetroFE/Source/Control/JoyButtonHandler.cpp @@ -13,10 +13,10 @@ void JoyButtonHandler::reset() bool JoyButtonHandler::update(SDL_Event &e) { - if(e.type != SDL_JOYBUTTONUP && e.type != SDL_JOYBUTTONDOWN) return false; + if(e.type != SDL_EVENT_JOYSTICK_BUTTON_UP && e.type != SDL_EVENT_JOYSTICK_BUTTON_DOWN) return false; if((joynum_ == -1 || e.jbutton.which == joynum_) && e.jbutton.button == button_) { - pressed_ = (e.type == SDL_JOYBUTTONDOWN) ? true : false; + pressed_ = (e.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN) ? true : false; return true; } diff --git a/RetroFE/Source/Control/JoyHatHandler.cpp b/RetroFE/Source/Control/JoyHatHandler.cpp index 1a7e3f283..0899d97c1 100644 --- a/RetroFE/Source/Control/JoyHatHandler.cpp +++ b/RetroFE/Source/Control/JoyHatHandler.cpp @@ -14,7 +14,7 @@ void JoyHatHandler::reset() bool JoyHatHandler::update(SDL_Event &e) { - if(e.type != SDL_JOYHATMOTION || (joynum_ != -1 && e.jhat.which != joynum_) || e.jhat.hat != hatnum_) return false; + if(e.type != SDL_EVENT_JOYSTICK_HAT_MOTION || (joynum_ != -1 && e.jhat.which != joynum_) || e.jhat.hat != hatnum_) return false; pressed_ = (e.jhat.value == direction_); return true; diff --git a/RetroFE/Source/Control/KeyboardHandler.cpp b/RetroFE/Source/Control/KeyboardHandler.cpp index 8c7b0ba78..6da617427 100644 --- a/RetroFE/Source/Control/KeyboardHandler.cpp +++ b/RetroFE/Source/Control/KeyboardHandler.cpp @@ -12,10 +12,10 @@ void KeyboardHandler::reset() bool KeyboardHandler::update(SDL_Event &e) { - if(e.type != SDL_KEYUP && e.type != SDL_KEYDOWN) return false; + if(e.type != SDL_EVENT_KEY_UP && e.type != SDL_EVENT_KEY_DOWN) return false; - if(e.key.keysym.scancode == scancode_) { - pressed_ = (e.type == SDL_KEYDOWN); + if(e.key.scancode == scancode_) { + pressed_ = (e.type == SDL_EVENT_KEY_DOWN); return true; } @@ -29,6 +29,6 @@ bool KeyboardHandler::pressed() void KeyboardHandler::updateKeystate() { - const Uint8 *state = SDL_GetKeyboardState(nullptr); + const bool *state = SDL_GetKeyboardState(nullptr); pressed_ = state[scancode_]; } diff --git a/RetroFE/Source/Control/MouseButtonHandler.cpp b/RetroFE/Source/Control/MouseButtonHandler.cpp index 059f97cb6..007238a4a 100644 --- a/RetroFE/Source/Control/MouseButtonHandler.cpp +++ b/RetroFE/Source/Control/MouseButtonHandler.cpp @@ -13,10 +13,10 @@ void MouseButtonHandler::reset() bool MouseButtonHandler::update(SDL_Event &e) { - if(e.type != SDL_MOUSEBUTTONUP && e.type != SDL_MOUSEBUTTONDOWN) return false; + if(e.type != SDL_EVENT_MOUSE_BUTTON_UP && e.type != SDL_EVENT_MOUSE_BUTTON_DOWN) return false; if(e.button.button == button_) { - pressed_ = (e.type == SDL_MOUSEBUTTONDOWN) ? true : false; + pressed_ = (e.type == SDL_EVENT_MOUSE_BUTTON_DOWN) ? true : false; return true; } diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index ebf57e45c..fb9635fde 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -340,8 +340,9 @@ bool UserInput::update( SDL_Event &e ) memset( currentKeyState_, 0, sizeof( currentKeyState_ ) ); // Handle adding a joystick - if ( e.type == SDL_JOYDEVICEADDED ) { - SDL_JoystickID id = SDL_JoystickInstanceID( SDL_JoystickOpen( e.jdevice.which ) ); + if ( e.type == SDL_EVENT_JOYSTICK_ADDED ) { + SDL_Joystick* joystick = SDL_OpenJoystick( e.jdevice.which ); + SDL_JoystickID id = SDL_GetJoystickID( joystick ); for ( unsigned int i = 0; i < cMaxJoy; i++ ) { if ( joysticks_[i] == -1 ) { joysticks_[i] = id; @@ -351,21 +352,21 @@ bool UserInput::update( SDL_Event &e ) } // Handle removing a joystick - if ( e.type == SDL_JOYDEVICEREMOVED ) { + if ( e.type == SDL_EVENT_JOYSTICK_REMOVED ) { for ( unsigned int i = 0; i < cMaxJoy; i++ ) { if ( joysticks_[i] == e.jdevice.which ) { joysticks_[i] = -1; break; } } - SDL_JoystickClose( SDL_JoystickFromInstanceID( e.jdevice.which ) ); + SDL_CloseJoystick( SDL_GetJoystickFromID( e.jdevice.which ) ); } // Remap joystick events - if ( e.type == SDL_JOYAXISMOTION || - e.type == SDL_JOYBUTTONUP || - e.type == SDL_JOYBUTTONDOWN || - e.type == SDL_JOYHATMOTION ) { + if ( e.type == SDL_EVENT_JOYSTICK_AXIS_MOTION || + e.type == SDL_EVENT_JOYSTICK_BUTTON_UP || + e.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN || + e.type == SDL_EVENT_JOYSTICK_HAT_MOTION ) { for ( unsigned int i = 0; i < cMaxJoy; i++ ) { if ( joysticks_[i] == e.jdevice.which ) { e.jdevice.which = i; diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index a2989241a..32439a8aa 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -14,8 +14,8 @@ * along with RetroFE. If not, see . */ #pragma once -#include -#include +#include +#include #include #include #include diff --git a/RetroFE/Source/Execute/Input/InputMonitor.cpp b/RetroFE/Source/Execute/Input/InputMonitor.cpp index 2bb2709a3..ec5fb6652 100644 --- a/RetroFE/Source/Execute/Input/InputMonitor.cpp +++ b/RetroFE/Source/Execute/Input/InputMonitor.cpp @@ -60,7 +60,7 @@ InputMonitor::InputMonitor(Configuration& config) { InputDetectionResult InputMonitor::checkSdlEvents() { SDL_Event e; while (SDL_PollEvent(&e)) { - if (e.type == SDL_JOYBUTTONDOWN) { + if (e.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN) { int buttonIdx = e.jbutton.button; if (singleQuitButtonIndices_.count(buttonIdx) > 0) { @@ -130,7 +130,7 @@ InputDetectionResult InputMonitor::checkSdlEvents() { return InputDetectionResult::PlayInput; } } - else if (e.type == SDL_JOYBUTTONUP) { + else if (e.type == SDL_EVENT_JOYSTICK_BUTTON_UP) { joystickButtonState_[e.jbutton.which][e.jbutton.button] = false; } } diff --git a/RetroFE/Source/Execute/Input/InputMonitor.h b/RetroFE/Source/Execute/Input/InputMonitor.h index aba42099b..622c3fbc4 100644 --- a/RetroFE/Source/Execute/Input/InputMonitor.h +++ b/RetroFE/Source/Execute/Input/InputMonitor.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include "SDLJoyStickScopeGuard.h" #include "../../Database/Configuration.h" // For reading config values diff --git a/RetroFE/Source/Execute/Input/SDLJoyStickScopeGuard.h b/RetroFE/Source/Execute/Input/SDLJoyStickScopeGuard.h index a44d6ac0f..eba96078a 100644 --- a/RetroFE/Source/Execute/Input/SDLJoyStickScopeGuard.h +++ b/RetroFE/Source/Execute/Input/SDLJoyStickScopeGuard.h @@ -6,7 +6,7 @@ #include // Assuming SDL headers are available via the build system's include paths -#include +#include // Assuming your logging utility is accessible from this location. // Adjust the path if necessary based on your project structure. @@ -26,7 +26,7 @@ struct SDLJoystickScopeGuard { SDLJoystickScopeGuard() { // Check if the joystick subsystem is already running. - if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) != 0) { + if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) != 0) { LOG_INFO("Launcher", "Using existing SDL joystick session for input monitoring."); // We don't need to do anything else. The main RetroFE instance is handling it. // Joysticks are assumed to be open already. @@ -34,18 +34,20 @@ struct SDLJoystickScopeGuard { else { // SDL is not initialized, so we must do it. LOG_INFO("Launcher", "SDL joystick session not found. Initializing a temporary one."); - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == 0) { + if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD) == 0) { initialized_by_me = true; // We are responsible for cleanup. - SDL_JoystickEventState(SDL_ENABLE); + SDL_SetJoystickEventsEnabled(true); // Enumerate and open all joysticks - int numJoysticks = SDL_NumJoysticks(); + int numJoysticks; + SDL_JoystickID* joystickIDs = SDL_GetJoysticks(&numJoysticks); for (int i = 0; i < numJoysticks; ++i) { - SDL_Joystick* joy = SDL_JoystickOpen(i); + SDL_Joystick* joy = SDL_OpenJoystick(joystickIDs[i]); if (joy) { joysticks.push_back(joy); } } + SDL_free(joystickIDs); LOG_INFO("Launcher", "Temporary SDL joystick subsystem initialized successfully."); } else { @@ -58,10 +60,10 @@ struct SDLJoystickScopeGuard { // Only shut down the subsystem if we were the one who started it. if (initialized_by_me) { for (auto joy : joysticks) { - if (joy) SDL_JoystickClose(joy); + if (joy) SDL_CloseJoystick(joy); } joysticks.clear(); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMEPAD); LOG_INFO("Launcher", "Temporary SDL joystick subsystem deinitialized."); } // If initialized_by_me is false, we do nothing and leave the main session alone. diff --git a/RetroFE/Source/Execute/Platform/Windows/WindowsProcessManager.cpp b/RetroFE/Source/Execute/Platform/Windows/WindowsProcessManager.cpp index 4ffb130fc..753280a34 100644 --- a/RetroFE/Source/Execute/Platform/Windows/WindowsProcessManager.cpp +++ b/RetroFE/Source/Execute/Platform/Windows/WindowsProcessManager.cpp @@ -21,7 +21,7 @@ #include #include // For GetModuleFileNameExA #include // For CreateToolhelp32Snapshot -#include +#include #include "../../../SDL.h" // For SDL::getActiveWindow #include "../../../Utility/Log.h" diff --git a/RetroFE/Source/Graphics/Component/Container.h b/RetroFE/Source/Graphics/Component/Container.h index caf8649a0..acc9d09aa 100644 --- a/RetroFE/Source/Graphics/Component/Container.h +++ b/RetroFE/Source/Graphics/Component/Container.h @@ -16,7 +16,7 @@ #pragma once #include "Component.h" -#include +#include #include class Container : public Component diff --git a/RetroFE/Source/Graphics/Component/Image.h b/RetroFE/Source/Graphics/Component/Image.h index 49886461f..313e791b9 100644 --- a/RetroFE/Source/Graphics/Component/Image.h +++ b/RetroFE/Source/Graphics/Component/Image.h @@ -18,7 +18,7 @@ #include #include "Component.h" -#include +#include #if __has_include() #include #elif __has_include() diff --git a/RetroFE/Source/Graphics/Component/ReloadableHiscores.h b/RetroFE/Source/Graphics/Component/ReloadableHiscores.h index b698ca1f7..76bc1d116 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableHiscores.h +++ b/RetroFE/Source/Graphics/Component/ReloadableHiscores.h @@ -19,7 +19,7 @@ #include #include -#include +#include #include "Component.h" #include "../../Collection/Item.h" diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.h b/RetroFE/Source/Graphics/Component/ReloadableMedia.h index da9e09b44..578a23e06 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.h +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.h @@ -18,7 +18,7 @@ #include "ReloadableText.h" #include "../../Video/IVideo.h" #include "../../Collection/Item.h" -#include +#include #include class Image; diff --git a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h index 6298cf73d..710ccee62 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h +++ b/RetroFE/Source/Graphics/Component/ReloadableScrollingText.h @@ -16,7 +16,7 @@ #pragma once #include "Component.h" #include "../../Collection/Item.h" -#include +#include #include #include #include diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.h b/RetroFE/Source/Graphics/Component/ReloadableText.h index 28b0877dd..af3b12585 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.h +++ b/RetroFE/Source/Graphics/Component/ReloadableText.h @@ -19,7 +19,7 @@ #include "../Font.h" #include "../Page.h" #include "../../Collection/Item.h" -#include +#include #include #include diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 702bfce5f..058dea7c7 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -23,7 +23,7 @@ #include "../Page.h" #include "../ViewInfo.h" #include "../../Database/Configuration.h" -#include +#include template class RotatableView { diff --git a/RetroFE/Source/Graphics/Component/Text.h b/RetroFE/Source/Graphics/Component/Text.h index 6e64e375b..bc0daa286 100644 --- a/RetroFE/Source/Graphics/Component/Text.h +++ b/RetroFE/Source/Graphics/Component/Text.h @@ -18,7 +18,7 @@ #include "Component.h" #include "../Page.h" -#include +#include #include diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.cpp b/RetroFE/Source/Graphics/Component/VideoComponent.cpp index 015b97002..4a9a64014 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.cpp +++ b/RetroFE/Source/Graphics/Component/VideoComponent.cpp @@ -32,8 +32,8 @@ #include "../../Video/VideoFactory.h" #include "../Page.h" #ifdef __APPLE__ -#include "SDL2/SDL_rect.h" -#include "SDL2/SDL_render.h" +#include "SDL3/SDL_rect.h" +#include "SDL3/SDL_render.h" #else #include "SDL_rect.h" #include "SDL_render.h" diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.h b/RetroFE/Source/Graphics/Component/VideoComponent.h index 3ce9622d4..9cb415969 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.h +++ b/RetroFE/Source/Graphics/Component/VideoComponent.h @@ -20,7 +20,7 @@ #include "../../Collection/Item.h" #include "../../Video/IVideo.h" #include "../../Video/VideoFactory.h" -#include +#include #include #include #include diff --git a/RetroFE/Source/Graphics/Font.cpp b/RetroFE/Source/Graphics/Font.cpp index 5b4519dc5..448c8be6d 100644 --- a/RetroFE/Source/Graphics/Font.cpp +++ b/RetroFE/Source/Graphics/Font.cpp @@ -16,7 +16,7 @@ #include "Font.h" #include "../SDL.h" #include "../Utility/Log.h" -#include +#include #if __has_include() #include #elif __has_include() diff --git a/RetroFE/Source/Graphics/Font.h b/RetroFE/Source/Graphics/Font.h index 184e1ec8f..f9c7ac2af 100644 --- a/RetroFE/Source/Graphics/Font.h +++ b/RetroFE/Source/Graphics/Font.h @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #if __has_include() #include #elif __has_include() diff --git a/RetroFE/Source/Graphics/PageBuilder.h b/RetroFE/Source/Graphics/PageBuilder.h index 6578c9673..3e4b6fe76 100644 --- a/RetroFE/Source/Graphics/PageBuilder.h +++ b/RetroFE/Source/Graphics/PageBuilder.h @@ -17,7 +17,7 @@ #include "Component/Image.h" #include "FontCache.h" -#include +#include #if __has_include() #include #elif __has_include() diff --git a/RetroFE/Source/Menu/Menu.cpp b/RetroFE/Source/Menu/Menu.cpp index 7d05d41de..ba2255f01 100644 --- a/RetroFE/Source/Menu/Menu.cpp +++ b/RetroFE/Source/Menu/Menu.cpp @@ -19,7 +19,7 @@ #include "../Collection/Item.h" #include "../Control/UserInput.h" #include "../Database/Configuration.h" -#include +#include #include diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 412c18f68..ca34181e0 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -66,8 +66,8 @@ #endif #ifdef WIN32 -#include -#include +#include +#include #include #include "StdAfx.h" #endif diff --git a/RetroFE/Source/RetroFE.h b/RetroFE/Source/RetroFE.h index c83d1f325..134bd96ae 100644 --- a/RetroFE/Source/RetroFE.h +++ b/RetroFE/Source/RetroFE.h @@ -26,7 +26,7 @@ #include "Video/VideoFactory.h" #include "Video/GStreamerVideo.h" #include "Sound/MusicPlayer.h" -#include +#include #include "Control/Restrictor/Restrictor.h" #if __has_include() #include diff --git a/RetroFE/Source/SDL.cpp b/RetroFE/Source/SDL.cpp index b34f90a9b..ede4ce540 100644 --- a/RetroFE/Source/SDL.cpp +++ b/RetroFE/Source/SDL.cpp @@ -15,23 +15,23 @@ */ -#include "SDL.h" -#include "Database/Configuration.h" -#include "Database/GlobalOpts.h" -#include "Utility/Log.h" -#if __has_include() -#include -#elif __has_include() -#include -#else -#error "Cannot find SDL_mixer header" -#endif -#include "Utility/Utils.h" - -std::vector SDL::window_; -std::vector SDL::renderer_; -std::vector SDL::renderTargets_; -SDL_mutex* SDL::mutex_ = nullptr; +#include "SDL.h" +#include "Database/Configuration.h" +#include "Database/GlobalOpts.h" +#include "Utility/Log.h" +#if __has_include() +#include +#elif __has_include() +#include +#else +#error "Cannot find SDL_mixer header" +#endif +#include "Utility/Utils.h" + +std::vector SDL::window_; +std::vector SDL::renderer_; +std::vector SDL::renderTargets_; +SDL_Mutex* SDL::mutex_ = nullptr; std::vector SDL::displayWidth_; std::vector SDL::displayHeight_; std::vector SDL::windowWidth_; @@ -59,10 +59,10 @@ bool SDL::initialize(Configuration& config) { LOG_ERROR("SDL", "Unable to set DPI awareness hint"); } #endif - if (SDL_WasInit(0) == 0) { - // First-time startup: Initialize everything. - LOG_INFO("SDL", "Performing first-time full initialization of all SDL subsystems."); - if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS) != 0) + if (SDL_WasInit(0) == 0) { + // First-time startup: Initialize everything. + LOG_INFO("SDL", "Performing first-time full initialization of all SDL subsystems."); + if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMEPAD | SDL_INIT_EVENTS) != 0) { std::string error = SDL_GetError(); LOG_ERROR("SDL", "Initial SDL_Init failed: " + error); @@ -109,8 +109,13 @@ bool SDL::initialize(Configuration& config) { SDL_SetHint(SDL_HINT_RENDER_BATCHING, "0"); // For all renderers - if (config.getProperty(OPTION_HIDEMOUSE, hideMouse)) - SDL_ShowCursor(hideMouse ? SDL_FALSE : SDL_TRUE); + if (config.getProperty(OPTION_HIDEMOUSE, hideMouse)) { + if (hideMouse) { + SDL_HideCursor(); + } else { + SDL_ShowCursor(); + } + } // --- Configuration for hardware/video/audio --- bool HardwareVideoAccel = false; @@ -323,15 +328,15 @@ bool SDL::initialize(Configuration& config) { } fullscreen_.push_back(fullscreen); - if (fullscreen_[logicalScreen]) - { -#ifdef WIN32 - windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; -#elif defined(__APPLE__) - windowFlags |= SDL_WINDOW_BORDERLESS; -#else - windowFlags |= SDL_WINDOW_FULLSCREEN; -#endif + if (fullscreen_[logicalScreen]) + { +#ifdef WIN32 + windowFlags |= SDL_WINDOW_FULLSCREEN; +#elif defined(__APPLE__) + windowFlags |= SDL_WINDOW_BORDERLESS; +#else + windowFlags |= SDL_WINDOW_FULLSCREEN; +#endif } else { @@ -365,11 +370,19 @@ bool SDL::initialize(Configuration& config) { << " on physical display " << physicalDisplay; LOG_INFO("SDL", ss.str()); std::string retrofeTitle = "RetroFE " + std::to_string(physicalDisplay); - if (!window_[logicalScreen]) - { - window_[logicalScreen] = SDL_CreateWindow(retrofeTitle.c_str(), - SDL_WINDOWPOS_CENTERED_DISPLAY(physicalDisplay), SDL_WINDOWPOS_CENTERED_DISPLAY(physicalDisplay), - windowWidth_[logicalScreen], windowHeight_[logicalScreen], windowFlags); + if (!window_[logicalScreen]) + { + window_[logicalScreen] = SDL_CreateWindow(retrofeTitle.c_str(), + windowWidth_[logicalScreen], windowHeight_[logicalScreen], windowFlags); + // Position the window on the correct display + if (window_[logicalScreen]) { + SDL_Rect displayBounds; + if (SDL_GetDisplayBounds(physicalDisplay, &displayBounds) == 0) { + int x = displayBounds.x + (displayBounds.w - windowWidth_[logicalScreen]) / 2; + int y = displayBounds.y + (displayBounds.h - windowHeight_[logicalScreen]) / 2; + SDL_SetWindowPosition(window_[logicalScreen], x, y); + } + } } if (window_[logicalScreen] == NULL) @@ -399,17 +412,18 @@ bool SDL::initialize(Configuration& config) { } bool vSync = false; config.getProperty(OPTION_VSYNC, vSync); - if (!renderer_[logicalScreen]) - { - if (vSync) - { - renderer_[logicalScreen] = SDL_CreateRenderer(window_[logicalScreen], -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); - LOG_INFO("SDL", "vSync Enabled"); - } - else - { - renderer_[logicalScreen] = SDL_CreateRenderer(window_[logicalScreen], -1, SDL_RENDERER_ACCELERATED); - } + if (!renderer_[logicalScreen]) + { + if (vSync) + { + renderer_[logicalScreen] = SDL_CreateRenderer(window_[logicalScreen], NULL); + SDL_SetRenderVSync(renderer_[logicalScreen], 1); + LOG_INFO("SDL", "vSync Enabled"); + } + else + { + renderer_[logicalScreen] = SDL_CreateRenderer(window_[logicalScreen], NULL); + } } if (renderer_[logicalScreen] == NULL) { @@ -579,7 +593,7 @@ bool SDL::deInitialize(bool fullShutdown) { // The 'fullShutdown' parameter is k mirror_.clear(); rotation_.clear(); - SDL_ShowCursor(SDL_TRUE); + SDL_ShowCursor(); return true; } @@ -769,11 +783,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } else { @@ -783,11 +797,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } } @@ -812,7 +826,7 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } @@ -889,11 +903,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } else { @@ -903,11 +917,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -931,7 +945,7 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1004,11 +1018,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } else { @@ -1018,11 +1032,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1046,7 +1060,7 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1119,11 +1133,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } else { @@ -1133,11 +1147,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1161,7 +1175,7 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1234,11 +1248,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } else { @@ -1248,11 +1262,11 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1276,7 +1290,7 @@ bool SDL::renderCopy(SDL_Texture* texture, float alpha, SDL_Rect const* src, SDL } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyEx(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1420,11 +1434,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } else { @@ -1434,11 +1448,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } } @@ -1463,7 +1477,7 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_NONE); } } @@ -1540,11 +1554,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } else { @@ -1554,11 +1568,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1582,7 +1596,7 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1655,11 +1669,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } else { @@ -1669,11 +1683,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1697,7 +1711,7 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_VERTICAL); } } } @@ -1770,11 +1784,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } else { @@ -1784,11 +1798,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1812,7 +1826,7 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1886,11 +1900,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co if (srcRect.h > 0 && srcRect.w > 0) { dstRect.y += windowHeight_[viewInfo.Monitor] / 2; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } else { @@ -1900,11 +1914,11 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co dstRect.y = tmp - dstRect.h / 2 + dstRect.w / 2; angle += 90; SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); dstRect.x = windowWidth_[viewInfo.Monitor] - dstRect.x - dstRect.w; dstRect.y = windowHeight_[viewInfo.Monitor] - dstRect.y - dstRect.h; angle += 180; - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } @@ -1928,7 +1942,7 @@ bool SDL::renderCopyF(SDL_Texture* texture, float alpha, const SDL_Rect* src, co } if (srcRect.h > 0 && srcRect.w > 0) { SDL_SetTextureAlphaMod(texture, static_cast(viewInfo.ReflectionAlpha * alpha * 255)); - SDL_RenderCopyExF(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); + SDL_RenderTextureRotated(renderer_[viewInfo.Monitor], texture, &srcRect, &dstRect, angle, nullptr, SDL_FLIP_HORIZONTAL); } } } diff --git a/RetroFE/Source/SDL.h b/RetroFE/Source/SDL.h index 2c7846a8d..e95339f91 100644 --- a/RetroFE/Source/SDL.h +++ b/RetroFE/Source/SDL.h @@ -16,7 +16,7 @@ #pragma once -#include +#include #include #include "Graphics/ViewInfo.h" #include @@ -32,7 +32,7 @@ class SDL static bool deInitialize(bool fullShutdown = false ); static SDL_Renderer *getRenderer( int index ); static std::string getRendererBackend(int index); - static SDL_mutex *getMutex( ); + static SDL_Mutex *getMutex( ); static SDL_Window *getWindow( int index ); static SDL_Texture* getRenderTarget(int index); static bool renderCopy( SDL_Texture *texture, float alpha, SDL_Rect const *src, SDL_Rect const *dest, ViewInfo &viewInfo, int layoutWidth, int layoutHeight ); @@ -73,7 +73,7 @@ class SDL private: static std::vector window_; static std::vector renderer_; - static SDL_mutex *mutex_; + static SDL_Mutex *mutex_; static std::vector displayWidth_; static std::vector displayHeight_; static std::vector windowWidth_; diff --git a/RetroFE/Source/Sound/MusicPlayer.h b/RetroFE/Source/Sound/MusicPlayer.h index 8a7ab130b..930454668 100644 --- a/RetroFE/Source/Sound/MusicPlayer.h +++ b/RetroFE/Source/Sound/MusicPlayer.h @@ -22,11 +22,11 @@ #include #include #include -#include - -#if __has_include() -#include -#elif __has_include() +#include + +#if __has_include() +#include +#elif __has_include() #include #else #error "Cannot find SDL_mixer header" diff --git a/RetroFE/Source/Video/GStreamerVideo.cpp b/RetroFE/Source/Video/GStreamerVideo.cpp index 04e5c49c3..76288c446 100644 --- a/RetroFE/Source/Video/GStreamerVideo.cpp +++ b/RetroFE/Source/Video/GStreamerVideo.cpp @@ -26,7 +26,7 @@ #include "../SDL.h" #include "../Utility/Log.h" #include "../Utility/Utils.h" -#include +#include #include #include #include diff --git a/RetroFE/Source/Video/IVideo.h b/RetroFE/Source/Video/IVideo.h index ec565256e..d512e884d 100644 --- a/RetroFE/Source/Video/IVideo.h +++ b/RetroFE/Source/Video/IVideo.h @@ -15,7 +15,7 @@ */ #pragma once -#include +#include #include #include