Compare commits

..

24 Commits

Author SHA1 Message Date
Sam Lantinga
c98c4fbff6 Updated to version 2.30.9 for release 2024-11-01 14:24:51 -07:00
Sam Lantinga
4d4f004968 Fixed the PS5 controller face buttons on Amazon Fire TV, Android 11
(cherry picked from commit 09495059df)
(cherry picked from commit 3b7a45853c)
2024-10-30 05:24:08 -07:00
Sam Lantinga
5d7a023430 Revert "aaudio: Set low-latency audio mode."
This reverts commit 1e016fd5ea.

In order to use low latency mode, you need to set low latency callbacks. This has always been recommended and is apparently required on Android 15. SDL3 has these implemented correctly but SDL2 does not, so we should revert this for now.

Fixes https://github.com/libsdl-org/SDL/issues/11376

(cherry picked from commit d2b9ecd281)
2024-10-29 22:36:54 -07:00
dv-senna
3e272e73d6 SDL_vulkan.h: undefine VK_DEFINE_HANDLER and VK_DEFINE_NON_DISPATCHABLE_HANDLE
Allows including vulkan.hpp in user code in C++ before SDL_vulkan.h w/o errors.
Fixes:  https://github.com/libsdl-org/SDL/issues/11328 .

(cherry picked from commit 149ecffd6f)
(cherry picked from commit 478dff3585)
2024-10-29 22:36:24 -07:00
Ryan C. Gordon
cc2352f842 wasapi: Deal with device buffer sizes changing.
Otherwise, it would fill the previous size's worth of data into the current
size's buffer.

Fixes #11122.

(cherry picked from commit 5b0e838a74)
2024-10-29 22:36:19 -07:00
Ryan C. Gordon
f170ced2a7 cocoa: Patched to compile.
(cherry picked from commit e5348c611d)
2024-10-25 10:23:36 -04:00
Ryan C. Gordon
dcdb763de8 cocoa: Make sure GL context destruction happens on the main thread.
Fixes #10900.

(cherry picked from commit 5cb87ff99f)
2024-10-25 10:17:47 -04:00
Ryan C. Gordon
5c9f37080e emscripten: scale mousewheel X coordinates correctly, not just Y coordinates.
Fixes #10454.

(cherry picked from commit 00f15dd215)
2024-10-23 23:41:10 -04:00
Ivan Epifanov
257d75429d VITA: fix SDL_ShowMessageBox by using different memory type
(cherry picked from commit 52714d5063)
2024-10-22 12:22:20 -07:00
Frank Praznik
c1adfb4c94 wayland: Always create a viewport for the window if available
Viewports decouple the buffer from the window size and avoids the window geometry hacks used to prevent problems if a buffer with an old size in the pipeline ends up being committed.

Fixes an invalid geometry warning and incorrect overview size for fullscreen windows on GNOME, and avoids flicker when entering/exiting fullscreen or moving the window between scaled and non-scaled displays.

(cherry picked from commit 849c905d8c)
2024-10-21 15:22:24 -04:00
Ivan Epifanov
217bc17a21 VITA: fix yuv texture update
(cherry picked from commit 86fd4ed83c)
2024-10-17 07:54:41 -07:00
Sam Lantinga
7107e02315 Only use Steam Virtual Gamepads if we're running under Steam
Fixes https://github.com/libsdl-org/SDL/issues/11214
Fixes https://github.com/libsdl-org/SDL/issues/11215

(cherry picked from commit 8a30def5f2)
(cherry picked from commit b6fa4dc794)
2024-10-16 17:53:01 -07:00
Sam Lantinga
062a777240 Added support for the Steam Virtual Gamepad on macOS Sequoia
(cherry picked from commit d7b1ba1bfc)
(cherry picked from commit cfb3db01dc)
2024-10-16 17:53:01 -07:00
Pierre Wendling
1842745c9c VisualC: Set the correct component to false.
When SDL2_main would not be found, it would incorrectly flag the shared SDL2 library as not found.

(cherry picked from commit 378234437f)
2024-10-13 09:03:22 -07:00
Cameron Cawley
bbcc9421d6 3DS: Support simple message boxes
(cherry picked from commit 23d456e146)
2024-10-13 09:03:22 -07:00
Cameron Cawley
b58a1c7f33 3DS: Only bundle resources with tests that need them
(cherry picked from commit d7bb56f163)
2024-10-13 09:03:22 -07:00
Cameron Cawley
79a8f7b3a0 Reduce the size of the SDL_blit_0 alpha code
(cherry picked from commit 90f792f83c)
2024-10-13 09:03:22 -07:00
Cameron Cawley
302ab09178 testdrawchessboard: Allow using the standard render API
(cherry picked from commit e2f27362cb)
2024-10-13 09:03:22 -07:00
Guldoman
e1e38e2250 x11: Set correct clipboard target type in SelectionRequest handling
(cherry picked from commit 5fe010270a)
2024-10-13 09:02:49 -07:00
Sam Lantinga
2638809c50 Fixed typo in SDL_audio.h
(cherry picked from commit da4608ed03)
2024-10-10 08:50:19 -07:00
Sam Clegg
36853f923e [emscripten] Fixes for data addresses above 2gb
This includes both wasm64 and wasm32 when addressing more than 2gb of
memory.

Fixes: #9052
(cherry picked from commit 3deb07ea39)
2024-10-08 15:17:44 -07:00
Sam Lantinga
63aff8e3d0 Added support for wired XBox controllers on macOS 15.0 Sequoia
Fixes https://github.com/libsdl-org/SDL/issues/11002

(cherry picked from commit 7da728a642)
(cherry picked from commit da19244f7f)
2024-10-07 16:41:47 -07:00
Sam Lantinga
7eebc2ad4d Fixed detecting the Steam Virtual Gamepad on macOS
(cherry picked from commit bb33eb409e)
2024-10-07 16:22:03 -07:00
Frank Praznik
0f695adb03 Reapply "wayland: Don't initialize OpenGL when the window flags didn't specify it"
This reverts commit 120b8d4189.

The issue this was patching over in Vanilla-Conquer was the lack of an exposure event when showing a window, which has since been remedied.

Attaching EGL window objects can also cause protocol violations now that the explicit sync protocol is in use, if SDL creates one and then the client tries to attach one itself, so they really shouldn't be created unless the client specifically requested it.

(cherry picked from commit 643437f5b0)
2024-10-02 13:52:59 -04:00
43 changed files with 221 additions and 246 deletions

View File

@@ -87,7 +87,7 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 30)
set(SDL_MICRO_VERSION 8)
set(SDL_MICRO_VERSION 9)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts

View File

@@ -15,7 +15,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
MICRO_VERSION = 8
MICRO_VERSION = 9
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2

View File

@@ -6,7 +6,7 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 30
MICRO_VERSION = 8
MICRO_VERSION = 9
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .

View File

@@ -94,7 +94,7 @@ if(EXISTS "${_sdl2main_library}")
endif()
set(SDL2_SDL2main_FOUND TRUE)
else()
set(SDL2_SDL2_FOUND FALSE)
set(SDL2_SDL2main_FOUND FALSE)
endif()
unset(_sdl2main_library)

View File

@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.30.8</string>
<string>2.30.9</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.30.8</string>
<string>2.30.9</string>
</dict>
</plist>

View File

@@ -9729,7 +9729,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
DYLIB_CURRENT_VERSION = 3001.8.0;
DYLIB_CURRENT_VERSION = 3001.9.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.8;
MARKETING_VERSION = 2.30.9;
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.8.0;
DYLIB_CURRENT_VERSION = 3001.9.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.8;
MARKETING_VERSION = 2.30.9;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10063,7 +10063,7 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
DYLIB_CURRENT_VERSION = 3001.8.0;
DYLIB_CURRENT_VERSION = 3001.9.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.8.0;
DYLIB_CURRENT_VERSION = 3001.9.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;

View File

@@ -1,4 +1,4 @@
Title SDL 2.30.8
Title SDL 2.30.9
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks

View File

@@ -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 = 8;
private static final int SDL_MICRO_VERSION = 9;
/*
// Display InputType.SOURCE/CLASS of events and devices
//

2
configure vendored
View File

@@ -3508,7 +3508,7 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=30
SDL_MICRO_VERSION=8
SDL_MICRO_VERSION=9
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -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=8
SDL_MICRO_VERSION=9
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`

View File

@@ -594,7 +594,7 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* frames_ (with stereo output, two samples--left and right--would make a
* single sample frame). This number should be a power of two, and may be
* adjusted by the audio driver to a value more suitable for the hardware.
* Good values seem to range between 512 and 8096 inclusive, depending on
* Good values seem to range between 512 and 4096 inclusive, depending on
* the application and CPU speed. Smaller values reduce latency, but can
* lead to underflow if the application is doing heavy processing and cannot
* fill the audio buffer in time. Note that the number of sample frames is

View File

@@ -257,7 +257,7 @@ typedef uint64_t Uint64;
#define SDL_PRIs64 "I64d"
#elif defined(PRIs64)
#define SDL_PRIs64 PRIs64
#elif defined(__LP64__) && !defined(__APPLE__)
#elif defined(__LP64__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#define SDL_PRIs64 "ld"
#else
#define SDL_PRIs64 "lld"

View File

@@ -59,7 +59,7 @@ typedef struct SDL_version
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 30
#define SDL_PATCHLEVEL 8
#define SDL_PATCHLEVEL 9
/**
* Macro to determine SDL version program was compiled against.

View File

@@ -52,6 +52,10 @@ extern "C" {
VK_DEFINE_HANDLE(VkInstance)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
/* Make sure to undef to avoid issues in case of later vulkan include */
#undef VK_DEFINE_HANDLE
#undef VK_DEFINE_NON_DISPATCHABLE_HANDLE
#endif /* !NO_SDL_VULKAN_TYPEDEFS */
typedef VkInstance SDL_vulkanInstance;

View File

@@ -292,7 +292,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
break;
}
}
#elif defined(HAVE_STDIO_H)
#elif defined(HAVE_STDIO_H) && !defined(__3DS__)
/* this is a little hacky. */
for (;;) {
char buf[32];
@@ -319,6 +319,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
break;
}
}
#else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Assertion Failed", message, window);
#endif /* HAVE_STDIO_H */
}

View File

@@ -116,7 +116,6 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
}
ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, private);
ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u",
this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format),
@@ -239,7 +238,6 @@ static int RebuildAAudioStream(SDL_AudioDevice *device)
}
ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, hidden);
ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY);
LOGI("AAudio Try to reopen %u hz %u bit chan %u %s samples %u",
device->spec.freq, SDL_AUDIO_BITSIZE(device->spec.format),

View File

@@ -32,7 +32,7 @@ SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder * builder, aa
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder * builder, aaudio_sharing_mode_t sharingMode))
SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder * builder, aaudio_direction_t direction))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder * builder, int32_t numFrames))
SDL_PROC(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder * builder, aaudio_performance_mode_t mode))
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder * builder, aaudio_usage_t usage)) /* API 28 */
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder * builder, aaudio_content_type_t contentType)) /* API 28 */
SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder * builder, aaudio_input_preset_t inputPreset)) /* API 28 */

View File

@@ -39,6 +39,12 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
/* *INDENT-OFF* */ /* clang-format off */
MAIN_THREAD_EM_ASM({
var SDL2 = Module['SDL2'];
/* Convert incoming buf pointer to a HEAPF32 offset. */
#ifdef __wasm64__
var buf = $0 / 4;
#else
var buf = $0 >>> 2;
#endif
var numChannels = SDL2.audio.currentOutputBuffer['numberOfChannels'];
for (var c = 0; c < numChannels; ++c) {
var channelData = SDL2.audio.currentOutputBuffer['getChannelData'](c);
@@ -47,7 +53,7 @@ static void FeedAudioDevice(_THIS, const void *buf, const int buflen)
}
for (var j = 0; j < $1; ++j) {
channelData[j] = HEAPF32[$0 + ((j*numChannels + c) << 2) >> 2]; /* !!! FIXME: why are these shifts here? */
channelData[j] = HEAPF32[buf + (j*numChannels + c)];
}
}
}, buf, buflen / framelen);

View File

@@ -111,6 +111,12 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
}
}
/* if the device sample size changed, make sure we're asking for enough data. */
if (this->callbackspec.samples != this->spec.samples) {
this->callbackspec.samples = this->spec.samples;
SDL_CalculateAudioSpec(&this->callbackspec);
}
/* make sure our scratch buffer can cover the new device spec. */
if (this->spec.size > this->work_buffer_len) {
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);

View File

@@ -2123,28 +2123,10 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
return SDL_TRUE;
}
if (SDL_allowed_controllers.num_included_entries == 0 &&
SDL_ignored_controllers.num_included_entries == 0) {
return SDL_FALSE;
}
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL);
if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) {
/* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */
/* https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices */
SDL_bool bSteamVirtualGamepad = SDL_FALSE;
#if defined(__LINUX__)
bSteamVirtualGamepad = (vendor == USB_VENDOR_VALVE && product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD);
#elif defined(__MACOSX__)
bSteamVirtualGamepad = (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 1);
#elif defined(__WIN32__)
/* We can't tell on Windows, but Steam will block others in input hooks */
bSteamVirtualGamepad = SDL_TRUE;
#endif
if (bSteamVirtualGamepad) {
return SDL_FALSE;
}
if (SDL_IsJoystickSteamVirtualGamepad(vendor, product, version)) {
return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE);
}
if (SDL_allowed_controllers.num_included_entries > 0) {

View File

@@ -773,8 +773,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,",
"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,",
"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,",
@@ -925,7 +925,7 @@ static const char *s_ControllerMappings[] = {
"050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000004c050000cc090000fffe3f80,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b0,y:b2,",
"050000004c050000cc090000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000004c050000e60c0000fffe3f80,PS5 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b0,y:b2,",
"050000004c050000e60c0000fffe3f80,PS5 Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a3,rightx:a4,righty:a5,start:b16,x:b2,y:b17,",
"050000004c050000e60c0000ffff3f00,PS5 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"05000000f8270000bf0b0000ffff3f00,Razer Kishi,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
"050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",

View File

@@ -2843,6 +2843,15 @@ SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product
return vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR;
}
SDL_bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version)
{
#ifdef __MACOSX__
return (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 0);
#else
return (vendor_id == USB_VENDOR_VALVE && product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD);
#endif
}
SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
{
EControllerType eType = GuessControllerType(vendor_id, product_id);

View File

@@ -123,6 +123,9 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id);
extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick is a Steam Virtual Gamepad */
extern SDL_bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version);
/* Function to return whether a joystick is a Steam Controller */
extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);

View File

@@ -477,6 +477,11 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
}
if (SDL_IsJoystickXboxOne(vendor, product)) {
/* We can't actually use this API for Xbox controllers */
return false;
}
/* get device name */
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey));
if ((!refCF) || (!CFStringGetCString(refCF, manufacturer_string, sizeof(manufacturer_string), kCFStringEncodingUTF8))) {

View File

@@ -84,21 +84,16 @@ static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(SDL_HIDAPI_Device *device
/* This is the chatpad or other input interface, not the Xbox 360 interface */
return SDL_FALSE;
}
#ifdef __MACOSX__
if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER && version == 1) {
/* This is the Steam Virtual Gamepad, which isn't supported by this driver */
#if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI)
if (SDL_IsJoystickSteamVirtualGamepad(vendor_id, product_id, version)) {
/* GCController support doesn't work with the Steam Virtual Gamepad */
return SDL_TRUE;
} else {
/* On macOS you can't write output reports to wired XBox controllers,
so we'll just use the GCController support instead.
*/
return SDL_FALSE;
}
/* Wired Xbox One controllers are handled by this driver, interfacing with
the 360Controller driver available from:
https://github.com/360Controller/360Controller/releases
Bluetooth Xbox One controllers are handled by the SDL Xbox One driver
*/
if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
return SDL_FALSE;
}
return (type == SDL_CONTROLLER_TYPE_XBOX360 || type == SDL_CONTROLLER_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE;
#else
return (type == SDL_CONTROLLER_TYPE_XBOX360) ? SDL_TRUE : SDL_FALSE;
#endif
@@ -153,6 +148,13 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device)
device->type = SDL_CONTROLLER_TYPE_XBOX360;
if (SDL_IsJoystickSteamVirtualGamepad(device->vendor_id, device->product_id, device->version) &&
device->product_string && SDL_strncmp(device->product_string, "GamePad-", 8) == 0) {
int slot = 0;
SDL_sscanf(device->product_string, "GamePad-%d", &slot);
device->steam_virtual_gamepad_slot = (slot - 1);
}
return HIDAPI_JoystickConnected(device, NULL);
}
@@ -201,30 +203,6 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL
static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
#ifdef __MACOSX__
if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) {
Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 };
rumble_packet[4] = (low_frequency_rumble >> 8);
rumble_packet[5] = (high_frequency_rumble >> 8);
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
} else {
/* On Mac OS X the 360Controller driver uses this short report,
and we need to prefix it with a magic token so hidapi passes it through untouched
*/
Uint8 rumble_packet[] = { 'M', 'A', 'G', 'I', 'C', '0', 0x00, 0x04, 0x00, 0x00 };
rumble_packet[6 + 2] = (low_frequency_rumble >> 8);
rumble_packet[6 + 3] = (high_frequency_rumble >> 8);
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
}
#else
Uint8 rumble_packet[] = { 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
rumble_packet[3] = (low_frequency_rumble >> 8);
@@ -233,7 +211,6 @@ static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Jo
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
}
#endif
return 0;
}

View File

@@ -354,9 +354,12 @@ static SDL_bool HIDAPI_DriverXboxOne_IsEnabled(void)
static SDL_bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
{
#ifdef __MACOSX__
/* Wired Xbox One controllers are handled by the 360Controller driver */
#if defined(__MACOSX__) && defined(SDL_JOYSTICK_MFI)
if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
/* On macOS we get a shortened version of the real report and
you can't write output reports for wired controllers, so
we'll just use the GCController support instead.
*/
return SDL_FALSE;
}
#endif

View File

@@ -929,6 +929,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->manufacturer_string, device->product_string, 'h', 0);
device->joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER;
device->type = SDL_GetJoystickGameControllerProtocol(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol);
device->steam_virtual_gamepad_slot = -1;
if (num_children > 0) {
int i;
@@ -1380,6 +1381,12 @@ static const char *HIDAPI_JoystickGetDevicePath(int device_index)
static int HIDAPI_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index)
{
SDL_HIDAPI_Device *device;
device = HIDAPI_GetDeviceByIndex(device_index, NULL);
if (device) {
return device->steam_virtual_gamepad_slot;
}
return -1;
}

View File

@@ -83,6 +83,7 @@ typedef struct _SDL_HIDAPI_Device
SDL_bool is_bluetooth;
SDL_JoystickType joystick_type;
SDL_GameControllerType type;
int steam_virtual_gamepad_slot;
struct _SDL_HIDAPI_DeviceDriver *driver;
void *context;

View File

@@ -406,7 +406,8 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
device->is_switch_joyconL = IsControllerSwitchJoyConL(controller);
device->is_switch_joyconR = IsControllerSwitchJoyConR(controller);
#ifdef SDL_JOYSTICK_HIDAPI
if ((device->is_xbox && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE)) ||
if ((device->is_xbox && (HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE) ||
HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOX360))) ||
(device->is_ps4 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS4)) ||
(device->is_ps5 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS5)) ||
(device->is_switch_pro && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO)) ||
@@ -418,6 +419,10 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
return FALSE;
}
#endif
if (device->is_xbox && SDL_strncmp(name, "GamePad-", 8) == 0) {
/* This is a Steam Virtual Gamepad, which isn't supported by GCController */
return FALSE;
}
CheckControllerSiriRemote(controller, &device->is_siri_remote);
if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) {
@@ -437,7 +442,7 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
device->has_xbox_share_button = TRUE;
}
}
#endif // ENABLE_PHYSICAL_INPUT_PROFILE
#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */
if (device->is_backbone_one) {
vendor = USB_VENDOR_BACKBONE;

View File

@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,30,8,0
PRODUCTVERSION 2,30,8,0
FILEVERSION 2,30,9,0
PRODUCTVERSION 2,30,9,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 30, 8, 0\0"
VALUE "FileVersion", "2, 30, 9, 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, 8, 0\0"
VALUE "ProductVersion", "2, 30, 9, 0\0"
END
END
BLOCK "VarFileInfo"

View File

@@ -366,6 +366,7 @@ static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
length = rect->w * SDL_BYTESPERPIXEL(texture->format);
if (length == pitch && length == dpitch) {
SDL_memcpy(dst, pixels, length * rect->h);
pixels += pitch * rect->h;
} else {
for (row = 0; row < rect->h; ++row) {
SDL_memcpy(dst, pixels, length);
@@ -393,6 +394,7 @@ static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
// U plane
if (length == uv_src_pitch && length == uv_pitch) {
SDL_memcpy(Udst, pixels, length * UVrect.h);
pixels += uv_src_pitch * UVrect.h;
} else {
for (row = 0; row < UVrect.h; ++row) {
SDL_memcpy(Udst, pixels, length);

View File

@@ -31,6 +31,8 @@ void *vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignmen
if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) {
size = ALIGN(size, 256 * 1024);
} else if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW) {
size = ALIGN(size, 1024 * 1024);
} else {
size = ALIGN(size, 4 * 1024);
}

View File

@@ -1162,7 +1162,7 @@ void gxm_init_for_common_dialog(void)
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) {
buffer_for_common_dialog[i].displayData.wait_vblank = SDL_TRUE;
buffer_for_common_dialog[i].displayData.address = vita_mem_alloc(
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
SCE_KERNEL_MEMBLOCK_TYPE_USER_MAIN_PHYCONT_NC_RW,
4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT,
SCE_GXM_COLOR_SURFACE_ALIGNMENT,
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,

View File

@@ -605,11 +605,8 @@ SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp)
}
}
SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
static void BlitBtoNAlpha(SDL_BlitInfo *info)
{
const Uint32 mask = (1 << srcbpp) - 1;
const Uint32 align = (8 / srcbpp) - 1;
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
@@ -617,15 +614,17 @@ SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
const SDL_Color *srcpal = info->src_fmt->palette->colors;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp;
int srcbpp, dstbpp;
int c;
Uint32 pixel;
Uint32 pixel, mask, align;
unsigned sR, sG, sB;
unsigned dR, dG, dB, dA;
const unsigned A = info->a;
/* Set up some basic variables */
srcbpp = srcfmt->BytesPerPixel;
dstbpp = dstfmt->BytesPerPixel;
if (srcbpp == 4)
srcskip += width - (width + 1) / 2;
@@ -633,6 +632,8 @@ SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
srcskip += width - (width + 3) / 4;
else if (srcbpp == 1)
srcskip += width - (width + 7) / 8;
mask = (1 << srcbpp) - 1;
align = (8 / srcbpp) - 1;
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
while (height--) {
@@ -681,11 +682,8 @@ SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
}
}
SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp)
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
{
const Uint32 mask = (1 << srcbpp) - 1;
const Uint32 align = (8 / srcbpp) - 1;
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
@@ -695,15 +693,16 @@ SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp)
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
const SDL_Color *srcpal = srcfmt->palette->colors;
int dstbpp;
int srcbpp, dstbpp;
int c;
Uint32 pixel;
Uint32 pixel, mask, align;
unsigned sR, sG, sB;
unsigned dR, dG, dB, dA;
const unsigned A = info->a;
Uint32 ckey = info->colorkey;
/* Set up some basic variables */
srcbpp = srcfmt->BytesPerPixel;
dstbpp = dstfmt->BytesPerPixel;
if (srcbpp == 4)
srcskip += width - (width + 1) / 2;
@@ -711,6 +710,8 @@ SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp)
srcskip += width - (width + 3) / 4;
else if (srcbpp == 1)
srcskip += width - (width + 7) / 8;
mask = (1 << srcbpp) - 1;
align = (8 / srcbpp) - 1;
if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) {
while (height--) {
@@ -801,16 +802,6 @@ static const SDL_BlitFunc colorkey_blit_1b[] = {
(SDL_BlitFunc)NULL, Blit1bto1Key, Blit1bto2Key, Blit1bto3Key, Blit1bto4Key
};
static void Blit1btoNAlpha(SDL_BlitInfo *info)
{
BlitBtoNAlpha(info, 1);
}
static void Blit1btoNAlphaKey(SDL_BlitInfo *info)
{
BlitBtoNAlphaKey(info, 1);
}
static void Blit2bto1(SDL_BlitInfo *info) {
@@ -853,16 +844,6 @@ static const SDL_BlitFunc colorkey_blit_2b[] = {
(SDL_BlitFunc)NULL, Blit2bto1Key, Blit2bto2Key, Blit2bto3Key, Blit2bto4Key
};
static void Blit2btoNAlpha(SDL_BlitInfo *info)
{
BlitBtoNAlpha(info, 2);
}
static void Blit2btoNAlphaKey(SDL_BlitInfo *info)
{
BlitBtoNAlphaKey(info, 2);
}
static void Blit4bto1(SDL_BlitInfo *info) {
@@ -905,16 +886,6 @@ static const SDL_BlitFunc colorkey_blit_4b[] = {
(SDL_BlitFunc)NULL, Blit4bto1Key, Blit4bto2Key, Blit4bto3Key, Blit4bto4Key
};
static void Blit4btoNAlpha(SDL_BlitInfo *info)
{
BlitBtoNAlpha(info, 4);
}
static void Blit4btoNAlphaKey(SDL_BlitInfo *info)
{
BlitBtoNAlphaKey(info, 4);
}
SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
@@ -936,10 +907,10 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
return colorkey_blit_1b[which];
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit1btoNAlpha : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL;
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit1btoNAlphaKey : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL;
}
return NULL;
}
@@ -953,10 +924,10 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
return colorkey_blit_2b[which];
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit2btoNAlpha : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL;
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit2btoNAlphaKey : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL;
}
return NULL;
}
@@ -970,10 +941,10 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
return colorkey_blit_4b[which];
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit4btoNAlpha : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL;
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit4btoNAlphaKey : (SDL_BlitFunc)NULL;
return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL;
}
return NULL;
}

View File

@@ -57,6 +57,10 @@
#include <emscripten.h>
#endif
#ifdef __3DS__
#include <3ds.h>
#endif
#ifdef __LINUX__
#include <sys/types.h>
#include <sys/stat.h>
@@ -4542,6 +4546,23 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag
},
title, message);
return 0;
#elif defined(__3DS__)
errorConf errCnf;
bool hasGpuRight;
/* If the video subsystem has not been initialised, set up graphics temporarily */
hasGpuRight = gspHasGpuRight();
if (!hasGpuRight)
gfxInitDefault();
errorInit(&errCnf, ERROR_TEXT_WORD_WRAP, CFG_LANGUAGE_EN);
errorText(&errCnf, message);
errorDisp(&errCnf);
if (!hasGpuRight)
gfxExit();
return 0;
#else
SDL_MessageBoxData data;
SDL_MessageBoxButtonData button;

View File

@@ -507,13 +507,31 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
return 0;
}}
void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
{ @autoreleasepool
static void DispatchedDeleteContext(SDL_GLContext context)
{
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
[nscontext cleanup];
CFRelease(context);
}}
@autoreleasepool {
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
[nscontext cleanup];
CFRelease(context);
}
}
void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
{
if ([NSThread isMainThread]) {
DispatchedDeleteContext(context);
} else {
if (SDL_opengl_async_dispatch) {
dispatch_async(dispatch_get_main_queue(), ^{
DispatchedDeleteContext(context);
});
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
DispatchedDeleteContext(context);
});
}
}
}
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
#ifdef __clang__

View File

@@ -714,20 +714,24 @@ static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent
SDL_WindowData *window_data = userData;
float deltaY = wheelEvent->deltaY;
float deltaX = wheelEvent->deltaX;
switch (wheelEvent->deltaMode) {
case DOM_DELTA_PIXEL:
deltaY /= 100; /* 100 pixels make up a step */
deltaX /= 100; /* 100 pixels make up a step */
break;
case DOM_DELTA_LINE:
deltaY /= 3; /* 3 lines make up a step */
deltaX /= 3; /* 3 lines make up a step */
break;
case DOM_DELTA_PAGE:
deltaY *= 80; /* A page makes up 80 steps */
deltaX *= 80; /* A page makes up 80 steps */
break;
}
SDL_SendMouseWheel(window_data->window, 0, (float)wheelEvent->deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
SDL_SendMouseWheel(window_data->window, 0, deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL);
return SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE;
}

View File

@@ -89,7 +89,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
SDL2.imageCtx = SDL2.ctx;
}
var data = SDL2.image.data;
var src = pixels >> 2;
var src = pixels / 4;
var dst = 0;
var num;
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {

View File

@@ -98,7 +98,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int
var image = ctx.createImageData(w, h);
var data = image.data;
var src = pixels >> 2;
var src = pixels / 4;
var dst = 0;
var num;
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {

View File

@@ -118,47 +118,12 @@ static void GetFullScreenDimensions(SDL_Window *window, int *width, int *height,
}
}
SDL_FORCE_INLINE SDL_bool SurfaceScaleIsFractional(SDL_Window *window)
{
SDL_WindowData *data = window->driverdata;
return !FloatEqual(SDL_roundf(data->scale_factor), data->scale_factor);
}
SDL_FORCE_INLINE SDL_bool FullscreenModeEmulation(SDL_Window *window)
{
return (window->flags & SDL_WINDOW_FULLSCREEN) &&
((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP);
}
static SDL_bool NeedViewport(SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
SDL_VideoData *video = wind->waylandData;
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
SDL_WaylandOutputData *output = display ? ((SDL_WaylandOutputData *)display->driverdata) : NULL;
const int output_width = wind->fs_output_width ? wind->fs_output_width : (output ? output->width : wind->window_width);
const int output_height = wind->fs_output_height ? wind->fs_output_height : (output ? output->height : wind->window_height);
int fs_width, fs_height;
/*
* A viewport is only required when scaling is enabled and:
* - A fullscreen mode is being emulated and the mode does not match the logical desktop dimensions.
* - The desktop uses fractional scaling and the high-DPI flag is set.
*/
if (video->viewporter) {
if (FullscreenModeEmulation(window)) {
GetFullScreenDimensions(window, &fs_width, &fs_height, NULL, NULL);
if (fs_width != output_width || fs_height != output_height) {
return SDL_TRUE;
}
} else if (SurfaceScaleIsFractional(window) && (window->flags & SDL_WINDOW_ALLOW_HIGHDPI)) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}
static void GetBufferSize(SDL_Window *window, int *width, int *height)
{
SDL_WindowData *data = window->driverdata;
@@ -167,15 +132,12 @@ static void GetBufferSize(SDL_Window *window, int *width, int *height)
if (FullscreenModeEmulation(window)) {
GetFullScreenDimensions(window, NULL, NULL, &buf_width, &buf_height);
} else if (NeedViewport(window)) {
} else if (data->draw_viewport) {
/* Round fractional backbuffer sizes halfway away from zero. */
buf_width = (int)SDL_lroundf(window->w * data->scale_factor);
buf_height = (int)SDL_lroundf(window->h * data->scale_factor);
} else {
/*
* Integer scaled windowed or fullscreen with no viewport
*
* Round the scale factor up in the unlikely scenario of a compositor
/* Round the scale factor up in the unlikely scenario of a compositor
* that supports fractional scaling, but not viewports.
*/
int scale_factor = (int)SDL_ceilf(data->scale_factor);
@@ -192,31 +154,6 @@ static void GetBufferSize(SDL_Window *window, int *width, int *height)
}
}
static void SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_height, int dst_width, int dst_height)
{
SDL_WindowData *wind = window->driverdata;
SDL_VideoData *video = wind->waylandData;
if (video->viewporter) {
if (!wind->draw_viewport) {
wind->draw_viewport = wp_viewporter_get_viewport(video->viewporter, wind->surface);
}
wp_viewport_set_source(wind->draw_viewport, wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1));
wp_viewport_set_destination(wind->draw_viewport, dst_width, dst_height);
}
}
static void UnsetDrawSurfaceViewport(SDL_Window *window)
{
SDL_WindowData *wind = window->driverdata;
if (wind->draw_viewport) {
wp_viewport_destroy(wind->draw_viewport);
wind->draw_viewport = NULL;
}
}
static void ConfigureWindowGeometry(SDL_Window *window)
{
SDL_WindowData *data = window->driverdata;
@@ -240,7 +177,7 @@ static void ConfigureWindowGeometry(SDL_Window *window)
0, 0);
}
if (FullscreenModeEmulation(window) && NeedViewport(window)) {
if (FullscreenModeEmulation(window) && data->draw_viewport) {
int fs_width, fs_height;
const int output_width = data->fs_output_width ? data->fs_output_width : (output ? output->width : data->window_width);
const int output_height = data->fs_output_height ? data->fs_output_height : (output ? output->height : data->window_height);
@@ -252,8 +189,7 @@ static void ConfigureWindowGeometry(SDL_Window *window)
/* Set the buffer scale to 1 since a viewport will be used. */
wl_surface_set_buffer_scale(data->surface, 1);
SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height,
output_width, output_height);
wp_viewport_set_destination(data->draw_viewport, output_width, output_height);
data->window_width = output_width;
data->window_height = output_height;
@@ -265,12 +201,10 @@ static void ConfigureWindowGeometry(SDL_Window *window)
window_size_changed = data->window_width != window->w || data->window_height != window->h;
if (window_size_changed || drawable_size_changed) {
if (NeedViewport(window)) {
if (data->draw_viewport) {
wl_surface_set_buffer_scale(data->surface, 1);
SetDrawSurfaceViewport(window, data->drawable_width, data->drawable_height, window->w, window->h);
wp_viewport_set_destination(data->draw_viewport, window->w, window->h);
} else {
UnsetDrawSurfaceViewport(window);
if (!FullscreenModeEmulation(window)) {
/* Round to the next integer in case of a fractional value. */
wl_surface_set_buffer_scale(data->surface, (int32_t)SDL_ceilf(data->scale_factor));
@@ -293,8 +227,11 @@ static void ConfigureWindowGeometry(SDL_Window *window)
* need to be recalculated if the output size has changed.
*/
if (window_size_changed) {
/* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */
if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR &&
/* XXX: This is a hack and only set on the xdg-toplevel path when viewports
* aren't supported to avoid a potential protocol violation if a buffer
* with an old size is committed.
*/
if (!data->draw_viewport && data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL &&
viddata->shell.xdg && data->shell_surface.xdg.surface) {
xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height);
}
@@ -1420,9 +1357,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
&decoration_listener,
window);
}
/* Set the geometry */
xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height);
} else {
/* Nothing to see here, just commit. */
wl_surface_commit(data->surface);
@@ -1999,13 +1933,6 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
c = _this->driverdata;
window->driverdata = data;
if (!(window->flags & SDL_WINDOW_VULKAN)) {
if (!(window->flags & SDL_WINDOW_OPENGL)) {
SDL_GL_LoadLibrary(NULL);
window->flags |= SDL_WINDOW_OPENGL;
}
}
if (window->x == SDL_WINDOWPOS_UNDEFINED) {
window->x = 0;
}
@@ -2043,6 +1970,13 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
SDL_WAYLAND_register_surface(data->surface);
if (c->viewporter) {
data->draw_viewport = wp_viewporter_get_viewport(c->viewporter, data->surface);
wp_viewport_set_source(data->draw_viewport,
wl_fixed_from_int(-1), wl_fixed_from_int(-1),
wl_fixed_from_int(-1), wl_fixed_from_int(-1));
}
/* Must be called before EGL configuration to set the drawable backbuffer size. */
ConfigureWindowGeometry(window);

View File

@@ -676,9 +676,10 @@ static void X11_HandleClipboardEvent(_THIS, const XEvent *xevent)
&overflow, &seln_data) == Success) {
if (seln_format != None) {
X11_XChangeProperty(display, req->requestor, req->property,
sevent.xselection.target, seln_format, PropModeReplace,
req->target, 8, PropModeReplace,
seln_data, nbytes);
sevent.xselection.property = req->property;
sevent.xselection.target = req->target;
X11_XFree(seln_data);
break;
} else {

View File

@@ -366,12 +366,11 @@ if(PSP)
endif()
if(N3DS)
set(ROMFS_DIR "${CMAKE_CURRENT_BINARY_DIR}/romfs")
file(COPY ${RESOURCE_FILES} DESTINATION "${ROMFS_DIR}")
foreach(APP IN LISTS SDL_TEST_EXECUTABLES)
get_target_property(TARGET_BINARY_DIR ${APP} BINARY_DIR)
set(ROMFS_DIR "${TARGET_BINARY_DIR}/sdl-${APP}")
set(SMDH_FILE "${TARGET_BINARY_DIR}/${APP}.smdh")
file(MAKE_DIRECTORY ${ROMFS_DIR})
ctr_generate_smdh("${SMDH_FILE}"
NAME "SDL-${APP}"
DESCRIPTION "SDL2 Test suite"
@@ -428,7 +427,7 @@ add_custom_target(copy-sdl-test-resources
)
foreach(APP IN LISTS SDL_TESTS_NEEDS_RESOURCES)
if(PSP OR PS2)
if(PSP OR PS2 OR N3DS)
foreach(RESOURCE_FILE ${RESOURCE_FILES})
add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $<TARGET_FILE_DIR:${APP}>/sdl-${APP})
endforeach()

View File

@@ -12,7 +12,10 @@
This file is created by : Nitin Jain (nitin.j4@samsung.com)
*/
/* Sample program: Draw a Chess Board by using SDL_CreateSoftwareRenderer API */
/* Sample program: Draw a Chess Board by using the SDL render API */
/* This allows testing SDL_CreateSoftwareRenderer with the window surface API. Undefine it to use the accelerated renderer instead. */
#define USE_SOFTWARE_RENDERER
#include <stdlib.h>
#include <stdio.h>
@@ -25,9 +28,12 @@
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Surface *surface;
int done;
#ifdef USE_SOFTWARE_RENDERER
SDL_Surface *surface;
#endif
void DrawChessBoard(void)
{
int row = 0, column = 0, x = 0;
@@ -50,7 +56,6 @@ void DrawChessBoard(void)
SDL_RenderFillRect(renderer, &rect);
}
}
SDL_RenderPresent(renderer);
}
void loop(void)
@@ -58,6 +63,7 @@ void loop(void)
SDL_Event e;
while (SDL_PollEvent(&e)) {
#ifdef USE_SOFTWARE_RENDERER
/* Re-create when window has been resized */
if ((e.type == SDL_WINDOWEVENT) && (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) {
@@ -69,6 +75,7 @@ void loop(void)
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(renderer);
}
#endif
if (e.type == SDL_QUIT) {
done = 1;
@@ -87,11 +94,19 @@ void loop(void)
}
}
/* Clear the rendering surface with the specified color */
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(renderer);
DrawChessBoard();
SDL_RenderPresent(renderer);
#ifdef USE_SOFTWARE_RENDERER
/* Got everything on rendering surface,
now Update the drawing image on window screen */
SDL_UpdateWindowSurface(window);
#endif
}
int main(int argc, char *argv[])
@@ -111,17 +126,17 @@ int main(int argc, char *argv[])
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError());
return 1;
}
#ifdef USE_SOFTWARE_RENDERER
surface = SDL_GetWindowSurface(window);
renderer = SDL_CreateSoftwareRenderer(surface);
#else
renderer = SDL_CreateRenderer(window, -1, 0);
#endif
if (!renderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError());
return 1;
}
/* Clear the rendering surface with the specified color */
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
SDL_RenderClear(renderer);
/* Draw the Image on rendering surface */
done = 0;
#ifdef __EMSCRIPTEN__