diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bed6ef5db034..28d526abe4391 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 30) -set(SDL_MICRO_VERSION 6) +set(SDL_MICRO_VERSION 7) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts @@ -3555,7 +3555,10 @@ if(SDL_TEST) endif() if(MSVC AND NOT SDL_LIBC) - set(targets SDL2) + set(targets ) + if(TARGET SDL2) + list(APPEND targets SDL2) + endif() if(TARGET SDL2-static) list(APPEND targets SDL2-static) endif() diff --git a/Makefile.os2 b/Makefile.os2 index b99d0f599aa26..ff95021bbd2a2 100644 --- a/Makefile.os2 +++ b/Makefile.os2 @@ -15,7 +15,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 6 +MICRO_VERSION = 7 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 diff --git a/Makefile.w32 b/Makefile.w32 index 31e3438b471cd..076f7954cbeb5 100644 --- a/Makefile.w32 +++ b/Makefile.w32 @@ -6,7 +6,7 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 MINOR_VERSION = 30 -MICRO_VERSION = 6 +MICRO_VERSION = 7 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . diff --git a/Xcode/SDL/Info-Framework.plist b/Xcode/SDL/Info-Framework.plist index 20b5c0ebbb20b..342da0ec7c101 100644 --- a/Xcode/SDL/Info-Framework.plist +++ b/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.30.6 + 2.30.7 CFBundleSignature SDLX CFBundleVersion - 2.30.6 + 2.30.7 diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index ce34a86ed5f86..217add597ca59 100644 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -9729,7 +9729,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.6.0; + DYLIB_CURRENT_VERSION = 3001.7.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9770,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.6; + MARKETING_VERSION = 2.30.7; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9814,7 +9814,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.6.0; + DYLIB_CURRENT_VERSION = 3001.7.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9856,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.30.6; + MARKETING_VERSION = 2.30.7; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -10063,7 +10063,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.6.0; + DYLIB_CURRENT_VERSION = 3001.7.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -10115,7 +10115,7 @@ DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; DYLIB_COMPATIBILITY_VERSION = 3001.0.0; - DYLIB_CURRENT_VERSION = 3001.6.0; + DYLIB_CURRENT_VERSION = 3001.7.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Xcode/SDL/pkg-support/SDL.info b/Xcode/SDL/pkg-support/SDL.info index 9a3789b678e24..0e289444dc1fe 100644 --- a/Xcode/SDL/pkg-support/SDL.info +++ b/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.30.6 +Title SDL 2.30.7 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 976b1c39621d6..2114311f1ff7d 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -61,7 +61,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh private static final String TAG = "SDL"; private static final int SDL_MAJOR_VERSION = 2; private static final int SDL_MINOR_VERSION = 30; - private static final int SDL_MICRO_VERSION = 6; + private static final int SDL_MICRO_VERSION = 7; /* // Display InputType.SOURCE/CLASS of events and devices // diff --git a/configure b/configure index 12713bf9385cc..6d39b056a8869 100755 --- a/configure +++ b/configure @@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=6 +SDL_MICRO_VERSION=7 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/configure.ac b/configure.ac index 9ffae908396d4..7be3b5c3f9499 100644 --- a/configure.ac +++ b/configure.ac @@ -13,7 +13,7 @@ dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=30 -SDL_MICRO_VERSION=6 +SDL_MICRO_VERSION=7 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` diff --git a/include/SDL_version.h b/include/SDL_version.h index 759ce4e95227e..517811f32e3e6 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 30 -#define SDL_PATCHLEVEL 6 +#define SDL_PATCHLEVEL 7 /** * Macro to determine SDL version program was compiled against. diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index bf47ba7110b4d..444bf4af3d5c5 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -36,6 +36,7 @@ #ifdef HAVE_STDIO_H #include +#include #include #endif #ifdef HAVE_LIMITS_H @@ -632,7 +633,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) FILE *fp = fopen(file, mode); #endif if (!fp) { - SDL_SetError("Couldn't open %s", file); + SDL_SetError("Couldn't open %s: %s", file, strerror(errno)); } else if (!IsRegularFileOrPipe(fp)) { fclose(fp); fp = NULL; diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 75c62b187af86..29643ae2e10a7 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -398,6 +398,7 @@ static Uint32 initial_wheel_devices[] = { MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */ + MAKE_VIDPID(0x3416, 0x0302), /* Cammus C12 Wheelbase */ MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */ MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */ MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */ diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h index fd77b2a9d5a1d..79446c5cae7b5 100644 --- a/src/joystick/controller_list.h +++ b/src/joystick/controller_list.h @@ -69,7 +69,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x20d6, 0x576d ), k_eControllerType_PS3Controller, NULL }, // Power A PS3 { MAKE_CONTROLLER_ID( 0x20d6, 0xca6d ), k_eControllerType_PS3Controller, NULL }, // From SDL { MAKE_CONTROLLER_ID( 0x2563, 0x0523 ), k_eControllerType_PS3Controller, NULL }, // Digiflip GP006 - { MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, NULL }, // From SDL + { MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller, "Retro-bit Controller" }, // SWITCH CO., LTD. Retro-bit Controller { MAKE_CONTROLLER_ID( 0x25f0, 0x83c3 ), k_eControllerType_PS3Controller, NULL }, // gioteck vx2 { MAKE_CONTROLLER_ID( 0x25f0, 0xc121 ), k_eControllerType_PS3Controller, NULL }, // { MAKE_CONTROLLER_ID( 0x2c22, 0x2003 ), k_eControllerType_PS3Controller, NULL }, // Qanba Drone diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index 1b10e9ffbad8a..fdc21bb9e24d0 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -50,6 +50,7 @@ typedef struct SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool is_shanwan; + SDL_bool has_analog_buttons; SDL_bool report_sensors; SDL_bool effects_updated; int player_index; @@ -145,6 +146,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) } ctx->device = device; ctx->is_shanwan = is_shanwan; + ctx->has_analog_buttons = SDL_TRUE; device->context = ctx; @@ -247,7 +249,10 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy /* Initialize the joystick capabilities */ joystick->nbuttons = 15; - joystick->naxes = 16; + joystick->naxes = 6; + if (ctx->has_analog_buttons) { + joystick->naxes += 10; + } joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f); @@ -432,7 +437,7 @@ static void HIDAPI_DriverPS3_HandleStatePacket(SDL_Joystick *joystick, SDL_Drive SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); /* Buttons are mapped as axes in the order they appear in the button enumeration */ - { + if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { 24, /* SDL_CONTROLLER_BUTTON_A */ 23, /* SDL_CONTROLLER_BUTTON_B */ @@ -617,6 +622,11 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) return SDL_FALSE; } ctx->device = device; + if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) { + ctx->has_analog_buttons = SDL_FALSE; + } else { + ctx->has_analog_buttons = SDL_TRUE; + } device->context = ctx; @@ -650,8 +660,17 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic /* Initialize the joystick capabilities */ joystick->nbuttons = 15; - joystick->naxes = 16; - joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; + joystick->naxes = 6; + if (ctx->has_analog_buttons) { + joystick->naxes += 10; + } + + if (device->vendor_id == USB_VENDOR_SWITCH && device->product_id == USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER) { + // This is a wireless controller using a USB dongle + joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; + } else { + joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; + } return SDL_TRUE; } @@ -762,7 +781,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); /* Buttons are mapped as axes in the order they appear in the button enumeration */ - { + if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { 12, /* SDL_GAMEPAD_BUTTON_A */ 11, /* SDL_GAMEPAD_BUTTON_B */ @@ -871,9 +890,17 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic } } - axis = ((int)data[17] * 257) - 32768; + if (data[0] & 0x40) { + axis = 32767; + } else { + axis = ((int)data[17] * 257) - 32768; + } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); - axis = ((int)data[18] * 257) - 32768; + if (data[0] & 0x80) { + axis = 32767; + } else { + axis = ((int)data[18] * 257) - 32768; + } SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); axis = ((int)data[3] * 257) - 32768; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); @@ -885,7 +912,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); /* Buttons are mapped as axes in the order they appear in the button enumeration */ - { + if (ctx->has_analog_buttons) { static int button_axis_offsets[] = { 13, /* SDL_CONTROLLER_BUTTON_A */ 12, /* SDL_CONTROLLER_BUTTON_B */ diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index d16605751b47d..8e7a4d63f75e9 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -54,6 +54,7 @@ #define USB_VENDOR_SONY 0x054c #define USB_VENDOR_THRUSTMASTER 0x044f #define USB_VENDOR_TURTLE_BEACH 0x10f5 +#define USB_VENDOR_SWITCH 0x2563 #define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_ZEROPLUS 0x0c12 @@ -116,6 +117,7 @@ #define USB_PRODUCT_SONY_DS4_STRIKEPAD 0x05c5 #define USB_PRODUCT_SONY_DS5 0x0ce6 #define USB_PRODUCT_SONY_DS5_EDGE 0x0df2 +#define USB_PRODUCT_SWITCH_RETROBIT_CONTROLLER 0x0575 #define USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO 0xd012 #define USB_PRODUCT_TURTLE_BEACH_SERIES_X_REACT_R 0x7013 #define USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON 0x7009 diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 2e107082b8704..68627326fd038 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -1290,6 +1290,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) value_caps = SDL_stack_alloc(HIDP_VALUE_CAPS, caps.NumberInputValueCaps); if (SDL_HidP_GetValueCaps(HidP_Input, value_caps, &caps.NumberInputValueCaps, ctx->preparsed_data) != HIDP_STATUS_SUCCESS) { RAWINPUT_JoystickClose(joystick); + SDL_stack_free(button_caps); return SDL_SetError("Couldn't get device value capabilities"); } @@ -1318,6 +1319,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices)); if (!ctx->button_indices) { RAWINPUT_JoystickClose(joystick); + SDL_stack_free(value_caps); + SDL_stack_free(button_caps); return SDL_OutOfMemory(); } @@ -1342,6 +1345,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->nbuttons += 1; } + SDL_stack_free(button_caps); + for (i = 0; i < caps.NumberInputValueCaps; ++i) { HIDP_VALUE_CAPS *cap = &value_caps[i]; @@ -1371,6 +1376,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices)); if (!ctx->axis_indices) { RAWINPUT_JoystickClose(joystick); + SDL_stack_free(value_caps); return SDL_OutOfMemory(); } @@ -1404,6 +1410,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices)); if (!ctx->hat_indices) { RAWINPUT_JoystickClose(joystick); + SDL_stack_free(value_caps); return SDL_OutOfMemory(); } @@ -1422,6 +1429,8 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) } } + SDL_stack_free(value_caps); + joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; return 0; diff --git a/src/main/windows/version.rc b/src/main/windows/version.rc index bd4ee89ade669..455c254f62fab 100644 --- a/src/main/windows/version.rc +++ b/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,30,6,0 - PRODUCTVERSION 2,30,6,0 + FILEVERSION 2,30,7,0 + PRODUCTVERSION 2,30,7,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 30, 6, 0\0" + VALUE "FileVersion", "2, 30, 7, 0\0" VALUE "InternalName", "SDL\0" VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 30, 6, 0\0" + VALUE "ProductVersion", "2, 30, 7, 0\0" END END BLOCK "VarFileInfo" diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 3f57253cd1932..c06faf2ee4289 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -161,7 +161,7 @@ static void SDL_ANDROID_SensorUpdate(SDL_Sensor *sensor) ASensorEvent event; struct android_poll_source *source; - if (ALooper_pollAll(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) { + if (ALooper_pollOnce(0, NULL, &events, (void **)&source) == LOOPER_ID_USER) { SDL_zero(event); while (ASensorEventQueue_getEvents(sensor->hwdata->eventqueue, &event, 1) > 0) { SDL_PrivateSensorUpdate(sensor, 0, event.data, SDL_arraysize(event.data)); diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index b66163ce6eff5..3f26e8d903686 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1529,7 +1529,7 @@ typedef enum typedef struct { - SDL_bool left_justify; /* for now: ignored. */ + SDL_bool left_justify; SDL_bool force_sign; SDL_bool force_type; /* for now: used only by float printer, ignored otherwise. */ SDL_bool pad_zeroes; @@ -1541,6 +1541,9 @@ typedef struct static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string) { + const char fill = (info && info->pad_zeroes) ? '0' : ' '; + size_t width = 0; + size_t filllen = 0; size_t length = 0; size_t slen, sz; @@ -1550,24 +1553,29 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c sz = SDL_strlen(string); if (info && info->width > 0 && (size_t)info->width > sz) { - const char fill = info->pad_zeroes ? '0' : ' '; - size_t width = info->width - sz; - size_t filllen; - + width = info->width - sz; if (info->precision >= 0 && (size_t)info->precision < sz) { width += sz - (size_t)info->precision; } filllen = SDL_min(width, maxlen); - SDL_memset(text, fill, filllen); - text += filllen; - maxlen -= filllen; - length += width; + if (!info->left_justify) { + SDL_memset(text, fill, filllen); + text += filllen; + maxlen -= filllen; + length += width; + filllen = 0; + } } SDL_strlcpy(text, string, maxlen); length += sz; + if (filllen > 0) { + SDL_memset(text + sz, fill, filllen); + length += width; + } + if (info) { if (info->precision >= 0 && (size_t)info->precision < sz) { slen = (size_t)info->precision; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 66fa3f4e0ccf3..35e1d7edd3cd5 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -3303,6 +3303,9 @@ void SDL_DestroyWindow(SDL_Window *window) if (SDL_GetKeyboardFocus() == window) { SDL_SetKeyboardFocus(NULL); } + if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + SDL_UpdateMouseCapture(SDL_TRUE); + } if (SDL_GetMouseFocus() == window) { SDL_SetMouseFocus(NULL); } diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 9b34d68961527..cbf86c9498c54 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -194,7 +194,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) we have waited here, there won't be a pending pageflip so the WaitPageflip at the beginning of this function will be a no-op. Just leave it here and don't worry. - Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 " + Run your SDL2 program with "SDL_VIDEO_DOUBLE_BUFFER=1 " to enable this. */ if (windata->double_buffer) { if (!KMSDRM_WaitPageflip(_this, windata)) { diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index e4457921c46ae..b7abb4fc785f5 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -97,7 +97,7 @@ static int get_driindex(void) SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname, sizeof(device) - kmsdrm_dri_devnamesize); - while((res = readdir(folder)) != NULL) { + while((res = readdir(folder)) != NULL && available < 0) { if (SDL_memcmp(res->d_name, kmsdrm_dri_devname, kmsdrm_dri_devnamesize) == 0) { SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize, @@ -123,7 +123,7 @@ static int get_driindex(void) resources->count_encoders > 0 && resources->count_crtcs > 0) { available = -ENOENT; - for (i = 0; i < resources->count_connectors; i++) { + for (i = 0; i < resources->count_connectors && available < 0; i++) { drmModeConnector *conn = KMSDRM_drmModeGetConnector( drm_fd, resources->connectors[i]); @@ -134,20 +134,21 @@ static int get_driindex(void) if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) { + SDL_bool access_denied = SDL_FALSE; if (SDL_GetHintBoolean( SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER, SDL_TRUE)) { /* Skip this device if we can't obtain * DRM master */ KMSDRM_drmSetMaster(drm_fd); - if (KMSDRM_drmAuthMagic(drm_fd, 0) == - -EACCES) { - continue; + if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) { + access_denied = SDL_TRUE; } } - available = devindex; - break; + if (!access_denied) { + available = devindex; + } } KMSDRM_drmModeFreeConnector(conn); @@ -158,11 +159,10 @@ static int get_driindex(void) SDL_KMSDRM_UnloadSymbols(); } close(drm_fd); + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, + "Failed to open KMSDRM device %s, errno: %d\n", device, errno); } - - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, - "Failed to open KMSDRM device %s, errno: %d\n", device, - errno); } } @@ -380,15 +380,9 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags); if (ret) { - handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32; strides[0] = KMSDRM_gbm_bo_get_stride(bo); - offsets[0] = 0; - for (int i = 1; i<4; i++) { - handles[i] = 0; - strides[i] = 0; - offsets[i] = 0; - } - ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, w, h, format, handles, strides, offsets, &fb_info->fb_id, 0); + handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32; + ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, strides[0], handles[0], &fb_info->fb_id); } if (ret) { @@ -1478,6 +1472,12 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) windata->viddata = viddata; window->driverdata = windata; + /* Do we want a double buffering scheme to get low video lag? */ + windata->double_buffer = SDL_FALSE; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { + windata->double_buffer = SDL_TRUE; + } + if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */ /* Maybe you didn't ask for an OPENGL window, but that's what you will get. @@ -1583,7 +1583,12 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) SDL_SetKeyboardFocus(window); /* Tell the app that the window has moved to top-left. */ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, 0, 0); + { + SDL_Rect display_bounds; + SDL_zero(display_bounds); + SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &display_bounds); + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, display_bounds.x, display_bounds.y); + } /* Allocated windata will be freed in KMSDRM_DestroyWindow, and KMSDRM_DestroyWindow() will be called by SDL_CreateWindow() diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index 07cbedebec2d4..3587822d58798 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -70,8 +70,8 @@ void VITA_InitTouch(void) } // Support passing both front and back touch devices in events - SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front"); - SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back"); + SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Front"); + SDL_AddTouch((SDL_TouchID)2, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back"); } void VITA_QuitTouch(void) diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 9aff010470a74..fada1f76da7ca 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -713,6 +713,7 @@ static void Wayland_WarpMouse(SDL_Window *window, int x, int y) Wayland_input_lock_pointer(input); input->relative_mode_override = SDL_TRUE; } + SDL_SendMouseMotion(window, 0, 0, x, y); } } diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 0938de99f8233..5048cd01bbbe2 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -30,6 +30,7 @@ /* FIXME: Find a better place to put this... */ static Cursor x11_empty_cursor = None; +static SDL_bool x11_cursor_visible = SDL_TRUE; static Display *GetDisplay(void) { @@ -298,6 +299,8 @@ static int X11_ShowCursor(SDL_Cursor *cursor) Display *display = GetDisplay(); SDL_Window *window; + x11_cursor_visible = !!cursor; + for (window = video->windows; window; window = window->next) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data) { @@ -317,12 +320,13 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) { SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata; Display *display = videodata->display; - SDL_Mouse *mouse = SDL_GetMouse(); +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 int deviceid = 0; +#endif SDL_bool warp_hack = SDL_FALSE; /* XWayland will only warp the cursor if it is hidden, so this workaround is required. */ - if (videodata->is_xwayland && mouse && mouse->cursor_shown) { + if (videodata->is_xwayland && x11_cursor_visible) { warp_hack = SDL_TRUE; } @@ -490,5 +494,3 @@ void X11_QuitMouse(_THIS) } #endif /* SDL_VIDEO_DRIVER_X11 */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c index ed9f13ea35d98..969dd39b4810e 100644 --- a/test/testautomation_stdlib.c +++ b/test/testautomation_stdlib.c @@ -62,6 +62,18 @@ int stdlib_snprintf(void *arg) SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result); + result = SDL_snprintf(text, sizeof(text), "%10sA", "foo"); + expected = " fooA"; + SDLTest_AssertPass("Call to SDL_snprintf(\"%%10sA\", \"foo\")"); + SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); + SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result); + + result = SDL_snprintf(text, sizeof(text), "%-10sA", "foo"); + expected = "foo A"; + SDLTest_AssertPass("Call to SDL_snprintf(\"%%-10sA\", \"foo\")"); + SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: %s, got: %s", expected, text); + SDLTest_AssertCheck(result == SDL_strlen(text), "Check result value, expected: %d, got: %d", (int)SDL_strlen(text), result); + result = SDL_snprintf(text, sizeof(text), "%S", L"foo"); expected = "foo"; SDLTest_AssertPass("Call to SDL_snprintf(\"%%S\", \"foo\")");