mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-26 18:51:08 +01:00
Compare commits
25 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eef7ca475 | ||
|
|
d126e7bbba | ||
|
|
e5024fae3d | ||
|
|
eb053c7f3f | ||
|
|
ed441c8289 | ||
|
|
59b0a1dc65 | ||
|
|
80d36aba5b | ||
|
|
e1e36d213b | ||
|
|
5c8d92e4d0 | ||
|
|
8a39054b54 | ||
|
|
c60e2704c8 | ||
|
|
a9fdbf7f21 | ||
|
|
ed86b02df8 | ||
|
|
0811b4dc51 | ||
|
|
d9901e0b85 | ||
|
|
0f5752b0fc | ||
|
|
31f77182d0 | ||
|
|
620e875335 | ||
|
|
c18173c260 | ||
|
|
f08f458896 | ||
|
|
53cf48f505 | ||
|
|
c32a1a5023 | ||
|
|
8b204815cc | ||
|
|
a9bb92b3ae | ||
|
|
630272eb55 |
@@ -87,7 +87,7 @@ endif()
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 30)
|
||||
set(SDL_MICRO_VERSION 4)
|
||||
set(SDL_MICRO_VERSION 5)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -1674,7 +1674,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
||||
if(FREEBSD OR NETBSD OR OPENBSD OR BSDI)
|
||||
CheckUSBHID()
|
||||
endif()
|
||||
if(LINUX AND HAVE_LINUX_INPUT_H AND NOT ANDROID)
|
||||
if((LINUX OR FREEBSD) AND HAVE_LINUX_INPUT_H AND NOT ANDROID)
|
||||
set(SDL_JOYSTICK_LINUX 1)
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
|
||||
list(APPEND SOURCE_FILES ${JOYSTICK_SOURCES})
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 4
|
||||
MICRO_VERSION = 5
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 4
|
||||
MICRO_VERSION = 5
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
|
||||
LIBHOME = .
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.30.4</string>
|
||||
<string>2.30.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.30.4</string>
|
||||
<string>2.30.5</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -9729,7 +9729,7 @@
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.4.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.5.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.4;
|
||||
MARKETING_VERSION = 2.30.5;
|
||||
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.4.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.5.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.4;
|
||||
MARKETING_VERSION = 2.30.5;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -10063,7 +10063,7 @@
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.4.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.5.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.4.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.5.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Title SDL 2.30.4
|
||||
Title SDL 2.30.5
|
||||
Version 1
|
||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
||||
@@ -277,6 +277,7 @@ public class HIDDeviceManager {
|
||||
0x044f, // Thrustmaster
|
||||
0x045e, // Microsoft
|
||||
0x0738, // Mad Catz
|
||||
0x0b05, // ASUS
|
||||
0x0e6f, // PDP
|
||||
0x0f0d, // Hori
|
||||
0x10f5, // Turtle Beach
|
||||
@@ -590,7 +591,13 @@ public class HIDDeviceManager {
|
||||
} else {
|
||||
flags = 0;
|
||||
}
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags));
|
||||
if (Build.VERSION.SDK_INT >= 33 /* Android 14.0 (U) */) {
|
||||
Intent intent = new Intent(HIDDeviceManager.ACTION_USB_PERMISSION);
|
||||
intent.setPackage(mContext.getPackageName());
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, intent, flags));
|
||||
} else {
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), flags));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
||||
HIDDeviceOpenResult(deviceID, false);
|
||||
|
||||
@@ -38,6 +38,10 @@ public class SDL {
|
||||
}
|
||||
|
||||
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
|
||||
loadLibrary(libraryName, mContext);
|
||||
}
|
||||
|
||||
public static void loadLibrary(String libraryName, Context context) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
|
||||
|
||||
if (libraryName == null) {
|
||||
throw new NullPointerException("No library name provided.");
|
||||
@@ -53,10 +57,10 @@ public class SDL {
|
||||
// To use ReLinker, just add it as a dependency. For more information, see
|
||||
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
||||
//
|
||||
Class<?> relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
||||
Class<?> relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
||||
Class<?> contextClass = mContext.getClassLoader().loadClass("android.content.Context");
|
||||
Class<?> stringClass = mContext.getClassLoader().loadClass("java.lang.String");
|
||||
Class<?> relinkClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
||||
Class<?> relinkListenerClass = context.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
||||
Class<?> contextClass = context.getClassLoader().loadClass("android.content.Context");
|
||||
Class<?> stringClass = context.getClassLoader().loadClass("java.lang.String");
|
||||
|
||||
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
||||
// they've changed during updates.
|
||||
@@ -66,7 +70,7 @@ public class SDL {
|
||||
|
||||
// Actually load the library!
|
||||
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
|
||||
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
|
||||
loadMethod.invoke(relinkInstance, context, libraryName, null, null);
|
||||
}
|
||||
catch (final Throwable e) {
|
||||
// Fall back
|
||||
|
||||
@@ -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 = 4;
|
||||
private static final int SDL_MICRO_VERSION = 5;
|
||||
/*
|
||||
// Display InputType.SOURCE/CLASS of events and devices
|
||||
//
|
||||
@@ -281,7 +281,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
// Load the .so
|
||||
public void loadLibraries() {
|
||||
for (String lib : getLibraries()) {
|
||||
SDL.loadLibrary(lib);
|
||||
SDL.loadLibrary(lib, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
configure
vendored
2
configure
vendored
@@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=30
|
||||
SDL_MICRO_VERSION=4
|
||||
SDL_MICRO_VERSION=5
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -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=4
|
||||
SDL_MICRO_VERSION=5
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
|
||||
@@ -1424,7 +1424,19 @@ extern "C" {
|
||||
#define SDL_HINT_MOUSE_RELATIVE_WARP_MOTION "SDL_MOUSE_RELATIVE_WARP_MOTION"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether mouse events should generate synthetic touch events
|
||||
* \brief A variable controlling whether the hardware cursor stays visible when relative mode is active.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - The cursor will be hidden while relative mode is active (default)
|
||||
* "1" - The cursor will remain visible while relative mode is active
|
||||
*
|
||||
* Note that for systems without raw hardware inputs, relative mode is implemented using warping, so the hardware cursor will visibly warp between frames if this is enabled on those systems.
|
||||
*/
|
||||
#define SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE "SDL_MOUSE_RELATIVE_CURSOR_VISIBLE"
|
||||
|
||||
/**
|
||||
* A variable controlling whether mouse events should generate synthetic touch
|
||||
* events
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - Mouse events will not generate touch events (default for desktop platforms)
|
||||
|
||||
@@ -790,12 +790,17 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
* **WARNING**: Calling this function may delete all events currently in SDL's
|
||||
* event queue.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns 1 if enabled, 0 if disabled, or a negative error code on failure;
|
||||
* call SDL_GetError() for more information.
|
||||
* While `param` is meant to be one of `SDL_QUERY`, `SDL_IGNORE`, or
|
||||
* `SDL_ENABLE`, this function accepts any value, with any non-zero value that
|
||||
* isn't `SDL_QUERY` being treated as `SDL_ENABLE`.
|
||||
*
|
||||
* If `state` is `SDL_QUERY` then the current state is returned,
|
||||
* otherwise the new processing state is returned.
|
||||
* If SDL was built with events disabled (extremely uncommon!), this will
|
||||
* do nothing and always return `SDL_IGNORE`.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns If `state` is `SDL_QUERY` then the current state is returned,
|
||||
* otherwise `state` is returned (even if it was not one of the
|
||||
* allowed values).
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef struct SDL_version
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 30
|
||||
#define SDL_PATCHLEVEL 4
|
||||
#define SDL_PATCHLEVEL 5
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
||||
@@ -485,7 +485,6 @@ void SDL_Fcitx_PumpEvents(void)
|
||||
|
||||
while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) {
|
||||
/* Do nothing, actual work happens in DBus_MessageFilter */
|
||||
usleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -170,6 +170,13 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha
|
||||
mouse->relative_mode_warp_motion = SDL_GetStringBoolean(hint, SDL_FALSE);
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_MouseRelativeCursorVisibleChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
{
|
||||
SDL_Mouse *mouse = (SDL_Mouse *)userdata;
|
||||
|
||||
mouse->relative_mode_cursor_visible = SDL_GetStringBoolean(hint, SDL_FALSE);
|
||||
}
|
||||
|
||||
/* Public functions */
|
||||
int SDL_MousePreInit(void)
|
||||
{
|
||||
@@ -209,6 +216,9 @@ int SDL_MousePreInit(void)
|
||||
SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION,
|
||||
SDL_MouseRelativeWarpMotionChanged, mouse);
|
||||
|
||||
SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE,
|
||||
SDL_MouseRelativeCursorVisibleChanged, mouse);
|
||||
|
||||
mouse->was_touch_mouse_events = SDL_FALSE; /* no touch to mouse movement event pending */
|
||||
|
||||
mouse->cursor_shown = SDL_TRUE;
|
||||
@@ -992,6 +1002,9 @@ void SDL_MouseQuit(void)
|
||||
|
||||
SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_WARP_MOTION,
|
||||
SDL_MouseRelativeWarpMotionChanged, mouse);
|
||||
|
||||
SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_CURSOR_VISIBLE,
|
||||
SDL_MouseRelativeCursorVisibleChanged, mouse);
|
||||
}
|
||||
|
||||
Uint32 SDL_GetMouseState(int *x, int *y)
|
||||
@@ -1412,7 +1425,7 @@ void SDL_SetCursor(SDL_Cursor *cursor)
|
||||
}
|
||||
}
|
||||
|
||||
if (cursor && mouse->cursor_shown && !mouse->relative_mode) {
|
||||
if (cursor && mouse->cursor_shown && (!mouse->relative_mode || mouse->relative_mode_cursor_visible)) {
|
||||
if (mouse->ShowCursor) {
|
||||
mouse->ShowCursor(cursor);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ typedef struct
|
||||
SDL_bool relative_mode;
|
||||
SDL_bool relative_mode_warp;
|
||||
SDL_bool relative_mode_warp_motion;
|
||||
SDL_bool relative_mode_cursor_visible;
|
||||
SDL_bool enable_normal_speed_scale;
|
||||
float normal_speed_scale;
|
||||
SDL_bool enable_relative_speed_scale;
|
||||
|
||||
@@ -715,6 +715,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de
|
||||
0x044f, /* Thrustmaster */
|
||||
0x045e, /* Microsoft */
|
||||
0x0738, /* Mad Catz */
|
||||
0x0b05, /* ASUS */
|
||||
0x0e6f, /* PDP */
|
||||
0x0f0d, /* Hori */
|
||||
0x10f5, /* Turtle Beach */
|
||||
|
||||
@@ -688,16 +688,14 @@ static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID g
|
||||
/*
|
||||
* Helper function to scan the mappings database for a controller with the specified GUID
|
||||
*/
|
||||
static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_crc, SDL_bool match_version)
|
||||
static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_version)
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
ControllerMapping_t *mapping, *best_match = NULL;
|
||||
Uint16 crc = 0;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
if (match_crc) {
|
||||
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc);
|
||||
}
|
||||
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, NULL, &crc);
|
||||
|
||||
/* Clear the CRC from the GUID for matching, the mappings never include it in the GUID */
|
||||
SDL_SetJoystickGUIDCRC(&guid, 0);
|
||||
@@ -719,20 +717,26 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic
|
||||
}
|
||||
|
||||
if (SDL_memcmp(&guid, &mapping_guid, sizeof(guid)) == 0) {
|
||||
Uint16 mapping_crc = 0;
|
||||
const char *crc_string = SDL_strstr(mapping->mapping, SDL_CONTROLLER_CRC_FIELD);
|
||||
if (crc_string) {
|
||||
Uint16 mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16);
|
||||
|
||||
if (match_crc) {
|
||||
const char *crc_string = SDL_strstr(mapping->mapping, SDL_CONTROLLER_CRC_FIELD);
|
||||
if (crc_string) {
|
||||
mapping_crc = (Uint16)SDL_strtol(crc_string + SDL_CONTROLLER_CRC_FIELD_SIZE, NULL, 16);
|
||||
if (mapping_crc != crc) {
|
||||
/* This mapping specified a CRC and they don't match */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (crc == mapping_crc) {
|
||||
|
||||
/* An exact match, including CRC */
|
||||
return mapping;
|
||||
}
|
||||
|
||||
|
||||
if (!best_match) {
|
||||
best_match = mapping;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return best_match;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -741,19 +745,8 @@ static ControllerMapping_t *SDL_PrivateMatchControllerMappingForGUID(SDL_Joystic
|
||||
static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID guid, SDL_bool adding_mapping)
|
||||
{
|
||||
ControllerMapping_t *mapping;
|
||||
Uint16 vendor, product, crc;
|
||||
|
||||
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, &crc);
|
||||
if (crc) {
|
||||
/* First check for exact CRC matching */
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_TRUE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now check for a mapping without CRC */
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_TRUE);
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
@@ -767,14 +760,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
||||
|
||||
if (SDL_JoystickGUIDUsesVersion(guid)) {
|
||||
/* Try again, ignoring the version */
|
||||
if (crc) {
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_FALSE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
}
|
||||
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE, SDL_FALSE);
|
||||
mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_FALSE);
|
||||
if (mapping) {
|
||||
return mapping;
|
||||
}
|
||||
@@ -1391,9 +1377,6 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const
|
||||
}
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
if (!mapping) {
|
||||
mapping = s_pDefaultMapping;
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@@ -1506,6 +1489,9 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mapping) {
|
||||
mapping = s_pDefaultMapping;
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
@@ -2059,7 +2045,7 @@ SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid
|
||||
|
||||
SDL_LockJoysticks();
|
||||
{
|
||||
if (SDL_PrivateGetControllerMappingForNameAndGUID(name, guid) != NULL) {
|
||||
if (s_pDefaultMapping || SDL_PrivateGetControllerMappingForNameAndGUID(name, guid) != NULL) {
|
||||
retval = SDL_TRUE;
|
||||
} else {
|
||||
retval = SDL_FALSE;
|
||||
|
||||
@@ -2220,7 +2220,7 @@ void SDL_JoystickUpdate(void)
|
||||
int SDL_JoystickEventState(int state)
|
||||
{
|
||||
#ifdef SDL_EVENTS_DISABLED
|
||||
return SDL_DISABLE;
|
||||
return SDL_IGNORE;
|
||||
#else
|
||||
const Uint32 event_list[] = {
|
||||
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
|
||||
@@ -2748,6 +2748,11 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
if (vendor_id == USB_VENDOR_ASUS) {
|
||||
if (product_id == USB_PRODUCT_ROG_RAIKIRI) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char *
|
||||
0x044f, /* Thrustmaster */
|
||||
0x045e, /* Microsoft */
|
||||
0x0738, /* Mad Catz */
|
||||
0x0b05, /* ASUS */
|
||||
0x0e6f, /* PDP */
|
||||
0x0f0d, /* Hori */
|
||||
0x10f5, /* Turtle Beach */
|
||||
|
||||
@@ -47,7 +47,14 @@
|
||||
#define SDL_JOYSTICK_HIDAPI_SHIELD
|
||||
|
||||
/* Whether HIDAPI is enabled by default */
|
||||
#if defined(__ANDROID__) || \
|
||||
defined(__IPHONEOS__) || \
|
||||
defined(__TVOS__)
|
||||
/* On Android, HIDAPI prompts for permissions and acquires exclusive access to the device, and on Apple mobile platforms it doesn't do anything except for handling Bluetooth Steam Controllers, so we'll leave it off by default. */
|
||||
#define SDL_HIDAPI_DEFAULT SDL_FALSE
|
||||
#else
|
||||
#define SDL_HIDAPI_DEFAULT SDL_TRUE
|
||||
#endif
|
||||
|
||||
/* The maximum size of a USB packet for HID devices */
|
||||
#define USB_PACKET_LENGTH 64
|
||||
|
||||
@@ -96,6 +96,9 @@ static int PSP_JoystickInit(void)
|
||||
analog_map[127 - i] = -1 * analog_map[i + 128];
|
||||
}
|
||||
|
||||
/* Fire off a joystick add event */
|
||||
SDL_PrivateJoystickAdded(0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#define USB_VENDOR_AMAZON 0x1949
|
||||
#define USB_VENDOR_APPLE 0x05ac
|
||||
#define USB_VENDOR_ASTRO 0x9886
|
||||
#define USB_VENDOR_ASUS 0x0b05
|
||||
#define USB_VENDOR_BACKBONE 0x358a
|
||||
#define USB_VENDOR_GAMESIR 0x3537
|
||||
#define USB_VENDOR_DRAGONRISE 0x0079
|
||||
@@ -105,6 +106,7 @@
|
||||
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS 0x100c
|
||||
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRED 0x1010
|
||||
#define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRELESS 0x1011
|
||||
#define USB_PRODUCT_ROG_RAIKIRI 0x1a38
|
||||
#define USB_PRODUCT_SAITEK_CYBORG_V3 0xf622
|
||||
#define USB_PRODUCT_SHANWAN_DS3 0x0523
|
||||
#define USB_PRODUCT_SONY_DS3 0x0268
|
||||
|
||||
@@ -458,6 +458,7 @@ void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick)
|
||||
void SDL_XINPUT_JoystickQuit(void)
|
||||
{
|
||||
if (s_bXInputEnabled) {
|
||||
s_bXInputEnabled = SDL_FALSE;
|
||||
WIN_UnloadXInputDLL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,30,4,0
|
||||
PRODUCTVERSION 2,30,4,0
|
||||
FILEVERSION 2,30,5,0
|
||||
PRODUCTVERSION 2,30,5,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
@@ -23,12 +23,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "2, 30, 4, 0\0"
|
||||
VALUE "FileVersion", "2, 30, 5, 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, 4, 0\0"
|
||||
VALUE "ProductVersion", "2, 30, 5, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -65,7 +65,7 @@ void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (co
|
||||
|
||||
/*
|
||||
This code came from Gareth McCaughan, under the zlib license.
|
||||
Specifically this: https://www.mccaughan.org.uk/software/qsort.c-1.15
|
||||
Specifically this: https://www.mccaughan.org.uk/software/qsort.c-1.16
|
||||
|
||||
Everything below this comment until the HAVE_QSORT #endif was from Gareth
|
||||
(any minor changes will be noted inline).
|
||||
@@ -112,7 +112,7 @@ benefit!
|
||||
* Gareth McCaughan
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1998-2016 Gareth McCaughan
|
||||
/* Copyright (c) 1998-2021 Gareth McCaughan
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
@@ -148,17 +148,23 @@ benefit!
|
||||
* (pre-insertion-sort messed up).
|
||||
* Disable DEBUG_QSORT by default.
|
||||
* Tweak comments very slightly.
|
||||
* 2021-02-20 v1.16 Fix bug kindly reported by Ray Gardner
|
||||
* (error in recursion leading to possible
|
||||
* stack overflow).
|
||||
* When checking alignment, avoid casting
|
||||
* pointer to possibly-smaller integer.
|
||||
*/
|
||||
|
||||
/* BEGIN SDL CHANGE ... commented this out with an #if 0 block. --ryan. */
|
||||
#if 0
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#undef DEBUG_QSORT
|
||||
|
||||
static char _ID[]="<qsort.c gjm 1.15 2016-03-10>";
|
||||
static char _ID[]="<qsort.c gjm 1.16 2021-02-20>";
|
||||
#endif
|
||||
/* END SDL CHANGE ... commented this out with an #if 0 block. --ryan. */
|
||||
|
||||
@@ -168,7 +174,8 @@ static char _ID[]="<qsort.c gjm 1.15 2016-03-10>";
|
||||
#define WORD_BYTES sizeof(int)
|
||||
|
||||
/* How big does our stack need to be? Answer: one entry per
|
||||
* bit in a |size_t|.
|
||||
* bit in a |size_t|. (Actually, a bit less because we don't
|
||||
* recurse all the way down to size-1 subarrays.)
|
||||
*/
|
||||
#define STACK_SIZE (8*sizeof(size_t))
|
||||
|
||||
@@ -207,11 +214,12 @@ typedef struct { char * first; char * last; } stack_entry;
|
||||
* on large datasets for locality-of-reference reasons,
|
||||
* but it makes the code much nastier and increases
|
||||
* bookkeeping overhead.
|
||||
* 2. We always save the shorter and get to work on the
|
||||
* longer. This guarantees that every time we push
|
||||
* an item onto the stack its size is <= 1/2 of that
|
||||
* of its parent; so the stack can't need more than
|
||||
* log_2(max-array-size) entries.
|
||||
* 2. We always save the longer and get to work on the
|
||||
* shorter. This guarantees that whenever we push
|
||||
* a k'th entry onto the stack we are about to get
|
||||
* working on something of size <= N/2^k where N is
|
||||
* the original array size; so the stack can't need
|
||||
* more than log_2(max-array-size) entries.
|
||||
* 3. We choose a pivot by looking at the first, last
|
||||
* and middle elements. We arrange them into order
|
||||
* because it's easy to do that in conjunction with
|
||||
@@ -273,8 +281,8 @@ typedef struct { char * first; char * last; } stack_entry;
|
||||
if (r>=Trunc) doRight \
|
||||
else pop \
|
||||
} \
|
||||
else if (l<=r) { pushLeft; doRight } \
|
||||
else if (r>=Trunc) { pushRight; doLeft }\
|
||||
else if (l<=r) { pushRight; doLeft } \
|
||||
else if (r>=Trunc) { pushLeft; doRight }\
|
||||
else doLeft \
|
||||
}
|
||||
|
||||
@@ -526,7 +534,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
|
||||
int (SDLCALL * compare)(const void *, const void *)) {
|
||||
|
||||
if (nmemb<=1) return;
|
||||
if (((size_t)base|size)&(WORD_BYTES-1))
|
||||
if (((uintptr_t)base|size)&(WORD_BYTES-1))
|
||||
qsort_nonaligned(base,nmemb,size,compare);
|
||||
else if (size!=WORD_BYTES)
|
||||
qsort_aligned(base,nmemb,size,compare);
|
||||
|
||||
@@ -120,8 +120,12 @@ SDL_SYS_WaitThread(SDL_Thread *thread)
|
||||
|
||||
try {
|
||||
std::thread *cpp_thread = (std::thread *)thread->handle;
|
||||
if (cpp_thread->joinable()) {
|
||||
cpp_thread->join();
|
||||
if (cpp_thread) {
|
||||
if (cpp_thread->joinable()) {
|
||||
cpp_thread->join();
|
||||
}
|
||||
delete cpp_thread;
|
||||
thread->handle = nullptr;
|
||||
}
|
||||
} catch (std::system_error &) {
|
||||
// An error occurred when joining the thread. SDL_WaitThread does not,
|
||||
@@ -139,8 +143,12 @@ SDL_SYS_DetachThread(SDL_Thread *thread)
|
||||
|
||||
try {
|
||||
std::thread *cpp_thread = (std::thread *)thread->handle;
|
||||
if (cpp_thread->joinable()) {
|
||||
cpp_thread->detach();
|
||||
if (cpp_thread) {
|
||||
if (cpp_thread->joinable()) {
|
||||
cpp_thread->detach();
|
||||
}
|
||||
delete cpp_thread;
|
||||
thread->handle = nullptr;
|
||||
}
|
||||
} catch (std::system_error &) {
|
||||
// An error occurred when detaching the thread. SDL_DetachThread does not,
|
||||
|
||||
@@ -227,26 +227,37 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U
|
||||
|
||||
if (!data) {
|
||||
SDL_Renderer *renderer = NULL;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' &&
|
||||
SDL_strcasecmp(hint, "true") != 0 &&
|
||||
SDL_strcasecmp(hint, "false") != 0 &&
|
||||
SDL_strcasecmp(hint, "software") != 0);
|
||||
const char *render_driver = NULL;
|
||||
const char *hint;
|
||||
|
||||
/* See if there's a render driver being requested */
|
||||
hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint && *hint != '0' && *hint != '1' &&
|
||||
SDL_strcasecmp(hint, "true") != 0 &&
|
||||
SDL_strcasecmp(hint, "false") != 0 &&
|
||||
SDL_strcasecmp(hint, "software") != 0) {
|
||||
render_driver = hint;
|
||||
}
|
||||
|
||||
if (!render_driver) {
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
|
||||
if (hint && *hint && SDL_strcasecmp(hint, "software") != 0) {
|
||||
render_driver = hint;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check to see if there's a specific driver requested */
|
||||
if (specific_accelerated_renderer) {
|
||||
if (render_driver) {
|
||||
for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) {
|
||||
SDL_GetRenderDriverInfo(i, &info);
|
||||
if (SDL_strcasecmp(info.name, hint) == 0) {
|
||||
if (SDL_strcasecmp(info.name, render_driver) == 0) {
|
||||
renderer = SDL_CreateRenderer(window, i, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) {
|
||||
if (renderer) {
|
||||
SDL_DestroyRenderer(renderer);
|
||||
}
|
||||
return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available");
|
||||
if (!renderer) {
|
||||
/* The error for this specific renderer has already been set */
|
||||
return -1;
|
||||
}
|
||||
/* if it was specifically requested, even if SDL_RENDERER_ACCELERATED isn't set, we'll accept this renderer. */
|
||||
} else {
|
||||
@@ -672,9 +683,9 @@ void SDL_DelVideoDisplay(int index)
|
||||
|
||||
SDL_SendDisplayEvent(&_this->displays[index], SDL_DISPLAYEVENT_DISCONNECTED, 0);
|
||||
|
||||
SDL_free(_this->displays[index].driverdata);
|
||||
SDL_free(_this->displays[index].name);
|
||||
if (index < (_this->num_displays - 1)) {
|
||||
SDL_free(_this->displays[index].driverdata);
|
||||
SDL_free(_this->displays[index].name);
|
||||
SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index]));
|
||||
}
|
||||
--_this->num_displays;
|
||||
@@ -1941,12 +1952,6 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags)
|
||||
/* Tear down the old native window */
|
||||
SDL_DestroyWindowSurface(window);
|
||||
|
||||
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
}
|
||||
@@ -2645,6 +2650,55 @@ int SDL_SetWindowFullscreen(SDL_Window *window, Uint32 flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static SDL_bool ShouldAttemptTextureFramebuffer(void)
|
||||
{
|
||||
const char *hint;
|
||||
SDL_bool attempt_texture_framebuffer = SDL_TRUE;
|
||||
|
||||
/* The dummy driver never has GPU support, of course. */
|
||||
if (_this->is_dummy) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* See if there's a hint override */
|
||||
hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint && *hint) {
|
||||
if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0 || SDL_strcasecmp(hint, "software") == 0) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
} else {
|
||||
attempt_texture_framebuffer = SDL_TRUE;
|
||||
}
|
||||
} else {
|
||||
/* Check for platform specific defaults */
|
||||
#if defined(__LINUX__)
|
||||
/* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */
|
||||
if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) {
|
||||
struct stat sb;
|
||||
if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
|
||||
if (_this->CreateWindowFramebuffer && (SDL_strcmp(_this->name, "windows") == 0)) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (attempt_texture_framebuffer) {
|
||||
/* Using a software renderer will try to display on a window surface, so avoid recursion here */
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
|
||||
if (hint && SDL_strcasecmp(hint, "software") == 0) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
return attempt_texture_framebuffer;
|
||||
}
|
||||
|
||||
static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
||||
{
|
||||
Uint32 format = 0;
|
||||
@@ -2661,42 +2715,8 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
||||
using a GPU texture through the 2D render API, if we think this would
|
||||
be more efficient. This only checks once, on demand. */
|
||||
if (!_this->checked_texture_framebuffer) {
|
||||
SDL_bool attempt_texture_framebuffer = SDL_TRUE;
|
||||
|
||||
/* See if the user or application wants to specifically disable the framebuffer */
|
||||
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
|
||||
if (hint) {
|
||||
if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, "software") == 0)) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (_this->is_dummy) { /* dummy driver never has GPU support, of course. */
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
|
||||
#if defined(__LINUX__)
|
||||
/* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */
|
||||
else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) {
|
||||
struct stat sb;
|
||||
if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */
|
||||
else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
else {
|
||||
attempt_texture_framebuffer = SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (attempt_texture_framebuffer) {
|
||||
if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) == -1) {
|
||||
if (ShouldAttemptTextureFramebuffer()) {
|
||||
if (SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch) < 0) {
|
||||
/* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc),
|
||||
!!! FIXME: we probably need to clean this up so it doesn't interfere with
|
||||
!!! FIXME: a software fallback at the system level (can we blit to an
|
||||
@@ -2718,6 +2738,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
||||
|
||||
if (!created_framebuffer) {
|
||||
if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) {
|
||||
SDL_SetError("Window framebuffer support not available");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2727,6 +2748,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
||||
}
|
||||
|
||||
if (window->surface) {
|
||||
/* We may have gone recursive and already created the surface */
|
||||
return window->surface;
|
||||
}
|
||||
|
||||
@@ -2749,7 +2771,12 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
||||
CHECK_WINDOW_MAGIC(window, NULL);
|
||||
|
||||
if (!window->surface_valid) {
|
||||
SDL_DestroyWindowSurface(window);
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
}
|
||||
|
||||
window->surface = SDL_CreateWindowFramebuffer(window);
|
||||
if (window->surface) {
|
||||
window->surface_valid = SDL_TRUE;
|
||||
@@ -2786,6 +2813,25 @@ int SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects,
|
||||
return _this->UpdateWindowFramebuffer(_this, window, rects, numrects);
|
||||
}
|
||||
|
||||
int SDL_DestroyWindowSurface(SDL_Window *window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SetWindowBrightness(SDL_Window * window, float brightness)
|
||||
{
|
||||
Uint16 ramp[256];
|
||||
@@ -2831,19 +2877,6 @@ int SDL_SetWindowOpacity(SDL_Window * window, float opacity)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int SDL_DestroyWindowSurface(SDL_Window *window)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
SDL_FreeSurface(window->surface);
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_GetWindowOpacity(SDL_Window *window, float *out_opacity)
|
||||
{
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
@@ -3282,19 +3315,15 @@ void SDL_DestroyWindow(SDL_Window *window)
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
|
||||
/* make no context current if this is the current context window. */
|
||||
SDL_DestroyWindowSurface(window);
|
||||
|
||||
/* Make no context current if this is the current context window */
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
if (_this->current_glwin == window) {
|
||||
SDL_GL_MakeCurrent(window, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_DestroyWindowSurface(window);
|
||||
if (_this->checked_texture_framebuffer) { /* never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. */
|
||||
if (_this->DestroyWindowFramebuffer) {
|
||||
_this->DestroyWindowFramebuffer(_this, window);
|
||||
}
|
||||
}
|
||||
if (_this->DestroyWindow) {
|
||||
_this->DestroyWindow(_this, window);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,11 @@ SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height,
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
uint32_t *buf_id, uint32_t flags))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width,
|
||||
uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4],
|
||||
const uint32_t pitches[4], const uint32_t offsets[4],
|
||||
const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags))
|
||||
|
||||
SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId))
|
||||
SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf))
|
||||
SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId))
|
||||
@@ -124,6 +129,10 @@ SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf))
|
||||
SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo))
|
||||
|
||||
SDL_KMSDRM_SYM(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane))
|
||||
SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane))
|
||||
|
||||
#undef SDL_KMSDRM_MODULE
|
||||
#undef SDL_KMSDRM_SYM
|
||||
|
||||
@@ -336,8 +336,9 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
{
|
||||
SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata);
|
||||
unsigned w, h;
|
||||
int ret;
|
||||
Uint32 stride, handle;
|
||||
int ret, num_planes = 0;
|
||||
Uint32 format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0;
|
||||
uint64_t modifiers[4] = { 0 };
|
||||
|
||||
/* Check for an existing framebuffer */
|
||||
KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo);
|
||||
@@ -357,20 +358,33 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
|
||||
fb_info->drm_fd = viddata->drm_fd;
|
||||
|
||||
/* Create framebuffer object for the buffer */
|
||||
/* Create framebuffer object for the buffer using the modifiers requested by GBM.
|
||||
Use of the modifiers is necessary on some platforms. */
|
||||
w = KMSDRM_gbm_bo_get_width(bo);
|
||||
h = KMSDRM_gbm_bo_get_height(bo);
|
||||
stride = KMSDRM_gbm_bo_get_stride(bo);
|
||||
handle = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||
ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle,
|
||||
&fb_info->fb_id);
|
||||
format = KMSDRM_gbm_bo_get_format(bo);
|
||||
|
||||
modifiers[0] = KMSDRM_gbm_bo_get_modifier(bo);
|
||||
num_planes = KMSDRM_gbm_bo_get_plane_count(bo);
|
||||
for (int i = 0; i < num_planes; i++) {
|
||||
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
|
||||
handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32;
|
||||
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
|
||||
modifiers[i] = modifiers[0];
|
||||
}
|
||||
|
||||
if (modifiers[0]) {
|
||||
flags = DRM_MODE_FB_MODIFIERS;
|
||||
}
|
||||
|
||||
ret = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags);
|
||||
if (ret) {
|
||||
SDL_free(fb_info);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p",
|
||||
fb_info->fb_id, w, h, stride, (void *)bo);
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, from BO %p",
|
||||
fb_info->fb_id, w, h, (void *)bo);
|
||||
|
||||
/* Associate our DRM framebuffer with this buffer object */
|
||||
KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback);
|
||||
|
||||
@@ -33,6 +33,41 @@
|
||||
#include <gbm.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#ifndef DRM_MODE_FB_MODIFIERS
|
||||
#define DRM_MODE_FB_MODIFIERS 2
|
||||
#endif
|
||||
|
||||
#ifndef DRM_MODE_PAGE_FLIP_ASYNC
|
||||
#define DRM_MODE_PAGE_FLIP_ASYNC 2
|
||||
#endif
|
||||
|
||||
#ifndef DRM_MODE_OBJECT_CONNECTOR
|
||||
#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
|
||||
#endif
|
||||
|
||||
#ifndef DRM_MODE_OBJECT_CRTC
|
||||
#define DRM_MODE_OBJECT_CRTC 0xcccccccc
|
||||
#endif
|
||||
|
||||
#ifndef DRM_CAP_ASYNC_PAGE_FLIP
|
||||
#define DRM_CAP_ASYNC_PAGE_FLIP 7
|
||||
#endif
|
||||
|
||||
#ifndef DRM_CAP_CURSOR_WIDTH
|
||||
#define DRM_CAP_CURSOR_WIDTH 8
|
||||
#endif
|
||||
|
||||
#ifndef DRM_CAP_CURSOR_HEIGHT
|
||||
#define DRM_CAP_CURSOR_HEIGHT 9
|
||||
#endif
|
||||
|
||||
#ifndef GBM_FORMAT_ARGB8888
|
||||
#define GBM_FORMAT_ARGB8888 ((uint32_t)('A') | ((uint32_t)('R') << 8) | ((uint32_t)('2') << 16) | ((uint32_t)('4') << 24))
|
||||
#define GBM_BO_USE_CURSOR (1 << 1)
|
||||
#define GBM_BO_USE_WRITE (1 << 3)
|
||||
#define GBM_BO_USE_LINEAR (1 << 4)
|
||||
#endif
|
||||
|
||||
typedef struct SDL_VideoData
|
||||
{
|
||||
int devindex; /* device index that was passed on creation */
|
||||
|
||||
@@ -751,12 +751,11 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_DelVideoDisplay(i);
|
||||
if (data->xdg_output) {
|
||||
zxdg_output_v1_destroy(data->xdg_output);
|
||||
}
|
||||
wl_output_destroy(data->output);
|
||||
SDL_free(data);
|
||||
SDL_DelVideoDisplay(i);
|
||||
|
||||
/* Update the index for all remaining displays */
|
||||
num_displays -= 1;
|
||||
@@ -1016,9 +1015,6 @@ static void Wayland_VideoCleanup(_THIS)
|
||||
}
|
||||
|
||||
wl_output_destroy(((SDL_WaylandOutputData *)display->driverdata)->output);
|
||||
SDL_free(display->driverdata);
|
||||
display->driverdata = NULL;
|
||||
|
||||
SDL_DelVideoDisplay(i);
|
||||
}
|
||||
data->output_list = NULL;
|
||||
|
||||
@@ -2181,6 +2181,76 @@ int video_setWindowCenteredOnDisplay(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests window surface functionality
|
||||
*/
|
||||
static int video_getWindowSurface(void *arg)
|
||||
{
|
||||
const char *title = "video_getWindowSurface Test Window";
|
||||
SDL_Window *window;
|
||||
SDL_Surface *surface;
|
||||
SDL_Renderer *renderer;
|
||||
Uint32 renderer_flags = SDL_RENDERER_ACCELERATED;
|
||||
int result;
|
||||
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
|
||||
renderer_flags = SDL_RENDERER_SOFTWARE;
|
||||
}
|
||||
|
||||
/* Make sure we're testing interaction with an accelerated renderer */
|
||||
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1");
|
||||
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0);
|
||||
SDLTest_AssertPass("Call to SDL_CreateWindow('%s', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 320, 320, 0)", title);
|
||||
SDLTest_AssertCheck(window != NULL, "Validate that returned window is not NULL");
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
|
||||
SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface");
|
||||
|
||||
result = SDL_UpdateWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_UpdateWindowSurface(window)");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
|
||||
/* We shouldn't be able to create a renderer on a window with a surface */
|
||||
renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
||||
SDLTest_AssertPass("Call to SDL_CreateRenderer(window)");
|
||||
SDLTest_AssertCheck(renderer == NULL, "Validate that returned renderer is NULL");
|
||||
|
||||
result = SDL_DestroyWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_DestroyWindowSurface(window)");
|
||||
SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result);
|
||||
SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface");
|
||||
|
||||
/* We should be able to create a renderer on the window now */
|
||||
renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
||||
SDLTest_AssertPass("Call to SDL_CreateRenderer(window)");
|
||||
SDLTest_AssertCheck(renderer != NULL, "Validate that returned renderer is not NULL");
|
||||
|
||||
/* We should not be able to create a window surface now, unless it was created by the renderer */
|
||||
if (!SDL_HasWindowSurface(window)) {
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface == NULL, "Validate that returned surface is NULL");
|
||||
}
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDLTest_AssertPass("Call to SDL_DestroyRenderer(renderer)");
|
||||
SDLTest_AssertCheck(!SDL_HasWindowSurface(window), "Validate that window does not have a surface");
|
||||
|
||||
/* We should be able to create a window surface again */
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowSurface(window)");
|
||||
SDLTest_AssertCheck(surface != NULL, "Validate that returned surface is not NULL");
|
||||
SDLTest_AssertCheck(SDL_HasWindowSurface(window), "Validate that window has a surface");
|
||||
|
||||
/* Clean up */
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Video test cases */
|
||||
@@ -2265,13 +2335,17 @@ static const SDLTest_TestCaseReference videoTest23 =
|
||||
static const SDLTest_TestCaseReference videoTest24 =
|
||||
{ (SDLTest_TestCaseFp) video_setWindowCenteredOnDisplay, "video_setWindowCenteredOnDisplay", "Checks using SDL_WINDOWPOS_CENTERED_DISPLAY centers the window on a display", TEST_ENABLED };
|
||||
|
||||
static const SDLTest_TestCaseReference videoTest25 = {
|
||||
(SDLTest_TestCaseFp)video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Video test cases */
|
||||
static const SDLTest_TestCaseReference *videoTests[] = {
|
||||
&videoTest1, &videoTest2, &videoTest3, &videoTest4, &videoTest5, &videoTest6,
|
||||
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
|
||||
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
|
||||
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
|
||||
&videoTest23, &videoTest24, NULL
|
||||
&videoTest23, &videoTest24, &videoTest25, NULL
|
||||
};
|
||||
|
||||
/* Video test suite (global) */
|
||||
|
||||
Reference in New Issue
Block a user