mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-22 00:31:06 +01:00
Compare commits
60 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 | ||
|
|
92fe3b19c8 | ||
|
|
30e2b03a65 | ||
|
|
f8943854fd | ||
|
|
325465935d | ||
|
|
1cdd37b32c | ||
|
|
499bff9c3a | ||
|
|
bd06e43b87 | ||
|
|
72e5620202 | ||
|
|
fbb9646806 | ||
|
|
4b91f0793c | ||
|
|
6243a80b3f | ||
|
|
e0b0a98c8e | ||
|
|
785eac863b | ||
|
|
ab8659922d | ||
|
|
d48f9c4af4 | ||
|
|
5cc0644aa0 | ||
|
|
91accc391d | ||
|
|
3ee20388c5 | ||
|
|
2449510673 | ||
|
|
2c07ed320e | ||
|
|
607f37dafd | ||
|
|
acc2e040ce | ||
|
|
faa9bbdc8e | ||
|
|
cf6c760cd3 | ||
|
|
e49349ac0c | ||
|
|
1e5db996ff | ||
|
|
793a0681a9 | ||
|
|
825ffaa168 | ||
|
|
9ad6a36b7b | ||
|
|
c3b53c72c7 | ||
|
|
0800d81fb4 | ||
|
|
c27219695a | ||
|
|
9dcfc308ef | ||
|
|
77b3a6afaf | ||
|
|
dd42795131 |
@@ -87,7 +87,7 @@ endif()
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 30)
|
||||
set(SDL_MICRO_VERSION 3)
|
||||
set(SDL_MICRO_VERSION 5)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -241,7 +241,7 @@ endif()
|
||||
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
|
||||
set(OPT_DEF_LIBC ON)
|
||||
endif()
|
||||
if(WINDOWS OR IOS OR TVOS)
|
||||
if(WINDOWS OR DARWIN OR MACOSX OR IOS OR TVOS)
|
||||
set(SDL_SYSTEM_ICONV_DEFAULT OFF)
|
||||
else()
|
||||
set(SDL_SYSTEM_ICONV_DEFAULT ON)
|
||||
@@ -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})
|
||||
@@ -1810,13 +1810,11 @@ elseif(WINDOWS)
|
||||
check_include_file(d3d9.h HAVE_D3D_H)
|
||||
check_include_file(d3d11_1.h HAVE_D3D11_H)
|
||||
check_c_source_compiles("
|
||||
#include <winsdkver.h>
|
||||
#include <sdkddkver.h>
|
||||
#include <d3d12.h>
|
||||
#include <d3d12sdklayers.h>
|
||||
ID3D12Device1 *device;
|
||||
#if WDK_NTDDI_VERSION > 0x0A000008
|
||||
int main(int argc, char **argv) { return 0; }
|
||||
#endif" HAVE_D3D12_H)
|
||||
int main(int argc, char **argv) {return 0; }
|
||||
" HAVE_D3D12_H)
|
||||
check_include_file(ddraw.h HAVE_DDRAW_H)
|
||||
check_include_file(dsound.h HAVE_DSOUND_H)
|
||||
check_include_file(dinput.h HAVE_DINPUT_H)
|
||||
|
||||
@@ -52,7 +52,7 @@ WAYLAND_SCANNER_CODE_MODE = @WAYLAND_SCANNER_CODE_MODE@
|
||||
|
||||
INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@
|
||||
|
||||
SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols
|
||||
SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-GDK VisualC-WinRT Xcode Xcode-iOS wayland-protocols
|
||||
GEN_DIST = SDL2.spec
|
||||
|
||||
ifneq ($V,1)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 3
|
||||
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 = 3
|
||||
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.3</string>
|
||||
<string>2.30.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.30.3</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.3.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.3;
|
||||
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.3.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.3;
|
||||
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.3.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.3.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.3
|
||||
Title SDL 2.30.5
|
||||
Version 1
|
||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:allowBackup="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:theme="@style/AppTheme"
|
||||
android:hardwareAccelerated="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
|
||||
@@ -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 = 3;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,8 +995,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
/* No valid hint, nothing is explicitly allowed */
|
||||
if (!is_portrait_allowed && !is_landscape_allowed) {
|
||||
if (resizable) {
|
||||
/* All orientations are allowed */
|
||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
||||
/* All orientations are allowed, respecting user orientation lock setting */
|
||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
|
||||
} else {
|
||||
/* Fixed window and nothing specified. Get orientation from w/h of created window */
|
||||
req = (w > h ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
|
||||
@@ -1005,8 +1005,8 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
/* At least one orientation is allowed */
|
||||
if (resizable) {
|
||||
if (is_portrait_allowed && is_landscape_allowed) {
|
||||
/* hint allows both landscape and portrait, promote to full sensor */
|
||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR;
|
||||
/* hint allows both landscape and portrait, promote to full user */
|
||||
req = ActivityInfo.SCREEN_ORIENTATION_FULL_USER;
|
||||
} else {
|
||||
/* Use the only one allowed "orientation" */
|
||||
req = (is_landscape_allowed ? orientation_landscape : orientation_portrait);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<style name="AppTheme" parent="android:Theme.NoTitleBar.Fullscreen">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
15
configure
vendored
15
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=3
|
||||
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`
|
||||
@@ -18816,7 +18816,7 @@ fi
|
||||
|
||||
enable_system_iconv_default=yes
|
||||
case "$host" in
|
||||
*-*-cygwin*|*-*-mingw*)
|
||||
*-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*)
|
||||
enable_system_iconv_default=no
|
||||
;;
|
||||
esac
|
||||
@@ -27513,18 +27513,14 @@ then :
|
||||
have_d3d11=yes
|
||||
fi
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for d3d12 Windows SDK version" >&5
|
||||
printf %s "checking for d3d12 Windows SDK version... " >&6; }
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compatible d3d12 headers" >&5
|
||||
printf %s "checking for compatible d3d12 headers... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <winsdkver.h>
|
||||
#include <sdkddkver.h>
|
||||
#include <d3d12.h>
|
||||
#include <d3d12sdklayers.h>
|
||||
ID3D12Device1 *device;
|
||||
#if WDK_NTDDI_VERSION <= 0x0A000008
|
||||
asdf
|
||||
#endif
|
||||
|
||||
int
|
||||
main (void)
|
||||
@@ -27543,6 +27539,7 @@ fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5
|
||||
printf "%s\n" "$have_d3d12" >&6; }
|
||||
|
||||
ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_ddraw_h" = xyes
|
||||
then :
|
||||
|
||||
13
configure.ac
13
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=3
|
||||
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`
|
||||
@@ -322,7 +322,7 @@ AC_ARG_ENABLE(libc,
|
||||
dnl See whether we are allowed to use system iconv
|
||||
enable_system_iconv_default=yes
|
||||
case "$host" in
|
||||
*-*-cygwin*|*-*-mingw*)
|
||||
*-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*)
|
||||
enable_system_iconv_default=no
|
||||
;;
|
||||
esac
|
||||
@@ -3343,17 +3343,14 @@ CheckDIRECTX()
|
||||
if test x$enable_directx = xyes; then
|
||||
AC_CHECK_HEADER(d3d9.h, have_d3d=yes)
|
||||
AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes)
|
||||
AC_MSG_CHECKING(for d3d12 Windows SDK version)
|
||||
AC_MSG_CHECKING(for compatible d3d12 headers)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <winsdkver.h>
|
||||
#include <sdkddkver.h>
|
||||
#include <d3d12.h>
|
||||
#include <d3d12sdklayers.h>
|
||||
ID3D12Device1 *device;
|
||||
#if WDK_NTDDI_VERSION <= 0x0A000008
|
||||
asdf
|
||||
#endif
|
||||
]])], [have_d3d12=yes],[have_d3d12=no])
|
||||
AC_MSG_RESULT($have_d3d12)
|
||||
|
||||
AC_CHECK_HEADER(ddraw.h, have_ddraw=yes)
|
||||
AC_CHECK_HEADER(dsound.h, have_dsound=yes)
|
||||
AC_CHECK_HEADER(dinput.h, have_dinput=yes)
|
||||
|
||||
@@ -114,9 +114,6 @@
|
||||
#define HAVE_MEMCPY 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_WCSLEN 1
|
||||
#define HAVE_WCSLCPY 1
|
||||
#define HAVE_WCSLCAT 1
|
||||
#define HAVE_WCSCMP 1
|
||||
#define HAVE__WCSICMP 1
|
||||
#define HAVE__WCSNICMP 1
|
||||
|
||||
@@ -99,9 +99,11 @@ typedef unsigned int uintptr_t;
|
||||
#define HAVE_D3D11_H 1
|
||||
#define HAVE_ROAPI_H 1
|
||||
#endif
|
||||
#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<d3d12.h>) && __has_include(<d3d12sdklayers.h>)
|
||||
#define HAVE_D3D12_H 1
|
||||
#endif
|
||||
#endif
|
||||
#if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */
|
||||
#define HAVE_SHELLSCALINGAPI_H 1
|
||||
#endif
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -73,7 +73,13 @@
|
||||
#if defined(__APPLE__)
|
||||
/* lets us know what version of Mac OS X we're compiling on */
|
||||
#include <AvailabilityMacros.h>
|
||||
#ifndef __has_extension /* Older compilers don't support this */
|
||||
#define __has_extension(x) 0
|
||||
#include <TargetConditionals.h>
|
||||
#undef __has_extension
|
||||
#else
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
/* Fix building with older SDKs that don't define these
|
||||
See this for more information:
|
||||
|
||||
@@ -253,10 +253,10 @@ typedef uint64_t Uint64;
|
||||
* <stdint.h> should define these but this is not true all platforms.
|
||||
* (for example win32) */
|
||||
#ifndef SDL_PRIs64
|
||||
#ifdef PRIs64
|
||||
#define SDL_PRIs64 PRIs64
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#elif defined(PRIs64)
|
||||
#define SDL_PRIs64 PRIs64
|
||||
#elif defined(__LP64__) && !defined(__APPLE__)
|
||||
#define SDL_PRIs64 "ld"
|
||||
#else
|
||||
@@ -264,10 +264,10 @@ typedef uint64_t Uint64;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIu64
|
||||
#ifdef PRIu64
|
||||
#define SDL_PRIu64 PRIu64
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIu64 "I64u"
|
||||
#elif defined(PRIu64)
|
||||
#define SDL_PRIu64 PRIu64
|
||||
#elif defined(__LP64__) && !defined(__APPLE__)
|
||||
#define SDL_PRIu64 "lu"
|
||||
#else
|
||||
@@ -275,10 +275,10 @@ typedef uint64_t Uint64;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIx64
|
||||
#ifdef PRIx64
|
||||
#define SDL_PRIx64 PRIx64
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIx64 "I64x"
|
||||
#elif defined(PRIx64)
|
||||
#define SDL_PRIx64 PRIx64
|
||||
#elif defined(__LP64__) && !defined(__APPLE__)
|
||||
#define SDL_PRIx64 "lx"
|
||||
#else
|
||||
@@ -286,10 +286,10 @@ typedef uint64_t Uint64;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef SDL_PRIX64
|
||||
#ifdef PRIX64
|
||||
#define SDL_PRIX64 PRIX64
|
||||
#elif defined(__WIN32__) || defined(__GDK__)
|
||||
#if defined(__WIN32__) || defined(__GDK__)
|
||||
#define SDL_PRIX64 "I64X"
|
||||
#elif defined(PRIX64)
|
||||
#define SDL_PRIX64 PRIX64
|
||||
#elif defined(__LP64__) && !defined(__APPLE__)
|
||||
#define SDL_PRIX64 "lX"
|
||||
#else
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef struct SDL_version
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 30
|
||||
#define SDL_PATCHLEVEL 3
|
||||
#define SDL_PATCHLEVEL 5
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
||||
@@ -161,6 +161,10 @@ const char *SDL_GetHint(const char *name)
|
||||
const char *env;
|
||||
SDL_Hint *hint;
|
||||
|
||||
if (!name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env = SDL_getenv(name);
|
||||
for (hint = SDL_hints; hint; hint = hint->next) {
|
||||
if (SDL_strcmp(name, hint->name) == 0) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,6 @@
|
||||
#include "../video/SDL_sysvideo.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
#undef SDL_PRIs64
|
||||
#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__)
|
||||
#define SDL_PRIs64 "I64d"
|
||||
#else
|
||||
#define SDL_PRIs64 "lld"
|
||||
#endif
|
||||
|
||||
/* An arbitrary limit so we don't have unbounded growth */
|
||||
#define SDL_MAX_QUEUED_EVENTS 65535
|
||||
|
||||
@@ -454,8 +447,8 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
|
||||
#define PRINT_FINGER_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \
|
||||
(uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \
|
||||
(long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
||||
(uint)event->tfinger.timestamp, event->tfinger.touchId, \
|
||||
event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \
|
||||
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure)
|
||||
SDL_EVENT_CASE(SDL_FINGERDOWN)
|
||||
PRINT_FINGER_EVENT(event);
|
||||
@@ -470,8 +463,8 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
|
||||
#define PRINT_DOLLAR_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \
|
||||
(uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \
|
||||
(long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
||||
(uint)event->dgesture.timestamp, event->dgesture.touchId, \
|
||||
event->dgesture.gestureId, (uint)event->dgesture.numFingers, \
|
||||
event->dgesture.error, event->dgesture.x, event->dgesture.y)
|
||||
SDL_EVENT_CASE(SDL_DOLLARGESTURE)
|
||||
PRINT_DOLLAR_EVENT(event);
|
||||
@@ -483,7 +476,7 @@ static void SDL_LogEvent(const SDL_Event *event)
|
||||
|
||||
SDL_EVENT_CASE(SDL_MULTIGESTURE)
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)",
|
||||
(uint)event->mgesture.timestamp, (long long)event->mgesture.touchId,
|
||||
(uint)event->mgesture.timestamp, event->mgesture.touchId,
|
||||
event->mgesture.dTheta, event->mgesture.dDist,
|
||||
event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers);
|
||||
break;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -877,6 +877,41 @@ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev,
|
||||
#undef make_path
|
||||
#undef read_thread
|
||||
|
||||
/* If the platform has any backend other than libusb, try to avoid using
|
||||
* libusb as the main backend for devices, since it detaches drivers and
|
||||
* therefore makes devices inaccessible to the rest of the OS.
|
||||
*
|
||||
* We do this by whitelisting devices we know to be accessible _exclusively_
|
||||
* via libusb; these are typically devices that look like HIDs but have a
|
||||
* quirk that requires direct access to the hardware.
|
||||
*/
|
||||
static const struct {
|
||||
Uint16 vendor;
|
||||
Uint16 product;
|
||||
} SDL_libusb_whitelist[] = {
|
||||
{ 0x057e, 0x0337 } /* Nintendo WUP-028, Wii U/Switch GameCube Adapter */
|
||||
};
|
||||
|
||||
static SDL_bool
|
||||
IsInWhitelist(Uint16 vendor, Uint16 product)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < SDL_arraysize(SDL_libusb_whitelist); i += 1) {
|
||||
if (vendor == SDL_libusb_whitelist[i].vendor &&
|
||||
product == SDL_libusb_whitelist[i].product) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND
|
||||
static const SDL_bool use_libusb_whitelist_default = SDL_TRUE;
|
||||
#else
|
||||
static const SDL_bool use_libusb_whitelist_default = SDL_FALSE;
|
||||
#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */
|
||||
static SDL_bool use_libusb_whitelist = use_libusb_whitelist_default;
|
||||
|
||||
#endif /* HAVE_LIBUSB */
|
||||
|
||||
#endif /* !SDL_HIDAPI_DISABLED */
|
||||
@@ -1062,6 +1097,8 @@ int SDL_hid_init(void)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBUSB
|
||||
use_libusb_whitelist = SDL_GetHintBoolean("SDL_HIDAPI_LIBUSB_WHITELIST",
|
||||
use_libusb_whitelist_default);
|
||||
if (SDL_getenv("SDL_HIDAPI_DISABLE_LIBUSB") != NULL) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT,
|
||||
"libusb disabled by SDL_HIDAPI_DISABLE_LIBUSB");
|
||||
@@ -1238,6 +1275,16 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
|
||||
SDL_Log("libusb devices found:");
|
||||
#endif
|
||||
for (usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next) {
|
||||
if (use_libusb_whitelist) {
|
||||
if (!IsInWhitelist(usb_dev->vendor_id, usb_dev->product_id)) {
|
||||
#ifdef DEBUG_HIDAPI
|
||||
SDL_Log("Device was not in libusb whitelist: %ls %ls 0x%.4hx 0x%.4hx",
|
||||
usb_dev->manufacturer_string, usb_dev->product_string,
|
||||
usb_dev->vendor_id, usb_dev->product_id);
|
||||
#endif /* DEBUG_HIDAPI */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info));
|
||||
if (new_dev == NULL) {
|
||||
LIBUSB_hid_free_enumeration(usb_devs);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -304,6 +304,7 @@ static const char *s_ControllerMappings[] = {
|
||||
"030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,",
|
||||
"03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
|
||||
"03000000790000000600000000000000,SPEEDLINK STRIKE Gamepad,crc:5811,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,",
|
||||
"03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,",
|
||||
"03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,",
|
||||
"03000000457500002211000000000000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
@@ -771,6 +772,8 @@ static const char *s_ControllerMappings[] = {
|
||||
"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,",
|
||||
"03000000222c00000225000011010000,Qanba Dragon Arcade Joystick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00000025000011010000,Qanba Dragon Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00001020000011010000,Qanba Drone 2 Arcade Joystick (PS5),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00001220000011010000,Qanba Drone 2 Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00000020000011010000,Qanba Drone Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00000223000011010000,Qanba Obsidian Arcade Joystick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
|
||||
"03000000222c00000023000011010000,Qanba Obsidian Arcade Joystick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
|
||||
|
||||
@@ -373,6 +373,7 @@ static Uint32 initial_wheel_devices[] = {
|
||||
MAKE_VIDPID(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */
|
||||
MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */
|
||||
MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */
|
||||
MAKE_VIDPID(0x0483, 0xa355), /* VRS DirectForce Pro Wheel Base */
|
||||
MAKE_VIDPID(0x0eb7, 0x0001), /* Fanatec ClubSport Wheel Base V2 */
|
||||
MAKE_VIDPID(0x0eb7, 0x0004), /* Fanatec ClubSport Wheel Base V2.5 */
|
||||
MAKE_VIDPID(0x0eb7, 0x0005), /* Fanatec CSL Elite Wheel Base+ (PS4) */
|
||||
@@ -385,10 +386,20 @@ static Uint32 initial_wheel_devices[] = {
|
||||
MAKE_VIDPID(0x0eb7, 0x0e03), /* Fanatec CSL Elite Wheel Base */
|
||||
MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */
|
||||
MAKE_VIDPID(0x1209, 0xffb0), /* Generic FFBoard OpenFFBoard universal forcefeedback wheel */
|
||||
MAKE_VIDPID(0x16d0, 0x0d5a), /* Simucube 1 Wheelbase */
|
||||
MAKE_VIDPID(0x16d0, 0x0d5f), /* Simucube 2 Ultimate Wheelbase */
|
||||
MAKE_VIDPID(0x16d0, 0x0d60), /* Simucube 2 Pro Wheelbase */
|
||||
MAKE_VIDPID(0x16d0, 0x0d61), /* Simucube 2 Sport Wheelbase */
|
||||
MAKE_VIDPID(0x2433, 0xf300), /* Asetek SimSports Invicta Wheelbase */
|
||||
MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */
|
||||
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(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0005), /* Moza R3 Wheelbase */
|
||||
MAKE_VIDPID(0x346e, 0x0006), /* Moza R12 Wheelbase */
|
||||
};
|
||||
static SDL_vidpid_list wheel_devices = {
|
||||
SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL,
|
||||
@@ -2209,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,
|
||||
@@ -2737,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x0079, 0x1844 ), k_eControllerType_PS3Controller, NULL }, // From SDL
|
||||
{ MAKE_CONTROLLER_ID( 0x044f, 0xb315 ), k_eControllerType_PS3Controller, NULL }, // Firestorm Dual Analog 3
|
||||
{ MAKE_CONTROLLER_ID( 0x044f, 0xd007 ), k_eControllerType_PS3Controller, NULL }, // Thrustmaster wireless 3-1
|
||||
{ MAKE_CONTROLLER_ID( 0x046d, 0xcad1 ), k_eControllerType_PS3Controller, NULL }, // Logitech Chillstream
|
||||
//{ MAKE_CONTROLLER_ID( 0x046d, 0xc24f ), k_eControllerType_PS3Controller, NULL }, // Logitech G29 (PS3)
|
||||
{ MAKE_CONTROLLER_ID( 0x054c, 0x0268 ), k_eControllerType_PS3Controller, NULL }, // Sony PS3 Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x056e, 0x200f ), k_eControllerType_PS3Controller, NULL }, // From SDL
|
||||
@@ -157,6 +158,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0184 ), k_eControllerType_PS5Controller, NULL }, // Hori Fighting Stick α
|
||||
{ MAKE_CONTROLLER_ID( 0x1532, 0x100b ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wired)
|
||||
{ MAKE_CONTROLLER_ID( 0x1532, 0x100c ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wireless)
|
||||
{ MAKE_CONTROLLER_ID( 0x1532, 0x1012 ), k_eControllerType_PS5Controller, NULL }, // Razer Kitsune
|
||||
{ MAKE_CONTROLLER_ID( 0x3285, 0x0d18 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode with dongle)
|
||||
{ MAKE_CONTROLLER_ID( 0x3285, 0x0d19 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode wired)
|
||||
{ MAKE_CONTROLLER_ID( 0x358a, 0x0104 ), k_eControllerType_PS5Controller, NULL }, // Backbone One PlayStation Edition for iOS
|
||||
@@ -593,7 +595,7 @@ static const ControllerDescription_t arrControllers[] = {
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1102 ), k_eControllerType_SteamController, NULL }, // Valve wired Steam Controller (D0G)
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1105 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G)
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1106 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G)
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x11ff ), k_eControllerType_UnknownNonSteamController, "Steam Virtual Gamepad" }, // Steam virtual gamepad
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x11ff ), k_eControllerType_UnknownNonSteamController, NULL }, // Steam Virtual Gamepad
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1142 ), k_eControllerType_SteamController, NULL }, // Valve wireless Steam Controller
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1201 ), k_eControllerType_SteamControllerV2, NULL }, // Valve wired Steam Controller (HEADCRAB)
|
||||
{ MAKE_CONTROLLER_ID( 0x28de, 0x1202 ), k_eControllerType_SteamControllerV2, NULL }, // Valve Bluetooth Steam Controller (HEADCRAB)
|
||||
|
||||
@@ -584,7 +584,13 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device *
|
||||
Uint8 data[USB_PACKET_LENGTH];
|
||||
int size;
|
||||
|
||||
if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
|
||||
if (vendor_id == USB_VENDOR_LOGITECH &&
|
||||
product_id == USB_PRODUCT_LOGITECH_CHILLSTREAM) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
if ((type == SDL_CONTROLLER_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) ||
|
||||
HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) {
|
||||
if (device && device->dev) {
|
||||
size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data));
|
||||
if (size == 8 && data[2] == 0x26) {
|
||||
@@ -768,7 +774,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic
|
||||
0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */
|
||||
0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */
|
||||
14, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */
|
||||
16, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */
|
||||
15, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */
|
||||
8, /* SDL_GAMEPAD_BUTTON_DPAD_UP */
|
||||
9, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */
|
||||
7, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */
|
||||
@@ -813,48 +819,56 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_bool dpad_up = SDL_FALSE;
|
||||
SDL_bool dpad_down = SDL_FALSE;
|
||||
SDL_bool dpad_left = SDL_FALSE;
|
||||
SDL_bool dpad_right = SDL_FALSE;
|
||||
if (ctx->device->vendor_id == USB_VENDOR_SAITEK && ctx->device->product_id == USB_PRODUCT_SAITEK_CYBORG_V3) {
|
||||
/* Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead */
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, data[10] ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, data[9] ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, data[7] ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, data[8] ? SDL_PRESSED : SDL_RELEASED);
|
||||
} else {
|
||||
if (ctx->last_state[2] != data[2]) {
|
||||
SDL_bool dpad_up = SDL_FALSE;
|
||||
SDL_bool dpad_down = SDL_FALSE;
|
||||
SDL_bool dpad_left = SDL_FALSE;
|
||||
SDL_bool dpad_right = SDL_FALSE;
|
||||
|
||||
switch (data[2] & 0x0f) {
|
||||
case 0:
|
||||
dpad_up = SDL_TRUE;
|
||||
break;
|
||||
case 1:
|
||||
dpad_up = SDL_TRUE;
|
||||
dpad_right = SDL_TRUE;
|
||||
break;
|
||||
case 2:
|
||||
dpad_right = SDL_TRUE;
|
||||
break;
|
||||
case 3:
|
||||
dpad_right = SDL_TRUE;
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 4:
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 5:
|
||||
dpad_left = SDL_TRUE;
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 6:
|
||||
dpad_left = SDL_TRUE;
|
||||
break;
|
||||
case 7:
|
||||
dpad_up = SDL_TRUE;
|
||||
dpad_left = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (data[2] & 0x0f) {
|
||||
case 0:
|
||||
dpad_up = SDL_TRUE;
|
||||
break;
|
||||
case 1:
|
||||
dpad_up = SDL_TRUE;
|
||||
dpad_right = SDL_TRUE;
|
||||
break;
|
||||
case 2:
|
||||
dpad_right = SDL_TRUE;
|
||||
break;
|
||||
case 3:
|
||||
dpad_right = SDL_TRUE;
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 4:
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 5:
|
||||
dpad_left = SDL_TRUE;
|
||||
dpad_down = SDL_TRUE;
|
||||
break;
|
||||
case 6:
|
||||
dpad_left = SDL_TRUE;
|
||||
break;
|
||||
case 7:
|
||||
dpad_up = SDL_TRUE;
|
||||
dpad_left = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right);
|
||||
SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left);
|
||||
}
|
||||
|
||||
axis = ((int)data[17] * 257) - 32768;
|
||||
|
||||
@@ -499,6 +499,12 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
|
||||
ctx->sensors_supported = SDL_TRUE;
|
||||
ctx->touchpad_supported = SDL_TRUE;
|
||||
ctx->use_alternate_report = SDL_TRUE;
|
||||
} else if (device->vendor_id == USB_VENDOR_RAZER &&
|
||||
device->product_id == USB_PRODUCT_RAZER_KITSUNE) {
|
||||
/* The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad */
|
||||
joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK;
|
||||
ctx->touchpad_supported = SDL_TRUE;
|
||||
ctx->use_alternate_report = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported || ctx->playerled_supported);
|
||||
|
||||
@@ -758,7 +758,18 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx)
|
||||
* battery level over Bluetooth anyway.
|
||||
*/
|
||||
if (ctx->device->vendor_id == USB_VENDOR_NINTENDO) {
|
||||
/* However, switching to full controller state breaks DirectInput, so let's not do that */
|
||||
#if 0
|
||||
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
||||
#endif
|
||||
|
||||
/* However, Joy-Con controllers switch their thumbsticks into D-pad mode in simple mode,
|
||||
* so let's enable full controller state for them.
|
||||
*/
|
||||
if (ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT ||
|
||||
ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) {
|
||||
input_mode = k_eSwitchInputReportIDs_FullControllerState;
|
||||
}
|
||||
}
|
||||
return input_mode;
|
||||
}
|
||||
@@ -1292,6 +1303,27 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
|
||||
break;
|
||||
case k_eSwitchDeviceInfoControllerType_Unknown:
|
||||
/* We couldn't read the device info for this controller, might not be fully compliant */
|
||||
if (device->vendor_id == USB_VENDOR_NINTENDO) {
|
||||
switch (device->product_id) {
|
||||
case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT:
|
||||
ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConLeft;
|
||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)");
|
||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT;
|
||||
break;
|
||||
case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT:
|
||||
ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConRight;
|
||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)");
|
||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT;
|
||||
break;
|
||||
case USB_PRODUCT_NINTENDO_SWITCH_PRO:
|
||||
ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_ProController;
|
||||
HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller");
|
||||
device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
default:
|
||||
device->type = SDL_CONTROLLER_TYPE_UNKNOWN;
|
||||
@@ -2211,6 +2243,10 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_SubcommandReply) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->m_bInputOnly) {
|
||||
HandleInputOnlyControllerState(joystick, ctx, (SwitchInputOnlyControllerStatePacket_t *)&ctx->m_rgucReadBuffer[0]);
|
||||
} else {
|
||||
|
||||
@@ -157,16 +157,12 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product)
|
||||
case USB_VENDOR_HORI:
|
||||
return SDL_TRUE;
|
||||
case USB_VENDOR_LOGITECH:
|
||||
/* Most Logitech devices are fine with this, but there are a few exceptions */
|
||||
if (product == USB_PRODUCT_LOGITECH_F310) {
|
||||
/* The Logitech F310 gamepad will lock up */
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (product == 0xc33f) {
|
||||
/* The Logitech G815 keyboard will reset the LEDs */
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_TRUE;
|
||||
/* Most Logitech devices are not PlayStation controllers, and some of them
|
||||
* lock up or reset when we send them the Sony third-party query feature
|
||||
* report, so don't include that vendor here. Instead add devices as
|
||||
* appropriate to controller_list.h
|
||||
*/
|
||||
return SDL_FALSE;
|
||||
case USB_VENDOR_MADCATZ:
|
||||
if (product == USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK) {
|
||||
/* This is not a Playstation compatible device */
|
||||
@@ -187,10 +183,10 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product)
|
||||
case USB_VENDOR_QANBA:
|
||||
return SDL_TRUE;
|
||||
case USB_VENDOR_RAZER:
|
||||
/* Most Razer devices are not game controllers, and some of them lock up
|
||||
* or reset when we send them the Sony third-party query feature report,
|
||||
* so don't include that vendor here. Instead add devices as appropriate
|
||||
* to controller_type.c
|
||||
/* Most Razer devices are not PlayStation controllers, and some of them
|
||||
* lock up or reset when we send them the Sony third-party query feature
|
||||
* report, so don't include that vendor here. Instead add devices as
|
||||
* appropriate to controller_list.h
|
||||
*
|
||||
* Reference: https://github.com/libsdl-org/SDL/issues/6733
|
||||
* https://github.com/libsdl-org/SDL/issues/6799
|
||||
@@ -284,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
|
||||
@@ -47,6 +48,7 @@
|
||||
#define USB_VENDOR_POWERA_ALT 0x20d6
|
||||
#define USB_VENDOR_QANBA 0x2c22
|
||||
#define USB_VENDOR_RAZER 0x1532
|
||||
#define USB_VENDOR_SAITEK 0x06a3
|
||||
#define USB_VENDOR_SHANWAN 0x2563
|
||||
#define USB_VENDOR_SHANWAN_ALT 0x20bc
|
||||
#define USB_VENDOR_SONY 0x054c
|
||||
@@ -90,6 +92,7 @@
|
||||
#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 0x7210
|
||||
#define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104 0x7214
|
||||
#define USB_PRODUCT_RAZER_ATROX 0x0a00
|
||||
#define USB_PRODUCT_RAZER_KITSUNE 0x1012
|
||||
#define USB_PRODUCT_RAZER_PANTHERA 0x0401
|
||||
#define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008
|
||||
#define USB_PRODUCT_RAZER_RAIJU 0x1000
|
||||
@@ -103,6 +106,8 @@
|
||||
#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
|
||||
#define USB_PRODUCT_SONY_DS4 0x05c4
|
||||
|
||||
@@ -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,3,0
|
||||
PRODUCTVERSION 2,30,3,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, 3, 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, 3, 0\0"
|
||||
VALUE "ProductVersion", "2, 30, 5, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <dxgi1_6.h>
|
||||
#include <dxgidebug.h>
|
||||
#include <d3d12sdklayers.h>
|
||||
#include <sdkddkver.h>
|
||||
#endif
|
||||
|
||||
#include "SDL_shaders_d3d12.h"
|
||||
@@ -58,6 +59,11 @@
|
||||
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
|
||||
#endif
|
||||
|
||||
/* DXGI_PRESENT flags are removed on Xbox */
|
||||
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
#define DXGI_PRESENT_ALLOW_TEARING 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define SAFE_RELEASE(X) \
|
||||
if (X) { \
|
||||
@@ -78,6 +84,54 @@
|
||||
#define D3D_GUID(X) &(X)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Older MS Windows SDK headers declare some d3d12 functions with the wrong function prototype.
|
||||
* - ID3D12Heap::GetDesc
|
||||
* - ID3D12Resource::GetDesc
|
||||
* - ID3D12DescriptorHeap::GetDesc
|
||||
* (and 9 more)+
|
||||
* This is fixed in SDKs since WDK_NTDDI_VERSION >= NTDDI_WIN10_FE (0x0A00000A)
|
||||
*/
|
||||
|
||||
#if !(defined(__MINGW32__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) \
|
||||
&& (WDK_NTDDI_VERSION < 0x0A00000A)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_CPU_DESCRIPTOR_HANDLE * Handle) = \
|
||||
(void*)(THIS)->lpVtbl->GetCPUDescriptorHandleForHeapStart; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_GPU_DESCRIPTOR_HANDLE * Handle) = \
|
||||
(void*)(THIS)->lpVtbl->GetGPUDescriptorHandleForHeapStart; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) do { \
|
||||
void (STDMETHODCALLTYPE * func)(ID3D12Resource * This, D3D12_RESOURCE_DESC * Desc) = \
|
||||
(void*)(THIS)->lpVtbl->GetDesc; \
|
||||
func((THIS), ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* MinGW has correct function prototypes in the vtables, but defines wrong functions
|
||||
* Xbox just needs these macros defined as used below (because CINTERFACE doesn't exist)
|
||||
*/
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetCPUDescriptorHandleForHeapStart, ##__VA_ARGS__);
|
||||
|
||||
#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetGPUDescriptorHandleForHeapStart, ##__VA_ARGS__);
|
||||
|
||||
#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) \
|
||||
D3D_CALL_RET(THIS, GetDesc, ##__VA_ARGS__);
|
||||
|
||||
#endif
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -393,10 +447,10 @@ static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *he
|
||||
SIZE_T offset;
|
||||
|
||||
/* Calculate the correct offset into the heap */
|
||||
D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart);
|
||||
offset = CPUHandle.ptr - CPUHeapStart.ptr;
|
||||
|
||||
D3D_CALL_RET(heap, GetGPUDescriptorHandleForHeapStart, &GPUHandle);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle);
|
||||
GPUHandle.ptr += offset;
|
||||
|
||||
return GPUHandle;
|
||||
@@ -427,7 +481,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE D3D12_GetCurrentRenderTargetView(SDL_Renderer
|
||||
}
|
||||
|
||||
SDL_zero(rtvDescriptor);
|
||||
D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
|
||||
rtvDescriptor.ptr += data->currentBackBufferIndex * data->rtvDescriptorSize;
|
||||
return rtvDescriptor;
|
||||
}
|
||||
@@ -1047,7 +1101,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
|
||||
samplerDesc.MinLOD = 0.0f;
|
||||
samplerDesc.MaxLOD = D3D12_FLOAT32_MAX;
|
||||
D3D_CALL_RET(data->samplerDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &data->nearestPixelSampler);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->nearestPixelSampler);
|
||||
D3D_CALL(data->d3dDevice, CreateSampler, &samplerDesc, data->nearestPixelSampler);
|
||||
|
||||
samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
@@ -1336,7 +1390,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
|
||||
SDL_zero(rtvDescriptor);
|
||||
D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor);
|
||||
rtvDescriptor.ptr += i * data->rtvDescriptorSize;
|
||||
D3D_CALL(data->d3dDevice, CreateRenderTargetView, data->renderTargets[i], &rtvDesc, rtvDescriptor);
|
||||
}
|
||||
@@ -1550,7 +1604,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels;
|
||||
|
||||
textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer);
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceView);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView);
|
||||
textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize;
|
||||
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
@@ -1559,7 +1613,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
textureData->mainTextureResourceView);
|
||||
#if SDL_HAVE_YUV
|
||||
if (textureData->yuv) {
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU);
|
||||
textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
@@ -1567,7 +1621,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
&resourceViewDesc,
|
||||
textureData->mainTextureResourceViewU);
|
||||
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewV);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV);
|
||||
textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
@@ -1581,7 +1635,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
|
||||
|
||||
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewNV);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV);
|
||||
textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer);
|
||||
textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize;
|
||||
D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView,
|
||||
@@ -1598,7 +1652,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
renderTargetViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
|
||||
renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
D3D_CALL_RET(rendererData->textureRTVDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureRenderTargetView);
|
||||
D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView);
|
||||
textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize;
|
||||
|
||||
D3D_CALL(rendererData->d3dDevice, CreateRenderTargetView,
|
||||
@@ -1663,7 +1717,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res
|
||||
|
||||
/* Create an upload buffer, which will be used to write to the main texture. */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET(texture, GetDesc, &textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(texture, &textureDesc);
|
||||
textureDesc.Width = w;
|
||||
textureDesc.Height = h;
|
||||
|
||||
@@ -1919,7 +1973,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
/* Create an upload buffer, which will be used to write to the main texture. */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
|
||||
textureDesc.Width = rect->w;
|
||||
textureDesc.Height = rect->h;
|
||||
|
||||
@@ -2028,7 +2082,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D_CALL(textureData->stagingBuffer, Unmap, 0, NULL);
|
||||
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc);
|
||||
textureDesc.Width = textureData->lockedRect.w;
|
||||
textureDesc.Height = textureData->lockedRect.h;
|
||||
|
||||
@@ -2739,7 +2793,7 @@ static int D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
|
||||
/* Create a staging texture to copy the screen's data to: */
|
||||
SDL_zero(textureDesc);
|
||||
D3D_CALL_RET(backBuffer, GetDesc, &textureDesc);
|
||||
D3D_CALL_RET_ID3D12Resource_GetDesc(backBuffer, &textureDesc);
|
||||
textureDesc.Width = rect->w;
|
||||
textureDesc.Height = rect->h;
|
||||
|
||||
|
||||
@@ -822,6 +822,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
switch (retCode) {
|
||||
case SDL_ICONV_E2BIG:
|
||||
{
|
||||
const ptrdiff_t diff = (ptrdiff_t) (outbuf - string);
|
||||
char *oldstring = string;
|
||||
stringsize *= 2;
|
||||
string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32));
|
||||
@@ -830,8 +831,8 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
SDL_iconv_close(cd);
|
||||
return NULL;
|
||||
}
|
||||
outbuf = string + (outbuf - oldstring);
|
||||
outbytesleft = stringsize - (outbuf - string);
|
||||
outbuf = string + diff;
|
||||
outbytesleft = stringsize - diff;
|
||||
SDL_memset(outbuf, 0, sizeof(Uint32));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
#if defined(HAVE_QSORT)
|
||||
void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
|
||||
void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *))
|
||||
{
|
||||
if (!base) {
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void
|
||||
|
||||
/*
|
||||
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 \
|
||||
}
|
||||
|
||||
@@ -368,7 +376,7 @@ typedef struct { char * first; char * last; } stack_entry;
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static char * pivot_big(char *first, char *mid, char *last, size_t size,
|
||||
int compare(const void *, const void *)) {
|
||||
int (SDLCALL * compare)(const void *, const void *)) {
|
||||
size_t d=(((last-first)/size)>>3)*size;
|
||||
#ifdef DEBUG_QSORT
|
||||
fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size));
|
||||
@@ -409,7 +417,7 @@ fprintf(stderr,"-> %d %d %d @ %p %p %p\n",*(int*)m1,*(int*)m2,*(int*)m3, m1,m2,m
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
int (*compare)(const void *, const void *)) {
|
||||
int (SDLCALL * compare)(const void *, const void *)) {
|
||||
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
@@ -440,7 +448,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size,
|
||||
}
|
||||
|
||||
static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
int (*compare)(const void *, const void *)) {
|
||||
int (SDLCALL * compare)(const void *, const void *)) {
|
||||
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
@@ -471,7 +479,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size,
|
||||
}
|
||||
|
||||
static void qsort_words(void *base, size_t nmemb,
|
||||
int (*compare)(const void *, const void *)) {
|
||||
int (SDLCALL * compare)(const void *, const void *)) {
|
||||
|
||||
stack_entry stack[STACK_SIZE];
|
||||
int stacktop=0;
|
||||
@@ -523,10 +531,10 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
extern void qsortG(void *base, size_t nmemb, size_t size,
|
||||
int (*compare)(const void *, const void *)) {
|
||||
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);
|
||||
@@ -536,7 +544,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
|
||||
|
||||
#endif /* HAVE_QSORT */
|
||||
|
||||
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
|
||||
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL * compare)(const void *, const void *))
|
||||
{
|
||||
#if defined(HAVE_BSEARCH)
|
||||
return bsearch(key, base, nmemb, size, compare);
|
||||
@@ -569,4 +577,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size,
|
||||
}
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1373,6 +1373,8 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
|
||||
data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface);
|
||||
xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname);
|
||||
xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data);
|
||||
|
||||
SetMinMaxDimensions(window, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -638,6 +638,10 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
if (nCode < 0 || nCode != HC_ACTION) {
|
||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||
}
|
||||
if (hookData->scanCode == 0x21d) {
|
||||
// Skip fake LCtrl when RAlt is pressed
|
||||
return 1;
|
||||
}
|
||||
|
||||
switch (hookData->vkCode) {
|
||||
case VK_LWIN:
|
||||
@@ -692,6 +696,39 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||
|
||||
|
||||
// Return 1 if spruious LCtrl is pressed
|
||||
// LCtrl is sent when RAltGR is pressed
|
||||
int skip_bad_lcrtl(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MSG next_msg;
|
||||
DWORD msg_time;
|
||||
if (wParam != VK_CONTROL) {
|
||||
return 0;
|
||||
}
|
||||
// Is this an extended key (i.e. right key)?
|
||||
if (lParam & 0x01000000)
|
||||
return 0;
|
||||
|
||||
// Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
|
||||
// want the RALT message, so we try to see if the next message
|
||||
// is a RALT message. In that case, this is a false LCTRL!
|
||||
msg_time = GetMessageTime();
|
||||
if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||
if (next_msg.message == WM_KEYDOWN ||
|
||||
next_msg.message == WM_SYSKEYDOWN) {
|
||||
if (next_msg.wParam == VK_MENU &&
|
||||
(next_msg.lParam & 0x01000000) &&
|
||||
next_msg.time == msg_time) {
|
||||
// Next message is a RALT down message, which
|
||||
// means that this is NOT a proper LCTRL message!
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@@ -1009,6 +1046,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
||||
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
||||
|
||||
if (skip_bad_lcrtl(wParam, lParam)) {
|
||||
returnCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Detect relevant keyboard shortcuts */
|
||||
if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) {
|
||||
/* ALT+F4: Close window */
|
||||
@@ -1031,6 +1073,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
||||
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
||||
|
||||
if (skip_bad_lcrtl(wParam, lParam)) {
|
||||
returnCode = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (code != SDL_SCANCODE_UNKNOWN) {
|
||||
if (code == SDL_SCANCODE_PRINTSCREEN &&
|
||||
keyboardState[code] == SDL_RELEASED) {
|
||||
|
||||
@@ -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