From fb0f0c5e6c161b4b88439cda84c8b6cae9d236cc Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 01:46:42 -0600 Subject: [PATCH 1/6] cmake: Use MAME YM2612 emu in GME --- thirdparty/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 8fa47ba3a..6480e6720 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -521,6 +521,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") OPTIONS "BUILD_SHARED_LIBS ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}" "ENABLE_UBSAN OFF" + "GME_YM2612_EMU MAME" ) target_compile_features(gme PRIVATE cxx_std_11) target_link_libraries(gme PRIVATE ZLIB::ZLIB) From fcf69001ada08077f82d3fc8510dcd24b4433e64 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 01:53:23 -0600 Subject: [PATCH 2/6] cmake: Fix png and openmpt builds in clean envs In environments without zlib installed, png would fail to build since it can't find zlib.h. The zlib build's generated public include dir needs zlib.h to work. openmpt fails to build because it can't find Rpcrt4, which is not a necessary link under mingw, but exists in some mingw-w64 toolchains. It is only needed for MSVC. --- thirdparty/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 6480e6720..7aff16601 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -91,6 +91,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") configure_file("${ZLIB_SOURCE_DIR}/zlib.pc.cmakein" "${ZLIB_BINARY_DIR}/zlib.pc" @ONLY) configure_file("${ZLIB_SOURCE_DIR}/zconf.h.cmakein" "${ZLIB_BINARY_DIR}/include/zconf.h" @ONLY) + configure_file("${ZLIB_SOURCE_DIR}/zlib.h" "${ZLIB_BINARY_DIR}/include/zlib.h" @ONLY) add_library(ZLIB ${SRB2_INTERNAL_LIBRARY_TYPE} ${ZLIB_SRCS}) set_target_properties(ZLIB PROPERTIES @@ -173,8 +174,8 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") target_include_directories(png PUBLIC "${png_BINARY_DIR}/include") # ... and these also need to be present only for png build - target_include_directories(png PRIVATE "${zlib_SOURCE_DIR}") - target_include_directories(png PRIVATE "${zlib_BINARY_DIR}") + target_include_directories(png PRIVATE "${ZLIB_SOURCE_DIR}") + target_include_directories(png PRIVATE "${ZLIB_BINARY_DIR}") target_include_directories(png PRIVATE "${png_BINARY_DIR}") target_link_libraries(png PRIVATE ZLIB::ZLIB) @@ -495,7 +496,7 @@ if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") if("${CMAKE_C_COMPILER_ID}" STREQUAL GNU OR "${CMAKE_C_COMPILER_ID}" STREQUAL Clang OR "${CMAKE_C_COMPILER_ID}" STREQUAL AppleClang) target_compile_options(openmpt PRIVATE "-g0") endif() - if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows) + if("${CMAKE_SYSTEM_NAME}" STREQUAL Windows AND "${CMAKE_C_COMPILER_ID}" STREQUAL MSVC) target_link_libraries(openmpt PRIVATE Rpcrt4) endif() target_compile_features(openmpt PRIVATE cxx_std_11) From ec58b1504d28513ae4a972b4d2a32bfed01dec4a Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 02:19:05 -0600 Subject: [PATCH 3/6] sdl: SDL version-guard controller type and hidapi --- src/sdl/i_gamepad.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c index dbafc1f63..28f9681be 100644 --- a/src/sdl/i_gamepad.c +++ b/src/sdl/i_gamepad.c @@ -39,8 +39,10 @@ static boolean InitGamepadSubsystems(void) { if (M_CheckParm("-noxinput")) SDL_SetHintWithPriority(SDL_HINT_XINPUT_ENABLED, "0", SDL_HINT_OVERRIDE); +#if SDL_VERSION_ATLEAST(2,0,9) if (M_CheckParm("-nohidapi")) SDL_SetHintWithPriority(SDL_HINT_JOYSTICK_HIDAPI, "0", SDL_HINT_OVERRIDE); +#endif if (SDL_WasInit(GAMEPAD_INIT_FLAGS) == 0) { @@ -199,6 +201,7 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) CONS_Debug(DBG_GAMELOGIC, M_GetText("Controller %d: %s\n"), which, SDL_GameControllerName(controller->dev)); +#if SDL_VERSION_ATLEAST(2,0,12) #define GAMEPAD_TYPE_CASE(ctrl) \ case SDL_CONTROLLER_TYPE_##ctrl: \ controller->info->type = GAMEPAD_TYPE_##ctrl; \ @@ -211,15 +214,22 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) GAMEPAD_TYPE_CASE(XBOXONE); GAMEPAD_TYPE_CASE(PS3); GAMEPAD_TYPE_CASE(PS4); +#if SDL_VERSION_ATLEAST(2,0,14) GAMEPAD_TYPE_CASE(PS5); +#endif GAMEPAD_TYPE_CASE(NINTENDO_SWITCH_PRO); +#if SDL_VERSION_ATLEAST(2,0,16) GAMEPAD_TYPE_CASE(GOOGLE_STADIA); GAMEPAD_TYPE_CASE(AMAZON_LUNA); +#endif GAMEPAD_TYPE_CASE(VIRTUAL); default: break; } - #undef GAMEPAD_BUTTON_CASE +#else + // Under older versions of SDL, we aren't provided controller type information. + controller->info->type = GAMEPAD_TYPE_UNKNOWN; +#endif // SDL_VERSION_ATLEAST(2,0,12) // Check the device vendor and product to find out what controller this actually is Uint16 vendor = SDL_JoystickGetDeviceVendor(devindex); From f5f224136ba6d8db1319eb091c9b9877173d8e55 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 02:34:33 -0600 Subject: [PATCH 4/6] sdl: Version-guard rumble and extended buttons --- src/sdl/i_gamepad.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c index 28f9681be..109d37d4a 100644 --- a/src/sdl/i_gamepad.c +++ b/src/sdl/i_gamepad.c @@ -231,6 +231,7 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) controller->info->type = GAMEPAD_TYPE_UNKNOWN; #endif // SDL_VERSION_ATLEAST(2,0,12) +#if SDL_VERSION_ATLEAST(2,0,6) // Check the device vendor and product to find out what controller this actually is Uint16 vendor = SDL_JoystickGetDeviceVendor(devindex); Uint16 product = SDL_JoystickGetDeviceProduct(devindex); @@ -239,13 +240,17 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) controller->info->type = GAMEPAD_TYPE_XBOX_SERIES_XS; else if (IsJoystickXboxOneElite(vendor, product)) controller->info->type = GAMEPAD_TYPE_XBOX_ELITE; +#endif CONS_Debug(DBG_GAMELOGIC, M_GetText(" Type: %s\n"), G_GamepadTypeToString(controller->info->type)); +#if SDL_VERSION_ATLEAST(2,0,12) // Change the ring LEDs on Xbox 360 controllers // FIXME: Doesn't seem to work? SDL_GameControllerSetPlayerIndex(controller->dev, which); +#endif +#if SDL_VERSION_ATLEAST(2,0,18) // Check if rumble is supported if (SDL_GameControllerHasRumble(controller->dev) == SDL_TRUE) { @@ -255,8 +260,12 @@ static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) else { controller->info->rumble.supported = false; - CONS_Debug(DBG_GAMELOGIC, M_GetText(" Rumble supported: No\n"));; + CONS_Debug(DBG_GAMELOGIC, M_GetText(" Rumble supported: No\n")); } +#else + controller->info->rumble.supported = true; + CONS_Debug(DBG_GAMELOGIC, M_GetText(" Rumble supported: Maybe\n")); +#endif // SDL_VERSION_ATLEAST(2,0,18) if (!controller->info->connected) { @@ -600,12 +609,14 @@ void I_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type) GAMEPAD_BUTTON_CASE(DPAD_DOWN); GAMEPAD_BUTTON_CASE(DPAD_LEFT); GAMEPAD_BUTTON_CASE(DPAD_RIGHT); +#if SDL_VERSION_ATLEAST(2,0,14) GAMEPAD_BUTTON_CASE(MISC1); GAMEPAD_BUTTON_CASE(PADDLE1); GAMEPAD_BUTTON_CASE(PADDLE2); GAMEPAD_BUTTON_CASE(PADDLE3); GAMEPAD_BUTTON_CASE(PADDLE4); GAMEPAD_BUTTON_CASE(TOUCHPAD); +#endif default: return; } @@ -663,8 +674,10 @@ static void Controller_StopRumble(UINT8 num) gamepad->rumble.data.small_magnitude = 0; gamepad->rumble.data.duration = 0; +#if SDL_VERSION_ATLEAST(2,0,9) if (gamepad->rumble.supported) SDL_GameControllerRumble(controller->dev, 0, 0, 0); +#endif } static void Controller_Close(UINT8 num) From df28ffd72eb168bf392db7cf88a4c58218fe2923 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 02:42:14 -0600 Subject: [PATCH 5/6] sdl: Yet more SDL rumble version-guards --- src/sdl/i_gamepad.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c index 109d37d4a..b2b50e43d 100644 --- a/src/sdl/i_gamepad.c +++ b/src/sdl/i_gamepad.c @@ -66,7 +66,11 @@ void I_InitGamepads(void) if (!InitGamepadSubsystems()) return; +#if SDL_VERSION_ATLEAST(2,0,9) rumble_supported = !M_CheckParm("-norumble"); +#else + rumble_supported = false; +#endif for (UINT8 i = 0; i < NUM_GAMEPADS; i++) controllers[i].info = &gamepads[i]; @@ -727,14 +731,20 @@ boolean I_RumbleSupported(void) static boolean Controller_Rumble(ControllerInfo *c) { +#if SDL_VERSION_ATLEAST(2,0,9) if (SDL_GameControllerRumble(c->dev, c->rumble.large_magnitude, c->rumble.small_magnitude, 0) == -1) return false; return true; +#else + (void)c; + return false; +#endif } void I_ToggleControllerRumble(boolean unpause) { +#if SDL_VERSION_ATLEAST(2,0,9) if (!I_RumbleSupported() || rumble_paused == !unpause) return; @@ -754,6 +764,10 @@ void I_ToggleControllerRumble(boolean unpause) controller->rumble.expiration = controller->rumble.time_left = 0; } } +#else + (void)unpause; + return; +#endif } void I_UpdateControllers(void) From fdb6f2aff93e91cfc1dac24804c912d8b0dc31e6 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 10 Dec 2022 02:47:53 -0600 Subject: [PATCH 6/6] sdl: I can't believe it's more version-guards --- src/sdl/i_gamepad.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c index b2b50e43d..ecde251fb 100644 --- a/src/sdl/i_gamepad.c +++ b/src/sdl/i_gamepad.c @@ -103,6 +103,7 @@ INT32 I_NumGamepads(void) #define USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2 0x4001 #define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA 0x4002 +#if SDL_VERSION_ATLEAST(2,0,6) static boolean IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id) { if (vendor_id == USB_VENDOR_MICROSOFT) { @@ -141,6 +142,7 @@ static boolean IsJoystickXboxSeriesXS(Uint16 vendor_id, Uint16 product_id) return false; } +#endif // Opens a controller device static boolean Controller_OpenDevice(UINT8 which, INT32 devindex) @@ -885,6 +887,7 @@ boolean I_SetGamepadSmallMotorFreq(UINT8 which, fixed_t freq) void I_SetGamepadRumblePaused(UINT8 which, boolean pause) { +#if SDL_VERSION_ATLEAST(2,0,9) if (!I_RumbleSupported() || which >= NUM_GAMEPADS) return; @@ -915,6 +918,11 @@ void I_SetGamepadRumblePaused(UINT8 which, boolean pause) } controller->info->rumble.paused = pause; +#else + (void)which; + (void)pause; + return; +#endif } boolean I_GetGamepadRumbleSupported(UINT8 which)