Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions RetroFE/Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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}"
Expand All @@ -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}
)
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Control/InputHandler.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <SDL2/SDL.h>
#include <SDL3/SDL.h>

class InputHandler
{
Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Control/JoyAxisHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions RetroFE/Source/Control/JoyButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Control/JoyHatHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions RetroFE/Source/Control/KeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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_];
}
4 changes: 2 additions & 2 deletions RetroFE/Source/Control/MouseButtonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
17 changes: 9 additions & 8 deletions RetroFE/Source/Control/UserInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions RetroFE/Source/Control/UserInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <SDL2/SDL.h>
#include <SDL2/SDL_joystick.h>
#include <SDL3/SDL.h>
#include <SDL3/SDL_joystick.h>
#include <map>
#include <string>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions RetroFE/Source/Execute/Input/InputMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Execute/Input/InputMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <set>
#include <chrono>

#include <SDL2/SDL.h>
#include <SDL3/SDL.h>

#include "SDLJoyStickScopeGuard.h"
#include "../../Database/Configuration.h" // For reading config values
Expand Down
18 changes: 10 additions & 8 deletions RetroFE/Source/Execute/Input/SDLJoyStickScopeGuard.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

// Assuming SDL headers are available via the build system's include paths
#include <SDL2/SDL.h>
#include <SDL3/SDL.h>

// Assuming your logging utility is accessible from this location.
// Adjust the path if necessary based on your project structure.
Expand All @@ -26,26 +26,28 @@ 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.
}
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 {
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <filesystem>
#include <Psapi.h> // For GetModuleFileNameExA
#include <tlhelp32.h> // For CreateToolhelp32Snapshot
#include <SDL2/SDL_syswm.h>
#include <SDL3/SDL_syswm.h>
#include "../../../SDL.h" // For SDL::getActiveWindow

#include "../../../Utility/Log.h"
Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Graphics/Component/Container.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#pragma once

#include "Component.h"
#include <SDL2/SDL.h>
#include <SDL3/SDL.h>
#include <string>

class Container : public Component
Expand Down
2 changes: 1 addition & 1 deletion RetroFE/Source/Graphics/Component/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <string>
#include "Component.h"
#include <SDL2/SDL.h>
#include <SDL3/SDL.h>
#if __has_include(<SDL2/SDL_image.h>)
#include <SDL2/SDL_image.h>
#elif __has_include(<SDL2_image/SDL_image.h>)
Expand Down
Loading