Compare commits
112
Commits
SDL2
...
release-2.32.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4478ad67d2 | ||
|
|
667e4e9020 | ||
|
|
2430122b21 | ||
|
|
18c96e27d2 | ||
|
|
0dcfa78be6 | ||
|
|
c636332031 | ||
|
|
385e995790 | ||
|
|
a069ac41e5 | ||
|
|
dc086d6454 | ||
|
|
1acc405bd4 | ||
|
|
a07b00ccb0 | ||
|
|
e458305c43 | ||
|
|
3ff58bf062 | ||
|
|
7eb78c5070 | ||
|
|
6e5cad8e1e | ||
|
|
876baf6b0e | ||
|
|
c0d0b31d1c | ||
|
|
80cbc908a1 | ||
|
|
735d8a2dc8 | ||
|
|
bc67702d8d | ||
|
|
40625e9e7e | ||
|
|
a5f445dba1 | ||
|
|
f172ee3d0e | ||
|
|
7fe49da380 | ||
|
|
0efcafc74d | ||
|
|
dcc72b43ba | ||
|
|
b8430e4135 | ||
|
|
394d9bfa1a | ||
|
|
ecc71c02ea | ||
|
|
60515350ae | ||
|
|
05c9b16183 | ||
|
|
2db8436d8c | ||
|
|
5d24957039 | ||
|
|
fd5dcfba03 | ||
|
|
5806036c68 | ||
|
|
9f369a1736 | ||
|
|
1f6e0e3a23 | ||
|
|
c8e984701e | ||
|
|
2a506c8778 | ||
|
|
a455f023c2 | ||
|
|
2a10b8c4e7 | ||
|
|
f610a3d66b | ||
|
|
54772f345a | ||
|
|
e257904eb3 | ||
|
|
cc7a73e727 | ||
|
|
9f1cc301a7 | ||
|
|
e321995244 | ||
|
|
28e9533d34 | ||
|
|
f9fc36be9e | ||
|
|
f8119d4760 | ||
|
|
1b35c66aa8 | ||
|
|
553ea4e4ee | ||
|
|
c438953aa2 | ||
|
|
6e77327789 | ||
|
|
e25c61cda8 | ||
|
|
28f2944947 | ||
|
|
ab9f59e59a | ||
|
|
f99f57ffd1 | ||
|
|
7f371c7808 | ||
|
|
d98087a0c3 | ||
|
|
933715fa45 | ||
|
|
73492c5570 | ||
|
|
19fc5c2953 | ||
|
|
c2a62ee696 | ||
|
|
c1b8ac9764 | ||
|
|
7a43692bdf | ||
|
|
99ad0871b1 | ||
|
|
f901079dd5 | ||
|
|
98d1f3a45a | ||
|
|
1226e6b2bc | ||
|
|
213b074697 | ||
|
|
4177e06c09 | ||
|
|
4318013777 | ||
|
|
3364486f56 | ||
|
|
dc69988fdf | ||
|
|
4ed1fc5bff | ||
|
|
84081d884b | ||
|
|
a5fad8b0cb | ||
|
|
6510d6ccbf | ||
|
|
b0b50da4b6 | ||
|
|
8b7a088efc | ||
|
|
7fc5edab8e | ||
|
|
24ccde693e | ||
|
|
f46ef5d76d | ||
|
|
5696677558 | ||
|
|
093307f1f4 | ||
|
|
f54014e173 | ||
|
|
64ad33884d | ||
|
|
2359383fc1 | ||
|
|
b2a95b2482 | ||
|
|
2708e08f40 | ||
|
|
3f6efbf2df | ||
|
|
9b048e73a2 | ||
|
|
d3bb91522f | ||
|
|
c8c4c97727 | ||
|
|
f08a5cfcab | ||
|
|
e9d2f60e1c | ||
|
|
9e079fe9c7 | ||
|
|
53c022c880 | ||
|
|
e11183ea6c | ||
|
|
024c27645a | ||
|
|
c2047f0496 | ||
|
|
220895d4d2 | ||
|
|
282f7a84fc | ||
|
|
9be8c2a899 | ||
|
|
51e20f1666 | ||
|
|
a34c8403e7 | ||
|
|
dc74448014 | ||
|
|
155f99a4e6 | ||
|
|
63bb1a8583 | ||
|
|
8b0c9e1dce | ||
|
|
7f74c1ed63 |
No files matched your search
@@ -20,7 +20,6 @@ class AppleArch(Enum):
|
||||
class MsvcArch(Enum):
|
||||
X86 = "x86"
|
||||
X64 = "x64"
|
||||
Arm32 = "arm"
|
||||
Arm64 = "arm64"
|
||||
|
||||
|
||||
@@ -28,7 +27,6 @@ class JobOs(Enum):
|
||||
WindowsLatest = "windows-latest"
|
||||
UbuntuLatest = "ubuntu-latest"
|
||||
MacosLatest = "macos-latest"
|
||||
Ubuntu20_04 = "ubuntu-20.04"
|
||||
Ubuntu22_04 = "ubuntu-22.04"
|
||||
Ubuntu24_04 = "ubuntu-24.04"
|
||||
Macos13 = "macos-13"
|
||||
@@ -51,19 +49,18 @@ class SdlPlatform(Enum):
|
||||
Riscos = "riscos"
|
||||
FreeBSD = "freebsd"
|
||||
NetBSD = "netbsd"
|
||||
OpenBSD = "openbsd"
|
||||
Watcom = "watcom"
|
||||
|
||||
|
||||
class Msys2Platform(Enum):
|
||||
Mingw32 = "mingw32"
|
||||
Mingw64 = "mingw64"
|
||||
Clang32 = "clang32"
|
||||
Clang64 = "clang64"
|
||||
Ucrt64 = "ucrt64"
|
||||
|
||||
|
||||
class IntelCompiler(Enum):
|
||||
Icc = "icc"
|
||||
Icx = "icx"
|
||||
|
||||
|
||||
@@ -99,7 +96,6 @@ class JobSpec:
|
||||
msvc_static_crt: bool = False
|
||||
clang_cl: bool = False
|
||||
gdk: bool = False
|
||||
uwp: bool = False
|
||||
vita_gles: Optional[VitaGLES] = None
|
||||
watcom_platform: Optional[WatcomPlatform] = None
|
||||
|
||||
@@ -107,7 +103,6 @@ class JobSpec:
|
||||
JOB_SPECS = {
|
||||
"msys2-mingw32": JobSpec(name="Windows (msys2, mingw32)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw32", msys2_platform=Msys2Platform.Mingw32, ),
|
||||
"msys2-mingw64": JobSpec(name="Windows (msys2, mingw64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64", msys2_platform=Msys2Platform.Mingw64, ),
|
||||
"msys2-clang32": JobSpec(name="Windows (msys2, clang32)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw32-clang", msys2_platform=Msys2Platform.Clang32, ),
|
||||
"msys2-clang64": JobSpec(name="Windows (msys2, clang64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-clang", msys2_platform=Msys2Platform.Clang64, ),
|
||||
"msys2-ucrt64": JobSpec(name="Windows (msys2, ucrt64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msys2, artifact="SDL-mingw64-ucrt", msys2_platform=Msys2Platform.Ucrt64, ),
|
||||
"msvc-x64": JobSpec(name="Windows (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x64", msvc_arch=MsvcArch.X64, msvc_project="VisualC/SDL.sln", ),
|
||||
@@ -116,15 +111,11 @@ JOB_SPECS = {
|
||||
"msvc-static-x64": JobSpec(name="Windows (MSVC, static VCRT, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x64", msvc_arch=MsvcArch.X64, msvc_static_crt=True, ),
|
||||
"msvc-clang-x64": JobSpec(name="Windows (MSVC, clang-cl x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x64", msvc_arch=MsvcArch.X64, clang_cl=True, ),
|
||||
"msvc-clang-x86": JobSpec(name="Windows (MSVC, clang-cl x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-clang-cl-x86", msvc_arch=MsvcArch.X86, clang_cl=True, ),
|
||||
"msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ),
|
||||
"msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ),
|
||||
"msvc-uwp-x64": JobSpec(name="UWP (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-UWP", msvc_arch=MsvcArch.X64, msvc_project="VisualC-WinRT/SDL-UWP.sln", uwp=True, ),
|
||||
"msvc-gdk-x64": JobSpec(name="GDK (MSVC, x64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-GDK", msvc_arch=MsvcArch.X64, msvc_project="VisualC-GDK/SDL.sln", gdk=True, no_cmake=True, ),
|
||||
"ubuntu-20.04": JobSpec(name="Ubuntu 20.04", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04", autotools=True),
|
||||
"ubuntu-22.04": JobSpec(name="Ubuntu 22.04", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04", autotools=True),
|
||||
"steamrt-sniper": JobSpec(name="Steam Linux Runtime (Sniper)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Linux, artifact="SDL-slrsniper", container="registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta", ),
|
||||
"ubuntu-intel-icx": JobSpec(name="Ubuntu 20.04 (Intel oneAPI)", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04-oneapi", intel=IntelCompiler.Icx, ),
|
||||
"ubuntu-intel-icc": JobSpec(name="Ubuntu 20.04 (Intel Compiler)", os=JobOs.Ubuntu20_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu20.04-icc", intel=IntelCompiler.Icc, ),
|
||||
"ubuntu-intel-icx": JobSpec(name="Ubuntu 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ),
|
||||
"macos-gnu-arm64-x64": JobSpec(name="MacOS (GNU prefix)", os=JobOs.MacosLatest, platform=SdlPlatform.MacOS, artifact="SDL-macos-arm64-x64-gnu",autotools=True, apple_archs={AppleArch.X86_64, AppleArch.ARM64, }, ),
|
||||
"ios": JobSpec(name="iOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Ios, artifact="SDL-ios-arm64", xcode=True, ),
|
||||
"tvos": JobSpec(name="tvOS (CMake & xcode)", os=JobOs.MacosLatest, platform=SdlPlatform.Tvos, artifact="SDL-tvos-arm64", xcode=True, ),
|
||||
@@ -139,6 +130,7 @@ JOB_SPECS = {
|
||||
"vita-pvr": JobSpec(name="Sony PlayStation Vita (GLES w/ PVR_PSP2)", os=JobOs.UbuntuLatest, platform=SdlPlatform.Vita, artifact="SDL-vita-pvr", container="vitasdk/vitasdk:latest", vita_gles=VitaGLES.Pvr, ),
|
||||
"riscos": JobSpec(name="RISC OS", os=JobOs.UbuntuLatest, platform=SdlPlatform.Riscos, artifact="SDL-riscos", container="riscosdotinfo/riscos-gccsdk-4.7:latest", ),
|
||||
"netbsd": JobSpec(name="NetBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.NetBSD, artifact="SDL-netbsd-x64", autotools=True, ),
|
||||
"openbsd": JobSpec(name="OpenBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.OpenBSD, artifact="SDL-openbsd-x64", autotools=True, ),
|
||||
"freebsd": JobSpec(name="FreeBSD", os=JobOs.UbuntuLatest, platform=SdlPlatform.FreeBSD, artifact="SDL-freebsd-x64", autotools=True, ),
|
||||
"watcom-win32": JobSpec(name="Watcom (Windows)", os=JobOs.WindowsLatest, platform=SdlPlatform.Watcom, artifact="SDL-watcom-win32", no_cmake=True, watcom_platform=WatcomPlatform.Windows ),
|
||||
"watcom-os2": JobSpec(name="Watcom (OS/2)", os=JobOs.WindowsLatest, platform=SdlPlatform.Watcom, artifact="SDL-watcom-win32", no_cmake=True, watcom_platform=WatcomPlatform.OS2 ),
|
||||
@@ -181,6 +173,7 @@ class JobDetails:
|
||||
brew_packages: list[str] = dataclasses.field(default_factory=list)
|
||||
cmake_toolchain_file: str = ""
|
||||
cmake_arguments: list[str] = dataclasses.field(default_factory=list)
|
||||
cmake_generator: str = "Ninja"
|
||||
cmake_build_arguments: list[str] = dataclasses.field(default_factory=list)
|
||||
cppflags: list[str] = dataclasses.field(default_factory=list)
|
||||
cc: str = ""
|
||||
@@ -226,6 +219,7 @@ class JobDetails:
|
||||
setup_vita_gles_type: str = ""
|
||||
check_sources: bool = False
|
||||
watcom_makefile: str = ""
|
||||
binutils_strings: str = "strings"
|
||||
|
||||
def to_workflow(self, enable_artifacts: bool) -> dict[str, str|bool]:
|
||||
data = {
|
||||
@@ -259,6 +253,7 @@ class JobDetails:
|
||||
"cflags": my_shlex_join(self.cppflags + self.cflags),
|
||||
"cxxflags": my_shlex_join(self.cppflags + self.cxxflags),
|
||||
"ldflags": my_shlex_join(self.ldflags),
|
||||
"cmake-generator": self.cmake_generator,
|
||||
"cmake-toolchain-file": self.cmake_toolchain_file,
|
||||
"cmake-arguments": my_shlex_join(self.cmake_arguments),
|
||||
"cmake-build-arguments": my_shlex_join(self.cmake_build_arguments),
|
||||
@@ -291,6 +286,7 @@ class JobDetails:
|
||||
"setup-gdk-folder": self.setup_gdk_folder,
|
||||
"check-sources": self.check_sources,
|
||||
"watcom-makefile": self.watcom_makefile,
|
||||
"binutils-strings": self.binutils_strings,
|
||||
}
|
||||
return {k: v for k, v in data.items() if v != ""}
|
||||
|
||||
@@ -344,10 +340,6 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
case IntelCompiler.Icx:
|
||||
job.cc = "icx"
|
||||
job.cxx = "icpx"
|
||||
case IntelCompiler.Icc:
|
||||
job.cc = "icc"
|
||||
job.cxx = "icpc"
|
||||
job.cppflags.append("-diag-disable=10441")
|
||||
case _:
|
||||
raise ValueError(f"Invalid intel={spec.intel}")
|
||||
job.source_cmd = f"source /opt/intel/oneapi/setvars.sh;"
|
||||
@@ -371,10 +363,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
"-DCMAKE_EXE_LINKER_FLAGS=-DEBUG",
|
||||
"-DCMAKE_SHARED_LINKER_FLAGS=-DEBUG",
|
||||
))
|
||||
if spec.uwp:
|
||||
job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL'")
|
||||
else:
|
||||
job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>'")
|
||||
job.cmake_arguments.append("'-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>'")
|
||||
|
||||
if spec.clang_cl:
|
||||
job.cmake_arguments.extend((
|
||||
@@ -406,21 +395,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.msvc_vcvars_arch = "x64_x86"
|
||||
case MsvcArch.X64:
|
||||
job.msvc_vcvars_arch = "x64"
|
||||
case MsvcArch.Arm32:
|
||||
job.msvc_vcvars_arch = "x64_arm"
|
||||
job.msvc_vcvars_sdk = "10.0.22621.0" # 10.0.26100.0 dropped ARM32 um and ucrt libraries
|
||||
job.run_tests = False
|
||||
case MsvcArch.Arm64:
|
||||
job.msvc_vcvars_arch = "x64_arm64"
|
||||
job.run_tests = False
|
||||
if spec.uwp:
|
||||
job.build_tests = False
|
||||
job.cmake_arguments.extend((
|
||||
"-DCMAKE_SYSTEM_NAME=WindowsStore",
|
||||
"-DCMAKE_SYSTEM_VERSION=10.0",
|
||||
))
|
||||
job.msvc_project_flags.append("-p:WindowsTargetPlatformVersion=10.0.17763.0")
|
||||
elif spec.gdk:
|
||||
if spec.gdk:
|
||||
job.setup_gdk_folder = "VisualC-GDK"
|
||||
else:
|
||||
match spec.msvc_arch:
|
||||
@@ -610,11 +588,14 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.shared_lib = SharedLibType.SO_0
|
||||
job.static_lib = StaticLibType.A
|
||||
case SdlPlatform.N3ds:
|
||||
job.cmake_generator = "Unix Makefiles"
|
||||
job.cmake_build_arguments.append("-j$(nproc)")
|
||||
job.shared = False
|
||||
job.apt_packages = ["ninja-build", "binutils"]
|
||||
job.apt_packages = []
|
||||
job.run_tests = False
|
||||
job.cc_from_cmake = True
|
||||
job.cmake_toolchain_file = "${DEVKITPRO}/cmake/3DS.cmake"
|
||||
job.binutils_strings = "/opt/devkitpro/devkitARM/bin/arm-none-eabi-strings"
|
||||
job.static_lib = StaticLibType.A
|
||||
case SdlPlatform.Msys2:
|
||||
job.shell = "msys2 {0}"
|
||||
@@ -627,7 +608,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
"clang64": "mingw-w64-clang-x86_64",
|
||||
"ucrt64": "mingw-w64-ucrt-x86_64",
|
||||
}[spec.msys2_platform.value]
|
||||
job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, Msys2Platform.Clang32)
|
||||
job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, )
|
||||
job.shared_lib = SharedLibType.WIN32
|
||||
job.static_lib = StaticLibType.A
|
||||
case SdlPlatform.Riscos:
|
||||
@@ -646,7 +627,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
))
|
||||
job.cmake_toolchain_file = "/home/riscos/env/toolchain-riscos.cmake"
|
||||
job.static_lib = StaticLibType.A
|
||||
case SdlPlatform.FreeBSD | SdlPlatform.NetBSD:
|
||||
case SdlPlatform.FreeBSD | SdlPlatform.NetBSD | SdlPlatform.OpenBSD:
|
||||
job.build_autotools_tests = False
|
||||
job.cpactions = True
|
||||
job.no_cmake = True
|
||||
@@ -657,7 +638,7 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
match spec.platform:
|
||||
case SdlPlatform.FreeBSD:
|
||||
job.cpactions_os = "freebsd"
|
||||
job.cpactions_version = "14.2"
|
||||
job.cpactions_version = "14.3"
|
||||
job.cpactions_arch = "x86-64"
|
||||
job.cpactions_setup_cmd = "sudo pkg update"
|
||||
job.cpactions_install_cmd = "sudo pkg install -y cmake ninja pkgconf libXcursor libXext libXinerama libXi libXfixes libXrandr libXScrnSaver libXxf86vm wayland wayland-protocols libxkbcommon mesa-libs libglvnd evdev-proto libinotify alsa-lib jackit pipewire pulseaudio sndio dbus zh-fcitx ibus libudev-devd"
|
||||
@@ -671,6 +652,12 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
job.cpactions_arch = "x86-64"
|
||||
job.cpactions_setup_cmd = "export PATH=\"/usr/pkg/sbin:/usr/pkg/bin:/sbin:$PATH\"; export PKG_CONFIG_PATH=\"/usr/pkg/lib/pkgconfig\";export PKG_PATH=\"https://cdn.netBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r|cut -f \"1 2\" -d.)/All/\";echo \"PKG_PATH=$PKG_PATH\";echo \"uname -a -> \"$(uname -a)\"\";sudo -E sysctl -w security.pax.aslr.enabled=0;sudo -E sysctl -w security.pax.aslr.global=0;sudo -E pkgin clean;sudo -E pkgin update"
|
||||
job.cpactions_install_cmd = "sudo -E pkgin -y install cmake dbus pkgconf ninja-build pulseaudio libxkbcommon wayland wayland-protocols libinotify libusb1"
|
||||
case SdlPlatform.OpenBSD:
|
||||
job.cpactions_os = "openbsd"
|
||||
job.cpactions_version = "7.7"
|
||||
job.cpactions_arch = "x86-64"
|
||||
job.cpactions_setup_cmd = "sudo pkg_add -u"
|
||||
job.cpactions_install_cmd = "sudo pkg_add cmake ninja pkgconf wayland wayland-protocols libxkbcommon libinotify pulseaudio dbus ibus"
|
||||
case SdlPlatform.Watcom:
|
||||
match spec.watcom_platform:
|
||||
case WatcomPlatform.OS2:
|
||||
|
||||
@@ -177,7 +177,7 @@ jobs:
|
||||
#shell: ${{ matrix.platform.shell }}
|
||||
run: |
|
||||
${{ matrix.platform.source-cmd }}
|
||||
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -GNinja \
|
||||
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -G "${{ matrix.platform.cmake-generator }}" \
|
||||
-Wdeprecated -Wdev -Werror \
|
||||
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
|
||||
-DSDL_WERROR=${{ matrix.platform.werror }} \
|
||||
@@ -207,9 +207,9 @@ jobs:
|
||||
run: |
|
||||
echo "This should show us the SDL_REVISION"
|
||||
echo "Shared library:"
|
||||
${{ (matrix.platform.shared-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
|
||||
${{ (matrix.platform.shared-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
|
||||
echo "Static library:"
|
||||
${{ (matrix.platform.static-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
|
||||
${{ (matrix.platform.static-lib && format('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.static-lib)) || 'echo "<Static library not supported by platform>"' }}
|
||||
- name: 'Run build-time tests (CMake)'
|
||||
id: cmake-tests
|
||||
if: ${{ !matrix.platform.no-cmake && matrix.platform.run-tests }}
|
||||
@@ -264,7 +264,7 @@ jobs:
|
||||
- name: 'Build (cross-platform-actions, BSD)'
|
||||
id: cpactions
|
||||
if: ${{ matrix.platform.cpactions }}
|
||||
uses: cross-platform-actions/action@v0.27.0
|
||||
uses: cross-platform-actions/action@v0.29.0
|
||||
with:
|
||||
operating_system: '${{ matrix.platform.cpactions-os }}'
|
||||
architecture: '${{ matrix.platform.cpactions-arch }}'
|
||||
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
|
||||
msvc:
|
||||
needs: [src]
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2025
|
||||
outputs:
|
||||
VC-x86: ${{ steps.releaser.outputs.VC-x86 }}
|
||||
VC-x64: ${{ steps.releaser.outputs.VC-x64 }}
|
||||
|
||||
+19
-7
@@ -89,7 +89,7 @@ endif()
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 32)
|
||||
set(SDL_MICRO_VERSION 0)
|
||||
set(SDL_MICRO_VERSION 11)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -755,6 +755,11 @@ if(MSVC)
|
||||
if(MSVC_VERSION GREATER 1926 AND CMAKE_GENERATOR_PLATFORM MATCHES "Win32|x64")
|
||||
list(APPEND EXTRA_LDFLAGS_BUILD "-CETCOMPAT")
|
||||
endif()
|
||||
|
||||
# for VS >= 17.14 targeting ARM64: inline the Interlocked funcs
|
||||
if(MSVC_VERSION GREATER 1943 AND SDL_CPU_ARM64 AND NOT SDL_LIBC)
|
||||
list(APPEND EXTRA_CFLAGS /forceInterlockedFunctions-)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
||||
@@ -1094,6 +1099,7 @@ if(SDL_LIBC)
|
||||
endforeach()
|
||||
|
||||
check_symbol_exists(sigaction "signal.h" HAVE_SIGACTION)
|
||||
check_symbol_exists(sigtimedwait "signal.h" HAVE_SIGTIMEDWAIT)
|
||||
check_symbol_exists(setjmp "setjmp.h" HAVE_SETJMP)
|
||||
check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP)
|
||||
check_symbol_exists(sysconf "unistd.h" HAVE_SYSCONF)
|
||||
@@ -1465,10 +1471,14 @@ elseif(EMSCRIPTEN)
|
||||
elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
||||
if(SDL_AUDIO)
|
||||
if(SYSV5 OR SOLARIS OR HPUX)
|
||||
set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
|
||||
file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
|
||||
list(APPEND SOURCE_FILES ${SUN_AUDIO_SOURCES})
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
# Newer Solaris-based systems, like OpenIndiana, don't have this interface anymore. Check for the header first.
|
||||
check_include_file(sys/audioio.h HAVE_SYS_AUDIOIO_H)
|
||||
if(HAVE_SYS_AUDIOIO_H)
|
||||
set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
|
||||
file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
|
||||
list(APPEND SOURCE_FILES ${SUN_AUDIO_SOURCES})
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
endif()
|
||||
elseif(NETBSD)
|
||||
set(SDL_AUDIO_DRIVER_NETBSD 1)
|
||||
file(GLOB NETBSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/netbsd/*.c)
|
||||
@@ -1829,8 +1839,10 @@ elseif(WINDOWS)
|
||||
set(HAVE_DIRECTX TRUE)
|
||||
if(NOT MINGW AND NOT USE_WINSDK_DIRECTX)
|
||||
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
|
||||
target_link_directories(sdl-build-options INTERFACE "$$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}")
|
||||
target_include_directories(sdl-build-options INTERFACE "$ENV{DXSDK_DIR}\\Include")
|
||||
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}" SDL2_TMP_DXSDK_LIB_DIR)
|
||||
target_link_directories(sdl-build-options INTERFACE "${SDL2_TMP_DXSDK_LIB_DIR}")
|
||||
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}\\Include" SDL2_TMP_DXSDK_INCLUDE_DIR)
|
||||
target_include_directories(sdl-build-options INTERFACE "${SDL2_TMP_DXSDK_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 32
|
||||
MICRO_VERSION = 0
|
||||
MICRO_VERSION = 11
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 32
|
||||
MICRO_VERSION = 0
|
||||
MICRO_VERSION = 11
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
|
||||
LIBHOME = .
|
||||
|
||||
@@ -456,7 +456,10 @@ main(int argc, char *argv[])
|
||||
while (!done) {
|
||||
SDL_Event event;
|
||||
double deltaTime = updateDeltaTime();
|
||||
SDL_bool hasEvents = SDL_FALSE;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
hasEvents = SDL_TRUE;
|
||||
if (event.type == SDL_QUIT) {
|
||||
done = 1;
|
||||
}
|
||||
@@ -466,10 +469,17 @@ main(int argc, char *argv[])
|
||||
spawnEmitterParticle(x, y);
|
||||
}
|
||||
}
|
||||
stepParticles(deltaTime);
|
||||
drawParticles();
|
||||
SDL_GL_SwapWindow(window);
|
||||
SDL_Delay(1);
|
||||
|
||||
/* Only update and render if we have active particles or just received events */
|
||||
if (num_active_particles > 0 || hasEvents) {
|
||||
stepParticles(deltaTime);
|
||||
drawParticles();
|
||||
SDL_GL_SwapWindow(window);
|
||||
SDL_Delay(16); // Target 60 FPS when active
|
||||
} else {
|
||||
/* Idle state - wait for events with longer delay to save CPU */
|
||||
SDL_Delay(100); // Much longer delay when idle
|
||||
}
|
||||
}
|
||||
|
||||
/* delete textures */
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.32.0</string>
|
||||
<string>2.32.11</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.32.0</string>
|
||||
<string>2.32.11</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -9729,7 +9729,7 @@
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.11.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.32.0;
|
||||
MARKETING_VERSION = 2.32.11;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Release;
|
||||
@@ -9814,7 +9814,7 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.11.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.32.0;
|
||||
MARKETING_VERSION = 2.32.11;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -10063,7 +10063,7 @@
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.11.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 = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3201.11.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Title SDL 2.32.0
|
||||
Title SDL 2.32.11
|
||||
Version 1
|
||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
||||
@@ -11,15 +11,15 @@ android {
|
||||
if (buildAsApplication) {
|
||||
namespace "org.libsdl.app"
|
||||
}
|
||||
compileSdkVersion 34
|
||||
compileSdkVersion 35
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 34
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 35
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
arguments "APP_PLATFORM=android-19"
|
||||
arguments "APP_PLATFORM=android-21"
|
||||
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||
}
|
||||
// cmake {
|
||||
|
||||
@@ -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 = 32;
|
||||
private static final int SDL_MICRO_VERSION = 0;
|
||||
private static final int SDL_MICRO_VERSION = 11;
|
||||
/*
|
||||
// Display InputType.SOURCE/CLASS of events and devices
|
||||
//
|
||||
|
||||
@@ -6,7 +6,7 @@ buildscript {
|
||||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.1.1'
|
||||
classpath 'com.android.tools.build:gradle:8.6.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Thu Nov 11 18:20:34 PST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
Vendored
+10
-7
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2024-07-27'
|
||||
timestamp='2025-07-10'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -60,7 +60,7 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -1597,8 +1597,11 @@ EOF
|
||||
*:Unleashed:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
|
||||
;;
|
||||
*:Ironclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-ironclad
|
||||
x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-pc-ironclad-mlibc
|
||||
;;
|
||||
*:[Ii]ronclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-ironclad-mlibc
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1808,8 +1811,8 @@ fi
|
||||
exit 1
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "timestamp='"
|
||||
# time-stamp-format: "%:y-%02m-%02d"
|
||||
# time-stamp-format: "%Y-%02m-%02d"
|
||||
# time-stamp-end: "'"
|
||||
# End:
|
||||
Vendored
+19
-9
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
|
||||
|
||||
timestamp='2024-05-27'
|
||||
timestamp='2025-07-10'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -76,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
|
||||
@@ -145,6 +145,7 @@ case $1 in
|
||||
| kfreebsd*-gnu* \
|
||||
| knetbsd*-gnu* \
|
||||
| kopensolaris*-gnu* \
|
||||
| ironclad-* \
|
||||
| linux-* \
|
||||
| managarm-* \
|
||||
| netbsd*-eabi* \
|
||||
@@ -242,7 +243,6 @@ case $1 in
|
||||
| rombug \
|
||||
| semi \
|
||||
| sequent* \
|
||||
| siemens \
|
||||
| sgi* \
|
||||
| siemens \
|
||||
| sim \
|
||||
@@ -261,7 +261,7 @@ case $1 in
|
||||
basic_machine=$field1-$field2
|
||||
basic_os=
|
||||
;;
|
||||
zephyr*)
|
||||
tock* | zephyr*)
|
||||
basic_machine=$field1-unknown
|
||||
basic_os=$field2
|
||||
;;
|
||||
@@ -1194,7 +1194,7 @@ case $cpu-$vendor in
|
||||
xscale-* | xscalee[bl]-*)
|
||||
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
|
||||
;;
|
||||
arm64-* | aarch64le-*)
|
||||
arm64-* | aarch64le-* | arm64_32-*)
|
||||
cpu=aarch64
|
||||
;;
|
||||
|
||||
@@ -1321,6 +1321,7 @@ case $cpu-$vendor in
|
||||
| i960 \
|
||||
| ia16 \
|
||||
| ia64 \
|
||||
| intelgt \
|
||||
| ip2k \
|
||||
| iq2000 \
|
||||
| javascript \
|
||||
@@ -1522,6 +1523,10 @@ EOF
|
||||
kernel=nto
|
||||
os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
|
||||
;;
|
||||
ironclad*)
|
||||
kernel=ironclad
|
||||
os=`echo "$basic_os" | sed -e 's|ironclad|mlibc|'`
|
||||
;;
|
||||
linux*)
|
||||
kernel=linux
|
||||
os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
|
||||
@@ -1976,6 +1981,7 @@ case $os in
|
||||
| atheos* \
|
||||
| auroraux* \
|
||||
| aux* \
|
||||
| banan_os* \
|
||||
| beos* \
|
||||
| bitrig* \
|
||||
| bme* \
|
||||
@@ -2022,7 +2028,6 @@ case $os in
|
||||
| ios* \
|
||||
| iris* \
|
||||
| irix* \
|
||||
| ironclad* \
|
||||
| isc* \
|
||||
| its* \
|
||||
| l4re* \
|
||||
@@ -2118,6 +2123,7 @@ case $os in
|
||||
| sysv* \
|
||||
| tenex* \
|
||||
| tirtos* \
|
||||
| tock* \
|
||||
| toppers* \
|
||||
| tops10* \
|
||||
| tops20* \
|
||||
@@ -2214,6 +2220,8 @@ case $kernel-$os-$obj in
|
||||
;;
|
||||
uclinux-uclibc*- | uclinux-gnu*- )
|
||||
;;
|
||||
ironclad-mlibc*-)
|
||||
;;
|
||||
managarm-mlibc*- | managarm-kernel*- )
|
||||
;;
|
||||
windows*-msvc*-)
|
||||
@@ -2249,6 +2257,8 @@ case $kernel-$os-$obj in
|
||||
;;
|
||||
*-eabi*- | *-gnueabi*-)
|
||||
;;
|
||||
ios*-simulator- | tvos*-simulator- | watchos*-simulator- )
|
||||
;;
|
||||
none--*)
|
||||
# None (no kernel, i.e. freestanding / bare metal),
|
||||
# can be paired with an machine code file format
|
||||
@@ -2347,8 +2357,8 @@ echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
|
||||
exit
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "timestamp='"
|
||||
# time-stamp-format: "%:y-%02m-%02d"
|
||||
# time-stamp-format: "%Y-%02m-%02d"
|
||||
# time-stamp-end: "'"
|
||||
# End:
|
||||
@@ -966,7 +966,7 @@ macro(CheckPTHREAD)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
|
||||
set(PTHREAD_LDFLAGS "-mt -lpthread")
|
||||
else()
|
||||
set(PTHREAD_LDFLAGS "-pthread -lposix4")
|
||||
set(PTHREAD_LDFLAGS "-pthread")
|
||||
endif()
|
||||
elseif(SYSV5)
|
||||
set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
|
||||
|
||||
@@ -3516,7 +3516,7 @@ orig_CFLAGS="$CFLAGS"
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=32
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_MICRO_VERSION=11
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
@@ -19755,6 +19755,12 @@ if test "x$ac_cv_func_sigaction" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "sigtimedwait" "ac_cv_func_sigtimedwait"
|
||||
if test "x$ac_cv_func_sigtimedwait" = xyes
|
||||
then :
|
||||
printf "%s\n" "#define HAVE_SIGTIMEDWAIT 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
ac_fn_c_check_func "$LINENO" "setjmp" "ac_cv_func_setjmp"
|
||||
if test "x$ac_cv_func_setjmp" = xyes
|
||||
@@ -22422,7 +22428,6 @@ printf %s "checking for NAS audio support... " >&6; }
|
||||
have_nas=yes
|
||||
NAS_CFLAGS="-I/usr/X11R6/include/"
|
||||
NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
|
||||
|
||||
fi
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_nas" >&5
|
||||
@@ -28394,7 +28399,8 @@ fi
|
||||
|
||||
if test x$hidapi_support = xyes; then
|
||||
if test x$have_libusb_h = xyes; then
|
||||
printf "%s\n" "#define HAVE_LIBUSB 1" >>confdefs.h
|
||||
|
||||
printf "%s\n" "#define HAVE_LIBUSB 1" >>confdefs.h
|
||||
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
|
||||
if test x$require_hidapi_libusb = xyes; then
|
||||
@@ -28741,12 +28747,23 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h
|
||||
if test x$enable_audio = xyes; then
|
||||
case $ARCH in
|
||||
sysv5|solaris|hpux)
|
||||
# Newer Solaris-based systems, like OpenIndiana, don't have this interface anymore. Check for the header first.
|
||||
ac_fn_c_check_header_compile "$LINENO" "sys/audioio.h" "ac_cv_header_sys_audioio_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_sys_audioio_h" = xyes
|
||||
then :
|
||||
have_sys_audioio_h=yes
|
||||
else $as_nop
|
||||
have_sys_audioio_h=no
|
||||
fi
|
||||
|
||||
if test x$have_sys_audioio_h = xyes; then
|
||||
|
||||
printf "%s\n" "#define SDL_AUDIO_DRIVER_SUNAUDIO 1" >>confdefs.h
|
||||
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
fi
|
||||
;;
|
||||
netbsd) # Don't use this on OpenBSD, it's busted.
|
||||
|
||||
|
||||
+11
-8
@@ -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=32
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_MICRO_VERSION=11
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||
@@ -359,7 +359,7 @@ dnl Checks for library functions.
|
||||
AC_DEFINE(HAVE_MPROTECT, 1, [ ])
|
||||
],[]),
|
||||
)
|
||||
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _Exit)
|
||||
AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction sigtimedwait setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _Exit)
|
||||
|
||||
AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
|
||||
AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
|
||||
@@ -1247,7 +1247,6 @@ CheckNAS()
|
||||
have_nas=yes
|
||||
NAS_CFLAGS="-I/usr/X11R6/include/"
|
||||
NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT($have_nas)
|
||||
@@ -3636,7 +3635,7 @@ CheckHIDAPI()
|
||||
|
||||
if test x$hidapi_support = xyes; then
|
||||
if test x$have_libusb_h = xyes; then
|
||||
AC_DEFINE(HAVE_LIBUSB)
|
||||
AC_DEFINE(HAVE_LIBUSB, 1, [ ])
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
|
||||
if test x$require_hidapi_libusb = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
|
||||
@@ -3869,10 +3868,14 @@ case "$host" in
|
||||
if test x$enable_audio = xyes; then
|
||||
case $ARCH in
|
||||
sysv5|solaris|hpux)
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
# Newer Solaris-based systems, like OpenIndiana, don't have this interface anymore. Check for the header first.
|
||||
AC_CHECK_HEADER(sys/audioio.h, have_sys_audioio_h=yes, have_sys_audioio_h=no)
|
||||
if test x$have_sys_audioio_h = xyes; then
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
fi
|
||||
;;
|
||||
netbsd) # Don't use this on OpenBSD, it's busted.
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])
|
||||
|
||||
+5
-1
@@ -11,7 +11,7 @@ Credit to
|
||||
## Building
|
||||
To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run:
|
||||
```bash
|
||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake
|
||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev.cmake
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
@@ -19,6 +19,10 @@ cmake --install build
|
||||
## Hints
|
||||
The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`.
|
||||
If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30.
|
||||
- `SDL_HINT_PS2_GS_WIDTH`: Width of the framebuffer. Defaults to 640.
|
||||
- `SDL_HINT_PS2_GS_HEIGHT`: Height of the framebuffer. Defaults to 448.
|
||||
- `SDL_HINT_PS2_GS_PROGRESSIVE`: Whether to use progressive, instead of interlaced. Defaults to 0.
|
||||
- `SDL_HINT_PS2_GS_MODE`: Regional standard of the signal. "NTSC" (60hz), "PAL" (50hz) or "" (the console's region, default).
|
||||
|
||||
## Notes
|
||||
If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer.
|
||||
|
||||
@@ -153,7 +153,7 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
|
||||
#define SDL_enabled_assert(condition) \
|
||||
do { \
|
||||
while ( !(condition) ) { \
|
||||
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
|
||||
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, NULL, 0, NULL, NULL }; \
|
||||
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
|
||||
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
|
||||
continue; /* go again. */ \
|
||||
|
||||
@@ -193,6 +193,7 @@
|
||||
#cmakedefine HAVE_MEMFD_CREATE 1
|
||||
#cmakedefine HAVE_POSIX_FALLOCATE 1
|
||||
#cmakedefine HAVE_SIGACTION 1
|
||||
#cmakedefine HAVE_SIGTIMEDWAIT 1
|
||||
#cmakedefine HAVE_SA_SIGACTION 1
|
||||
#cmakedefine HAVE_SETJMP 1
|
||||
#cmakedefine HAVE_NANOSLEEP 1
|
||||
|
||||
@@ -195,6 +195,7 @@
|
||||
#undef HAVE_FSEEKO
|
||||
#undef HAVE_FSEEKO64
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_SIGTIMEDWAIT
|
||||
#undef HAVE_SA_SIGACTION
|
||||
#undef HAVE_SETJMP
|
||||
#undef HAVE_NANOSLEEP
|
||||
@@ -216,6 +217,7 @@
|
||||
#undef HAVE__EXIT
|
||||
|
||||
#else
|
||||
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDDEF_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
@@ -115,7 +115,8 @@ _m_prefetch(void *__P)
|
||||
#include <lasxintrin.h>
|
||||
#define __LASX__
|
||||
#endif
|
||||
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
|
||||
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) && \
|
||||
(defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86))
|
||||
#include <immintrin.h>
|
||||
#else
|
||||
#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version,
|
||||
so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */
|
||||
#ifdef __clang__
|
||||
#if defined(__clang__) && !_SDL_HAS_BUILTIN(_m_prefetch)
|
||||
#ifndef __PRFCHWINTRIN_H
|
||||
#define __PRFCHWINTRIN_H
|
||||
static __inline__ void __attribute__((__always_inline__, __nodebug__))
|
||||
|
||||
+54
-2
@@ -1262,8 +1262,8 @@ extern "C" {
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
*
|
||||
* - "0": RAWINPUT drivers are not used
|
||||
* - "1": RAWINPUT drivers are used (the default)
|
||||
* - "0": RAWINPUT drivers are not used (the default)
|
||||
* - "1": RAWINPUT drivers are used
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_RAWINPUT "SDL_JOYSTICK_RAWINPUT"
|
||||
|
||||
@@ -1423,6 +1423,27 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_DEVICE "SDL_JOYSTICK_DEVICE"
|
||||
|
||||
|
||||
/**
|
||||
* A variable containing a list of devices and their desired number of haptic
|
||||
* (force feedback) enabled axis.
|
||||
*
|
||||
* The format of the string is a comma separated list of USB VID/PID pairs in
|
||||
* hexadecimal form plus the number of desired axes, e.g.
|
||||
*
|
||||
* `0xAAAA/0xBBBB/1,0xCCCC/0xDDDD/3`
|
||||
*
|
||||
* This hint supports a "wildcard" device that will set the number of haptic
|
||||
* axes on all initialized haptic devices which were not defined explicitly in
|
||||
* this hint.
|
||||
*
|
||||
* `0xFFFF/0xFFFF/1`
|
||||
*
|
||||
* This hint should be set before a controller is opened. The number of haptic
|
||||
* axes won't exceed the number of real axes found on the device.
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HAPTIC_AXES "SDL_JOYSTICK_HAPTIC_AXES"
|
||||
|
||||
/**
|
||||
* A variable controlling whether joysticks on Linux will always treat 'hat'
|
||||
* axis inputs (ABS_HAT0X - ABS_HAT3Y) as 8-way digital hats without checking
|
||||
@@ -2003,6 +2024,37 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED"
|
||||
|
||||
/**
|
||||
* Variable controlling the width of the PS2's framebuffer in pixels
|
||||
*
|
||||
* By default, this variable is "640"
|
||||
*/
|
||||
#define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH"
|
||||
|
||||
/**
|
||||
* Variable controlling the height of the PS2's framebuffer in pixels
|
||||
*
|
||||
* By default, this variable is "448"
|
||||
*/
|
||||
#define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT"
|
||||
|
||||
/**
|
||||
* Variable controlling whether the signal is interlaced or progressive
|
||||
*
|
||||
* - "0": Image is interlaced. (default)
|
||||
* - "1": Image is progressive
|
||||
*/
|
||||
#define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE"
|
||||
|
||||
/**
|
||||
* Variable controlling the video mode of the console
|
||||
*
|
||||
* - "": Console-native. (default)
|
||||
* - "NTSC": 60hz region
|
||||
* - "PAL": 50hz region
|
||||
*/
|
||||
#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE"
|
||||
|
||||
/**
|
||||
* A variable controlling if VSYNC is automatically disable if doesn't reach
|
||||
* the enough FPS
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef struct SDL_Keysym
|
||||
{
|
||||
SDL_Scancode scancode; /**< SDL physical key code - see SDL_Scancode for details */
|
||||
SDL_Keycode sym; /**< SDL virtual key code - see SDL_Keycode for details */
|
||||
Uint16 mod; /**< current key modifiers */
|
||||
Uint16 mod; /**< current key modifiers - see SDL_Keymod for details */
|
||||
Uint32 unused;
|
||||
} SDL_Keysym;
|
||||
|
||||
@@ -255,7 +255,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
|
||||
* On some platforms using this function activates the screen keyboard.
|
||||
*
|
||||
* On desktop platforms, SDL_StartTextInput() is implicitly called on SDL
|
||||
* window creation which will cause events SDL_TextInputEvent and
|
||||
* video subsystem initialization which will cause SDL_TextInputEvent and
|
||||
* SDL_TextEditingEvent to begin emitting.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
|
||||
@@ -244,7 +244,7 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_CreateRenderer
|
||||
* \sa SDL_CreateWindowRenderer
|
||||
* \sa SDL_CreateWindowAndRenderer
|
||||
* \sa SDL_DestroyRenderer
|
||||
*/
|
||||
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
|
||||
@@ -787,7 +787,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
|
||||
* Get the current render target.
|
||||
*
|
||||
* The default render target is the window for which the renderer was created,
|
||||
* and is reported a NULL here.
|
||||
* and is reported as NULL here.
|
||||
*
|
||||
* \param renderer the rendering context.
|
||||
* \returns the current render target or NULL for the default render target.
|
||||
|
||||
@@ -565,6 +565,7 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
return;
|
||||
}
|
||||
switch (dwords % 4) {
|
||||
default:
|
||||
case 0: do { *_p++ = _val; SDL_FALLTHROUGH;
|
||||
case 3: *_p++ = _val; SDL_FALLTHROUGH;
|
||||
case 2: *_p++ = _val; SDL_FALLTHROUGH;
|
||||
@@ -750,8 +751,12 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
|
||||
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
/* strdup is not ANSI but POSIX, and its prototype might be hidden... */
|
||||
/* not for windows: might conflict with string.h where strdup may have
|
||||
* dllimport attribute: https://github.com/libsdl-org/SDL/issues/12948 */
|
||||
char *strdup(const char *str);
|
||||
#endif
|
||||
|
||||
/* Starting LLVM 16, the analyser errors out if these functions do not have
|
||||
their prototype defined (clang-diagnostic-implicit-function-declaration) */
|
||||
|
||||
@@ -808,8 +808,8 @@ extern DECLSPEC int SDLCALL SDL_FillRects
|
||||
*
|
||||
* This assumes that the source and destination rectangles are the same size.
|
||||
* If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
|
||||
* `dst`) is copied. The final blit rectangles are saved in `srcrect` and
|
||||
* `dstrect` after all clipping is performed.
|
||||
* `dst`) is copied. The final blit rectangle is saved in `dstrect` after
|
||||
* all clipping is performed.
|
||||
*
|
||||
* The blit function should not be called on a locked surface.
|
||||
*
|
||||
|
||||
@@ -58,7 +58,7 @@ typedef struct SDL_version
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 32
|
||||
#define SDL_PATCHLEVEL 0
|
||||
#define SDL_PATCHLEVEL 11
|
||||
|
||||
/**
|
||||
* Macro to determine SDL version program was compiled against.
|
||||
|
||||
+15
-18
@@ -42,15 +42,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#include <emscripten.h>
|
||||
/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
|
||||
#ifndef MAIN_THREAD_EM_ASM_PTR
|
||||
#ifdef __wasm64__
|
||||
#error You need to upgrade your Emscripten compiler to support wasm64
|
||||
#else
|
||||
#define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
|
||||
#endif
|
||||
#endif
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
/* The size of the stack buffer to use for rendering assert messages. */
|
||||
@@ -259,7 +251,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
||||
for (;;) {
|
||||
SDL_bool okay = SDL_TRUE;
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({
|
||||
int reply = MAIN_THREAD_EM_ASM_INT({
|
||||
var str =
|
||||
UTF8ToString($0) + '\n\n' +
|
||||
'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :';
|
||||
@@ -267,26 +259,31 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
||||
if (reply === null) {
|
||||
reply = "i";
|
||||
}
|
||||
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
|
||||
return reply.length === 1 ? reply.charCodeAt(0) : -1;
|
||||
}, message);
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
|
||||
if (SDL_strcmp(buf, "a") == 0) {
|
||||
switch (reply) {
|
||||
case 'a':
|
||||
state = SDL_ASSERTION_ABORT;
|
||||
#if 0 /* (currently) no break functionality on Emscripten */
|
||||
} else if (SDL_strcmp(buf, "b") == 0) {
|
||||
case 'b':
|
||||
state = SDL_ASSERTION_BREAK;
|
||||
break;
|
||||
#endif
|
||||
} else if (SDL_strcmp(buf, "r") == 0) {
|
||||
case 'r':
|
||||
state = SDL_ASSERTION_RETRY;
|
||||
} else if (SDL_strcmp(buf, "i") == 0) {
|
||||
break;
|
||||
case 'i':
|
||||
state = SDL_ASSERTION_IGNORE;
|
||||
} else if (SDL_strcmp(buf, "A") == 0) {
|
||||
break;
|
||||
case 'A':
|
||||
state = SDL_ASSERTION_ALWAYS_IGNORE;
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
okay = SDL_FALSE;
|
||||
break;
|
||||
}
|
||||
free(buf);
|
||||
|
||||
if (okay) {
|
||||
break;
|
||||
|
||||
@@ -678,6 +678,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
|
||||
int data_len = 0;
|
||||
Uint8 *data;
|
||||
Uint8 *device_buf_keepsafe = NULL;
|
||||
Uint32 delay;
|
||||
|
||||
SDL_assert(!device->iscapture);
|
||||
|
||||
@@ -761,7 +762,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
|
||||
SDL_assert((got <= 0) || (got == device->spec.size));
|
||||
|
||||
if (data == NULL) { /* device is having issues... */
|
||||
const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
|
||||
delay = ((device->spec.samples * 1000) / device->spec.freq);
|
||||
SDL_Delay(delay); /* wait for as long as this buffer would have played. Maybe device recovers later? */
|
||||
} else {
|
||||
if (got != device->spec.size) {
|
||||
@@ -781,7 +782,7 @@ static int SDLCALL SDL_RunAudio(void *userdata)
|
||||
}
|
||||
} else if (data == device->work_buffer) {
|
||||
/* nothing to do; pause like we queued a buffer to play. */
|
||||
const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
|
||||
delay = ((device->spec.samples * 1000) / device->spec.freq);
|
||||
SDL_Delay(delay);
|
||||
} else { /* writing directly to the device. */
|
||||
/* queue this buffer and wait for it to finish playing. */
|
||||
@@ -791,7 +792,11 @@ static int SDLCALL SDL_RunAudio(void *userdata)
|
||||
}
|
||||
|
||||
/* Wait for the audio to drain. */
|
||||
SDL_Delay(((device->spec.samples * 1000) / device->spec.freq) * 2);
|
||||
delay = ((device->spec.samples * 1000) / device->spec.freq) * 2;
|
||||
if (delay > 100) {
|
||||
delay = 100;
|
||||
}
|
||||
SDL_Delay(delay);
|
||||
|
||||
current_audio.impl.ThreadDeinit(device);
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ static int (*ALSA_snd_pcm_hw_params_set_access)(snd_pcm_t *, snd_pcm_hw_params_t
|
||||
static int (*ALSA_snd_pcm_hw_params_set_format)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_format_t);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_channels)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_channels)(const snd_pcm_hw_params_t *, unsigned int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_rate)(const snd_pcm_hw_params_t *, unsigned int*, int*);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_rate_near)(snd_pcm_t *, snd_pcm_hw_params_t *, unsigned int *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_set_period_size_near)(snd_pcm_t *, snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
|
||||
static int (*ALSA_snd_pcm_hw_params_get_period_size)(const snd_pcm_hw_params_t *, snd_pcm_uframes_t *, int *);
|
||||
@@ -83,6 +84,12 @@ static int (*ALSA_snd_device_name_hint)(int, const char *, void ***);
|
||||
static char *(*ALSA_snd_device_name_get_hint)(const void *, const char *);
|
||||
static int (*ALSA_snd_device_name_free_hint)(void **);
|
||||
static snd_pcm_sframes_t (*ALSA_snd_pcm_avail)(snd_pcm_t *);
|
||||
static int (*ALSA_snd_pcm_info)(snd_pcm_t *, snd_pcm_info_t *);
|
||||
static const char *(*ALSA_snd_pcm_info_get_name)(const snd_pcm_info_t *);
|
||||
static int (*ALSA_snd_pcm_info_get_card)(const snd_pcm_info_t *);
|
||||
static int (*ALSA_snd_card_get_name)(int, char **);
|
||||
static int (*ALSA_snd_pcm_info_malloc)(snd_pcm_info_t **);
|
||||
static void (*ALSA_snd_pcm_info_free)(snd_pcm_info_t *);
|
||||
#ifdef SND_CHMAP_API_VERSION
|
||||
static snd_pcm_chmap_t *(*ALSA_snd_pcm_get_chmap)(snd_pcm_t *);
|
||||
static int (*ALSA_snd_pcm_chmap_print)(const snd_pcm_chmap_t *map, size_t maxlen, char *buf);
|
||||
@@ -132,6 +139,7 @@ static int load_alsa_syms(void)
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_format);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_channels);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_channels);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_rate);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_rate_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_set_period_size_near);
|
||||
SDL_ALSA_SYM(snd_pcm_hw_params_get_period_size);
|
||||
@@ -152,6 +160,12 @@ static int load_alsa_syms(void)
|
||||
SDL_ALSA_SYM(snd_device_name_get_hint);
|
||||
SDL_ALSA_SYM(snd_device_name_free_hint);
|
||||
SDL_ALSA_SYM(snd_pcm_avail);
|
||||
SDL_ALSA_SYM(snd_pcm_info);
|
||||
SDL_ALSA_SYM(snd_pcm_info_get_card);
|
||||
SDL_ALSA_SYM(snd_pcm_info_get_name);
|
||||
SDL_ALSA_SYM(snd_card_get_name);
|
||||
SDL_ALSA_SYM(snd_pcm_info_malloc);
|
||||
SDL_ALSA_SYM(snd_pcm_info_free);
|
||||
#ifdef SND_CHMAP_API_VERSION
|
||||
SDL_ALSA_SYM(snd_pcm_get_chmap);
|
||||
SDL_ALSA_SYM(snd_pcm_chmap_print);
|
||||
@@ -458,6 +472,9 @@ static void ALSA_CloseDevice(_THIS)
|
||||
ALSA_snd_pcm_drop() can hang, so don't use that.
|
||||
*/
|
||||
Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2;
|
||||
if (delay > 100) {
|
||||
delay = 100;
|
||||
}
|
||||
SDL_Delay(delay);
|
||||
|
||||
ALSA_snd_pcm_close(this->hidden->pcm_handle);
|
||||
@@ -466,6 +483,58 @@ static void ALSA_CloseDevice(_THIS)
|
||||
SDL_free(this->hidden);
|
||||
}
|
||||
|
||||
static int ALSA_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
|
||||
{
|
||||
const char *device = "default";
|
||||
snd_pcm_t *pcm_handle;
|
||||
snd_pcm_info_t *pcm_info;
|
||||
snd_pcm_stream_t stream;
|
||||
int card_index;
|
||||
const char *dev_name;
|
||||
char *card_name = NULL;
|
||||
char final_name[256];
|
||||
|
||||
SDL_zero(final_name);
|
||||
stream = iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK;
|
||||
|
||||
if (ALSA_snd_pcm_open(&pcm_handle, device, stream, SND_PCM_NONBLOCK) < 0) {
|
||||
return SDL_SetError("ALSA: Couldn't open default device");
|
||||
}
|
||||
|
||||
if (ALSA_snd_pcm_info_malloc(&pcm_info) < 0) {
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return SDL_SetError("ALSA: Couldn't allocate pcm_info");
|
||||
}
|
||||
|
||||
if (ALSA_snd_pcm_info(pcm_handle, pcm_info) < 0) {
|
||||
ALSA_snd_pcm_info_free(pcm_info);
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return SDL_SetError("ALSA: Couldn't get PCM info");
|
||||
}
|
||||
|
||||
card_index = ALSA_snd_pcm_info_get_card(pcm_info);
|
||||
dev_name = ALSA_snd_pcm_info_get_name(pcm_info);
|
||||
|
||||
if (card_index >= 0 && ALSA_snd_card_get_name(card_index, &card_name) >= 0) {
|
||||
SDL_snprintf(final_name, sizeof(final_name), "%s, %s", card_name, dev_name);
|
||||
*name = SDL_strdup(final_name);
|
||||
} else {
|
||||
*name = SDL_strdup(dev_name ? dev_name : "Unknown ALSA Device");
|
||||
}
|
||||
|
||||
if (spec) {
|
||||
SDL_zero(*spec);
|
||||
spec->freq = 48000;
|
||||
spec->format = AUDIO_S16SYS;
|
||||
spec->channels = 2;
|
||||
spec->samples = 512;
|
||||
}
|
||||
|
||||
ALSA_snd_pcm_info_free(pcm_info);
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ALSA_set_buffer_size(_THIS, snd_pcm_hw_params_t *params)
|
||||
{
|
||||
int status;
|
||||
@@ -716,6 +785,16 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
|
||||
char *desc;
|
||||
char *handle = NULL;
|
||||
char *ptr;
|
||||
snd_pcm_t *pcm_handle;
|
||||
snd_pcm_stream_t stream;
|
||||
snd_pcm_hw_params_t *hwparams;
|
||||
|
||||
unsigned int freq = 0;
|
||||
int dir;
|
||||
unsigned int channels = 0;
|
||||
snd_pcm_uframes_t samples = 0;
|
||||
|
||||
SDL_AudioSpec spec;
|
||||
|
||||
if (!dev) {
|
||||
return;
|
||||
@@ -755,12 +834,36 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
|
||||
SDL_free(dev);
|
||||
return;
|
||||
}
|
||||
stream = iscapture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK;
|
||||
|
||||
if (ALSA_snd_pcm_open(&pcm_handle, handle, stream, SND_PCM_NONBLOCK) < 0) {
|
||||
SDL_free(dev);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Note that spec is NULL, because we are required to open the device before
|
||||
* acquiring the mix format, making this information inaccessible at
|
||||
* enumeration time
|
||||
*/
|
||||
SDL_AddAudioDevice(iscapture, desc, NULL, handle);
|
||||
snd_pcm_hw_params_alloca(&hwparams);
|
||||
ALSA_snd_pcm_hw_params_any(pcm_handle, hwparams);
|
||||
|
||||
ALSA_snd_pcm_hw_params_get_rate(hwparams, &freq, &dir);
|
||||
ALSA_snd_pcm_hw_params_get_channels(hwparams, &channels);
|
||||
ALSA_snd_pcm_hw_params_get_period_size(hwparams, &samples, &dir);
|
||||
|
||||
ALSA_snd_pcm_close(pcm_handle);
|
||||
|
||||
/* Let's fill the spec */
|
||||
|
||||
spec.freq = freq;
|
||||
spec.channels = channels;
|
||||
spec.samples = samples;
|
||||
spec.silence = 0;
|
||||
spec.padding = 0;
|
||||
/* Can't calculate size yet because this is an exploratory device opening
|
||||
* so we don't know the sample format.
|
||||
* Probably AUDIO_S16SYS/SND_PCM_FORMAT_S16_LE would be a good default
|
||||
* if required.*/
|
||||
spec.size = 0;
|
||||
|
||||
SDL_AddAudioDevice(iscapture, desc, &spec, handle);
|
||||
if (hint) {
|
||||
free(desc);
|
||||
}
|
||||
@@ -975,6 +1078,7 @@ static SDL_bool ALSA_Init(SDL_AudioDriverImpl *impl)
|
||||
impl->Deinitialize = ALSA_Deinitialize;
|
||||
impl->CaptureFromDevice = ALSA_CaptureFromDevice;
|
||||
impl->FlushCapture = ALSA_FlushCapture;
|
||||
impl->GetDefaultAudioInfo = ALSA_GetDefaultAudioInfo;
|
||||
|
||||
impl->HasCaptureSupport = SDL_TRUE;
|
||||
impl->SupportsNonPow2Samples = SDL_TRUE;
|
||||
|
||||
@@ -383,7 +383,8 @@ static BOOL update_audio_session(_THIS, SDL_bool open, SDL_bool allow_playandrec
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_AUDIO_CATEGORY);
|
||||
if (hint) {
|
||||
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0) {
|
||||
if (SDL_strcasecmp(hint, "AVAudioSessionCategoryAmbient") == 0 ||
|
||||
SDL_strcasecmp(hint, "ambient") == 0) {
|
||||
category = AVAudioSessionCategoryAmbient;
|
||||
} else if (SDL_strcasecmp(hint, "AVAudioSessionCategorySoloAmbient") == 0) {
|
||||
category = AVAudioSessionCategorySoloAmbient;
|
||||
|
||||
@@ -310,7 +310,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; }
|
||||
audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0);
|
||||
SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer;
|
||||
dynCall('vi', $2, [$3]);
|
||||
dynCall('vp', $2, [$3]);
|
||||
};
|
||||
SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode);
|
||||
SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination);
|
||||
@@ -326,7 +326,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
|
||||
var silence_callback = function() {
|
||||
SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
|
||||
dynCall('vi', $2, [$3]);
|
||||
dynCall('vp', $2, [$3]);
|
||||
};
|
||||
|
||||
SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000);
|
||||
@@ -351,7 +351,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
SDL2.audio.silenceBuffer = undefined;
|
||||
}
|
||||
SDL2.audio.currentOutputBuffer = e['outputBuffer'];
|
||||
dynCall('vi', $2, [$3]);
|
||||
dynCall('vp', $2, [$3]);
|
||||
};
|
||||
|
||||
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
|
||||
@@ -369,7 +369,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
|
||||
// the buffer that gets filled here just gets ignored, so the app can make progress
|
||||
// and/or avoid flooding audio queues until we can actually play audio.
|
||||
SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer;
|
||||
dynCall('vi', $2, [$3]);
|
||||
dynCall('vp', $2, [$3]);
|
||||
SDL2.audio.currentOutputBuffer = undefined;
|
||||
};
|
||||
|
||||
|
||||
@@ -413,27 +413,32 @@ static int openslES_CreatePCMPlayer(_THIS)
|
||||
SLresult result;
|
||||
int i;
|
||||
|
||||
/* If we want to add floating point audio support (requires API level 21)
|
||||
it can be done as described here:
|
||||
https://developer.android.com/ndk/guides/audio/opensl/android-extensions.html#floating-point
|
||||
*/
|
||||
/* according to https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android,
|
||||
Android's OpenSL ES only supports Uint8 and _littleendian_ Sint16.
|
||||
(and float32, with an extension we use, below.) */
|
||||
if (SDL_GetAndroidSDKVersion() >= 21) {
|
||||
SDL_AudioFormat test_format;
|
||||
for (test_format = SDL_FirstAudioFormat(this->spec.format); test_format; test_format = SDL_NextAudioFormat()) {
|
||||
if (SDL_AUDIO_ISSIGNED(test_format)) {
|
||||
switch (test_format) {
|
||||
case AUDIO_U8:
|
||||
case AUDIO_S16LSB:
|
||||
case AUDIO_F32LSB:
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!test_format) {
|
||||
/* Didn't find a compatible format : */
|
||||
LOGI("No compatible audio format, using signed 16-bit audio");
|
||||
test_format = AUDIO_S16SYS;
|
||||
LOGI("No compatible audio format, using signed 16-bit LE audio");
|
||||
test_format = AUDIO_S16LSB;
|
||||
}
|
||||
this->spec.format = test_format;
|
||||
} else {
|
||||
/* Just go with signed 16-bit audio as it's the most compatible */
|
||||
this->spec.format = AUDIO_S16SYS;
|
||||
this->spec.format = AUDIO_S16LSB;
|
||||
}
|
||||
|
||||
/* Update the fragment size as size in bytes */
|
||||
|
||||
@@ -574,6 +574,25 @@ static SDL_bool get_int_param(const struct spa_pod *param, Uint32 key, int *val)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static SDL_AudioFormat SPAFormatToSDL(enum spa_audio_format spafmt)
|
||||
{
|
||||
switch (spafmt) {
|
||||
#define CHECKFMT(spa,sdl) case SPA_AUDIO_FORMAT_##spa: return AUDIO_##sdl
|
||||
CHECKFMT(U8, U8);
|
||||
CHECKFMT(S8, S8);
|
||||
CHECKFMT(S16_LE, S16LSB);
|
||||
CHECKFMT(S16_BE, S16MSB);
|
||||
CHECKFMT(S32_LE, S32LSB);
|
||||
CHECKFMT(S32_BE, S32MSB);
|
||||
CHECKFMT(F32_LE, F32LSB);
|
||||
CHECKFMT(F32_BE, F32MSB);
|
||||
#undef CHECKFMT
|
||||
default: break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Interface node callbacks */
|
||||
static void node_event_info(void *object, const struct pw_node_info *info)
|
||||
{
|
||||
@@ -590,7 +609,7 @@ static void node_event_info(void *object, const struct pw_node_info *info)
|
||||
|
||||
/* Need to parse the parameters to get the sample rate */
|
||||
for (i = 0; i < info->n_params; ++i) {
|
||||
pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL);
|
||||
pw_node_enum_params((struct pw_node*)node->proxy, 0, info->params[i].id, 0, 0, NULL);
|
||||
}
|
||||
|
||||
hotplug_core_sync(node);
|
||||
@@ -602,6 +621,15 @@ static void node_event_param(void *object, int seq, uint32_t id, uint32_t index,
|
||||
struct node_object *node = object;
|
||||
struct io_node *io = node->userdata;
|
||||
|
||||
if ((id == SPA_PARAM_Format) && (io->spec.format == 0)) {
|
||||
struct spa_audio_info_raw info;
|
||||
SDL_zero(info);
|
||||
if (spa_format_audio_raw_parse(param, &info) == 0) {
|
||||
/*SDL_Log("Sink Format: %d, Rate: %d Hz, Channels: %d", info.format, info.rate, info.channels);*/
|
||||
io->spec.format = SPAFormatToSDL(info.format);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the default frequency */
|
||||
if (io->spec.freq == 0) {
|
||||
get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL);
|
||||
@@ -719,7 +747,9 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
|
||||
/* Begin setting the node properties */
|
||||
io->id = id;
|
||||
io->is_capture = is_capture;
|
||||
io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */
|
||||
if (io->spec.format == 0) {
|
||||
io->spec.format = AUDIO_S16; /* we'll go conservative here if for some reason the format isn't known. */
|
||||
}
|
||||
io->name = io->buf;
|
||||
io->path = io->buf + desc_buffer_len;
|
||||
SDL_strlcpy(io->buf, node_desc, desc_buffer_len);
|
||||
|
||||
@@ -497,7 +497,7 @@ static void PULSEAUDIO_FlushCapture(_THIS)
|
||||
{
|
||||
struct SDL_PrivateAudioData *h = this->hidden;
|
||||
const void *data = NULL;
|
||||
size_t nbytes = 0;
|
||||
size_t nbytes = 0, buflen = 0;
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
|
||||
|
||||
@@ -507,19 +507,19 @@ static void PULSEAUDIO_FlushCapture(_THIS)
|
||||
h->capturelen = 0;
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&this->enabled) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) {
|
||||
buflen = PULSEAUDIO_pa_stream_readable_size(h->stream);
|
||||
while (SDL_AtomicGet(&this->enabled) && (buflen > 0)) {
|
||||
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);
|
||||
if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) {
|
||||
/*printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n");*/
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
break;
|
||||
}
|
||||
|
||||
if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) {
|
||||
/* a new fragment is available! Just dump it. */
|
||||
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
|
||||
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
|
||||
}
|
||||
/* a fragment of audio present before FlushCapture was call is
|
||||
available! Just drop it. */
|
||||
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
|
||||
PULSEAUDIO_pa_stream_drop(h->stream);
|
||||
buflen -= nbytes;
|
||||
}
|
||||
|
||||
PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop);
|
||||
|
||||
@@ -24,18 +24,12 @@
|
||||
|
||||
/* Allow access to a raw mixing buffer */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#ifdef __NETBSD__
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
#endif
|
||||
#ifdef __SVR4
|
||||
#include <sys/audioio.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
|
||||
@@ -424,9 +424,12 @@ static int device_class(struct udev_device *dev)
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
|
||||
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
|
||||
val && SDL_strcmp(val, "1") == 0) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
if (val && SDL_strcmp(val, "1") == 0) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_FALSE)) {
|
||||
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
|
||||
} else {
|
||||
devclass |= SDL_UDEV_DEVICE_ACCELEROMETER;
|
||||
}
|
||||
}
|
||||
|
||||
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
|
||||
|
||||
@@ -199,6 +199,24 @@ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WO
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOL WIN_IsWine(void)
|
||||
{
|
||||
static SDL_bool checked;
|
||||
static SDL_bool is_wine;
|
||||
|
||||
if (!checked) {
|
||||
HMODULE ntdll = LoadLibrary(TEXT("ntdll.dll"));
|
||||
if (ntdll) {
|
||||
if (GetProcAddress(ntdll, "wine_get_version") != NULL) {
|
||||
is_wine = SDL_TRUE;
|
||||
}
|
||||
FreeLibrary(ntdll);
|
||||
}
|
||||
checked = SDL_TRUE;
|
||||
}
|
||||
return is_wine;
|
||||
}
|
||||
|
||||
BOOL WIN_IsWindowsVistaOrGreater(void)
|
||||
{
|
||||
#if defined(__WINRT__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||
|
||||
@@ -136,6 +136,9 @@ extern void WIN_CoUninitialize(void);
|
||||
extern HRESULT WIN_RoInitialize(void);
|
||||
extern void WIN_RoUninitialize(void);
|
||||
|
||||
/* Returns true if we're running on Wine */
|
||||
extern BOOL WIN_IsWine(void);
|
||||
|
||||
/* Returns SDL_TRUE if we're running on Windows Vista and newer */
|
||||
extern BOOL WIN_IsWindowsVistaOrGreater(void);
|
||||
|
||||
|
||||
+17
-12
@@ -50,13 +50,12 @@
|
||||
#endif
|
||||
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
|
||||
#include <sys/sysctl.h> /* For AltiVec check */
|
||||
#elif defined(__OpenBSD__) && defined(__powerpc__)
|
||||
#elif defined(__OpenBSD__) && defined(__powerpc__) && !defined(HAVE_ELF_AUX_INFO)
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h> /* For AltiVec check */
|
||||
#include <machine/cpu.h>
|
||||
#elif defined(__FreeBSD__) && defined(__powerpc__)
|
||||
#elif defined(__FreeBSD__) && defined(__powerpc__) && defined(HAVE_ELF_AUX_INFO)
|
||||
#include <machine/cpu.h>
|
||||
#include <sys/auxv.h>
|
||||
#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
@@ -127,7 +126,11 @@
|
||||
#define CPU_CFG2_LSX (1 << 6)
|
||||
#define CPU_CFG2_LASX (1 << 7)
|
||||
|
||||
#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(__MACOSX__) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
|
||||
#if !defined(SDL_CPUINFO_DISABLED) && \
|
||||
!((defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))) && \
|
||||
!(defined(__FreeBSD__) && defined(__powerpc__)) && \
|
||||
!(defined(__LINUX__) && defined(__powerpc__) && defined(HAVE_GETAUXVAL)) && \
|
||||
defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
|
||||
/* This is the brute force way of detecting instruction sets...
|
||||
the idea is borrowed from the libmpeg2 library - thanks!
|
||||
*/
|
||||
@@ -339,7 +342,12 @@ static int CPU_haveAltiVec(void)
|
||||
{
|
||||
volatile int altivec = 0;
|
||||
#ifndef SDL_CPUINFO_DISABLED
|
||||
#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
|
||||
#if (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__powerpc__) && defined(HAVE_ELF_AUX_INFO)
|
||||
unsigned long cpufeatures = 0;
|
||||
elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
|
||||
altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
|
||||
return altivec;
|
||||
#elif (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
|
||||
#ifdef __OpenBSD__
|
||||
int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
|
||||
#else
|
||||
@@ -351,11 +359,8 @@ static int CPU_haveAltiVec(void)
|
||||
if (0 == error) {
|
||||
altivec = (hasVectorUnit != 0);
|
||||
}
|
||||
#elif defined(__FreeBSD__) && defined(__powerpc__)
|
||||
unsigned long cpufeatures = 0;
|
||||
elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures));
|
||||
altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC;
|
||||
return altivec;
|
||||
#elif defined(__LINUX__) && defined(__powerpc__) && defined(HAVE_GETAUXVAL)
|
||||
altivec = getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC;
|
||||
#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP)
|
||||
void (*handler)(int sig);
|
||||
handler = signal(SIGILL, illegal_instruction);
|
||||
@@ -483,8 +488,6 @@ static int CPU_haveNEON(void)
|
||||
return 0; /* assume anything else from Apple doesn't have NEON. */
|
||||
#elif !defined(__arm__)
|
||||
return 0; /* not an ARM CPU at all. */
|
||||
#elif defined(__OpenBSD__)
|
||||
return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */
|
||||
#elif defined(HAVE_ELF_AUX_INFO)
|
||||
unsigned long hasneon = 0;
|
||||
if (elf_aux_info(AT_HWCAP, (void *)&hasneon, (int)sizeof(hasneon)) != 0) {
|
||||
@@ -521,6 +524,8 @@ static int CPU_haveNEON(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#elif defined(__OpenBSD__)
|
||||
return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */
|
||||
#else
|
||||
#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
|
||||
return 0;
|
||||
|
||||
@@ -440,19 +440,24 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
||||
|
||||
static void SDL_InitDynamicAPILocked(void)
|
||||
{
|
||||
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
||||
SDL_bool use_internal = SDL_TRUE;
|
||||
|
||||
/* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
|
||||
/* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
|
||||
char envbuf[512]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
|
||||
const DWORD rc = GetEnvironmentVariableA(SDL_DYNAMIC_API_ENVVAR, envbuf, (DWORD) sizeof (envbuf));
|
||||
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
|
||||
#elif defined(__OS2__)
|
||||
char * libname;
|
||||
if (DosScanEnv(SDL_DYNAMIC_API_ENVVAR, &libname) != NO_ERROR) {
|
||||
libname = NULL;
|
||||
}
|
||||
#else
|
||||
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR);
|
||||
#endif
|
||||
|
||||
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
||||
SDL_bool use_internal = SDL_TRUE;
|
||||
|
||||
if (libname) {
|
||||
while (*libname && !entry) {
|
||||
char *ptr = libname;
|
||||
|
||||
+11
-28
@@ -738,21 +738,17 @@ static void SDL_CutEvent(SDL_EventEntry *entry)
|
||||
|
||||
static int SDL_SendWakeupEvent(void)
|
||||
{
|
||||
SDL_Window *wakeup_window;
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
if (_this == NULL || !_this->SendWakeupEvent) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_LockMutex(_this->wakeup_lock);
|
||||
{
|
||||
if (_this->wakeup_window) {
|
||||
_this->SendWakeupEvent(_this, _this->wakeup_window);
|
||||
|
||||
/* No more wakeup events needed until we enter a new wait */
|
||||
_this->wakeup_window = NULL;
|
||||
}
|
||||
/* We only want to do this once while waiting for an event, so set it to NULL atomically here */
|
||||
wakeup_window = (SDL_Window *)SDL_AtomicSetPtr(&_this->wakeup_window, NULL);
|
||||
if (wakeup_window) {
|
||||
_this->SendWakeupEvent(_this, wakeup_window);
|
||||
}
|
||||
SDL_UnlockMutex(_this->wakeup_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1009,18 +1005,7 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
|
||||
int status;
|
||||
SDL_PumpEventsInternal(SDL_TRUE);
|
||||
|
||||
SDL_LockMutex(_this->wakeup_lock);
|
||||
{
|
||||
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
/* If status == 0 we are going to block so wakeup will be needed. */
|
||||
if (status == 0) {
|
||||
_this->wakeup_window = wakeup_window;
|
||||
} else {
|
||||
_this->wakeup_window = NULL;
|
||||
}
|
||||
}
|
||||
SDL_UnlockMutex(_this->wakeup_lock);
|
||||
|
||||
status = SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
|
||||
if (status < 0) {
|
||||
/* Got an error: return */
|
||||
break;
|
||||
@@ -1033,8 +1018,6 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
|
||||
if (timeout > 0) {
|
||||
Uint32 elapsed = SDL_GetTicks() - start;
|
||||
if (elapsed >= (Uint32)timeout) {
|
||||
/* Set wakeup_window to NULL without holding the lock. */
|
||||
_this->wakeup_window = NULL;
|
||||
return 0;
|
||||
}
|
||||
loop_timeout = (int)((Uint32)timeout - elapsed);
|
||||
@@ -1049,9 +1032,9 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve
|
||||
}
|
||||
}
|
||||
|
||||
SDL_AtomicSetPtr(&_this->wakeup_window, wakeup_window);
|
||||
status = _this->WaitEventTimeout(_this, loop_timeout);
|
||||
/* Set wakeup_window to NULL without holding the lock. */
|
||||
_this->wakeup_window = NULL;
|
||||
SDL_AtomicSetPtr(&_this->wakeup_window, NULL);
|
||||
if (status == 0 && poll_interval != SDL_MAX_SINT16 && loop_timeout == poll_interval) {
|
||||
/* We may have woken up to poll. Try again */
|
||||
continue;
|
||||
@@ -1318,7 +1301,7 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
Uint8 lo = (type & 0xff);
|
||||
|
||||
if (SDL_disabled_events[hi] &&
|
||||
(SDL_disabled_events[hi]->bits[lo / 32] & (1 << (lo & 31)))) {
|
||||
(SDL_disabled_events[hi]->bits[lo / 32] & (1U << (lo & 31)))) {
|
||||
current_state = SDL_DISABLE;
|
||||
} else {
|
||||
current_state = SDL_ENABLE;
|
||||
@@ -1332,11 +1315,11 @@ Uint8 SDL_EventState(Uint32 type, int state)
|
||||
}
|
||||
/* Out of memory, nothing we can do... */
|
||||
if (SDL_disabled_events[hi]) {
|
||||
SDL_disabled_events[hi]->bits[lo / 32] |= (1 << (lo & 31));
|
||||
SDL_disabled_events[hi]->bits[lo / 32] |= (1U << (lo & 31));
|
||||
SDL_FlushEvent(type);
|
||||
}
|
||||
} else { // state == SDL_ENABLE
|
||||
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31));
|
||||
SDL_disabled_events[hi]->bits[lo / 32] &= ~(1U << (lo & 31));
|
||||
}
|
||||
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
|
||||
@@ -1121,6 +1121,15 @@ int SDL_WarpMouseGlobal(int x, int y)
|
||||
|
||||
static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
|
||||
{
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND
|
||||
SDL_VideoDevice *vid = SDL_GetVideoDevice();
|
||||
|
||||
/* Wayland can't warp the mouse, but uses this hint internally to deliver accelerated motion */
|
||||
if (SDL_strcmp(vid->name, "wayland") == 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mouse->WarpMouse) {
|
||||
/* Need this functionality for relative mode warp implementation */
|
||||
return SDL_FALSE;
|
||||
|
||||
@@ -49,8 +49,10 @@ static SDL_bool send_foregrounding_pending = SDL_FALSE;
|
||||
|
||||
static void SDL_HandleSIG(int sig)
|
||||
{
|
||||
/* Reset the signal handler */
|
||||
#ifndef HAVE_SIGACTION
|
||||
/* Reset the signal handler if it was installed with signal() */
|
||||
(void)signal(sig, SDL_HandleSIG);
|
||||
#endif
|
||||
|
||||
/* Send a quit event next time the event loop pumps. */
|
||||
/* We can't send it in signal handler; SDL_malloc() might be interrupted! */
|
||||
|
||||
@@ -23,6 +23,85 @@
|
||||
#include "SDL_syshaptic.h"
|
||||
#include "SDL_haptic_c.h"
|
||||
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_hints_c.h"
|
||||
|
||||
typedef struct SDL_Haptic_VIDPID_Naxes {
|
||||
Uint16 vid;
|
||||
Uint16 pid;
|
||||
Uint16 naxes;
|
||||
} SDL_Haptic_VIDPID_Naxes;
|
||||
|
||||
static void SDL_HapticLoadAxesList(SDL_Haptic_VIDPID_Naxes **entries, int *num_entries)
|
||||
{
|
||||
SDL_Haptic_VIDPID_Naxes entry;
|
||||
const char *spot;
|
||||
int length = 0;
|
||||
|
||||
spot = SDL_GetHint(SDL_HINT_JOYSTICK_HAPTIC_AXES);
|
||||
if (!spot)
|
||||
return;
|
||||
|
||||
while (SDL_sscanf(spot, "0x%hx/0x%hx/%hu%n", &entry.vid, &entry.pid, &entry.naxes, &length) == 3) {
|
||||
SDL_assert(length > 0);
|
||||
spot += length;
|
||||
length = 0;
|
||||
|
||||
if ((*num_entries % 8) == 0) {
|
||||
int new_max = *num_entries + 8;
|
||||
SDL_Haptic_VIDPID_Naxes *new_entries =
|
||||
(SDL_Haptic_VIDPID_Naxes *)SDL_realloc(*entries, new_max * sizeof(**entries));
|
||||
|
||||
// Out of memory, go with what we have already
|
||||
if (!new_entries)
|
||||
break;
|
||||
|
||||
*entries = new_entries;
|
||||
}
|
||||
(*entries)[(*num_entries)++] = entry;
|
||||
|
||||
if (spot[0] == ',')
|
||||
spot++;
|
||||
}
|
||||
}
|
||||
|
||||
// /* Return -1 if not found */
|
||||
static int SDL_HapticNaxesListIndex(struct SDL_Haptic_VIDPID_Naxes *entries, int num_entries, Uint16 vid, Uint16 pid)
|
||||
{
|
||||
int i;
|
||||
if (!entries)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < num_entries; ++i) {
|
||||
if (entries[i].vid == vid && entries[i].pid == pid)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check if device needs a custom number of naxes
|
||||
static int SDL_HapticGetNaxes(Uint16 vid, Uint16 pid)
|
||||
{
|
||||
int num_entries = 0, index = 0, naxes = -1;
|
||||
SDL_Haptic_VIDPID_Naxes *naxes_list = NULL;
|
||||
|
||||
SDL_HapticLoadAxesList(&naxes_list, &num_entries);
|
||||
if (!num_entries || !naxes_list)
|
||||
return -1;
|
||||
|
||||
// Perform "wildcard" pass
|
||||
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, 0xffff, 0xffff);
|
||||
if (index >= 0)
|
||||
naxes = naxes_list[index].naxes;
|
||||
|
||||
index = SDL_HapticNaxesListIndex(naxes_list, num_entries, vid, pid);
|
||||
if (index >= 0)
|
||||
naxes = naxes_list[index].naxes;
|
||||
|
||||
SDL_free(naxes_list);
|
||||
return naxes;
|
||||
}
|
||||
|
||||
/* Global for SDL_windowshaptic.c */
|
||||
#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT)
|
||||
@@ -258,6 +337,8 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_Haptic *haptic;
|
||||
SDL_Haptic *hapticlist;
|
||||
int naxes, general_axes;
|
||||
Uint16 vid, pid;
|
||||
|
||||
/* Make sure there is room. */
|
||||
if (SDL_NumHaptics() <= 0) {
|
||||
@@ -314,6 +395,18 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
vid = SDL_JoystickGetVendor(joystick);
|
||||
pid = SDL_JoystickGetProduct(joystick);
|
||||
general_axes = SDL_JoystickNumAxes(joystick);
|
||||
|
||||
naxes = SDL_HapticGetNaxes(vid, pid);
|
||||
if (naxes > 0)
|
||||
haptic->naxes = naxes;
|
||||
|
||||
// Limit to the actual number of axes found on the device
|
||||
if (general_axes >= 0 && naxes > general_axes)
|
||||
haptic->naxes = general_axes;
|
||||
|
||||
/* Add haptic to list */
|
||||
++haptic->ref_count;
|
||||
/* Link the haptic in the list */
|
||||
|
||||
+18
-15
@@ -630,11 +630,9 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL;
|
||||
|
||||
#ifdef SDL_JOYSTICK_HIDAPI_STEAMXBOX
|
||||
#define HAVE_DRIVER_BACKEND 1
|
||||
#else
|
||||
#define HAVE_DRIVER_BACKEND 0
|
||||
#endif
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
|
||||
/* DRIVER HIDAPI Implementation */
|
||||
|
||||
@@ -905,7 +903,7 @@ IsInWhitelist(Uint16 vendor, Uint16 product)
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND)
|
||||
#define use_libusb_whitelist_default SDL_TRUE
|
||||
#else
|
||||
#define use_libusb_whitelist_default SDL_FALSE
|
||||
@@ -951,7 +949,7 @@ static const struct hidapi_backend PLATFORM_Backend = {
|
||||
};
|
||||
#endif /* HAVE_PLATFORM_BACKEND */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
static const struct hidapi_backend DRIVER_Backend = {
|
||||
(void *)DRIVER_hid_write,
|
||||
(void *)DRIVER_hid_read_timeout,
|
||||
@@ -993,7 +991,7 @@ struct SDL_hid_device_
|
||||
};
|
||||
static char device_magic;
|
||||
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
|
||||
static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend)
|
||||
{
|
||||
@@ -1019,7 +1017,7 @@ static void DeleteHIDDeviceWrapper(SDL_hid_device *device)
|
||||
}
|
||||
|
||||
#ifndef SDL_HIDAPI_DISABLED
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
|
||||
#define COPY_IF_EXISTS(var) \
|
||||
if (pSrc->var != NULL) { \
|
||||
@@ -1249,12 +1247,12 @@ Uint32 SDL_hid_device_change_count(void)
|
||||
|
||||
struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id)
|
||||
{
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
#ifdef HAVE_LIBUSB
|
||||
struct SDL_hid_device_info *usb_devs = NULL;
|
||||
struct SDL_hid_device_info *usb_dev;
|
||||
#endif
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
struct SDL_hid_device_info *driver_devs = NULL;
|
||||
struct SDL_hid_device_info *driver_dev;
|
||||
#endif
|
||||
@@ -1309,7 +1307,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
|
||||
}
|
||||
#endif /* HAVE_LIBUSB */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
driver_devs = DRIVER_hid_enumerate(vendor_id, product_id);
|
||||
for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) {
|
||||
new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info));
|
||||
@@ -1339,6 +1337,11 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
|
||||
#endif
|
||||
#ifdef HAVE_LIBUSB
|
||||
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)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (raw_dev->vendor_id == usb_dev->vendor_id &&
|
||||
raw_dev->product_id == usb_dev->product_id &&
|
||||
(raw_dev->interface_number < 0 || raw_dev->interface_number == usb_dev->interface_number)) {
|
||||
@@ -1347,7 +1350,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) {
|
||||
if (raw_dev->vendor_id == driver_dev->vendor_id &&
|
||||
raw_dev->product_id == driver_dev->product_id &&
|
||||
@@ -1412,7 +1415,7 @@ void SDL_hid_free_enumeration(struct SDL_hid_device_info *devs)
|
||||
|
||||
SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
|
||||
{
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
void *pDevice = NULL;
|
||||
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
@@ -1428,7 +1431,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
|
||||
}
|
||||
#endif /* HAVE_PLATFORM_BACKEND */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
pDevice = DRIVER_hid_open(vendor_id, product_id, serial_number);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||
@@ -1451,7 +1454,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
|
||||
|
||||
SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */)
|
||||
{
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB)
|
||||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
void *pDevice = NULL;
|
||||
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
@@ -1467,7 +1470,7 @@ SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */
|
||||
}
|
||||
#endif /* HAVE_PLATFORM_BACKEND */
|
||||
|
||||
#if HAVE_DRIVER_BACKEND
|
||||
#ifdef HAVE_DRIVER_BACKEND
|
||||
pDevice = DRIVER_hid_open_path(path, bExclusive);
|
||||
if (pDevice != NULL) {
|
||||
return CreateHIDDeviceWrapper(pDevice, &DRIVER_Backend);
|
||||
|
||||
@@ -1135,11 +1135,14 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data,
|
||||
|
||||
void HID_API_EXPORT hid_close(hid_device *dev)
|
||||
{
|
||||
int disconnected;
|
||||
|
||||
if (!dev)
|
||||
return;
|
||||
|
||||
/* Disconnect the report callback before close. */
|
||||
if (!dev->disconnected) {
|
||||
disconnected = dev->disconnected;
|
||||
if (!disconnected) {
|
||||
IOHIDDeviceRegisterInputReportCallback(
|
||||
dev->device_handle, dev->input_report_buf, dev->max_input_report_len,
|
||||
NULL, dev);
|
||||
@@ -1163,7 +1166,7 @@ void HID_API_EXPORT hid_close(hid_device *dev)
|
||||
/* Close the OS handle to the device, but only if it's not
|
||||
been unplugged. If it's been unplugged, then calling
|
||||
IOHIDDeviceClose() will crash. */
|
||||
if (!dev->disconnected) {
|
||||
if (!disconnected) {
|
||||
IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeNone);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
#include "../events/SDL_events_c.h"
|
||||
#endif
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include "../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include "SDL_system.h"
|
||||
#endif
|
||||
@@ -1984,7 +1988,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index)
|
||||
SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
|
||||
{
|
||||
SDL_JoystickGUID joystick_guid = SDL_JoystickGetDeviceGUID(joystick_index);
|
||||
const char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
|
||||
char *mapping = SDL_GameControllerMappingForGUID(joystick_guid);
|
||||
char *type_string, *comma;
|
||||
SDL_GameControllerType type;
|
||||
if (mapping) {
|
||||
@@ -1999,8 +2003,10 @@ SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index)
|
||||
} else {
|
||||
type = SDL_GetGameControllerTypeFromString(type_string);
|
||||
}
|
||||
SDL_free(mapping);
|
||||
return type;
|
||||
}
|
||||
SDL_free(mapping);
|
||||
}
|
||||
return SDL_GetJoystickGameControllerTypeFromGUID(joystick_guid, SDL_JoystickNameForIndex(joystick_index));
|
||||
}
|
||||
@@ -2128,7 +2134,7 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
|
||||
|
||||
#ifdef __WIN32__
|
||||
if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE) &&
|
||||
SDL_GetHintBoolean("STEAM_COMPAT_PROTON", SDL_FALSE)) {
|
||||
WIN_IsWine()) {
|
||||
/* We are launched by Steam and running under Proton
|
||||
* We can't tell whether this controller is a Steam Virtual Gamepad,
|
||||
* so assume that Proton is doing the appropriate filtering of controllers
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef __LINUX__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE "SteamVirtualGamepadInfo"
|
||||
|
||||
@@ -123,6 +126,28 @@ static void AddVirtualGamepadInfo(int slot, SDL_SteamVirtualGamepadInfo *info)
|
||||
SDL_zerop(info);
|
||||
}
|
||||
|
||||
#ifdef __LINUX__
|
||||
static const char *SDL_GetExeName(void)
|
||||
{
|
||||
const char *proc_name = NULL;
|
||||
static char linkfile[1024];
|
||||
int linksize;
|
||||
const char *proc_path = "/proc/self/exe";
|
||||
|
||||
linksize = readlink(proc_path, linkfile, sizeof(linkfile) - 1);
|
||||
if (linksize > 0) {
|
||||
linkfile[linksize] = '\0';
|
||||
proc_name = SDL_strrchr(linkfile, '/');
|
||||
if (proc_name) {
|
||||
++proc_name;
|
||||
} else {
|
||||
proc_name = linkfile;
|
||||
}
|
||||
}
|
||||
return proc_name;
|
||||
}
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
void SDL_InitSteamVirtualGamepadInfo(void)
|
||||
{
|
||||
const char *file;
|
||||
@@ -131,6 +156,16 @@ void SDL_InitSteamVirtualGamepadInfo(void)
|
||||
|
||||
file = SDL_GetHint(SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE);
|
||||
if (file && *file) {
|
||||
#ifdef __LINUX__
|
||||
/* Older versions of Wine will blacklist the Steam Virtual Gamepad if
|
||||
* it appears to have the real controller's VID/PID, so ignore this.
|
||||
*/
|
||||
const char *exe = SDL_GetExeName();
|
||||
if (exe && SDL_strcmp(exe, "wine64-preloader") == 0) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Wine launched by Steam, ignoring %s", SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
SDL_steam_virtual_gamepad_info_file = SDL_strdup(file);
|
||||
}
|
||||
SDL_UpdateSteamVirtualGamepadInfo();
|
||||
|
||||
@@ -40,17 +40,18 @@ static int numjoysticks = 0;
|
||||
|
||||
static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData)
|
||||
{
|
||||
SDL_joylist_item *item;
|
||||
int i;
|
||||
|
||||
SDL_joylist_item *item;
|
||||
SDL_LockJoysticks();
|
||||
|
||||
if (JoystickByIndex(gamepadEvent->index) != NULL) {
|
||||
return 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item));
|
||||
if (!item) {
|
||||
return 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
SDL_zerop(item);
|
||||
@@ -59,14 +60,14 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep
|
||||
item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id);
|
||||
if (!item->name) {
|
||||
SDL_free(item);
|
||||
return 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
item->mapping = SDL_strdup(gamepadEvent->mapping);
|
||||
if (!item->mapping) {
|
||||
SDL_free(item->name);
|
||||
SDL_free(item);
|
||||
return 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
item->naxes = gamepadEvent->numAxes;
|
||||
@@ -103,6 +104,9 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep
|
||||
SDL_Log("Added joystick with index %d", item->index);
|
||||
#endif
|
||||
|
||||
done:
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -111,6 +115,8 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa
|
||||
SDL_joylist_item *item = SDL_joylist;
|
||||
SDL_joylist_item *prev = NULL;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
while (item) {
|
||||
if (item->index == gamepadEvent->index) {
|
||||
break;
|
||||
@@ -120,7 +126,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa
|
||||
}
|
||||
|
||||
if (!item) {
|
||||
return 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (item->joystick) {
|
||||
@@ -148,6 +154,10 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa
|
||||
SDL_free(item->name);
|
||||
SDL_free(item->mapping);
|
||||
SDL_free(item);
|
||||
|
||||
done:
|
||||
SDL_UnlockJoysticks();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -644,13 +644,6 @@ static void RotatePad(int *pX, int *pY, float flAngleInRad)
|
||||
*pX = (int)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY);
|
||||
*pY = (int)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY);
|
||||
}
|
||||
static void RotatePadShort(short *pX, short *pY, float flAngleInRad)
|
||||
{
|
||||
short int origX = *pX, origY = *pY;
|
||||
|
||||
*pX = (short)(SDL_cosf(flAngleInRad) * origX - SDL_sinf(flAngleInRad) * origY);
|
||||
*pY = (short)(SDL_sinf(flAngleInRad) * origX + SDL_cosf(flAngleInRad) * origY);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Format the first part of the state packet
|
||||
@@ -774,9 +767,16 @@ static void FormatStatePacketUntilGyro(SteamControllerStateInternal_t *pState, V
|
||||
//---------------------------------------------------------------------------
|
||||
static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, SteamControllerStateInternal_t *pState)
|
||||
{
|
||||
const float flRotationAngle = 0.261799f;
|
||||
int nLeftPadX;
|
||||
int nLeftPadY;
|
||||
int nRightPadX;
|
||||
int nRightPadY;
|
||||
int nPadOffset;
|
||||
uint32_t ucOptionDataMask;
|
||||
|
||||
// 15 degrees in rad
|
||||
const float flRotationAngle = 0.261799f;
|
||||
|
||||
pState->unPacketNum++;
|
||||
ucOptionDataMask = (*pData++ & 0xF0);
|
||||
ucOptionDataMask |= (uint32_t)(*pData++) << 8;
|
||||
@@ -805,7 +805,6 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLELeftTrackpadChunk) {
|
||||
int nLength = sizeof(pState->sLeftPadX) + sizeof(pState->sLeftPadY);
|
||||
int nPadOffset;
|
||||
SDL_memcpy(&pState->sLeftPadX, pData, nLength);
|
||||
if (pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK) {
|
||||
nPadOffset = 1000;
|
||||
@@ -813,14 +812,15 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sLeftPadX, &pState->sLeftPadY, -flRotationAngle);
|
||||
pState->sLeftPadX = clamp(pState->sLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sLeftPadY = clamp(pState->sLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
nLeftPadX = pState->sLeftPadX;
|
||||
nLeftPadY = pState->sLeftPadY;
|
||||
RotatePad(&nLeftPadX, &nLeftPadY, -flRotationAngle);
|
||||
pState->sLeftPadX = (short)clamp(nLeftPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sLeftPadY = (short)clamp(nLeftPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pData += nLength;
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLERightTrackpadChunk) {
|
||||
int nLength = sizeof(pState->sRightPadX) + sizeof(pState->sRightPadY);
|
||||
int nPadOffset = 0;
|
||||
|
||||
SDL_memcpy(&pState->sRightPadX, pData, nLength);
|
||||
|
||||
@@ -830,9 +830,11 @@ static bool UpdateBLESteamControllerState(const uint8_t *pData, int nDataSize, S
|
||||
nPadOffset = 0;
|
||||
}
|
||||
|
||||
RotatePadShort(&pState->sRightPadX, &pState->sRightPadY, flRotationAngle);
|
||||
pState->sRightPadX = clamp(pState->sRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sRightPadY = clamp(pState->sRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
nRightPadX = pState->sRightPadX;
|
||||
nRightPadY = pState->sRightPadY;
|
||||
RotatePad(&nRightPadX, &nRightPadY, flRotationAngle);
|
||||
pState->sRightPadX = (short)clamp(nRightPadX + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pState->sRightPadY = (short)clamp(nRightPadY + nPadOffset, SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
pData += nLength;
|
||||
}
|
||||
if (ucOptionDataMask & k_EBLEIMUAccelChunk) {
|
||||
|
||||
@@ -62,9 +62,7 @@
|
||||
#define SWITCH_GYRO_SCALE 14.2842f
|
||||
#define SWITCH_ACCEL_SCALE 4096.f
|
||||
|
||||
#define SWITCH_GYRO_SCALE_OFFSET 13371.0f
|
||||
#define SWITCH_GYRO_SCALE_MULT 936.0f
|
||||
#define SWITCH_ACCEL_SCALE_OFFSET 16384.0f
|
||||
#define SWITCH_ACCEL_SCALE_MULT 4.0f
|
||||
|
||||
typedef enum
|
||||
@@ -817,6 +815,8 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||
SwitchSubcommandInputPacket_t *factory_reply = NULL;
|
||||
SwitchSPIOpData_t readUserParams;
|
||||
SwitchSPIOpData_t readFactoryParams;
|
||||
const int MAX_ATTEMPTS = 3;
|
||||
int attempt;
|
||||
|
||||
/* Read User Calibration Info */
|
||||
readUserParams.unAddress = k_unSPIStickUserCalibrationStartOffset;
|
||||
@@ -829,8 +829,19 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
|
||||
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
|
||||
readFactoryParams.ucLength = k_unSPIStickFactoryCalibrationLength;
|
||||
|
||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) {
|
||||
return SDL_FALSE;
|
||||
for (attempt = 0; ; ++attempt) {
|
||||
if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (factory_reply->stickFactoryCalibration.opData.unAddress == k_unSPIStickFactoryCalibrationStartOffset) {
|
||||
/* We successfully read the calibration data */
|
||||
break;
|
||||
}
|
||||
|
||||
if (attempt == MAX_ATTEMPTS) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Automatically select the user calibration if magic bytes are set */
|
||||
@@ -912,6 +923,8 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
||||
if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply)) {
|
||||
Uint8 *pIMUScale;
|
||||
Sint16 sAccelRawX, sAccelRawY, sAccelRawZ, sGyroRawX, sGyroRawY, sGyroRawZ;
|
||||
Sint16 sAccelSensCoeffX, sAccelSensCoeffY, sAccelSensCoeffZ;
|
||||
Sint16 sGyroSensCoeffX, sGyroSensCoeffY, sGyroSensCoeffZ;
|
||||
|
||||
/* IMU scale gives us multipliers for converting raw values to real world values */
|
||||
pIMUScale = reply->spiReadData.rgucReadData;
|
||||
@@ -920,10 +933,18 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
||||
sAccelRawY = (pIMUScale[3] << 8) | pIMUScale[2];
|
||||
sAccelRawZ = (pIMUScale[5] << 8) | pIMUScale[4];
|
||||
|
||||
sAccelSensCoeffX = (pIMUScale[7] << 8) | pIMUScale[6];
|
||||
sAccelSensCoeffY = (pIMUScale[9] << 8) | pIMUScale[8];
|
||||
sAccelSensCoeffZ = (pIMUScale[11] << 8) | pIMUScale[10];
|
||||
|
||||
sGyroRawX = (pIMUScale[13] << 8) | pIMUScale[12];
|
||||
sGyroRawY = (pIMUScale[15] << 8) | pIMUScale[14];
|
||||
sGyroRawZ = (pIMUScale[17] << 8) | pIMUScale[16];
|
||||
|
||||
sGyroSensCoeffX = (pIMUScale[19] << 8) | pIMUScale[18];
|
||||
sGyroSensCoeffY = (pIMUScale[21] << 8) | pIMUScale[20];
|
||||
sGyroSensCoeffZ = (pIMUScale[23] << 8) | pIMUScale[22];
|
||||
|
||||
/* Check for user calibration data. If it's present and set, it'll override the factory settings */
|
||||
readParams.unAddress = k_unSPIIMUUserScaleStartOffset;
|
||||
readParams.ucLength = k_unSPIIMUUserScaleLength;
|
||||
@@ -940,14 +961,14 @@ static SDL_bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
|
||||
}
|
||||
|
||||
/* Accelerometer scale */
|
||||
ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
|
||||
ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
|
||||
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / (SWITCH_ACCEL_SCALE_OFFSET - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
||||
ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffX - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
|
||||
ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffY - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
|
||||
ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffZ - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
|
||||
|
||||
/* Gyro scale */
|
||||
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawX) * (float)M_PI / 180.0f;
|
||||
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawY) * (float)M_PI / 180.0f;
|
||||
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / (SWITCH_GYRO_SCALE_OFFSET - (float)sGyroRawZ) * (float)M_PI / 180.0f;
|
||||
ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffX - (float)sGyroRawX) * (float)M_PI / 180.0f;
|
||||
ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffY - (float)sGyroRawY) * (float)M_PI / 180.0f;
|
||||
ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffZ - (float)sGyroRawZ) * (float)M_PI / 180.0f;
|
||||
|
||||
} else {
|
||||
/* Use default values */
|
||||
@@ -969,15 +990,17 @@ static Sint16 ApplyStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, i
|
||||
{
|
||||
sRawValue -= ctx->m_StickCalData[nStick].axis[nAxis].sCenter;
|
||||
|
||||
if (sRawValue > ctx->m_StickExtents[nStick].axis[nAxis].sMax) {
|
||||
ctx->m_StickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||
if (sRawValue >= 0) {
|
||||
if (sRawValue > ctx->m_StickExtents[nStick].axis[nAxis].sMax) {
|
||||
ctx->m_StickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||
}
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_StickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16);
|
||||
} else {
|
||||
if (sRawValue < ctx->m_StickExtents[nStick].axis[nAxis].sMin) {
|
||||
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||
}
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0);
|
||||
}
|
||||
if (sRawValue < ctx->m_StickExtents[nStick].axis[nAxis].sMin) {
|
||||
ctx->m_StickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||
}
|
||||
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, ctx->m_StickExtents[nStick].axis[nAxis].sMax,
|
||||
SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
}
|
||||
|
||||
static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue)
|
||||
@@ -987,15 +1010,17 @@ static Sint16 ApplySimpleStickCalibration(SDL_DriverSwitch_Context *ctx, int nSt
|
||||
|
||||
sRawValue -= usJoystickCenter;
|
||||
|
||||
if (sRawValue > ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax) {
|
||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||
if (sRawValue >= 0) {
|
||||
if (sRawValue > ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax) {
|
||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax = sRawValue;
|
||||
}
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16);
|
||||
} else {
|
||||
if (sRawValue < ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin) {
|
||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||
}
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0);
|
||||
}
|
||||
if (sRawValue < ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin) {
|
||||
ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin = sRawValue;
|
||||
}
|
||||
|
||||
return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMin, ctx->m_SimpleStickExtents[nStick].axis[nAxis].sMax,
|
||||
SDL_MIN_SINT16, SDL_MAX_SINT16);
|
||||
}
|
||||
|
||||
static void SDLCALL SDL_GameControllerButtonReportingHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
|
||||
@@ -1426,6 +1451,10 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
|
||||
ctx->m_bSyncWrite = SDL_TRUE;
|
||||
|
||||
if (!ctx->m_bInputOnly) {
|
||||
#ifdef SDL_PLATFORM_MACOS
|
||||
// Wait for the OS to finish its handshake with the controller
|
||||
SDL_Delay(250);
|
||||
#endif
|
||||
GetInitialInputMode(ctx);
|
||||
ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode;
|
||||
|
||||
|
||||
@@ -822,11 +822,12 @@ SDL_bool HIDAPI_JoystickConnected(SDL_HIDAPI_Device *device, SDL_JoystickID *pJo
|
||||
|
||||
++SDL_HIDAPI_numjoysticks;
|
||||
|
||||
SDL_PrivateJoystickAdded(joystickID);
|
||||
|
||||
if (pJoystickID) {
|
||||
*pJoystickID = joystickID;
|
||||
}
|
||||
|
||||
SDL_PrivateJoystickAdded(joystickID);
|
||||
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
@@ -890,10 +891,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf
|
||||
return NULL;
|
||||
}
|
||||
device->magic = &SDL_HIDAPI_device_magic;
|
||||
device->path = SDL_strdup(info->path);
|
||||
if (!device->path) {
|
||||
SDL_free(device);
|
||||
return NULL;
|
||||
if (info->path) {
|
||||
device->path = SDL_strdup(info->path);
|
||||
}
|
||||
device->seen = SDL_TRUE;
|
||||
device->vendor_id = info->vendor_id;
|
||||
|
||||
@@ -908,9 +908,11 @@ static void RAWINPUT_AddDevice(HANDLE hDevice)
|
||||
char *product_string = NULL;
|
||||
WCHAR string[128];
|
||||
|
||||
string[0] = 0;
|
||||
if (SDL_HidD_GetManufacturerString(hFile, string, sizeof(string))) {
|
||||
manufacturer_string = WIN_StringToUTF8W(string);
|
||||
}
|
||||
string[0] = 0;
|
||||
if (SDL_HidD_GetProductString(hFile, string, sizeof(string))) {
|
||||
product_string = WIN_StringToUTF8W(string);
|
||||
}
|
||||
@@ -1025,7 +1027,7 @@ static int RAWINPUT_JoystickInit(void)
|
||||
{
|
||||
SDL_assert(!SDL_RAWINPUT_inited);
|
||||
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_TRUE)) {
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT, SDL_FALSE)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,32,0,0
|
||||
PRODUCTVERSION 2,32,0,0
|
||||
FILEVERSION 2,32,11,0
|
||||
PRODUCTVERSION 2,32,11,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS 0x40004L
|
||||
@@ -23,12 +23,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "\0"
|
||||
VALUE "FileDescription", "SDL\0"
|
||||
VALUE "FileVersion", "2, 32, 0, 0\0"
|
||||
VALUE "FileVersion", "2, 32, 11, 0\0"
|
||||
VALUE "InternalName", "SDL\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0"
|
||||
VALUE "OriginalFilename", "SDL2.dll\0"
|
||||
VALUE "ProductName", "Simple DirectMedia Layer\0"
|
||||
VALUE "ProductVersion", "2, 32, 0, 0\0"
|
||||
VALUE "ProductVersion", "2, 32, 11, 0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
@@ -975,8 +975,8 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
SDL_Vertex *verts = (SDL_Vertex *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->tex_coord);
|
||||
uintptr_t base = (uintptr_t)vertices + cmd->data.draw.first; // address of first vertex, or base offset when using VBOs.
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)(base + offsetof(SDL_Vertex, tex_coord)));
|
||||
}
|
||||
|
||||
if (GLES2_SelectProgram(data, imgsrc, texture ? texture->w : 0, texture ? texture->h : 0) < 0) {
|
||||
@@ -1009,9 +1009,9 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
|
||||
/* all drawing commands use this */
|
||||
{
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *)(((Uint8 *)vertices) + cmd->data.draw.first);
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)&verts->position);
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *)&verts->color);
|
||||
uintptr_t base = (uintptr_t)vertices + cmd->data.draw.first; // address of first vertex, or base offset when using VBOs.
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, stride, (const GLvoid *)(base + offsetof(SDL_VertexSolid, position)));
|
||||
data->glVertexAttribPointer(GLES2_ATTRIBUTE_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE /* Normalized */, stride, (const GLvoid *)(base + offsetof(SDL_VertexSolid, color)));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1200,7 +1200,8 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
if (data->current_vertex_buffer >= SDL_arraysize(data->vertex_buffers)) {
|
||||
data->current_vertex_buffer = 0;
|
||||
}
|
||||
vertices = NULL; /* attrib pointers will be offsets into the VBO. */
|
||||
// attrib pointers will be offsets into the VBO.
|
||||
vertices = (void *)(uintptr_t)0; // must be the exact value 0, not NULL (the representation of NULL is not guaranteed to be 0).
|
||||
#endif
|
||||
|
||||
while (cmd) {
|
||||
@@ -2220,8 +2221,8 @@ SDL_RenderDriver GLES2_RenderDriver = {
|
||||
{ "opengles2",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
||||
4,
|
||||
{ SDL_PIXELFORMAT_BGRA32,
|
||||
SDL_PIXELFORMAT_ABGR32,
|
||||
{ SDL_PIXELFORMAT_RGBA32,
|
||||
SDL_PIXELFORMAT_BGRA32,
|
||||
SDL_PIXELFORMAT_BGRX32,
|
||||
SDL_PIXELFORMAT_RGBX32 },
|
||||
0,
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef struct
|
||||
static int vsync_sema_id = 0;
|
||||
|
||||
/* PRIVATE METHODS */
|
||||
static int vsync_handler(void)
|
||||
static int vsync_handler(int reason)
|
||||
{
|
||||
iSignalSema(vsync_sema_id);
|
||||
|
||||
@@ -624,8 +624,42 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, Uint32
|
||||
|
||||
gsGlobal = gsKit_init_global_custom(RENDER_QUEUE_OS_POOLSIZE, RENDER_QUEUE_PER_POOLSIZE);
|
||||
|
||||
gsGlobal->Mode = GS_MODE_NTSC;
|
||||
gsGlobal->Height = 448;
|
||||
// GS interlaced/progressive
|
||||
if (SDL_GetHintBoolean(SDL_HINT_PS2_GS_PROGRESSIVE, false)) {
|
||||
gsGlobal->Interlace = GS_NONINTERLACED;
|
||||
} else {
|
||||
gsGlobal->Interlace = GS_INTERLACED;
|
||||
}
|
||||
|
||||
// GS width/height
|
||||
gsGlobal->Width = 0;
|
||||
gsGlobal->Height = 0;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_PS2_GS_WIDTH);
|
||||
if (hint) {
|
||||
gsGlobal->Width = SDL_atoi(hint);
|
||||
}
|
||||
hint = SDL_GetHint(SDL_HINT_PS2_GS_HEIGHT);
|
||||
if (hint) {
|
||||
gsGlobal->Height = SDL_atoi(hint);
|
||||
}
|
||||
if (gsGlobal->Width <= 0) {
|
||||
gsGlobal->Width = 640;
|
||||
}
|
||||
if (gsGlobal->Height <= 0) {
|
||||
gsGlobal->Height = 448;
|
||||
}
|
||||
|
||||
// GS region
|
||||
hint = SDL_GetHint(SDL_HINT_PS2_GS_MODE);
|
||||
if (hint) {
|
||||
if (SDL_strcasecmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE), "NTSC") == 0) {
|
||||
gsGlobal->Mode = GS_MODE_NTSC;
|
||||
}
|
||||
|
||||
if (SDL_strcasecmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE), "PAL") == 0) {
|
||||
gsGlobal->Mode = GS_MODE_PAL;
|
||||
}
|
||||
}
|
||||
|
||||
gsGlobal->PSM = GS_PSM_CT24;
|
||||
gsGlobal->PSMZ = GS_PSMZ_16S;
|
||||
|
||||
@@ -826,6 +826,35 @@ static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ClampCliprectToViewport(SDL_Rect *clip, const SDL_Rect *viewport)
|
||||
{
|
||||
int max_x_v, max_y_v, max_x_c, max_y_c;
|
||||
|
||||
if (clip->x < 0) {
|
||||
clip->w += clip->x;
|
||||
clip->x = 0;
|
||||
}
|
||||
|
||||
if (clip->y < 0) {
|
||||
clip->h += clip->y;
|
||||
clip->y = 0;
|
||||
}
|
||||
|
||||
max_x_c = clip->x + clip->w;
|
||||
max_y_c = clip->y + clip->h;
|
||||
|
||||
max_x_v = viewport->x + viewport->w;
|
||||
max_y_v = viewport->y + viewport->h;
|
||||
|
||||
if (max_x_c > max_x_v) {
|
||||
clip->w -= (max_x_v - max_x_c);
|
||||
}
|
||||
|
||||
if (max_y_c > max_y_v) {
|
||||
clip->h -= (max_y_v - max_y_c);
|
||||
}
|
||||
}
|
||||
|
||||
static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
{
|
||||
SDL_Texture *texture = cmd->data.draw.texture;
|
||||
@@ -868,9 +897,13 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) {
|
||||
const SDL_Rect *rect = &data->drawstate.cliprect;
|
||||
set_clip_rectangle(data, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
|
||||
if ((data->drawstate.cliprect_enabled || data->drawstate.viewport_is_set) && data->drawstate.cliprect_dirty) {
|
||||
SDL_Rect rect;
|
||||
SDL_copyp(&rect, &data->drawstate.cliprect);
|
||||
if (data->drawstate.viewport_is_set) {
|
||||
ClampCliprectToViewport(&rect, &data->drawstate.viewport);
|
||||
}
|
||||
set_clip_rectangle(data, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h);
|
||||
data->drawstate.cliprect_dirty = SDL_FALSE;
|
||||
}
|
||||
|
||||
@@ -925,20 +958,27 @@ static int SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata;
|
||||
int w, h;
|
||||
|
||||
StartDrawing(renderer);
|
||||
|
||||
data->drawstate.target = renderer->target;
|
||||
if (!data->drawstate.target) {
|
||||
int w, h;
|
||||
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
|
||||
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc.
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
data->drawstate.drawablew = w;
|
||||
data->drawstate.drawableh = h;
|
||||
} else {
|
||||
if (SDL_QueryTexture(renderer->target, NULL, NULL, &w, &h) < 0) {
|
||||
w = data->drawstate.drawablew;
|
||||
h = data->drawstate.drawableh;
|
||||
}
|
||||
}
|
||||
|
||||
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
|
||||
data->drawstate.viewport_dirty = SDL_TRUE; // if the window dimensions changed, invalidate the current viewport, etc.
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
data->drawstate.drawablew = w;
|
||||
data->drawstate.drawableh = h;
|
||||
}
|
||||
|
||||
while (cmd) {
|
||||
switch (cmd->command) {
|
||||
|
||||
@@ -949,6 +989,16 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
SDL_copyp(viewport, &cmd->data.viewport.rect);
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
data->drawstate.cliprect_dirty = SDL_TRUE;
|
||||
data->drawstate.viewport_is_set = viewport->x != 0 || viewport->y != 0 || viewport->w != data->drawstate.drawablew || viewport->h != data->drawstate.drawableh;
|
||||
if (!data->drawstate.cliprect_enabled) {
|
||||
if (data->drawstate.viewport_is_set) {
|
||||
SDL_copyp(&data->drawstate.cliprect, viewport);
|
||||
data->drawstate.cliprect.x = 0;
|
||||
data->drawstate.cliprect.y = 0;
|
||||
} else {
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -956,9 +1006,15 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
case SDL_RENDERCMD_SETCLIPRECT:
|
||||
{
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
const SDL_Rect *viewport = &data->drawstate.viewport;
|
||||
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
|
||||
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
|
||||
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
|
||||
if (!data->drawstate.cliprect_enabled && data->drawstate.viewport_is_set) {
|
||||
SDL_copyp(&data->drawstate.cliprect, viewport);
|
||||
data->drawstate.cliprect.x = 0;
|
||||
data->drawstate.cliprect.y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
|
||||
|
||||
@@ -106,6 +106,7 @@ typedef struct
|
||||
{
|
||||
SDL_Rect viewport;
|
||||
SDL_bool viewport_dirty;
|
||||
SDL_bool viewport_is_set;
|
||||
SDL_Texture *texture;
|
||||
SDL_Texture *target;
|
||||
SDL_Color color;
|
||||
|
||||
+36
-7
@@ -81,14 +81,12 @@ static size_t SDL_ScanUnsignedLongLongInternal(const char *text, int count, int
|
||||
negative = *text == '-';
|
||||
++text;
|
||||
}
|
||||
if ((radix == 0 || radix == 16) && *text == '0' && text[1] != '\0') {
|
||||
if ((radix == 0 || radix == 16) && *text == '0' && (text[1] == 'x' || text[1] == 'X')) {
|
||||
text += 2;
|
||||
radix = 16;
|
||||
} else if (radix == 0 && *text == '0' && (text[1] >= '0' && text[1] <= '9')) {
|
||||
++text;
|
||||
if (*text == 'x' || *text == 'X') {
|
||||
radix = 16;
|
||||
++text;
|
||||
} else if (radix == 0) {
|
||||
radix = 8;
|
||||
}
|
||||
radix = 8;
|
||||
} else if (radix == 0) {
|
||||
radix = 10;
|
||||
}
|
||||
@@ -1113,6 +1111,7 @@ static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len)
|
||||
/* NOLINTNEXTLINE(readability-non-const-parameter) */
|
||||
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
||||
{
|
||||
const char *start = text;
|
||||
int retval = 0;
|
||||
|
||||
if (!text || !*text) {
|
||||
@@ -1383,6 +1382,36 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
||||
}
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
switch (inttype) {
|
||||
case DO_SHORT:
|
||||
{
|
||||
short *valuep = va_arg(ap, short *);
|
||||
*valuep = (short)(text - start);
|
||||
} break;
|
||||
case DO_INT:
|
||||
{
|
||||
int *valuep = va_arg(ap, int *);
|
||||
*valuep = (int)(text - start);
|
||||
} break;
|
||||
case DO_LONG:
|
||||
{
|
||||
long *valuep = va_arg(ap, long *);
|
||||
*valuep = (long)(text - start);
|
||||
} break;
|
||||
case DO_LONGLONG:
|
||||
{
|
||||
long long *valuep = va_arg(ap, long long *);
|
||||
*valuep = (long long)(text - start);
|
||||
} break;
|
||||
case DO_SIZE_T:
|
||||
{
|
||||
size_t *valuep = va_arg(ap, size_t *);
|
||||
*valuep = (size_t)(text - start);
|
||||
} break;
|
||||
}
|
||||
done = SDL_TRUE;
|
||||
break;
|
||||
case '[':
|
||||
{
|
||||
const char *set = fmt + 1;
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <pspkerneltypes.h>
|
||||
#include <pspthreadman.h>
|
||||
|
||||
#define PSP_THREAD_NAME_MAX 32
|
||||
|
||||
static int ThreadEntry(SceSize args, void *argp)
|
||||
{
|
||||
SDL_RunThread(*(SDL_Thread **)argp);
|
||||
@@ -44,6 +46,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
|
||||
{
|
||||
SceKernelThreadInfo status;
|
||||
int priority = 32;
|
||||
char thread_name[PSP_THREAD_NAME_MAX];
|
||||
|
||||
/* Set priority of new thread to the same as the current thread */
|
||||
status.size = sizeof(SceKernelThreadInfo);
|
||||
@@ -51,7 +54,12 @@ int SDL_SYS_CreateThread(SDL_Thread *thread)
|
||||
priority = status.currentPriority;
|
||||
}
|
||||
|
||||
thread->handle = sceKernelCreateThread(thread->name, ThreadEntry,
|
||||
SDL_strlcpy(thread_name, "SDL thread", PSP_THREAD_NAME_MAX);
|
||||
if (thread->name) {
|
||||
SDL_strlcpy(thread_name, thread->name, PSP_THREAD_NAME_MAX);
|
||||
}
|
||||
|
||||
thread->handle = sceKernelCreateThread(thread_name, ThreadEntry,
|
||||
priority, thread->stacksize ? ((int)thread->stacksize) : 0x8000,
|
||||
PSP_THREAD_ATTR_VFPU, NULL);
|
||||
if (thread->handle < 0) {
|
||||
|
||||
@@ -159,7 +159,7 @@ void SDL_SYS_SetupThread(const char *name)
|
||||
inf.dwFlags = 0;
|
||||
|
||||
/* The debugger catches this, renames the thread, continues on. */
|
||||
RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR *)&inf);
|
||||
RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG_PTR), (const ULONG_PTR *)&inf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+67
-2
@@ -412,6 +412,66 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
|
||||
|
||||
#endif /* __MMX__ */
|
||||
|
||||
#if defined(__loongarch_sx)
|
||||
|
||||
static void
|
||||
BlitRGBtoRGBPixelAlphaLSX(SDL_BlitInfo * info)
|
||||
{
|
||||
int width = info->dst_w;
|
||||
int height = info->dst_h;
|
||||
Uint32 *srcp = (Uint32 *) info->src;
|
||||
int srcskip = info->src_skip >> 2;
|
||||
Uint32 *dstp = (Uint32 *) info->dst;
|
||||
int dstskip = info->dst_skip >> 2;
|
||||
SDL_PixelFormat *sf = info->src_fmt;
|
||||
Uint32 amask = sf->Amask;
|
||||
Uint32 ashift = sf->Ashift;
|
||||
Uint64 multmask, multmask2;
|
||||
|
||||
__m128i src1, src2, src3, dst1, alpha, alpha2;
|
||||
multmask = 0x00FF;
|
||||
multmask <<= (ashift * 2);
|
||||
multmask2 = 0x00FF00FF00FF00FFULL;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */
|
||||
DUFFS_LOOP4({
|
||||
Uint32 alpha1 = *srcp & amask;
|
||||
if (alpha1 == 0) {
|
||||
/* do nothing */
|
||||
} else if (alpha1 == amask) {
|
||||
*dstp = *srcp;
|
||||
} else {
|
||||
src1 = __lsx_vreplgr2vr_w(*srcp);
|
||||
src1 = __lsx_vinsgr2vr_w(src1, *dstp, 1);
|
||||
src2 = __lsx_vsllwil_hu_bu(src1, 0);
|
||||
|
||||
alpha = __lsx_vreplgr2vr_w(alpha1);
|
||||
alpha = __lsx_vsrl_d(alpha, __lsx_vreplgr2vr_d(ashift));
|
||||
alpha = __lsx_vilvl_h(alpha, alpha);
|
||||
alpha2 = __lsx_vilvl_w(alpha, alpha);
|
||||
alpha = __lsx_vor_v(alpha2, __lsx_vreplgr2vr_d(multmask));
|
||||
alpha2 = __lsx_vxor_v(alpha2, __lsx_vreplgr2vr_d(multmask2));
|
||||
|
||||
src3 = __lsx_vilvl_d(alpha2, alpha);
|
||||
src1 = __lsx_vmul_h(src2, src3);
|
||||
src1 = __lsx_vsrli_h(src1, 8);
|
||||
src2 = __lsx_vilvh_d(src1, src1);
|
||||
src1 = __lsx_vadd_h(src1, src2);
|
||||
dst1 = __lsx_vssrlni_bu_h(src1, src1, 0);
|
||||
__lsx_vstelm_w(dst1, dstp, 0, 0);
|
||||
}
|
||||
++srcp;
|
||||
++dstp;
|
||||
}, width);
|
||||
/* *INDENT-ON* */
|
||||
srcp += srcskip;
|
||||
dstp += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __loongarch_sx */
|
||||
|
||||
#ifdef SDL_ARM_SIMD_BLITTERS
|
||||
void BlitARGBto565PixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride);
|
||||
|
||||
@@ -1456,7 +1516,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||
|
||||
case 4:
|
||||
if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->BytesPerPixel == 4) {
|
||||
#if defined(__MMX__) || defined(__3dNOW__)
|
||||
#if defined(__MMX__) || defined(__3dNOW__) || defined(__loongarch_sx)
|
||||
if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && sf->Ashift % 8 == 0 && sf->Aloss == 0) {
|
||||
#ifdef __3dNOW__
|
||||
if (SDL_Has3DNow()) {
|
||||
@@ -1467,9 +1527,14 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||
if (SDL_HasMMX()) {
|
||||
return BlitRGBtoRGBPixelAlphaMMX;
|
||||
}
|
||||
#endif
|
||||
#ifdef __loongarch_sx
|
||||
if (SDL_HasLSX()) {
|
||||
return BlitRGBtoRGBPixelAlphaLSX;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* __MMX__ || __3dNOW__ */
|
||||
#endif /* __MMX__ || __3dNOW__ || __loongarch_sx*/
|
||||
if (sf->Amask == 0xff000000) {
|
||||
#ifdef SDL_ARM_NEON_BLITTERS
|
||||
if (SDL_HasNEON()) {
|
||||
|
||||
@@ -1186,6 +1186,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
/* max 2 key+value pairs, plus terminator. */
|
||||
EGLint attribs[5];
|
||||
int attr = 0;
|
||||
int opaque_ext_idx = -1;
|
||||
|
||||
EGLSurface *surface;
|
||||
|
||||
@@ -1220,6 +1221,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
#ifdef EGL_EXT_present_opaque
|
||||
if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) {
|
||||
const SDL_bool allow_transparent = SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY, SDL_FALSE);
|
||||
opaque_ext_idx = attr;
|
||||
attribs[attr++] = EGL_PRESENT_OPAQUE_EXT;
|
||||
attribs[attr++] = allow_transparent ? EGL_FALSE : EGL_TRUE;
|
||||
}
|
||||
@@ -1231,6 +1233,16 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
|
||||
_this->egl_data->egl_display,
|
||||
_this->egl_data->egl_config,
|
||||
nw, &attribs[0]);
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
/* we had a report of Nvidia drivers that report EGL_BAD_ATTRIBUTE if you try to
|
||||
* use EGL_PRESENT_OPAQUE_EXT, even when EGL_EXT_present_opaque is reported as available.
|
||||
* If we used it, try a second time without this attribute. */
|
||||
if ((_this->egl_data->eglGetError() == EGL_BAD_ATTRIBUTE) && (opaque_ext_idx >= 0)) {
|
||||
SDL_memmove(&attribs[opaque_ext_idx], &attribs[opaque_ext_idx + 2], sizeof (attribs[0]) * ((attr - opaque_ext_idx) - 2));
|
||||
surface = _this->egl_data->eglCreateWindowSurface(_this->egl_data->egl_display, _this->egl_data->egl_config, nw, &attribs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (surface == EGL_NO_SURFACE) {
|
||||
SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
|
||||
}
|
||||
|
||||
@@ -135,6 +135,61 @@ DEFINE_SSE_FILLRECT(4, Uint32)
|
||||
/* *INDENT-ON* */ /* clang-format on */
|
||||
#endif /* __SSE__ */
|
||||
|
||||
#if defined(__loongarch_sx)
|
||||
|
||||
#define LSX_BEGIN __m128i c128 = __lsx_vreplgr2vr_w(color);
|
||||
|
||||
#define LSX_WORK \
|
||||
for (i = n / 64; i--;) { \
|
||||
__lsx_vst(c128, p, 0); \
|
||||
__lsx_vst(c128, p, 16); \
|
||||
__lsx_vst(c128, p, 32); \
|
||||
__lsx_vst(c128, p, 48); \
|
||||
p += 64; \
|
||||
}
|
||||
|
||||
#define DEFINE_LSX_FILLRECT(bpp, type) \
|
||||
static void \
|
||||
SDL_FillRect##bpp##LSX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
|
||||
{ \
|
||||
int i, n; \
|
||||
Uint8 *p = NULL; \
|
||||
\
|
||||
LSX_BEGIN; \
|
||||
\
|
||||
while (h--) { \
|
||||
n = w * bpp; \
|
||||
p = pixels; \
|
||||
\
|
||||
if (n > 63) { \
|
||||
int adjust = 16 - ((uintptr_t)p & 15); \
|
||||
if (adjust < 16) { \
|
||||
n -= adjust; \
|
||||
adjust /= bpp; \
|
||||
while (adjust--) { \
|
||||
*((type *)p) = (type)color; \
|
||||
p += bpp; \
|
||||
} \
|
||||
} \
|
||||
LSX_WORK; \
|
||||
} \
|
||||
if (n & 63) { \
|
||||
int remainder = (n & 63); \
|
||||
remainder /= bpp; \
|
||||
while (remainder--) { \
|
||||
*((type *)p) = (type)color; \
|
||||
p += bpp; \
|
||||
} \
|
||||
} \
|
||||
pixels += pitch; \
|
||||
} \
|
||||
\
|
||||
}
|
||||
|
||||
DEFINE_LSX_FILLRECT(4, Uint32)
|
||||
|
||||
#endif
|
||||
|
||||
static void SDL_FillRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
|
||||
{
|
||||
int n;
|
||||
@@ -423,6 +478,13 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __loongarch_sx
|
||||
if (SDL_HasLSX()) {
|
||||
fill_function = SDL_FillRect4LSX;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
fill_function = SDL_FillRect4;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B)
|
||||
} else if (!B) {
|
||||
SDL_InvalidParamError("B");
|
||||
return SDL_FALSE;
|
||||
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) {
|
||||
return SDL_FALSE; /* Special cases for empty rects */
|
||||
}
|
||||
|
||||
/* Horizontal intersection */
|
||||
@@ -79,10 +77,6 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul
|
||||
} else if (!result) {
|
||||
SDL_InvalidParamError("result");
|
||||
return SDL_FALSE;
|
||||
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */
|
||||
result->w = 0;
|
||||
result->h = 0;
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
/* Horizontal intersection */
|
||||
|
||||
@@ -355,8 +355,7 @@ struct SDL_VideoDevice
|
||||
SDL_bool checked_texture_framebuffer;
|
||||
SDL_bool is_dummy;
|
||||
SDL_bool suspend_screensaver;
|
||||
SDL_Window *wakeup_window;
|
||||
SDL_mutex *wakeup_lock; /* Initialized only if WaitEventTimeout/SendWakeupEvent are supported */
|
||||
void *wakeup_window;
|
||||
int num_displays;
|
||||
SDL_VideoDisplay *displays;
|
||||
SDL_Window *windows;
|
||||
|
||||
@@ -3368,9 +3368,7 @@ void SDL_DestroyWindow(SDL_Window *window)
|
||||
_this->current_glwin = NULL;
|
||||
}
|
||||
|
||||
if (_this->wakeup_window == window) {
|
||||
_this->wakeup_window = NULL;
|
||||
}
|
||||
SDL_AtomicCASPtr(&_this->wakeup_window, window, NULL);
|
||||
|
||||
/* Now invalidate magic */
|
||||
window->magic = NULL;
|
||||
|
||||
@@ -287,9 +287,21 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
|
||||
/* The menu bar of SDL apps which don't have the typical .app bundle
|
||||
* structure fails to work the first time a window is created (until it's
|
||||
* de-focused and re-focused), if this call is in Cocoa_RegisterApp instead
|
||||
* of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051
|
||||
* of here. https://github.com/libsdl-org/SDL/issues/1913
|
||||
*/
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, SDL_FALSE)) {
|
||||
|
||||
/* this apparently became unnecessary on macOS 14.0, and will addition pop up a
|
||||
hidden dock if you're moving the mouse during launch, so change the default
|
||||
behaviour there. https://github.com/libsdl-org/SDL/issues/10340
|
||||
(13.6 still needs it, presumably 13.7 does, too.) */
|
||||
SDL_bool background_app_default = SDL_FALSE;
|
||||
#if _SDL_HAS_BUILTIN(__builtin_available)
|
||||
if (@available(macOS 14.0, *)) {
|
||||
background_app_default = SDL_TRUE; /* by default, don't explicitly activate the dock and then us again to force to foreground */
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, background_app_default)) {
|
||||
/* Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. */
|
||||
for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
|
||||
[i activateWithOptions:NSApplicationActivateIgnoringOtherApps];
|
||||
|
||||
@@ -48,9 +48,6 @@ static void Cocoa_VideoQuit(_THIS);
|
||||
static void Cocoa_DeleteDevice(SDL_VideoDevice * device)
|
||||
{ @autoreleasepool
|
||||
{
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
CFBridgingRelease(device->driverdata);
|
||||
SDL_free(device);
|
||||
}}
|
||||
@@ -76,7 +73,6 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = (void *)CFBridgingRetain(data);
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Cocoa_VideoInit;
|
||||
|
||||
@@ -855,6 +855,11 @@ static NSCursor *Cocoa_GetDesiredCursor(void)
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
|
||||
/* The OS can resize the window automatically if the display density
|
||||
changes while the window is miniaturized or hidden */
|
||||
if (![nswindow isVisible])
|
||||
return;
|
||||
|
||||
/* isZoomed always returns true if the window is not resizable */
|
||||
if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) {
|
||||
zoomed = YES;
|
||||
|
||||
@@ -79,7 +79,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect
|
||||
if (!Module['SDL2']) Module['SDL2'] = {};
|
||||
var SDL2 = Module['SDL2'];
|
||||
if (SDL2.ctxCanvas !== Module['canvas']) {
|
||||
SDL2.ctx = Module['createContext'](Module['canvas'], false, true);
|
||||
SDL2.ctx = Browser.createContext(Module['canvas'], false, true);
|
||||
SDL2.ctxCanvas = Module['canvas'];
|
||||
}
|
||||
if (SDL2.w !== w || SDL2.h !== h || SDL2.imageCtx !== SDL2.ctx) {
|
||||
|
||||
@@ -338,6 +338,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo)
|
||||
unsigned w, h;
|
||||
int rc = -1;
|
||||
int num_planes = 0;
|
||||
int i;
|
||||
uint32_t format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0;
|
||||
uint64_t modifiers[4] = { 0 };
|
||||
|
||||
@@ -374,7 +375,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *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++) {
|
||||
for (i = 0; i < num_planes; i++) {
|
||||
strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i);
|
||||
handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32;
|
||||
offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i);
|
||||
|
||||
@@ -40,6 +40,48 @@
|
||||
*/
|
||||
#define PIPE_MS_TIMEOUT 14
|
||||
|
||||
/* sigtimedwait() is an optional part of POSIX.1-2001, and OpenBSD doesn't implement it.
|
||||
* Based on https://comp.unix.programmer.narkive.com/rEDH0sPT/sigtimedwait-implementation
|
||||
*/
|
||||
#ifndef HAVE_SIGTIMEDWAIT
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
static int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout)
|
||||
{
|
||||
struct timespec elapsed = { 0 }, rem = { 0 };
|
||||
sigset_t pending;
|
||||
int signo;
|
||||
do {
|
||||
/* Check the pending signals, and call sigwait if there is at least one of interest in the set. */
|
||||
sigpending(&pending);
|
||||
for (signo = 1; signo < NSIG; ++signo) {
|
||||
if (sigismember(set, signo) && sigismember(&pending, signo)) {
|
||||
if (!sigwait(set, &signo)) {
|
||||
if (info) {
|
||||
SDL_memset(info, 0, sizeof *info);
|
||||
info->si_signo = signo;
|
||||
}
|
||||
return signo;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout->tv_sec || timeout->tv_nsec) {
|
||||
long ns = 20000000L; // 2/100ths of a second
|
||||
nanosleep(&(struct timespec){ 0, ns }, &rem);
|
||||
ns -= rem.tv_nsec;
|
||||
elapsed.tv_sec += (elapsed.tv_nsec + ns) / 1000000000L;
|
||||
elapsed.tv_nsec = (elapsed.tv_nsec + ns) % 1000000000L;
|
||||
}
|
||||
} while (elapsed.tv_sec < timeout->tv_sec || (elapsed.tv_sec == timeout->tv_sec && elapsed.tv_nsec < timeout->tv_nsec));
|
||||
|
||||
errno = EAGAIN;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_t *pos)
|
||||
{
|
||||
int ready = 0;
|
||||
@@ -75,7 +117,7 @@ static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_
|
||||
}
|
||||
}
|
||||
|
||||
sigtimedwait(&sig_set, 0, &zerotime);
|
||||
sigtimedwait(&sig_set, NULL, &zerotime);
|
||||
|
||||
#ifdef SDL_THREADS_DISABLED
|
||||
sigprocmask(SIG_SETMASK, &old_sig_set, NULL);
|
||||
|
||||
@@ -2681,23 +2681,28 @@ static void relative_pointer_handle_relative_motion(void *data,
|
||||
struct SDL_WaylandInput *input = data;
|
||||
SDL_VideoData *d = input->display;
|
||||
SDL_WindowData *window = input->pointer_focus;
|
||||
double dx_unaccel;
|
||||
double dy_unaccel;
|
||||
double dx;
|
||||
double dy;
|
||||
double dx_mod;
|
||||
double dy_mod;
|
||||
|
||||
dx_unaccel = wl_fixed_to_double(dx_unaccel_w);
|
||||
dy_unaccel = wl_fixed_to_double(dy_unaccel_w);
|
||||
if (!d->relative_mode_accelerated) {
|
||||
dx = wl_fixed_to_double(dx_unaccel_w);
|
||||
dy = wl_fixed_to_double(dy_unaccel_w);
|
||||
} else {
|
||||
dx = wl_fixed_to_double(dx_w) * (window ? window->pointer_scale_x : 1.0);
|
||||
dy = wl_fixed_to_double(dy_w) * (window ? window->pointer_scale_y : 1.0);
|
||||
}
|
||||
|
||||
/* Add left over fraction from last event. */
|
||||
dx_unaccel += input->dx_frac;
|
||||
dy_unaccel += input->dy_frac;
|
||||
dx += input->dx_frac;
|
||||
dy += input->dy_frac;
|
||||
|
||||
input->dx_frac = modf(dx_unaccel, &dx);
|
||||
input->dy_frac = modf(dy_unaccel, &dy);
|
||||
input->dx_frac = modf(dx, &dx_mod);
|
||||
input->dy_frac = modf(dy, &dy_mod);
|
||||
|
||||
if (input->pointer_focus && d->relative_mouse_mode) {
|
||||
SDL_SendMouseMotion(window->sdlwindow, 0, 1, (int)dx, (int)dy);
|
||||
SDL_SendMouseMotion(window->sdlwindow, 0, 1, (int)dx_mod, (int)dy_mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -537,6 +537,9 @@ static int Wayland_SetRelativeMouseMode(SDL_bool enabled)
|
||||
SDL_VideoData *data = (SDL_VideoData *)vd->driverdata;
|
||||
|
||||
if (enabled) {
|
||||
/* Clients use relative warp mode to get accelerated motion deltas, which Wayland delivers internally. */
|
||||
data->relative_mode_accelerated = SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE);
|
||||
|
||||
/* Disable mouse warp emulation if it's enabled. */
|
||||
if (data->input->relative_mode_override) {
|
||||
data->input->relative_mode_override = SDL_FALSE;
|
||||
|
||||
@@ -162,9 +162,6 @@ static void Wayland_DeleteDevice(SDL_VideoDevice *device)
|
||||
WAYLAND_wl_display_flush(data->display);
|
||||
WAYLAND_wl_display_disconnect(data->display);
|
||||
}
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
SDL_free(data);
|
||||
SDL_free(device);
|
||||
SDL_WAYLAND_UnloadSymbols();
|
||||
@@ -233,7 +230,6 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
|
||||
}
|
||||
|
||||
device->driverdata = data;
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
/* Set the function pointers */
|
||||
device->VideoInit = Wayland_VideoInit;
|
||||
|
||||
@@ -101,6 +101,7 @@ typedef struct
|
||||
char *classname;
|
||||
|
||||
int relative_mouse_mode;
|
||||
int relative_mode_accelerated;
|
||||
SDL_bool egl_transparency_enabled;
|
||||
} SDL_VideoData;
|
||||
|
||||
|
||||
@@ -250,7 +250,10 @@ static void WIN_FreeCursor(SDL_Cursor *cursor)
|
||||
static int WIN_ShowCursor(SDL_Cursor *cursor)
|
||||
{
|
||||
if (!cursor) {
|
||||
cursor = SDL_blank_cursor;
|
||||
if (GetSystemMetrics(SM_REMOTESESSION)) {
|
||||
// Use a blank cursor so we continue to get relative motion over RDP
|
||||
cursor = SDL_blank_cursor;
|
||||
}
|
||||
}
|
||||
if (cursor) {
|
||||
SDL_cursor = (HCURSOR)cursor->driverdata;
|
||||
|
||||
@@ -93,9 +93,6 @@ static void WIN_DeleteDevice(SDL_VideoDevice *device)
|
||||
SDL_UnloadObject(data->shcoreDLL);
|
||||
}
|
||||
#endif
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
}
|
||||
@@ -120,7 +117,6 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
|
||||
return NULL;
|
||||
}
|
||||
device->driverdata = data;
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||
data->userDLL = SDL_LoadObject("USER32.DLL");
|
||||
|
||||
@@ -108,9 +108,6 @@ static void X11_DeleteDevice(SDL_VideoDevice *device)
|
||||
X11_XCloseDisplay(data->request_display);
|
||||
}
|
||||
SDL_free(data->windowlist);
|
||||
if (device->wakeup_lock) {
|
||||
SDL_DestroyMutex(device->wakeup_lock);
|
||||
}
|
||||
SDL_free(device->driverdata);
|
||||
SDL_free(device);
|
||||
|
||||
@@ -204,8 +201,6 @@ static SDL_VideoDevice *X11_CreateDevice(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device->wakeup_lock = SDL_CreateMutex();
|
||||
|
||||
#ifdef X11_DEBUG
|
||||
X11_XSynchronize(data->display, True);
|
||||
#endif
|
||||
|
||||
@@ -393,6 +393,7 @@ int stdlib_getsetenv(void *arg)
|
||||
#endif
|
||||
|
||||
#define FMT_PRILLd "%lld"
|
||||
#define FMT_PRILLdn "%lld%lln"
|
||||
#define FMT_PRILLu "%llu"
|
||||
|
||||
/**
|
||||
@@ -403,13 +404,15 @@ int stdlib_sscanf(void *arg)
|
||||
{
|
||||
int output;
|
||||
int result;
|
||||
int length;
|
||||
int expected_output;
|
||||
int expected_result;
|
||||
short short_output, expected_short_output;
|
||||
long long_output, expected_long_output;
|
||||
long long long_long_output, expected_long_long_output;
|
||||
short short_output, expected_short_output, short_length;
|
||||
long long_output, expected_long_output, long_length;
|
||||
long long long_long_output, expected_long_long_output, long_long_length;
|
||||
size_t size_output, expected_size_output;
|
||||
char text[128], text2[128];
|
||||
unsigned int r = 0, g = 0, b = 0;
|
||||
|
||||
expected_output = output = 123;
|
||||
expected_result = -1;
|
||||
@@ -426,43 +429,62 @@ int stdlib_sscanf(void *arg)
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
|
||||
|
||||
output = 123;
|
||||
length = 0;
|
||||
expected_output = 2;
|
||||
expected_result = 1;
|
||||
result = SDL_sscanf("2", "%i", &output);
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i\", &output)");
|
||||
result = SDL_sscanf("2", "%i%n", &output, &length);
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"2\", \"%%i%%n\", &output, &length)");
|
||||
SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
|
||||
SDLTest_AssertCheck(length == 1, "Check length, expected: 1, got: %i", length);
|
||||
|
||||
output = 123;
|
||||
length = 0;
|
||||
expected_output = 0xa;
|
||||
expected_result = 1;
|
||||
result = SDL_sscanf("aa", "%1x", &output);
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"aa\", \"%%1x\", &output)");
|
||||
result = SDL_sscanf("aa", "%1x%n", &output, &length);
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"aa\", \"%%1x%%n\", &output, &length)");
|
||||
SDLTest_AssertCheck(expected_output == output, "Check output, expected: %i, got: %i", expected_output, output);
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
|
||||
SDLTest_AssertCheck(length == 1, "Check length, expected: 1, got: %i", length);
|
||||
|
||||
#define SIZED_TEST_CASE(type, var, format_specifier) \
|
||||
var##_output = 123; \
|
||||
expected_##var##_output = (type)(((unsigned type)(~0)) >> 1); \
|
||||
expected_result = 1; \
|
||||
result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \
|
||||
result = SDL_sscanf(text, format_specifier, &var##_output); \
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \
|
||||
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
|
||||
\
|
||||
var##_output = 123; \
|
||||
expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \
|
||||
expected_result = 1; \
|
||||
result = SDL_snprintf(text, sizeof(text), format_specifier, expected_##var##_output); \
|
||||
result = SDL_sscanf(text, format_specifier, &var##_output); \
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", \"%s\", &output)", text, #format_specifier); \
|
||||
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " format_specifier ", got: " format_specifier, expected_##var##_output, var##_output); \
|
||||
expected_result = 3;
|
||||
result = SDL_sscanf("#026", "#%1x%1x%1x", &r, &g, &b);
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"#026\", \"#%%1x%%1x%%1x\", &r, &g, &b)");
|
||||
expected_output = 0;
|
||||
SDLTest_AssertCheck(r == expected_output, "Check output for r, expected: %i, got: %i", expected_output, r);
|
||||
expected_output = 2;
|
||||
SDLTest_AssertCheck(g == expected_output, "Check output for g, expected: %i, got: %i", expected_output, g);
|
||||
expected_output = 6;
|
||||
SDLTest_AssertCheck(b == expected_output, "Check output for b, expected: %i, got: %i", expected_output, b);
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result);
|
||||
|
||||
SIZED_TEST_CASE(short, short, "%hd")
|
||||
SIZED_TEST_CASE(long, long, "%ld")
|
||||
SIZED_TEST_CASE(long long, long_long, "%lld")
|
||||
#define SIZED_TEST_CASE(type, var, printf_specifier, scanf_specifier) \
|
||||
var##_output = 123; \
|
||||
var##_length = 0; \
|
||||
expected_##var##_output = (type)(((unsigned type)(~0)) >> 1); \
|
||||
expected_result = 1; \
|
||||
result = SDL_snprintf(text, sizeof(text), printf_specifier, expected_##var##_output); \
|
||||
result = SDL_sscanf(text, scanf_specifier, &var##_output, &var##_length); \
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", %s, &output, &length)", text, #scanf_specifier); \
|
||||
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " printf_specifier ", got: " printf_specifier, expected_##var##_output, var##_output); \
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
|
||||
SDLTest_AssertCheck(var##_length == (type)SDL_strlen(text), "Check length, expected: %i, got: %i", (int)SDL_strlen(text), (int)var##_length); \
|
||||
\
|
||||
var##_output = 123; \
|
||||
var##_length = 0; \
|
||||
expected_##var##_output = ~(type)(((unsigned type)(~0)) >> 1); \
|
||||
expected_result = 1; \
|
||||
result = SDL_snprintf(text, sizeof(text), printf_specifier, expected_##var##_output); \
|
||||
result = SDL_sscanf(text, scanf_specifier, &var##_output, &var##_length); \
|
||||
SDLTest_AssertPass("Call to SDL_sscanf(\"%s\", %s, &output, &length)", text, #scanf_specifier); \
|
||||
SDLTest_AssertCheck(expected_##var##_output == var##_output, "Check output, expected: " printf_specifier ", got: " printf_specifier, expected_##var##_output, var##_output); \
|
||||
SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); \
|
||||
SDLTest_AssertCheck(var##_length == (type)SDL_strlen(text), "Check length, expected: %i, got: %i", (int)SDL_strlen(text), (int)var##_length); \
|
||||
|
||||
SIZED_TEST_CASE(short, short, "%hd", "%hd%hn")
|
||||
SIZED_TEST_CASE(long, long, "%ld", "%ld%ln")
|
||||
SIZED_TEST_CASE(long long, long_long, FMT_PRILLd, FMT_PRILLdn)
|
||||
|
||||
size_output = 123;
|
||||
expected_size_output = ~((size_t)0);
|
||||
|
||||
Reference in new issue
Block a user