mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
Compare commits
321 Commits
SDL2
...
release-2.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
fa24d868ac | ||
![]() |
c38a40eff9 | ||
![]() |
439bb5377c | ||
![]() |
e38ea9df0c | ||
![]() |
6955c981bc | ||
![]() |
fb3bd3b233 | ||
![]() |
847f828e7f | ||
![]() |
ec0ba62326 | ||
![]() |
76816a3bfc | ||
![]() |
ea873d322a | ||
![]() |
1c3ad751de | ||
![]() |
eccd76a6ac | ||
![]() |
2e99b6e9ce | ||
![]() |
e305da0baf | ||
![]() |
ca8e33375b | ||
![]() |
4568e64d9e | ||
![]() |
5b3ce972e0 | ||
![]() |
bf3a264202 | ||
![]() |
fc2fd42197 | ||
![]() |
9c821dc21c | ||
![]() |
826c56b67c | ||
![]() |
f3245a6fed | ||
![]() |
43e9c5b247 | ||
![]() |
6d9ab4c984 | ||
![]() |
5418740c4a | ||
![]() |
0251b14be3 | ||
![]() |
2e43a69a5c | ||
![]() |
056a4a0960 | ||
![]() |
1bb627514d | ||
![]() |
1e3465dc99 | ||
![]() |
2f873636c7 | ||
![]() |
cb3e9578e3 | ||
![]() |
eecf3aab80 | ||
![]() |
779a6637b2 | ||
![]() |
482ff3b911 | ||
![]() |
616923c1b0 | ||
![]() |
c57874fde0 | ||
![]() |
9eebee9ff0 | ||
![]() |
bc8a1fd7d5 | ||
![]() |
01dee787c1 | ||
![]() |
eedf76f8ed | ||
![]() |
dccd23e6fb | ||
![]() |
7217771458 | ||
![]() |
3ee780ce9c | ||
![]() |
bee8874629 | ||
![]() |
11ffdd3abc | ||
![]() |
6f859d90f1 | ||
![]() |
96f4421e5f | ||
![]() |
ad602924a4 | ||
![]() |
9eca707549 | ||
![]() |
4fc47a774f | ||
![]() |
c98c4fbff6 | ||
![]() |
4d4f004968 | ||
![]() |
5d7a023430 | ||
![]() |
3e272e73d6 | ||
![]() |
cc2352f842 | ||
![]() |
f170ced2a7 | ||
![]() |
dcdb763de8 | ||
![]() |
5c9f37080e | ||
![]() |
257d75429d | ||
![]() |
c1adfb4c94 | ||
![]() |
217bc17a21 | ||
![]() |
7107e02315 | ||
![]() |
062a777240 | ||
![]() |
1842745c9c | ||
![]() |
bbcc9421d6 | ||
![]() |
b58a1c7f33 | ||
![]() |
79a8f7b3a0 | ||
![]() |
302ab09178 | ||
![]() |
e1e38e2250 | ||
![]() |
2638809c50 | ||
![]() |
36853f923e | ||
![]() |
63aff8e3d0 | ||
![]() |
7eebc2ad4d | ||
![]() |
0f695adb03 | ||
![]() |
79ec168f3c | ||
![]() |
40a3a80d45 | ||
![]() |
025fc35c87 | ||
![]() |
e9f5f3ac1f | ||
![]() |
235c87dc92 | ||
![]() |
b6535836aa | ||
![]() |
5e90dd3507 | ||
![]() |
d9139ff3de | ||
![]() |
5669b97fd7 | ||
![]() |
6f0fae7432 | ||
![]() |
1c4dd015ac | ||
![]() |
e9efcfb428 | ||
![]() |
d32189918b | ||
![]() |
38d3b1b6d6 | ||
![]() |
1df907b1ba | ||
![]() |
00a7191f67 | ||
![]() |
d53b22e8f0 | ||
![]() |
e5bb4fa90f | ||
![]() |
ba9b075eba | ||
![]() |
85b2733324 | ||
![]() |
9519b9916c | ||
![]() |
00494df2f1 | ||
![]() |
948196448f | ||
![]() |
7ca3d26e7a | ||
![]() |
f79d28085d | ||
![]() |
74a005f73f | ||
![]() |
6f7aa1e755 | ||
![]() |
847a6cce96 | ||
![]() |
95aed34a69 | ||
![]() |
21e0382edd | ||
![]() |
0cdfdb9970 | ||
![]() |
f75b0aa814 | ||
![]() |
403f87340f | ||
![]() |
07cfc34a2e | ||
![]() |
4222cebef6 | ||
![]() |
1e2aa2363b | ||
![]() |
0b25cd2196 | ||
![]() |
b7457ff61b | ||
![]() |
ba2f78a006 | ||
![]() |
dcbdf09709 | ||
![]() |
a9b11980d2 | ||
![]() |
906d0e9c03 | ||
![]() |
0952ab1ab9 | ||
![]() |
7635776ca4 | ||
![]() |
76a3457ad5 | ||
![]() |
881c4cb49e | ||
![]() |
0406d1c316 | ||
![]() |
1ca76a29d9 | ||
![]() |
e53df5b07e | ||
![]() |
e7a47e783b | ||
![]() |
279eb89ce5 | ||
![]() |
fe9020dcb8 | ||
![]() |
4927836b2d | ||
![]() |
5a072d38db | ||
![]() |
2d1ebf4850 | ||
![]() |
44ec2027f3 | ||
![]() |
000da98663 | ||
![]() |
87ba287f81 | ||
![]() |
d133701a72 | ||
![]() |
4635f8597d | ||
![]() |
802351be25 | ||
![]() |
d3765b27c2 | ||
![]() |
7b11fff2ee | ||
![]() |
de4573275a | ||
![]() |
275c94c900 | ||
![]() |
c084e647ed | ||
![]() |
2cdb419a21 | ||
![]() |
2eef7ca475 | ||
![]() |
d126e7bbba | ||
![]() |
e5024fae3d | ||
![]() |
eb053c7f3f | ||
![]() |
ed441c8289 | ||
![]() |
59b0a1dc65 | ||
![]() |
80d36aba5b | ||
![]() |
e1e36d213b | ||
![]() |
5c8d92e4d0 | ||
![]() |
8a39054b54 | ||
![]() |
c60e2704c8 | ||
![]() |
a9fdbf7f21 | ||
![]() |
ed86b02df8 | ||
![]() |
0811b4dc51 | ||
![]() |
d9901e0b85 | ||
![]() |
0f5752b0fc | ||
![]() |
31f77182d0 | ||
![]() |
620e875335 | ||
![]() |
c18173c260 | ||
![]() |
f08f458896 | ||
![]() |
53cf48f505 | ||
![]() |
c32a1a5023 | ||
![]() |
8b204815cc | ||
![]() |
a9bb92b3ae | ||
![]() |
630272eb55 | ||
![]() |
92fe3b19c8 | ||
![]() |
30e2b03a65 | ||
![]() |
f8943854fd | ||
![]() |
325465935d | ||
![]() |
1cdd37b32c | ||
![]() |
499bff9c3a | ||
![]() |
bd06e43b87 | ||
![]() |
72e5620202 | ||
![]() |
fbb9646806 | ||
![]() |
4b91f0793c | ||
![]() |
6243a80b3f | ||
![]() |
e0b0a98c8e | ||
![]() |
785eac863b | ||
![]() |
ab8659922d | ||
![]() |
d48f9c4af4 | ||
![]() |
5cc0644aa0 | ||
![]() |
91accc391d | ||
![]() |
3ee20388c5 | ||
![]() |
2449510673 | ||
![]() |
2c07ed320e | ||
![]() |
607f37dafd | ||
![]() |
acc2e040ce | ||
![]() |
faa9bbdc8e | ||
![]() |
cf6c760cd3 | ||
![]() |
e49349ac0c | ||
![]() |
1e5db996ff | ||
![]() |
793a0681a9 | ||
![]() |
825ffaa168 | ||
![]() |
9ad6a36b7b | ||
![]() |
c3b53c72c7 | ||
![]() |
0800d81fb4 | ||
![]() |
c27219695a | ||
![]() |
9dcfc308ef | ||
![]() |
77b3a6afaf | ||
![]() |
dd42795131 | ||
![]() |
fb1497566c | ||
![]() |
cc6c0fe230 | ||
![]() |
f9a46a319b | ||
![]() |
48a0592a45 | ||
![]() |
1c74a8b5ae | ||
![]() |
3d18043005 | ||
![]() |
6e1e00701e | ||
![]() |
5570d846ea | ||
![]() |
f5dcb8f7ad | ||
![]() |
f6f1b09b69 | ||
![]() |
bf540985aa | ||
![]() |
c39f86c28a | ||
![]() |
b5da8ad00d | ||
![]() |
f62b86263a | ||
![]() |
3449c734d5 | ||
![]() |
3f29d985fe | ||
![]() |
2f4a7bbced | ||
![]() |
a0522e4c21 | ||
![]() |
f461d91cd2 | ||
![]() |
ef54e0c4f4 | ||
![]() |
863f39fb9f | ||
![]() |
d33b28c9fe | ||
![]() |
c15a87a614 | ||
![]() |
45de0635ac | ||
![]() |
bca314c339 | ||
![]() |
f05490d0e2 | ||
![]() |
442e201705 | ||
![]() |
9c346b2321 | ||
![]() |
a6b684d05a | ||
![]() |
8fb82da226 | ||
![]() |
0949f89028 | ||
![]() |
350a49e1cc | ||
![]() |
bc19e38728 | ||
![]() |
228a2954d7 | ||
![]() |
3d6d4ca2cd | ||
![]() |
4c3e5cf1d1 | ||
![]() |
27b1b6d4eb | ||
![]() |
24269007d8 | ||
![]() |
d849036927 | ||
![]() |
5be47255ba | ||
![]() |
8f860b3698 | ||
![]() |
35992597ae | ||
![]() |
3f0d7a2937 | ||
![]() |
dae1232489 | ||
![]() |
8e388843b8 | ||
![]() |
5adbf3765a | ||
![]() |
e910e6f13d | ||
![]() |
2f2cca8ac6 | ||
![]() |
a2f39399a1 | ||
![]() |
c1149f88b6 | ||
![]() |
54adba6a31 | ||
![]() |
b48106f8a8 | ||
![]() |
f345428367 | ||
![]() |
e4287595c1 | ||
![]() |
73efbf2e14 | ||
![]() |
ad342dfca9 | ||
![]() |
f13d6d4b0f | ||
![]() |
dfb8241317 | ||
![]() |
c67f10e43f | ||
![]() |
932eea513e | ||
![]() |
5e51a37518 | ||
![]() |
372564299e | ||
![]() |
c397fe0c51 | ||
![]() |
95227e2732 | ||
![]() |
6f8d6da77f | ||
![]() |
6f15aec644 | ||
![]() |
9bed177f10 | ||
![]() |
7de4f16710 | ||
![]() |
beac43f41f | ||
![]() |
8538d5dcf1 | ||
![]() |
0fb294ade4 | ||
![]() |
0f6a682ea6 | ||
![]() |
c4fc20a033 | ||
![]() |
a24e2bfc76 | ||
![]() |
6a83588fdd | ||
![]() |
0092b3629e | ||
![]() |
c0eedcd4ce | ||
![]() |
d1b6d5f33d | ||
![]() |
fe297fc6d8 | ||
![]() |
384fcea585 | ||
![]() |
2f2b44a1bd | ||
![]() |
8386daddcb | ||
![]() |
739a23e506 | ||
![]() |
5a59155a05 | ||
![]() |
1ad917e2f6 | ||
![]() |
859844eae3 | ||
![]() |
857b9848d2 | ||
![]() |
5f98fcf00b | ||
![]() |
5a492e8196 | ||
![]() |
80cb52c944 | ||
![]() |
4436c09c9d | ||
![]() |
23cf7a2e0d | ||
![]() |
4a62e1c0ca | ||
![]() |
173afd8564 | ||
![]() |
f6b9ebb838 | ||
![]() |
f1b109005c | ||
![]() |
0bd58cd727 | ||
![]() |
de1292f8ac | ||
![]() |
a6d5c1fe05 | ||
![]() |
fc5bd11dac | ||
![]() |
e767840874 | ||
![]() |
fd08ca3823 | ||
![]() |
3bf60755cb | ||
![]() |
aac7d1c2ae | ||
![]() |
55caed2011 | ||
![]() |
53058af284 | ||
![]() |
ad1a11164c | ||
![]() |
5f6a4fe643 | ||
![]() |
c85ea238ca | ||
![]() |
5c0b2d04f4 | ||
![]() |
76e64053c3 | ||
![]() |
ddfa59a52b | ||
![]() |
e3fb974fc7 | ||
![]() |
9120fbd501 | ||
![]() |
52181848da | ||
![]() |
10cbe04fc5 | ||
![]() |
8367b00e8c | ||
![]() |
4a4f289adc | ||
![]() |
467f1d52e4 |
45
.github/workflows/create-test-plan.py
vendored
45
.github/workflows/create-test-plan.py
vendored
@@ -28,6 +28,7 @@ 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"
|
||||
@@ -50,18 +51,19 @@ 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"
|
||||
|
||||
|
||||
@@ -105,21 +107,24 @@ 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", ),
|
||||
"msvc-x86": JobSpec(name="Windows (MSVC, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, msvc_project="VisualC/SDL.sln", ),
|
||||
"msvc-static-x86": JobSpec(name="Windows (MSVC, static VCRT, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, msvc_static_crt=True, ),
|
||||
"msvc-arm64": JobSpec(name="Windows (MSVC, ARM64)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm64", msvc_arch=MsvcArch.Arm64, ),
|
||||
"msvc-arm32": JobSpec(name="Windows (MSVC, ARM)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-arm32", msvc_arch=MsvcArch.Arm32, ),
|
||||
"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-static-x86": JobSpec(name="Windows (MSVC, static VCRT, x86)", os=JobOs.WindowsLatest, platform=SdlPlatform.Msvc, artifact="SDL-VC-x86", msvc_arch=MsvcArch.X86, 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 22.04 (Intel oneAPI)", os=JobOs.Ubuntu22_04, platform=SdlPlatform.Linux, artifact="SDL-ubuntu22.04-oneapi", intel=IntelCompiler.Icx, ),
|
||||
"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, ),
|
||||
"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, ),
|
||||
@@ -134,7 +139,6 @@ 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 ),
|
||||
@@ -177,7 +181,6 @@ 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 = ""
|
||||
@@ -223,7 +226,6 @@ 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 = {
|
||||
@@ -257,7 +259,6 @@ 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),
|
||||
@@ -290,7 +291,6 @@ 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,6 +344,10 @@ 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;"
|
||||
@@ -380,9 +384,11 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
match spec.msvc_arch:
|
||||
case MsvcArch.X86:
|
||||
job.cflags.append("/clang:-m32")
|
||||
job.cxxflags.append("/clang:-m32")
|
||||
job.ldflags.append("/MACHINE:X86")
|
||||
case MsvcArch.X64:
|
||||
job.cflags.append("/clang:-m64")
|
||||
job.cxxflags.append("/clang:-m64")
|
||||
job.ldflags.append("/MACHINE:X64")
|
||||
case _:
|
||||
raise ValueError(f"Unsupported clang-cl architecture (arch={spec.msvc_arch})")
|
||||
@@ -606,14 +612,11 @@ 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 = []
|
||||
job.apt_packages = ["ninja-build", "binutils"]
|
||||
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}"
|
||||
@@ -626,7 +629,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, )
|
||||
job.msys2_no_perl = spec.msys2_platform in (Msys2Platform.Mingw32, Msys2Platform.Clang32)
|
||||
job.shared_lib = SharedLibType.WIN32
|
||||
job.static_lib = StaticLibType.A
|
||||
case SdlPlatform.Riscos:
|
||||
@@ -645,7 +648,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 | SdlPlatform.OpenBSD:
|
||||
case SdlPlatform.FreeBSD | SdlPlatform.NetBSD:
|
||||
job.build_autotools_tests = False
|
||||
job.cpactions = True
|
||||
job.no_cmake = True
|
||||
@@ -656,7 +659,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 = "13.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"
|
||||
@@ -666,16 +669,10 @@ def spec_to_job(spec: JobSpec, key: str, trackmem_symbol_names: bool) -> JobDeta
|
||||
))
|
||||
case SdlPlatform.NetBSD:
|
||||
job.cpactions_os = "netbsd"
|
||||
job.cpactions_version = "10.1"
|
||||
job.cpactions_version = "10.0"
|
||||
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.4"
|
||||
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 xwayland libxkbcommon libinotify pulseaudio dbus ibus"
|
||||
case SdlPlatform.Watcom:
|
||||
match spec.watcom_platform:
|
||||
case WatcomPlatform.OS2:
|
||||
|
14
.github/workflows/generic.yml
vendored
14
.github/workflows/generic.yml
vendored
@@ -177,7 +177,7 @@ jobs:
|
||||
#shell: ${{ matrix.platform.shell }}
|
||||
run: |
|
||||
${{ matrix.platform.source-cmd }}
|
||||
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -G "${{ matrix.platform.cmake-generator }}" \
|
||||
${{ matrix.platform.cmake-config-emulator }} cmake -S . -B build -GNinja \
|
||||
-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('{0} build/{1} | grep "Github Workflow"', matrix.platform.binutils-strings, matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
|
||||
${{ (matrix.platform.shared-lib && format('strings build/{0} | grep "Github Workflow"', matrix.platform.shared-lib)) || 'echo "<Shared library not supported by platform>"' }}
|
||||
echo "Static library:"
|
||||
${{ (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>"' }}
|
||||
${{ (matrix.platform.static-lib && format('strings build/{0} | grep "Github Workflow"', 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,11 +264,11 @@ 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.25.0
|
||||
with:
|
||||
operating_system: '${{ matrix.platform.cpactions-os }}'
|
||||
architecture: '${{ matrix.platform.cpactions-arch }}'
|
||||
version: '${{ matrix.platform.cpactions-version }}'
|
||||
operating_system: ${{ matrix.platform.cpactions-os }}
|
||||
architecture: ${{ matrix.platform.cpactions-arch }}
|
||||
version: ${{ matrix.platform.cpactions-version }}
|
||||
run: |
|
||||
${{ matrix.platform.cpactions-setup-cmd }}
|
||||
${{ matrix.platform.cpactions-install-cmd }}
|
||||
|
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -181,7 +181,7 @@ jobs:
|
||||
|
||||
msvc:
|
||||
needs: [src]
|
||||
runs-on: windows-2025
|
||||
runs-on: windows-2019
|
||||
outputs:
|
||||
VC-x86: ${{ steps.releaser.outputs.VC-x86 }}
|
||||
VC-x64: ${{ steps.releaser.outputs.VC-x64 }}
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -15,7 +15,7 @@ build
|
||||
gen
|
||||
Build
|
||||
buildbot
|
||||
/REVISION.txt
|
||||
/VERSION.txt
|
||||
dist
|
||||
|
||||
*.so
|
||||
|
@@ -1,9 +1,9 @@
|
||||
projectfullname = Simple Directmedia Layer
|
||||
projectshortname = SDL
|
||||
projectfullname = SDL2
|
||||
projectshortname = SDL2
|
||||
incsubdir = include
|
||||
wikisubdir = SDL2
|
||||
readmesubdir = docs
|
||||
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_|[US]int\d+)
|
||||
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
|
||||
mainincludefname = SDL.h
|
||||
versionfname = include/SDL_version.h
|
||||
versionmajorregex = \A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z
|
||||
@@ -14,19 +14,4 @@ projecturl = https://libsdl.org/
|
||||
wikiurl = https://wiki.libsdl.org/SDL2
|
||||
bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new
|
||||
warn_about_missing = 0
|
||||
#wikipreamble = (This is the legacy documentation for SDL2, the previous stable version; [SDL3](https://wiki.libsdl.org/SDL3/) is the current stable version.)
|
||||
wikiheaderfiletext = Defined in [%fname%](https://github.com/libsdl-org/SDL/blob/SDL2/include/%fname%)
|
||||
manpageheaderfiletext = Defined in %fname%
|
||||
|
||||
# All SDL_config_*.h headers are uncategorized, in case something slips in from them.
|
||||
# All SDL_test_* headers become uncategorized, everything else just converts like SDL_audio.h -> Audio
|
||||
# A handful of others we fix up in the header itself with /* WIKI CATEGORY: x */ comments.
|
||||
headercategoryeval = s/\ASDL_config_.*?\.h\Z//; s/\ASDL_test_.*?\.h\Z//; s/\ASDL_?(.*?)\.h\Z/$1/; ucfirst();
|
||||
|
||||
# !!! FIXME: maybe later, but there are probably documentation gaps to fix first.
|
||||
quickrefenabled = 0
|
||||
quickrefcategoryorder = Init,Hints,Error,Version,Properties,Log,Video,Events,Keyboard,Mouse,Touch,Gesture,GameController,Joystick,Haptic,Audio,Timer,Render,LoadSO,Thread,Mutex,Atomic,Filesystem,RWOPS,Pixels,Surface,Blendmode,Rect,Clipboard,Messagebox,Vulkan,Metal,Platform,Power,Sensor,Bits,Endian,Assert,CPUInfo,Locale,System,Misc,GUID,Main,Stdinc
|
||||
quickreftitle = SDL2 API Quick Reference
|
||||
quickrefurl = https://libsdl.org/
|
||||
quickrefdesc = The latest version of this document can be found at https://wiki.libsdl.org/SDL2/QuickReference
|
||||
quickrefmacroregex = \A(SDL_Atomic...Ref|SDL_assert.*?|SDL_arraysize|SDL_Swap[BL]E\d\d|SDL_[a-z]+_cast|SDL_Load...)\Z
|
||||
wikipreamble = (This is the legacy documentation for stable SDL2, the current stable version; [SDL3](https://wiki.libsdl.org/SDL3/) is the current development version.)
|
||||
|
@@ -35,7 +35,6 @@ LOCAL_SRC_FILES := \
|
||||
$(wildcard $(LOCAL_PATH)/src/hidapi/android/*.cpp) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/dummy/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/hidapi/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/joystick/virtual/*.c) \
|
||||
$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
|
||||
|
175
CMakeLists.txt
175
CMakeLists.txt
@@ -6,7 +6,7 @@ endif()
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
|
||||
|
||||
cmake_minimum_required(VERSION 3.0.0...3.10)
|
||||
project(SDL2 C)
|
||||
project(SDL2 C CXX)
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
set(SDL2_SUBPROJECT OFF)
|
||||
@@ -15,15 +15,13 @@ else()
|
||||
endif()
|
||||
|
||||
if (HAIKU)
|
||||
enable_language(CXX)
|
||||
set(LINKER_LANGUAGE CXX)
|
||||
endif()
|
||||
|
||||
set(EXTRA_LIBS)
|
||||
set(EXTRA_LDFLAGS)
|
||||
|
||||
set(CMAKE_LIBS)
|
||||
set(PKGCONFIG_LDFLAGS)
|
||||
set(CMAKE_DEPENDS)
|
||||
set(PKGCONFIG_DEPENDS)
|
||||
|
||||
# This is a virtual "library" that just exists to collect up compiler and
|
||||
@@ -88,8 +86,8 @@ endif()
|
||||
|
||||
# See docs/release_checklist.md
|
||||
set(SDL_MAJOR_VERSION 2)
|
||||
set(SDL_MINOR_VERSION 33)
|
||||
set(SDL_MICRO_VERSION 0)
|
||||
set(SDL_MINOR_VERSION 30)
|
||||
set(SDL_MICRO_VERSION 11)
|
||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||
|
||||
# Set defaults preventing destination file conflicts
|
||||
@@ -142,7 +140,6 @@ check_cpu_architecture(x86 SDL_CPU_X86)
|
||||
check_cpu_architecture(x64 SDL_CPU_X64)
|
||||
check_cpu_architecture(arm32 SDL_CPU_ARM32)
|
||||
check_cpu_architecture(arm64 SDL_CPU_ARM64)
|
||||
check_cpu_architecture(arm64ec SDL_CPU_ARM64EC)
|
||||
check_cpu_architecture(loongarch64 SDL_CPU_LOONGARCH64)
|
||||
|
||||
# Check for 64 or 32 bit
|
||||
@@ -198,7 +195,7 @@ endif()
|
||||
# so we'll just use libusb when it's available. libusb does not support iOS,
|
||||
# so we default to yes on iOS.
|
||||
# TODO: Windows can support libusb, the hid.c file just depends on Unix APIs
|
||||
if((WINDOWS AND NOT WINDOWS_STORE) OR IOS OR TVOS OR VISIONOS OR WATCHOS OR ANDROID)
|
||||
if((WINDOWS AND NOT WINDOWS_STORE) OR IOS OR TVOS OR ANDROID)
|
||||
set(HIDAPI_SKIP_LIBUSB TRUE)
|
||||
else()
|
||||
set(HIDAPI_SKIP_LIBUSB FALSE)
|
||||
@@ -241,10 +238,10 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC)
|
||||
endif()
|
||||
|
||||
# Default option knobs
|
||||
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS OR SDL_CPU_ARM64EC)
|
||||
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
|
||||
set(OPT_DEF_LIBC ON)
|
||||
endif()
|
||||
if(WINDOWS OR MACOS OR IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if(WINDOWS OR DARWIN OR MACOSX OR IOS OR TVOS)
|
||||
set(SDL_SYSTEM_ICONV_DEFAULT OFF)
|
||||
else()
|
||||
set(SDL_SYSTEM_ICONV_DEFAULT ON)
|
||||
@@ -363,11 +360,6 @@ if(VITA OR PSP OR PS2 OR N3DS)
|
||||
set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
set(SDL_X11_XRANDR_DEFAULT ON)
|
||||
if(SOLARIS)
|
||||
set(SDL_X11_XRANDR_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
# When defined, respect CMake's BUILD_SHARED_LIBS setting:
|
||||
set(SDL_STATIC_ENABLED_BY_DEFAULT ON)
|
||||
if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT)
|
||||
@@ -464,19 +456,17 @@ set_option(SDL_RPATH "Use an rpath when linking SDL" ${UNIX_SYS})
|
||||
set_option(SDL_CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" ${SDL_CLOCK_GETTIME_ENABLED_BY_DEFAULT})
|
||||
set_option(SDL_X11 "Use X11 video driver" ${UNIX_SYS})
|
||||
dep_option(SDL_X11_SHARED "Dynamically load X11 support" ON "SDL_X11" OFF)
|
||||
dep_option(SDL_X11_XCURSOR "Enable Xcursor support" ON SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XDBE "Enable Xdbe support" ON SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XINPUT "Enable XInput support" ON SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XFIXES "Enable Xfixes support" ON SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XRANDR "Enable Xrandr support" "${SDL_X11_XRANDR_DEFAULT}" SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XSCRNSAVER "Enable Xscrnsaver support" ON SDL_X11 OFF)
|
||||
dep_option(SDL_X11_XSHAPE "Enable XShape support" ON SDL_X11 OFF)
|
||||
set(SDL_X11_OPTIONS Xcursor Xdbe XInput Xfixes Xrandr Xscrnsaver XShape)
|
||||
foreach(_SUB ${SDL_X11_OPTIONS})
|
||||
string(TOUPPER "SDL_X11_${_SUB}" _OPT)
|
||||
dep_option(${_OPT} "Enable ${_SUB} support" ON "SDL_X11" OFF)
|
||||
endforeach()
|
||||
set_option(SDL_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
|
||||
dep_option(SDL_WAYLAND_SHARED "Dynamically load Wayland support" ON "SDL_WAYLAND" OFF)
|
||||
dep_option(SDL_WAYLAND_LIBDECOR "Use client-side window decorations on Wayland" ON "SDL_WAYLAND" OFF)
|
||||
dep_option(SDL_WAYLAND_LIBDECOR_SHARED "Dynamically load libdecor support" ON "SDL_WAYLAND_LIBDECOR;SDL_WAYLAND_SHARED" OFF)
|
||||
dep_option(SDL_WAYLAND_QT_TOUCH "QtWayland server support for Wayland video driver" ON "SDL_WAYLAND" OFF)
|
||||
set_option(SDL_RPI "Use Raspberry Pi 0-3 video driver" ${UNIX_SYS})
|
||||
set_option(SDL_RPI "Use Raspberry Pi video driver" ${UNIX_SYS})
|
||||
set_option(SDL_COCOA "Use Cocoa video driver" ${APPLE})
|
||||
set_option(SDL_DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
|
||||
set_option(SDL_XINPUT "Use Xinput for Windows" ${WINDOWS})
|
||||
@@ -755,11 +745,6 @@ 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")
|
||||
@@ -1099,7 +1084,6 @@ 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)
|
||||
@@ -1471,14 +1455,10 @@ elseif(EMSCRIPTEN)
|
||||
elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
||||
if(SDL_AUDIO)
|
||||
if(SYSV5 OR SOLARIS OR HPUX)
|
||||
# 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()
|
||||
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)
|
||||
elseif(NETBSD)
|
||||
set(SDL_AUDIO_DRIVER_NETBSD 1)
|
||||
file(GLOB NETBSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/netbsd/*.c)
|
||||
@@ -1793,7 +1773,6 @@ elseif(WINDOWS)
|
||||
list(APPEND SOURCE_FILES ${CORE_SOURCES})
|
||||
|
||||
if(WINDOWS_STORE)
|
||||
enable_language(CXX)
|
||||
file(GLOB WINRT_SOURCE_FILES ${SDL2_SOURCE_DIR}/src/core/winrt/*.c ${SDL2_SOURCE_DIR}/src/core/winrt/*.cpp)
|
||||
list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
|
||||
endif()
|
||||
@@ -1839,10 +1818,8 @@ 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
|
||||
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}")
|
||||
target_link_directories(sdl-build-options INTERFACE "$$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}")
|
||||
target_include_directories(sdl-build-options INTERFACE "$ENV{DXSDK_DIR}\\Include")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
@@ -2077,7 +2054,6 @@ elseif(WINDOWS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
enable_language(RC)
|
||||
file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
|
||||
file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
|
||||
if(MINGW OR CYGWIN)
|
||||
@@ -2095,7 +2071,7 @@ elseif(APPLE)
|
||||
# !!! FIXME: we need Carbon for some very old API calls in
|
||||
# !!! FIXME: src/video/cocoa/SDL_cocoakeyboard.c, but we should figure out
|
||||
# !!! FIXME: how to dump those.
|
||||
if(MACOS)
|
||||
if(DARWIN OR MACOSX)
|
||||
set(SDL_FRAMEWORK_COCOA 1)
|
||||
set(SDL_FRAMEWORK_CARBON 1)
|
||||
endif()
|
||||
@@ -2109,12 +2085,12 @@ elseif(APPLE)
|
||||
set(HAVE_SDL_FILE TRUE)
|
||||
endif()
|
||||
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS OR TVOS)
|
||||
file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/uikit/*.c)
|
||||
endif()
|
||||
|
||||
if(SDL_MISC)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS OR TVOS)
|
||||
file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/ios/*.m)
|
||||
else()
|
||||
file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m)
|
||||
@@ -2139,10 +2115,10 @@ elseif(APPLE)
|
||||
|
||||
if(SDL_JOYSTICK)
|
||||
file(GLOB MFI_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS OR TVOS)
|
||||
file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
|
||||
set(SDL_JOYSTICK_MFI 1)
|
||||
if(IOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS)
|
||||
set(SDL_FRAMEWORK_COREMOTION 1)
|
||||
endif()
|
||||
set(SDL_FRAMEWORK_GAMECONTROLLER 1)
|
||||
@@ -2183,7 +2159,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(SDL_HAPTIC)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if (IOS OR TVOS)
|
||||
file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
|
||||
set(SDL_HAPTIC_DUMMY 1)
|
||||
else()
|
||||
@@ -2197,7 +2173,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(SDL_POWER)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if (IOS OR TVOS)
|
||||
file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
|
||||
set(SDL_POWER_UIKIT 1)
|
||||
else()
|
||||
@@ -2230,7 +2206,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(SDL_SENSOR)
|
||||
if(IOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS)
|
||||
set(SDL_SENSOR_COREMOTION 1)
|
||||
set(HAVE_SDL_SENSORS TRUE)
|
||||
file(GLOB SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/coremotion/*.m)
|
||||
@@ -2240,7 +2216,7 @@ elseif(APPLE)
|
||||
|
||||
# iOS hack needed - http://code.google.com/p/ios-cmake/ ?
|
||||
if(SDL_VIDEO)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if (IOS OR TVOS)
|
||||
set(SDL_VIDEO_DRIVER_UIKIT 1)
|
||||
set(SDL_FRAMEWORK_COREGRAPHICS 1)
|
||||
set(SDL_FRAMEWORK_QUARTZCORE 1)
|
||||
@@ -2261,7 +2237,7 @@ elseif(APPLE)
|
||||
endif()
|
||||
|
||||
if(SDL_OPENGLES)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
if(IOS OR TVOS)
|
||||
set(SDL_FRAMEWORK_OPENGLES 1)
|
||||
set(SDL_VIDEO_OPENGL_ES 1)
|
||||
set(SDL_VIDEO_RENDER_OGL_ES 1)
|
||||
@@ -2304,96 +2280,73 @@ elseif(APPLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Minimum version for $<LINK_LIBRARY:feature,library-list>
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
# Actually load the frameworks at the end so we don't duplicate include.
|
||||
if(SDL_FRAMEWORK_COREVIDEO)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,CoreVideo")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,CoreVideo>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreVideo")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COCOA)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,Cocoa")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,Cocoa>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Cocoa")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_IOKIT)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,IOKit")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,IOKit>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,IOKit")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_FF)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,ForceFeedback")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,ForceFeedback>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,ForceFeedback")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_CARBON)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,Carbon")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,Carbon>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Carbon")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREAUDIO)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,CoreAudio")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,CoreAudio>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreAudio")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_AUDIOTOOLBOX)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,AudioToolbox")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,AudioToolbox>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,AudioToolbox")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_AVFOUNDATION)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,AVFoundation")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,AVFoundation>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,AVFoundation")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREBLUETOOTH)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,CoreBluetooth")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,CoreBluetooth>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreBluetooth")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREGRAPHICS)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,CoreGraphics")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,CoreGraphics>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreGraphics")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREMOTION)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,CoreMotion")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,Coremotion>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,CoreMotion")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_FOUNDATION)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,Foundation")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,Foundation>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Foundation")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_GAMECONTROLLER)
|
||||
find_library(GAMECONTROLLER GameController)
|
||||
if(GAMECONTROLLER)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-weak_framework,GameController")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:WEAK_FRAMEWORK,GameController>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,GameController")
|
||||
endif()
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_METAL)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,Metal")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,Metal>")
|
||||
if(IOS OR TVOS)
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,Metal")
|
||||
else()
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-weak_framework,Metal")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:WEAK_FRAMEWORK,Metal>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,Metal")
|
||||
endif()
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_OPENGLES)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,OpenGLES")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,OpenGLES>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,OpenGLES")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_QUARTZCORE)
|
||||
if(IOS OR TVOS OR VISIONOS OR WATCHOS)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,QuartzCore")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,QuartzCore>")
|
||||
if(IOS OR TVOS)
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,QuartzCore")
|
||||
else()
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-weak_framework,QuartzCore")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:WEAK_FRAMEWORK,QuartzCore>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,QuartzCore")
|
||||
endif()
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_UIKIT)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-framework,UIKit")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:FRAMEWORK,UIKit>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-framework,UIKit")
|
||||
endif()
|
||||
if(SDL_FRAMEWORK_COREHAPTICS)
|
||||
find_library(COREHAPTICS CoreHaptics)
|
||||
if(COREHAPTICS)
|
||||
list(APPEND PKGCONFIG_LDFLAGS "-Wl,-weak_framework,CoreHaptics")
|
||||
list(APPEND CMAKE_LIBS "$<LINK_LIBRARY:WEAK_FRAMEWORK,CoreHaptics>")
|
||||
list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,CoreHaptics")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -3199,7 +3152,7 @@ endif()
|
||||
|
||||
# Clean up the different lists
|
||||
listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
|
||||
set(SDL_STATIC_LIBS ${EXTRA_LDFLAGS} ${_EXTRA_LIBS} ${PKGCONFIG_LDFLAGS})
|
||||
set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
|
||||
list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
|
||||
listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
|
||||
set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
|
||||
@@ -3233,11 +3186,9 @@ macro(check_add_debug_flag FLAG SUFFIX)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX})
|
||||
if (HAS_CXX_${SUFFIX})
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX})
|
||||
if (HAS_CXX_${SUFFIX})
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -3256,20 +3207,18 @@ macro(asan_check_add_debug_flag2 ASAN_FLAG)
|
||||
|
||||
set (STORED_REQLIBS ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set (CMAKE_REQUIRED_LIBRARIES "${FLAG};asan")
|
||||
|
||||
check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG})
|
||||
check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG})
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS})
|
||||
|
||||
if (HAS_C_FLAG_${ASAN_FLAG})
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG})
|
||||
if (HAS_CXX_${ASAN_FLAG})
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
if (HAS_CXX_${ASAN_FLAG})
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||
endif()
|
||||
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS})
|
||||
if(HAS_C_${ASAN_FLAG} OR HAS_CXX_${ASAN_FLAG})
|
||||
set(HAVE_ASAN ON)
|
||||
endif()
|
||||
@@ -3493,7 +3442,7 @@ if(SDL_SHARED)
|
||||
set_property(TARGET SDL2 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " /NODEFAULTLIB")
|
||||
endif()
|
||||
# FIXME: if CMAKE_VERSION >= 3.13, use target_link_options for EXTRA_LDFLAGS
|
||||
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD} ${CMAKE_LIBS})
|
||||
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD} ${CMAKE_DEPENDS})
|
||||
target_include_directories(SDL2 PUBLIC
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
||||
@@ -3529,7 +3478,7 @@ if(SDL_STATIC)
|
||||
target_compile_definitions(SDL2-static PRIVATE SDL_STATIC_LIB)
|
||||
# TODO: Win32 platforms keep the same suffix .lib for import and static
|
||||
# libraries - do we need to consider this?
|
||||
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${CMAKE_LIBS})
|
||||
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${CMAKE_DEPENDS})
|
||||
target_include_directories(SDL2-static PUBLIC
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
||||
|
@@ -14,8 +14,8 @@
|
||||
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 33
|
||||
MICRO_VERSION = 0
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 11
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
DESCRIPTION = Simple DirectMedia Layer 2
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
|
||||
LIBNAME = SDL2
|
||||
MAJOR_VERSION = 2
|
||||
MINOR_VERSION = 33
|
||||
MICRO_VERSION = 0
|
||||
MINOR_VERSION = 30
|
||||
MICRO_VERSION = 11
|
||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||
|
||||
LIBHOME = .
|
||||
|
@@ -52,4 +52,4 @@
|
||||
<UniqueIdentifier>{e704dcb9-c83c-4c94-a139-b0f3e3f428f2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -398,4 +398,4 @@ copy "%(FullPath)" "$(OutDir)\"</Command>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -50,4 +50,4 @@
|
||||
<UniqueIdentifier>{ac7aa2d5-f0f7-46eb-a548-5b6316f3b63b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -392,4 +392,4 @@ copy "%(FullPath)" "$(OutDir)\"</Command>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -49,4 +49,4 @@
|
||||
<UniqueIdentifier>{9bf62acf-6661-43f9-bde3-0de9e1db4290}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -371,7 +371,6 @@
|
||||
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformMinVersion>10.0.0.0</WindowsTargetPlatformMinVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
@@ -392,7 +391,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
@@ -604,4 +603,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -188,12 +188,6 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
|
||||
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
|
||||
<Private>false</Private>
|
||||
|
@@ -216,12 +216,6 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
|
||||
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
|
||||
<Private>false</Private>
|
||||
|
@@ -188,12 +188,6 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
|
||||
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
|
||||
<Private>false</Private>
|
||||
|
@@ -194,12 +194,6 @@
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
|
||||
<Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
|
||||
<Private>false</Private>
|
||||
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
|
||||
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
|
||||
<Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
|
||||
<Private>false</Private>
|
||||
|
@@ -456,10 +456,7 @@ 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;
|
||||
}
|
||||
@@ -469,17 +466,10 @@ main(int argc, char *argv[])
|
||||
spawnEmitterParticle(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
}
|
||||
stepParticles(deltaTime);
|
||||
drawParticles();
|
||||
SDL_GL_SwapWindow(window);
|
||||
SDL_Delay(1);
|
||||
}
|
||||
|
||||
/* delete textures */
|
||||
|
@@ -19,10 +19,10 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.33.0</string>
|
||||
<string>2.30.11</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.33.0</string>
|
||||
<string>2.30.11</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
@@ -9728,8 +9728,8 @@
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEPLOYMENT_POSTPROCESSING = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3301.0.0;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.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.33.0;
|
||||
MARKETING_VERSION = 2.30.11;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Release;
|
||||
@@ -9813,8 +9813,8 @@
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3301.0.0;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.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.33.0;
|
||||
MARKETING_VERSION = 2.30.11;
|
||||
OTHER_LDFLAGS = "-liconv";
|
||||
};
|
||||
name = Debug;
|
||||
@@ -10062,8 +10062,8 @@
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3301.0.0;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.11.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
@@ -10114,8 +10114,8 @@
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3301.0.0;
|
||||
DYLIB_COMPATIBILITY_VERSION = 3001.0.0;
|
||||
DYLIB_CURRENT_VERSION = 3001.11.0;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
Title SDL 2.33.0
|
||||
Title SDL 2.30.11
|
||||
Version 1
|
||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||
DefaultLocation /Library/Frameworks
|
||||
|
44
acinclude/libtool.m4
vendored
44
acinclude/libtool.m4
vendored
@@ -1023,21 +1023,6 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
|
||||
rm -f conftest.*
|
||||
fi])
|
||||
|
||||
# Feature test to disable chained fixups since it is not
|
||||
# compatible with '-undefined dynamic_lookup'
|
||||
AC_CACHE_CHECK([for -no_fixup_chains linker flag],
|
||||
[lt_cv_support_no_fixup_chains],
|
||||
[ save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,-no_fixup_chains"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([],[])],
|
||||
lt_cv_support_no_fixup_chains=yes,
|
||||
lt_cv_support_no_fixup_chains=no
|
||||
)
|
||||
LDFLAGS=$save_LDFLAGS
|
||||
]
|
||||
)
|
||||
|
||||
AC_CACHE_CHECK([for -exported_symbols_list linker flag],
|
||||
[lt_cv_ld_exported_symbols_list],
|
||||
[lt_cv_ld_exported_symbols_list=no
|
||||
@@ -1062,7 +1047,7 @@ _LT_EOF
|
||||
echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
|
||||
$RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
|
||||
cat > conftest.c << _LT_EOF
|
||||
int main(void) { return 0;}
|
||||
int main() { return 0;}
|
||||
_LT_EOF
|
||||
echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
|
||||
$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
|
||||
@@ -1087,12 +1072,7 @@ _LT_EOF
|
||||
10.[[012]],*|,*powerpc*-darwin[[5-8]]*)
|
||||
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
|
||||
*)
|
||||
if test yes = "$lt_cv_support_no_fixup_chains"; then
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup $wl-no_fixup_chains'
|
||||
else
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup'
|
||||
fi
|
||||
;;
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@@ -1882,11 +1862,11 @@ else
|
||||
/* When -fvisibility=hidden is used, assume the code has been annotated
|
||||
correspondingly for the symbols needed. */
|
||||
#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
|
||||
int fnord (void) __attribute__((visibility("default")));
|
||||
int fnord () __attribute__((visibility("default")));
|
||||
#endif
|
||||
|
||||
int fnord (void) { return 42; }
|
||||
int main (void)
|
||||
int fnord () { return 42; }
|
||||
int main ()
|
||||
{
|
||||
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
|
||||
int status = $lt_dlunknown;
|
||||
@@ -2567,14 +2547,14 @@ cygwin* | mingw* | windows* | pw32* | cegcc*)
|
||||
cygwin*)
|
||||
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
|
||||
#soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
m4_if([$1], [],[
|
||||
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
|
||||
;;
|
||||
mingw* | windows* | cegcc*)
|
||||
# MinGW DLLs use traditional 'lib' prefix
|
||||
#soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
;;
|
||||
pw32*)
|
||||
# pw32 DLLs use 'pw' prefix rather than 'lib'
|
||||
@@ -3486,7 +3466,7 @@ cygwin*)
|
||||
# func_win32_libid is a shell function defined in ltmain.sh
|
||||
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
|
||||
lt_cv_file_magic_cmd='func_win32_libid'
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization.
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization
|
||||
;;
|
||||
|
||||
mingw* | windows* | pw32*)
|
||||
@@ -3498,10 +3478,10 @@ mingw* | windows* | pw32*)
|
||||
lt_cv_file_magic_cmd='func_win32_libid'
|
||||
else
|
||||
# Keep this pattern in sync with the one in func_win32_libid.
|
||||
lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)'
|
||||
lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
|
||||
lt_cv_file_magic_cmd='$OBJDUMP -f'
|
||||
fi
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization.
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization
|
||||
;;
|
||||
|
||||
cegcc*)
|
||||
@@ -4072,7 +4052,7 @@ void nm_test_func(void){}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
int main(void){nm_test_var='a';nm_test_func();return(0);}
|
||||
int main(){nm_test_var='a';nm_test_func();return(0);}
|
||||
_LT_EOF
|
||||
|
||||
if AC_TRY_EVAL(ac_compile); then
|
||||
@@ -6238,7 +6218,7 @@ _LT_TAGVAR(objext, $1)=$objext
|
||||
lt_simple_compile_test_code="int some_variable = 0;"
|
||||
|
||||
# Code to be used in simple link tests
|
||||
lt_simple_link_test_code='int main(void){return(0);}'
|
||||
lt_simple_link_test_code='int main(){return(0);}'
|
||||
|
||||
_LT_TAG_COMPILER
|
||||
# Save the default compiler, since it gets overwritten when the other
|
||||
|
81
android-project/app/proguard-rules.pro
vendored
81
android-project/app/proguard-rules.pro
vendored
@@ -15,84 +15,3 @@
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLInputConnection {
|
||||
void nativeCommitText(java.lang.String, int);
|
||||
void nativeGenerateScancodeForUnichar(char);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses class org.libsdl.app.SDLActivity {
|
||||
# for some reason these aren't compatible with allowoptimization modifier
|
||||
boolean supportsRelativeMouse();
|
||||
void setWindowStyle(boolean);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLActivity {
|
||||
java.lang.String nativeGetHint(java.lang.String); # Java-side doesn't use this, so it gets minified, but C-side still tries to register it
|
||||
boolean onNativeSoftReturnKey();
|
||||
void onNativeKeyboardFocusLost();
|
||||
boolean isScreenKeyboardShown();
|
||||
android.util.DisplayMetrics getDisplayDPI();
|
||||
java.lang.String clipboardGetText();
|
||||
boolean clipboardHasText();
|
||||
void clipboardSetText(java.lang.String);
|
||||
int createCustomCursor(int[], int, int, int, int);
|
||||
void destroyCustomCursor(int);
|
||||
android.content.Context getContext();
|
||||
boolean getManifestEnvironmentVariables();
|
||||
android.view.Surface getNativeSurface();
|
||||
void initTouch();
|
||||
boolean isAndroidTV();
|
||||
boolean isChromebook();
|
||||
boolean isDeXMode();
|
||||
boolean isTablet();
|
||||
void manualBackButton();
|
||||
int messageboxShowMessageBox(int, java.lang.String, java.lang.String, int[], int[], java.lang.String[], int[]);
|
||||
void minimizeWindow();
|
||||
int openURL(java.lang.String);
|
||||
void requestPermission(java.lang.String, int);
|
||||
int showToast(java.lang.String, int, int, int, int);
|
||||
boolean sendMessage(int, int);
|
||||
boolean setActivityTitle(java.lang.String);
|
||||
boolean setCustomCursor(int);
|
||||
void setOrientation(int, int, boolean, java.lang.String);
|
||||
boolean setRelativeMouseEnabled(boolean);
|
||||
boolean setSystemCursor(int);
|
||||
boolean shouldMinimizeOnFocusLoss();
|
||||
boolean showTextInput(int, int, int, int);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.HIDDeviceManager {
|
||||
boolean initialize(boolean, boolean);
|
||||
boolean openDevice(int);
|
||||
int sendOutputReport(int, byte[]);
|
||||
int sendFeatureReport(int, byte[]);
|
||||
boolean getFeatureReport(int, byte[]);
|
||||
void closeDevice(int);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLAudioManager {
|
||||
int[] getAudioOutputDevices();
|
||||
int[] getAudioInputDevices();
|
||||
int[] audioOpen(int, int, int, int, int);
|
||||
void audioWriteFloatBuffer(float[]);
|
||||
void audioWriteShortBuffer(short[]);
|
||||
void audioWriteByteBuffer(byte[]);
|
||||
void audioClose();
|
||||
int[] captureOpen(int, int, int, int, int);
|
||||
int captureReadFloatBuffer(float[], boolean);
|
||||
int captureReadShortBuffer(short[], boolean);
|
||||
int captureReadByteBuffer(byte[], boolean);
|
||||
void captureClose();
|
||||
void audioSetThreadPriority(boolean, int);
|
||||
native int nativeSetupJNI();
|
||||
native void removeAudioDevice(boolean, int);
|
||||
native void addAudioDevice(boolean, int);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses,allowoptimization class org.libsdl.app.SDLControllerManager {
|
||||
void pollInputDevices();
|
||||
void pollHapticDevices();
|
||||
void hapticRun(int, float, int);
|
||||
void hapticStop(int);
|
||||
}
|
||||
|
@@ -60,8 +60,8 @@ import java.util.Locale;
|
||||
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
||||
private static final String TAG = "SDL";
|
||||
private static final int SDL_MAJOR_VERSION = 2;
|
||||
private static final int SDL_MINOR_VERSION = 33;
|
||||
private static final int SDL_MICRO_VERSION = 0;
|
||||
private static final int SDL_MINOR_VERSION = 30;
|
||||
private static final int SDL_MICRO_VERSION = 11;
|
||||
/*
|
||||
// Display InputType.SOURCE/CLASS of events and devices
|
||||
//
|
||||
@@ -790,9 +790,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
SDLActivity.mFullscreenModeActive = false;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 28 /* Android 9 (Pie) */) {
|
||||
window.getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "error handling message, getContext() returned no Activity");
|
||||
|
@@ -80,8 +80,7 @@ do
|
||||
cd $folder
|
||||
done
|
||||
|
||||
# Uppercase the first char in the activity class name because it's Java
|
||||
ACTIVITY="$(echo $folder | awk '{$1=toupper(substr($1,0,1))substr($1,2)}1')Activity"
|
||||
ACTIVITY="${folder}Activity"
|
||||
sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" $BUILDPATH/app/src/main/AndroidManifest.xml
|
||||
|
||||
# Fill in a default Activity
|
||||
|
@@ -37,8 +37,6 @@ logger = logging.getLogger(__name__)
|
||||
GIT_HASH_FILENAME = ".git-hash"
|
||||
REVISION_TXT = "REVISION.txt"
|
||||
|
||||
RE_ILLEGAL_MINGW_LIBRARIES = re.compile(r"(?:lib)?(?:gcc|(?:std)?c[+][+]|(?:win)?pthread).*", flags=re.I)
|
||||
|
||||
|
||||
def safe_isotime_to_datetime(str_isotime: str) -> datetime.datetime:
|
||||
try:
|
||||
@@ -341,12 +339,6 @@ class ArchiveFileTree:
|
||||
def add_file(self, file: NodeInArchive):
|
||||
self._tree[file.arcpath] = file
|
||||
|
||||
def __iter__(self) -> typing.Iterable[NodeInArchive]:
|
||||
yield from self._tree.values()
|
||||
|
||||
def __contains__(self, value: str) -> bool:
|
||||
return value in self._tree
|
||||
|
||||
def get_latest_mod_time(self) -> datetime.datetime:
|
||||
return max(item.time for item in self._tree.values() if item.time)
|
||||
|
||||
@@ -534,16 +526,6 @@ class SourceCollector:
|
||||
return path_times
|
||||
|
||||
|
||||
class AndroidApiVersion:
|
||||
def __init__(self, name: str, ints: tuple[int, ...]):
|
||||
self.name = name
|
||||
self.ints = ints
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<{self.name} ({'.'.join(str(v) for v in self.ints)})>"
|
||||
|
||||
ANDROID_ABI_EXTRA_LINK_OPTIONS = {}
|
||||
|
||||
class Releaser:
|
||||
def __init__(self, release_info: dict, commit: str, revision: str, root: Path, dist_path: Path, section_printer: SectionPrinter, executer: Executer, cmake_generator: str, deps_path: Path, overwrite: bool, github: bool, fast: bool):
|
||||
self.release_info = release_info
|
||||
@@ -604,22 +586,12 @@ class Releaser:
|
||||
def create_source_archives(self) -> None:
|
||||
source_collector = SourceCollector(root=self.root, commit=self.commit, executer=self.executer, filter=self._path_filter)
|
||||
print(f"Collecting sources of {self.project}...")
|
||||
archive_tree: ArchiveFileTree = source_collector.get_archive_file_tree()
|
||||
archive_tree = source_collector.get_archive_file_tree()
|
||||
latest_mod_time = archive_tree.get_latest_mod_time()
|
||||
archive_tree.add_file(NodeInArchive.from_text(arcpath=REVISION_TXT, text=f"{self.revision}\n", time=latest_mod_time))
|
||||
archive_tree.add_file(NodeInArchive.from_text(arcpath=f"{GIT_HASH_FILENAME}", text=f"{self.commit}\n", time=latest_mod_time))
|
||||
archive_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["source"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=latest_mod_time)
|
||||
|
||||
if "Makefile.am" in archive_tree:
|
||||
patched_time = latest_mod_time + datetime.timedelta(minutes=1)
|
||||
print(f"Makefile.am detected -> touching aclocal.m4, */Makefile.in, configure")
|
||||
for node_data in archive_tree:
|
||||
arc_name = os.path.basename(node_data.arcpath)
|
||||
arc_name_we, arc_name_ext = os.path.splitext(arc_name)
|
||||
if arc_name in ("aclocal.m4", "configure", "Makefile.in"):
|
||||
print(f"Bumping time of {node_data.arcpath}")
|
||||
node_data.time = patched_time
|
||||
|
||||
archive_base = f"{self.project}-{self.version}"
|
||||
zip_path = self.dist_path / f"{archive_base}.zip"
|
||||
tgz_path = self.dist_path / f"{archive_base}.tar.gz"
|
||||
@@ -696,15 +668,6 @@ class Releaser:
|
||||
def git_hash_data(self) -> bytes:
|
||||
return f"{self.commit}\n".encode()
|
||||
|
||||
def verify_mingw_library(self, triplet: str, path: Path):
|
||||
objdump_output = self.executer.check_output([f"{triplet}-objdump", "-p", str(path)])
|
||||
libraries = re.findall(r"DLL Name: ([^\n]+)", objdump_output)
|
||||
logger.info("%s (%s) libraries: %r", path, triplet, libraries)
|
||||
illegal_libraries = list(filter(RE_ILLEGAL_MINGW_LIBRARIES.match, libraries))
|
||||
logger.error("Detected 'illegal' libraries: %r", illegal_libraries)
|
||||
if illegal_libraries:
|
||||
raise Exception(f"{path} links to illegal libraries: {illegal_libraries}")
|
||||
|
||||
def create_mingw_archives(self) -> None:
|
||||
build_type = "Release"
|
||||
build_parent_dir = self.root / "build-mingw"
|
||||
@@ -801,6 +764,7 @@ class Releaser:
|
||||
f"--includedir=${{prefix}}/include",
|
||||
f"--libdir=${{prefix}}/lib",
|
||||
f"--bindir=${{prefix}}/bin",
|
||||
f"--exec-prefix=${{prefix}}/bin",
|
||||
f"--host={triplet}",
|
||||
f"--build=x86_64-none-linux-gnu",
|
||||
"CFLAGS=-O2",
|
||||
@@ -808,10 +772,9 @@ class Releaser:
|
||||
"LDFLAGS=-Wl,-s",
|
||||
] + extra_args, cwd=build_path, env=new_env)
|
||||
with self.section_printer.group(f"Build MinGW {triplet} (autotools)"):
|
||||
self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
|
||||
self.executer.run(["make", "V=1", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
|
||||
with self.section_printer.group(f"Install MinGW {triplet} (autotools)"):
|
||||
self.executer.run(["make", "install"], cwd=build_path, env=new_env)
|
||||
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
|
||||
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
|
||||
|
||||
print("Recording arch-dependent extra files for MinGW development archive ...")
|
||||
@@ -867,7 +830,6 @@ class Releaser:
|
||||
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type], cwd=build_path, env=new_env)
|
||||
with self.section_printer.group(f"Install MinGW {triplet} (CMake)"):
|
||||
self.executer.run(["cmake", "--install", str(build_path)], cwd=build_path, env=new_env)
|
||||
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
|
||||
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
|
||||
|
||||
print("Recording arch-dependent extra files for MinGW development archive ...")
|
||||
@@ -895,25 +857,22 @@ class Releaser:
|
||||
self.artifacts["mingw-devel-tar-gz"] = tgz_path
|
||||
self.artifacts["mingw-devel-tar-xz"] = txz_path
|
||||
|
||||
def _detect_android_api(self, android_home: str) -> typing.Optional[AndroidApiVersion]:
|
||||
def _detect_android_api(self, android_home: str) -> typing.Optional[int]:
|
||||
platform_dirs = list(Path(p) for p in glob.glob(f"{android_home}/platforms/android-*"))
|
||||
re_platform = re.compile("^android-([0-9]+)(?:-ext([0-9]+))?$")
|
||||
platform_versions: list[AndroidApiVersion] = []
|
||||
re_platform = re.compile("android-([0-9]+)")
|
||||
platform_versions = []
|
||||
for platform_dir in platform_dirs:
|
||||
logger.debug("Found Android Platform SDK: %s", platform_dir)
|
||||
if not (platform_dir / "android.jar").is_file():
|
||||
logger.debug("Skipping SDK, missing android.jar")
|
||||
continue
|
||||
if m:= re_platform.match(platform_dir.name):
|
||||
platform_versions.append(AndroidApiVersion(name=platform_dir.name, ints=(int(m.group(1)), int(m.group(2) or 0))))
|
||||
platform_versions.sort(key=lambda v: v.ints)
|
||||
platform_versions.append(int(m.group(1)))
|
||||
platform_versions.sort()
|
||||
logger.info("Available platform versions: %s", platform_versions)
|
||||
platform_versions = list(filter(lambda v: v.ints >= self._android_api_minimum.ints, platform_versions))
|
||||
logger.info("Valid platform versions (>=%s): %s", self._android_api_minimum.ints, platform_versions)
|
||||
platform_versions = list(filter(lambda v: v >= self._android_api_minimum, platform_versions))
|
||||
logger.info("Valid platform versions (>=%d): %s", self._android_api_minimum, platform_versions)
|
||||
if not platform_versions:
|
||||
return None
|
||||
android_api = platform_versions[0]
|
||||
logger.info("Selected API version %s", android_api)
|
||||
logger.info("Selected API version %d", android_api)
|
||||
return android_api
|
||||
|
||||
def _get_prefab_json_text(self) -> str:
|
||||
@@ -937,19 +896,8 @@ class Releaser:
|
||||
return json.dumps(module_json_dict, indent=4)
|
||||
|
||||
@property
|
||||
def _android_api_minimum(self) -> AndroidApiVersion:
|
||||
value = self.release_info["android"]["api-minimum"]
|
||||
if isinstance(value, int):
|
||||
ints = (value, )
|
||||
elif isinstance(value, str):
|
||||
ints = tuple(split("."))
|
||||
else:
|
||||
raise ValueError("Invalid android.api-minimum: must be X or X.Y")
|
||||
match len(ints):
|
||||
case 1: name = f"android-{ints[0]}"
|
||||
case 2: name = f"android-{ints[0]}-ext-{ints[1]}"
|
||||
case _: raise ValueError("Invalid android.api-minimum: must be X or X.Y")
|
||||
return AndroidApiVersion(name=name, ints=ints)
|
||||
def _android_api_minimum(self):
|
||||
return self.release_info["android"]["api-minimum"]
|
||||
|
||||
@property
|
||||
def _android_api_target(self):
|
||||
@@ -962,7 +910,7 @@ class Releaser:
|
||||
def _get_prefab_abi_json_text(self, abi: str, cpp: bool, shared: bool) -> str:
|
||||
abi_json_dict = {
|
||||
"abi": abi,
|
||||
"api": self._android_api_minimum.ints[0],
|
||||
"api": self._android_api_minimum,
|
||||
"ndk": self._android_ndk_minimum,
|
||||
"stl": "c++_shared" if cpp else "none",
|
||||
"static": not shared,
|
||||
@@ -975,7 +923,7 @@ class Releaser:
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.libsdl.android.{self.project}" android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="{self._android_api_minimum.ints[0]}"
|
||||
<uses-sdk android:minSdkVersion="{self._android_api_minimum}"
|
||||
android:targetSdkVersion="{self._android_api_target}" />
|
||||
</manifest>
|
||||
""")
|
||||
@@ -985,8 +933,7 @@ class Releaser:
|
||||
if not cmake_toolchain_file.exists():
|
||||
logger.error("CMake toolchain file does not exist (%s)", cmake_toolchain_file)
|
||||
raise SystemExit(1)
|
||||
aar_path = self.root / "build-android" / f"{self.project}-{self.version}.aar"
|
||||
android_dist_path = self.dist_path / f"{self.project}-devel-{self.version}-android.zip"
|
||||
aar_path = self.dist_path / f"{self.project}-{self.version}.aar"
|
||||
android_abis = self.release_info["android"]["abis"]
|
||||
java_jars_added = False
|
||||
module_data_added = False
|
||||
@@ -994,27 +941,16 @@ class Releaser:
|
||||
shutil.rmtree(android_deps_path, ignore_errors=True)
|
||||
|
||||
for dep, depinfo in self.release_info["android"].get("dependencies", {}).items():
|
||||
dep_devel_zip = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
|
||||
|
||||
dep_extract_path = self.deps_path / f"extract/android/{dep}"
|
||||
shutil.rmtree(dep_extract_path, ignore_errors=True)
|
||||
dep_extract_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with self.section_printer.group(f"Extracting Android dependency {dep} ({dep_devel_zip})"):
|
||||
with zipfile.ZipFile(dep_devel_zip, "r") as zf:
|
||||
zf.extractall(dep_extract_path)
|
||||
|
||||
dep_devel_aar = dep_extract_path / glob.glob("*.aar", root_dir=dep_extract_path)[0]
|
||||
self.executer.run([sys.executable, str(dep_devel_aar), "-o", str(android_deps_path)])
|
||||
android_aar = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
|
||||
with self.section_printer.group(f"Extracting Android dependency {dep} ({android_aar.name})"):
|
||||
self.executer.run([sys.executable, str(android_aar), "-o", str(android_deps_path)])
|
||||
|
||||
for module_name, module_info in self.release_info["android"]["modules"].items():
|
||||
assert "type" in module_info and module_info["type"] in ("interface", "library"), f"module {module_name} must have a valid type"
|
||||
|
||||
aar_file_tree = ArchiveFileTree()
|
||||
android_devel_file_tree = ArchiveFileTree()
|
||||
archive_file_tree = ArchiveFileTree()
|
||||
|
||||
for android_abi in android_abis:
|
||||
extra_link_options = ANDROID_ABI_EXTRA_LINK_OPTIONS.get(android_abi, "")
|
||||
with self.section_printer.group(f"Building for Android {android_api} {android_abi}"):
|
||||
build_dir = self.root / "build-android" / f"{android_abi}-build"
|
||||
install_dir = self.root / "install-android" / f"{android_abi}-install"
|
||||
@@ -1025,11 +961,8 @@ class Releaser:
|
||||
"cmake",
|
||||
"-S", str(self.root),
|
||||
"-B", str(build_dir),
|
||||
# NDK 21e does not support -ffile-prefix-map
|
||||
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
|
||||
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
|
||||
f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
|
||||
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
|
||||
f"-DCMAKE_PREFIX_PATH={str(android_deps_path)}",
|
||||
f"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH",
|
||||
@@ -1066,20 +999,20 @@ class Releaser:
|
||||
assert library.suffix in (".so", ".a")
|
||||
assert library.is_file(), f"CMake should have built library '{library}' for module {module_name}"
|
||||
arcdir_prefab_libs = f"{arcdir_prefab_module}/libs/android.{android_abi}"
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
|
||||
|
||||
if not module_data_added:
|
||||
library_name = None
|
||||
if module_info["type"] == "library":
|
||||
library_name = Path(module_info["library"]).stem.removeprefix("lib")
|
||||
export_libraries = module_info.get("export-libraries", [])
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
|
||||
arcdir_prefab_include = f"prefab/modules/{module_name}/include"
|
||||
if "includes" in module_info:
|
||||
aar_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
|
||||
archive_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
|
||||
else:
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
|
||||
module_data_added = True
|
||||
|
||||
if not java_jars_added:
|
||||
@@ -1092,28 +1025,21 @@ class Releaser:
|
||||
assert sources_jar_path.is_file(), f"CMake should have archived the java sources into a JAR ({sources_jar_path})"
|
||||
assert doc_jar_path.is_file(), f"CMake should have archived javadoc into a JAR ({doc_jar_path})"
|
||||
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
|
||||
|
||||
assert ("jars" in self.release_info["android"] and java_jars_added) or "jars" not in self.release_info["android"], "Must have archived java JAR archives"
|
||||
|
||||
aar_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["aar-files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
|
||||
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
|
||||
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
|
||||
|
||||
with Archiver(zip_path=aar_path) as archiver:
|
||||
aar_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
archive_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
|
||||
|
||||
android_devel_file_tree.add_file(NodeInArchive.from_fs(arcpath=aar_path.name, path=aar_path))
|
||||
android_devel_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
with Archiver(zip_path=android_dist_path) as archiver:
|
||||
android_devel_file_tree.add_to_archiver(archive_base="", archiver=archiver)
|
||||
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
|
||||
|
||||
self.artifacts[f"android-aar"] = android_dist_path
|
||||
self.artifacts[f"android-aar"] = aar_path
|
||||
|
||||
def download_dependencies(self):
|
||||
shutil.rmtree(self.deps_path, ignore_errors=True)
|
||||
@@ -1150,7 +1076,7 @@ class Releaser:
|
||||
assert len(msvc_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
|
||||
if "android" in self.release_info:
|
||||
android_matches = glob.glob(self.release_info["android"]["dependencies"][dep]["artifact"], root_dir=self.deps_path)
|
||||
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {android_matches}"
|
||||
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
|
||||
|
||||
@staticmethod
|
||||
def _arch_to_vs_platform(arch: str, configuration: str="Release") -> VsArchPlatformConfig:
|
||||
@@ -1276,10 +1202,6 @@ class Releaser:
|
||||
platform_context = self.get_context(extra_context=arch_platform.extra_context())
|
||||
|
||||
build_type = "Release"
|
||||
extra_context = {
|
||||
"ARCH": arch_platform.arch,
|
||||
"PLATFORM": arch_platform.platform,
|
||||
}
|
||||
|
||||
built_paths = set(install_path / configure_text(f, context=platform_context) for file_mapping in (self.release_info["msvc"]["cmake"]["files-lib"], self.release_info["msvc"]["cmake"]["files-devel"]) for files_list in file_mapping.values() for f in files_list)
|
||||
logger.info("CMake builds these files, to be included in the package: %s", built_paths)
|
||||
@@ -1330,7 +1252,7 @@ class Releaser:
|
||||
logger.info("Collecting files...")
|
||||
archive_file_tree = ArchiveFileTree()
|
||||
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["cmake"]["files-lib"], file_mapping_root=install_path, context=platform_context, time=self.arc_time)
|
||||
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["files-lib"], file_mapping_root=self.root, context=self.get_context(extra_context=extra_context), time=self.arc_time)
|
||||
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["files-lib"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
|
||||
|
||||
logger.info("Creating %s", zip_path)
|
||||
with Archiver(zip_path=zip_path) as archiver:
|
||||
@@ -1394,7 +1316,7 @@ def main(argv=None) -> int:
|
||||
parser.add_argument("--actions", choices=["download", "source", "android", "mingw", "msvc", "dmg"], required=True, nargs="+", dest="actions", help="What to do?")
|
||||
parser.set_defaults(loglevel=logging.INFO)
|
||||
parser.add_argument('--vs-year', dest="vs_year", help="Visual Studio year")
|
||||
parser.add_argument('--android-api', dest="android_api", help="Android API version")
|
||||
parser.add_argument('--android-api', type=int, dest="android_api", help="Android API version")
|
||||
parser.add_argument('--android-home', dest="android_home", default=os.environ.get("ANDROID_HOME"), help="Android Home folder")
|
||||
parser.add_argument('--android-ndk-home', dest="android_ndk_home", default=os.environ.get("ANDROID_NDK_HOME"), help="Android NDK Home folder")
|
||||
parser.add_argument('--cmake-generator', dest="cmake_generator", default="Ninja", help="CMake Generator")
|
||||
@@ -1521,27 +1443,14 @@ def main(argv=None) -> int:
|
||||
if args.android_api is None:
|
||||
with section_printer.group("Detect Android APIS"):
|
||||
args.android_api = releaser._detect_android_api(android_home=args.android_home)
|
||||
else:
|
||||
try:
|
||||
android_api_ints = tuple(int(v) for v in args.android_api.split("."))
|
||||
match len(android_api_ints):
|
||||
case 1: android_api_name = f"android-{android_api_ints[0]}"
|
||||
case 2: android_api_name = f"android-{android_api_ints[0]}-ext-{android_api_ints[1]}"
|
||||
case _: raise ValueError
|
||||
except ValueError:
|
||||
logger.error("Invalid --android-api, must be a 'X' or 'X.Y' version")
|
||||
args.android_api = AndroidApiVersion(ints=android_api_ints, name=android_api_name)
|
||||
if args.android_api is None:
|
||||
if args.android_api is None or not (Path(args.android_home) / f"platforms/android-{args.android_api}").is_dir():
|
||||
parser.error("Invalid --android-api, and/or could not be detected")
|
||||
android_api_path = Path(args.android_home) / f"platforms/{args.android_api.name}"
|
||||
if not android_api_path.is_dir():
|
||||
logger.warning(f"Android API directory does not exist ({android_api_path})")
|
||||
with section_printer.group("Android arguments"):
|
||||
print(f"android_home = {args.android_home}")
|
||||
print(f"android_ndk_home = {args.android_ndk_home}")
|
||||
print(f"android_api = {args.android_api}")
|
||||
releaser.create_android_archives(
|
||||
android_api=args.android_api.ints[0],
|
||||
android_api=args.android_api,
|
||||
android_home=args.android_home,
|
||||
android_ndk_home=args.android_ndk_home,
|
||||
)
|
||||
|
26
build-scripts/config.guess
vendored
26
build-scripts/config.guess
vendored
@@ -1,10 +1,10 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright 1992-2025 Free Software Foundation, Inc.
|
||||
# Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2025-07-10'
|
||||
timestamp='2024-01-01'
|
||||
|
||||
# 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-2025 Free Software Foundation, Inc.
|
||||
Copyright 1992-2024 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."
|
||||
@@ -123,7 +123,7 @@ set_cc_for_build() {
|
||||
dummy=$tmp/dummy
|
||||
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
|
||||
,,) echo "int x;" > "$dummy.c"
|
||||
for driver in cc gcc c17 c99 c89 ; do
|
||||
for driver in cc gcc c89 c99 ; do
|
||||
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
|
||||
CC_FOR_BUILD=$driver
|
||||
break
|
||||
@@ -634,8 +634,7 @@ EOF
|
||||
sed 's/^ //' << EOF > "$dummy.c"
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
main()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
@@ -719,8 +718,7 @@ EOF
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
int main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
@@ -1597,11 +1595,8 @@ EOF
|
||||
*:Unleashed:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
|
||||
;;
|
||||
x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-pc-ironclad-mlibc
|
||||
;;
|
||||
*:[Ii]ronclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-ironclad-mlibc
|
||||
*:Ironclad:*:*)
|
||||
GUESS=$UNAME_MACHINE-unknown-ironclad
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1626,7 +1621,6 @@ cat > "$dummy.c" <<EOF
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
@@ -1811,8 +1805,8 @@ fi
|
||||
exit 1
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# time-stamp-start: "timestamp='"
|
||||
# time-stamp-format: "%Y-%02m-%02d"
|
||||
# time-stamp-format: "%:y-%02m-%02d"
|
||||
# time-stamp-end: "'"
|
||||
# End:
|
||||
|
751
build-scripts/config.sub
vendored
751
build-scripts/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@@ -2415,10 +2415,10 @@ libtool_validate_options ()
|
||||
# preserve --debug
|
||||
test : = "$debug_cmd" || func_append preserve_args " --debug"
|
||||
|
||||
case $host_os in
|
||||
case $host in
|
||||
# Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
|
||||
# see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
|
||||
cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*)
|
||||
*cygwin* | *mingw* | *windows* | *pw32* | *cegcc* | *solaris2* | *os2*)
|
||||
# don't eliminate duplications in $postdeps and $predeps
|
||||
opt_duplicate_compiler_generated_deps=:
|
||||
;;
|
||||
@@ -4935,7 +4935,7 @@ func_win32_libid ()
|
||||
*ar\ archive*) # could be an import, or static
|
||||
# Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
|
||||
if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
|
||||
$EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then
|
||||
$EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
|
||||
case $nm_interface in
|
||||
"MS dumpbin")
|
||||
if func_cygming_ms_implib_p "$1" ||
|
||||
@@ -5534,7 +5534,7 @@ EOF
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#if defined _WIN32 && !defined __GNUC__
|
||||
#ifdef _MSC_VER
|
||||
# include <direct.h>
|
||||
# include <process.h>
|
||||
# include <io.h>
|
||||
@@ -6501,7 +6501,7 @@ func_mode_link ()
|
||||
# we shouldn't force the makefile maintainer to figure out
|
||||
# what system we are compiling for in order to pass an extra
|
||||
# flag for every libtool invocation.
|
||||
# SDL customization: SDL code doesn't have any undefined symbols.
|
||||
# SDL customization: SDL code doesn't have any undefined symbols
|
||||
allow_undefined=no
|
||||
|
||||
# FIXME: Unfortunately, there are problems with the above when trying
|
||||
@@ -6509,7 +6509,7 @@ func_mode_link ()
|
||||
# even a static library is built. For now, we need to specify
|
||||
# -no-undefined on the libtool link line when we can be certain
|
||||
# that all symbols are satisfied, otherwise we get a static library.
|
||||
# SDL customization: SDL code doesn't have any undefined symbols.
|
||||
# SDL customization: SDL code doesn't have any undefined symbols
|
||||
# allow_undefined=yes
|
||||
;;
|
||||
*)
|
||||
@@ -7096,7 +7096,7 @@ func_mode_link ()
|
||||
continue
|
||||
;;
|
||||
-mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
|
||||
|-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
|
||||
|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
|
||||
func_append compiler_flags " $arg"
|
||||
func_append compile_command " $arg"
|
||||
func_append finalize_command " $arg"
|
||||
@@ -7310,10 +7310,7 @@ func_mode_link ()
|
||||
# -fno-sanitize* Clang/GCC memory and address sanitizer
|
||||
# -shared-libsan Link with shared sanitizer runtimes (Clang)
|
||||
# -static-libsan Link with static sanitizer runtimes (Clang)
|
||||
# -no-canonical-prefixes Do not expand any symbolic links
|
||||
# -fuse-ld=* Linker select flags for GCC
|
||||
# -static-* direct GCC to link specific libraries statically
|
||||
# -fcilkplus Cilk Plus language extension features for C/C++
|
||||
# -rtlib=* select c runtime lib with clang
|
||||
# --unwindlib=* select unwinder library with clang
|
||||
# -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
|
||||
@@ -7321,12 +7318,12 @@ func_mode_link ()
|
||||
# -Werror, -Werror=* Report (specified) warnings as errors
|
||||
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
|
||||
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
|
||||
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \
|
||||
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*| \
|
||||
-stdlib=*|-rtlib=*|--unwindlib=*| \
|
||||
-specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
|
||||
-ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
|
||||
-fdiagnostics-color*|-frecord-gcc-switches| \
|
||||
-fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*)
|
||||
-fuse-ld=*|-Wa,*|-Werror|-Werror=*)
|
||||
func_quote_for_eval "$arg"
|
||||
arg=$func_quote_for_eval_result
|
||||
func_append compile_command " $arg"
|
||||
@@ -7656,7 +7653,7 @@ func_mode_link ()
|
||||
found=false
|
||||
case $deplib in
|
||||
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
|
||||
|-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
|
||||
|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
|
||||
if test prog,link = "$linkmode,$pass"; then
|
||||
compile_deplibs="$deplib $compile_deplibs"
|
||||
finalize_deplibs="$deplib $finalize_deplibs"
|
||||
@@ -8182,8 +8179,8 @@ func_mode_link ()
|
||||
fi
|
||||
if test -n "$library_names" &&
|
||||
{ test no = "$use_static_libs" || test -z "$old_library"; }; then
|
||||
case $host_os in
|
||||
cygwin* | mingw* | windows* | cegcc* | os2*)
|
||||
case $host in
|
||||
*cygwin* | *mingw* | *windows* | *cegcc* | *os2*)
|
||||
# No point in relinking DLLs because paths are not encoded
|
||||
func_append notinst_deplibs " $lib"
|
||||
need_relink=no
|
||||
@@ -8252,8 +8249,8 @@ func_mode_link ()
|
||||
soname=$dlname
|
||||
elif test -n "$soname_spec"; then
|
||||
# bleh windows
|
||||
case $host_os in
|
||||
cygwin* | mingw* | windows* | cegcc*) # | os2* # SDL customization: removed OS/2 versioning support.
|
||||
case $host in
|
||||
*cygwin* | mingw* | *windows* | *cegcc*) # | *os2* # SDL customization: removed OS/2 versioning support.
|
||||
func_arith $current - $age
|
||||
major=$func_arith_result
|
||||
versuffix=-$major
|
||||
@@ -8395,7 +8392,7 @@ func_mode_link ()
|
||||
test no = "$hardcode_direct_absolute"; then
|
||||
add=$libdir/$linklib
|
||||
elif test yes = "$hardcode_minus_L"; then
|
||||
add_dir=-L$lt_sysroot$libdir
|
||||
add_dir=-L$libdir
|
||||
add=-l$name
|
||||
elif test yes = "$hardcode_shlibpath_var"; then
|
||||
case :$finalize_shlibpath: in
|
||||
@@ -8412,7 +8409,7 @@ func_mode_link ()
|
||||
fi
|
||||
else
|
||||
# We cannot seem to hardcode it, guess we'll fake it.
|
||||
add_dir=-L$lt_sysroot$libdir
|
||||
add_dir=-L$libdir
|
||||
# Try looking first in the location we're being installed to.
|
||||
if test -n "$inst_prefix_dir"; then
|
||||
case $libdir in
|
||||
@@ -8683,7 +8680,7 @@ func_mode_link ()
|
||||
test CXX = "$tagname" && {
|
||||
case $host_os in
|
||||
linux*)
|
||||
case `$CC -V 2>&1 | $SED 5q` in
|
||||
case `$CC -V 2>&1 | sed 5q` in
|
||||
*Sun\ C*) # Sun C++ 5.9
|
||||
func_suncc_cstd_abi
|
||||
|
||||
@@ -8856,13 +8853,13 @@ func_mode_link ()
|
||||
#
|
||||
case $version_type in
|
||||
# correct linux to gnu/linux during the next big refactor
|
||||
darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none)
|
||||
darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none)
|
||||
func_arith $number_major + $number_minor
|
||||
current=$func_arith_result
|
||||
age=$number_minor
|
||||
revision=$number_revision
|
||||
;;
|
||||
freebsd-aout|sco|sunos)
|
||||
freebsd-aout|qnx|sco|sunos)
|
||||
current=$number_major
|
||||
revision=$number_minor
|
||||
age=0
|
||||
@@ -9009,9 +9006,8 @@ func_mode_link ()
|
||||
;;
|
||||
|
||||
qnx)
|
||||
func_arith $current - $age
|
||||
major=.$func_arith_result
|
||||
versuffix=$major.$age.$revision
|
||||
major=.$current
|
||||
versuffix=.$current
|
||||
;;
|
||||
|
||||
sco)
|
||||
|
0
build-scripts/setup-gdk-desktop.py
Normal file → Executable file
0
build-scripts/setup-gdk-desktop.py
Normal file → Executable file
@@ -5,8 +5,8 @@
|
||||
SDL_ROOT=$(dirname $0)/..
|
||||
cd $SDL_ROOT
|
||||
|
||||
if [ -e ./REVISION.txt ]; then
|
||||
cat ./REVISION.txt
|
||||
if [ -e ./VERSION.txt ]; then
|
||||
cat ./VERSION.txt
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@@ -29,7 +29,7 @@ done
|
||||
rev=`sh showrev.sh 2>/dev/null`
|
||||
if [ "$rev" != "" ]; then
|
||||
if [ -n "$dist" ]; then
|
||||
echo "$rev" > "$outdir/REVISION.txt"
|
||||
echo "$rev" > "$outdir/VERSION.txt"
|
||||
fi
|
||||
echo "/* Generated by updaterev.sh, do not edit */" >"$header.new"
|
||||
if [ -n "$vendor" ]; then
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -27,13 +27,11 @@ function(check_cpu_architecture ARCH VARIABLE)
|
||||
if(ARCH STREQUAL "x86")
|
||||
_internal_check_cpu_architecture("defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" x86 ${VARIABLE})
|
||||
elseif(ARCH STREQUAL "x64")
|
||||
_internal_check_cpu_architecture("(defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)) && !defined(_M_ARM64EC)" x64 ${VARIABLE})
|
||||
_internal_check_cpu_architecture("defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" x64 ${VARIABLE})
|
||||
elseif(ARCH STREQUAL "arm32")
|
||||
_internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE})
|
||||
elseif(ARCH STREQUAL "arm64")
|
||||
_internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE})
|
||||
elseif(ARCH STREQUAL "arm64ec")
|
||||
_internal_check_cpu_architecture("defined(_M_ARM64EC)" arm64ec ${VARIABLE})
|
||||
elseif(ARCH STREQUAL "loongarch64")
|
||||
_internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE})
|
||||
else()
|
||||
|
@@ -119,7 +119,7 @@ macro(CheckALSA)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT HAVE_ALSA_SHARED)
|
||||
list(APPEND CMAKE_LIBS ALSA::ALSA)
|
||||
list(APPEND CMAKE_DEPENDS ALSA::ALSA)
|
||||
list(APPEND PKGCONFIG_DEPENDS alsa)
|
||||
endif()
|
||||
set(HAVE_SDL_AUDIO TRUE)
|
||||
@@ -947,7 +947,7 @@ macro(CheckPTHREAD)
|
||||
elseif(BSDI)
|
||||
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
||||
set(PTHREAD_LDFLAGS "")
|
||||
elseif(MACOS)
|
||||
elseif(DARWIN)
|
||||
set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
|
||||
# causes Carbon.p complaints?
|
||||
# set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
||||
@@ -963,11 +963,7 @@ macro(CheckPTHREAD)
|
||||
set(PTHREAD_LDFLAGS "-lpthread")
|
||||
elseif(SOLARIS)
|
||||
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
|
||||
set(PTHREAD_LDFLAGS "-mt -lpthread")
|
||||
else()
|
||||
set(PTHREAD_LDFLAGS "-pthread")
|
||||
endif()
|
||||
set(PTHREAD_LDFLAGS "-pthread -lposix4")
|
||||
elseif(SYSV5)
|
||||
set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
|
||||
set(PTHREAD_LDFLAGS "")
|
||||
@@ -1253,7 +1249,6 @@ macro(CheckHIDAPI)
|
||||
|
||||
if(HAVE_HIDAPI)
|
||||
if(ANDROID)
|
||||
enable_language(CXX)
|
||||
list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
|
||||
endif()
|
||||
if(IOS OR TVOS)
|
||||
@@ -1281,18 +1276,13 @@ endmacro()
|
||||
# - n/a
|
||||
macro(CheckRPI)
|
||||
if(SDL_RPI)
|
||||
pkg_check_modules(VIDEO_RPI bcm_host)
|
||||
pkg_check_modules(VIDEO_RPI bcm_host brcmegl)
|
||||
if (NOT VIDEO_RPI_FOUND)
|
||||
set(VIDEO_RPI_INCLUDE_DIRS "/opt/vc/include" "/opt/vc/include/interface/vcos/pthreads" "/opt/vc/include/interface/vmcs_host/linux/" )
|
||||
set(VIDEO_RPI_LIBRARY_DIRS "/opt/vc/lib" )
|
||||
set(VIDEO_RPI_LIBRARIES bcm_host )
|
||||
set(VIDEO_RPI_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
|
||||
endif()
|
||||
|
||||
pkg_check_modules(VIDEO_RPI_EGL brcmegl)
|
||||
if (NOT VIDEO_RPI_EGL_FOUND)
|
||||
set(VIDEO_RPI_EGL_LDFLAGS "-Wl,-rpath,/opt/vc/lib")
|
||||
endif()
|
||||
|
||||
listtostr(VIDEO_RPI_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
|
||||
listtostr(VIDEO_RPI_LIBRARY_DIRS VIDEO_RPI_LIBRARY_FLAGS "-L")
|
||||
|
||||
@@ -1301,7 +1291,9 @@ macro(CheckRPI)
|
||||
set(CMAKE_REQUIRED_LIBRARIES "${VIDEO_RPI_LIBRARIES}")
|
||||
check_c_source_compiles("
|
||||
#include <bcm_host.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
int main(int argc, char **argv) {
|
||||
EGL_DISPMANX_WINDOW_T window;
|
||||
bcm_host_init();
|
||||
}" HAVE_RPI)
|
||||
set(CMAKE_REQUIRED_FLAGS "${ORIG_CMAKE_REQUIRED_FLAGS}")
|
||||
@@ -1315,7 +1307,7 @@ macro(CheckRPI)
|
||||
list(APPEND EXTRA_LIBS ${VIDEO_RPI_LIBRARIES})
|
||||
# !!! FIXME: shouldn't be using CMAKE_C_FLAGS, right?
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")
|
||||
list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS} ${VIDEO_RPI_EGL_LDFLAGS})
|
||||
list(APPEND EXTRA_LDFLAGS ${VIDEO_RPI_LDFLAGS})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
@@ -32,8 +32,10 @@ macro(SDL_DetectCMakePlatform)
|
||||
set(SDL_CMAKE_PLATFORM QNX)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*")
|
||||
set(SDL_CMAKE_PLATFORM MACOS)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
|
||||
set(SDL_CMAKE_PLATFORM DARWIN)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
|
||||
set(SDL_CMAKE_PLATFORM MACOSX)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
|
||||
set(SDL_CMAKE_PLATFORM TVOS)
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
|
||||
@@ -41,10 +43,6 @@ macro(SDL_DetectCMakePlatform)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.14)
|
||||
set(SDL_CMAKE_PLATFORM IOS)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*watchOS.*")
|
||||
set(SDL_CMAKE_PLATFORM WATCHOS)
|
||||
elseif (CMAKE_SYSTEM_NAME MATCHES "visionOS")
|
||||
set(SDL_CMAKE_PLATFORM VISIONOS)
|
||||
endif()
|
||||
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
|
||||
message_error("BeOS support has been removed as of SDL 2.0.2.")
|
||||
|
@@ -3,8 +3,6 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(sdl_test LANGUAGES C)
|
||||
|
||||
include(CheckLanguage)
|
||||
include(FeatureSummary)
|
||||
include(GenerateExportHeader)
|
||||
|
||||
if(ANDROID)
|
||||
@@ -21,6 +19,8 @@ cmake_policy(SET CMP0074 NEW)
|
||||
# Override CMAKE_FIND_ROOT_PATH_MODE to allow search for SDL2 outside of sysroot
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
|
||||
|
||||
include(FeatureSummary)
|
||||
|
||||
option(TEST_SHARED "Test linking to shared SDL2 library" ON)
|
||||
add_feature_info("TEST_SHARED" TEST_SHARED "Test linking with shared library")
|
||||
|
||||
@@ -33,19 +33,6 @@ add_feature_info("TEST_TEST" TEST_STATIC "Test linking to SDL test library")
|
||||
option(TEST_FULL "Run complete SDL test suite" OFF)
|
||||
add_feature_info("TEST_FULL" TEST_FULL "Build full SDL testsuite")
|
||||
|
||||
# FIXME: how to target ios/tvos with Swift?
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/20104
|
||||
if(APPLE AND CMAKE_SYSTEM_NAME MATCHES ".*(Darwin|MacOS).*")
|
||||
# multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES count_osx_archs)
|
||||
if(count_osx_archs LESS_EQUAL 1)
|
||||
check_language(Swift)
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
enable_language(Swift)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_SHARED)
|
||||
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2)
|
||||
if(EMSCRIPTEN OR (WIN32 AND NOT WINDOWS_STORE))
|
||||
@@ -99,12 +86,6 @@ if(TEST_SHARED)
|
||||
add_executable(sdltest-shared sdltest.c)
|
||||
target_link_libraries(sdltest-shared PRIVATE SDL2::SDL2main SDL2::SDL2test SDL2::SDL2)
|
||||
endif()
|
||||
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
add_executable(swift-shared main.swift)
|
||||
target_include_directories(swift-shared PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
|
||||
target_link_libraries(swift-shared PRIVATE SDL2::SDL2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TEST_STATIC)
|
||||
@@ -142,11 +123,6 @@ if(TEST_STATIC)
|
||||
target_include_directories(cli-static-vars PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(TEST_TEST)
|
||||
add_executable(sdltest-static sdltest.c)
|
||||
target_link_libraries(sdltest-static PRIVATE SDL2::SDL2main SDL2::SDL2test SDL2::SDL2-static)
|
||||
endif()
|
||||
|
||||
if(CMAKE_Swift_COMPILER)
|
||||
add_executable(swift-static main.swift)
|
||||
target_include_directories(swift-static PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/swift")
|
||||
|
@@ -1,12 +0,0 @@
|
||||
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
|
||||
|
||||
import SDL2
|
||||
|
||||
guard SDL_Init(Uint32(SDL_INIT_VIDEO)) == 0 else {
|
||||
fatalError("SDL_Init error: \(String(cString: SDL_GetError()))")
|
||||
}
|
||||
|
||||
var sdlVersion = SDL_version()
|
||||
SDL_GetVersion(&sdlVersion)
|
||||
|
||||
print("SDL version: \(sdlVersion.major).\(sdlVersion.minor).\(sdlVersion.patch)")
|
@@ -1,4 +0,0 @@
|
||||
module SDL2 [extern_c] {
|
||||
header "shim.h"
|
||||
export *
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
/* Contributed by Piotr Usewicz (https://github.com/pusewicz) */
|
||||
|
||||
#include "SDL.h"
|
233
configure
vendored
233
configure
vendored
@@ -703,8 +703,6 @@ X_LIBS
|
||||
X_PRE_LIBS
|
||||
X_CFLAGS
|
||||
XMKMF
|
||||
RPI_EGL_LIBS
|
||||
RPI_EGL_CFLAGS
|
||||
RPI_LIBS
|
||||
RPI_CFLAGS
|
||||
DECOR_LIBS
|
||||
@@ -993,8 +991,6 @@ DECOR_CFLAGS
|
||||
DECOR_LIBS
|
||||
RPI_CFLAGS
|
||||
RPI_LIBS
|
||||
RPI_EGL_CFLAGS
|
||||
RPI_EGL_LIBS
|
||||
XMKMF
|
||||
DIRECTFB_CFLAGS
|
||||
DIRECTFB_LIBS
|
||||
@@ -1722,7 +1718,7 @@ Optional Features:
|
||||
[default=yes]
|
||||
--enable-libdecor-shared
|
||||
dynamically load libdecor [default=yes]
|
||||
--enable-video-rpi use Raspberry Pi 0-3 video driver [default=yes]
|
||||
--enable-video-rpi use Raspberry Pi 2/3 video driver [default=yes]
|
||||
--enable-video-x11 use X11 video driver [default=maybe]
|
||||
--enable-x11-shared dynamically load X11 support [default=maybe]
|
||||
--enable-video-x11-xcursor
|
||||
@@ -1852,10 +1848,6 @@ Some influential environment variables:
|
||||
DECOR_LIBS linker flags for DECOR, overriding pkg-config
|
||||
RPI_CFLAGS C compiler flags for RPI, overriding pkg-config
|
||||
RPI_LIBS linker flags for RPI, overriding pkg-config
|
||||
RPI_EGL_CFLAGS
|
||||
C compiler flags for RPI_EGL, overriding pkg-config
|
||||
RPI_EGL_LIBS
|
||||
linker flags for RPI_EGL, overriding pkg-config
|
||||
XMKMF Path to xmkmf, Makefile generator for X Window System
|
||||
DIRECTFB_CFLAGS
|
||||
C compiler flags for DIRECTFB, overriding pkg-config
|
||||
@@ -3515,8 +3507,8 @@ orig_CFLAGS="$CFLAGS"
|
||||
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=33
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_MINOR_VERSION=30
|
||||
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`
|
||||
@@ -5815,7 +5807,7 @@ cygwin*)
|
||||
# func_win32_libid is a shell function defined in ltmain.sh
|
||||
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
|
||||
lt_cv_file_magic_cmd='func_win32_libid'
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization.
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization
|
||||
;;
|
||||
|
||||
mingw* | windows* | pw32*)
|
||||
@@ -5827,10 +5819,10 @@ mingw* | windows* | pw32*)
|
||||
lt_cv_file_magic_cmd='func_win32_libid'
|
||||
else
|
||||
# Keep this pattern in sync with the one in func_win32_libid.
|
||||
lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)'
|
||||
lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
|
||||
lt_cv_file_magic_cmd='$OBJDUMP -f'
|
||||
fi
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization.
|
||||
lt_cv_deplibs_check_method=pass_all # SDL customization
|
||||
;;
|
||||
|
||||
cegcc*)
|
||||
@@ -6836,7 +6828,7 @@ void nm_test_func(void){}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
int main(void){nm_test_var='a';nm_test_func();return(0);}
|
||||
int main(){nm_test_var='a';nm_test_func();return(0);}
|
||||
_LT_EOF
|
||||
|
||||
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
|
||||
@@ -8098,43 +8090,6 @@ fi
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
|
||||
printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; }
|
||||
|
||||
# Feature test to disable chained fixups since it is not
|
||||
# compatible with '-undefined dynamic_lookup'
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -no_fixup_chains linker flag" >&5
|
||||
printf %s "checking for -no_fixup_chains linker flag... " >&6; }
|
||||
if test ${lt_cv_support_no_fixup_chains+y}
|
||||
then :
|
||||
printf %s "(cached) " >&6
|
||||
else $as_nop
|
||||
save_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,-no_fixup_chains"
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"
|
||||
then :
|
||||
lt_cv_support_no_fixup_chains=yes
|
||||
else $as_nop
|
||||
lt_cv_support_no_fixup_chains=no
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LDFLAGS=$save_LDFLAGS
|
||||
|
||||
|
||||
fi
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_support_no_fixup_chains" >&5
|
||||
printf "%s\n" "$lt_cv_support_no_fixup_chains" >&6; }
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
|
||||
printf %s "checking for -exported_symbols_list linker flag... " >&6; }
|
||||
if test ${lt_cv_ld_exported_symbols_list+y}
|
||||
@@ -8187,7 +8142,7 @@ _LT_EOF
|
||||
echo "$RANLIB libconftest.a" >&5
|
||||
$RANLIB libconftest.a 2>&5
|
||||
cat > conftest.c << _LT_EOF
|
||||
int main(void) { return 0;}
|
||||
int main() { return 0;}
|
||||
_LT_EOF
|
||||
echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
|
||||
$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
|
||||
@@ -8215,12 +8170,7 @@ printf "%s\n" "$lt_cv_ld_force_load" >&6; }
|
||||
10.[012],*|,*powerpc*-darwin[5-8]*)
|
||||
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
|
||||
*)
|
||||
if test yes = "$lt_cv_support_no_fixup_chains"; then
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup $wl-no_fixup_chains'
|
||||
else
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup'
|
||||
fi
|
||||
;;
|
||||
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@@ -9120,7 +9070,7 @@ objext=$objext
|
||||
lt_simple_compile_test_code="int some_variable = 0;"
|
||||
|
||||
# Code to be used in simple link tests
|
||||
lt_simple_link_test_code='int main(void){return(0);}'
|
||||
lt_simple_link_test_code='int main(){return(0);}'
|
||||
|
||||
|
||||
|
||||
@@ -11600,14 +11550,14 @@ cygwin* | mingw* | windows* | pw32* | cegcc*)
|
||||
cygwin*)
|
||||
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
|
||||
#soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
|
||||
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
|
||||
;;
|
||||
mingw* | windows* | cegcc*)
|
||||
# MinGW DLLs use traditional 'lib' prefix
|
||||
#soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
;;
|
||||
pw32*)
|
||||
# pw32 DLLs use 'pw' prefix rather than 'lib'
|
||||
@@ -12671,11 +12621,11 @@ else
|
||||
/* When -fvisibility=hidden is used, assume the code has been annotated
|
||||
correspondingly for the symbols needed. */
|
||||
#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
|
||||
int fnord (void) __attribute__((visibility("default")));
|
||||
int fnord () __attribute__((visibility("default")));
|
||||
#endif
|
||||
|
||||
int fnord (void) { return 42; }
|
||||
int main (void)
|
||||
int fnord () { return 42; }
|
||||
int main ()
|
||||
{
|
||||
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
|
||||
int status = $lt_dlunknown;
|
||||
@@ -12778,11 +12728,11 @@ else
|
||||
/* When -fvisibility=hidden is used, assume the code has been annotated
|
||||
correspondingly for the symbols needed. */
|
||||
#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
|
||||
int fnord (void) __attribute__((visibility("default")));
|
||||
int fnord () __attribute__((visibility("default")));
|
||||
#endif
|
||||
|
||||
int fnord (void) { return 42; }
|
||||
int main (void)
|
||||
int fnord () { return 42; }
|
||||
int main ()
|
||||
{
|
||||
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
|
||||
int status = $lt_dlunknown;
|
||||
@@ -16984,13 +16934,13 @@ cygwin* | mingw* | windows* | pw32* | cegcc*)
|
||||
cygwin*)
|
||||
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
|
||||
#soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
|
||||
;;
|
||||
mingw* | windows* | cegcc*)
|
||||
# MinGW DLLs use traditional 'lib' prefix
|
||||
#soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization.
|
||||
soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization
|
||||
;;
|
||||
pw32*)
|
||||
# pw32 DLLs use 'pw' prefix rather than 'lib'
|
||||
@@ -19755,12 +19705,6 @@ 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
|
||||
@@ -22428,6 +22372,7 @@ 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
|
||||
@@ -23675,19 +23620,19 @@ fi
|
||||
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
||||
|
||||
pkg_failed=no
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bcm_host" >&5
|
||||
printf %s "checking for bcm_host... " >&6; }
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bcm_host brcmegl" >&5
|
||||
printf %s "checking for bcm_host brcmegl... " >&6; }
|
||||
|
||||
if test -n "$RPI_CFLAGS"; then
|
||||
pkg_cv_RPI_CFLAGS="$RPI_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "bcm_host") 2>&5
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "bcm_host brcmegl") 2>&5
|
||||
ac_status=$?
|
||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_RPI_CFLAGS=`$PKG_CONFIG --cflags "bcm_host" 2>/dev/null`
|
||||
pkg_cv_RPI_CFLAGS=`$PKG_CONFIG --cflags "bcm_host brcmegl" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
@@ -23699,12 +23644,12 @@ if test -n "$RPI_LIBS"; then
|
||||
pkg_cv_RPI_LIBS="$RPI_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "bcm_host") 2>&5
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bcm_host brcmegl\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "bcm_host brcmegl") 2>&5
|
||||
ac_status=$?
|
||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_RPI_LIBS=`$PKG_CONFIG --libs "bcm_host" 2>/dev/null`
|
||||
pkg_cv_RPI_LIBS=`$PKG_CONFIG --libs "bcm_host brcmegl" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
@@ -23725,9 +23670,9 @@ else
|
||||
_pkg_short_errors_supported=no
|
||||
fi
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
RPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bcm_host" 2>&1`
|
||||
RPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bcm_host brcmegl" 2>&1`
|
||||
else
|
||||
RPI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bcm_host" 2>&1`
|
||||
RPI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bcm_host brcmegl" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$RPI_PKG_ERRORS" >&5
|
||||
@@ -23745,92 +23690,13 @@ printf "%s\n" "yes" >&6; }
|
||||
video_rpi=yes
|
||||
fi
|
||||
|
||||
pkg_failed=no
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for brcmegl" >&5
|
||||
printf %s "checking for brcmegl... " >&6; }
|
||||
|
||||
if test -n "$RPI_EGL_CFLAGS"; then
|
||||
pkg_cv_RPI_EGL_CFLAGS="$RPI_EGL_CFLAGS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"brcmegl\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "brcmegl") 2>&5
|
||||
ac_status=$?
|
||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_RPI_EGL_CFLAGS=`$PKG_CONFIG --cflags "brcmegl" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
if test -n "$RPI_EGL_LIBS"; then
|
||||
pkg_cv_RPI_EGL_LIBS="$RPI_EGL_LIBS"
|
||||
elif test -n "$PKG_CONFIG"; then
|
||||
if test -n "$PKG_CONFIG" && \
|
||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"brcmegl\""; } >&5
|
||||
($PKG_CONFIG --exists --print-errors "brcmegl") 2>&5
|
||||
ac_status=$?
|
||||
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }; then
|
||||
pkg_cv_RPI_EGL_LIBS=`$PKG_CONFIG --libs "brcmegl" 2>/dev/null`
|
||||
test "x$?" != "x0" && pkg_failed=yes
|
||||
else
|
||||
pkg_failed=yes
|
||||
fi
|
||||
else
|
||||
pkg_failed=untried
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
|
||||
_pkg_short_errors_supported=yes
|
||||
else
|
||||
_pkg_short_errors_supported=no
|
||||
fi
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
RPI_EGL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "brcmegl" 2>&1`
|
||||
else
|
||||
RPI_EGL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "brcmegl" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$RPI_EGL_PKG_ERRORS" >&5
|
||||
|
||||
video_rpi_egl=no
|
||||
elif test $pkg_failed = untried; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
video_rpi_egl=no
|
||||
else
|
||||
RPI_EGL_CFLAGS=$pkg_cv_RPI_EGL_CFLAGS
|
||||
RPI_EGL_LIBS=$pkg_cv_RPI_EGL_LIBS
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
printf "%s\n" "yes" >&6; }
|
||||
video_rpi_egl=yes
|
||||
fi
|
||||
|
||||
if test x$video_rpi = xno; then
|
||||
if test x$ARCH = xnetbsd; then
|
||||
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
||||
RPI_LIBS="-L/usr/pkg/lib -lbcm_host"
|
||||
RPI_LIBS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
||||
else
|
||||
RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
|
||||
RPI_LIBS="-L/opt/vc/lib -lbcm_host"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$video_rpi_egl = xno; then
|
||||
if test x$ARCH = xnetbsd; then
|
||||
RPI_EGL_LIBS="-Wl,-R/usr/pkg/lib"
|
||||
else
|
||||
RPI_EGL_LIBS="-Wl,-rpath,/opt/vc/lib"
|
||||
RPI_LIBS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -23838,20 +23704,22 @@ fi
|
||||
ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
|
||||
|
||||
# Add the Raspberry Pi compiler flags and libraries
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_EGL_LIBS $RPI_LIBS"
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LIBS"
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Raspberry Pi 0-3" >&5
|
||||
printf %s "checking for Raspberry Pi 0-3... " >&6; }
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Raspberry Pi 2/3" >&5
|
||||
printf %s "checking for Raspberry Pi 2/3... " >&6; }
|
||||
have_video_rpi=no
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <bcm_host.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
|
||||
EGL_DISPMANX_WINDOW_T window;
|
||||
bcm_host_init();
|
||||
|
||||
;
|
||||
@@ -23874,7 +23742,7 @@ printf "%s\n" "$have_video_rpi" >&6; }
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"
|
||||
SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_EGL_LIBS $RPI_LIBS"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LIBS"
|
||||
SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
|
||||
|
||||
printf "%s\n" "#define SDL_VIDEO_DRIVER_RPI 1" >>confdefs.h
|
||||
@@ -26458,9 +26326,6 @@ else $as_nop
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
;;
|
||||
*-*-solaris*)
|
||||
enable_video_vulkan=no
|
||||
;;
|
||||
*-*-darwin*)
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -x objective-c"
|
||||
@@ -28399,8 +28264,7 @@ 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
|
||||
@@ -28747,23 +28611,12 @@ 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
|
||||
fi
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
;;
|
||||
netbsd) # Don't use this on OpenBSD, it's busted.
|
||||
|
||||
|
50
configure.ac
50
configure.ac
@@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS"
|
||||
dnl Set various version strings - taken gratefully from the GTk sources
|
||||
# See docs/release_checklist.md
|
||||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=33
|
||||
SDL_MICRO_VERSION=0
|
||||
SDL_MINOR_VERSION=30
|
||||
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 sigtimedwait 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 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,6 +1247,7 @@ CheckNAS()
|
||||
have_nas=yes
|
||||
NAS_CFLAGS="-I/usr/X11R6/include/"
|
||||
NAS_LIBS="-L/usr/X11R6/lib -laudio -lXt"
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT($have_nas)
|
||||
@@ -1847,27 +1848,18 @@ CheckNativeClient()
|
||||
CheckRPI()
|
||||
{
|
||||
AC_ARG_ENABLE(video-rpi,
|
||||
[AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi 0-3 video driver [default=yes]])],
|
||||
[AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi 2/3 video driver [default=yes]])],
|
||||
, enable_video_rpi=yes)
|
||||
if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then
|
||||
PKG_CHECK_MODULES([RPI], [bcm_host], video_rpi=yes, video_rpi=no)
|
||||
PKG_CHECK_MODULES([RPI_EGL], [brcmegl], video_rpi_egl=yes, video_rpi_egl=no)
|
||||
PKG_CHECK_MODULES([RPI], [bcm_host brcmegl], video_rpi=yes, video_rpi=no)
|
||||
|
||||
if test x$video_rpi = xno; then
|
||||
if test x$ARCH = xnetbsd; then
|
||||
RPI_CFLAGS="-I/usr/pkg/include -I/usr/pkg/include/interface/vcos/pthreads -I/usr/pkg/include/interface/vmcs_host/linux"
|
||||
RPI_LIBS="-L/usr/pkg/lib -lbcm_host"
|
||||
RPI_LIBS="-Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lbcm_host"
|
||||
else
|
||||
RPI_CFLAGS="-I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux"
|
||||
RPI_LIBS="-L/opt/vc/lib -lbcm_host"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x$video_rpi_egl = xno; then
|
||||
if test x$ARCH = xnetbsd; then
|
||||
RPI_EGL_LIBS="-Wl,-R/usr/pkg/lib"
|
||||
else
|
||||
RPI_EGL_LIBS="-Wl,-rpath,/opt/vc/lib"
|
||||
RPI_LIBS="-Wl,-rpath,/opt/vc/lib -L/opt/vc/lib -lbcm_host"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1875,13 +1867,15 @@ CheckRPI()
|
||||
ac_save_cflags="$CFLAGS"; ac_save_libs="$LIBS"
|
||||
|
||||
# Add the Raspberry Pi compiler flags and libraries
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_EGL_LIBS $RPI_LIBS"
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"; LIBS="$LIBS $RPI_LIBS"
|
||||
|
||||
AC_MSG_CHECKING(for Raspberry Pi 0-3)
|
||||
AC_MSG_CHECKING(for Raspberry Pi 2/3)
|
||||
have_video_rpi=no
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <bcm_host.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
]], [[
|
||||
EGL_DISPMANX_WINDOW_T window;
|
||||
bcm_host_init();
|
||||
]])], [have_video_rpi=yes],[])
|
||||
AC_MSG_RESULT($have_video_rpi)
|
||||
@@ -1893,7 +1887,7 @@ CheckRPI()
|
||||
CFLAGS="$CFLAGS $RPI_CFLAGS"
|
||||
SDL_CFLAGS="$SDL_CFLAGS $RPI_CFLAGS"
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $RPI_CFLAGS"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_EGL_LIBS $RPI_LIBS"
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $RPI_LIBS"
|
||||
SOURCES="$SOURCES $srcdir/src/video/raspberry/*.c"
|
||||
AC_DEFINE(SDL_VIDEO_DRIVER_RPI, 1, [ ])
|
||||
SUMMARY_video="${SUMMARY_video} rpi"
|
||||
@@ -2742,10 +2736,6 @@ CheckVulkan()
|
||||
#endif
|
||||
]],[])], [],[enable_video_vulkan=no])
|
||||
;;
|
||||
*-*-solaris*)
|
||||
dnl Strictly speaking, what's missing here is libxcb. Even without Vulkan support at the OS level, it should still compile if we had that.
|
||||
enable_video_vulkan=no
|
||||
;;
|
||||
*-*-darwin*)
|
||||
save_CFLAGS="$CFLAGS"
|
||||
dnl Work around that we don't have Objective-C support in autoconf
|
||||
@@ -3635,7 +3625,7 @@ CheckHIDAPI()
|
||||
|
||||
if test x$hidapi_support = xyes; then
|
||||
if test x$have_libusb_h = xyes; then
|
||||
AC_DEFINE(HAVE_LIBUSB, 1, [ ])
|
||||
AC_DEFINE(HAVE_LIBUSB)
|
||||
EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBUSB_CFLAGS"
|
||||
if test x$require_hidapi_libusb = xyes; then
|
||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBUSB_LIBS"
|
||||
@@ -3868,14 +3858,10 @@ case "$host" in
|
||||
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_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
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_SUNAUDIO, 1, [ ])
|
||||
SOURCES="$SOURCES $srcdir/src/audio/sun/*.c"
|
||||
SUMMARY_audio="${SUMMARY_audio} sun"
|
||||
have_audio=yes
|
||||
;;
|
||||
netbsd) # Don't use this on OpenBSD, it's busted.
|
||||
AC_DEFINE(SDL_AUDIO_DRIVER_NETBSD, 1, [ ])
|
||||
|
@@ -1,483 +1,483 @@
|
||||
Android
|
||||
================================================================================
|
||||
|
||||
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
|
||||
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
|
||||
|
||||
The rest of this README covers the Android gradle style build process.
|
||||
|
||||
If you are using the older ant build process, it is no longer officially
|
||||
supported, but you can use the "android-project-ant" directory as a template.
|
||||
|
||||
|
||||
Requirements
|
||||
================================================================================
|
||||
|
||||
Android SDK (version 34 or later)
|
||||
https://developer.android.com/sdk/index.html
|
||||
|
||||
Android NDK r15c or later
|
||||
https://developer.android.com/tools/sdk/ndk/index.html
|
||||
|
||||
Minimum API level supported by SDL: 19 (Android 4.4)
|
||||
|
||||
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||
the SDL library
|
||||
- This means that your application C code must be placed inside an Android
|
||||
Java project, along with some C support code that communicates with Java
|
||||
- This eventually produces a standard Android .apk package
|
||||
|
||||
The Android Java code implements an "Activity" and can be found in:
|
||||
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||
|
||||
The Java code loads your game code, the SDL shared library, and
|
||||
dispatches to native functions implemented in the SDL library:
|
||||
src/core/android/SDL_android.c
|
||||
|
||||
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||
|
||||
There's two ways of using it:
|
||||
|
||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
||||
|
||||
sources.list should be a text file with a source file name in each line
|
||||
Filenames should be specified relative to the current directory, for example if
|
||||
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||
run:
|
||||
|
||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||
|
||||
One limitation of this script is that all sources provided will be aggregated into
|
||||
a single directory, thus all your source files should have a unique name.
|
||||
|
||||
Once the project is complete the script will tell you where the debug APK is located.
|
||||
If you want to create a signed release APK, you can use the project created by this
|
||||
utility to generate it.
|
||||
|
||||
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
||||
done in the build directory for the app!
|
||||
|
||||
|
||||
|
||||
For more complex projects, follow these instructions:
|
||||
|
||||
1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
|
||||
|
||||
(The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
|
||||
|
||||
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
|
||||
|
||||
(This is needed as the source of SDL has to be compiled by the Android compiler)
|
||||
|
||||
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
|
||||
|
||||
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
|
||||
|
||||
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
|
||||
|
||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||
|
||||
|
||||
If you already have a project that uses CMake, the instructions change somewhat:
|
||||
|
||||
1. Do points 1 and 2 from the instruction above.
|
||||
2. Edit "YOURPROJECT/app/build.gradle" to comment out or remove sections containing ndk-build
|
||||
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
||||
3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
|
||||
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
||||
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
||||
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
||||
add_executable() for the target containing your "main" function.
|
||||
|
||||
If you wish to use Android Studio, you can skip the last step.
|
||||
|
||||
4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
|
||||
connected Android device
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/app
|
||||
build.gradle - build info including the application version and SDK
|
||||
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
|
||||
jni/ - directory holding native code
|
||||
jni/Application.mk - Application JNI settings, including target platform and STL library
|
||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
||||
jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject
|
||||
jni/SDL/ - (symlink to) directory holding the SDL library files
|
||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||
jni/src/ - directory holding your C/C++ source
|
||||
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
||||
jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references
|
||||
src/main/assets/ - directory holding asset files for your application
|
||||
src/main/res/ - directory holding resources for your application
|
||||
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
||||
src/main/res/values/strings.xml - strings used in your application, including the application name
|
||||
src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
|
||||
|
||||
|
||||
Customizing your application name
|
||||
================================================================================
|
||||
|
||||
To customize your application name, edit AndroidManifest.xml and replace
|
||||
"org.libsdl.app" with an identifier for your product package.
|
||||
|
||||
Then create a Java class extending SDLActivity and place it in a directory
|
||||
under src matching your package, e.g.
|
||||
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
|
||||
Here's an example of a minimal class file:
|
||||
|
||||
--- MyGame.java --------------------------
|
||||
package com.gamemaker.game;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
/**
|
||||
* A sample wrapper class that just calls SDLActivity
|
||||
*/
|
||||
|
||||
public class MyGame extends SDLActivity { }
|
||||
|
||||
------------------------------------------
|
||||
|
||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||
class, .e.g. "MyGame"
|
||||
|
||||
|
||||
Customizing your application icon
|
||||
================================================================================
|
||||
|
||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||
the drawable directories under the res directory. There are several directories
|
||||
for different screen sizes.
|
||||
|
||||
|
||||
Loading assets
|
||||
================================================================================
|
||||
|
||||
Any files you put in the "app/src/main/assets" directory of your project
|
||||
directory will get bundled into the application package and you can load
|
||||
them using the standard functions in SDL_rwops.h.
|
||||
|
||||
There are also a few Android specific functions that allow you to get other
|
||||
useful paths for saving and loading data:
|
||||
* SDL_AndroidGetInternalStoragePath()
|
||||
* SDL_AndroidGetExternalStorageState()
|
||||
* SDL_AndroidGetExternalStoragePath()
|
||||
|
||||
See SDL_system.h for more details on these functions.
|
||||
|
||||
The asset packaging system will, by default, compress certain file extensions.
|
||||
SDL includes two asset file access mechanisms, the preferred one is the so
|
||||
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
||||
GC, but given this method does not work on compressed assets, there is also the
|
||||
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
||||
may want to keep this fact in mind when building your APK, specially when large
|
||||
files are involved.
|
||||
For more information on which extensions get compressed by default and how to
|
||||
disable this behaviour, see for example:
|
||||
|
||||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||
|
||||
|
||||
Pause / Resume behaviour
|
||||
================================================================================
|
||||
|
||||
If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default),
|
||||
the event loop will block itself when the app is paused (ie, when the user
|
||||
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||
use, and it allows your app to spring back to life instantaneously after resume
|
||||
(versus polling for a resume message).
|
||||
|
||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||
app can continue to operate as it was.
|
||||
|
||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||
where the GL context can not be restored. In that case you have to listen for
|
||||
a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures
|
||||
manually or quit the app.
|
||||
|
||||
You should not use the SDL renderer API while the app going in background:
|
||||
- SDL_APP_WILLENTERBACKGROUND:
|
||||
after you read this message, GL context gets backed-up and you should not
|
||||
use the SDL renderer API.
|
||||
|
||||
When this event is received, you have to set the render target to NULL, if you're using it.
|
||||
(eg call SDL_SetRenderTarget(renderer, NULL))
|
||||
|
||||
- SDL_APP_DIDENTERFOREGROUND:
|
||||
GL context is restored, and the SDL renderer API is available (unless you
|
||||
receive SDL_RENDER_DEVICE_RESET).
|
||||
|
||||
Mouse / Touch events
|
||||
================================================================================
|
||||
|
||||
In some case, SDL generates synthetic mouse (resp. touch) events for touch
|
||||
(resp. mouse) devices.
|
||||
To enable/disable this behavior, see SDL_hints.h:
|
||||
- SDL_HINT_TOUCH_MOUSE_EVENTS
|
||||
- SDL_HINT_MOUSE_TOUCH_EVENTS
|
||||
|
||||
Misc
|
||||
================================================================================
|
||||
|
||||
For some device, it appears to works better setting explicitly GL attributes
|
||||
before creating a window:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
|
||||
Threads and the Java VM
|
||||
================================================================================
|
||||
|
||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||
a look here: https://developer.android.com/guide/practices/jni.html
|
||||
|
||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||
do so by creating them using SDL functions. This way, the required attach/detach
|
||||
handling is managed by SDL automagically. If you have threads created by other
|
||||
means and they make calls to SDL functions, make sure that you call
|
||||
Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
|
||||
your thread automatically anyway (when you make an SDL call), but it'll never
|
||||
detach it.
|
||||
|
||||
|
||||
If you ever want to use JNI in a native thread (created by "SDL_CreateThread()"),
|
||||
it won't be able to find your java class and method because of the java class loader
|
||||
which is different for native threads, than for java threads (eg your "main()").
|
||||
|
||||
the work-around is to find class/method, in you "main()" thread, and to use them
|
||||
in your native thread.
|
||||
|
||||
see:
|
||||
https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
||||
|
||||
Using STL
|
||||
================================================================================
|
||||
|
||||
You can use STL in your project by creating an Application.mk file in the jni
|
||||
folder and adding the following line:
|
||||
|
||||
APP_STL := c++_shared
|
||||
|
||||
For more information go here:
|
||||
https://developer.android.com/ndk/guides/cpp-support
|
||||
|
||||
|
||||
Using the emulator
|
||||
================================================================================
|
||||
|
||||
There are some good tips and tricks for getting the most out of the
|
||||
emulator here: https://developer.android.com/tools/devices/emulator.html
|
||||
|
||||
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
||||
|
||||
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
||||
Using a real device works better.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
|
||||
adb devices
|
||||
|
||||
You can see the output of log messages on the default device with:
|
||||
|
||||
adb logcat
|
||||
|
||||
You can push files to the device with:
|
||||
|
||||
adb push local_file remote_path_and_file
|
||||
|
||||
You can push files to the SD Card at /sdcard, for example:
|
||||
|
||||
adb push moose.dat /sdcard/moose.dat
|
||||
|
||||
You can see the files on the SD card with a shell command:
|
||||
|
||||
adb shell ls /sdcard/
|
||||
|
||||
You can start a command shell on the default device with:
|
||||
|
||||
adb shell
|
||||
|
||||
You can remove the library files of your project (and not the SDL lib files) with:
|
||||
|
||||
ndk-build clean
|
||||
|
||||
You can do a build with the following command:
|
||||
|
||||
ndk-build
|
||||
|
||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||
|
||||
ndk-build V=1
|
||||
|
||||
If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
|
||||
https://developer.android.com/ndk/guides/ndk-stack
|
||||
|
||||
If you want to go through the process manually, you can use addr2line to convert the
|
||||
addresses in the stack trace to lines in your code.
|
||||
|
||||
For example, if your crash looks like this:
|
||||
|
||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||
|
||||
You can see that there's a crash in the C library being called from the main code.
|
||||
I run addr2line with the debug version of my code:
|
||||
|
||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||
|
||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||
000014bc
|
||||
|
||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||
|
||||
You can add logging to your code to help show what's happening:
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||
|
||||
If you need to build without optimization turned on, you can create a file called
|
||||
"Application.mk" in the jni directory, with the following line in it:
|
||||
|
||||
APP_OPTIM := debug
|
||||
|
||||
|
||||
Memory debugging
|
||||
================================================================================
|
||||
|
||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||
Valgrind has support for Android out of the box, just grab code using:
|
||||
|
||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||
|
||||
... and follow the instructions in the file README.android to build it.
|
||||
|
||||
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
||||
and add ranlib to the environment variables:
|
||||
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
||||
|
||||
Once valgrind is built, you can create a wrapper script to launch your
|
||||
application with it, changing org.libsdl.app to your package identifier:
|
||||
|
||||
--- start_valgrind_app -------------------
|
||||
#!/system/bin/sh
|
||||
export TMPDIR=/data/data/org.libsdl.app
|
||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||
------------------------------------------
|
||||
|
||||
Then push it to the device:
|
||||
|
||||
adb push start_valgrind_app /data/local
|
||||
|
||||
and make it executable:
|
||||
|
||||
adb shell chmod 755 /data/local/start_valgrind_app
|
||||
|
||||
and tell Android to use the script to launch your application:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||
|
||||
If the setprop command says "could not set property", it's likely that
|
||||
your package name is too long and you should make it shorter by changing
|
||||
AndroidManifest.xml and the path to your class file in android-project/src
|
||||
|
||||
You can then launch your application normally and waaaaaaaiiittt for it.
|
||||
You can monitor the startup process with the logcat command above, and
|
||||
when it's done (or even while it's running) you can grab the valgrind
|
||||
output file:
|
||||
|
||||
adb pull /sdcard/valgrind.log
|
||||
|
||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app ""
|
||||
|
||||
|
||||
Graphics debugging
|
||||
================================================================================
|
||||
|
||||
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
||||
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
|
||||
and GLES libraries, you must follow their instructions for installing the
|
||||
interposer library on a rooted device. The non-rooted instructions are not
|
||||
compatible with applications that use SDL2 for video.
|
||||
|
||||
The Tegra Graphics Debugger is available from NVidia here:
|
||||
https://developer.nvidia.com/tegra-graphics-debugger
|
||||
|
||||
|
||||
Why is API level 19 the minimum required?
|
||||
================================================================================
|
||||
|
||||
The latest NDK toolchain doesn't support targeting earlier than API level 19.
|
||||
As of this writing, according to https://www.composables.com/tools/distribution-chart
|
||||
about 99.7% of the Android devices accessing Google Play support API level 19 or
|
||||
higher (August 2023).
|
||||
|
||||
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
================================================================================
|
||||
|
||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||
where you only update a portion of the screen on each frame, you may notice a
|
||||
variety of visual glitches on Android, that are not present on other platforms.
|
||||
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
||||
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
||||
documentation for the function "The contents of ancillary buffers are always
|
||||
undefined after calling eglSwapBuffers".
|
||||
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
||||
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
||||
17+, so the only workaround available on this platform is to redraw the entire
|
||||
screen each frame.
|
||||
|
||||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||
|
||||
|
||||
Ending your application
|
||||
================================================================================
|
||||
|
||||
Two legitimate ways:
|
||||
|
||||
- return from your main() function. Java side will automatically terminate the
|
||||
Activity by calling Activity.finish().
|
||||
|
||||
- Android OS can decide to terminate your application by calling onDestroy()
|
||||
(see Activity life cycle). Your application will receive a SDL_QUIT event you
|
||||
can handle to save things and quit.
|
||||
|
||||
Don't call exit() as it stops the activity badly.
|
||||
|
||||
NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
|
||||
SDLK_AC_BACK, for any purpose.
|
||||
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||
is the current maximum number of buttons Android can report.
|
||||
|
||||
Android
|
||||
================================================================================
|
||||
|
||||
Matt Styles wrote a tutorial on building SDL for Android with Visual Studio:
|
||||
http://trederia.blogspot.de/2017/03/building-sdl2-for-android-with-visual.html
|
||||
|
||||
The rest of this README covers the Android gradle style build process.
|
||||
|
||||
If you are using the older ant build process, it is no longer officially
|
||||
supported, but you can use the "android-project-ant" directory as a template.
|
||||
|
||||
|
||||
Requirements
|
||||
================================================================================
|
||||
|
||||
Android SDK (version 34 or later)
|
||||
https://developer.android.com/sdk/index.html
|
||||
|
||||
Android NDK r15c or later
|
||||
https://developer.android.com/tools/sdk/ndk/index.html
|
||||
|
||||
Minimum API level supported by SDL: 19 (Android 4.4)
|
||||
|
||||
|
||||
How the port works
|
||||
================================================================================
|
||||
|
||||
- Android applications are Java-based, optionally with parts written in C
|
||||
- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to
|
||||
the SDL library
|
||||
- This means that your application C code must be placed inside an Android
|
||||
Java project, along with some C support code that communicates with Java
|
||||
- This eventually produces a standard Android .apk package
|
||||
|
||||
The Android Java code implements an "Activity" and can be found in:
|
||||
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
|
||||
|
||||
The Java code loads your game code, the SDL shared library, and
|
||||
dispatches to native functions implemented in the SDL library:
|
||||
src/core/android/SDL_android.c
|
||||
|
||||
|
||||
Building an app
|
||||
================================================================================
|
||||
|
||||
For simple projects you can use the script located at build-scripts/androidbuild.sh
|
||||
|
||||
There's two ways of using it:
|
||||
|
||||
androidbuild.sh com.yourcompany.yourapp < sources.list
|
||||
androidbuild.sh com.yourcompany.yourapp source1.c source2.c ...sourceN.c
|
||||
|
||||
sources.list should be a text file with a source file name in each line
|
||||
Filenames should be specified relative to the current directory, for example if
|
||||
you are in the build-scripts directory and want to create the testgles.c test, you'll
|
||||
run:
|
||||
|
||||
./androidbuild.sh org.libsdl.testgles ../test/testgles.c
|
||||
|
||||
One limitation of this script is that all sources provided will be aggregated into
|
||||
a single directory, thus all your source files should have a unique name.
|
||||
|
||||
Once the project is complete the script will tell you where the debug APK is located.
|
||||
If you want to create a signed release APK, you can use the project created by this
|
||||
utility to generate it.
|
||||
|
||||
Finally, a word of caution: re running androidbuild.sh wipes any changes you may have
|
||||
done in the build directory for the app!
|
||||
|
||||
|
||||
|
||||
For more complex projects, follow these instructions:
|
||||
|
||||
1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
|
||||
|
||||
(The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
|
||||
|
||||
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
|
||||
|
||||
(This is needed as the source of SDL has to be compiled by the Android compiler)
|
||||
|
||||
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
|
||||
|
||||
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
|
||||
|
||||
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
|
||||
|
||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||
|
||||
|
||||
If you already have a project that uses CMake, the instructions change somewhat:
|
||||
|
||||
1. Do points 1 and 2 from the instruction above.
|
||||
2. Edit "YOURPROJECT/app/build.gradle" to comment out or remove sections containing ndk-build
|
||||
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
||||
3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
|
||||
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
||||
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
||||
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
||||
add_executable() for the target containing your "main" function.
|
||||
|
||||
If you wish to use Android Studio, you can skip the last step.
|
||||
|
||||
4. Run './gradlew installDebug' or './gradlew installRelease' in the project directory. It will build and install your .apk on any
|
||||
connected Android device
|
||||
|
||||
Here's an explanation of the files in the Android project, so you can customize them:
|
||||
|
||||
android-project/app
|
||||
build.gradle - build info including the application version and SDK
|
||||
src/main/AndroidManifest.xml - package manifest. Among others, it contains the class name of the main Activity and the package name of the application.
|
||||
jni/ - directory holding native code
|
||||
jni/Application.mk - Application JNI settings, including target platform and STL library
|
||||
jni/Android.mk - Android makefile that can call recursively the Android.mk files in all subdirectories
|
||||
jni/CMakeLists.txt - Top-level CMake project that adds SDL as a subproject
|
||||
jni/SDL/ - (symlink to) directory holding the SDL library files
|
||||
jni/SDL/Android.mk - Android makefile for creating the SDL shared library
|
||||
jni/src/ - directory holding your C/C++ source
|
||||
jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references
|
||||
jni/src/CMakeLists.txt - CMake file that you may customize to include your source code and any library references
|
||||
src/main/assets/ - directory holding asset files for your application
|
||||
src/main/res/ - directory holding resources for your application
|
||||
src/main/res/mipmap-* - directories holding icons for different phone hardware
|
||||
src/main/res/values/strings.xml - strings used in your application, including the application name
|
||||
src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application.
|
||||
|
||||
|
||||
Customizing your application name
|
||||
================================================================================
|
||||
|
||||
To customize your application name, edit AndroidManifest.xml and replace
|
||||
"org.libsdl.app" with an identifier for your product package.
|
||||
|
||||
Then create a Java class extending SDLActivity and place it in a directory
|
||||
under src matching your package, e.g.
|
||||
|
||||
src/com/gamemaker/game/MyGame.java
|
||||
|
||||
Here's an example of a minimal class file:
|
||||
|
||||
--- MyGame.java --------------------------
|
||||
package com.gamemaker.game;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
/**
|
||||
* A sample wrapper class that just calls SDLActivity
|
||||
*/
|
||||
|
||||
public class MyGame extends SDLActivity { }
|
||||
|
||||
------------------------------------------
|
||||
|
||||
Then replace "SDLActivity" in AndroidManifest.xml with the name of your
|
||||
class, .e.g. "MyGame"
|
||||
|
||||
|
||||
Customizing your application icon
|
||||
================================================================================
|
||||
|
||||
Conceptually changing your icon is just replacing the "ic_launcher.png" files in
|
||||
the drawable directories under the res directory. There are several directories
|
||||
for different screen sizes.
|
||||
|
||||
|
||||
Loading assets
|
||||
================================================================================
|
||||
|
||||
Any files you put in the "app/src/main/assets" directory of your project
|
||||
directory will get bundled into the application package and you can load
|
||||
them using the standard functions in SDL_rwops.h.
|
||||
|
||||
There are also a few Android specific functions that allow you to get other
|
||||
useful paths for saving and loading data:
|
||||
* SDL_AndroidGetInternalStoragePath()
|
||||
* SDL_AndroidGetExternalStorageState()
|
||||
* SDL_AndroidGetExternalStoragePath()
|
||||
|
||||
See SDL_system.h for more details on these functions.
|
||||
|
||||
The asset packaging system will, by default, compress certain file extensions.
|
||||
SDL includes two asset file access mechanisms, the preferred one is the so
|
||||
called "File Descriptor" method, which is faster and doesn't involve the Dalvik
|
||||
GC, but given this method does not work on compressed assets, there is also the
|
||||
"Input Stream" method, which is automatically used as a fall back by SDL. You
|
||||
may want to keep this fact in mind when building your APK, specially when large
|
||||
files are involved.
|
||||
For more information on which extensions get compressed by default and how to
|
||||
disable this behaviour, see for example:
|
||||
|
||||
http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/
|
||||
|
||||
|
||||
Pause / Resume behaviour
|
||||
================================================================================
|
||||
|
||||
If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default),
|
||||
the event loop will block itself when the app is paused (ie, when the user
|
||||
returns to the main Android dashboard). Blocking is better in terms of battery
|
||||
use, and it allows your app to spring back to life instantaneously after resume
|
||||
(versus polling for a resume message).
|
||||
|
||||
Upon resume, SDL will attempt to restore the GL context automatically.
|
||||
In modern devices (Android 3.0 and up) this will most likely succeed and your
|
||||
app can continue to operate as it was.
|
||||
|
||||
However, there's a chance (on older hardware, or on systems under heavy load),
|
||||
where the GL context can not be restored. In that case you have to listen for
|
||||
a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures
|
||||
manually or quit the app.
|
||||
|
||||
You should not use the SDL renderer API while the app going in background:
|
||||
- SDL_APP_WILLENTERBACKGROUND:
|
||||
after you read this message, GL context gets backed-up and you should not
|
||||
use the SDL renderer API.
|
||||
|
||||
When this event is received, you have to set the render target to NULL, if you're using it.
|
||||
(eg call SDL_SetRenderTarget(renderer, NULL))
|
||||
|
||||
- SDL_APP_DIDENTERFOREGROUND:
|
||||
GL context is restored, and the SDL renderer API is available (unless you
|
||||
receive SDL_RENDER_DEVICE_RESET).
|
||||
|
||||
Mouse / Touch events
|
||||
================================================================================
|
||||
|
||||
In some case, SDL generates synthetic mouse (resp. touch) events for touch
|
||||
(resp. mouse) devices.
|
||||
To enable/disable this behavior, see SDL_hints.h:
|
||||
- SDL_HINT_TOUCH_MOUSE_EVENTS
|
||||
- SDL_HINT_MOUSE_TOUCH_EVENTS
|
||||
|
||||
Misc
|
||||
================================================================================
|
||||
|
||||
For some device, it appears to works better setting explicitly GL attributes
|
||||
before creating a window:
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
|
||||
Threads and the Java VM
|
||||
================================================================================
|
||||
|
||||
For a quick tour on how Linux native threads interoperate with the Java VM, take
|
||||
a look here: https://developer.android.com/guide/practices/jni.html
|
||||
|
||||
If you want to use threads in your SDL app, it's strongly recommended that you
|
||||
do so by creating them using SDL functions. This way, the required attach/detach
|
||||
handling is managed by SDL automagically. If you have threads created by other
|
||||
means and they make calls to SDL functions, make sure that you call
|
||||
Android_JNI_SetupThread() before doing anything else otherwise SDL will attach
|
||||
your thread automatically anyway (when you make an SDL call), but it'll never
|
||||
detach it.
|
||||
|
||||
|
||||
If you ever want to use JNI in a native thread (created by "SDL_CreateThread()"),
|
||||
it won't be able to find your java class and method because of the java class loader
|
||||
which is different for native threads, than for java threads (eg your "main()").
|
||||
|
||||
the work-around is to find class/method, in you "main()" thread, and to use them
|
||||
in your native thread.
|
||||
|
||||
see:
|
||||
https://developer.android.com/training/articles/perf-jni#faq:-why-didnt-findclass-find-my-class
|
||||
|
||||
Using STL
|
||||
================================================================================
|
||||
|
||||
You can use STL in your project by creating an Application.mk file in the jni
|
||||
folder and adding the following line:
|
||||
|
||||
APP_STL := c++_shared
|
||||
|
||||
For more information go here:
|
||||
https://developer.android.com/ndk/guides/cpp-support
|
||||
|
||||
|
||||
Using the emulator
|
||||
================================================================================
|
||||
|
||||
There are some good tips and tricks for getting the most out of the
|
||||
emulator here: https://developer.android.com/tools/devices/emulator.html
|
||||
|
||||
Especially useful is the info on setting up OpenGL ES 2.0 emulation.
|
||||
|
||||
Notice that this software emulator is incredibly slow and needs a lot of disk space.
|
||||
Using a real device works better.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
================================================================================
|
||||
|
||||
You can see if adb can see any devices with the following command:
|
||||
|
||||
adb devices
|
||||
|
||||
You can see the output of log messages on the default device with:
|
||||
|
||||
adb logcat
|
||||
|
||||
You can push files to the device with:
|
||||
|
||||
adb push local_file remote_path_and_file
|
||||
|
||||
You can push files to the SD Card at /sdcard, for example:
|
||||
|
||||
adb push moose.dat /sdcard/moose.dat
|
||||
|
||||
You can see the files on the SD card with a shell command:
|
||||
|
||||
adb shell ls /sdcard/
|
||||
|
||||
You can start a command shell on the default device with:
|
||||
|
||||
adb shell
|
||||
|
||||
You can remove the library files of your project (and not the SDL lib files) with:
|
||||
|
||||
ndk-build clean
|
||||
|
||||
You can do a build with the following command:
|
||||
|
||||
ndk-build
|
||||
|
||||
You can see the complete command line that ndk-build is using by passing V=1 on the command line:
|
||||
|
||||
ndk-build V=1
|
||||
|
||||
If your application crashes in native code, you can use ndk-stack to get a symbolic stack trace:
|
||||
https://developer.android.com/ndk/guides/ndk-stack
|
||||
|
||||
If you want to go through the process manually, you can use addr2line to convert the
|
||||
addresses in the stack trace to lines in your code.
|
||||
|
||||
For example, if your crash looks like this:
|
||||
|
||||
I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0
|
||||
I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4
|
||||
I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c
|
||||
I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c
|
||||
I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030
|
||||
I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so
|
||||
I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so
|
||||
I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so
|
||||
|
||||
You can see that there's a crash in the C library being called from the main code.
|
||||
I run addr2line with the debug version of my code:
|
||||
|
||||
arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so
|
||||
|
||||
and then paste in the number after "pc" in the call stack, from the line that I care about:
|
||||
000014bc
|
||||
|
||||
I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23.
|
||||
|
||||
You can add logging to your code to help show what's happening:
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x);
|
||||
|
||||
If you need to build without optimization turned on, you can create a file called
|
||||
"Application.mk" in the jni directory, with the following line in it:
|
||||
|
||||
APP_OPTIM := debug
|
||||
|
||||
|
||||
Memory debugging
|
||||
================================================================================
|
||||
|
||||
The best (and slowest) way to debug memory issues on Android is valgrind.
|
||||
Valgrind has support for Android out of the box, just grab code using:
|
||||
|
||||
svn co svn://svn.valgrind.org/valgrind/trunk valgrind
|
||||
|
||||
... and follow the instructions in the file README.android to build it.
|
||||
|
||||
One thing I needed to do on Mac OS X was change the path to the toolchain,
|
||||
and add ranlib to the environment variables:
|
||||
export RANLIB=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-ranlib
|
||||
|
||||
Once valgrind is built, you can create a wrapper script to launch your
|
||||
application with it, changing org.libsdl.app to your package identifier:
|
||||
|
||||
--- start_valgrind_app -------------------
|
||||
#!/system/bin/sh
|
||||
export TMPDIR=/data/data/org.libsdl.app
|
||||
exec /data/local/Inst/bin/valgrind --log-file=/sdcard/valgrind.log --error-limit=no $*
|
||||
------------------------------------------
|
||||
|
||||
Then push it to the device:
|
||||
|
||||
adb push start_valgrind_app /data/local
|
||||
|
||||
and make it executable:
|
||||
|
||||
adb shell chmod 755 /data/local/start_valgrind_app
|
||||
|
||||
and tell Android to use the script to launch your application:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app "logwrapper /data/local/start_valgrind_app"
|
||||
|
||||
If the setprop command says "could not set property", it's likely that
|
||||
your package name is too long and you should make it shorter by changing
|
||||
AndroidManifest.xml and the path to your class file in android-project/src
|
||||
|
||||
You can then launch your application normally and waaaaaaaiiittt for it.
|
||||
You can monitor the startup process with the logcat command above, and
|
||||
when it's done (or even while it's running) you can grab the valgrind
|
||||
output file:
|
||||
|
||||
adb pull /sdcard/valgrind.log
|
||||
|
||||
When you're done instrumenting with valgrind, you can disable the wrapper:
|
||||
|
||||
adb shell setprop wrap.org.libsdl.app ""
|
||||
|
||||
|
||||
Graphics debugging
|
||||
================================================================================
|
||||
|
||||
If you are developing on a compatible Tegra-based tablet, NVidia provides
|
||||
Tegra Graphics Debugger at their website. Because SDL2 dynamically loads EGL
|
||||
and GLES libraries, you must follow their instructions for installing the
|
||||
interposer library on a rooted device. The non-rooted instructions are not
|
||||
compatible with applications that use SDL2 for video.
|
||||
|
||||
The Tegra Graphics Debugger is available from NVidia here:
|
||||
https://developer.nvidia.com/tegra-graphics-debugger
|
||||
|
||||
|
||||
Why is API level 19 the minimum required?
|
||||
================================================================================
|
||||
|
||||
The latest NDK toolchain doesn't support targeting earlier than API level 19.
|
||||
As of this writing, according to https://www.composables.com/tools/distribution-chart
|
||||
about 99.7% of the Android devices accessing Google Play support API level 19 or
|
||||
higher (August 2023).
|
||||
|
||||
|
||||
A note regarding the use of the "dirty rectangles" rendering technique
|
||||
================================================================================
|
||||
|
||||
If your app uses a variation of the "dirty rectangles" rendering technique,
|
||||
where you only update a portion of the screen on each frame, you may notice a
|
||||
variety of visual glitches on Android, that are not present on other platforms.
|
||||
This is caused by SDL's use of EGL as the support system to handle OpenGL ES/ES2
|
||||
contexts, in particular the use of the eglSwapBuffers function. As stated in the
|
||||
documentation for the function "The contents of ancillary buffers are always
|
||||
undefined after calling eglSwapBuffers".
|
||||
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to EGL_BUFFER_PRESERVED
|
||||
is not possible for SDL as it requires EGL 1.4, available only on the API level
|
||||
17+, so the only workaround available on this platform is to redraw the entire
|
||||
screen each frame.
|
||||
|
||||
Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html
|
||||
|
||||
|
||||
Ending your application
|
||||
================================================================================
|
||||
|
||||
Two legitimate ways:
|
||||
|
||||
- return from your main() function. Java side will automatically terminate the
|
||||
Activity by calling Activity.finish().
|
||||
|
||||
- Android OS can decide to terminate your application by calling onDestroy()
|
||||
(see Activity life cycle). Your application will receive a SDL_QUIT event you
|
||||
can handle to save things and quit.
|
||||
|
||||
Don't call exit() as it stops the activity badly.
|
||||
|
||||
NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode
|
||||
SDLK_AC_BACK, for any purpose.
|
||||
|
||||
Known issues
|
||||
================================================================================
|
||||
|
||||
- The number of buttons reported for each joystick is hardcoded to be 36, which
|
||||
is the current maximum number of buttons Android can report.
|
||||
|
||||
|
@@ -1,163 +1,163 @@
|
||||
# CMake
|
||||
|
||||
(www.cmake.org)
|
||||
|
||||
SDL's build system was traditionally based on autotools. Over time, this
|
||||
approach has suffered from several issues across the different supported
|
||||
platforms.
|
||||
To solve these problems, a new build system based on CMake was introduced.
|
||||
It is developed in parallel to the legacy autotools build system, so users
|
||||
can experiment with it without complication.
|
||||
|
||||
The CMake build system is supported on the following platforms:
|
||||
|
||||
* FreeBSD
|
||||
* Linux
|
||||
* Microsoft Visual C
|
||||
* MinGW and Msys
|
||||
* macOS, iOS, and tvOS, with support for XCode
|
||||
* Android
|
||||
* Emscripten
|
||||
* RiscOS
|
||||
* Playstation Vita
|
||||
|
||||
## Building SDL
|
||||
|
||||
Assuming the source for SDL is located at `~/sdl`
|
||||
```sh
|
||||
cd ~
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ~/sdl
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
This will build the static and dynamic versions of SDL in the `~/build` directory.
|
||||
Installation can be done using:
|
||||
|
||||
```sh
|
||||
cmake --install . # '--install' requires CMake 3.15, or newer
|
||||
```
|
||||
|
||||
## Including SDL in your project
|
||||
|
||||
SDL can be included in your project in 2 major ways:
|
||||
- using a system SDL library, provided by your (*nix) distribution or a package manager
|
||||
- using a vendored SDL library: this is SDL copied or symlinked in a subfolder.
|
||||
|
||||
The following CMake script supports both, depending on the value of `MYGAME_VENDORED`.
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(mygame)
|
||||
|
||||
# Create an option to switch between a system sdl library and a vendored sdl library
|
||||
option(MYGAME_VENDORED "Use vendored libraries" OFF)
|
||||
|
||||
if(MYGAME_VENDORED)
|
||||
add_subdirectory(vendored/sdl EXCLUDE_FROM_ALL)
|
||||
else()
|
||||
# 1. Look for a SDL2 package, 2. look for the SDL2 component and 3. fail if none can be found
|
||||
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
|
||||
|
||||
# 1. Look for a SDL2 package, 2. Look for the SDL2maincomponent and 3. DO NOT fail when SDL2main is not available
|
||||
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
|
||||
endif()
|
||||
|
||||
# Create your game executable target as usual
|
||||
add_executable(mygame WIN32 mygame.c)
|
||||
|
||||
# SDL2::SDL2main may or may not be available. It is e.g. required by Windows GUI applications
|
||||
if(TARGET SDL2::SDL2main)
|
||||
# It has an implicit dependency on SDL2 functions, so it MUST be added before SDL2::SDL2 (or SDL2::SDL2-static)
|
||||
target_link_libraries(mygame PRIVATE SDL2::SDL2main)
|
||||
endif()
|
||||
|
||||
# Link to the actual SDL2 library. SDL2::SDL2 is the shared SDL library, SDL2::SDL2-static is the static SDL libarary.
|
||||
target_link_libraries(mygame PRIVATE SDL2::SDL2)
|
||||
```
|
||||
|
||||
### A system SDL library
|
||||
|
||||
For CMake to find SDL, it must be installed in [a default location CMake is looking for](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure).
|
||||
|
||||
The following components are available, to be used as an argument of `find_package`.
|
||||
|
||||
| Component name | Description |
|
||||
|----------------|--------------------------------------------------------------------------------------------|
|
||||
| SDL2 | The SDL2 shared library, available through the `SDL2::SDL2` target [^SDL_TARGET_EXCEPTION] |
|
||||
| SDL2-static | The SDL2 static library, available through the `SDL2::SDL2-static` target |
|
||||
| SDL2main | The SDL2main static library, available through the `SDL2::SDL2main` target |
|
||||
| SDL2test | The SDL2test static library, available through the `SDL2::SDL2test` target |
|
||||
|
||||
### Using a vendored SDL
|
||||
|
||||
This only requires a copy of SDL in a subdirectory.
|
||||
|
||||
## CMake configuration options for platforms
|
||||
|
||||
### iOS/tvOS
|
||||
|
||||
CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built
|
||||
using Xcode or Make, possibly among other build-systems.
|
||||
|
||||
When using a recent version of CMake (3.14+), it should be possible to:
|
||||
|
||||
- build SDL for iOS, both static and dynamic
|
||||
- build SDL test apps (as iOS/tvOS .app bundles)
|
||||
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
|
||||
|
||||
To use, set the following CMake variables when running CMake's configuration stage:
|
||||
|
||||
- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`)
|
||||
- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`,
|
||||
`appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.)
|
||||
- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64")
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
```bash
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, 64-bit only
|
||||
|
||||
```bash
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
```
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
|
||||
```
|
||||
|
||||
- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example):
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
```
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DSDL_TESTS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for tvOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for tvOS-Device, using the latest, installed SDK:
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||
```
|
||||
|
||||
|
||||
[^SDL_TARGET_EXCEPTION]: `SDL2::SDL2` can be an ALIAS to a static `SDL2::SDL2-static` target for multiple reasons.
|
||||
# CMake
|
||||
|
||||
(www.cmake.org)
|
||||
|
||||
SDL's build system was traditionally based on autotools. Over time, this
|
||||
approach has suffered from several issues across the different supported
|
||||
platforms.
|
||||
To solve these problems, a new build system based on CMake was introduced.
|
||||
It is developed in parallel to the legacy autotools build system, so users
|
||||
can experiment with it without complication.
|
||||
|
||||
The CMake build system is supported on the following platforms:
|
||||
|
||||
* FreeBSD
|
||||
* Linux
|
||||
* Microsoft Visual C
|
||||
* MinGW and Msys
|
||||
* macOS, iOS, and tvOS, with support for XCode
|
||||
* Android
|
||||
* Emscripten
|
||||
* RiscOS
|
||||
* Playstation Vita
|
||||
|
||||
## Building SDL
|
||||
|
||||
Assuming the source for SDL is located at `~/sdl`
|
||||
```sh
|
||||
cd ~
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ~/sdl
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
This will build the static and dynamic versions of SDL in the `~/build` directory.
|
||||
Installation can be done using:
|
||||
|
||||
```sh
|
||||
cmake --install . # '--install' requires CMake 3.15, or newer
|
||||
```
|
||||
|
||||
## Including SDL in your project
|
||||
|
||||
SDL can be included in your project in 2 major ways:
|
||||
- using a system SDL library, provided by your (*nix) distribution or a package manager
|
||||
- using a vendored SDL library: this is SDL copied or symlinked in a subfolder.
|
||||
|
||||
The following CMake script supports both, depending on the value of `MYGAME_VENDORED`.
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(mygame)
|
||||
|
||||
# Create an option to switch between a system sdl library and a vendored sdl library
|
||||
option(MYGAME_VENDORED "Use vendored libraries" OFF)
|
||||
|
||||
if(MYGAME_VENDORED)
|
||||
add_subdirectory(vendored/sdl EXCLUDE_FROM_ALL)
|
||||
else()
|
||||
# 1. Look for a SDL2 package, 2. look for the SDL2 component and 3. fail if none can be found
|
||||
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
|
||||
|
||||
# 1. Look for a SDL2 package, 2. Look for the SDL2maincomponent and 3. DO NOT fail when SDL2main is not available
|
||||
find_package(SDL2 REQUIRED CONFIG COMPONENTS SDL2main)
|
||||
endif()
|
||||
|
||||
# Create your game executable target as usual
|
||||
add_executable(mygame WIN32 mygame.c)
|
||||
|
||||
# SDL2::SDL2main may or may not be available. It is e.g. required by Windows GUI applications
|
||||
if(TARGET SDL2::SDL2main)
|
||||
# It has an implicit dependency on SDL2 functions, so it MUST be added before SDL2::SDL2 (or SDL2::SDL2-static)
|
||||
target_link_libraries(mygame PRIVATE SDL2::SDL2main)
|
||||
endif()
|
||||
|
||||
# Link to the actual SDL2 library. SDL2::SDL2 is the shared SDL library, SDL2::SDL2-static is the static SDL libarary.
|
||||
target_link_libraries(mygame PRIVATE SDL2::SDL2)
|
||||
```
|
||||
|
||||
### A system SDL library
|
||||
|
||||
For CMake to find SDL, it must be installed in [a default location CMake is looking for](https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure).
|
||||
|
||||
The following components are available, to be used as an argument of `find_package`.
|
||||
|
||||
| Component name | Description |
|
||||
|----------------|--------------------------------------------------------------------------------------------|
|
||||
| SDL2 | The SDL2 shared library, available through the `SDL2::SDL2` target [^SDL_TARGET_EXCEPTION] |
|
||||
| SDL2-static | The SDL2 static library, available through the `SDL2::SDL2-static` target |
|
||||
| SDL2main | The SDL2main static library, available through the `SDL2::SDL2main` target |
|
||||
| SDL2test | The SDL2test static library, available through the `SDL2::SDL2test` target |
|
||||
|
||||
### Using a vendored SDL
|
||||
|
||||
This only requires a copy of SDL in a subdirectory.
|
||||
|
||||
## CMake configuration options for platforms
|
||||
|
||||
### iOS/tvOS
|
||||
|
||||
CMake 3.14+ natively includes support for iOS and tvOS. SDL binaries may be built
|
||||
using Xcode or Make, possibly among other build-systems.
|
||||
|
||||
When using a recent version of CMake (3.14+), it should be possible to:
|
||||
|
||||
- build SDL for iOS, both static and dynamic
|
||||
- build SDL test apps (as iOS/tvOS .app bundles)
|
||||
- generate a working SDL_config.h for iOS (using SDL_config.h.cmake as a basis)
|
||||
|
||||
To use, set the following CMake variables when running CMake's configuration stage:
|
||||
|
||||
- `CMAKE_SYSTEM_NAME=<OS>` (either `iOS` or `tvOS`)
|
||||
- `CMAKE_OSX_SYSROOT=<SDK>` (examples: `iphoneos`, `iphonesimulator`, `iphoneos12.4`, `/full/path/to/iPhoneOS.sdk`,
|
||||
`appletvos`, `appletvsimulator`, `appletvos12.4`, `/full/path/to/AppleTVOS.sdk`, etc.)
|
||||
- `CMAKE_OSX_ARCHITECTURES=<semicolon-separated list of CPU architectures>` (example: "arm64;armv7s;x86_64")
|
||||
|
||||
|
||||
#### Examples
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
```bash
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, 64-bit only
|
||||
|
||||
```bash
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
```
|
||||
|
||||
- for iOS-Device, using the latest, installed SDK, mixed 32/64 bit
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES="arm64;armv7s"
|
||||
```
|
||||
|
||||
- for iOS-Device, using a specific SDK revision (iOS 12.4, in this example):
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos12.4 -DCMAKE_OSX_ARCHITECTURES=arm64
|
||||
```
|
||||
|
||||
- for iOS-Simulator, using the latest, installed SDK, and building SDL test apps (as .app bundles):
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DSDL_TESTS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for tvOS-Simulator, using the latest, installed SDK:
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
```
|
||||
|
||||
- for tvOS-Device, using the latest, installed SDK:
|
||||
|
||||
```cmake
|
||||
cmake ~/sdl -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_ARCHITECTURES=arm64`
|
||||
```
|
||||
|
||||
|
||||
[^SDL_TARGET_EXCEPTION]: `SDL2::SDL2` can be an ALIAS to a static `SDL2::SDL2-static` target for multiple reasons.
|
||||
|
@@ -1,123 +1,123 @@
|
||||
DirectFB
|
||||
========
|
||||
|
||||
Supports:
|
||||
|
||||
- Hardware YUV overlays
|
||||
- OpenGL - software only
|
||||
- 2D/3D accelerations (depends on directfb driver)
|
||||
- multiple displays
|
||||
- windows
|
||||
|
||||
What you need:
|
||||
|
||||
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||
* Mesa 7.0.x - optional for OpenGL
|
||||
|
||||
The `/etc/directfbrc` file should contain the following lines to make
|
||||
your joystick work and avoid crashes:
|
||||
|
||||
```
|
||||
disable-module=joystick
|
||||
disable-module=cle266
|
||||
disable-module=cyber5k
|
||||
no-linux-input-grab
|
||||
```
|
||||
|
||||
To disable to use x11 backend when DISPLAY variable is found use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_X11_CHECK=0
|
||||
```
|
||||
|
||||
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
||||
use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_LINUX_INPUT=0
|
||||
```
|
||||
|
||||
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_YUV_DIRECT=1
|
||||
```
|
||||
|
||||
This is disabled by default. It will only support one
|
||||
YUV texture, namely the first. Every other YUV texture will be
|
||||
rendered in software.
|
||||
|
||||
In addition, you may use (directfb-1.2.x)
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
||||
```
|
||||
|
||||
to make the YUV texture an underlay. This will make the cursor to
|
||||
be shown.
|
||||
|
||||
Simple Window Manager
|
||||
=====================
|
||||
|
||||
The driver has support for a very, very basic window manager you may
|
||||
want to use when running with `wm=default`. Use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_WM=1
|
||||
```
|
||||
|
||||
to enable basic window borders. In order to have the window title rendered,
|
||||
you need to have the following font installed:
|
||||
|
||||
```
|
||||
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
||||
```
|
||||
|
||||
OpenGL Support
|
||||
==============
|
||||
|
||||
The following instructions will give you *software* OpenGL. However this
|
||||
works at least on all directfb supported platforms.
|
||||
|
||||
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
||||
|
||||
```
|
||||
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
||||
cd mesa
|
||||
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
||||
```
|
||||
|
||||
Edit `configs/linux-directfb` so that the Directories-section looks like this:
|
||||
|
||||
```
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = directfb
|
||||
PROGRAM_DIRS =
|
||||
```
|
||||
|
||||
Then do the following:
|
||||
|
||||
```
|
||||
make linux-directfb
|
||||
make
|
||||
|
||||
echo Installing - please enter sudo pw.
|
||||
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
cd src/mesa/drivers/directfb
|
||||
make
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
```
|
||||
|
||||
To run the SDL - testprograms:
|
||||
|
||||
```
|
||||
export SDL_VIDEODRIVER=directfb
|
||||
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
||||
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
||||
|
||||
./testgl
|
||||
```
|
||||
DirectFB
|
||||
========
|
||||
|
||||
Supports:
|
||||
|
||||
- Hardware YUV overlays
|
||||
- OpenGL - software only
|
||||
- 2D/3D accelerations (depends on directfb driver)
|
||||
- multiple displays
|
||||
- windows
|
||||
|
||||
What you need:
|
||||
|
||||
* DirectFB 1.0.1, 1.2.x, 1.3.0
|
||||
* Kernel-Framebuffer support: required: vesafb, radeonfb ....
|
||||
* Mesa 7.0.x - optional for OpenGL
|
||||
|
||||
The `/etc/directfbrc` file should contain the following lines to make
|
||||
your joystick work and avoid crashes:
|
||||
|
||||
```
|
||||
disable-module=joystick
|
||||
disable-module=cle266
|
||||
disable-module=cyber5k
|
||||
no-linux-input-grab
|
||||
```
|
||||
|
||||
To disable to use x11 backend when DISPLAY variable is found use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_X11_CHECK=0
|
||||
```
|
||||
|
||||
To disable the use of linux input devices, i.e. multimice/multikeyboard support,
|
||||
use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_LINUX_INPUT=0
|
||||
```
|
||||
|
||||
To use hardware accelerated YUV-overlays for YUV-textures, use:
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_YUV_DIRECT=1
|
||||
```
|
||||
|
||||
This is disabled by default. It will only support one
|
||||
YUV texture, namely the first. Every other YUV texture will be
|
||||
rendered in software.
|
||||
|
||||
In addition, you may use (directfb-1.2.x)
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_YUV_UNDERLAY=1
|
||||
```
|
||||
|
||||
to make the YUV texture an underlay. This will make the cursor to
|
||||
be shown.
|
||||
|
||||
Simple Window Manager
|
||||
=====================
|
||||
|
||||
The driver has support for a very, very basic window manager you may
|
||||
want to use when running with `wm=default`. Use
|
||||
|
||||
```
|
||||
export SDL_DIRECTFB_WM=1
|
||||
```
|
||||
|
||||
to enable basic window borders. In order to have the window title rendered,
|
||||
you need to have the following font installed:
|
||||
|
||||
```
|
||||
/usr/share/fonts/truetype/freefont/FreeSans.ttf
|
||||
```
|
||||
|
||||
OpenGL Support
|
||||
==============
|
||||
|
||||
The following instructions will give you *software* OpenGL. However this
|
||||
works at least on all directfb supported platforms.
|
||||
|
||||
As of this writing 20100802 you need to pull Mesa from git and do the following:
|
||||
|
||||
```
|
||||
git clone git://anongit.freedesktop.org/git/mesa/mesa
|
||||
cd mesa
|
||||
git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a
|
||||
```
|
||||
|
||||
Edit `configs/linux-directfb` so that the Directories-section looks like this:
|
||||
|
||||
```
|
||||
# Directories
|
||||
SRC_DIRS = mesa glu
|
||||
GLU_DIRS = sgi
|
||||
DRIVER_DIRS = directfb
|
||||
PROGRAM_DIRS =
|
||||
```
|
||||
|
||||
Then do the following:
|
||||
|
||||
```
|
||||
make linux-directfb
|
||||
make
|
||||
|
||||
echo Installing - please enter sudo pw.
|
||||
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
cd src/mesa/drivers/directfb
|
||||
make
|
||||
sudo make install INSTALL_DIR=/usr/local/dfb_GL
|
||||
```
|
||||
|
||||
To run the SDL - testprograms:
|
||||
|
||||
```
|
||||
export SDL_VIDEODRIVER=directfb
|
||||
export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib
|
||||
export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7
|
||||
|
||||
./testgl
|
||||
```
|
||||
|
@@ -1,138 +1,138 @@
|
||||
# Dynamic API
|
||||
|
||||
Originally posted on Ryan's Google+ account.
|
||||
|
||||
Background:
|
||||
|
||||
- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2,
|
||||
but developers are shipping their own SDL2 with individual Steam games.
|
||||
These games might stop getting updates, but a newer SDL2 might be needed later.
|
||||
Certainly we'll always be fixing bugs in SDL, even if a new video target isn't
|
||||
ever needed, and these fixes won't make it to a game shipping its own SDL.
|
||||
- Even if we replace the SDL2 in those games with a compatible one, that is to
|
||||
say, edit a developer's Steam depot (yuck!), there are developers that are
|
||||
statically linking SDL2 that we can't do this for. We can't even force the
|
||||
dynamic loader to ignore their SDL2 in this case, of course.
|
||||
- If you don't ship an SDL2 with the game in some form, people that disabled the
|
||||
Steam Runtime, or just tried to run the game from the command line instead of
|
||||
Steam might find themselves unable to run the game, due to a missing dependency.
|
||||
- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target
|
||||
generic Linux boxes that may or may not have SDL2 installed, you have to ship
|
||||
the library or risk a total failure to launch. So now, you might have to have
|
||||
a non-Steam build plus a Steam build (that is, one with and one without SDL2
|
||||
included), which is inconvenient if you could have had one universal build
|
||||
that works everywhere.
|
||||
- We like the zlib license, but the biggest complaint from the open source
|
||||
community about the license change is the static linking. The LGPL forced this
|
||||
as a legal, not technical issue, but zlib doesn't care. Even those that aren't
|
||||
concerned about the GNU freedoms found themselves solving the same problems:
|
||||
swapping in a newer SDL to an older game often times can save the day.
|
||||
Static linking stops this dead.
|
||||
|
||||
So here's what we did:
|
||||
|
||||
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||
now looks like:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init(Uint32 flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
Except that is all done with a bunch of macro magic so we don't have to maintain
|
||||
every one of these.
|
||||
|
||||
What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
||||
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||
like this:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
||||
pointers, which means that this `_DEFAULT` function never gets called again.
|
||||
First call to any SDL function sets the whole thing up.
|
||||
|
||||
So you might be asking, what was the value in that? Isn't this what the operating
|
||||
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
||||
level of indirection, we can do things like this:
|
||||
|
||||
```bash
|
||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||
./MyGameThatIsStaticallyLinkedToSDL2
|
||||
```
|
||||
|
||||
And now, this game that is statically linked to SDL, can still be overridden
|
||||
with a newer, or better, SDL. The statically linked one will only be used as
|
||||
far as calling into the jump table in this case. But in cases where no override
|
||||
is desired, the statically linked version will provide its own jump table,
|
||||
and everyone is happy.
|
||||
|
||||
So now:
|
||||
- Developers can statically link SDL, and users can still replace it.
|
||||
(We'd still rather you ship a shared library, though!)
|
||||
- Developers can ship an SDL with their game, Valve can override it for, say,
|
||||
new features on SteamOS, or distros can override it for their own needs,
|
||||
but it'll also just work in the default case.
|
||||
- Developers can ship the same package to everyone (Humble Bundle, GOG, etc),
|
||||
and it'll do the right thing.
|
||||
- End users (and Valve) can update a game's SDL in almost any case,
|
||||
to keep abandoned games running on newer platforms.
|
||||
- Everyone develops with SDL exactly as they have been doing all along.
|
||||
Same headers, same ABI. Just get the latest version to enable this magic.
|
||||
|
||||
|
||||
A little more about SDL_InitDynamicAPI():
|
||||
|
||||
Internally, InitAPI does some locking to make sure everything waits until a
|
||||
single thread initializes everything (although even SDL_CreateThread() goes
|
||||
through here before spinning a thread, too), and then decides if it should use
|
||||
an external SDL library. If not, it sets up the jump table using the current
|
||||
SDL's function pointers (which might be statically linked into a program, or in
|
||||
a shared library of its own). If so, it loads that library and looks for and
|
||||
calls a single function:
|
||||
|
||||
```c
|
||||
Sint32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||
```
|
||||
|
||||
That function takes a version number (more on that in a moment), the address of
|
||||
the jump table, and the size, in bytes, of the table.
|
||||
Now, we've got policy here: this table's layout never changes; new stuff gets
|
||||
added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all
|
||||
the needed functions if tablesize <= sizeof its own jump table. If tablesize is
|
||||
bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but
|
||||
if it's smaller, we know we can provide the entire API that the caller needs.
|
||||
|
||||
The version variable is a failsafe switch.
|
||||
Right now it's always 1. This number changes when there are major API changes
|
||||
(so we know if the tablesize might be smaller, or entries in it have changed).
|
||||
Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not
|
||||
inconceivable to have a small dispatch library that only supplies this one
|
||||
function and loads different, otherwise-incompatible SDL libraries and has the
|
||||
right one initialize the jump table based on the version. For something that
|
||||
must generically catch lots of different versions of SDL over time, like the
|
||||
Steam Client, this isn't a bad option.
|
||||
|
||||
Finally, I'm sure some people are reading this and thinking,
|
||||
"I don't want that overhead in my project!"
|
||||
|
||||
To which I would point out that the extra function call through the jump table
|
||||
probably wouldn't even show up in a profile, but lucky you: this can all be
|
||||
disabled. You can build SDL without this if you absolutely must, but we would
|
||||
encourage you not to do that. However, on heavily locked down platforms like
|
||||
iOS, or maybe when debugging, it makes sense to disable it. The way this is
|
||||
designed in SDL, you just have to change one #define, and the entire system
|
||||
vaporizes out, and SDL functions exactly like it always did. Most of it is
|
||||
macro magic, so the system is contained to one C file and a few headers.
|
||||
However, this is on by default and you have to edit a header file to turn it
|
||||
off. Our hopes is that if we make it easy to disable, but not too easy,
|
||||
everyone will ultimately be able to get what they want, but we've gently
|
||||
nudged everyone towards what we think is the best solution.
|
||||
# Dynamic API
|
||||
|
||||
Originally posted on Ryan's Google+ account.
|
||||
|
||||
Background:
|
||||
|
||||
- The Steam Runtime has (at least in theory) a really kick-ass build of SDL2,
|
||||
but developers are shipping their own SDL2 with individual Steam games.
|
||||
These games might stop getting updates, but a newer SDL2 might be needed later.
|
||||
Certainly we'll always be fixing bugs in SDL, even if a new video target isn't
|
||||
ever needed, and these fixes won't make it to a game shipping its own SDL.
|
||||
- Even if we replace the SDL2 in those games with a compatible one, that is to
|
||||
say, edit a developer's Steam depot (yuck!), there are developers that are
|
||||
statically linking SDL2 that we can't do this for. We can't even force the
|
||||
dynamic loader to ignore their SDL2 in this case, of course.
|
||||
- If you don't ship an SDL2 with the game in some form, people that disabled the
|
||||
Steam Runtime, or just tried to run the game from the command line instead of
|
||||
Steam might find themselves unable to run the game, due to a missing dependency.
|
||||
- If you want to ship on non-Steam platforms like GOG or Humble Bundle, or target
|
||||
generic Linux boxes that may or may not have SDL2 installed, you have to ship
|
||||
the library or risk a total failure to launch. So now, you might have to have
|
||||
a non-Steam build plus a Steam build (that is, one with and one without SDL2
|
||||
included), which is inconvenient if you could have had one universal build
|
||||
that works everywhere.
|
||||
- We like the zlib license, but the biggest complaint from the open source
|
||||
community about the license change is the static linking. The LGPL forced this
|
||||
as a legal, not technical issue, but zlib doesn't care. Even those that aren't
|
||||
concerned about the GNU freedoms found themselves solving the same problems:
|
||||
swapping in a newer SDL to an older game often times can save the day.
|
||||
Static linking stops this dead.
|
||||
|
||||
So here's what we did:
|
||||
|
||||
SDL now has, internally, a table of function pointers. So, this is what SDL_Init
|
||||
now looks like:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init(Uint32 flags)
|
||||
{
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
Except that is all done with a bunch of macro magic so we don't have to maintain
|
||||
every one of these.
|
||||
|
||||
What is jump_table.SDL_init()? Eventually, that's a function pointer of the real
|
||||
SDL_Init() that you've been calling all this time. But at startup, it looks more
|
||||
like this:
|
||||
|
||||
```c
|
||||
Uint32 SDL_Init_DEFAULT(Uint32 flags)
|
||||
{
|
||||
SDL_InitDynamicAPI();
|
||||
return jump_table.SDL_Init(flags);
|
||||
}
|
||||
```
|
||||
|
||||
SDL_InitDynamicAPI() fills in jump_table with all the actual SDL function
|
||||
pointers, which means that this `_DEFAULT` function never gets called again.
|
||||
First call to any SDL function sets the whole thing up.
|
||||
|
||||
So you might be asking, what was the value in that? Isn't this what the operating
|
||||
system's dynamic loader was supposed to do for us? Yes, but now we've got this
|
||||
level of indirection, we can do things like this:
|
||||
|
||||
```bash
|
||||
export SDL_DYNAMIC_API=/my/actual/libSDL-2.0.so.0
|
||||
./MyGameThatIsStaticallyLinkedToSDL2
|
||||
```
|
||||
|
||||
And now, this game that is statically linked to SDL, can still be overridden
|
||||
with a newer, or better, SDL. The statically linked one will only be used as
|
||||
far as calling into the jump table in this case. But in cases where no override
|
||||
is desired, the statically linked version will provide its own jump table,
|
||||
and everyone is happy.
|
||||
|
||||
So now:
|
||||
- Developers can statically link SDL, and users can still replace it.
|
||||
(We'd still rather you ship a shared library, though!)
|
||||
- Developers can ship an SDL with their game, Valve can override it for, say,
|
||||
new features on SteamOS, or distros can override it for their own needs,
|
||||
but it'll also just work in the default case.
|
||||
- Developers can ship the same package to everyone (Humble Bundle, GOG, etc),
|
||||
and it'll do the right thing.
|
||||
- End users (and Valve) can update a game's SDL in almost any case,
|
||||
to keep abandoned games running on newer platforms.
|
||||
- Everyone develops with SDL exactly as they have been doing all along.
|
||||
Same headers, same ABI. Just get the latest version to enable this magic.
|
||||
|
||||
|
||||
A little more about SDL_InitDynamicAPI():
|
||||
|
||||
Internally, InitAPI does some locking to make sure everything waits until a
|
||||
single thread initializes everything (although even SDL_CreateThread() goes
|
||||
through here before spinning a thread, too), and then decides if it should use
|
||||
an external SDL library. If not, it sets up the jump table using the current
|
||||
SDL's function pointers (which might be statically linked into a program, or in
|
||||
a shared library of its own). If so, it loads that library and looks for and
|
||||
calls a single function:
|
||||
|
||||
```c
|
||||
Sint32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize);
|
||||
```
|
||||
|
||||
That function takes a version number (more on that in a moment), the address of
|
||||
the jump table, and the size, in bytes, of the table.
|
||||
Now, we've got policy here: this table's layout never changes; new stuff gets
|
||||
added to the end. Therefore SDL_DYNAPI_entry() knows that it can provide all
|
||||
the needed functions if tablesize <= sizeof its own jump table. If tablesize is
|
||||
bigger (say, SDL 2.0.4 is trying to load SDL 2.0.3), then we know to abort, but
|
||||
if it's smaller, we know we can provide the entire API that the caller needs.
|
||||
|
||||
The version variable is a failsafe switch.
|
||||
Right now it's always 1. This number changes when there are major API changes
|
||||
(so we know if the tablesize might be smaller, or entries in it have changed).
|
||||
Right now SDL_DYNAPI_entry gives up if the version doesn't match, but it's not
|
||||
inconceivable to have a small dispatch library that only supplies this one
|
||||
function and loads different, otherwise-incompatible SDL libraries and has the
|
||||
right one initialize the jump table based on the version. For something that
|
||||
must generically catch lots of different versions of SDL over time, like the
|
||||
Steam Client, this isn't a bad option.
|
||||
|
||||
Finally, I'm sure some people are reading this and thinking,
|
||||
"I don't want that overhead in my project!"
|
||||
|
||||
To which I would point out that the extra function call through the jump table
|
||||
probably wouldn't even show up in a profile, but lucky you: this can all be
|
||||
disabled. You can build SDL without this if you absolutely must, but we would
|
||||
encourage you not to do that. However, on heavily locked down platforms like
|
||||
iOS, or maybe when debugging, it makes sense to disable it. The way this is
|
||||
designed in SDL, you just have to change one #define, and the entire system
|
||||
vaporizes out, and SDL functions exactly like it always did. Most of it is
|
||||
macro magic, so the system is contained to one C file and a few headers.
|
||||
However, this is on by default and you have to edit a header file to turn it
|
||||
off. Our hopes is that if we make it easy to disable, but not too easy,
|
||||
everyone will ultimately be able to get what they want, but we've gently
|
||||
nudged everyone towards what we think is the best solution.
|
||||
|
@@ -1,374 +1,374 @@
|
||||
# Emscripten
|
||||
|
||||
## The state of things
|
||||
|
||||
(As of September 2023, but things move quickly and we don't update this
|
||||
document often.)
|
||||
|
||||
In modern times, all the browsers you probably care about (Chrome, Firefox,
|
||||
Edge, and Safari, on Windows, macOS, Linux, iOS and Android), support some
|
||||
reasonable base configurations:
|
||||
|
||||
- WebAssembly (don't bother with asm.js any more)
|
||||
- WebGL (which will look like OpenGL ES 2 or 3 to your app).
|
||||
- Threads (see caveats, though!)
|
||||
- Game controllers
|
||||
- Autoupdating (so you can assume they have a recent version of the browser)
|
||||
|
||||
All this to say we're at the point where you don't have to make a lot of
|
||||
concessions to get even a fairly complex SDL-based game up and running.
|
||||
|
||||
|
||||
## RTFM
|
||||
|
||||
This document is a quick rundown of some high-level details. The
|
||||
documentation at [emscripten.org](https://emscripten.org/) is vast
|
||||
and extremely detailed for a wide variety of topics, and you should at
|
||||
least skim through it at some point.
|
||||
|
||||
|
||||
## Porting your app to Emscripten
|
||||
|
||||
Many many things just need some simple adjustments and they'll compile
|
||||
like any other C/C++ code, as long as SDL was handling the platform-specific
|
||||
work for your program.
|
||||
|
||||
First, you probably need this in at least one of your source files:
|
||||
|
||||
```c
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
```
|
||||
|
||||
Second: assembly language code has to go. Replace it with C. You can even use
|
||||
[x86 SIMD intrinsic functions in Emscripten](https://emscripten.org/docs/porting/simd.html)!
|
||||
|
||||
Third: Middleware has to go. If you have a third-party library you link
|
||||
against, you either need an Emscripten port of it, or the source code to it
|
||||
to compile yourself, or you need to remove it.
|
||||
|
||||
Fourth: You still start in a function called main(), but you need to get out of
|
||||
it and into a function that gets called repeatedly, and returns quickly,
|
||||
called a mainloop.
|
||||
|
||||
Somewhere in your program, you probably have something that looks like a more
|
||||
complicated version of this:
|
||||
|
||||
```c
|
||||
void main(void)
|
||||
{
|
||||
initialize_the_game();
|
||||
while (game_is_still_running) {
|
||||
check_for_new_input();
|
||||
think_about_stuff();
|
||||
draw_the_next_frame();
|
||||
}
|
||||
deinitialize_the_game();
|
||||
}
|
||||
```
|
||||
|
||||
This will not work on Emscripten, because the main thread needs to be free
|
||||
to do stuff and can't sit in this loop forever. So Emscripten lets you set up
|
||||
a [mainloop](https://emscripten.org/docs/porting/emscripten-runtime-environment.html#browser-main-loop).
|
||||
|
||||
```c
|
||||
static void mainloop(void) /* this will run often, possibly at the monitor's refresh rate */
|
||||
{
|
||||
if (!game_is_still_running) {
|
||||
deinitialize_the_game();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
||||
#else
|
||||
exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
check_for_new_input();
|
||||
think_about_stuff();
|
||||
draw_the_next_frame();
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
initialize_the_game();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(mainloop, 0, 1);
|
||||
#else
|
||||
while (1) { mainloop(); }
|
||||
#endif
|
||||
}
|
||||
```
|
||||
|
||||
Basically, `emscripten_set_main_loop(mainloop, 0, 1);` says "run
|
||||
`mainloop` over and over until I end the program." The function will
|
||||
run, and return, freeing the main thread for other tasks, and then
|
||||
run again when it's time. The `1` parameter does some magic to make
|
||||
your main() function end immediately; this is useful because you
|
||||
don't want any shutdown code that might be sitting below this code
|
||||
to actually run if main() were to continue on, since we're just
|
||||
getting started.
|
||||
|
||||
There's a lot of little details that are beyond the scope of this
|
||||
document, but that's the biggest intial set of hurdles to porting
|
||||
your app to the web.
|
||||
|
||||
|
||||
## Do you need threads?
|
||||
|
||||
If you plan to use threads, they work on all major browsers now. HOWEVER,
|
||||
they bring with them a lot of careful considerations. Rendering _must_
|
||||
be done on the main thread. This is a general guideline for many
|
||||
platforms, but a hard requirement on the web.
|
||||
|
||||
Many other things also must happen on the main thread; often times SDL
|
||||
and Emscripten make efforts to "proxy" work to the main thread that
|
||||
must be there, but you have to be careful (and read more detailed
|
||||
documentation than this for the finer points).
|
||||
|
||||
Even when using threads, your main thread needs to set an Emscripten
|
||||
mainloop that runs quickly and returns, or things will fail to work
|
||||
correctly.
|
||||
|
||||
You should definitely read [Emscripten's pthreads docs](https://emscripten.org/docs/porting/pthreads.html)
|
||||
for all the finer points. Mostly SDL's thread API will work as expected,
|
||||
but is built on pthreads, so it shares the same little incompatibilities
|
||||
that are documented there, such as where you can use a mutex, and when
|
||||
a thread will start running, etc.
|
||||
|
||||
|
||||
IMPORTANT: You have to decide to either build something that uses
|
||||
threads or something that doesn't; you can't have one build
|
||||
that works everywhere. This is an Emscripten (or maybe WebAssembly?
|
||||
Or just web browsers in general?) limitation. If you aren't using
|
||||
threads, it's easier to not enable them at all, at build time.
|
||||
|
||||
If you use threads, you _have to_ run from a web server that has
|
||||
[COOP/COEP headers set correctly](https://web.dev/why-coop-coep/)
|
||||
or your program will fail to start at all.
|
||||
|
||||
If building with threads, `__EMSCRIPTEN_PTHREADS__` will be defined
|
||||
for checking with the C preprocessor, so you can build something
|
||||
different depending on what sort of build you're compiling.
|
||||
|
||||
|
||||
## Audio
|
||||
|
||||
Audio works as expected at the API level, but not exactly like other
|
||||
platforms.
|
||||
|
||||
You'll only see a single default audio device. Audio capture also works;
|
||||
if the browser pops up a prompt to ask for permission to access the
|
||||
microphone, the SDL_OpenAudioDevice call will succeed and start producing
|
||||
silence at a regular interval. Once the user approves the request, real
|
||||
audio data will flow. If the user denies it, the app is not informed and
|
||||
will just continue to receive silence.
|
||||
|
||||
Modern web browsers will not permit web pages to produce sound before the
|
||||
user has interacted with them (clicked or tapped on them, usually); this is
|
||||
for several reasons, not the least of which being that no one likes when a
|
||||
random browser tab suddenly starts making noise and the user has to scramble
|
||||
to figure out which and silence it.
|
||||
|
||||
SDL will allow you to open the audio device for playback in this
|
||||
circumstance, and your audio callback will fire, but SDL will throw the audio
|
||||
data away until the user interacts with the page. This helps apps that depend
|
||||
on the audio callback to make progress, and also keeps audio playback in sync
|
||||
once the app is finally allowed to make noise.
|
||||
|
||||
There are two reasonable ways to deal with the silence at the app level:
|
||||
if you are writing some sort of media player thing, where the user expects
|
||||
there to be a volume control when you mouseover the canvas, just default
|
||||
that control to a muted state; if the user clicks on the control to unmute
|
||||
it, on this first click, open the audio device. This allows the media to
|
||||
play at start, and the user can reasonably opt-in to listening.
|
||||
|
||||
Many games do not have this sort of UI, and are more rigid about starting
|
||||
audio along with everything else at the start of the process. For these, your
|
||||
best bet is to write a little Javascript that puts up a "Click here to play!"
|
||||
UI, and upon the user clicking, remove that UI and then call the Emscripten
|
||||
app's main() function. As far as the application knows, the audio device was
|
||||
available to be opened as soon as the program started, and since this magic
|
||||
happens in a little Javascript, you don't have to change your C/C++ code at
|
||||
all to make it happen.
|
||||
|
||||
Please see the discussion at https://github.com/libsdl-org/SDL/issues/6385
|
||||
for some Javascript code to steal for this approach.
|
||||
|
||||
|
||||
## Rendering
|
||||
|
||||
If you use SDL's 2D render API, it will use GLES2 internally, which
|
||||
Emscripten will turn into WebGL calls. You can also use OpenGL ES 2
|
||||
directly by creating a GL context and drawing into it.
|
||||
|
||||
Calling SDL_RenderPresent (or SDL_GL_SwapWindow) will not actually
|
||||
present anything on the screen until your return from your mainloop
|
||||
function.
|
||||
|
||||
|
||||
## Building SDL/emscripten
|
||||
|
||||
First: do you _really_ need to build SDL from source?
|
||||
|
||||
If you aren't developing SDL itself, have a desire to mess with its source
|
||||
code, or need something on the bleeding edge, don't build SDL. Just use
|
||||
Emscripten's packaged version!
|
||||
|
||||
Compile and link your app with `-sUSE_SDL=2` and it'll use a build of
|
||||
SDL packaged with Emscripten. This comes from the same source code and
|
||||
fixes the Emscripten project makes to SDL are generally merged into SDL's
|
||||
revision control, so often this is much easier for app developers.
|
||||
|
||||
`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL
|
||||
1.2 instead; if you need SDL 1.2, this might be fine, but we generally
|
||||
recommend you don't use SDL 1.2 in modern times.
|
||||
|
||||
|
||||
If you want to build SDL, though...
|
||||
|
||||
SDL currently requires at least Emscripten 3.1.35 to build. Newer versions
|
||||
are likely to work, as well.
|
||||
|
||||
|
||||
Build:
|
||||
|
||||
This works on Linux/Unix and macOS. Please send comments about Windows.
|
||||
|
||||
Make sure you've [installed emsdk](https://emscripten.org/docs/getting_started/downloads.html)
|
||||
first, and run `source emsdk_env.sh` at the command line so it finds the
|
||||
tools.
|
||||
|
||||
(These configure options might be overkill, but this has worked for me.)
|
||||
|
||||
```bash
|
||||
cd SDL
|
||||
mkdir build
|
||||
cd build
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3"
|
||||
emmake make -j4
|
||||
```
|
||||
|
||||
If you want to build with thread support, something like this works:
|
||||
|
||||
```bash
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread"
|
||||
```
|
||||
|
||||
Or with cmake:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
emcmake cmake ..
|
||||
emmake make -j4
|
||||
```
|
||||
|
||||
To build one of the tests:
|
||||
|
||||
```bash
|
||||
cd test/
|
||||
emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
||||
```
|
||||
|
||||
## Building your app
|
||||
|
||||
You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but
|
||||
mostly it uses the same command line arguments as Clang.
|
||||
|
||||
Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL,
|
||||
link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build.
|
||||
|
||||
Usually you would produce a binary like this:
|
||||
|
||||
```bash
|
||||
gcc -o mygame mygame.c # or whatever
|
||||
```
|
||||
|
||||
But for Emscripten, you want to output something else:
|
||||
|
||||
```bash
|
||||
emcc -o index.html mygame.c
|
||||
```
|
||||
|
||||
This will produce several files...support Javascript and WebAssembly (.wasm)
|
||||
files. The `-o index.html` will produce a simple HTML page that loads and
|
||||
runs your app. You will (probably) eventually want to replace or customize
|
||||
that file and do `-o index.js` instead to just build the code pieces.
|
||||
|
||||
If you're working on a program of any serious size, you'll likely need to
|
||||
link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access
|
||||
to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb`
|
||||
or the app will fail to start on iOS browsers, but this might be a bug that
|
||||
goes away in the future.
|
||||
|
||||
|
||||
## Data files
|
||||
|
||||
Your game probably has data files. Here's how to access them.
|
||||
|
||||
Filesystem access works like a Unix filesystem; you have a single directory
|
||||
tree, possibly interpolated from several mounted locations, no drive letters,
|
||||
'/' for a path separator. You can access them with standard file APIs like
|
||||
open() or fopen() or SDL_RWops. You can read or write from the filesystem.
|
||||
|
||||
By default, you probably have a "MEMFS" filesystem (all files are stored in
|
||||
memory, but access to them is immediate and doesn't need to block). There are
|
||||
other options, like "IDBFS" (files are stored in a local database, so they
|
||||
don't need to be in RAM all the time and they can persist between runs of the
|
||||
program, but access is not synchronous). You can mix and match these file
|
||||
systems, mounting a MEMFS filesystem at one place and idbfs elsewhere, etc,
|
||||
but that's beyond the scope of this document. Please refer to Emscripten's
|
||||
[page on the topic](https://emscripten.org/docs/porting/files/file_systems_overview.html)
|
||||
for more info.
|
||||
|
||||
The _easiest_ (but not the best) way to get at your data files is to embed
|
||||
them in the app itself. Emscripten's linker has support for automating this.
|
||||
|
||||
```bash
|
||||
emcc -o index.html loopwave.c --embed-file=../test/sample.wav@/sounds/sample.wav
|
||||
```
|
||||
|
||||
This will pack ../test/sample.wav in your app, and make it available at
|
||||
"/sounds/sample.wav" at runtime. Emscripten makes sure this data is available
|
||||
before your main() function runs, and since it's in MEMFS, you can just
|
||||
read it like you do on other platforms. `--embed-file` can also accept a
|
||||
directory to pack an entire tree, and you can specify the argument multiple
|
||||
times to pack unrelated things into the final installation.
|
||||
|
||||
Note that this is absolutely the best approach if you have a few small
|
||||
files to include and shouldn't worry about the issue further. However, if you
|
||||
have hundreds of megabytes and/or thousands of files, this is not so great,
|
||||
since the user will download it all every time they load your page, and it
|
||||
all has to live in memory at runtime.
|
||||
|
||||
[Emscripten's documentation on the matter](https://emscripten.org/docs/porting/files/packaging_files.html)
|
||||
gives other options and details, and is worth a read.
|
||||
|
||||
|
||||
## Debugging
|
||||
|
||||
Debugging web apps is a mixed bag. You should compile and link with
|
||||
`-gsource-map`, which embeds a ton of source-level debugging information into
|
||||
the build, and make sure _the app source code is available on the web server_,
|
||||
which is often a scary proposition for various reasons.
|
||||
|
||||
When you debug from the browser's tools and hit a breakpoint, you can step
|
||||
through the actual C/C++ source code, though, which can be nice.
|
||||
|
||||
If you try debugging in Firefox and it doesn't work well for no apparent
|
||||
reason, try Chrome, and vice-versa. These tools are still relatively new,
|
||||
and improving all the time.
|
||||
|
||||
SDL_Log() (or even plain old printf) will write to the Javascript console,
|
||||
and honestly I find printf-style debugging to be easier than setting up a build
|
||||
for proper debugging, so use whatever tools work best for you.
|
||||
|
||||
|
||||
## Questions?
|
||||
|
||||
Please give us feedback on this document at [the SDL bug tracker](https://github.com/libsdl-org/SDL/issues).
|
||||
If something is wrong or unclear, we want to know!
|
||||
|
||||
|
||||
|
||||
# Emscripten
|
||||
|
||||
## The state of things
|
||||
|
||||
(As of September 2023, but things move quickly and we don't update this
|
||||
document often.)
|
||||
|
||||
In modern times, all the browsers you probably care about (Chrome, Firefox,
|
||||
Edge, and Safari, on Windows, macOS, Linux, iOS and Android), support some
|
||||
reasonable base configurations:
|
||||
|
||||
- WebAssembly (don't bother with asm.js any more)
|
||||
- WebGL (which will look like OpenGL ES 2 or 3 to your app).
|
||||
- Threads (see caveats, though!)
|
||||
- Game controllers
|
||||
- Autoupdating (so you can assume they have a recent version of the browser)
|
||||
|
||||
All this to say we're at the point where you don't have to make a lot of
|
||||
concessions to get even a fairly complex SDL-based game up and running.
|
||||
|
||||
|
||||
## RTFM
|
||||
|
||||
This document is a quick rundown of some high-level details. The
|
||||
documentation at [emscripten.org](https://emscripten.org/) is vast
|
||||
and extremely detailed for a wide variety of topics, and you should at
|
||||
least skim through it at some point.
|
||||
|
||||
|
||||
## Porting your app to Emscripten
|
||||
|
||||
Many many things just need some simple adjustments and they'll compile
|
||||
like any other C/C++ code, as long as SDL was handling the platform-specific
|
||||
work for your program.
|
||||
|
||||
First, you probably need this in at least one of your source files:
|
||||
|
||||
```c
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten.h>
|
||||
#endif
|
||||
```
|
||||
|
||||
Second: assembly language code has to go. Replace it with C. You can even use
|
||||
[x86 SIMD intrinsic functions in Emscripten](https://emscripten.org/docs/porting/simd.html)!
|
||||
|
||||
Third: Middleware has to go. If you have a third-party library you link
|
||||
against, you either need an Emscripten port of it, or the source code to it
|
||||
to compile yourself, or you need to remove it.
|
||||
|
||||
Fourth: You still start in a function called main(), but you need to get out of
|
||||
it and into a function that gets called repeatedly, and returns quickly,
|
||||
called a mainloop.
|
||||
|
||||
Somewhere in your program, you probably have something that looks like a more
|
||||
complicated version of this:
|
||||
|
||||
```c
|
||||
void main(void)
|
||||
{
|
||||
initialize_the_game();
|
||||
while (game_is_still_running) {
|
||||
check_for_new_input();
|
||||
think_about_stuff();
|
||||
draw_the_next_frame();
|
||||
}
|
||||
deinitialize_the_game();
|
||||
}
|
||||
```
|
||||
|
||||
This will not work on Emscripten, because the main thread needs to be free
|
||||
to do stuff and can't sit in this loop forever. So Emscripten lets you set up
|
||||
a [mainloop](https://emscripten.org/docs/porting/emscripten-runtime-environment.html#browser-main-loop).
|
||||
|
||||
```c
|
||||
static void mainloop(void) /* this will run often, possibly at the monitor's refresh rate */
|
||||
{
|
||||
if (!game_is_still_running) {
|
||||
deinitialize_the_game();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_cancel_main_loop(); /* this should "kill" the app. */
|
||||
#else
|
||||
exit(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
check_for_new_input();
|
||||
think_about_stuff();
|
||||
draw_the_next_frame();
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
initialize_the_game();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(mainloop, 0, 1);
|
||||
#else
|
||||
while (1) { mainloop(); }
|
||||
#endif
|
||||
}
|
||||
```
|
||||
|
||||
Basically, `emscripten_set_main_loop(mainloop, 0, 1);` says "run
|
||||
`mainloop` over and over until I end the program." The function will
|
||||
run, and return, freeing the main thread for other tasks, and then
|
||||
run again when it's time. The `1` parameter does some magic to make
|
||||
your main() function end immediately; this is useful because you
|
||||
don't want any shutdown code that might be sitting below this code
|
||||
to actually run if main() were to continue on, since we're just
|
||||
getting started.
|
||||
|
||||
There's a lot of little details that are beyond the scope of this
|
||||
document, but that's the biggest intial set of hurdles to porting
|
||||
your app to the web.
|
||||
|
||||
|
||||
## Do you need threads?
|
||||
|
||||
If you plan to use threads, they work on all major browsers now. HOWEVER,
|
||||
they bring with them a lot of careful considerations. Rendering _must_
|
||||
be done on the main thread. This is a general guideline for many
|
||||
platforms, but a hard requirement on the web.
|
||||
|
||||
Many other things also must happen on the main thread; often times SDL
|
||||
and Emscripten make efforts to "proxy" work to the main thread that
|
||||
must be there, but you have to be careful (and read more detailed
|
||||
documentation than this for the finer points).
|
||||
|
||||
Even when using threads, your main thread needs to set an Emscripten
|
||||
mainloop that runs quickly and returns, or things will fail to work
|
||||
correctly.
|
||||
|
||||
You should definitely read [Emscripten's pthreads docs](https://emscripten.org/docs/porting/pthreads.html)
|
||||
for all the finer points. Mostly SDL's thread API will work as expected,
|
||||
but is built on pthreads, so it shares the same little incompatibilities
|
||||
that are documented there, such as where you can use a mutex, and when
|
||||
a thread will start running, etc.
|
||||
|
||||
|
||||
IMPORTANT: You have to decide to either build something that uses
|
||||
threads or something that doesn't; you can't have one build
|
||||
that works everywhere. This is an Emscripten (or maybe WebAssembly?
|
||||
Or just web browsers in general?) limitation. If you aren't using
|
||||
threads, it's easier to not enable them at all, at build time.
|
||||
|
||||
If you use threads, you _have to_ run from a web server that has
|
||||
[COOP/COEP headers set correctly](https://web.dev/why-coop-coep/)
|
||||
or your program will fail to start at all.
|
||||
|
||||
If building with threads, `__EMSCRIPTEN_PTHREADS__` will be defined
|
||||
for checking with the C preprocessor, so you can build something
|
||||
different depending on what sort of build you're compiling.
|
||||
|
||||
|
||||
## Audio
|
||||
|
||||
Audio works as expected at the API level, but not exactly like other
|
||||
platforms.
|
||||
|
||||
You'll only see a single default audio device. Audio capture also works;
|
||||
if the browser pops up a prompt to ask for permission to access the
|
||||
microphone, the SDL_OpenAudioDevice call will succeed and start producing
|
||||
silence at a regular interval. Once the user approves the request, real
|
||||
audio data will flow. If the user denies it, the app is not informed and
|
||||
will just continue to receive silence.
|
||||
|
||||
Modern web browsers will not permit web pages to produce sound before the
|
||||
user has interacted with them (clicked or tapped on them, usually); this is
|
||||
for several reasons, not the least of which being that no one likes when a
|
||||
random browser tab suddenly starts making noise and the user has to scramble
|
||||
to figure out which and silence it.
|
||||
|
||||
SDL will allow you to open the audio device for playback in this
|
||||
circumstance, and your audio callback will fire, but SDL will throw the audio
|
||||
data away until the user interacts with the page. This helps apps that depend
|
||||
on the audio callback to make progress, and also keeps audio playback in sync
|
||||
once the app is finally allowed to make noise.
|
||||
|
||||
There are two reasonable ways to deal with the silence at the app level:
|
||||
if you are writing some sort of media player thing, where the user expects
|
||||
there to be a volume control when you mouseover the canvas, just default
|
||||
that control to a muted state; if the user clicks on the control to unmute
|
||||
it, on this first click, open the audio device. This allows the media to
|
||||
play at start, and the user can reasonably opt-in to listening.
|
||||
|
||||
Many games do not have this sort of UI, and are more rigid about starting
|
||||
audio along with everything else at the start of the process. For these, your
|
||||
best bet is to write a little Javascript that puts up a "Click here to play!"
|
||||
UI, and upon the user clicking, remove that UI and then call the Emscripten
|
||||
app's main() function. As far as the application knows, the audio device was
|
||||
available to be opened as soon as the program started, and since this magic
|
||||
happens in a little Javascript, you don't have to change your C/C++ code at
|
||||
all to make it happen.
|
||||
|
||||
Please see the discussion at https://github.com/libsdl-org/SDL/issues/6385
|
||||
for some Javascript code to steal for this approach.
|
||||
|
||||
|
||||
## Rendering
|
||||
|
||||
If you use SDL's 2D render API, it will use GLES2 internally, which
|
||||
Emscripten will turn into WebGL calls. You can also use OpenGL ES 2
|
||||
directly by creating a GL context and drawing into it.
|
||||
|
||||
Calling SDL_RenderPresent (or SDL_GL_SwapWindow) will not actually
|
||||
present anything on the screen until your return from your mainloop
|
||||
function.
|
||||
|
||||
|
||||
## Building SDL/emscripten
|
||||
|
||||
First: do you _really_ need to build SDL from source?
|
||||
|
||||
If you aren't developing SDL itself, have a desire to mess with its source
|
||||
code, or need something on the bleeding edge, don't build SDL. Just use
|
||||
Emscripten's packaged version!
|
||||
|
||||
Compile and link your app with `-sUSE_SDL=2` and it'll use a build of
|
||||
SDL packaged with Emscripten. This comes from the same source code and
|
||||
fixes the Emscripten project makes to SDL are generally merged into SDL's
|
||||
revision control, so often this is much easier for app developers.
|
||||
|
||||
`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL
|
||||
1.2 instead; if you need SDL 1.2, this might be fine, but we generally
|
||||
recommend you don't use SDL 1.2 in modern times.
|
||||
|
||||
|
||||
If you want to build SDL, though...
|
||||
|
||||
SDL currently requires at least Emscripten 3.1.35 to build. Newer versions
|
||||
are likely to work, as well.
|
||||
|
||||
|
||||
Build:
|
||||
|
||||
This works on Linux/Unix and macOS. Please send comments about Windows.
|
||||
|
||||
Make sure you've [installed emsdk](https://emscripten.org/docs/getting_started/downloads.html)
|
||||
first, and run `source emsdk_env.sh` at the command line so it finds the
|
||||
tools.
|
||||
|
||||
(These configure options might be overkill, but this has worked for me.)
|
||||
|
||||
```bash
|
||||
cd SDL
|
||||
mkdir build
|
||||
cd build
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3"
|
||||
emmake make -j4
|
||||
```
|
||||
|
||||
If you want to build with thread support, something like this works:
|
||||
|
||||
```bash
|
||||
emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread"
|
||||
```
|
||||
|
||||
Or with cmake:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
emcmake cmake ..
|
||||
emmake make -j4
|
||||
```
|
||||
|
||||
To build one of the tests:
|
||||
|
||||
```bash
|
||||
cd test/
|
||||
emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html
|
||||
```
|
||||
|
||||
## Building your app
|
||||
|
||||
You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but
|
||||
mostly it uses the same command line arguments as Clang.
|
||||
|
||||
Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL,
|
||||
link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build.
|
||||
|
||||
Usually you would produce a binary like this:
|
||||
|
||||
```bash
|
||||
gcc -o mygame mygame.c # or whatever
|
||||
```
|
||||
|
||||
But for Emscripten, you want to output something else:
|
||||
|
||||
```bash
|
||||
emcc -o index.html mygame.c
|
||||
```
|
||||
|
||||
This will produce several files...support Javascript and WebAssembly (.wasm)
|
||||
files. The `-o index.html` will produce a simple HTML page that loads and
|
||||
runs your app. You will (probably) eventually want to replace or customize
|
||||
that file and do `-o index.js` instead to just build the code pieces.
|
||||
|
||||
If you're working on a program of any serious size, you'll likely need to
|
||||
link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access
|
||||
to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb`
|
||||
or the app will fail to start on iOS browsers, but this might be a bug that
|
||||
goes away in the future.
|
||||
|
||||
|
||||
## Data files
|
||||
|
||||
Your game probably has data files. Here's how to access them.
|
||||
|
||||
Filesystem access works like a Unix filesystem; you have a single directory
|
||||
tree, possibly interpolated from several mounted locations, no drive letters,
|
||||
'/' for a path separator. You can access them with standard file APIs like
|
||||
open() or fopen() or SDL_RWops. You can read or write from the filesystem.
|
||||
|
||||
By default, you probably have a "MEMFS" filesystem (all files are stored in
|
||||
memory, but access to them is immediate and doesn't need to block). There are
|
||||
other options, like "IDBFS" (files are stored in a local database, so they
|
||||
don't need to be in RAM all the time and they can persist between runs of the
|
||||
program, but access is not synchronous). You can mix and match these file
|
||||
systems, mounting a MEMFS filesystem at one place and idbfs elsewhere, etc,
|
||||
but that's beyond the scope of this document. Please refer to Emscripten's
|
||||
[page on the topic](https://emscripten.org/docs/porting/files/file_systems_overview.html)
|
||||
for more info.
|
||||
|
||||
The _easiest_ (but not the best) way to get at your data files is to embed
|
||||
them in the app itself. Emscripten's linker has support for automating this.
|
||||
|
||||
```bash
|
||||
emcc -o index.html loopwave.c --embed-file=../test/sample.wav@/sounds/sample.wav
|
||||
```
|
||||
|
||||
This will pack ../test/sample.wav in your app, and make it available at
|
||||
"/sounds/sample.wav" at runtime. Emscripten makes sure this data is available
|
||||
before your main() function runs, and since it's in MEMFS, you can just
|
||||
read it like you do on other platforms. `--embed-file` can also accept a
|
||||
directory to pack an entire tree, and you can specify the argument multiple
|
||||
times to pack unrelated things into the final installation.
|
||||
|
||||
Note that this is absolutely the best approach if you have a few small
|
||||
files to include and shouldn't worry about the issue further. However, if you
|
||||
have hundreds of megabytes and/or thousands of files, this is not so great,
|
||||
since the user will download it all every time they load your page, and it
|
||||
all has to live in memory at runtime.
|
||||
|
||||
[Emscripten's documentation on the matter](https://emscripten.org/docs/porting/files/packaging_files.html)
|
||||
gives other options and details, and is worth a read.
|
||||
|
||||
|
||||
## Debugging
|
||||
|
||||
Debugging web apps is a mixed bag. You should compile and link with
|
||||
`-gsource-map`, which embeds a ton of source-level debugging information into
|
||||
the build, and make sure _the app source code is available on the web server_,
|
||||
which is often a scary proposition for various reasons.
|
||||
|
||||
When you debug from the browser's tools and hit a breakpoint, you can step
|
||||
through the actual C/C++ source code, though, which can be nice.
|
||||
|
||||
If you try debugging in Firefox and it doesn't work well for no apparent
|
||||
reason, try Chrome, and vice-versa. These tools are still relatively new,
|
||||
and improving all the time.
|
||||
|
||||
SDL_Log() (or even plain old printf) will write to the Javascript console,
|
||||
and honestly I find printf-style debugging to be easier than setting up a build
|
||||
for proper debugging, so use whatever tools work best for you.
|
||||
|
||||
|
||||
## Questions?
|
||||
|
||||
Please give us feedback on this document at [the SDL bug tracker](https://github.com/libsdl-org/SDL/issues).
|
||||
If something is wrong or unclear, we want to know!
|
||||
|
||||
|
||||
|
||||
|
@@ -1,176 +1,176 @@
|
||||
GDK
|
||||
=====
|
||||
|
||||
This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
|
||||
|
||||
Windows (GDK) and Xbox One/Xbox Series (GDKX) are both supported and all the required code is included in this public SDL release. However, only licensed Xbox developers have access to the GDKX libraries which will allow you to build the Xbox targets.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
|
||||
* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
|
||||
* For Xbox, you will need the corresponding GDKX version (licensed developers only)
|
||||
* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work.
|
||||
|
||||
|
||||
Windows GDK Status
|
||||
------
|
||||
|
||||
The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
|
||||
|
||||
* Additionally, the GDK port adds the following:
|
||||
* Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.)
|
||||
* GDK-specific setup:
|
||||
* Initializing/uninitializing the game runtime, and initializing Xbox Live services
|
||||
* Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue.
|
||||
|
||||
* An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
|
||||
* Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
|
||||
* You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak).
|
||||
|
||||
* Single-player games have some additional features available:
|
||||
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
|
||||
* `SDL_GetPrefPath` still works, but only for single-player titles.
|
||||
|
||||
These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
|
||||
|
||||
* What doesn't work:
|
||||
* Compilation with anything other than through the included Visual C++ solution file
|
||||
|
||||
## VisualC-GDK Solution
|
||||
|
||||
The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
|
||||
|
||||
* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64.
|
||||
* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
|
||||
* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality.
|
||||
* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live.
|
||||
*NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this.
|
||||
* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality.
|
||||
|
||||
If you set one of the test programs as a startup project, you can run it directly from Visual Studio.
|
||||
|
||||
Windows GDK Setup, Detailed Steps
|
||||
---------------------
|
||||
|
||||
These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below.
|
||||
|
||||
### 1. Add a Gaming.Desktop.x64 Configuration ###
|
||||
|
||||
In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration.
|
||||
|
||||
### 2. Build SDL2 and SDL2main for GDK ###
|
||||
|
||||
Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project.
|
||||
|
||||
*Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built.
|
||||
|
||||
### 3. Configuring Project Settings ###
|
||||
|
||||
While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration:
|
||||
|
||||
* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced
|
||||
* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are
|
||||
* Under Linker > Input > Additional Dependencies, you need the following:
|
||||
* `SDL2.lib`
|
||||
* `SDL2main.lib` (unless not using)
|
||||
* `xgameruntime.lib`
|
||||
* `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib`
|
||||
* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK.
|
||||
|
||||
### 4. Setting up SDL_main ###
|
||||
|
||||
Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
|
||||
|
||||
### 5. Required DLLs ###
|
||||
|
||||
The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory:
|
||||
|
||||
* Your SDL2.dll
|
||||
* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll"
|
||||
* XCurl.dll
|
||||
|
||||
You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory.
|
||||
|
||||
### 6. Setting up MicrosoftGame.config ###
|
||||
|
||||
You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description.
|
||||
|
||||
This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type.
|
||||
|
||||
For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center.
|
||||
|
||||
Then, you need to set the following values to the values from Partner Center:
|
||||
|
||||
* Identity tag - Name and Publisher attributes
|
||||
* TitleId
|
||||
* MSAAppId
|
||||
|
||||
### 7. Adding Required Logos
|
||||
|
||||
Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file.
|
||||
|
||||
|
||||
### 8. Copying any Data Files ###
|
||||
|
||||
When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step.
|
||||
|
||||
|
||||
### 9. Build and Run from Visual Studio ###
|
||||
|
||||
At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs.
|
||||
|
||||
If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this:
|
||||
|
||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||
2. Switch the sandbox name with:
|
||||
`XblPCSandbox SANDBOX.#`
|
||||
3. (To switch back to the retail sandbox):
|
||||
`XblPCSandbox RETAIL`
|
||||
|
||||
### 10. Packaging and Installing Locally
|
||||
|
||||
You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files.
|
||||
|
||||
To create the package:
|
||||
|
||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||
2. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory)
|
||||
3. `mkdir Package` to create an output directory
|
||||
4. To package the file into the `Package` directory, use:
|
||||
`makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package`
|
||||
5. To install the package, use:
|
||||
`wdapp install PACKAGENAME.msixvc`
|
||||
6. Once the package is installed, you can run it from the start menu.
|
||||
7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
|
||||
|
||||
Xbox GDKX Setup
|
||||
---------------------
|
||||
In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
|
||||
* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
|
||||
* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
|
||||
* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
|
||||
* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox)
|
||||
* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons)
|
||||
* To create a package, use:
|
||||
`makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
|
||||
* To install the package, use:
|
||||
`xbapp install [PACKAGE].xvc`
|
||||
* For some reason, if you make changes that require SDL2.dll to build, and you are running through the debugger (instead of a package), you have to rebuild your .exe target for the debugger to recognize the dll has changed and needs to be transferred to the console again
|
||||
* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
#### Xbox Live Login does not work
|
||||
|
||||
As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values.
|
||||
|
||||
Furthermore, confirm that your PC is set to the correct sandbox.
|
||||
|
||||
|
||||
#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing
|
||||
|
||||
Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it).
|
||||
GDK
|
||||
=====
|
||||
|
||||
This port allows SDL applications to run via Microsoft's Game Development Kit (GDK).
|
||||
|
||||
Windows (GDK) and Xbox One/Xbox Series (GDKX) are both supported and all the required code is included in this public SDL release. However, only licensed Xbox developers have access to the GDKX libraries which will allow you to build the Xbox targets.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested)
|
||||
* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022))
|
||||
* For Xbox, you will need the corresponding GDKX version (licensed developers only)
|
||||
* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work.
|
||||
|
||||
|
||||
Windows GDK Status
|
||||
------
|
||||
|
||||
The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL.
|
||||
|
||||
* Additionally, the GDK port adds the following:
|
||||
* Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.)
|
||||
* GDK-specific setup:
|
||||
* Initializing/uninitializing the game runtime, and initializing Xbox Live services
|
||||
* Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue.
|
||||
|
||||
* An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
|
||||
* Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`).
|
||||
* You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak).
|
||||
|
||||
* Single-player games have some additional features available:
|
||||
* Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer.
|
||||
* `SDL_GetPrefPath` still works, but only for single-player titles.
|
||||
|
||||
These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values!
|
||||
|
||||
* What doesn't work:
|
||||
* Compilation with anything other than through the included Visual C++ solution file
|
||||
|
||||
## VisualC-GDK Solution
|
||||
|
||||
The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration:
|
||||
|
||||
* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64.
|
||||
* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs.
|
||||
* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality.
|
||||
* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live.
|
||||
*NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this.
|
||||
* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality.
|
||||
|
||||
If you set one of the test programs as a startup project, you can run it directly from Visual Studio.
|
||||
|
||||
Windows GDK Setup, Detailed Steps
|
||||
---------------------
|
||||
|
||||
These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below.
|
||||
|
||||
### 1. Add a Gaming.Desktop.x64 Configuration ###
|
||||
|
||||
In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration.
|
||||
|
||||
### 2. Build SDL2 and SDL2main for GDK ###
|
||||
|
||||
Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project.
|
||||
|
||||
*Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built.
|
||||
|
||||
### 3. Configuring Project Settings ###
|
||||
|
||||
While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration:
|
||||
|
||||
* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced
|
||||
* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are
|
||||
* Under Linker > Input > Additional Dependencies, you need the following:
|
||||
* `SDL2.lib`
|
||||
* `SDL2main.lib` (unless not using)
|
||||
* `xgameruntime.lib`
|
||||
* `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib`
|
||||
* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK.
|
||||
|
||||
### 4. Setting up SDL_main ###
|
||||
|
||||
Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters.
|
||||
|
||||
### 5. Required DLLs ###
|
||||
|
||||
The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory:
|
||||
|
||||
* Your SDL2.dll
|
||||
* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll"
|
||||
* XCurl.dll
|
||||
|
||||
You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory.
|
||||
|
||||
### 6. Setting up MicrosoftGame.config ###
|
||||
|
||||
You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description.
|
||||
|
||||
This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type.
|
||||
|
||||
For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center.
|
||||
|
||||
Then, you need to set the following values to the values from Partner Center:
|
||||
|
||||
* Identity tag - Name and Publisher attributes
|
||||
* TitleId
|
||||
* MSAAppId
|
||||
|
||||
### 7. Adding Required Logos
|
||||
|
||||
Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file.
|
||||
|
||||
|
||||
### 8. Copying any Data Files ###
|
||||
|
||||
When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step.
|
||||
|
||||
|
||||
### 9. Build and Run from Visual Studio ###
|
||||
|
||||
At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs.
|
||||
|
||||
If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this:
|
||||
|
||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||
2. Switch the sandbox name with:
|
||||
`XblPCSandbox SANDBOX.#`
|
||||
3. (To switch back to the retail sandbox):
|
||||
`XblPCSandbox RETAIL`
|
||||
|
||||
### 10. Packaging and Installing Locally
|
||||
|
||||
You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files.
|
||||
|
||||
To create the package:
|
||||
|
||||
1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu
|
||||
2. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory)
|
||||
3. `mkdir Package` to create an output directory
|
||||
4. To package the file into the `Package` directory, use:
|
||||
`makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package`
|
||||
5. To install the package, use:
|
||||
`wdapp install PACKAGENAME.msixvc`
|
||||
6. Once the package is installed, you can run it from the start menu.
|
||||
7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox.
|
||||
|
||||
Xbox GDKX Setup
|
||||
---------------------
|
||||
In general, the same process in the Windows GDK instructions work. There are just a few additional notes:
|
||||
* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target
|
||||
* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target
|
||||
* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define
|
||||
* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox)
|
||||
* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons)
|
||||
* To create a package, use:
|
||||
`makepkg pack /f PackageLayout.xml /lt /d . /pd Package`
|
||||
* To install the package, use:
|
||||
`xbapp install [PACKAGE].xvc`
|
||||
* For some reason, if you make changes that require SDL2.dll to build, and you are running through the debugger (instead of a package), you have to rebuild your .exe target for the debugger to recognize the dll has changed and needs to be transferred to the console again
|
||||
* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
#### Xbox Live Login does not work
|
||||
|
||||
As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values.
|
||||
|
||||
Furthermore, confirm that your PC is set to the correct sandbox.
|
||||
|
||||
|
||||
#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing
|
||||
|
||||
Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it).
|
||||
|
@@ -1,71 +1,71 @@
|
||||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||
|
||||
Recording:
|
||||
----------
|
||||
To begin recording on a touch device call:
|
||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||
|
||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||
|
||||
|
||||
Performing:
|
||||
-----------
|
||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||
|
||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||
|
||||
|
||||
|
||||
Saving:
|
||||
-------
|
||||
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
Both functions return the number of gestures successfully saved.
|
||||
|
||||
|
||||
Loading:
|
||||
--------
|
||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||
|
||||
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
Multi Gestures
|
||||
===========================================================================
|
||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||
|
||||
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
Dollar Gestures
|
||||
===========================================================================
|
||||
SDL provides an implementation of the $1 gesture recognition system. This allows for recording, saving, loading, and performing single stroke gestures.
|
||||
|
||||
Gestures can be performed with any number of fingers (the centroid of the fingers must follow the path of the gesture), but the number of fingers must be constant (a finger cannot go down in the middle of a gesture). The path of a gesture is considered the path from the time when the final finger went down, to the first time any finger comes up.
|
||||
|
||||
Dollar gestures are assigned an Id based on a hash function. This is guaranteed to remain constant for a given gesture. There is a (small) chance that two different gestures will be assigned the same ID. In this case, simply re-recording one of the gestures should result in a different ID.
|
||||
|
||||
Recording:
|
||||
----------
|
||||
To begin recording on a touch device call:
|
||||
SDL_RecordGesture(SDL_TouchID touchId), where touchId is the id of the touch device you wish to record on, or -1 to record on all connected devices.
|
||||
|
||||
Recording terminates as soon as a finger comes up. Recording is acknowledged by an SDL_DOLLARRECORD event.
|
||||
A SDL_DOLLARRECORD event is a dgesture with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch used to record the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the recorded gesture.
|
||||
|
||||
|
||||
Performing:
|
||||
-----------
|
||||
As long as there is a dollar gesture assigned to a touch, every finger-up event will also cause an SDL_DOLLARGESTURE event with the following fields:
|
||||
|
||||
* event.dgesture.touchId - the Id of the touch which performed the gesture.
|
||||
* event.dgesture.gestureId - the unique id of the closest gesture to the performed stroke.
|
||||
* event.dgesture.error - the difference between the gesture template and the actual performed gesture. Lower error is a better match.
|
||||
* event.dgesture.numFingers - the number of fingers used to draw the stroke.
|
||||
|
||||
Most programs will want to define an appropriate error threshold and check to be sure that the error of a gesture is not abnormally high (an indicator that no gesture was performed).
|
||||
|
||||
|
||||
|
||||
Saving:
|
||||
-------
|
||||
To save a template, call SDL_SaveDollarTemplate(gestureId, dst) where gestureId is the id of the gesture you want to save, and dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
To save all currently loaded templates, call SDL_SaveAllDollarTemplates(dst) where dst is an SDL_RWops pointer to the file where the gesture will be stored.
|
||||
|
||||
Both functions return the number of gestures successfully saved.
|
||||
|
||||
|
||||
Loading:
|
||||
--------
|
||||
To load templates from a file, call SDL_LoadDollarTemplates(touchId,src) where touchId is the id of the touch to load to (or -1 to load to all touch devices), and src is an SDL_RWops pointer to a gesture save file.
|
||||
|
||||
SDL_LoadDollarTemplates returns the number of templates successfully loaded.
|
||||
|
||||
|
||||
|
||||
===========================================================================
|
||||
Multi Gestures
|
||||
===========================================================================
|
||||
SDL provides simple support for pinch/rotate/swipe gestures.
|
||||
Every time a finger is moved an SDL_MULTIGESTURE event is sent with the following fields:
|
||||
|
||||
* event.mgesture.touchId - the Id of the touch on which the gesture was performed.
|
||||
* event.mgesture.x - the normalized x coordinate of the gesture. (0..1)
|
||||
* event.mgesture.y - the normalized y coordinate of the gesture. (0..1)
|
||||
* event.mgesture.dTheta - the amount that the fingers rotated during this motion.
|
||||
* event.mgesture.dDist - the amount that the fingers pinched during this motion.
|
||||
* event.mgesture.numFingers - the number of fingers used in the gesture.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
|
@@ -1,19 +1,19 @@
|
||||
git
|
||||
=========
|
||||
|
||||
The latest development version of SDL is available via git.
|
||||
Git allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "git" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Git website ( https://git-scm.com/ ) for more
|
||||
information on using git, where you can also download software for
|
||||
macOS, Windows, and Unix systems.
|
||||
|
||||
git clone https://github.com/libsdl-org/SDL
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the Git repository at:
|
||||
http://github.com/libsdl-org/SDL/
|
||||
|
||||
git
|
||||
=========
|
||||
|
||||
The latest development version of SDL is available via git.
|
||||
Git allows you to get up-to-the-minute fixes and enhancements;
|
||||
as a developer works on a source tree, you can use "git" to mirror that
|
||||
source tree instead of waiting for an official release. Please look
|
||||
at the Git website ( https://git-scm.com/ ) for more
|
||||
information on using git, where you can also download software for
|
||||
macOS, Windows, and Unix systems.
|
||||
|
||||
git clone https://github.com/libsdl-org/SDL
|
||||
|
||||
If you are building SDL via configure, you will need to run autogen.sh
|
||||
before running configure.
|
||||
|
||||
There is a web interface to the Git repository at:
|
||||
http://github.com/libsdl-org/SDL/
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
We are no longer hosted in Mercurial. Please see README-git.md for details.
|
||||
|
||||
Thanks!
|
||||
|
||||
We are no longer hosted in Mercurial. Please see README-git.md for details.
|
||||
|
||||
Thanks!
|
||||
|
||||
|
@@ -1,307 +1,307 @@
|
||||
iOS
|
||||
======
|
||||
|
||||
Building the Simple DirectMedia Layer for iOS 9.0+
|
||||
==============================================================================
|
||||
|
||||
Requirements: Mac OS X 10.9 or later and the iOS 9.0 or newer SDK.
|
||||
|
||||
Instructions:
|
||||
|
||||
1. Open SDL.xcodeproj (located in Xcode/SDL) in Xcode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
|
||||
Using the Simple DirectMedia Layer for iOS
|
||||
==============================================================================
|
||||
|
||||
1. Run Xcode and create a new project using the iOS Game template, selecting the Objective C language and Metal game technology.
|
||||
2. In the main view, delete all files except for Assets and LaunchScreen
|
||||
3. Right click the project in the main view, select "Add Files...", and add the SDL project, Xcode/SDL/SDL.xcodeproj
|
||||
4. Select the project in the main view, go to the "Info" tab and under "Custom iOS Target Properties" remove the line "Main storyboard file base name"
|
||||
5. Select the project in the main view, go to the "Build Settings" tab, select "All", and edit "Header Search Path" and drag over the SDL "Public Headers" folder from the left
|
||||
6. Select the project in the main view, go to the "Build Phases" tab, select "Link Binary With Libraries", and add SDL2.framework from "Framework-iOS"
|
||||
7. Select the project in the main view, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content", and select "Embed & Sign" for the SDL library.
|
||||
8. In the main view, expand SDL -> Library Source -> main -> uikit and drag SDL_uikit_main.c into your game files
|
||||
9. Add the source files that you would normally have for an SDL program, making sure to have #include "SDL.h" at the top of the file containing your main() function.
|
||||
10. Add any assets that your application needs.
|
||||
11. Enjoy!
|
||||
|
||||
|
||||
TODO: Add information regarding App Store requirements such as icons, etc.
|
||||
|
||||
|
||||
Notes -- Retina / High-DPI and window sizes
|
||||
==============================================================================
|
||||
|
||||
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
|
||||
in Apple's terminology) rather than in pixels. On iOS this means that a window
|
||||
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
|
||||
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
|
||||
size their content based on screen coordinates / points rather than pixels,
|
||||
as this allows different iOS devices to have different pixel densities
|
||||
(Retina versus non-Retina screens, etc.) without apps caring too much.
|
||||
|
||||
By default SDL will not use the full pixel density of the screen on
|
||||
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
|
||||
creating your window to enable high-dpi support.
|
||||
|
||||
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
|
||||
will still be in "screen coordinates" rather than pixels, but the window will
|
||||
have a much greater pixel density when the device supports it, and the
|
||||
SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() functions (depending on
|
||||
whether raw OpenGL or the SDL_Render API is used) can be queried to determine
|
||||
the size in pixels of the drawable screen framebuffer.
|
||||
|
||||
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
|
||||
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
|
||||
orthographic projection matrix using the size in screen coordinates
|
||||
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
||||
no matter whether a Retina device is used or not.
|
||||
|
||||
|
||||
Notes -- Application events
|
||||
==============================================================================
|
||||
|
||||
On iOS the application goes through a fixed life cycle and you will get
|
||||
notifications of state changes via application events. When these events
|
||||
are delivered you must handle them in an event callback because the OS may
|
||||
not give you any processing time after the events are delivered.
|
||||
|
||||
e.g.
|
||||
|
||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_APP_TERMINATING:
|
||||
/* Terminate the app.
|
||||
Shut everything down before returning from this function.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_LOWMEMORY:
|
||||
/* You will get this when your app is paused and iOS wants more memory.
|
||||
Release as much memory as possible.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERBACKGROUND:
|
||||
/* Prepare your app to go into the background. Stop loops, etc.
|
||||
This gets called when the user hits the home button, or gets a call.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERBACKGROUND:
|
||||
/* This will get called if the user accepted whatever sent your app to the background.
|
||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||
Your app is NOT active at this point.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERFOREGROUND:
|
||||
/* This call happens when your app is coming back to the foreground.
|
||||
Restore all your state here.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
/* Restart your loops here.
|
||||
Your app is interactive and getting CPU again.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/* No special processing, add it to the event queue */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||
|
||||
... run your main loop
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Notes -- Accelerometer as Joystick
|
||||
==============================================================================
|
||||
|
||||
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
||||
|
||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||
|
||||
|
||||
Notes -- OpenGL ES
|
||||
==============================================================================
|
||||
|
||||
Your SDL application for iOS uses OpenGL ES for video by default.
|
||||
|
||||
OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
|
||||
|
||||
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
||||
|
||||
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
|
||||
|
||||
OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
|
||||
|
||||
- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
|
||||
- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
|
||||
- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
|
||||
|
||||
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
||||
|
||||
|
||||
Notes -- Keyboard
|
||||
==============================================================================
|
||||
|
||||
The SDL keyboard API has been extended to support on-screen keyboards:
|
||||
|
||||
void SDL_StartTextInput()
|
||||
-- enables text events and reveals the onscreen keyboard.
|
||||
|
||||
void SDL_StopTextInput()
|
||||
-- disables text events and hides the onscreen keyboard.
|
||||
|
||||
SDL_bool SDL_IsTextInputActive()
|
||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||
|
||||
|
||||
Notes -- Mouse
|
||||
==============================================================================
|
||||
|
||||
iOS now supports Bluetooth mice on iPad, but by default will provide the mouse input as touch. In order for SDL to see the real mouse events, you should set the key UIApplicationSupportsIndirectInputEvents to true in your Info.plist
|
||||
|
||||
|
||||
Notes -- Reading and Writing files
|
||||
==============================================================================
|
||||
|
||||
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
||||
|
||||
Once your application is installed its directory tree looks like:
|
||||
|
||||
MySDLApp Home/
|
||||
MySDLApp.app
|
||||
Documents/
|
||||
Library/
|
||||
Preferences/
|
||||
tmp/
|
||||
|
||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||
|
||||
More information on this subject is available here:
|
||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||
|
||||
|
||||
Notes -- xcFramework
|
||||
==============================================================================
|
||||
|
||||
The SDL.xcodeproj file now includes a target to build SDL2.xcframework. An xcframework is a new (Xcode 11) uber-framework which can handle any combination of processor type and target OS platform.
|
||||
|
||||
In the past, iOS devices were always an ARM variant processor, and the simulator was always i386 or x86_64, and thus libraries could be combined into a single framework for both simulator and device. With the introduction of the Apple Silicon ARM-based machines, regular frameworks would collide as CPU type was no longer sufficient to differentiate the platform. So Apple created the new xcframework library package.
|
||||
|
||||
The xcframework target builds into a Products directory alongside the SDL.xcodeproj file, as SDL2.xcframework. This can be brought in to any iOS project and will function properly for both simulator and device, no matter their CPUs. Note that Intel Macs cannot cross-compile for Apple Silicon Macs. If you need AS compatibility, perform this build on an Apple Silicon Mac.
|
||||
|
||||
This target requires Xcode 11 or later. The target will simply fail to build if attempted on older Xcodes.
|
||||
|
||||
In addition, on Apple platforms, main() cannot be in a dynamically loaded library. This means that iOS apps which used the statically-linked libSDL2.lib and now link with the xcframwork will need to define their own main() to call SDL_UIKitRunApp(), like this:
|
||||
|
||||
#ifndef SDL_MAIN_HANDLED
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
||||
}
|
||||
#endif /* !SDL_MAIN_HANDLED */
|
||||
|
||||
Using an xcFramework is similar to using a regular framework. However, issues have been seen with the build system not seeing the headers in the xcFramework. To remedy this, add the path to the xcFramework in your app's target ==> Build Settings ==> Framework Search Paths and mark it recursive (this is critical). Also critical is to remove "*.framework" from Build Settings ==> Sub-Directories to Exclude in Recursive Searches. Clean the build folder, and on your next build the build system should be able to see any of these in your code, as expected:
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_main.h>
|
||||
|
||||
|
||||
Notes -- iPhone SDL limitations
|
||||
==============================================================================
|
||||
|
||||
Windows:
|
||||
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow() the flag SDL_WINDOW_BORDERLESS).
|
||||
|
||||
Textures:
|
||||
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
||||
|
||||
Loading Shared Objects:
|
||||
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
||||
|
||||
|
||||
Notes -- CoreBluetooth.framework
|
||||
==============================================================================
|
||||
|
||||
SDL_JOYSTICK_HIDAPI is disabled by default. It can give you access to a lot
|
||||
more game controller devices, but it requires permission from the user before
|
||||
your app will be able to talk to the Bluetooth hardware. "Made For iOS"
|
||||
branded controllers do not need this as we don't have to speak to them
|
||||
directly with raw bluetooth, so many apps can live without this.
|
||||
|
||||
You'll need to link with CoreBluetooth.framework and add something like this
|
||||
to your Info.plist:
|
||||
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
|
||||
|
||||
|
||||
Game Center
|
||||
==============================================================================
|
||||
|
||||
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||
|
||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
|
||||
|
||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||
|
||||
e.g.
|
||||
|
||||
extern "C"
|
||||
void ShowFrame(void*)
|
||||
{
|
||||
... do event handling, frame logic and rendering ...
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
... initialize game ...
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
// Initialize the Game Center for scoring and matchmaking
|
||||
InitGameCenter();
|
||||
|
||||
// Set up the game to run in the window animation callback on iOS
|
||||
// so that Game Center and so forth works correctly.
|
||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||
#else
|
||||
while ( running ) {
|
||||
ShowFrame(0);
|
||||
DelayFrame();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Deploying to older versions of iOS
|
||||
==============================================================================
|
||||
|
||||
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 8.0
|
||||
|
||||
In order to do that you need to download an older version of Xcode:
|
||||
https://developer.apple.com/download/more/?name=Xcode
|
||||
|
||||
Open the package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
|
||||
|
||||
Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
|
||||
|
||||
Open your project and set your deployment target to the desired version of iOS
|
||||
|
||||
Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
|
||||
iOS
|
||||
======
|
||||
|
||||
Building the Simple DirectMedia Layer for iOS 9.0+
|
||||
==============================================================================
|
||||
|
||||
Requirements: Mac OS X 10.9 or later and the iOS 9.0 or newer SDK.
|
||||
|
||||
Instructions:
|
||||
|
||||
1. Open SDL.xcodeproj (located in Xcode/SDL) in Xcode.
|
||||
2. Select your desired target, and hit build.
|
||||
|
||||
|
||||
Using the Simple DirectMedia Layer for iOS
|
||||
==============================================================================
|
||||
|
||||
1. Run Xcode and create a new project using the iOS Game template, selecting the Objective C language and Metal game technology.
|
||||
2. In the main view, delete all files except for Assets and LaunchScreen
|
||||
3. Right click the project in the main view, select "Add Files...", and add the SDL project, Xcode/SDL/SDL.xcodeproj
|
||||
4. Select the project in the main view, go to the "Info" tab and under "Custom iOS Target Properties" remove the line "Main storyboard file base name"
|
||||
5. Select the project in the main view, go to the "Build Settings" tab, select "All", and edit "Header Search Path" and drag over the SDL "Public Headers" folder from the left
|
||||
6. Select the project in the main view, go to the "Build Phases" tab, select "Link Binary With Libraries", and add SDL2.framework from "Framework-iOS"
|
||||
7. Select the project in the main view, go to the "General" tab, scroll down to "Frameworks, Libraries, and Embedded Content", and select "Embed & Sign" for the SDL library.
|
||||
8. In the main view, expand SDL -> Library Source -> main -> uikit and drag SDL_uikit_main.c into your game files
|
||||
9. Add the source files that you would normally have for an SDL program, making sure to have #include "SDL.h" at the top of the file containing your main() function.
|
||||
10. Add any assets that your application needs.
|
||||
11. Enjoy!
|
||||
|
||||
|
||||
TODO: Add information regarding App Store requirements such as icons, etc.
|
||||
|
||||
|
||||
Notes -- Retina / High-DPI and window sizes
|
||||
==============================================================================
|
||||
|
||||
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
|
||||
in Apple's terminology) rather than in pixels. On iOS this means that a window
|
||||
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
|
||||
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
|
||||
size their content based on screen coordinates / points rather than pixels,
|
||||
as this allows different iOS devices to have different pixel densities
|
||||
(Retina versus non-Retina screens, etc.) without apps caring too much.
|
||||
|
||||
By default SDL will not use the full pixel density of the screen on
|
||||
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
|
||||
creating your window to enable high-dpi support.
|
||||
|
||||
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
|
||||
will still be in "screen coordinates" rather than pixels, but the window will
|
||||
have a much greater pixel density when the device supports it, and the
|
||||
SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() functions (depending on
|
||||
whether raw OpenGL or the SDL_Render API is used) can be queried to determine
|
||||
the size in pixels of the drawable screen framebuffer.
|
||||
|
||||
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
|
||||
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
|
||||
orthographic projection matrix using the size in screen coordinates
|
||||
(SDL_GetWindowSize()) can be used in order to display content at the same scale
|
||||
no matter whether a Retina device is used or not.
|
||||
|
||||
|
||||
Notes -- Application events
|
||||
==============================================================================
|
||||
|
||||
On iOS the application goes through a fixed life cycle and you will get
|
||||
notifications of state changes via application events. When these events
|
||||
are delivered you must handle them in an event callback because the OS may
|
||||
not give you any processing time after the events are delivered.
|
||||
|
||||
e.g.
|
||||
|
||||
int HandleAppEvents(void *userdata, SDL_Event *event)
|
||||
{
|
||||
switch (event->type)
|
||||
{
|
||||
case SDL_APP_TERMINATING:
|
||||
/* Terminate the app.
|
||||
Shut everything down before returning from this function.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_LOWMEMORY:
|
||||
/* You will get this when your app is paused and iOS wants more memory.
|
||||
Release as much memory as possible.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERBACKGROUND:
|
||||
/* Prepare your app to go into the background. Stop loops, etc.
|
||||
This gets called when the user hits the home button, or gets a call.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERBACKGROUND:
|
||||
/* This will get called if the user accepted whatever sent your app to the background.
|
||||
If the user got a phone call and canceled it, you'll instead get an SDL_APP_DIDENTERFOREGROUND event and restart your loops.
|
||||
When you get this, you have 5 seconds to save all your state or the app will be terminated.
|
||||
Your app is NOT active at this point.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_WILLENTERFOREGROUND:
|
||||
/* This call happens when your app is coming back to the foreground.
|
||||
Restore all your state here.
|
||||
*/
|
||||
return 0;
|
||||
case SDL_APP_DIDENTERFOREGROUND:
|
||||
/* Restart your loops here.
|
||||
Your app is interactive and getting CPU again.
|
||||
*/
|
||||
return 0;
|
||||
default:
|
||||
/* No special processing, add it to the event queue */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetEventFilter(HandleAppEvents, NULL);
|
||||
|
||||
... run your main loop
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Notes -- Accelerometer as Joystick
|
||||
==============================================================================
|
||||
|
||||
SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory.
|
||||
|
||||
The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis() reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis() reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF.
|
||||
|
||||
|
||||
Notes -- OpenGL ES
|
||||
==============================================================================
|
||||
|
||||
Your SDL application for iOS uses OpenGL ES for video by default.
|
||||
|
||||
OpenGL ES for iOS supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute().
|
||||
|
||||
If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0.
|
||||
|
||||
Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 0.
|
||||
|
||||
OpenGL ES on iOS doesn't use the traditional system-framebuffer setup provided in other operating systems. Special care must be taken because of this:
|
||||
|
||||
- The drawable Renderbuffer must be bound to the GL_RENDERBUFFER binding point when SDL_GL_SwapWindow() is called.
|
||||
- The drawable Framebuffer Object must be bound while rendering to the screen and when SDL_GL_SwapWindow() is called.
|
||||
- If multisample antialiasing (MSAA) is used and glReadPixels is used on the screen, the drawable framebuffer must be resolved to the MSAA resolve framebuffer (via glBlitFramebuffer or glResolveMultisampleFramebufferAPPLE), and the MSAA resolve framebuffer must be bound to the GL_READ_FRAMEBUFFER binding point, before glReadPixels is called.
|
||||
|
||||
The above objects can be obtained via SDL_GetWindowWMInfo() (in SDL_syswm.h).
|
||||
|
||||
|
||||
Notes -- Keyboard
|
||||
==============================================================================
|
||||
|
||||
The SDL keyboard API has been extended to support on-screen keyboards:
|
||||
|
||||
void SDL_StartTextInput()
|
||||
-- enables text events and reveals the onscreen keyboard.
|
||||
|
||||
void SDL_StopTextInput()
|
||||
-- disables text events and hides the onscreen keyboard.
|
||||
|
||||
SDL_bool SDL_IsTextInputActive()
|
||||
-- returns whether or not text events are enabled (and the onscreen keyboard is visible)
|
||||
|
||||
|
||||
Notes -- Mouse
|
||||
==============================================================================
|
||||
|
||||
iOS now supports Bluetooth mice on iPad, but by default will provide the mouse input as touch. In order for SDL to see the real mouse events, you should set the key UIApplicationSupportsIndirectInputEvents to true in your Info.plist
|
||||
|
||||
|
||||
Notes -- Reading and Writing files
|
||||
==============================================================================
|
||||
|
||||
Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory.
|
||||
|
||||
Once your application is installed its directory tree looks like:
|
||||
|
||||
MySDLApp Home/
|
||||
MySDLApp.app
|
||||
Documents/
|
||||
Library/
|
||||
Preferences/
|
||||
tmp/
|
||||
|
||||
When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences".
|
||||
|
||||
More information on this subject is available here:
|
||||
http://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/Introduction/Introduction.html
|
||||
|
||||
|
||||
Notes -- xcFramework
|
||||
==============================================================================
|
||||
|
||||
The SDL.xcodeproj file now includes a target to build SDL2.xcframework. An xcframework is a new (Xcode 11) uber-framework which can handle any combination of processor type and target OS platform.
|
||||
|
||||
In the past, iOS devices were always an ARM variant processor, and the simulator was always i386 or x86_64, and thus libraries could be combined into a single framework for both simulator and device. With the introduction of the Apple Silicon ARM-based machines, regular frameworks would collide as CPU type was no longer sufficient to differentiate the platform. So Apple created the new xcframework library package.
|
||||
|
||||
The xcframework target builds into a Products directory alongside the SDL.xcodeproj file, as SDL2.xcframework. This can be brought in to any iOS project and will function properly for both simulator and device, no matter their CPUs. Note that Intel Macs cannot cross-compile for Apple Silicon Macs. If you need AS compatibility, perform this build on an Apple Silicon Mac.
|
||||
|
||||
This target requires Xcode 11 or later. The target will simply fail to build if attempted on older Xcodes.
|
||||
|
||||
In addition, on Apple platforms, main() cannot be in a dynamically loaded library. This means that iOS apps which used the statically-linked libSDL2.lib and now link with the xcframwork will need to define their own main() to call SDL_UIKitRunApp(), like this:
|
||||
|
||||
#ifndef SDL_MAIN_HANDLED
|
||||
#ifdef main
|
||||
#undef main
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
return SDL_UIKitRunApp(argc, argv, SDL_main);
|
||||
}
|
||||
#endif /* !SDL_MAIN_HANDLED */
|
||||
|
||||
Using an xcFramework is similar to using a regular framework. However, issues have been seen with the build system not seeing the headers in the xcFramework. To remedy this, add the path to the xcFramework in your app's target ==> Build Settings ==> Framework Search Paths and mark it recursive (this is critical). Also critical is to remove "*.framework" from Build Settings ==> Sub-Directories to Exclude in Recursive Searches. Clean the build folder, and on your next build the build system should be able to see any of these in your code, as expected:
|
||||
|
||||
#include "SDL_main.h"
|
||||
#include <SDL.h>
|
||||
#include <SDL_main.h>
|
||||
|
||||
|
||||
Notes -- iPhone SDL limitations
|
||||
==============================================================================
|
||||
|
||||
Windows:
|
||||
Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow() the flag SDL_WINDOW_BORDERLESS).
|
||||
|
||||
Textures:
|
||||
The optimal texture formats on iOS are SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, and SDL_PIXELFORMAT_RGB24 pixel formats.
|
||||
|
||||
Loading Shared Objects:
|
||||
This is disabled by default since it seems to break the terms of the iOS SDK agreement for iOS versions prior to iOS 8. It can be re-enabled in SDL_config_iphoneos.h.
|
||||
|
||||
|
||||
Notes -- CoreBluetooth.framework
|
||||
==============================================================================
|
||||
|
||||
SDL_JOYSTICK_HIDAPI is disabled by default. It can give you access to a lot
|
||||
more game controller devices, but it requires permission from the user before
|
||||
your app will be able to talk to the Bluetooth hardware. "Made For iOS"
|
||||
branded controllers do not need this as we don't have to speak to them
|
||||
directly with raw bluetooth, so many apps can live without this.
|
||||
|
||||
You'll need to link with CoreBluetooth.framework and add something like this
|
||||
to your Info.plist:
|
||||
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
|
||||
|
||||
|
||||
Game Center
|
||||
==============================================================================
|
||||
|
||||
Game Center integration might require that you break up your main loop in order to yield control back to the system. In other words, instead of running an endless main loop, you run each frame in a callback function, using:
|
||||
|
||||
int SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam);
|
||||
|
||||
This will set up the given function to be called back on the animation callback, and then you have to return from main() to let the Cocoa event loop run.
|
||||
|
||||
e.g.
|
||||
|
||||
extern "C"
|
||||
void ShowFrame(void*)
|
||||
{
|
||||
... do event handling, frame logic and rendering ...
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
... initialize game ...
|
||||
|
||||
#ifdef __IPHONEOS__
|
||||
// Initialize the Game Center for scoring and matchmaking
|
||||
InitGameCenter();
|
||||
|
||||
// Set up the game to run in the window animation callback on iOS
|
||||
// so that Game Center and so forth works correctly.
|
||||
SDL_iPhoneSetAnimationCallback(window, 1, ShowFrame, NULL);
|
||||
#else
|
||||
while ( running ) {
|
||||
ShowFrame(0);
|
||||
DelayFrame();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Deploying to older versions of iOS
|
||||
==============================================================================
|
||||
|
||||
SDL supports deploying to older versions of iOS than are supported by the latest version of Xcode, all the way back to iOS 8.0
|
||||
|
||||
In order to do that you need to download an older version of Xcode:
|
||||
https://developer.apple.com/download/more/?name=Xcode
|
||||
|
||||
Open the package contents of the older Xcode and your newer version of Xcode and copy over the folders in Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
|
||||
|
||||
Then open the file Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/SDKSettings.plist and add the versions of iOS you want to deploy to the key Root/DefaultProperties/DEPLOYMENT_TARGET_SUGGESTED_VALUES
|
||||
|
||||
Open your project and set your deployment target to the desired version of iOS
|
||||
|
||||
Finally, remove GameController from the list of frameworks linked by your application and edit the build settings for "Other Linker Flags" and add -weak_framework GameController
|
||||
|
@@ -1,27 +1,27 @@
|
||||
KMSDRM on *BSD
|
||||
==================================================
|
||||
|
||||
KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen.
|
||||
|
||||
WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance.
|
||||
|
||||
OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices.
|
||||
|
||||
|
||||
SDL2 WSCONS input backend features
|
||||
===================================================
|
||||
1. It is keymap-aware; it will work properly with different keymaps.
|
||||
2. It has mouse support.
|
||||
3. Accent input is supported.
|
||||
4. Compose keys are supported.
|
||||
5. AltGr and Meta Shift keys work as intended.
|
||||
|
||||
Partially working or no input on OpenBSD/NetBSD.
|
||||
==================================================
|
||||
|
||||
The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work.
|
||||
|
||||
Partially working or no input on FreeBSD.
|
||||
==================================================
|
||||
|
||||
The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices.
|
||||
KMSDRM on *BSD
|
||||
==================================================
|
||||
|
||||
KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen.
|
||||
|
||||
WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance.
|
||||
|
||||
OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices.
|
||||
|
||||
|
||||
SDL2 WSCONS input backend features
|
||||
===================================================
|
||||
1. It is keymap-aware; it will work properly with different keymaps.
|
||||
2. It has mouse support.
|
||||
3. Accent input is supported.
|
||||
4. Compose keys are supported.
|
||||
5. AltGr and Meta Shift keys work as intended.
|
||||
|
||||
Partially working or no input on OpenBSD/NetBSD.
|
||||
==================================================
|
||||
|
||||
The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work.
|
||||
|
||||
Partially working or no input on FreeBSD.
|
||||
==================================================
|
||||
|
||||
The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices.
|
||||
|
@@ -1,96 +1,96 @@
|
||||
Linux
|
||||
================================================================================
|
||||
|
||||
By default SDL will only link against glibc, the rest of the features will be
|
||||
enabled dynamically at runtime depending on the available features on the target
|
||||
system. So, for example if you built SDL with XRandR support and the target
|
||||
system does not have the XRandR libraries installed, it will be disabled
|
||||
at runtime, and you won't get a missing library error, at least with the
|
||||
default configuration parameters.
|
||||
|
||||
|
||||
Build Dependencies
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Ubuntu 18.04, all available features enabled:
|
||||
|
||||
sudo apt-get install build-essential git make autoconf automake libtool \
|
||||
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
|
||||
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
|
||||
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
|
||||
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
|
||||
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||
|
||||
Ubuntu 22.04+ can also add `libpipewire-0.3-dev libdecor-0-dev` to that command line.
|
||||
|
||||
Fedora 35, all available features enabled:
|
||||
|
||||
sudo yum install gcc git-core make cmake autoconf automake libtool \
|
||||
alsa-lib-devel pulseaudio-libs-devel nas-devel pipewire-devel \
|
||||
libX11-devel libXext-devel libXrandr-devel libXcursor-devel libXfixes-devel \
|
||||
libXi-devel libXScrnSaver-devel dbus-devel ibus-devel fcitx-devel \
|
||||
systemd-devel mesa-libGL-devel libxkbcommon-devel mesa-libGLES-devel \
|
||||
mesa-libEGL-devel vulkan-devel wayland-devel wayland-protocols-devel \
|
||||
libdrm-devel mesa-libgbm-devel libusb-devel libdecor-devel \
|
||||
libsamplerate-devel pipewire-jack-audio-connection-kit-devel \
|
||||
|
||||
NOTES:
|
||||
- This includes all the audio targets except arts and esd, because Ubuntu
|
||||
(and/or Debian) pulled their packages, but in theory SDL still supports them.
|
||||
The sndio audio target is also unavailable on Fedora.
|
||||
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
||||
for higher-quality audio resampling. SDL will work without it if the library
|
||||
is missing, so it's safe to build in support even if the end user doesn't
|
||||
have this library installed.
|
||||
- DirectFB isn't included because the configure script (currently) fails to find
|
||||
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
|
||||
configure script to include DirectFB support. Send patches. :)
|
||||
|
||||
|
||||
Joystick does not work
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
If you compiled or are using a version of SDL with udev support (and you should!)
|
||||
there's a few issues that may cause SDL to fail to detect your joystick. To
|
||||
debug this, start by installing the evtest utility. On Ubuntu/Debian:
|
||||
|
||||
sudo apt-get install evtest
|
||||
|
||||
Then run:
|
||||
|
||||
sudo evtest
|
||||
|
||||
You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
|
||||
Now run:
|
||||
|
||||
cat /dev/input/event/XX
|
||||
|
||||
If you get a permission error, you need to set a udev rule to change the mode of
|
||||
your device (see below)
|
||||
|
||||
Also, try:
|
||||
|
||||
sudo udevadm info --query=all --name=input/eventXX
|
||||
|
||||
If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
|
||||
you need to set up an udev rule to force this variable.
|
||||
|
||||
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
||||
like:
|
||||
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
You can set up similar rules for your device by changing the values listed in
|
||||
idProduct and idVendor. To obtain these values, try:
|
||||
|
||||
sudo udevadm info -a --name=input/eventXX | grep idVendor
|
||||
sudo udevadm info -a --name=input/eventXX | grep idProduct
|
||||
|
||||
If multiple values come up for each of these, the one you want is the first one of each.
|
||||
|
||||
On other systems which ship with an older udev (such as CentOS), you may need
|
||||
to set up a rule such as:
|
||||
|
||||
SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
Linux
|
||||
================================================================================
|
||||
|
||||
By default SDL will only link against glibc, the rest of the features will be
|
||||
enabled dynamically at runtime depending on the available features on the target
|
||||
system. So, for example if you built SDL with XRandR support and the target
|
||||
system does not have the XRandR libraries installed, it will be disabled
|
||||
at runtime, and you won't get a missing library error, at least with the
|
||||
default configuration parameters.
|
||||
|
||||
|
||||
Build Dependencies
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Ubuntu 18.04, all available features enabled:
|
||||
|
||||
sudo apt-get install build-essential git make autoconf automake libtool \
|
||||
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
|
||||
libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
|
||||
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
|
||||
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
|
||||
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||
|
||||
Ubuntu 22.04+ can also add `libpipewire-0.3-dev libdecor-0-dev` to that command line.
|
||||
|
||||
Fedora 35, all available features enabled:
|
||||
|
||||
sudo yum install gcc git-core make cmake autoconf automake libtool \
|
||||
alsa-lib-devel pulseaudio-libs-devel nas-devel pipewire-devel \
|
||||
libX11-devel libXext-devel libXrandr-devel libXcursor-devel libXfixes-devel \
|
||||
libXi-devel libXScrnSaver-devel dbus-devel ibus-devel fcitx-devel \
|
||||
systemd-devel mesa-libGL-devel libxkbcommon-devel mesa-libGLES-devel \
|
||||
mesa-libEGL-devel vulkan-devel wayland-devel wayland-protocols-devel \
|
||||
libdrm-devel mesa-libgbm-devel libusb-devel libdecor-devel \
|
||||
libsamplerate-devel pipewire-jack-audio-connection-kit-devel \
|
||||
|
||||
NOTES:
|
||||
- This includes all the audio targets except arts and esd, because Ubuntu
|
||||
(and/or Debian) pulled their packages, but in theory SDL still supports them.
|
||||
The sndio audio target is also unavailable on Fedora.
|
||||
- libsamplerate0-dev lets SDL optionally link to libresamplerate at runtime
|
||||
for higher-quality audio resampling. SDL will work without it if the library
|
||||
is missing, so it's safe to build in support even if the end user doesn't
|
||||
have this library installed.
|
||||
- DirectFB isn't included because the configure script (currently) fails to find
|
||||
it at all. You can do "sudo apt-get install libdirectfb-dev" and fix the
|
||||
configure script to include DirectFB support. Send patches. :)
|
||||
|
||||
|
||||
Joystick does not work
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
If you compiled or are using a version of SDL with udev support (and you should!)
|
||||
there's a few issues that may cause SDL to fail to detect your joystick. To
|
||||
debug this, start by installing the evtest utility. On Ubuntu/Debian:
|
||||
|
||||
sudo apt-get install evtest
|
||||
|
||||
Then run:
|
||||
|
||||
sudo evtest
|
||||
|
||||
You'll hopefully see your joystick listed along with a name like "/dev/input/eventXX"
|
||||
Now run:
|
||||
|
||||
cat /dev/input/event/XX
|
||||
|
||||
If you get a permission error, you need to set a udev rule to change the mode of
|
||||
your device (see below)
|
||||
|
||||
Also, try:
|
||||
|
||||
sudo udevadm info --query=all --name=input/eventXX
|
||||
|
||||
If you see a line stating ID_INPUT_JOYSTICK=1, great, if you don't see it,
|
||||
you need to set up an udev rule to force this variable.
|
||||
|
||||
A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks
|
||||
like:
|
||||
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
You can set up similar rules for your device by changing the values listed in
|
||||
idProduct and idVendor. To obtain these values, try:
|
||||
|
||||
sudo udevadm info -a --name=input/eventXX | grep idVendor
|
||||
sudo udevadm info -a --name=input/eventXX | grep idProduct
|
||||
|
||||
If multiple values come up for each of these, the one you want is the first one of each.
|
||||
|
||||
On other systems which ship with an older udev (such as CentOS), you may need
|
||||
to set up a rule such as:
|
||||
|
||||
SUBSYSTEM=="input", ENV{ID_CLASS}=="joystick", ENV{ID_INPUT_JOYSTICK}="1"
|
||||
|
||||
|
@@ -1,285 +1,285 @@
|
||||
# Mac OS X (aka macOS).
|
||||
|
||||
These instructions are for people using Apple's Mac OS X (pronounced
|
||||
"ten"), which in newer versions is just referred to as "macOS".
|
||||
|
||||
From the developer's point of view, macOS is a sort of hybrid Mac and
|
||||
Unix system, and you have the option of using either traditional
|
||||
command line tools or Apple's IDE Xcode.
|
||||
|
||||
# Command Line Build
|
||||
|
||||
To build SDL using the command line, use the standard configure and make
|
||||
process:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
CMake is also known to work, although it continues to be a work in progress:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
|
||||
You can also build SDL as a Universal library (a single binary for both
|
||||
64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh
|
||||
script.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
CC=$PWD/../build-scripts/clang-fat.sh ../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0
|
||||
ABI compatibility on ARM64 architectures. For best compatibility you
|
||||
should compile your application the same way.
|
||||
|
||||
Please note that building SDL requires at least Xcode 6 and the 10.9 SDK.
|
||||
PowerPC support for macOS has been officially dropped as of SDL 2.0.2.
|
||||
32-bit Intel and macOS 10.8 runtime support has been officially dropped as
|
||||
of SDL 2.24.0.
|
||||
|
||||
To use the library once it's built, you essential have two possibilities:
|
||||
use the traditional autoconf/automake/make method, or use Xcode.
|
||||
|
||||
|
||||
# Caveats for using SDL with Mac OS X
|
||||
|
||||
If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||
SDL will not register its own. This means that SDL will not terminate using
|
||||
SDL_Quit if it receives a termination request, it will terminate like a
|
||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||
file with the app. To solve these issues, put the following code in your
|
||||
NSApplicationDelegate implementation:
|
||||
|
||||
|
||||
```objc
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
```
|
||||
|
||||
# Using the Simple DirectMedia Layer with a traditional Makefile
|
||||
|
||||
An existing autoconf/automake build system for your SDL app has good chances
|
||||
to work almost unchanged on macOS. However, to produce a "real" Mac binary
|
||||
that you can distribute to users, you need to put the generated binary into a
|
||||
so called "bundle", which is basically a fancy folder with a name like
|
||||
"MyCoolGame.app".
|
||||
|
||||
To get this build automatically, add something like the following rule to
|
||||
your Makefile.am:
|
||||
|
||||
```make
|
||||
bundle_contents = APP_NAME.app/Contents
|
||||
APP_NAME_bundle: EXE_NAME
|
||||
mkdir -p $(bundle_contents)/MacOS
|
||||
mkdir -p $(bundle_contents)/Resources
|
||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||
```
|
||||
|
||||
You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is
|
||||
what will be visible to the user in the Finder. Usually it will be the same
|
||||
as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME`
|
||||
usually is "TestGame". You might also want to use `@PACKAGE@` to use the
|
||||
package name as specified in your configure.ac file.
|
||||
|
||||
If your project builds more than one application, you will have to do a bit
|
||||
more. For each of your target applications, you need a separate rule.
|
||||
|
||||
If you want the created bundles to be installed, you may want to add this
|
||||
rule to your Makefile.am:
|
||||
|
||||
```make
|
||||
install-exec-hook: APP_NAME_bundle
|
||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||
```
|
||||
|
||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||
into "$(DESTDIR)$(prefix)/Applications/".
|
||||
|
||||
Again, if you want to install multiple applications, you will have to augment
|
||||
the make rule accordingly.
|
||||
|
||||
But beware! That is only part of the story! With the above, you end up with
|
||||
a barebones .app bundle, which is double-clickable from the Finder. But
|
||||
there are some more things you should do before shipping your product...
|
||||
|
||||
1. The bundle right now probably is dynamically linked against SDL. That
|
||||
means that when you copy it to another computer, *it will not run*,
|
||||
unless you also install SDL on that other computer. A good solution
|
||||
for this dilemma is to static link against SDL. On OS X, you can
|
||||
achieve that by linking against the libraries listed by
|
||||
|
||||
```bash
|
||||
sdl-config --static-libs
|
||||
```
|
||||
|
||||
instead of those listed by
|
||||
|
||||
```bash
|
||||
sdl-config --libs
|
||||
```
|
||||
|
||||
Depending on how exactly SDL is integrated into your build systems, the
|
||||
way to achieve that varies, so I won't describe it here in detail
|
||||
|
||||
2. Add an 'Info.plist' to your application. That is a special XML file which
|
||||
contains some meta-information about your application (like some copyright
|
||||
information, the version of your app, the name of an optional icon file,
|
||||
and other things). Part of that information is displayed by the Finder
|
||||
when you click on the .app, or if you look at the "Get Info" window.
|
||||
More information about Info.plist files can be found on Apple's homepage.
|
||||
|
||||
|
||||
As a final remark, let me add that I use some of the techniques (and some
|
||||
variations of them) in [Exult](https://github.com/exult/exult) and
|
||||
[ScummVM](https://github.com/scummvm/scummvm); both are available in source on
|
||||
the net, so feel free to take a peek at them for inspiration!
|
||||
|
||||
|
||||
# Using the Simple DirectMedia Layer with Xcode
|
||||
|
||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||
|
||||
## First steps
|
||||
|
||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||
you should unpack the archive manually from the command line:
|
||||
|
||||
```bash
|
||||
cd [path_to_SDL_source]
|
||||
tar zxf Xcode.tar.gz
|
||||
```
|
||||
|
||||
This will create a new folder called Xcode, which you can browse
|
||||
normally from the Finder.
|
||||
|
||||
## Building the Framework
|
||||
|
||||
The SDL Library is packaged as a framework bundle, an organized
|
||||
relocatable folder hierarchy of executable code, interface headers,
|
||||
and additional resources. For practical purposes, you can think of a
|
||||
framework as a more user and system-friendly shared library, whose library
|
||||
file behaves more or less like a standard UNIX shared library.
|
||||
|
||||
To build the framework, simply open the framework project and build it.
|
||||
By default, the framework bundle "SDL.framework" is installed in
|
||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||
it to be located there. However, it will function the same in any of the
|
||||
following locations:
|
||||
|
||||
* ~/Library/Frameworks
|
||||
* /Local/Library/Frameworks
|
||||
* /System/Library/Frameworks
|
||||
|
||||
## Build Options
|
||||
|
||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||
"Development" should be used to debug SDL apps or the library itself.
|
||||
|
||||
## Building the Testers
|
||||
|
||||
Open the SDLTest project and build away!
|
||||
|
||||
## Using the Project Stationary
|
||||
|
||||
Copy the stationary to the indicated folders to access it from
|
||||
the "New Project" and "Add target" menus. What could be easier?
|
||||
|
||||
## Setting up a new project by hand
|
||||
|
||||
Some of you won't want to use the Stationary so I'll give some tips:
|
||||
|
||||
(this is accurate as of Xcode 12.5.)
|
||||
|
||||
* Click "File" -> "New" -> "Project...
|
||||
* Choose "macOS" and then "App" from the "Application" section.
|
||||
* Fill out the options in the next window. User interface is "XIB" and
|
||||
Language is "Objective-C".
|
||||
* Remove "main.m" from your project
|
||||
* Remove "MainMenu.xib" from your project
|
||||
* Remove "AppDelegates.*" from your project
|
||||
* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||
* Add "\$(HOME)/Library/Frameworks" to the frameworks search path
|
||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||
* Add your files
|
||||
* Clean and build
|
||||
|
||||
## Building from command line
|
||||
|
||||
Use `xcode-build` in the same directory as your .pbxproj file
|
||||
|
||||
## Running your app
|
||||
|
||||
You can send command line args to your app by either invoking it from
|
||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||
Executables" panel of the target settings.
|
||||
|
||||
# Implementation Notes
|
||||
|
||||
Some things that may be of interest about how it all works...
|
||||
|
||||
## Working directory
|
||||
|
||||
In SDL 1.2, the working directory of your SDL app is by default set to its
|
||||
parent, but this is no longer the case in SDL 2.0 and later. SDL2 does not
|
||||
change the working directory, which means it'll be whatever the command line
|
||||
prompt that launched the program was using, or if launched by double-clicking
|
||||
in the Finder, it will be "/", the _root of the filesystem_. Plan accordingly!
|
||||
You can use SDL_GetBasePath() to find where the program is running from and
|
||||
chdir() there directly.
|
||||
|
||||
|
||||
## You have a Cocoa App!
|
||||
|
||||
Your SDL app is essentially a Cocoa application. When your app
|
||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||
which sets up the working directory and calls your main() method.
|
||||
You are free to modify your Cocoa app with generally no consequence
|
||||
to SDL. You cannot, however, easily change the SDL window itself.
|
||||
Functionality may be added in the future to help this.
|
||||
|
||||
# Bug reports
|
||||
|
||||
Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/).
|
||||
Please feel free to report bugs there!
|
||||
|
||||
# Mac OS X (aka macOS).
|
||||
|
||||
These instructions are for people using Apple's Mac OS X (pronounced
|
||||
"ten"), which in newer versions is just referred to as "macOS".
|
||||
|
||||
From the developer's point of view, macOS is a sort of hybrid Mac and
|
||||
Unix system, and you have the option of using either traditional
|
||||
command line tools or Apple's IDE Xcode.
|
||||
|
||||
# Command Line Build
|
||||
|
||||
To build SDL using the command line, use the standard configure and make
|
||||
process:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
CMake is also known to work, although it continues to be a work in progress:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
|
||||
You can also build SDL as a Universal library (a single binary for both
|
||||
64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh
|
||||
script.
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
CC=$PWD/../build-scripts/clang-fat.sh ../configure
|
||||
make
|
||||
sudo make install
|
||||
```
|
||||
|
||||
This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0
|
||||
ABI compatibility on ARM64 architectures. For best compatibility you
|
||||
should compile your application the same way.
|
||||
|
||||
Please note that building SDL requires at least Xcode 6 and the 10.9 SDK.
|
||||
PowerPC support for macOS has been officially dropped as of SDL 2.0.2.
|
||||
32-bit Intel and macOS 10.8 runtime support has been officially dropped as
|
||||
of SDL 2.24.0.
|
||||
|
||||
To use the library once it's built, you essential have two possibilities:
|
||||
use the traditional autoconf/automake/make method, or use Xcode.
|
||||
|
||||
|
||||
# Caveats for using SDL with Mac OS X
|
||||
|
||||
If you register your own NSApplicationDelegate (using [NSApp setDelegate:]),
|
||||
SDL will not register its own. This means that SDL will not terminate using
|
||||
SDL_Quit if it receives a termination request, it will terminate like a
|
||||
normal app, and it will not send a SDL_DROPFILE when you request to open a
|
||||
file with the app. To solve these issues, put the following code in your
|
||||
NSApplicationDelegate implementation:
|
||||
|
||||
|
||||
```objc
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
|
||||
{
|
||||
if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.type = SDL_DROPFILE;
|
||||
event.drop.file = SDL_strdup([filename UTF8String]);
|
||||
return (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
```
|
||||
|
||||
# Using the Simple DirectMedia Layer with a traditional Makefile
|
||||
|
||||
An existing autoconf/automake build system for your SDL app has good chances
|
||||
to work almost unchanged on macOS. However, to produce a "real" Mac binary
|
||||
that you can distribute to users, you need to put the generated binary into a
|
||||
so called "bundle", which is basically a fancy folder with a name like
|
||||
"MyCoolGame.app".
|
||||
|
||||
To get this build automatically, add something like the following rule to
|
||||
your Makefile.am:
|
||||
|
||||
```make
|
||||
bundle_contents = APP_NAME.app/Contents
|
||||
APP_NAME_bundle: EXE_NAME
|
||||
mkdir -p $(bundle_contents)/MacOS
|
||||
mkdir -p $(bundle_contents)/Resources
|
||||
echo "APPL????" > $(bundle_contents)/PkgInfo
|
||||
$(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/
|
||||
```
|
||||
|
||||
You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is
|
||||
what will be visible to the user in the Finder. Usually it will be the same
|
||||
as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME`
|
||||
usually is "TestGame". You might also want to use `@PACKAGE@` to use the
|
||||
package name as specified in your configure.ac file.
|
||||
|
||||
If your project builds more than one application, you will have to do a bit
|
||||
more. For each of your target applications, you need a separate rule.
|
||||
|
||||
If you want the created bundles to be installed, you may want to add this
|
||||
rule to your Makefile.am:
|
||||
|
||||
```make
|
||||
install-exec-hook: APP_NAME_bundle
|
||||
rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app
|
||||
mkdir -p $(DESTDIR)$(prefix)/Applications/
|
||||
cp -r $< /$(DESTDIR)$(prefix)Applications/
|
||||
```
|
||||
|
||||
This rule takes the Bundle created by the rule from step 3 and installs them
|
||||
into "$(DESTDIR)$(prefix)/Applications/".
|
||||
|
||||
Again, if you want to install multiple applications, you will have to augment
|
||||
the make rule accordingly.
|
||||
|
||||
But beware! That is only part of the story! With the above, you end up with
|
||||
a barebones .app bundle, which is double-clickable from the Finder. But
|
||||
there are some more things you should do before shipping your product...
|
||||
|
||||
1. The bundle right now probably is dynamically linked against SDL. That
|
||||
means that when you copy it to another computer, *it will not run*,
|
||||
unless you also install SDL on that other computer. A good solution
|
||||
for this dilemma is to static link against SDL. On OS X, you can
|
||||
achieve that by linking against the libraries listed by
|
||||
|
||||
```bash
|
||||
sdl-config --static-libs
|
||||
```
|
||||
|
||||
instead of those listed by
|
||||
|
||||
```bash
|
||||
sdl-config --libs
|
||||
```
|
||||
|
||||
Depending on how exactly SDL is integrated into your build systems, the
|
||||
way to achieve that varies, so I won't describe it here in detail
|
||||
|
||||
2. Add an 'Info.plist' to your application. That is a special XML file which
|
||||
contains some meta-information about your application (like some copyright
|
||||
information, the version of your app, the name of an optional icon file,
|
||||
and other things). Part of that information is displayed by the Finder
|
||||
when you click on the .app, or if you look at the "Get Info" window.
|
||||
More information about Info.plist files can be found on Apple's homepage.
|
||||
|
||||
|
||||
As a final remark, let me add that I use some of the techniques (and some
|
||||
variations of them) in [Exult](https://github.com/exult/exult) and
|
||||
[ScummVM](https://github.com/scummvm/scummvm); both are available in source on
|
||||
the net, so feel free to take a peek at them for inspiration!
|
||||
|
||||
|
||||
# Using the Simple DirectMedia Layer with Xcode
|
||||
|
||||
These instructions are for using Apple's Xcode IDE to build SDL applications.
|
||||
|
||||
## First steps
|
||||
|
||||
The first thing to do is to unpack the Xcode.tar.gz archive in the
|
||||
top level SDL directory (where the Xcode.tar.gz archive resides).
|
||||
Because Stuffit Expander will unpack the archive into a subdirectory,
|
||||
you should unpack the archive manually from the command line:
|
||||
|
||||
```bash
|
||||
cd [path_to_SDL_source]
|
||||
tar zxf Xcode.tar.gz
|
||||
```
|
||||
|
||||
This will create a new folder called Xcode, which you can browse
|
||||
normally from the Finder.
|
||||
|
||||
## Building the Framework
|
||||
|
||||
The SDL Library is packaged as a framework bundle, an organized
|
||||
relocatable folder hierarchy of executable code, interface headers,
|
||||
and additional resources. For practical purposes, you can think of a
|
||||
framework as a more user and system-friendly shared library, whose library
|
||||
file behaves more or less like a standard UNIX shared library.
|
||||
|
||||
To build the framework, simply open the framework project and build it.
|
||||
By default, the framework bundle "SDL.framework" is installed in
|
||||
/Library/Frameworks. Therefore, the testers and project stationary expect
|
||||
it to be located there. However, it will function the same in any of the
|
||||
following locations:
|
||||
|
||||
* ~/Library/Frameworks
|
||||
* /Local/Library/Frameworks
|
||||
* /System/Library/Frameworks
|
||||
|
||||
## Build Options
|
||||
|
||||
There are two "Build Styles" (See the "Targets" tab) for SDL.
|
||||
"Deployment" should be used if you aren't tweaking the SDL library.
|
||||
"Development" should be used to debug SDL apps or the library itself.
|
||||
|
||||
## Building the Testers
|
||||
|
||||
Open the SDLTest project and build away!
|
||||
|
||||
## Using the Project Stationary
|
||||
|
||||
Copy the stationary to the indicated folders to access it from
|
||||
the "New Project" and "Add target" menus. What could be easier?
|
||||
|
||||
## Setting up a new project by hand
|
||||
|
||||
Some of you won't want to use the Stationary so I'll give some tips:
|
||||
|
||||
(this is accurate as of Xcode 12.5.)
|
||||
|
||||
* Click "File" -> "New" -> "Project...
|
||||
* Choose "macOS" and then "App" from the "Application" section.
|
||||
* Fill out the options in the next window. User interface is "XIB" and
|
||||
Language is "Objective-C".
|
||||
* Remove "main.m" from your project
|
||||
* Remove "MainMenu.xib" from your project
|
||||
* Remove "AppDelegates.*" from your project
|
||||
* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path
|
||||
* Add "\$(HOME)/Library/Frameworks" to the frameworks search path
|
||||
* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS"
|
||||
* Add your files
|
||||
* Clean and build
|
||||
|
||||
## Building from command line
|
||||
|
||||
Use `xcode-build` in the same directory as your .pbxproj file
|
||||
|
||||
## Running your app
|
||||
|
||||
You can send command line args to your app by either invoking it from
|
||||
the command line (in *.app/Contents/MacOS) or by entering them in the
|
||||
Executables" panel of the target settings.
|
||||
|
||||
# Implementation Notes
|
||||
|
||||
Some things that may be of interest about how it all works...
|
||||
|
||||
## Working directory
|
||||
|
||||
In SDL 1.2, the working directory of your SDL app is by default set to its
|
||||
parent, but this is no longer the case in SDL 2.0 and later. SDL2 does not
|
||||
change the working directory, which means it'll be whatever the command line
|
||||
prompt that launched the program was using, or if launched by double-clicking
|
||||
in the Finder, it will be "/", the _root of the filesystem_. Plan accordingly!
|
||||
You can use SDL_GetBasePath() to find where the program is running from and
|
||||
chdir() there directly.
|
||||
|
||||
|
||||
## You have a Cocoa App!
|
||||
|
||||
Your SDL app is essentially a Cocoa application. When your app
|
||||
starts up and the libraries finish loading, a Cocoa procedure is called,
|
||||
which sets up the working directory and calls your main() method.
|
||||
You are free to modify your Cocoa app with generally no consequence
|
||||
to SDL. You cannot, however, easily change the SDL window itself.
|
||||
Functionality may be added in the future to help this.
|
||||
|
||||
# Bug reports
|
||||
|
||||
Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/).
|
||||
Please feel free to report bugs there!
|
||||
|
||||
|
@@ -1,28 +1,28 @@
|
||||
# Nintendo 3DS
|
||||
|
||||
SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by:
|
||||
|
||||
- [Pierre Wendling](https://github.com/FtZPetruska)
|
||||
|
||||
Credits to:
|
||||
|
||||
- The awesome people who ported SDL to other homebrew platforms.
|
||||
- The Devkitpro team for making all the tools necessary to achieve this.
|
||||
|
||||
## Building
|
||||
|
||||
To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run:
|
||||
|
||||
```bash
|
||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Currently only software rendering is supported.
|
||||
- SDL2main should be used to ensure ROMFS is enabled.
|
||||
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
|
||||
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
|
||||
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
|
||||
# Nintendo 3DS
|
||||
|
||||
SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by:
|
||||
|
||||
- [Pierre Wendling](https://github.com/FtZPetruska)
|
||||
|
||||
Credits to:
|
||||
|
||||
- The awesome people who ported SDL to other homebrew platforms.
|
||||
- The Devkitpro team for making all the tools necessary to achieve this.
|
||||
|
||||
## Building
|
||||
|
||||
To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run:
|
||||
|
||||
```bash
|
||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- Currently only software rendering is supported.
|
||||
- SDL2main should be used to ensure ROMFS is enabled.
|
||||
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
|
||||
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
|
||||
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
|
||||
|
@@ -1,103 +1,103 @@
|
||||
Native Client
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* Native Client SDK (https://developer.chrome.com/native-client),
|
||||
(tested with Pepper version 33 or higher).
|
||||
|
||||
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
||||
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
||||
platforms. This does not mean it won't work with the other toolchains!
|
||||
|
||||
================================================================================
|
||||
Building SDL for NaCl
|
||||
================================================================================
|
||||
|
||||
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
|
||||
|
||||
configure --host=pnacl --prefix some/install/destination
|
||||
|
||||
Then "make".
|
||||
|
||||
As an example of how to create a deployable app a Makefile project is provided
|
||||
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
|
||||
provided by NaCl, without which linking properly to SDL won't work (the search
|
||||
path can't be modified externally, so the linker won't find SDL's binaries unless
|
||||
you dump them into the SDK path, which is inconvenient).
|
||||
Also provided in test/nacl is the required support file, such as index.html,
|
||||
manifest.json, etc.
|
||||
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
|
||||
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
|
||||
hiding the asynchronous nature of the browser behind the scenes...which is not the
|
||||
same as making it disappear!
|
||||
|
||||
|
||||
================================================================================
|
||||
Running tests
|
||||
================================================================================
|
||||
|
||||
Due to the nature of NaCl programs, building and running SDL tests is not as
|
||||
straightforward as one would hope. The script naclbuild.sh in build-scripts
|
||||
automates the process and should serve as a guide for users of SDL trying to build
|
||||
their own applications.
|
||||
|
||||
Basic usage:
|
||||
|
||||
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
|
||||
|
||||
This will build testgles2.c by default.
|
||||
|
||||
If you want to build a different test, for example testrendercopyex.c:
|
||||
|
||||
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
|
||||
|
||||
Once the build finishes, you have to serve the contents with a web server (the
|
||||
script will give you instructions on how to do that with Python).
|
||||
|
||||
================================================================================
|
||||
RWops and nacl_io
|
||||
================================================================================
|
||||
|
||||
SDL_RWops work transparently with nacl_io. Two functions control the mount points:
|
||||
|
||||
int mount(const char* source, const char* target,
|
||||
const char* filesystemtype,
|
||||
unsigned long mountflags, const void *data);
|
||||
int umount(const char *target);
|
||||
|
||||
For convenience, SDL will by default mount an httpfs tree at / before calling
|
||||
the app's main function. Such setting can be overridden by calling:
|
||||
|
||||
umount("/");
|
||||
|
||||
And then mounting a different filesystem at /
|
||||
|
||||
It's important to consider that the asynchronous nature of file operations on a
|
||||
browser is hidden from the application, effectively providing the developer with
|
||||
a set of blocking file operations just like you get in a regular desktop
|
||||
environment, which eases the job of porting to Native Client, but also introduces
|
||||
a set of challenges of its own, in particular when big file sizes and slow
|
||||
connections are involved.
|
||||
|
||||
For more information on how nacl_io and mount points work, see:
|
||||
|
||||
https://developer.chrome.com/native-client/devguide/coding/nacl_io
|
||||
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
|
||||
|
||||
To be able to save into the directory "/save/" (like backup of game) :
|
||||
|
||||
mount("", "/save", "html5fs", 0, "type=PERSISTENT");
|
||||
|
||||
And add to manifest.json :
|
||||
|
||||
"permissions": [
|
||||
"unlimitedStorage"
|
||||
]
|
||||
|
||||
================================================================================
|
||||
TODO - Known Issues
|
||||
================================================================================
|
||||
* Testing of all systems with a real application (something other than SDL's tests)
|
||||
* Key events don't seem to work properly
|
||||
|
||||
Native Client
|
||||
================================================================================
|
||||
|
||||
Requirements:
|
||||
|
||||
* Native Client SDK (https://developer.chrome.com/native-client),
|
||||
(tested with Pepper version 33 or higher).
|
||||
|
||||
The SDL backend for Chrome's Native Client has been tested only with the PNaCl
|
||||
toolchain, which generates binaries designed to run on ARM and x86_32/64
|
||||
platforms. This does not mean it won't work with the other toolchains!
|
||||
|
||||
================================================================================
|
||||
Building SDL for NaCl
|
||||
================================================================================
|
||||
|
||||
Set up the right environment variables (see naclbuild.sh), then configure SDL with:
|
||||
|
||||
configure --host=pnacl --prefix some/install/destination
|
||||
|
||||
Then "make".
|
||||
|
||||
As an example of how to create a deployable app a Makefile project is provided
|
||||
in test/nacl/Makefile, which includes some monkey patching of the common.mk file
|
||||
provided by NaCl, without which linking properly to SDL won't work (the search
|
||||
path can't be modified externally, so the linker won't find SDL's binaries unless
|
||||
you dump them into the SDK path, which is inconvenient).
|
||||
Also provided in test/nacl is the required support file, such as index.html,
|
||||
manifest.json, etc.
|
||||
SDL apps for NaCl run on a worker thread using the ppapi_simple infrastructure.
|
||||
This allows for blocking calls on all the relevant systems (OpenGL ES, filesystem),
|
||||
hiding the asynchronous nature of the browser behind the scenes...which is not the
|
||||
same as making it disappear!
|
||||
|
||||
|
||||
================================================================================
|
||||
Running tests
|
||||
================================================================================
|
||||
|
||||
Due to the nature of NaCl programs, building and running SDL tests is not as
|
||||
straightforward as one would hope. The script naclbuild.sh in build-scripts
|
||||
automates the process and should serve as a guide for users of SDL trying to build
|
||||
their own applications.
|
||||
|
||||
Basic usage:
|
||||
|
||||
./naclbuild.sh path/to/pepper/toolchain (i.e. ~/naclsdk/pepper_35)
|
||||
|
||||
This will build testgles2.c by default.
|
||||
|
||||
If you want to build a different test, for example testrendercopyex.c:
|
||||
|
||||
SOURCES=~/sdl/SDL/test/testrendercopyex.c ./naclbuild.sh ~/naclsdk/pepper_35
|
||||
|
||||
Once the build finishes, you have to serve the contents with a web server (the
|
||||
script will give you instructions on how to do that with Python).
|
||||
|
||||
================================================================================
|
||||
RWops and nacl_io
|
||||
================================================================================
|
||||
|
||||
SDL_RWops work transparently with nacl_io. Two functions control the mount points:
|
||||
|
||||
int mount(const char* source, const char* target,
|
||||
const char* filesystemtype,
|
||||
unsigned long mountflags, const void *data);
|
||||
int umount(const char *target);
|
||||
|
||||
For convenience, SDL will by default mount an httpfs tree at / before calling
|
||||
the app's main function. Such setting can be overridden by calling:
|
||||
|
||||
umount("/");
|
||||
|
||||
And then mounting a different filesystem at /
|
||||
|
||||
It's important to consider that the asynchronous nature of file operations on a
|
||||
browser is hidden from the application, effectively providing the developer with
|
||||
a set of blocking file operations just like you get in a regular desktop
|
||||
environment, which eases the job of porting to Native Client, but also introduces
|
||||
a set of challenges of its own, in particular when big file sizes and slow
|
||||
connections are involved.
|
||||
|
||||
For more information on how nacl_io and mount points work, see:
|
||||
|
||||
https://developer.chrome.com/native-client/devguide/coding/nacl_io
|
||||
https://src.chromium.org/chrome/trunk/src/native_client_sdk/src/libraries/nacl_io/nacl_io.h
|
||||
|
||||
To be able to save into the directory "/save/" (like backup of game) :
|
||||
|
||||
mount("", "/save", "html5fs", 0, "type=PERSISTENT");
|
||||
|
||||
And add to manifest.json :
|
||||
|
||||
"permissions": [
|
||||
"unlimitedStorage"
|
||||
]
|
||||
|
||||
================================================================================
|
||||
TODO - Known Issues
|
||||
================================================================================
|
||||
* Testing of all systems with a real application (something other than SDL's tests)
|
||||
* Key events don't seem to work properly
|
||||
|
||||
|
@@ -1,44 +1,44 @@
|
||||
Nokia N-Gage
|
||||
============
|
||||
|
||||
SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage
|
||||
(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev).
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project.
|
||||
The library is included in the
|
||||
[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a
|
||||
sub-module.
|
||||
|
||||
A complete example project based on SDL2 can be found in the GitHub
|
||||
account of the SDK: [Wordle](https://github.com/ngagesdk/wordle).
|
||||
|
||||
Current level of implementation
|
||||
-------------------------------
|
||||
|
||||
The video driver currently provides full screen video support with
|
||||
keyboard input.
|
||||
|
||||
At the moment only the software renderer works.
|
||||
|
||||
Audio is not yet implemented.
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the
|
||||
valuable insight into Symbian programming. Without the SDL 1.2 port
|
||||
which was specially developed for CDoom (Doom for the Nokia 9210), this
|
||||
adaptation would not have been possible.
|
||||
|
||||
I would like to thank my friends
|
||||
[Razvan](https://twitter.com/bewarerazvan) and [Dan
|
||||
Whelan](https://danwhelan.ie/), for their continuous support. Without
|
||||
you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would
|
||||
have lost my patience long ago.
|
||||
|
||||
Last but not least, I would like to thank the development team of
|
||||
[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your
|
||||
patience and support in troubleshooting helped me a lot.
|
||||
Nokia N-Gage
|
||||
============
|
||||
|
||||
SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage
|
||||
(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev).
|
||||
|
||||
Compiling
|
||||
---------
|
||||
|
||||
SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project.
|
||||
The library is included in the
|
||||
[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a
|
||||
sub-module.
|
||||
|
||||
A complete example project based on SDL2 can be found in the GitHub
|
||||
account of the SDK: [Wordle](https://github.com/ngagesdk/wordle).
|
||||
|
||||
Current level of implementation
|
||||
-------------------------------
|
||||
|
||||
The video driver currently provides full screen video support with
|
||||
keyboard input.
|
||||
|
||||
At the moment only the software renderer works.
|
||||
|
||||
Audio is not yet implemented.
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the
|
||||
valuable insight into Symbian programming. Without the SDL 1.2 port
|
||||
which was specially developed for CDoom (Doom for the Nokia 9210), this
|
||||
adaptation would not have been possible.
|
||||
|
||||
I would like to thank my friends
|
||||
[Razvan](https://twitter.com/bewarerazvan) and [Dan
|
||||
Whelan](https://danwhelan.ie/), for their continuous support. Without
|
||||
you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would
|
||||
have lost my patience long ago.
|
||||
|
||||
Last but not least, I would like to thank the development team of
|
||||
[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your
|
||||
patience and support in troubleshooting helped me a lot.
|
||||
|
@@ -1,92 +1,92 @@
|
||||
Simple DirectMedia Layer 2 for OS/2 & eComStation
|
||||
================================================================================
|
||||
SDL port for OS/2, authored by Andrey Vasilkin <digi@os2.snc.ru>, 2016
|
||||
|
||||
|
||||
OpenGL not supported by this port.
|
||||
|
||||
Additional optional environment variables:
|
||||
|
||||
SDL_AUDIO_SHARE
|
||||
Values: 0 or 1, default is 0
|
||||
Initializes the device as shareable or exclusively acquired.
|
||||
|
||||
SDL_VIDEODRIVER
|
||||
Values: DIVE or VMAN, default is DIVE
|
||||
Use video subsystem: Direct interface video extensions (DIVE) or
|
||||
Video Manager (VMAN).
|
||||
|
||||
You may significantly increase video output speed with OS4 kernel and patched
|
||||
files vman.dll and dive.dll or with latest versions of ACPI support and video
|
||||
driver Panorama.
|
||||
|
||||
Latest versions of OS/4 kernel:
|
||||
http://gus.biysk.ru/os4/
|
||||
(Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4)
|
||||
|
||||
Patched files vman.dll and dive.dll:
|
||||
http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see:
|
||||
https://github.com/open-watcom/ and https://open-watcom.github.io
|
||||
WATCOM environment variable must to be set to the Open Watcom install
|
||||
directory. To compile, run: wmake -f Makefile.os2
|
||||
|
||||
|
||||
Installing:
|
||||
-----------
|
||||
|
||||
- eComStation:
|
||||
|
||||
If you have previously installed SDL2, make a Backup copy of SDL2.dll
|
||||
located in D:\ecs\dll (where D: is disk on which installed eComStation).
|
||||
Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll
|
||||
|
||||
- OS/2:
|
||||
|
||||
Copy SDL2.dll to any directory on your LIBPATH. If you have a previous
|
||||
version installed, close all SDL2 applications before replacing the old
|
||||
copy. Also make sure that any other older versions of DLLs are removed
|
||||
from your system.
|
||||
|
||||
|
||||
Joysticks in SDL2:
|
||||
------------------
|
||||
|
||||
The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version.
|
||||
Here is the original documentation from SDL-1.2:
|
||||
|
||||
The Joystick detection only works for standard joysticks (2 buttons, 2 axes
|
||||
and the like). Therefore, if you use a non-standard joystick, you should
|
||||
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
|
||||
file or CONFIG.SYS, so SDL applications can provide full capability to your
|
||||
device. The syntax is:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
|
||||
|
||||
So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
|
||||
the line should be:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
|
||||
|
||||
If you want to add spaces in your joystick name, just surround it with
|
||||
quotes or double-quotes:
|
||||
|
||||
SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
|
||||
|
||||
or
|
||||
|
||||
SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
|
||||
|
||||
Note however that Balls and Hats are not supported under OS/2, and the
|
||||
value will be ignored... but it is wise to define these correctly because
|
||||
in the future those can be supported.
|
||||
|
||||
Also the number of buttons is limited to 2 when using two joysticks,
|
||||
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
|
||||
and 8 when using a joystick with 2 axes. Notice however these are limitations
|
||||
of the Joystick Port hardware, not OS/2.
|
||||
Simple DirectMedia Layer 2 for OS/2 & eComStation
|
||||
================================================================================
|
||||
SDL port for OS/2, authored by Andrey Vasilkin <digi@os2.snc.ru>, 2016
|
||||
|
||||
|
||||
OpenGL not supported by this port.
|
||||
|
||||
Additional optional environment variables:
|
||||
|
||||
SDL_AUDIO_SHARE
|
||||
Values: 0 or 1, default is 0
|
||||
Initializes the device as shareable or exclusively acquired.
|
||||
|
||||
SDL_VIDEODRIVER
|
||||
Values: DIVE or VMAN, default is DIVE
|
||||
Use video subsystem: Direct interface video extensions (DIVE) or
|
||||
Video Manager (VMAN).
|
||||
|
||||
You may significantly increase video output speed with OS4 kernel and patched
|
||||
files vman.dll and dive.dll or with latest versions of ACPI support and video
|
||||
driver Panorama.
|
||||
|
||||
Latest versions of OS/4 kernel:
|
||||
http://gus.biysk.ru/os4/
|
||||
(Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4)
|
||||
|
||||
Patched files vman.dll and dive.dll:
|
||||
http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see:
|
||||
https://github.com/open-watcom/ and https://open-watcom.github.io
|
||||
WATCOM environment variable must to be set to the Open Watcom install
|
||||
directory. To compile, run: wmake -f Makefile.os2
|
||||
|
||||
|
||||
Installing:
|
||||
-----------
|
||||
|
||||
- eComStation:
|
||||
|
||||
If you have previously installed SDL2, make a Backup copy of SDL2.dll
|
||||
located in D:\ecs\dll (where D: is disk on which installed eComStation).
|
||||
Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll
|
||||
|
||||
- OS/2:
|
||||
|
||||
Copy SDL2.dll to any directory on your LIBPATH. If you have a previous
|
||||
version installed, close all SDL2 applications before replacing the old
|
||||
copy. Also make sure that any other older versions of DLLs are removed
|
||||
from your system.
|
||||
|
||||
|
||||
Joysticks in SDL2:
|
||||
------------------
|
||||
|
||||
The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version.
|
||||
Here is the original documentation from SDL-1.2:
|
||||
|
||||
The Joystick detection only works for standard joysticks (2 buttons, 2 axes
|
||||
and the like). Therefore, if you use a non-standard joystick, you should
|
||||
specify its features in the SDL_OS2_JOYSTICK environment variable in a batch
|
||||
file or CONFIG.SYS, so SDL applications can provide full capability to your
|
||||
device. The syntax is:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS]
|
||||
|
||||
So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls,
|
||||
the line should be:
|
||||
|
||||
SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0
|
||||
|
||||
If you want to add spaces in your joystick name, just surround it with
|
||||
quotes or double-quotes:
|
||||
|
||||
SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0
|
||||
|
||||
or
|
||||
|
||||
SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0
|
||||
|
||||
Note however that Balls and Hats are not supported under OS/2, and the
|
||||
value will be ignored... but it is wise to define these correctly because
|
||||
in the future those can be supported.
|
||||
|
||||
Also the number of buttons is limited to 2 when using two joysticks,
|
||||
4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes
|
||||
and 8 when using a joystick with 2 axes. Notice however these are limitations
|
||||
of the Joystick Port hardware, not OS/2.
|
||||
|
@@ -1,17 +1,17 @@
|
||||
Pandora
|
||||
=====================================================================
|
||||
|
||||
( http://openpandora.org/ )
|
||||
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
||||
support to work on the pandora under the framebuffer. This driver do not have
|
||||
input support for now, so if you use it you will have to add your own control code.
|
||||
The video driver name is "pandora" so if you have problem running it from
|
||||
the framebuffer, try to set the following variable before starting your application :
|
||||
"export SDL_VIDEODRIVER=pandora"
|
||||
|
||||
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
||||
x11 driver one with OpenGLX support, with SDL input event's etc..
|
||||
|
||||
|
||||
David Carré (Cpasjuste)
|
||||
cpasjuste@gmail.com
|
||||
Pandora
|
||||
=====================================================================
|
||||
|
||||
( http://openpandora.org/ )
|
||||
- A pandora specific video driver was written to allow SDL 2.0 with OpenGL ES
|
||||
support to work on the pandora under the framebuffer. This driver do not have
|
||||
input support for now, so if you use it you will have to add your own control code.
|
||||
The video driver name is "pandora" so if you have problem running it from
|
||||
the framebuffer, try to set the following variable before starting your application :
|
||||
"export SDL_VIDEODRIVER=pandora"
|
||||
|
||||
- OpenGL ES support was added to the x11 driver, so it's working like the normal
|
||||
x11 driver one with OpenGLX support, with SDL input event's etc..
|
||||
|
||||
|
||||
David Carré (Cpasjuste)
|
||||
cpasjuste@gmail.com
|
||||
|
@@ -1,8 +1,8 @@
|
||||
Platforms
|
||||
=========
|
||||
|
||||
We maintain the list of supported platforms on our wiki now, and how to
|
||||
build and install SDL for those platforms:
|
||||
|
||||
https://wiki.libsdl.org/Installation
|
||||
|
||||
Platforms
|
||||
=========
|
||||
|
||||
We maintain the list of supported platforms on our wiki now, and how to
|
||||
build and install SDL for those platforms:
|
||||
|
||||
https://wiki.libsdl.org/Installation
|
||||
|
||||
|
@@ -1,68 +1,68 @@
|
||||
Porting
|
||||
=======
|
||||
|
||||
* Porting To A New Platform
|
||||
|
||||
The first thing you have to do when porting to a new platform, is look at
|
||||
include/SDL_platform.h and create an entry there for your operating system.
|
||||
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
|
||||
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
||||
on based on C preprocessor symbols.
|
||||
|
||||
There are two basic ways of building SDL at the moment:
|
||||
|
||||
1. The "UNIX" way: ./configure; make; make install
|
||||
|
||||
If you have a GNUish system, then you might try this. Edit configure.ac,
|
||||
take a look at the large section labelled:
|
||||
|
||||
"Set up the configuration based on the host platform!"
|
||||
|
||||
Add a section for your platform, and then re-run autogen.sh and build!
|
||||
|
||||
2. Using an IDE:
|
||||
|
||||
If you're using an IDE or other non-configure build system, you'll probably
|
||||
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
||||
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
||||
based on SDL_config_minimal.h and SDL_config.h.in
|
||||
|
||||
Add the top level include directory to the header search path, and then add
|
||||
the following sources to the project:
|
||||
|
||||
src/*.c
|
||||
src/atomic/*.c
|
||||
src/audio/*.c
|
||||
src/cpuinfo/*.c
|
||||
src/events/*.c
|
||||
src/file/*.c
|
||||
src/haptic/*.c
|
||||
src/joystick/*.c
|
||||
src/power/*.c
|
||||
src/render/*.c
|
||||
src/render/software/*.c
|
||||
src/stdlib/*.c
|
||||
src/thread/*.c
|
||||
src/timer/*.c
|
||||
src/video/*.c
|
||||
src/audio/disk/*.c
|
||||
src/audio/dummy/*.c
|
||||
src/filesystem/dummy/*.c
|
||||
src/video/dummy/*.c
|
||||
src/haptic/dummy/*.c
|
||||
src/joystick/dummy/*.c
|
||||
src/main/dummy/*.c
|
||||
src/thread/generic/*.c
|
||||
src/timer/dummy/*.c
|
||||
src/loadso/dummy/*.c
|
||||
|
||||
|
||||
Once you have a working library without any drivers, you can go back to each
|
||||
of the major subsystems and start implementing drivers for your platform.
|
||||
|
||||
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
||||
Porting
|
||||
=======
|
||||
|
||||
* Porting To A New Platform
|
||||
|
||||
The first thing you have to do when porting to a new platform, is look at
|
||||
include/SDL_platform.h and create an entry there for your operating system.
|
||||
The standard format is "__PLATFORM__", where PLATFORM is the name of the OS.
|
||||
Ideally SDL_platform.h will be able to auto-detect the system it's building
|
||||
on based on C preprocessor symbols.
|
||||
|
||||
There are two basic ways of building SDL at the moment:
|
||||
|
||||
1. The "UNIX" way: ./configure; make; make install
|
||||
|
||||
If you have a GNUish system, then you might try this. Edit configure.ac,
|
||||
take a look at the large section labelled:
|
||||
|
||||
"Set up the configuration based on the host platform!"
|
||||
|
||||
Add a section for your platform, and then re-run autogen.sh and build!
|
||||
|
||||
2. Using an IDE:
|
||||
|
||||
If you're using an IDE or other non-configure build system, you'll probably
|
||||
want to create a custom SDL_config.h for your platform. Edit SDL_config.h,
|
||||
add a section for your platform, and create a custom SDL_config_{platform}.h,
|
||||
based on SDL_config_minimal.h and SDL_config.h.in
|
||||
|
||||
Add the top level include directory to the header search path, and then add
|
||||
the following sources to the project:
|
||||
|
||||
src/*.c
|
||||
src/atomic/*.c
|
||||
src/audio/*.c
|
||||
src/cpuinfo/*.c
|
||||
src/events/*.c
|
||||
src/file/*.c
|
||||
src/haptic/*.c
|
||||
src/joystick/*.c
|
||||
src/power/*.c
|
||||
src/render/*.c
|
||||
src/render/software/*.c
|
||||
src/stdlib/*.c
|
||||
src/thread/*.c
|
||||
src/timer/*.c
|
||||
src/video/*.c
|
||||
src/audio/disk/*.c
|
||||
src/audio/dummy/*.c
|
||||
src/filesystem/dummy/*.c
|
||||
src/video/dummy/*.c
|
||||
src/haptic/dummy/*.c
|
||||
src/joystick/dummy/*.c
|
||||
src/main/dummy/*.c
|
||||
src/thread/generic/*.c
|
||||
src/timer/dummy/*.c
|
||||
src/loadso/dummy/*.c
|
||||
|
||||
|
||||
Once you have a working library without any drivers, you can go back to each
|
||||
of the major subsystems and start implementing drivers for your platform.
|
||||
|
||||
If you have any questions, don't hesitate to ask on the SDL mailing list:
|
||||
http://www.libsdl.org/mailing-list.php
|
||||
|
||||
Enjoy!
|
||||
Sam Lantinga (slouken@libsdl.org)
|
||||
|
||||
|
@@ -1,51 +1,51 @@
|
||||
PS2
|
||||
======
|
||||
SDL2 port for the Sony Playstation 2 contributed by:
|
||||
- Francisco Javier Trujillo Mata
|
||||
|
||||
|
||||
Credit to
|
||||
- The guys that ported SDL to PSP & Vita because I'm taking them as reference.
|
||||
- David G. F. for helping me with several issues and tests.
|
||||
|
||||
## 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 --build build
|
||||
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.
|
||||
|
||||
## 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.
|
||||
So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
|
||||
It could be something similar as:
|
||||
```c
|
||||
.....
|
||||
|
||||
SDL_PS2_SKIP_IOP_RESET();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
.....
|
||||
```
|
||||
For a release binary is recommendable to reset the IOP always.
|
||||
|
||||
Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected.
|
||||
|
||||
## Getting PS2 Dev
|
||||
[Installing PS2 Dev](https://github.com/ps2dev/ps2dev)
|
||||
|
||||
## Running on PCSX2 Emulator
|
||||
[PCSX2](https://github.com/PCSX2/pcsx2)
|
||||
|
||||
[More PCSX2 information](https://pcsx2.net/)
|
||||
|
||||
## To Do
|
||||
- PS2 Screen Keyboard
|
||||
- Dialogs
|
||||
- Others
|
||||
PS2
|
||||
======
|
||||
SDL2 port for the Sony Playstation 2 contributed by:
|
||||
- Francisco Javier Trujillo Mata
|
||||
|
||||
|
||||
Credit to
|
||||
- The guys that ported SDL to PSP & Vita because I'm taking them as reference.
|
||||
- David G. F. for helping me with several issues and tests.
|
||||
|
||||
## 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 --build build
|
||||
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.
|
||||
|
||||
## 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.
|
||||
So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
|
||||
It could be something similar as:
|
||||
```c
|
||||
.....
|
||||
|
||||
SDL_PS2_SKIP_IOP_RESET();
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
.....
|
||||
```
|
||||
For a release binary is recommendable to reset the IOP always.
|
||||
|
||||
Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected.
|
||||
|
||||
## Getting PS2 Dev
|
||||
[Installing PS2 Dev](https://github.com/ps2dev/ps2dev)
|
||||
|
||||
## Running on PCSX2 Emulator
|
||||
[PCSX2](https://github.com/PCSX2/pcsx2)
|
||||
|
||||
[More PCSX2 information](https://pcsx2.net/)
|
||||
|
||||
## To Do
|
||||
- PS2 Screen Keyboard
|
||||
- Dialogs
|
||||
- Others
|
||||
|
@@ -1,36 +1,36 @@
|
||||
PSP
|
||||
======
|
||||
SDL2 port for the Sony PSP contributed by:
|
||||
- Captian Lex
|
||||
- Francisco Javier Trujillo Mata
|
||||
- Wouter Wijsman
|
||||
|
||||
|
||||
Credit to
|
||||
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
||||
Geecko for his PSP GU lib "Glib2d"
|
||||
|
||||
## Building
|
||||
To build SDL2 library for the PSP, make sure you have the latest PSPDev status and run:
|
||||
```bash
|
||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
|
||||
## Getting PSP Dev
|
||||
[Installing PSP Dev](https://github.com/pspdev/pspdev)
|
||||
|
||||
## Running on PPSSPP Emulator
|
||||
[PPSSPP](https://github.com/hrydgard/ppsspp)
|
||||
|
||||
[Build Instructions](https://github.com/hrydgard/ppsspp/wiki/Build-instructions)
|
||||
|
||||
|
||||
## Compiling a HelloWorld
|
||||
[PSP Hello World](https://pspdev.github.io/basic_programs.html#hello-world)
|
||||
|
||||
## To Do
|
||||
- PSP Screen Keyboard
|
||||
- Dialogs
|
||||
PSP
|
||||
======
|
||||
SDL2 port for the Sony PSP contributed by:
|
||||
- Captian Lex
|
||||
- Francisco Javier Trujillo Mata
|
||||
- Wouter Wijsman
|
||||
|
||||
|
||||
Credit to
|
||||
Marcus R.Brown,Jim Paris,Matthew H for the original SDL 1.2 for PSP
|
||||
Geecko for his PSP GU lib "Glib2d"
|
||||
|
||||
## Building
|
||||
To build SDL2 library for the PSP, make sure you have the latest PSPDev status and run:
|
||||
```bash
|
||||
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PSPDEV/psp/share/pspdev.cmake
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
|
||||
## Getting PSP Dev
|
||||
[Installing PSP Dev](https://github.com/pspdev/pspdev)
|
||||
|
||||
## Running on PPSSPP Emulator
|
||||
[PPSSPP](https://github.com/hrydgard/ppsspp)
|
||||
|
||||
[Build Instructions](https://github.com/hrydgard/ppsspp/wiki/Build-instructions)
|
||||
|
||||
|
||||
## Compiling a HelloWorld
|
||||
[PSP Hello World](https://psp-dev.org/doku.php?id=tutorial:hello_world)
|
||||
|
||||
## To Do
|
||||
- PSP Screen Keyboard
|
||||
- Dialogs
|
||||
|
@@ -1,180 +1,180 @@
|
||||
Raspberry Pi
|
||||
============
|
||||
|
||||
Requirements:
|
||||
|
||||
Raspbian (other Linux distros may work as well).
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Works without X11
|
||||
* Hardware accelerated OpenGL ES 2.x
|
||||
* Sound via ALSA
|
||||
* Input (mouse/keyboard/joystick) via EVDEV
|
||||
* Hotplugging of input devices via UDEV
|
||||
|
||||
|
||||
Raspbian Build Dependencies
|
||||
---------------------------
|
||||
|
||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||
|
||||
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
||||
OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
||||
|
||||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||
|
||||
|
||||
NEON
|
||||
----
|
||||
|
||||
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
||||
that SDL will select some otherwise-disabled highly-optimized code. The
|
||||
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
||||
definitely does.
|
||||
|
||||
|
||||
Cross compiling from x86 Linux
|
||||
------------------------------
|
||||
|
||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||
will be placed in /opt/rpi-tools
|
||||
|
||||
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
||||
|
||||
You'll also need a Raspbian binary image.
|
||||
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
||||
After unzipping, you'll get file with a name like: "<date>-wheezy-raspbian.img"
|
||||
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
||||
|
||||
export SYSROOT=/opt/rpi-sysroot
|
||||
sudo kpartx -a -v <path_to_raspbian_image>.img
|
||||
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
||||
sudo cp -r /mnt $SYSROOT
|
||||
sudo apt-get install qemu binfmt-support qemu-user-static
|
||||
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
||||
sudo mount --bind /dev $SYSROOT/dev
|
||||
sudo mount --bind /proc $SYSROOT/proc
|
||||
sudo mount --bind /sys $SYSROOT/sys
|
||||
|
||||
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
||||
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
||||
|
||||
sudo chroot $SYSROOT
|
||||
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev
|
||||
exit
|
||||
sudo umount $SYSROOT/dev
|
||||
sudo umount $SYSROOT/proc
|
||||
sudo umount $SYSROOT/sys
|
||||
sudo umount /mnt
|
||||
|
||||
There's one more fix required, as the libdl.so symlink uses an absolute path
|
||||
which doesn't quite work in our setup.
|
||||
|
||||
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
|
||||
The final step is compiling SDL itself.
|
||||
|
||||
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
||||
cd <SDL SOURCE>
|
||||
mkdir -p build;cd build
|
||||
LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
||||
make
|
||||
make install
|
||||
|
||||
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
||||
|
||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||
|
||||
Apps don't work or poor video/audio performance
|
||||
-----------------------------------------------
|
||||
|
||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||
will also render the CMA - Dynamic Memory Split functionality useless.
|
||||
|
||||
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
||||
low in general, specially if a 1080p TV is hooked up.
|
||||
|
||||
See here how to configure this setting: http://elinux.org/RPiconfig
|
||||
|
||||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||
firmware, using CMA probably won't work, at least it's the current case).
|
||||
|
||||
No input
|
||||
--------
|
||||
|
||||
Make sure you belong to the "input" group.
|
||||
|
||||
sudo usermod -aG input `whoami`
|
||||
|
||||
No HDMI Audio
|
||||
-------------
|
||||
|
||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||
|
||||
hdmi_drive=2
|
||||
|
||||
to your config.txt file and reboot.
|
||||
|
||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||
|
||||
Text Input API support
|
||||
----------------------
|
||||
|
||||
The Text Input API is supported, with translation of scan codes done via the
|
||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||
If you notice there's no SDL_TEXTINPUT message being emitted, double check that
|
||||
your app has read access to one of the following:
|
||||
|
||||
* /proc/self/fd/0
|
||||
* /dev/tty
|
||||
* /dev/tty[0...6]
|
||||
* /dev/vc/0
|
||||
* /dev/console
|
||||
|
||||
This is usually not a problem if you run from the physical terminal (as opposed
|
||||
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
||||
quick workaround is to run your app as root or add yourself to the tty group,
|
||||
then re-login to the system.
|
||||
|
||||
sudo usermod -aG tty `whoami`
|
||||
|
||||
The keyboard layout used by SDL is the same as the one the kernel uses.
|
||||
To configure the layout on Raspbian:
|
||||
|
||||
sudo dpkg-reconfigure keyboard-configuration
|
||||
|
||||
To configure the locale, which controls which keys are interpreted as letters,
|
||||
this determining the CAPS LOCK behavior:
|
||||
|
||||
sudo dpkg-reconfigure locales
|
||||
|
||||
|
||||
OpenGL problems
|
||||
---------------
|
||||
|
||||
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
||||
compilation environment, support for it will be built in. However, the chipset
|
||||
does not actually have support for it, which causes issues in certain SDL apps
|
||||
since the presence of OpenGL support supersedes the ES/ES2 variants.
|
||||
The workaround is to disable OpenGL at configuration time:
|
||||
|
||||
./configure --disable-video-opengl
|
||||
|
||||
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
|
||||
environment variable:
|
||||
|
||||
export SDL_RENDER_DRIVER=opengles2
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||
leaking into the console only if it has root privileges. Launching apps locally
|
||||
does not suffer from this issue.
|
||||
|
||||
|
||||
Raspberry Pi
|
||||
============
|
||||
|
||||
Requirements:
|
||||
|
||||
Raspbian (other Linux distros may work as well).
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Works without X11
|
||||
* Hardware accelerated OpenGL ES 2.x
|
||||
* Sound via ALSA
|
||||
* Input (mouse/keyboard/joystick) via EVDEV
|
||||
* Hotplugging of input devices via UDEV
|
||||
|
||||
|
||||
Raspbian Build Dependencies
|
||||
---------------------------
|
||||
|
||||
sudo apt-get install libudev-dev libasound2-dev libdbus-1-dev
|
||||
|
||||
You also need the VideoCore binary stuff that ships in /opt/vc for EGL and
|
||||
OpenGL ES 2.x, it usually comes pre-installed, but in any case:
|
||||
|
||||
sudo apt-get install libraspberrypi0 libraspberrypi-bin libraspberrypi-dev
|
||||
|
||||
|
||||
NEON
|
||||
----
|
||||
|
||||
If your Pi has NEON support, make sure you add -mfpu=neon to your CFLAGS so
|
||||
that SDL will select some otherwise-disabled highly-optimized code. The
|
||||
original Pi units don't have NEON, the Pi2 probably does, and the Pi3
|
||||
definitely does.
|
||||
|
||||
|
||||
Cross compiling from x86 Linux
|
||||
------------------------------
|
||||
|
||||
To cross compile SDL for Raspbian from your desktop machine, you'll need a
|
||||
Raspbian system root and the cross compilation tools. We'll assume these tools
|
||||
will be placed in /opt/rpi-tools
|
||||
|
||||
sudo git clone --depth 1 https://github.com/raspberrypi/tools /opt/rpi-tools
|
||||
|
||||
You'll also need a Raspbian binary image.
|
||||
Get it from: http://downloads.raspberrypi.org/raspbian_latest
|
||||
After unzipping, you'll get file with a name like: "<date>-wheezy-raspbian.img"
|
||||
Let's assume the sysroot will be built in /opt/rpi-sysroot.
|
||||
|
||||
export SYSROOT=/opt/rpi-sysroot
|
||||
sudo kpartx -a -v <path_to_raspbian_image>.img
|
||||
sudo mount -o loop /dev/mapper/loop0p2 /mnt
|
||||
sudo cp -r /mnt $SYSROOT
|
||||
sudo apt-get install qemu binfmt-support qemu-user-static
|
||||
sudo cp /usr/bin/qemu-arm-static $SYSROOT/usr/bin
|
||||
sudo mount --bind /dev $SYSROOT/dev
|
||||
sudo mount --bind /proc $SYSROOT/proc
|
||||
sudo mount --bind /sys $SYSROOT/sys
|
||||
|
||||
Now, before chrooting into the ARM sysroot, you'll need to apply a workaround,
|
||||
edit $SYSROOT/etc/ld.so.preload and comment out all lines in it.
|
||||
|
||||
sudo chroot $SYSROOT
|
||||
apt-get install libudev-dev libasound2-dev libdbus-1-dev libraspberrypi0 libraspberrypi-bin libraspberrypi-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxss-dev
|
||||
exit
|
||||
sudo umount $SYSROOT/dev
|
||||
sudo umount $SYSROOT/proc
|
||||
sudo umount $SYSROOT/sys
|
||||
sudo umount /mnt
|
||||
|
||||
There's one more fix required, as the libdl.so symlink uses an absolute path
|
||||
which doesn't quite work in our setup.
|
||||
|
||||
sudo rm -rf $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
sudo ln -s ../../../lib/arm-linux-gnueabihf/libdl.so.2 $SYSROOT/usr/lib/arm-linux-gnueabihf/libdl.so
|
||||
|
||||
The final step is compiling SDL itself.
|
||||
|
||||
export CC="/opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux"
|
||||
cd <SDL SOURCE>
|
||||
mkdir -p build;cd build
|
||||
LDFLAGS="-L$SYSROOT/opt/vc/lib" ../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd
|
||||
make
|
||||
make install
|
||||
|
||||
To be able to deploy this to /usr/local in the Raspbian system you need to fix up a few paths:
|
||||
|
||||
perl -w -pi -e "s#$PWD/rpi-sdl2-installed#/usr/local#g;" ./rpi-sdl2-installed/lib/libSDL2.la ./rpi-sdl2-installed/lib/pkgconfig/sdl2.pc ./rpi-sdl2-installed/bin/sdl2-config
|
||||
|
||||
Apps don't work or poor video/audio performance
|
||||
-----------------------------------------------
|
||||
|
||||
If you get sound problems, buffer underruns, etc, run "sudo rpi-update" to
|
||||
update the RPi's firmware. Note that doing so will fix these problems, but it
|
||||
will also render the CMA - Dynamic Memory Split functionality useless.
|
||||
|
||||
Also, by default the Raspbian distro configures the GPU RAM at 64MB, this is too
|
||||
low in general, specially if a 1080p TV is hooked up.
|
||||
|
||||
See here how to configure this setting: http://elinux.org/RPiconfig
|
||||
|
||||
Using a fixed gpu_mem=128 is the best option (specially if you updated the
|
||||
firmware, using CMA probably won't work, at least it's the current case).
|
||||
|
||||
No input
|
||||
--------
|
||||
|
||||
Make sure you belong to the "input" group.
|
||||
|
||||
sudo usermod -aG input `whoami`
|
||||
|
||||
No HDMI Audio
|
||||
-------------
|
||||
|
||||
If you notice that ALSA works but there's no audio over HDMI, try adding:
|
||||
|
||||
hdmi_drive=2
|
||||
|
||||
to your config.txt file and reboot.
|
||||
|
||||
Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062
|
||||
|
||||
Text Input API support
|
||||
----------------------
|
||||
|
||||
The Text Input API is supported, with translation of scan codes done via the
|
||||
kernel symbol tables. For this to work, SDL needs access to a valid console.
|
||||
If you notice there's no SDL_TEXTINPUT message being emitted, double check that
|
||||
your app has read access to one of the following:
|
||||
|
||||
* /proc/self/fd/0
|
||||
* /dev/tty
|
||||
* /dev/tty[0...6]
|
||||
* /dev/vc/0
|
||||
* /dev/console
|
||||
|
||||
This is usually not a problem if you run from the physical terminal (as opposed
|
||||
to running from a pseudo terminal, such as via SSH). If running from a PTS, a
|
||||
quick workaround is to run your app as root or add yourself to the tty group,
|
||||
then re-login to the system.
|
||||
|
||||
sudo usermod -aG tty `whoami`
|
||||
|
||||
The keyboard layout used by SDL is the same as the one the kernel uses.
|
||||
To configure the layout on Raspbian:
|
||||
|
||||
sudo dpkg-reconfigure keyboard-configuration
|
||||
|
||||
To configure the locale, which controls which keys are interpreted as letters,
|
||||
this determining the CAPS LOCK behavior:
|
||||
|
||||
sudo dpkg-reconfigure locales
|
||||
|
||||
|
||||
OpenGL problems
|
||||
---------------
|
||||
|
||||
If you have desktop OpenGL headers installed at build time in your RPi or cross
|
||||
compilation environment, support for it will be built in. However, the chipset
|
||||
does not actually have support for it, which causes issues in certain SDL apps
|
||||
since the presence of OpenGL support supersedes the ES/ES2 variants.
|
||||
The workaround is to disable OpenGL at configuration time:
|
||||
|
||||
./configure --disable-video-opengl
|
||||
|
||||
Or if the application uses the Render functions, you can use the SDL_RENDER_DRIVER
|
||||
environment variable:
|
||||
|
||||
export SDL_RENDER_DRIVER=opengles2
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
* When launching apps remotely (via SSH), SDL can prevent local keystrokes from
|
||||
leaking into the console only if it has root privileges. Launching apps locally
|
||||
does not suffer from this issue.
|
||||
|
||||
|
||||
|
@@ -1,41 +1,41 @@
|
||||
RISC OS
|
||||
=======
|
||||
|
||||
Requirements:
|
||||
|
||||
* RISC OS 3.5 or later.
|
||||
* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm).
|
||||
* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support.
|
||||
* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions.
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported.
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using autoconf:
|
||||
|
||||
./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics
|
||||
make
|
||||
make install
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using CMake:
|
||||
|
||||
cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF
|
||||
cmake --build build-riscos
|
||||
cmake --build build-riscos --target install
|
||||
|
||||
|
||||
Current level of implementation
|
||||
-------------------------------
|
||||
|
||||
The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported.
|
||||
|
||||
The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions.
|
||||
|
||||
The audio, loadso, thread and timer APIs are currently provided by UnixLib.
|
||||
|
||||
GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake.
|
||||
|
||||
The joystick, locale and power APIs are not yet implemented.
|
||||
RISC OS
|
||||
=======
|
||||
|
||||
Requirements:
|
||||
|
||||
* RISC OS 3.5 or later.
|
||||
* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm).
|
||||
* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support.
|
||||
* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions.
|
||||
|
||||
|
||||
Compiling:
|
||||
----------
|
||||
|
||||
Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported.
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using autoconf:
|
||||
|
||||
./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics
|
||||
make
|
||||
make install
|
||||
|
||||
The following commands can be used to build SDL2 for RISC OS using CMake:
|
||||
|
||||
cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF
|
||||
cmake --build build-riscos
|
||||
cmake --build build-riscos --target install
|
||||
|
||||
|
||||
Current level of implementation
|
||||
-------------------------------
|
||||
|
||||
The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported.
|
||||
|
||||
The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions.
|
||||
|
||||
The audio, loadso, thread and timer APIs are currently provided by UnixLib.
|
||||
|
||||
GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake.
|
||||
|
||||
The joystick, locale and power APIs are not yet implemented.
|
||||
|
@@ -1,83 +1,86 @@
|
||||
Touch
|
||||
===========================================================================
|
||||
System Specific Notes
|
||||
===========================================================================
|
||||
Linux:
|
||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||
|
||||
Mac:
|
||||
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||
|
||||
iPhone:
|
||||
Works out of box.
|
||||
|
||||
Windows:
|
||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||
|
||||
Events
|
||||
===========================================================================
|
||||
SDL_FINGERDOWN:
|
||||
Sent when a finger (or stylus) is placed on a touch device.
|
||||
Fields:
|
||||
* event.tfinger.touchId - the Id of the touch device.
|
||||
* event.tfinger.fingerId - the Id of the finger which just went down.
|
||||
* event.tfinger.x - the x coordinate of the touch (0..1)
|
||||
* event.tfinger.y - the y coordinate of the touch (0..1)
|
||||
* event.tfinger.pressure - the pressure of the touch (0..1)
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is moved on the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN but with additional:
|
||||
* event.tfinger.dx - change in x coordinate during this motion event.
|
||||
* event.tfinger.dy - change in y coordinate during this motion event.
|
||||
|
||||
SDL_FINGERUP:
|
||||
Sent when a finger (or stylus) is lifted from the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN.
|
||||
|
||||
|
||||
Functions
|
||||
===========================================================================
|
||||
SDL provides the ability to access the underlying SDL_Finger structures.
|
||||
These structures should _never_ be modified.
|
||||
|
||||
The following functions are included from SDL_touch.h
|
||||
|
||||
To get a SDL_TouchID call SDL_GetTouchDevice(int index).
|
||||
This returns a SDL_TouchID.
|
||||
IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this!
|
||||
|
||||
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
||||
|
||||
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
||||
|
||||
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
||||
|
||||
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
||||
|
||||
float x = event.tfinger.x;
|
||||
float y = event.tfinger.y;
|
||||
|
||||
|
||||
|
||||
To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger.
|
||||
This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed.
|
||||
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
||||
As a result, be very careful to check for NULL return values.
|
||||
|
||||
A SDL_Finger has the following fields:
|
||||
* x, y:
|
||||
The current coordinates of the touch.
|
||||
* pressure:
|
||||
The pressure of the touch.
|
||||
|
||||
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
(original author, API was changed since)
|
||||
Touch
|
||||
===========================================================================
|
||||
System Specific Notes
|
||||
===========================================================================
|
||||
Linux:
|
||||
The linux touch system is currently based off event streams, and proc/bus/devices. The active user must be given permissions to read /dev/input/TOUCHDEVICE, where TOUCHDEVICE is the event stream for your device. Currently only Wacom tablets are supported. If you have an unsupported tablet contact me at jim.tla+sdl_touch@gmail.com and I will help you get support for it.
|
||||
|
||||
Mac:
|
||||
The Mac and iPhone APIs are pretty. If your touch device supports them then you'll be fine. If it doesn't, then there isn't much we can do.
|
||||
|
||||
iPhone:
|
||||
Works out of box.
|
||||
|
||||
Windows:
|
||||
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
|
||||
|
||||
===========================================================================
|
||||
Events
|
||||
===========================================================================
|
||||
SDL_FINGERDOWN:
|
||||
Sent when a finger (or stylus) is placed on a touch device.
|
||||
Fields:
|
||||
* event.tfinger.touchId - the Id of the touch device.
|
||||
* event.tfinger.fingerId - the Id of the finger which just went down.
|
||||
* event.tfinger.x - the x coordinate of the touch (0..1)
|
||||
* event.tfinger.y - the y coordinate of the touch (0..1)
|
||||
* event.tfinger.pressure - the pressure of the touch (0..1)
|
||||
|
||||
SDL_FINGERMOTION:
|
||||
Sent when a finger (or stylus) is moved on the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN but with additional:
|
||||
* event.tfinger.dx - change in x coordinate during this motion event.
|
||||
* event.tfinger.dy - change in y coordinate during this motion event.
|
||||
|
||||
SDL_FINGERUP:
|
||||
Sent when a finger (or stylus) is lifted from the touch device.
|
||||
Fields:
|
||||
Same as SDL_FINGERDOWN.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Functions
|
||||
===========================================================================
|
||||
SDL provides the ability to access the underlying SDL_Finger structures.
|
||||
These structures should _never_ be modified.
|
||||
|
||||
The following functions are included from SDL_touch.h
|
||||
|
||||
To get a SDL_TouchID call SDL_GetTouchDevice(int index).
|
||||
This returns a SDL_TouchID.
|
||||
IMPORTANT: If the touch has been removed, or there is no touch with the given index, SDL_GetTouchDevice() will return 0. Be sure to check for this!
|
||||
|
||||
The number of touch devices can be queried with SDL_GetNumTouchDevices().
|
||||
|
||||
A SDL_TouchID may be used to get pointers to SDL_Finger.
|
||||
|
||||
SDL_GetNumTouchFingers(touchID) may be used to get the number of fingers currently down on the device.
|
||||
|
||||
The most common reason to access SDL_Finger is to query the fingers outside the event. In most cases accessing the fingers is using the event. This would be accomplished by code like the following:
|
||||
|
||||
float x = event.tfinger.x;
|
||||
float y = event.tfinger.y;
|
||||
|
||||
|
||||
|
||||
To get a SDL_Finger, call SDL_GetTouchFinger(SDL_TouchID touchID, int index), where touchID is a SDL_TouchID, and index is the requested finger.
|
||||
This returns a SDL_Finger *, or NULL if the finger does not exist, or has been removed.
|
||||
A SDL_Finger is guaranteed to be persistent for the duration of a touch, but it will be de-allocated as soon as the finger is removed. This occurs when the SDL_FINGERUP event is _added_ to the event queue, and thus _before_ the SDL_FINGERUP event is polled.
|
||||
As a result, be very careful to check for NULL return values.
|
||||
|
||||
A SDL_Finger has the following fields:
|
||||
* x, y:
|
||||
The current coordinates of the touch.
|
||||
* pressure:
|
||||
The pressure of the touch.
|
||||
|
||||
|
||||
===========================================================================
|
||||
Notes
|
||||
===========================================================================
|
||||
For a complete example see test/testgesture.c
|
||||
|
||||
Please direct questions/comments to:
|
||||
jim.tla+sdl_touch@gmail.com
|
||||
(original author, API was changed since)
|
||||
|
@@ -1,60 +1,60 @@
|
||||
# Versioning
|
||||
|
||||
## Since 2.23.0
|
||||
|
||||
SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak
|
||||
and older versions of the Linux kernel:
|
||||
|
||||
* The major version (first part) increases when backwards compatibility
|
||||
is broken, which will happen infrequently.
|
||||
|
||||
* If the minor version (second part) is divisible by 2
|
||||
(for example 2.24.x, 2.26.x), this indicates a version of SDL that
|
||||
is believed to be stable and suitable for production use.
|
||||
|
||||
* In stable releases, the patchlevel or micro version (third part)
|
||||
indicates bugfix releases. Bugfix releases should not add or
|
||||
remove ABI, so the ".0" release (for example 2.24.0) should be
|
||||
forwards-compatible with all the bugfix releases from the
|
||||
same cycle (for example 2.24.1).
|
||||
|
||||
* The minor version increases when new API or ABI is added, or when
|
||||
other significant changes are made. Newer minor versions are
|
||||
backwards-compatible, but not fully forwards-compatible.
|
||||
For example, programs built against SDL 2.24.x should work fine
|
||||
with SDL 2.26.x, but programs built against SDL 2.26.x will not
|
||||
necessarily work with 2.24.x.
|
||||
|
||||
* If the minor version (second part) is not divisible by 2
|
||||
(for example 2.23.x, 2.25.x), this indicates a development prerelease
|
||||
of SDL that is not suitable for stable software distributions.
|
||||
Use with caution.
|
||||
|
||||
* The patchlevel or micro version (third part) increases with
|
||||
each prerelease.
|
||||
|
||||
* Each prerelease might add new API and/or ABI.
|
||||
|
||||
* Prereleases are backwards-compatible with older stable branches.
|
||||
For example, 2.25.x will be backwards-compatible with 2.24.x.
|
||||
|
||||
* Prereleases are not guaranteed to be backwards-compatible with
|
||||
each other. For example, new API or ABI added in 2.25.1
|
||||
might be removed or changed in 2.25.2.
|
||||
If this would be a problem for you, please do not use prereleases.
|
||||
|
||||
* Only upgrade to a prerelease if you can guarantee that you will
|
||||
promptly upgrade to the stable release that follows it.
|
||||
For example, do not upgrade to 2.23.x unless you will be able to
|
||||
upgrade to 2.24.0 when it becomes available.
|
||||
|
||||
* Software distributions that have a freeze policy (in particular Linux
|
||||
distributions with a release cycle, such as Debian and Fedora)
|
||||
should usually only package stable releases, and not prereleases.
|
||||
|
||||
## Before 2.23.0
|
||||
|
||||
Older versions of SDL followed a similar policy, but instead of the
|
||||
odd/even rule applying to the minor version, it applied to the patchlevel
|
||||
(micro version, third part). For example, 2.0.22 was a stable release
|
||||
and 2.0.21 was a prerelease.
|
||||
# Versioning
|
||||
|
||||
## Since 2.23.0
|
||||
|
||||
SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak
|
||||
and older versions of the Linux kernel:
|
||||
|
||||
* The major version (first part) increases when backwards compatibility
|
||||
is broken, which will happen infrequently.
|
||||
|
||||
* If the minor version (second part) is divisible by 2
|
||||
(for example 2.24.x, 2.26.x), this indicates a version of SDL that
|
||||
is believed to be stable and suitable for production use.
|
||||
|
||||
* In stable releases, the patchlevel or micro version (third part)
|
||||
indicates bugfix releases. Bugfix releases should not add or
|
||||
remove ABI, so the ".0" release (for example 2.24.0) should be
|
||||
forwards-compatible with all the bugfix releases from the
|
||||
same cycle (for example 2.24.1).
|
||||
|
||||
* The minor version increases when new API or ABI is added, or when
|
||||
other significant changes are made. Newer minor versions are
|
||||
backwards-compatible, but not fully forwards-compatible.
|
||||
For example, programs built against SDL 2.24.x should work fine
|
||||
with SDL 2.26.x, but programs built against SDL 2.26.x will not
|
||||
necessarily work with 2.24.x.
|
||||
|
||||
* If the minor version (second part) is not divisible by 2
|
||||
(for example 2.23.x, 2.25.x), this indicates a development prerelease
|
||||
of SDL that is not suitable for stable software distributions.
|
||||
Use with caution.
|
||||
|
||||
* The patchlevel or micro version (third part) increases with
|
||||
each prerelease.
|
||||
|
||||
* Each prerelease might add new API and/or ABI.
|
||||
|
||||
* Prereleases are backwards-compatible with older stable branches.
|
||||
For example, 2.25.x will be backwards-compatible with 2.24.x.
|
||||
|
||||
* Prereleases are not guaranteed to be backwards-compatible with
|
||||
each other. For example, new API or ABI added in 2.25.1
|
||||
might be removed or changed in 2.25.2.
|
||||
If this would be a problem for you, please do not use prereleases.
|
||||
|
||||
* Only upgrade to a prerelease if you can guarantee that you will
|
||||
promptly upgrade to the stable release that follows it.
|
||||
For example, do not upgrade to 2.23.x unless you will be able to
|
||||
upgrade to 2.24.0 when it becomes available.
|
||||
|
||||
* Software distributions that have a freeze policy (in particular Linux
|
||||
distributions with a release cycle, such as Debian and Fedora)
|
||||
should usually only package stable releases, and not prereleases.
|
||||
|
||||
## Before 2.23.0
|
||||
|
||||
Older versions of SDL followed a similar policy, but instead of the
|
||||
odd/even rule applying to the minor version, it applied to the patchlevel
|
||||
(micro version, third part). For example, 2.0.22 was a stable release
|
||||
and 2.0.21 was a prerelease.
|
||||
|
@@ -1,114 +1,114 @@
|
||||
Using SDL with Microsoft Visual C++
|
||||
===================================
|
||||
|
||||
### by Lion Kimbro with additions by James Turk
|
||||
|
||||
You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL
|
||||
yourself.
|
||||
|
||||
### Building SDL
|
||||
|
||||
0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from
|
||||
the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web).
|
||||
_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_
|
||||
|
||||
1. Open the Visual Studio solution file at `./VisualC/SDL.sln`.
|
||||
|
||||
2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog,
|
||||
all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with
|
||||
the `Platform Toolset`.
|
||||
|
||||
If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`.
|
||||
|
||||
3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_
|
||||
panel in the _FileView_ tab), and selecting `Build`.
|
||||
|
||||
You may get a few warnings, but you should not get any errors.
|
||||
|
||||
Later, we will refer to the following `.lib` and `.dll` files that have just been generated:
|
||||
|
||||
- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll`
|
||||
- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib`
|
||||
- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib`
|
||||
|
||||
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
|
||||
|
||||
### Creating a Project with SDL
|
||||
|
||||
- Create a project as a `Win32 Application`.
|
||||
|
||||
- Create a C++ file for your project.
|
||||
|
||||
- Set the C runtime to `Multi-threaded DLL` in the menu:
|
||||
`Project|Settings|C/C++ tab|Code Generation|Runtime Library `.
|
||||
|
||||
- Add the SDL `include` directory to your list of includes in the menu:
|
||||
`Project|Settings|C/C++ tab|Preprocessor|Additional include directories `
|
||||
|
||||
*VC7 Specific: Instead of doing this, I find it easier to add the
|
||||
include and library directories to the list that VC7 keeps. Do this by
|
||||
selecting Tools|Options|Projects|VC++ Directories and under the "Show
|
||||
Directories For:" dropbox select "Include Files", and click the "New
|
||||
Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you
|
||||
installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the
|
||||
dropbox selection to "Library Files" and add [SDLROOT]\\lib.*
|
||||
|
||||
The "include directory" I am referring to is the `./include` folder.
|
||||
|
||||
Now we're going to use the files that we had created earlier in the *Build SDL* step.
|
||||
|
||||
Copy the following file into your Project directory:
|
||||
|
||||
- `SDL2.dll`
|
||||
|
||||
Add the following files to your project (It is not necessary to copy them to your project directory):
|
||||
|
||||
- `SDL2.lib`
|
||||
- `SDL2main.lib`
|
||||
|
||||
To add them to your project, right click on your project, and select
|
||||
`Add files to project`.
|
||||
|
||||
**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line
|
||||
and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration
|
||||
(e.g. Release,Debug).**
|
||||
|
||||
### Hello SDL2
|
||||
|
||||
Here's a sample SDL snippet to verify everything is setup in your IDE:
|
||||
|
||||
```
|
||||
#include "SDL.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
const int WIDTH = 640;
|
||||
const int HEIGHT = 480;
|
||||
SDL_Window* window = NULL;
|
||||
SDL_Renderer* renderer = NULL;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### That's it!
|
||||
|
||||
I hope that this document has helped you get through the most difficult part of using the SDL: installing it.
|
||||
Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues).
|
||||
|
||||
### Credits
|
||||
|
||||
Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port.
|
||||
|
||||
This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org).
|
||||
|
||||
Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com).
|
||||
|
||||
Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net)
|
||||
Using SDL with Microsoft Visual C++
|
||||
===================================
|
||||
|
||||
### by Lion Kimbro with additions by James Turk
|
||||
|
||||
You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL
|
||||
yourself.
|
||||
|
||||
### Building SDL
|
||||
|
||||
0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from
|
||||
the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web).
|
||||
_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_
|
||||
|
||||
1. Open the Visual Studio solution file at `./VisualC/SDL.sln`.
|
||||
|
||||
2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog,
|
||||
all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with
|
||||
the `Platform Toolset`.
|
||||
|
||||
If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`.
|
||||
|
||||
3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_
|
||||
panel in the _FileView_ tab), and selecting `Build`.
|
||||
|
||||
You may get a few warnings, but you should not get any errors.
|
||||
|
||||
Later, we will refer to the following `.lib` and `.dll` files that have just been generated:
|
||||
|
||||
- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll`
|
||||
- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib`
|
||||
- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib`
|
||||
|
||||
_Note for the `x64` versions, just replace `Win32` in the path with `x64`_
|
||||
|
||||
### Creating a Project with SDL
|
||||
|
||||
- Create a project as a `Win32 Application`.
|
||||
|
||||
- Create a C++ file for your project.
|
||||
|
||||
- Set the C runtime to `Multi-threaded DLL` in the menu:
|
||||
`Project|Settings|C/C++ tab|Code Generation|Runtime Library `.
|
||||
|
||||
- Add the SDL `include` directory to your list of includes in the menu:
|
||||
`Project|Settings|C/C++ tab|Preprocessor|Additional include directories `
|
||||
|
||||
*VC7 Specific: Instead of doing this, I find it easier to add the
|
||||
include and library directories to the list that VC7 keeps. Do this by
|
||||
selecting Tools|Options|Projects|VC++ Directories and under the "Show
|
||||
Directories For:" dropbox select "Include Files", and click the "New
|
||||
Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you
|
||||
installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the
|
||||
dropbox selection to "Library Files" and add [SDLROOT]\\lib.*
|
||||
|
||||
The "include directory" I am referring to is the `./include` folder.
|
||||
|
||||
Now we're going to use the files that we had created earlier in the *Build SDL* step.
|
||||
|
||||
Copy the following file into your Project directory:
|
||||
|
||||
- `SDL2.dll`
|
||||
|
||||
Add the following files to your project (It is not necessary to copy them to your project directory):
|
||||
|
||||
- `SDL2.lib`
|
||||
- `SDL2main.lib`
|
||||
|
||||
To add them to your project, right click on your project, and select
|
||||
`Add files to project`.
|
||||
|
||||
**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line
|
||||
and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration
|
||||
(e.g. Release,Debug).**
|
||||
|
||||
### Hello SDL2
|
||||
|
||||
Here's a sample SDL snippet to verify everything is setup in your IDE:
|
||||
|
||||
```
|
||||
#include "SDL.h"
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
const int WIDTH = 640;
|
||||
const int HEIGHT = 480;
|
||||
SDL_Window* window = NULL;
|
||||
SDL_Renderer* renderer = NULL;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
### That's it!
|
||||
|
||||
I hope that this document has helped you get through the most difficult part of using the SDL: installing it.
|
||||
Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues).
|
||||
|
||||
### Credits
|
||||
|
||||
Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port.
|
||||
|
||||
This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org).
|
||||
|
||||
Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com).
|
||||
|
||||
Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net)
|
||||
|
@@ -1,33 +1,33 @@
|
||||
PS Vita
|
||||
=======
|
||||
SDL port for the Sony Playstation Vita and Sony Playstation TV
|
||||
|
||||
Credit to
|
||||
* xerpi, cpasjuste and rsn8887 for initial (vita2d) port
|
||||
* vitasdk/dolcesdk devs
|
||||
* CBPS discord (Namely Graphene and SonicMastr)
|
||||
|
||||
Building
|
||||
--------
|
||||
To build for the PSVita, make sure you have vitasdk and cmake installed and run:
|
||||
```
|
||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON`
|
||||
These renderers support 720p and 1080i resolutions. These can be specified with:
|
||||
`SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);`
|
||||
* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK.
|
||||
They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);`
|
||||
anytime before video subsystem initialization.
|
||||
* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON`
|
||||
* By default SDL emits mouse events for touch events on every touchscreen.
|
||||
Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead.
|
||||
Individual touchscreens can be disabled with:
|
||||
`SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);`
|
||||
* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita.
|
||||
PS Vita
|
||||
=======
|
||||
SDL port for the Sony Playstation Vita and Sony Playstation TV
|
||||
|
||||
Credit to
|
||||
* xerpi, cpasjuste and rsn8887 for initial (vita2d) port
|
||||
* vitasdk/dolcesdk devs
|
||||
* CBPS discord (Namely Graphene and SonicMastr)
|
||||
|
||||
Building
|
||||
--------
|
||||
To build for the PSVita, make sure you have vitasdk and cmake installed and run:
|
||||
```
|
||||
cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build
|
||||
cmake --install build
|
||||
```
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON`
|
||||
These renderers support 720p and 1080i resolutions. These can be specified with:
|
||||
`SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);`
|
||||
* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK.
|
||||
They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);`
|
||||
anytime before video subsystem initialization.
|
||||
* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON`
|
||||
* By default SDL emits mouse events for touch events on every touchscreen.
|
||||
Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead.
|
||||
Individual touchscreens can be disabled with:
|
||||
`SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);`
|
||||
* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita.
|
||||
|
@@ -1,10 +1,10 @@
|
||||
WinCE
|
||||
=====
|
||||
|
||||
Windows CE is no longer supported by SDL.
|
||||
|
||||
We have left the CE support in SDL 1.2 for those that must have it, and we
|
||||
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
|
||||
|
||||
--ryan.
|
||||
|
||||
WinCE
|
||||
=====
|
||||
|
||||
Windows CE is no longer supported by SDL.
|
||||
|
||||
We have left the CE support in SDL 1.2 for those that must have it, and we
|
||||
have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3.
|
||||
|
||||
--ryan.
|
||||
|
||||
|
@@ -1,58 +1,58 @@
|
||||
# Windows
|
||||
|
||||
## LLVM and Intel C++ compiler support
|
||||
|
||||
SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++
|
||||
compiler, but you'll have to manually add the "-msse3" command line option
|
||||
to at least the SDL_audiocvt.c source file, and possibly others. This may
|
||||
not be necessary if you build SDL with CMake instead of the included Visual
|
||||
Studio solution.
|
||||
|
||||
Details are here: https://github.com/libsdl-org/SDL/issues/5186
|
||||
|
||||
|
||||
## OpenGL ES 2.x support
|
||||
|
||||
SDL has support for OpenGL ES 2.x under Windows via two alternative
|
||||
implementations.
|
||||
|
||||
The most straightforward method consists in running your app in a system with
|
||||
a graphic card paired with a relatively recent (as of November of 2013) driver
|
||||
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
|
||||
to ship said extension on Windows currently include nVidia and Intel.
|
||||
|
||||
The other method involves using the
|
||||
[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x
|
||||
context is requested and no WGL_EXT_create_context_es2_profile extension is
|
||||
found, SDL will try to load the libEGL.dll library provided by ANGLE.
|
||||
|
||||
To obtain the ANGLE binaries, you can either compile from source from
|
||||
https://chromium.googlesource.com/angle/angle or copy the relevant binaries
|
||||
from a recent Chrome/Chromium install for Windows. The files you need are:
|
||||
|
||||
- libEGL.dll
|
||||
- libGLESv2.dll
|
||||
- d3dcompiler_46.dll (supports Windows Vista or later, better shader
|
||||
compiler) *or* d3dcompiler_43.dll (supports Windows XP or later)
|
||||
|
||||
If you compile ANGLE from source, you can configure it so it does not need the
|
||||
d3dcompiler_* DLL at all (for details on this, see their documentation).
|
||||
However, by default SDL will try to preload the d3dcompiler_46.dll to
|
||||
comply with ANGLE's requirements. If you wish SDL to preload
|
||||
d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you
|
||||
can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more
|
||||
details).
|
||||
|
||||
Known Bugs:
|
||||
|
||||
- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
|
||||
that there's a bug in the library which prevents the window contents from
|
||||
refreshing if this is set to anything other than the default value.
|
||||
|
||||
## Vulkan Surface Support
|
||||
|
||||
Support for creating Vulkan surfaces is configured on by default. To disable
|
||||
it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You
|
||||
must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to
|
||||
use Vulkan graphics in your application.
|
||||
|
||||
# Windows
|
||||
|
||||
## LLVM and Intel C++ compiler support
|
||||
|
||||
SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++
|
||||
compiler, but you'll have to manually add the "-msse3" command line option
|
||||
to at least the SDL_audiocvt.c source file, and possibly others. This may
|
||||
not be necessary if you build SDL with CMake instead of the included Visual
|
||||
Studio solution.
|
||||
|
||||
Details are here: https://github.com/libsdl-org/SDL/issues/5186
|
||||
|
||||
|
||||
## OpenGL ES 2.x support
|
||||
|
||||
SDL has support for OpenGL ES 2.x under Windows via two alternative
|
||||
implementations.
|
||||
|
||||
The most straightforward method consists in running your app in a system with
|
||||
a graphic card paired with a relatively recent (as of November of 2013) driver
|
||||
which supports the WGL_EXT_create_context_es2_profile extension. Vendors known
|
||||
to ship said extension on Windows currently include nVidia and Intel.
|
||||
|
||||
The other method involves using the
|
||||
[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x
|
||||
context is requested and no WGL_EXT_create_context_es2_profile extension is
|
||||
found, SDL will try to load the libEGL.dll library provided by ANGLE.
|
||||
|
||||
To obtain the ANGLE binaries, you can either compile from source from
|
||||
https://chromium.googlesource.com/angle/angle or copy the relevant binaries
|
||||
from a recent Chrome/Chromium install for Windows. The files you need are:
|
||||
|
||||
- libEGL.dll
|
||||
- libGLESv2.dll
|
||||
- d3dcompiler_46.dll (supports Windows Vista or later, better shader
|
||||
compiler) *or* d3dcompiler_43.dll (supports Windows XP or later)
|
||||
|
||||
If you compile ANGLE from source, you can configure it so it does not need the
|
||||
d3dcompiler_* DLL at all (for details on this, see their documentation).
|
||||
However, by default SDL will try to preload the d3dcompiler_46.dll to
|
||||
comply with ANGLE's requirements. If you wish SDL to preload
|
||||
d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you
|
||||
can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more
|
||||
details).
|
||||
|
||||
Known Bugs:
|
||||
|
||||
- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears
|
||||
that there's a bug in the library which prevents the window contents from
|
||||
refreshing if this is set to anything other than the default value.
|
||||
|
||||
## Vulkan Surface Support
|
||||
|
||||
Support for creating Vulkan surfaces is configured on by default. To disable
|
||||
it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You
|
||||
must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to
|
||||
use Vulkan graphics in your application.
|
||||
|
||||
|
1038
docs/README-winrt.md
1038
docs/README-winrt.md
File diff suppressed because it is too large
Load Diff
@@ -25,6 +25,7 @@
|
||||
* Main include header for the SDL library
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SDL_h_
|
||||
#define SDL_h_
|
||||
|
||||
@@ -69,8 +70,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* WIKI CATEGORY: Init */
|
||||
|
||||
/* As of version 0.5, SDL is loaded dynamically into the application */
|
||||
|
||||
/**
|
||||
@@ -131,7 +130,7 @@ extern "C" {
|
||||
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then
|
||||
* this call will increase the ref-count and return.
|
||||
*
|
||||
* \param flags subsystem initialization flags.
|
||||
* \param flags subsystem initialization flags
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
|
@@ -61,8 +61,6 @@ assert can have unique static variables associated with it.
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
|
||||
#elif defined(__APPLE__) && defined(__arm__)
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
|
||||
#elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) )
|
||||
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" )
|
||||
#elif defined(__386__) && defined(__WATCOMC__)
|
||||
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
|
||||
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
|
||||
@@ -153,7 +151,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, NULL, 0, NULL, NULL }; \
|
||||
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
|
||||
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,8 +191,8 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
|
||||
* A callback that fires when an SDL assertion fails.
|
||||
*
|
||||
* \param data a pointer to the SDL_AssertData structure corresponding to the
|
||||
* current assertion.
|
||||
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler().
|
||||
* current assertion
|
||||
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler()
|
||||
* \returns an SDL_AssertState value indicating how to handle the failure.
|
||||
*/
|
||||
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
|
||||
@@ -214,8 +212,8 @@ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
|
||||
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
|
||||
*
|
||||
* \param handler the SDL_AssertionHandler function to call when an assertion
|
||||
* fails or NULL for the default handler.
|
||||
* \param userdata a pointer that is passed to `handler`.
|
||||
* fails or NULL for the default handler
|
||||
* \param userdata a pointer that is passed to `handler`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -256,7 +254,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void
|
||||
* data, it is safe to pass a NULL pointer to this function to ignore it.
|
||||
*
|
||||
* \param puserdata pointer which is filled with the "userdata" pointer that
|
||||
* was passed to SDL_SetAssertionHandler().
|
||||
* was passed to SDL_SetAssertionHandler()
|
||||
* \returns the SDL_AssertionHandler that is called when an assert triggers.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
|
@@ -20,29 +20,38 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryAtomic
|
||||
* \file SDL_atomic.h
|
||||
*
|
||||
* Atomic operations.
|
||||
*
|
||||
* IMPORTANT: If you are not an expert in concurrent lockless programming, you
|
||||
* should not be using any functions in this file. You should be protecting
|
||||
* your data structures with full mutexes instead.
|
||||
* IMPORTANT:
|
||||
* If you are not an expert in concurrent lockless programming, you should
|
||||
* only be using the atomic lock and reference counting functions in this
|
||||
* file. In all other cases you should be protecting your data structures
|
||||
* with full mutexes.
|
||||
*
|
||||
* ***Seriously, here be dragons!***
|
||||
* The list of "safe" functions to use are:
|
||||
* SDL_AtomicLock()
|
||||
* SDL_AtomicUnlock()
|
||||
* SDL_AtomicIncRef()
|
||||
* SDL_AtomicDecRef()
|
||||
*
|
||||
* You can find out a little more about lockless programming and the subtle
|
||||
* issues that can arise here:
|
||||
* https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming
|
||||
* Seriously, here be dragons!
|
||||
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
*
|
||||
* You can find out a little more about lockless programming and the
|
||||
* subtle issues that can arise here:
|
||||
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
|
||||
*
|
||||
* There's also lots of good information here:
|
||||
* http://www.1024cores.net/home/lock-free-algorithms
|
||||
* http://preshing.com/
|
||||
*
|
||||
* - https://www.1024cores.net/home/lock-free-algorithms
|
||||
* - https://preshing.com/
|
||||
*
|
||||
* These operations may or may not actually be implemented using processor
|
||||
* specific atomic operations. When possible they are implemented as true
|
||||
* processor specific atomic operations. When that is not possible the are
|
||||
* implemented using locks that *do* use the available atomic operations.
|
||||
* These operations may or may not actually be implemented using
|
||||
* processor specific atomic operations. When possible they are
|
||||
* implemented as true processor specific atomic operations. When that
|
||||
* is not possible the are implemented using locks that *do* use the
|
||||
* available atomic operations.
|
||||
*
|
||||
* All of the atomic operations that modify memory are full memory barriers.
|
||||
*/
|
||||
@@ -85,7 +94,7 @@ typedef int SDL_SpinLock;
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \param lock a pointer to a lock variable.
|
||||
* \param lock a pointer to a lock variable
|
||||
* \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already
|
||||
* held.
|
||||
*
|
||||
@@ -102,7 +111,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \param lock a pointer to a lock variable.
|
||||
* \param lock a pointer to a lock variable
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -119,7 +128,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
|
||||
* ***Please note that spinlocks are dangerous if you don't know what you're
|
||||
* doing. Please be careful using any sort of spinlock!***
|
||||
*
|
||||
* \param lock a pointer to a lock variable.
|
||||
* \param lock a pointer to a lock variable
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -248,13 +257,10 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
||||
|
||||
|
||||
/**
|
||||
* A type representing an atomic integer value.
|
||||
*
|
||||
* It is a struct so people don't accidentally use numeric operations on it.
|
||||
* \brief A type representing an atomic integer value. It is a struct
|
||||
* so people don't accidentally use numeric operations on it.
|
||||
*/
|
||||
typedef struct SDL_atomic_t {
|
||||
int value;
|
||||
} SDL_atomic_t;
|
||||
typedef struct { int value; } SDL_atomic_t;
|
||||
|
||||
/**
|
||||
* Set an atomic variable to a new value if it is currently an old value.
|
||||
@@ -262,9 +268,9 @@ typedef struct SDL_atomic_t {
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified.
|
||||
* \param oldval the old value.
|
||||
* \param newval the new value.
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param oldval the old value
|
||||
* \param newval the new value
|
||||
* \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -283,8 +289,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified.
|
||||
* \param v the desired value.
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param v the desired value
|
||||
* \returns the previous value of the atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
@@ -299,7 +305,7 @@ extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable.
|
||||
* \param a a pointer to an SDL_atomic_t variable
|
||||
* \returns the current value of an atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
@@ -316,8 +322,8 @@ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified.
|
||||
* \param v the desired value to add.
|
||||
* \param a a pointer to an SDL_atomic_t variable to be modified
|
||||
* \param v the desired value to add
|
||||
* \returns the previous value of the atomic variable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
@@ -350,9 +356,9 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to a pointer.
|
||||
* \param oldval the old pointer value.
|
||||
* \param newval the new pointer value.
|
||||
* \param a a pointer to a pointer
|
||||
* \param oldval the old pointer value
|
||||
* \param newval the new pointer value
|
||||
* \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -369,8 +375,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to a pointer.
|
||||
* \param v the desired pointer value.
|
||||
* \param a a pointer to a pointer
|
||||
* \param v the desired pointer value
|
||||
* \returns the previous value of the pointer.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
@@ -386,7 +392,7 @@ extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
|
||||
* ***Note: If you don't know what this function is for, you shouldn't use
|
||||
* it!***
|
||||
*
|
||||
* \param a a pointer to a pointer.
|
||||
* \param a a pointer to a pointer
|
||||
* \returns the current value of a pointer.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.2.
|
||||
|
@@ -22,9 +22,9 @@
|
||||
/* !!! FIXME: several functions in here need Doxygen comments. */
|
||||
|
||||
/**
|
||||
* # CategoryAudio
|
||||
* \file SDL_audio.h
|
||||
*
|
||||
* Access to the raw audio mixing buffer for the SDL library.
|
||||
* Access to the raw audio mixing buffer for the SDL library.
|
||||
*/
|
||||
|
||||
#ifndef SDL_audio_h_
|
||||
@@ -44,24 +44,24 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Audio format flags.
|
||||
* \brief Audio format flags.
|
||||
*
|
||||
* These are what the 16 bits in SDL_AudioFormat currently mean...
|
||||
* (Unspecified bits are always zero).
|
||||
* These are what the 16 bits in SDL_AudioFormat currently mean...
|
||||
* (Unspecified bits are always zero).
|
||||
*
|
||||
* ```
|
||||
* ++-----------------------sample is signed if set
|
||||
* ||
|
||||
* || ++-----------sample is bigendian if set
|
||||
* || ||
|
||||
* || || ++---sample is float if set
|
||||
* || || ||
|
||||
* || || || +---sample bit size---+
|
||||
* || || || | |
|
||||
* 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
||||
* ```
|
||||
* \verbatim
|
||||
++-----------------------sample is signed if set
|
||||
||
|
||||
|| ++-----------sample is bigendian if set
|
||||
|| ||
|
||||
|| || ++---sample is float if set
|
||||
|| || ||
|
||||
|| || || +---sample bit size---+
|
||||
|| || || | |
|
||||
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
|
||||
\endverbatim
|
||||
*
|
||||
* There are macros in SDL 2.0 and later to query these bits.
|
||||
* There are macros in SDL 2.0 and later to query these bits.
|
||||
*/
|
||||
typedef Uint16 SDL_AudioFormat;
|
||||
|
||||
@@ -149,30 +149,33 @@ typedef Uint16 SDL_AudioFormat;
|
||||
/* @} *//* Audio flags */
|
||||
|
||||
/**
|
||||
* This function is called when the audio device needs more data.
|
||||
* This function is called when the audio device needs more data.
|
||||
*
|
||||
* \param userdata An application-specific parameter saved in the
|
||||
* SDL_AudioSpec structure.
|
||||
* \param stream A pointer to the audio data buffer.
|
||||
* \param len Length of **stream** in bytes.
|
||||
* \param userdata An application-specific parameter saved in
|
||||
* the SDL_AudioSpec structure
|
||||
* \param stream A pointer to the audio data buffer.
|
||||
* \param len The length of that buffer in bytes.
|
||||
*
|
||||
* Once the callback returns, the buffer will no longer be valid.
|
||||
* Stereo samples are stored in a LRLRLR ordering.
|
||||
*
|
||||
* You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
|
||||
* you like. Just open your audio device with a NULL callback.
|
||||
*/
|
||||
typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* The calculated values in this structure are calculated by SDL_OpenAudio().
|
||||
* The calculated values in this structure are calculated by SDL_OpenAudio().
|
||||
*
|
||||
* For multi-channel audio, the default SDL channel mapping is:
|
||||
*
|
||||
* ```
|
||||
* 2: FL FR (stereo)
|
||||
* 3: FL FR LFE (2.1 surround)
|
||||
* 4: FL FR BL BR (quad)
|
||||
* 5: FL FR LFE BL BR (4.1 surround)
|
||||
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
|
||||
* 7: FL FR FC LFE BC SL SR (6.1 surround)
|
||||
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
|
||||
* ```
|
||||
* For multi-channel audio, the default SDL channel mapping is:
|
||||
* 2: FL FR (stereo)
|
||||
* 3: FL FR LFE (2.1 surround)
|
||||
* 4: FL FR BL BR (quad)
|
||||
* 5: FL FR LFE BL BR (4.1 surround)
|
||||
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
|
||||
* 7: FL FR FC LFE BC SL SR (6.1 surround)
|
||||
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
|
||||
*/
|
||||
typedef struct SDL_AudioSpec
|
||||
{
|
||||
@@ -193,11 +196,11 @@ typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
|
||||
SDL_AudioFormat format);
|
||||
|
||||
/**
|
||||
* Upper limit of filters in SDL_AudioCVT
|
||||
* \brief Upper limit of filters in SDL_AudioCVT
|
||||
*
|
||||
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
|
||||
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, one
|
||||
* of which is the terminating NULL pointer.
|
||||
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
|
||||
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers,
|
||||
* one of which is the terminating NULL pointer.
|
||||
*/
|
||||
#define SDL_AUDIOCVT_MAX_FILTERS 9
|
||||
|
||||
@@ -284,7 +287,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
|
||||
* meant to be proper names.
|
||||
*
|
||||
* \param index the index of the audio driver; the value ranges from 0 to
|
||||
* SDL_GetNumAudioDrivers() - 1.
|
||||
* SDL_GetNumAudioDrivers() - 1
|
||||
* \returns the name of the audio driver at the requested index, or NULL if an
|
||||
* invalid index was specified.
|
||||
*
|
||||
@@ -311,7 +314,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
|
||||
* specific need to designate the audio driver you want to use. You should
|
||||
* normally use SDL_Init() or SDL_InitSubSystem().
|
||||
*
|
||||
* \param driver_name the name of the desired audio driver.
|
||||
* \param driver_name the name of the desired audio driver
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -405,13 +408,13 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
|
||||
SDL_AudioSpec * obtained);
|
||||
|
||||
/**
|
||||
* SDL Audio Device IDs.
|
||||
* SDL Audio Device IDs.
|
||||
*
|
||||
* A successful call to SDL_OpenAudio() is always device id 1, and legacy SDL
|
||||
* audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
|
||||
* always returns devices >= 2 on success. The legacy calls are good both for
|
||||
* backwards compatibility and when you don't care about multiple, specific,
|
||||
* or capture devices.
|
||||
* A successful call to SDL_OpenAudio() is always device id 1, and legacy
|
||||
* SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
|
||||
* always returns devices >= 2 on success. The legacy calls are good both
|
||||
* for backwards compatibility and when you don't care about multiple,
|
||||
* specific, or capture devices.
|
||||
*/
|
||||
typedef Uint32 SDL_AudioDeviceID;
|
||||
|
||||
@@ -449,7 +452,7 @@ typedef Uint32 SDL_AudioDeviceID;
|
||||
* ```
|
||||
*
|
||||
* \param iscapture zero to request playback devices, non-zero to request
|
||||
* recording devices.
|
||||
* recording devices
|
||||
* \returns the number of available devices exposed by the current driver or
|
||||
* -1 if an explicit list of devices can't be determined. A return
|
||||
* value of -1 does not necessarily mean an error condition.
|
||||
@@ -475,7 +478,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
|
||||
* invalid next time any of several other SDL functions are called.
|
||||
*
|
||||
* \param index the index of the audio device; valid values range from 0 to
|
||||
* SDL_GetNumAudioDevices() - 1.
|
||||
* SDL_GetNumAudioDevices() - 1
|
||||
* \param iscapture non-zero to query the list of recording devices, zero to
|
||||
* query the list of output devices.
|
||||
* \returns the name of the audio device at the requested index, or NULL on
|
||||
@@ -501,11 +504,11 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
|
||||
* count.
|
||||
*
|
||||
* \param index the index of the audio device; valid values range from 0 to
|
||||
* SDL_GetNumAudioDevices() - 1.
|
||||
* SDL_GetNumAudioDevices() - 1
|
||||
* \param iscapture non-zero to query the list of recording devices, zero to
|
||||
* query the list of output devices.
|
||||
* \param spec The SDL_AudioSpec to be initialized by this function.
|
||||
* \returns 0 on success, nonzero on error.
|
||||
* \returns 0 on success, nonzero on error
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*
|
||||
@@ -539,7 +542,7 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
|
||||
* \param spec The SDL_AudioSpec to be initialized by this function.
|
||||
* \param iscapture non-zero to query the default recording device, zero to
|
||||
* query the default output device.
|
||||
* \returns 0 on success, nonzero on error.
|
||||
* \returns 0 on success, nonzero on error
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*
|
||||
@@ -642,13 +645,13 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
|
||||
* driver-specific name as appropriate. NULL requests the most
|
||||
* reasonable default device.
|
||||
* \param iscapture non-zero to specify a device should be opened for
|
||||
* recording, not playback.
|
||||
* recording, not playback
|
||||
* \param desired an SDL_AudioSpec structure representing the desired output
|
||||
* format; see SDL_OpenAudio() for more information.
|
||||
* format; see SDL_OpenAudio() for more information
|
||||
* \param obtained an SDL_AudioSpec structure filled in with the actual output
|
||||
* format; see SDL_OpenAudio() for more information.
|
||||
* \param allowed_changes 0, or one or more flags OR'd together.
|
||||
* \returns a valid device ID > 0 on success or 0 on failure; call
|
||||
* format; see SDL_OpenAudio() for more information
|
||||
* \param allowed_changes 0, or one or more flags OR'd together
|
||||
* \returns a valid device ID that is > 0 on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* For compatibility with SDL 1.2, this will never return 1, since
|
||||
@@ -709,7 +712,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
|
||||
* Use this function to get the current audio state of an audio device.
|
||||
*
|
||||
* \param dev the ID of an audio device previously opened with
|
||||
* SDL_OpenAudioDevice().
|
||||
* SDL_OpenAudioDevice()
|
||||
* \returns the SDL_AudioStatus of the specified audio device.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -742,7 +745,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDevice
|
||||
*
|
||||
* ...and is only useful if you used the legacy SDL_OpenAudio() function.
|
||||
*
|
||||
* \param pause_on non-zero to pause, 0 to unpause.
|
||||
* \param pause_on non-zero to pause, 0 to unpause
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -772,8 +775,8 @@ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
|
||||
* callback, you shouldn't pause the audio device, as it will lead to dropouts
|
||||
* in the audio playback. Instead, you should use SDL_LockAudioDevice().
|
||||
*
|
||||
* \param dev a device opened by SDL_OpenAudioDevice().
|
||||
* \param pause_on non-zero to pause, 0 to unpause.
|
||||
* \param dev a device opened by SDL_OpenAudioDevice()
|
||||
* \param pause_on non-zero to pause, 0 to unpause
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -838,14 +841,14 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
|
||||
* SDL_LoadWAV("sample.wav", &spec, &buf, &len);
|
||||
* ```
|
||||
*
|
||||
* \param src The data source for the WAVE data.
|
||||
* \param freesrc If non-zero, SDL will _always_ free the data source.
|
||||
* \param src The data source for the WAVE data
|
||||
* \param freesrc If non-zero, SDL will _always_ free the data source
|
||||
* \param spec An SDL_AudioSpec that will be filled in with the wave file's
|
||||
* format details.
|
||||
* format details
|
||||
* \param audio_buf A pointer filled with the audio data, allocated by the
|
||||
* function.
|
||||
* \param audio_len A pointer filled with the length of the audio data buffer
|
||||
* in bytes.
|
||||
* in bytes
|
||||
* \returns This function, if successfully called, returns `spec`, which will
|
||||
* be filled with the audio data format of the wave source data.
|
||||
* `audio_buf` will be filled with a pointer to an allocated buffer
|
||||
@@ -871,9 +874,8 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
|
||||
Uint32 * audio_len);
|
||||
|
||||
/**
|
||||
* Loads a WAV from a file.
|
||||
*
|
||||
* Compatibility convenience function.
|
||||
* Loads a WAV from a file.
|
||||
* Compatibility convenience function.
|
||||
*/
|
||||
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
|
||||
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
|
||||
@@ -886,7 +888,7 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
|
||||
* this function with a NULL pointer.
|
||||
*
|
||||
* \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
|
||||
* SDL_LoadWAV_RW().
|
||||
* SDL_LoadWAV_RW()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -910,16 +912,15 @@ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
|
||||
* and then can call SDL_ConvertAudio() to complete the conversion.
|
||||
*
|
||||
* \param cvt an SDL_AudioCVT structure filled in with audio conversion
|
||||
* information.
|
||||
* information
|
||||
* \param src_format the source format of the audio data; for more info see
|
||||
* SDL_AudioFormat.
|
||||
* \param src_channels the number of channels in the source.
|
||||
* \param src_rate the frequency (sample-frames-per-second) of the source.
|
||||
* SDL_AudioFormat
|
||||
* \param src_channels the number of channels in the source
|
||||
* \param src_rate the frequency (sample-frames-per-second) of the source
|
||||
* \param dst_format the destination format of the audio data; for more info
|
||||
* see SDL_AudioFormat.
|
||||
* \param dst_channels the number of channels in the destination.
|
||||
* \param dst_rate the frequency (sample-frames-per-second) of the
|
||||
* destination.
|
||||
* see SDL_AudioFormat
|
||||
* \param dst_channels the number of channels in the destination
|
||||
* \param dst_rate the frequency (sample-frames-per-second) of the destination
|
||||
* \returns 1 if the audio filter is prepared, 0 if no conversion is needed,
|
||||
* or a negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
@@ -990,12 +991,12 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
|
||||
/**
|
||||
* Create a new audio stream.
|
||||
*
|
||||
* \param src_format The format of the source audio.
|
||||
* \param src_channels The number of channels of the source audio.
|
||||
* \param src_rate The sampling rate of the source audio.
|
||||
* \param dst_format The format of the desired audio output.
|
||||
* \param dst_channels The number of channels of the desired audio output.
|
||||
* \param dst_rate The sampling rate of the desired audio output.
|
||||
* \param src_format The format of the source audio
|
||||
* \param src_channels The number of channels of the source audio
|
||||
* \param src_rate The sampling rate of the source audio
|
||||
* \param dst_format The format of the desired audio output
|
||||
* \param dst_channels The number of channels of the desired audio output
|
||||
* \param dst_rate The sampling rate of the desired audio output
|
||||
* \returns 0 on success, or -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
@@ -1017,9 +1018,9 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm
|
||||
/**
|
||||
* Add data to be converted/resampled to the stream.
|
||||
*
|
||||
* \param stream The stream the audio data is being added to.
|
||||
* \param buf A pointer to the audio data to add.
|
||||
* \param len The number of bytes to write to the stream.
|
||||
* \param stream The stream the audio data is being added to
|
||||
* \param buf A pointer to the audio data to add
|
||||
* \param len The number of bytes to write to the stream
|
||||
* \returns 0 on success, or -1 on error.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
@@ -1036,10 +1037,10 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const vo
|
||||
/**
|
||||
* Get converted/resampled data from the stream
|
||||
*
|
||||
* \param stream The stream the audio is being requested from.
|
||||
* \param buf A buffer to fill with audio data.
|
||||
* \param len The maximum number of bytes to fill.
|
||||
* \returns the number of bytes read from the stream, or -1 on error.
|
||||
* \param stream The stream the audio is being requested from
|
||||
* \param buf A buffer to fill with audio data
|
||||
* \param len The maximum number of bytes to fill
|
||||
* \returns the number of bytes read from the stream, or -1 on error
|
||||
*
|
||||
* \since This function is available since SDL 2.0.7.
|
||||
*
|
||||
@@ -1117,9 +1118,6 @@ extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
|
||||
|
||||
/**
|
||||
* Maximum volume allowed in calls to SDL_MixAudio and SDL_MixAudioFormat.
|
||||
*/
|
||||
#define SDL_MIX_MAXVOLUME 128
|
||||
|
||||
/**
|
||||
@@ -1134,11 +1132,11 @@ extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
|
||||
* ...where `format` is the obtained format of the audio device from the
|
||||
* legacy SDL_OpenAudio() function.
|
||||
*
|
||||
* \param dst the destination for the mixed audio.
|
||||
* \param src the source audio buffer to be mixed.
|
||||
* \param len the length of the audio buffer in bytes.
|
||||
* \param dst the destination for the mixed audio
|
||||
* \param src the source audio buffer to be mixed
|
||||
* \param len the length of the audio buffer in bytes
|
||||
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
|
||||
* for full audio volume.
|
||||
* for full audio volume
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1167,13 +1165,13 @@ extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
|
||||
* SDL_MixAudioFormat() is really only needed when you're mixing a single
|
||||
* audio stream with a volume adjustment.
|
||||
*
|
||||
* \param dst the destination for the mixed audio.
|
||||
* \param src the source audio buffer to be mixed.
|
||||
* \param dst the destination for the mixed audio
|
||||
* \param src the source audio buffer to be mixed
|
||||
* \param format the SDL_AudioFormat structure representing the desired audio
|
||||
* format.
|
||||
* \param len the length of the audio buffer in bytes.
|
||||
* format
|
||||
* \param len the length of the audio buffer in bytes
|
||||
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
|
||||
* for full audio volume.
|
||||
* for full audio volume
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*/
|
||||
@@ -1217,9 +1215,9 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
|
||||
* from planar audio formats into a non-planar one (see SDL_AudioFormat)
|
||||
* before queuing audio.
|
||||
*
|
||||
* \param dev the device ID to which we will queue audio.
|
||||
* \param data the data to queue to the device for later playback.
|
||||
* \param len the number of bytes (not samples!) to which `data` points.
|
||||
* \param dev the device ID to which we will queue audio
|
||||
* \param data the data to queue to the device for later playback
|
||||
* \param len the number of bytes (not samples!) to which `data` points
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -1265,9 +1263,9 @@ extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *da
|
||||
* You should not call SDL_LockAudio() on the device before dequeueing; SDL
|
||||
* handles locking internally for this function.
|
||||
*
|
||||
* \param dev the device ID from which we will dequeue audio.
|
||||
* \param data a pointer into where audio data should be copied.
|
||||
* \param len the number of bytes (not samples!) to which (data) points.
|
||||
* \param dev the device ID from which we will dequeue audio
|
||||
* \param data a pointer into where audio data should be copied
|
||||
* \param len the number of bytes (not samples!) to which (data) points
|
||||
* \returns the number of bytes dequeued, which could be less than requested;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -1301,7 +1299,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *dat
|
||||
* You should not call SDL_LockAudio() on the device before querying; SDL
|
||||
* handles locking internally for this function.
|
||||
*
|
||||
* \param dev the device ID of which we will query queued audio size.
|
||||
* \param dev the device ID of which we will query queued audio size
|
||||
* \returns the number of bytes (not samples!) of queued audio.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
@@ -1336,7 +1334,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
|
||||
*
|
||||
* This function always succeeds and thus returns void.
|
||||
*
|
||||
* \param dev the device ID of which to clear the audio queue.
|
||||
* \param dev the device ID of which to clear the audio queue
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*
|
||||
@@ -1408,7 +1406,7 @@ extern DECLSPEC void SDLCALL SDL_LockAudio(void);
|
||||
* at once, not only will you block the audio callback, you'll block the other
|
||||
* thread.
|
||||
*
|
||||
* \param dev the ID of the device to be locked.
|
||||
* \param dev the ID of the device to be locked
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1441,7 +1439,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
|
||||
*
|
||||
* This function should be paired with a previous SDL_LockAudioDevice() call.
|
||||
*
|
||||
* \param dev the ID of the device to be unlocked.
|
||||
* \param dev the ID of the device to be unlocked
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1483,7 +1481,7 @@ extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
|
||||
* The device ID is invalid as soon as the device is closed, and is eligible
|
||||
* for reuse in a new SDL_OpenAudioDevice() call immediately.
|
||||
*
|
||||
* \param dev an audio device previously opened with SDL_OpenAudioDevice().
|
||||
* \param dev an audio device previously opened with SDL_OpenAudioDevice()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryBits
|
||||
* \file SDL_bits.h
|
||||
*
|
||||
* Functions for fiddling with bits and bitmasks.
|
||||
* Functions for fiddling with bits and bitmasks.
|
||||
*/
|
||||
|
||||
#ifndef SDL_bits_h_
|
||||
@@ -56,12 +56,6 @@ extern __inline int _SDL_bsr_watcom(Uint32);
|
||||
modify exact [eax] nomemory;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Use this function to get the index of the most significant (set) bit in a
|
||||
*
|
||||
* \param x the number to find the MSB of.
|
||||
* \returns the index of the most significant bit of x, or -1 if x is 0.
|
||||
*/
|
||||
SDL_FORCE_INLINE int
|
||||
SDL_MostSignificantBitIndex32(Uint32 x)
|
||||
{
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryBlendmode
|
||||
* \file SDL_blendmode.h
|
||||
*
|
||||
* Header file declaring the SDL_BlendMode enumeration
|
||||
* Header file declaring the SDL_BlendMode enumeration
|
||||
*/
|
||||
|
||||
#ifndef SDL_blendmode_h_
|
||||
@@ -35,9 +35,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The blend mode used in SDL_RenderCopy() and drawing operations.
|
||||
* \brief The blend mode used in SDL_RenderCopy() and drawing operations.
|
||||
*/
|
||||
typedef enum SDL_BlendMode
|
||||
typedef enum
|
||||
{
|
||||
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
|
||||
dstRGBA = srcRGBA */
|
||||
@@ -60,10 +60,9 @@ typedef enum SDL_BlendMode
|
||||
} SDL_BlendMode;
|
||||
|
||||
/**
|
||||
* The blend operation used when combining source and destination pixel
|
||||
* components
|
||||
* \brief The blend operation used when combining source and destination pixel components
|
||||
*/
|
||||
typedef enum SDL_BlendOperation
|
||||
typedef enum
|
||||
{
|
||||
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
|
||||
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
|
||||
@@ -73,9 +72,9 @@ typedef enum SDL_BlendOperation
|
||||
} SDL_BlendOperation;
|
||||
|
||||
/**
|
||||
* The normalized factor used to multiply pixel components
|
||||
* \brief The normalized factor used to multiply pixel components
|
||||
*/
|
||||
typedef enum SDL_BlendFactor
|
||||
typedef enum
|
||||
{
|
||||
SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */
|
||||
SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */
|
||||
@@ -159,18 +158,18 @@ typedef enum SDL_BlendFactor
|
||||
* case.
|
||||
*
|
||||
* \param srcColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||
* blue components of the source pixels.
|
||||
* blue components of the source pixels
|
||||
* \param dstColorFactor the SDL_BlendFactor applied to the red, green, and
|
||||
* blue components of the destination pixels.
|
||||
* blue components of the destination pixels
|
||||
* \param colorOperation the SDL_BlendOperation used to combine the red,
|
||||
* green, and blue components of the source and
|
||||
* destination pixels.
|
||||
* destination pixels
|
||||
* \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||
* the source pixels.
|
||||
* the source pixels
|
||||
* \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of
|
||||
* the destination pixels.
|
||||
* the destination pixels
|
||||
* \param alphaOperation the SDL_BlendOperation used to combine the alpha
|
||||
* component of the source and destination pixels.
|
||||
* component of the source and destination pixels
|
||||
* \returns an SDL_BlendMode that represents the chosen factors and
|
||||
* operations.
|
||||
*
|
||||
|
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryClipboard
|
||||
* \file SDL_clipboard.h
|
||||
*
|
||||
* Include file for SDL clipboard handling
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
/**
|
||||
* Put UTF-8 text into the clipboard.
|
||||
*
|
||||
* \param text the text to store in the clipboard.
|
||||
* \param text the text to store in the clipboard
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -85,7 +85,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
|
||||
/**
|
||||
* Put UTF-8 text into the primary selection.
|
||||
*
|
||||
* \param text the text to store in the primary selection.
|
||||
* \param text the text to store in the primary selection
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
|
@@ -24,7 +24,9 @@
|
||||
|
||||
#include "SDL_platform.h"
|
||||
|
||||
/* WIKI CATEGORY: - */
|
||||
/**
|
||||
* \file SDL_config.h
|
||||
*/
|
||||
|
||||
/* Add any platform that doesn't build using the configure system. */
|
||||
#if defined(__WIN32__)
|
||||
|
@@ -193,7 +193,6 @@
|
||||
#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,7 +195,6 @@
|
||||
#undef HAVE_FSEEKO
|
||||
#undef HAVE_FSEEKO64
|
||||
#undef HAVE_SIGACTION
|
||||
#undef HAVE_SIGTIMEDWAIT
|
||||
#undef HAVE_SA_SIGACTION
|
||||
#undef HAVE_SETJMP
|
||||
#undef HAVE_NANOSLEEP
|
||||
@@ -217,7 +216,6 @@
|
||||
#undef HAVE__EXIT
|
||||
|
||||
#else
|
||||
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDDEF_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
|
@@ -19,16 +19,10 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* WIKI CATEGORY: CPUInfo */
|
||||
|
||||
/**
|
||||
* # CategoryCPUInfo
|
||||
* \file SDL_cpuinfo.h
|
||||
*
|
||||
* CPU feature detection for SDL.
|
||||
*
|
||||
* These functions are largely concerned with reporting if the system has
|
||||
* access to various SIMD instruction sets, but also has other important info
|
||||
* to share, such as number of logical CPU cores.
|
||||
* CPU feature detection for SDL.
|
||||
*/
|
||||
|
||||
#ifndef SDL_cpuinfo_h_
|
||||
@@ -115,8 +109,7 @@ _m_prefetch(void *__P)
|
||||
#include <lasxintrin.h>
|
||||
#define __LASX__
|
||||
#endif
|
||||
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) && \
|
||||
(defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86))
|
||||
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
|
||||
#include <immintrin.h>
|
||||
#else
|
||||
#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
|
||||
|
@@ -19,10 +19,11 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is a simple file to encapsulate the EGL API headers.
|
||||
/**
|
||||
* \file SDL_egl.h
|
||||
*
|
||||
* This is a simple file to encapsulate the EGL API headers.
|
||||
*/
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(__ANDROID__) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)
|
||||
|
||||
#if defined(__vita__) || defined(__psp2__)
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryEndian
|
||||
* \file SDL_endian.h
|
||||
*
|
||||
* Functions for reading and writing endian-specific values
|
||||
* Functions for reading and writing endian-specific values
|
||||
*/
|
||||
|
||||
#ifndef SDL_endian_h_
|
||||
@@ -59,15 +59,6 @@ _m_prefetch(void *__P)
|
||||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER __BYTE_ORDER
|
||||
#elif defined(__sun) && defined(__SVR4) /* Solaris */
|
||||
#include <sys/byteorder.h>
|
||||
#if defined(_LITTLE_ENDIAN)
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
#elif defined(_BIG_ENDIAN)
|
||||
#define SDL_BYTEORDER SDL_BIG_ENDIAN
|
||||
#else
|
||||
#error Unsupported endianness
|
||||
#endif
|
||||
#elif defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER BYTE_ORDER
|
||||
@@ -88,7 +79,7 @@ _m_prefetch(void *__P)
|
||||
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
|
||||
(defined(__MIPS__) && defined(__MIPSEB__)) || \
|
||||
defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \
|
||||
defined(__sparc__) || defined(__sparc)
|
||||
defined(__sparc__)
|
||||
#define SDL_BYTEORDER SDL_BIG_ENDIAN
|
||||
#else
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
@@ -189,16 +180,6 @@ extern __inline Uint16 SDL_Swap16(Uint16);
|
||||
parm [ax] \
|
||||
modify [ax];
|
||||
#else
|
||||
|
||||
/**
|
||||
* Use this function to swap the byte order of a 16-bit value.
|
||||
*
|
||||
* \param x the value to be swapped.
|
||||
* \returns the swapped value.
|
||||
*
|
||||
* \sa SDL_SwapBE16
|
||||
* \sa SDL_SwapLE16
|
||||
*/
|
||||
SDL_FORCE_INLINE Uint16
|
||||
SDL_Swap16(Uint16 x)
|
||||
{
|
||||
@@ -250,16 +231,6 @@ extern __inline Uint32 SDL_Swap32(Uint32);
|
||||
parm [eax] \
|
||||
modify [eax];
|
||||
#else
|
||||
|
||||
/**
|
||||
* Use this function to swap the byte order of a 32-bit value.
|
||||
*
|
||||
* \param x the value to be swapped.
|
||||
* \returns the swapped value.
|
||||
*
|
||||
* \sa SDL_SwapBE32
|
||||
* \sa SDL_SwapLE32
|
||||
*/
|
||||
SDL_FORCE_INLINE Uint32
|
||||
SDL_Swap32(Uint32 x)
|
||||
{
|
||||
@@ -305,16 +276,6 @@ extern __inline Uint64 SDL_Swap64(Uint64);
|
||||
parm [eax edx] \
|
||||
modify [eax edx];
|
||||
#else
|
||||
|
||||
/**
|
||||
* Use this function to swap the byte order of a 64-bit value.
|
||||
*
|
||||
* \param x the value to be swapped.
|
||||
* \returns the swapped value.
|
||||
*
|
||||
* \sa SDL_SwapBE64
|
||||
* \sa SDL_SwapLE64
|
||||
*/
|
||||
SDL_FORCE_INLINE Uint64
|
||||
SDL_Swap64(Uint64 x)
|
||||
{
|
||||
@@ -332,15 +293,6 @@ SDL_Swap64(Uint64 x)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Use this function to swap the byte order of a floating point value.
|
||||
*
|
||||
* \param x the value to be swapped.
|
||||
* \returns the swapped value.
|
||||
*
|
||||
* \sa SDL_SwapFloatBE
|
||||
* \sa SDL_SwapFloatLE
|
||||
*/
|
||||
SDL_FORCE_INLINE float
|
||||
SDL_SwapFloat(float x)
|
||||
{
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryError
|
||||
* \file SDL_error.h
|
||||
*
|
||||
* Simple error message routines for SDL.
|
||||
* Simple error message routines for SDL.
|
||||
*/
|
||||
|
||||
#ifndef SDL_error_h_
|
||||
@@ -53,9 +53,9 @@ extern "C" {
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* \param fmt a printf()-style message format string.
|
||||
* \param fmt a printf()-style message format string
|
||||
* \param ... additional parameters matching % tokens in the `fmt` string, if
|
||||
* any.
|
||||
* any
|
||||
* \returns always -1.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -109,8 +109,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetError(void);
|
||||
* otherwise operates exactly the same as SDL_GetError().
|
||||
*
|
||||
* \param errstr A buffer to fill with the last error message that was set for
|
||||
* the current thread.
|
||||
* \param maxlen The size of the buffer pointed to by the errstr parameter.
|
||||
* the current thread
|
||||
* \param maxlen The size of the buffer pointed to by the errstr parameter
|
||||
* \returns the pointer passed in as the `errstr` parameter.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryEvents
|
||||
* \file SDL_events.h
|
||||
*
|
||||
* Include file for SDL event handling.
|
||||
* Include file for SDL event handling.
|
||||
*/
|
||||
|
||||
#ifndef SDL_events_h_
|
||||
@@ -52,7 +52,7 @@ extern "C" {
|
||||
/**
|
||||
* The types of events that can be delivered.
|
||||
*/
|
||||
typedef enum SDL_EventType
|
||||
typedef enum
|
||||
{
|
||||
SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
|
||||
|
||||
@@ -167,7 +167,7 @@ typedef enum SDL_EventType
|
||||
/* Internal events */
|
||||
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
|
||||
|
||||
/** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
|
||||
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
|
||||
* and should be allocated with SDL_RegisterEvents()
|
||||
*/
|
||||
SDL_USEREVENT = 0x8000,
|
||||
@@ -179,7 +179,7 @@ typedef enum SDL_EventType
|
||||
} SDL_EventType;
|
||||
|
||||
/**
|
||||
* Fields shared by every event
|
||||
* \brief Fields shared by every event
|
||||
*/
|
||||
typedef struct SDL_CommonEvent
|
||||
{
|
||||
@@ -188,14 +188,14 @@ typedef struct SDL_CommonEvent
|
||||
} SDL_CommonEvent;
|
||||
|
||||
/**
|
||||
* Display state change event data (event.display.*)
|
||||
* \brief Display state change event data (event.display.*)
|
||||
*/
|
||||
typedef struct SDL_DisplayEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_DISPLAYEVENT */
|
||||
Uint32 type; /**< ::SDL_DISPLAYEVENT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 display; /**< The associated display index */
|
||||
Uint8 event; /**< SDL_DisplayEventID */
|
||||
Uint8 event; /**< ::SDL_DisplayEventID */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
@@ -203,14 +203,14 @@ typedef struct SDL_DisplayEvent
|
||||
} SDL_DisplayEvent;
|
||||
|
||||
/**
|
||||
* Window state change event data (event.window.*)
|
||||
* \brief Window state change event data (event.window.*)
|
||||
*/
|
||||
typedef struct SDL_WindowEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_WINDOWEVENT */
|
||||
Uint32 type; /**< ::SDL_WINDOWEVENT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The associated window */
|
||||
Uint8 event; /**< SDL_WindowEventID */
|
||||
Uint8 event; /**< ::SDL_WindowEventID */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
@@ -219,14 +219,14 @@ typedef struct SDL_WindowEvent
|
||||
} SDL_WindowEvent;
|
||||
|
||||
/**
|
||||
* Keyboard button event structure (event.key.*)
|
||||
* \brief Keyboard button event structure (event.key.*)
|
||||
*/
|
||||
typedef struct SDL_KeyboardEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_KEYDOWN or SDL_KEYUP */
|
||||
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
@@ -234,13 +234,12 @@ typedef struct SDL_KeyboardEvent
|
||||
} SDL_KeyboardEvent;
|
||||
|
||||
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
|
||||
|
||||
/**
|
||||
* Keyboard text editing event structure (event.edit.*)
|
||||
* \brief Keyboard text editing event structure (event.edit.*)
|
||||
*/
|
||||
typedef struct SDL_TextEditingEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_TEXTEDITING */
|
||||
Uint32 type; /**< ::SDL_TEXTEDITING */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
|
||||
@@ -249,12 +248,12 @@ typedef struct SDL_TextEditingEvent
|
||||
} SDL_TextEditingEvent;
|
||||
|
||||
/**
|
||||
* Extended keyboard text editing event structure (event.editExt.*) when text
|
||||
* would be truncated if stored in the text buffer SDL_TextEditingEvent
|
||||
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be
|
||||
* truncated if stored in the text buffer SDL_TextEditingEvent
|
||||
*/
|
||||
typedef struct SDL_TextEditingExtEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_TEXTEDITING_EXT */
|
||||
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
|
||||
@@ -262,43 +261,24 @@ typedef struct SDL_TextEditingExtEvent
|
||||
Sint32 length; /**< The length of selected editing text */
|
||||
} SDL_TextEditingExtEvent;
|
||||
|
||||
/**
|
||||
* The maximum bytes of text that can be supplied in an SDL_TextInputEvent.
|
||||
*/
|
||||
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
|
||||
|
||||
/**
|
||||
* Keyboard text input event structure (event.text.*)
|
||||
*
|
||||
* `text` is limited to SDL_TEXTINPUTEVENT_TEXT_SIZE bytes. If the incoming
|
||||
* string is larger than this, SDL will split it and send it in pieces, across
|
||||
* multiple events. The string is in UTF-8 format, and if split, SDL
|
||||
* guarantees that it will not split in the middle of a UTF-8 sequence, so any
|
||||
* event will only contain complete codepoints. However, if there are several
|
||||
* codepoints that go together into a single glyph (like an emoji "thumbs up"
|
||||
* followed by a skin color), they may be split between events.
|
||||
*
|
||||
* This event will never be delivered unless text input is enabled by calling
|
||||
* SDL_StartTextInput(). Text input is enabled by default on desktop
|
||||
* platforms, and disabled by default on mobile platforms!
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
* \sa SDL_StopTextInput
|
||||
* \brief Keyboard text input event structure (event.text.*)
|
||||
*/
|
||||
typedef struct SDL_TextInputEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_TEXTINPUT */
|
||||
Uint32 type; /**< ::SDL_TEXTINPUT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text; UTF-8 encoded. */
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
|
||||
} SDL_TextInputEvent;
|
||||
|
||||
/**
|
||||
* Mouse motion event structure (event.motion.*)
|
||||
* \brief Mouse motion event structure (event.motion.*)
|
||||
*/
|
||||
typedef struct SDL_MouseMotionEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_MOUSEMOTION */
|
||||
Uint32 type; /**< ::SDL_MOUSEMOTION */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
@@ -310,16 +290,16 @@ typedef struct SDL_MouseMotionEvent
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/**
|
||||
* Mouse button event structure (event.button.*)
|
||||
* \brief Mouse button event structure (event.button.*)
|
||||
*/
|
||||
typedef struct SDL_MouseButtonEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
|
||||
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
Uint8 button; /**< The mouse button index */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
|
||||
Uint8 padding1;
|
||||
Sint32 x; /**< X coordinate, relative to window */
|
||||
@@ -327,11 +307,11 @@ typedef struct SDL_MouseButtonEvent
|
||||
} SDL_MouseButtonEvent;
|
||||
|
||||
/**
|
||||
* Mouse wheel event structure (event.wheel.*)
|
||||
* \brief Mouse wheel event structure (event.wheel.*)
|
||||
*/
|
||||
typedef struct SDL_MouseWheelEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_MOUSEWHEEL */
|
||||
Uint32 type; /**< ::SDL_MOUSEWHEEL */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
|
||||
@@ -345,11 +325,11 @@ typedef struct SDL_MouseWheelEvent
|
||||
} SDL_MouseWheelEvent;
|
||||
|
||||
/**
|
||||
* Joystick axis motion event structure (event.jaxis.*)
|
||||
* \brief Joystick axis motion event structure (event.jaxis.*)
|
||||
*/
|
||||
typedef struct SDL_JoyAxisEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYAXISMOTION */
|
||||
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 axis; /**< The joystick axis index */
|
||||
@@ -361,11 +341,11 @@ typedef struct SDL_JoyAxisEvent
|
||||
} SDL_JoyAxisEvent;
|
||||
|
||||
/**
|
||||
* Joystick trackball motion event structure (event.jball.*)
|
||||
* \brief Joystick trackball motion event structure (event.jball.*)
|
||||
*/
|
||||
typedef struct SDL_JoyBallEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYBALLMOTION */
|
||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 ball; /**< The joystick trackball index */
|
||||
@@ -377,18 +357,18 @@ typedef struct SDL_JoyBallEvent
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/**
|
||||
* Joystick hat position change event structure (event.jhat.*)
|
||||
* \brief Joystick hat position change event structure (event.jhat.*)
|
||||
*/
|
||||
typedef struct SDL_JoyHatEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYHATMOTION */
|
||||
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 hat; /**< The joystick hat index */
|
||||
Uint8 value; /**< The hat position value.
|
||||
* \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
|
||||
* \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
|
||||
* \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
|
||||
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
||||
* \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
|
||||
* \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
|
||||
*
|
||||
* Note that zero means the POV is centered.
|
||||
*/
|
||||
@@ -397,51 +377,46 @@ typedef struct SDL_JoyHatEvent
|
||||
} SDL_JoyHatEvent;
|
||||
|
||||
/**
|
||||
* Joystick button event structure (event.jbutton.*)
|
||||
* \brief Joystick button event structure (event.jbutton.*)
|
||||
*/
|
||||
typedef struct SDL_JoyButtonEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
|
||||
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 button; /**< The joystick button index */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
/**
|
||||
* Joystick device event structure (event.jdevice.*)
|
||||
*
|
||||
* SDL will send JOYSTICK_ADDED events for devices that are already plugged in
|
||||
* during SDL_Init.
|
||||
*
|
||||
* \sa SDL_ControllerDeviceEvent
|
||||
* \brief Joystick device event structure (event.jdevice.*)
|
||||
*/
|
||||
typedef struct SDL_JoyDeviceEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED */
|
||||
Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
|
||||
} SDL_JoyDeviceEvent;
|
||||
|
||||
/**
|
||||
* Joysick battery level change event structure (event.jbattery.*)
|
||||
* \brief Joysick battery level change event structure (event.jbattery.*)
|
||||
*/
|
||||
typedef struct SDL_JoyBatteryEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_JOYBATTERYUPDATED */
|
||||
Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
SDL_JoystickPowerLevel level; /**< The joystick battery level */
|
||||
} SDL_JoyBatteryEvent;
|
||||
|
||||
/**
|
||||
* Game controller axis motion event structure (event.caxis.*)
|
||||
* \brief Game controller axis motion event structure (event.caxis.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerAxisEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_CONTROLLERAXISMOTION */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
|
||||
@@ -454,42 +429,36 @@ typedef struct SDL_ControllerAxisEvent
|
||||
|
||||
|
||||
/**
|
||||
* Game controller button event structure (event.cbutton.*)
|
||||
* \brief Game controller button event structure (event.cbutton.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerButtonEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 button; /**< The controller button (SDL_GameControllerButton) */
|
||||
Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_ControllerButtonEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Controller device event structure (event.cdevice.*)
|
||||
*
|
||||
* Joysticks that are supported game controllers receive both an
|
||||
* SDL_JoyDeviceEvent and an SDL_ControllerDeviceEvent.
|
||||
*
|
||||
* SDL will send CONTROLLERDEVICEADDED events for joysticks that are already
|
||||
* plugged in during SDL_Init() and are recognized as game controllers.
|
||||
* \brief Controller device event structure (event.cdevice.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerDeviceEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, or SDL_CONTROLLERSTEAMHANDLEUPDATED */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, ::SDL_CONTROLLERDEVICEREMAPPED, or ::SDL_CONTROLLERSTEAMHANDLEUPDATED */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
|
||||
} SDL_ControllerDeviceEvent;
|
||||
|
||||
/**
|
||||
* Game controller touchpad event structure (event.ctouchpad.*)
|
||||
* \brief Game controller touchpad event structure (event.ctouchpad.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerTouchpadEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_CONTROLLERTOUCHPADDOWN or SDL_CONTROLLERTOUCHPADMOTION or SDL_CONTROLLERTOUCHPADUP */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Sint32 touchpad; /**< The index of the touchpad */
|
||||
@@ -500,24 +469,24 @@ typedef struct SDL_ControllerTouchpadEvent
|
||||
} SDL_ControllerTouchpadEvent;
|
||||
|
||||
/**
|
||||
* Game controller sensor event structure (event.csensor.*)
|
||||
* \brief Game controller sensor event structure (event.csensor.*)
|
||||
*/
|
||||
typedef struct SDL_ControllerSensorEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_CONTROLLERSENSORUPDATE */
|
||||
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */
|
||||
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */
|
||||
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
|
||||
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
|
||||
} SDL_ControllerSensorEvent;
|
||||
|
||||
/**
|
||||
* Audio device event structure (event.adevice.*)
|
||||
* \brief Audio device event structure (event.adevice.*)
|
||||
*/
|
||||
typedef struct SDL_AudioDeviceEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_AUDIODEVICEADDED, or SDL_AUDIODEVICEREMOVED */
|
||||
Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
|
||||
Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
|
||||
@@ -528,11 +497,11 @@ typedef struct SDL_AudioDeviceEvent
|
||||
|
||||
|
||||
/**
|
||||
* Touch finger event structure (event.tfinger.*)
|
||||
* \brief Touch finger event structure (event.tfinger.*)
|
||||
*/
|
||||
typedef struct SDL_TouchFingerEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP */
|
||||
Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_FingerID fingerId;
|
||||
@@ -546,11 +515,11 @@ typedef struct SDL_TouchFingerEvent
|
||||
|
||||
|
||||
/**
|
||||
* Multiple Finger Gesture Event (event.mgesture.*)
|
||||
* \brief Multiple Finger Gesture Event (event.mgesture.*)
|
||||
*/
|
||||
typedef struct SDL_MultiGestureEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_MULTIGESTURE */
|
||||
Uint32 type; /**< ::SDL_MULTIGESTURE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
float dTheta;
|
||||
@@ -563,11 +532,11 @@ typedef struct SDL_MultiGestureEvent
|
||||
|
||||
|
||||
/**
|
||||
* Dollar Gesture Event (event.dgesture.*)
|
||||
* \brief Dollar Gesture Event (event.dgesture.*)
|
||||
*/
|
||||
typedef struct SDL_DollarGestureEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_DOLLARGESTURE or SDL_DOLLARRECORD */
|
||||
Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_GestureID gestureId;
|
||||
@@ -579,15 +548,13 @@ typedef struct SDL_DollarGestureEvent
|
||||
|
||||
|
||||
/**
|
||||
* An event used to request a file open by the system (event.drop.*)
|
||||
*
|
||||
* This event is enabled by default, you can disable it with SDL_EventState().
|
||||
*
|
||||
* If this event is enabled, you must free the filename in the event.
|
||||
* \brief An event used to request a file open by the system (event.drop.*)
|
||||
* This event is enabled by default, you can disable it with SDL_EventState().
|
||||
* \note If this event is enabled, you must free the filename in the event.
|
||||
*/
|
||||
typedef struct SDL_DropEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_DROPBEGIN or SDL_DROPFILE or SDL_DROPTEXT or SDL_DROPCOMPLETE */
|
||||
Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
|
||||
Uint32 windowID; /**< The window that was dropped on, if any */
|
||||
@@ -595,11 +562,11 @@ typedef struct SDL_DropEvent
|
||||
|
||||
|
||||
/**
|
||||
* Sensor event structure (event.sensor.*)
|
||||
* \brief Sensor event structure (event.sensor.*)
|
||||
*/
|
||||
typedef struct SDL_SensorEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_SENSORUPDATE */
|
||||
Uint32 type; /**< ::SDL_SENSORUPDATE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The instance ID of the sensor */
|
||||
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
|
||||
@@ -607,20 +574,20 @@ typedef struct SDL_SensorEvent
|
||||
} SDL_SensorEvent;
|
||||
|
||||
/**
|
||||
* The "quit requested" event
|
||||
* \brief The "quit requested" event
|
||||
*/
|
||||
typedef struct SDL_QuitEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_QUIT */
|
||||
Uint32 type; /**< ::SDL_QUIT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
} SDL_QuitEvent;
|
||||
|
||||
/**
|
||||
* A user-defined event type (event.user.*)
|
||||
* \brief A user-defined event type (event.user.*)
|
||||
*/
|
||||
typedef struct SDL_UserEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_USEREVENT through SDL_LASTEVENT-1 */
|
||||
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 windowID; /**< The associated window if any */
|
||||
Sint32 code; /**< User defined event code */
|
||||
@@ -633,24 +600,20 @@ struct SDL_SysWMmsg;
|
||||
typedef struct SDL_SysWMmsg SDL_SysWMmsg;
|
||||
|
||||
/**
|
||||
* A video driver dependent system event (event.syswm.*)
|
||||
* \brief A video driver dependent system event (event.syswm.*)
|
||||
* This event is disabled by default, you can enable it with SDL_EventState()
|
||||
*
|
||||
* This event is disabled by default, you can enable it with SDL_EventState()
|
||||
*
|
||||
* If you want to use this event, you should include SDL_syswm.h.
|
||||
* \note If you want to use this event, you should include SDL_syswm.h.
|
||||
*/
|
||||
typedef struct SDL_SysWMEvent
|
||||
{
|
||||
Uint32 type; /**< SDL_SYSWMEVENT */
|
||||
Uint32 type; /**< ::SDL_SYSWMEVENT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
|
||||
} SDL_SysWMEvent;
|
||||
|
||||
/**
|
||||
* General event structure
|
||||
*
|
||||
* The SDL_Event structure is the core of all event handling in SDL. SDL_Event
|
||||
* is a union of all event structures used in SDL.
|
||||
* \brief General event structure
|
||||
*/
|
||||
typedef union SDL_Event
|
||||
{
|
||||
@@ -733,7 +696,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NUL
|
||||
extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
|
||||
|
||||
/* @{ */
|
||||
typedef enum SDL_eventaction
|
||||
typedef enum
|
||||
{
|
||||
SDL_ADDEVENT,
|
||||
SDL_PEEKEVENT,
|
||||
@@ -760,15 +723,15 @@ typedef enum SDL_eventaction
|
||||
*
|
||||
* This function is thread-safe.
|
||||
*
|
||||
* \param events destination buffer for the retrieved events.
|
||||
* \param events destination buffer for the retrieved events
|
||||
* \param numevents if action is SDL_ADDEVENT, the number of events to add
|
||||
* back to the event queue; if action is SDL_PEEKEVENT or
|
||||
* SDL_GETEVENT, the maximum number of events to retrieve.
|
||||
* \param action action to take; see [[#action|Remarks]] for details.
|
||||
* SDL_GETEVENT, the maximum number of events to retrieve
|
||||
* \param action action to take; see [[#action|Remarks]] for details
|
||||
* \param minType minimum value of the event type to be considered;
|
||||
* SDL_FIRSTEVENT is a safe choice.
|
||||
* SDL_FIRSTEVENT is a safe choice
|
||||
* \param maxType maximum value of the event type to be considered;
|
||||
* SDL_LASTEVENT is a safe choice.
|
||||
* SDL_LASTEVENT is a safe choice
|
||||
* \returns the number of events actually stored or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -789,7 +752,7 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
|
||||
* If you need to check for a range of event types, use SDL_HasEvents()
|
||||
* instead.
|
||||
*
|
||||
* \param type the type of event to be queried; see SDL_EventType for details.
|
||||
* \param type the type of event to be queried; see SDL_EventType for details
|
||||
* \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
|
||||
* events matching `type` are not present.
|
||||
*
|
||||
@@ -806,9 +769,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
|
||||
* If you need to check for a single event type, use SDL_HasEvent() instead.
|
||||
*
|
||||
* \param minType the low end of event type to be queried, inclusive; see
|
||||
* SDL_EventType for details.
|
||||
* SDL_EventType for details
|
||||
* \param maxType the high end of event type to be queried, inclusive; see
|
||||
* SDL_EventType for details.
|
||||
* SDL_EventType for details
|
||||
* \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
|
||||
* present, or SDL_FALSE if not.
|
||||
*
|
||||
@@ -832,7 +795,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
|
||||
* sure that all pending OS events are flushed, you can call SDL_PumpEvents()
|
||||
* on the main thread immediately before the flush call.
|
||||
*
|
||||
* \param type the type of event to be cleared; see SDL_EventType for details.
|
||||
* \param type the type of event to be cleared; see SDL_EventType for details
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -855,9 +818,9 @@ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
|
||||
* on the main thread immediately before the flush call.
|
||||
*
|
||||
* \param minType the low end of event type to be cleared, inclusive; see
|
||||
* SDL_EventType for details.
|
||||
* SDL_EventType for details
|
||||
* \param maxType the high end of event type to be cleared, inclusive; see
|
||||
* SDL_EventType for details.
|
||||
* SDL_EventType for details
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -898,7 +861,7 @@ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
|
||||
* ```
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled with the next event from
|
||||
* the queue, or NULL.
|
||||
* the queue, or NULL
|
||||
* \returns 1 if there is a pending event or 0 if there are none available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -922,7 +885,7 @@ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
|
||||
* this function in the thread that initialized the video subsystem.
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled in with the next event
|
||||
* from the queue, or NULL.
|
||||
* from the queue, or NULL
|
||||
* \returns 1 on success or 0 if there was an error while waiting for events;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -945,9 +908,9 @@ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
|
||||
* this function in the thread that initialized the video subsystem.
|
||||
*
|
||||
* \param event the SDL_Event structure to be filled in with the next event
|
||||
* from the queue, or NULL.
|
||||
* from the queue, or NULL
|
||||
* \param timeout the maximum number of milliseconds to wait for the next
|
||||
* available event.
|
||||
* available event
|
||||
* \returns 1 on success or 0 if there was an error while waiting for events;
|
||||
* call SDL_GetError() for more information. This also returns 0 if
|
||||
* the timeout elapsed without an event arriving.
|
||||
@@ -982,7 +945,7 @@ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
|
||||
* get an event type that does not conflict with other code that also wants
|
||||
* its own custom event types.
|
||||
*
|
||||
* \param event the SDL_Event to be added to the queue.
|
||||
* \param event the SDL_Event to be added to the queue
|
||||
* \returns 1 on success, 0 if the event was filtered, or a negative error
|
||||
* code on failure; call SDL_GetError() for more information. A
|
||||
* common reason for error is the event queue being full.
|
||||
@@ -998,11 +961,11 @@ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
|
||||
/**
|
||||
* A function pointer used for callbacks that watch the event queue.
|
||||
*
|
||||
* \param userdata what was passed as `userdata` to SDL_SetEventFilter() or
|
||||
* SDL_AddEventWatch, etc.
|
||||
* \param event the event that triggered the callback.
|
||||
* \returns 1 to permit event to be added to the queue, and 0 to disallow it.
|
||||
* When used with SDL_AddEventWatch, the return value is ignored.
|
||||
* \param userdata what was passed as `userdata` to SDL_SetEventFilter()
|
||||
* or SDL_AddEventWatch, etc
|
||||
* \param event the event that triggered the callback
|
||||
* \returns 1 to permit event to be added to the queue, and 0 to disallow
|
||||
* it. When used with SDL_AddEventWatch, the return value is ignored.
|
||||
*
|
||||
* \sa SDL_SetEventFilter
|
||||
* \sa SDL_AddEventWatch
|
||||
@@ -1025,7 +988,7 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
|
||||
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
|
||||
* application at the next event poll.
|
||||
*
|
||||
* There is one caveat when dealing with the SDL_QuitEvent event type. The
|
||||
* There is one caveat when dealing with the ::SDL_QuitEvent event type. The
|
||||
* event filter is only called when the window manager desires to close the
|
||||
* application window. If the event filter returns 1, then the window will be
|
||||
* closed, otherwise the window will remain open if possible.
|
||||
@@ -1040,8 +1003,8 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
|
||||
* the event filter, but events pushed onto the queue with SDL_PeepEvents() do
|
||||
* not.
|
||||
*
|
||||
* \param filter An SDL_EventFilter function to call when an event happens.
|
||||
* \param userdata a pointer that is passed to `filter`.
|
||||
* \param filter An SDL_EventFilter function to call when an event happens
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1060,9 +1023,9 @@ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
|
||||
* This function can be used to "chain" filters, by saving the existing filter
|
||||
* before replacing it with a function that will call that saved filter.
|
||||
*
|
||||
* \param filter the current callback function will be stored here.
|
||||
* \param filter the current callback function will be stored here
|
||||
* \param userdata the pointer that is passed to the current event filter will
|
||||
* be stored here.
|
||||
* be stored here
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -1091,7 +1054,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
|
||||
* through SDL_PeepEvents().
|
||||
*
|
||||
* \param filter an SDL_EventFilter function to call when an event happens.
|
||||
* \param userdata a pointer that is passed to `filter`.
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1107,8 +1070,8 @@ extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
|
||||
* This function takes the same input as SDL_AddEventWatch() to identify and
|
||||
* delete the corresponding callback.
|
||||
*
|
||||
* \param filter the function originally passed to SDL_AddEventWatch().
|
||||
* \param userdata the pointer originally passed to SDL_AddEventWatch().
|
||||
* \param filter the function originally passed to SDL_AddEventWatch()
|
||||
* \param userdata the pointer originally passed to SDL_AddEventWatch()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1125,8 +1088,8 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
|
||||
* this function does not change the filter permanently, it only uses the
|
||||
* supplied filter until this function returns.
|
||||
*
|
||||
* \param filter the SDL_EventFilter function to call when an event happens.
|
||||
* \param userdata a pointer that is passed to `filter`.
|
||||
* \param filter the SDL_EventFilter function to call when an event happens
|
||||
* \param userdata a pointer that is passed to `filter`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1152,8 +1115,8 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
|
||||
* from the event queue and will not be filtered
|
||||
* - `SDL_ENABLE`: the event will be processed normally
|
||||
*
|
||||
* \param type the type of event; see SDL_EventType for details.
|
||||
* \param state how to process the event.
|
||||
* \param type the type of event; see SDL_EventType for details
|
||||
* \param state how to process the event
|
||||
* \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
|
||||
* of the event before this function makes any changes to it.
|
||||
*
|
||||
@@ -1175,7 +1138,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
|
||||
* Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
|
||||
* 0xFFFFFFFF), but is clearer to write.
|
||||
*
|
||||
* \param numevents the number of events to be allocated.
|
||||
* \param numevents the number of events to be allocated
|
||||
* \returns the beginning event number, or (Uint32)-1 if there are not enough
|
||||
* user-defined events left.
|
||||
*
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryFilesystem
|
||||
* \file SDL_filesystem.h
|
||||
*
|
||||
* Include file for filesystem SDL API functions
|
||||
* \brief Include file for filesystem SDL API functions
|
||||
*/
|
||||
|
||||
#ifndef SDL_filesystem_h_
|
||||
@@ -126,8 +126,8 @@ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
|
||||
* The pointer returned is owned by the caller. Please call SDL_free() on the
|
||||
* pointer when done with it.
|
||||
*
|
||||
* \param org the name of your organization.
|
||||
* \param app the name of your application.
|
||||
* \param org the name of your organization
|
||||
* \param app the name of your application
|
||||
* \returns a UTF-8 string of the user directory in platform-dependent
|
||||
* notation. NULL if there's a problem (creating directory failed,
|
||||
* etc.).
|
||||
|
@@ -19,12 +19,10 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* WIKI CATEGORY: GameController */
|
||||
|
||||
/**
|
||||
* # CategoryGameController
|
||||
* \file SDL_gamecontroller.h
|
||||
*
|
||||
* Include file for SDL game controller event handling
|
||||
* Include file for SDL game controller event handling
|
||||
*/
|
||||
|
||||
#ifndef SDL_gamecontroller_h_
|
||||
@@ -46,7 +44,7 @@ extern "C" {
|
||||
* \file SDL_gamecontroller.h
|
||||
*
|
||||
* In order to use these functions, SDL_Init() must have been called
|
||||
* with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
|
||||
* with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
|
||||
* for game controllers, and load appropriate drivers.
|
||||
*
|
||||
* If you would like to receive controller updates while the application
|
||||
@@ -60,7 +58,7 @@ extern "C" {
|
||||
struct _SDL_GameController;
|
||||
typedef struct _SDL_GameController SDL_GameController;
|
||||
|
||||
typedef enum SDL_GameControllerType
|
||||
typedef enum
|
||||
{
|
||||
SDL_CONTROLLER_TYPE_UNKNOWN = 0,
|
||||
SDL_CONTROLLER_TYPE_XBOX360,
|
||||
@@ -79,7 +77,7 @@ typedef enum SDL_GameControllerType
|
||||
SDL_CONTROLLER_TYPE_MAX
|
||||
} SDL_GameControllerType;
|
||||
|
||||
typedef enum SDL_GameControllerBindType
|
||||
typedef enum
|
||||
{
|
||||
SDL_CONTROLLER_BINDTYPE_NONE = 0,
|
||||
SDL_CONTROLLER_BINDTYPE_BUTTON,
|
||||
@@ -88,7 +86,7 @@ typedef enum SDL_GameControllerBindType
|
||||
} SDL_GameControllerBindType;
|
||||
|
||||
/**
|
||||
* Get the SDL joystick layer binding for this controller button/axis mapping
|
||||
* Get the SDL joystick layer binding for this controller button/axis mapping
|
||||
*/
|
||||
typedef struct SDL_GameControllerButtonBind
|
||||
{
|
||||
@@ -146,10 +144,6 @@ typedef struct SDL_GameControllerButtonBind
|
||||
* If a new mapping is loaded for an already known controller GUID, the later
|
||||
* version will overwrite the one currently loaded.
|
||||
*
|
||||
* If this function is called before SDL_Init, SDL will generate an
|
||||
* SDL_CONTROLLERDEVICEADDED event for matching controllers that are plugged
|
||||
* in at the time that SDL_Init is called.
|
||||
*
|
||||
* Mappings not belonging to the current platform or with no platform field
|
||||
* specified will be ignored (i.e. mappings for Linux will be ignored in
|
||||
* Windows, etc).
|
||||
@@ -158,8 +152,8 @@ typedef struct SDL_GameControllerButtonBind
|
||||
* processing it, so take this into consideration if you are in a memory
|
||||
* constrained environment.
|
||||
*
|
||||
* \param rw the data stream for the mappings to be added.
|
||||
* \param freerw non-zero to close the stream after being read.
|
||||
* \param rw the data stream for the mappings to be added
|
||||
* \param freerw non-zero to close the stream after being read
|
||||
* \returns the number of mappings added or -1 on error; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
@@ -168,15 +162,13 @@ typedef struct SDL_GameControllerButtonBind
|
||||
* \sa SDL_GameControllerAddMapping
|
||||
* \sa SDL_GameControllerAddMappingsFromFile
|
||||
* \sa SDL_GameControllerMappingForGUID
|
||||
* \sa SDL_CONTROLLERDEVICEADDED
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
||||
|
||||
/**
|
||||
* Load a set of mappings from a file, filtered by the current
|
||||
* SDL_GetPlatform()
|
||||
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
|
||||
*
|
||||
* Convenience macro.
|
||||
* Convenience macro.
|
||||
*/
|
||||
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
|
||||
|
||||
@@ -198,11 +190,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
|
||||
* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
|
||||
* ```
|
||||
*
|
||||
* If this function is called before SDL_Init, SDL will generate an
|
||||
* SDL_CONTROLLERDEVICEADDED event for matching controllers that are plugged
|
||||
* in at the time that SDL_Init is called.
|
||||
*
|
||||
* \param mappingString the mapping string.
|
||||
* \param mappingString the mapping string
|
||||
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
|
||||
* -1 on error; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -210,7 +198,6 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
|
||||
*
|
||||
* \sa SDL_GameControllerMapping
|
||||
* \sa SDL_GameControllerMappingForGUID
|
||||
* \sa SDL_CONTROLLERDEVICEADDED
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
|
||||
|
||||
@@ -238,7 +225,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_ind
|
||||
*
|
||||
* The returned string must be freed with SDL_free().
|
||||
*
|
||||
* \param guid a structure containing the GUID for which a mapping is desired.
|
||||
* \param guid a structure containing the GUID for which a mapping is desired
|
||||
* \returns a mapping string or NULL on error; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
@@ -257,7 +244,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID
|
||||
* Details about mappings are discussed with SDL_GameControllerAddMapping().
|
||||
*
|
||||
* \param gamecontroller the game controller you want to get the current
|
||||
* mapping for.
|
||||
* mapping for
|
||||
* \returns a string that has the controller's mapping or NULL if no mapping
|
||||
* is available; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -275,7 +262,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gam
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick_index the device_index of a device, up to
|
||||
* SDL_NumJoysticks().
|
||||
* SDL_NumJoysticks()
|
||||
* \returns SDL_TRUE if the given joystick is supported by the game controller
|
||||
* interface, SDL_FALSE if it isn't or it's an invalid index.
|
||||
*
|
||||
@@ -295,7 +282,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1.
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the implementation-dependent name for the game controller, or NULL
|
||||
* if there is no name or the index is invalid.
|
||||
*
|
||||
@@ -316,7 +303,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_
|
||||
* SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1.
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the implementation-dependent path for the game controller, or NULL
|
||||
* if there is no path or the index is invalid.
|
||||
*
|
||||
@@ -332,7 +319,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_
|
||||
* This can be called before any controllers are opened.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1.
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the controller type.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.12.
|
||||
@@ -345,7 +332,7 @@ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(in
|
||||
* This can be called before any controllers are opened.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, from zero to
|
||||
* SDL_NumJoysticks()-1.
|
||||
* SDL_NumJoysticks()-1
|
||||
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
||||
* no mapping is available.
|
||||
*
|
||||
@@ -365,7 +352,7 @@ extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joysti
|
||||
* be used there instead.
|
||||
*
|
||||
* \param joystick_index the device_index of a device, up to
|
||||
* SDL_NumJoysticks().
|
||||
* SDL_NumJoysticks()
|
||||
* \returns a gamecontroller identifier or NULL if an error occurred; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -380,7 +367,7 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_
|
||||
/**
|
||||
* Get the SDL_GameController associated with an instance id.
|
||||
*
|
||||
* \param joyid the instance id to get the SDL_GameController for.
|
||||
* \param joyid the instance id to get the SDL_GameController for
|
||||
* \returns an SDL_GameController on success or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -412,7 +399,7 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(in
|
||||
* it takes a controller identifier instead of the (unstable) device index.
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen().
|
||||
* SDL_GameControllerOpen()
|
||||
* \returns the implementation dependent name for the game controller, or NULL
|
||||
* if there is no name or the identifier passed is invalid.
|
||||
*
|
||||
@@ -430,7 +417,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *g
|
||||
* it takes a controller identifier instead of the (unstable) device index.
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen().
|
||||
* SDL_GameControllerOpen()
|
||||
* \returns the implementation dependent path for the game controller, or NULL
|
||||
* if there is no path or the identifier passed is invalid.
|
||||
*
|
||||
@@ -540,8 +527,8 @@ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameControl
|
||||
/**
|
||||
* Get the Steam Input handle of an opened controller, if available.
|
||||
*
|
||||
* Returns an InputHandle_t for the controller that can be used with Steam
|
||||
* Input API: https://partner.steamgames.com/doc/api/ISteamInput
|
||||
* Returns an InputHandle_t for the controller that can be used with Steam Input API:
|
||||
* https://partner.steamgames.com/doc/api/ISteamInput
|
||||
*
|
||||
* \param gamecontroller the game controller object to query.
|
||||
* \returns the gamepad handle, or 0 if unavailable.
|
||||
@@ -555,7 +542,7 @@ extern DECLSPEC Uint64 SDLCALL SDL_GameControllerGetSteamHandle(SDL_GameControll
|
||||
* Check if a controller has been opened and is currently connected.
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen().
|
||||
* SDL_GameControllerOpen()
|
||||
* \returns SDL_TRUE if the controller has been opened and is currently
|
||||
* connected, or SDL_FALSE if not.
|
||||
*
|
||||
@@ -580,7 +567,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameControlle
|
||||
* cause SDL to crash.
|
||||
*
|
||||
* \param gamecontroller the game controller object that you want to get a
|
||||
* joystick from.
|
||||
* joystick from
|
||||
* \returns a SDL_Joystick object; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -597,7 +584,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameCont
|
||||
* Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
|
||||
* and 1 will have any effect. Other numbers will just be returned.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`.
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns the same value passed to the function, with exception to -1
|
||||
* (SDL_QUERY), which will return the current state.
|
||||
*
|
||||
@@ -620,19 +607,17 @@ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
|
||||
|
||||
|
||||
/**
|
||||
* The list of axes available from a controller
|
||||
* The list of axes available from a controller
|
||||
*
|
||||
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
|
||||
* SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
|
||||
* advanced UI will allow users to set or autodetect the dead zone, which
|
||||
* varies between controllers.
|
||||
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX,
|
||||
* and are centered within ~8000 of zero, though advanced UI will allow users to set
|
||||
* or autodetect the dead zone, which varies between controllers.
|
||||
*
|
||||
* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
|
||||
* pressed) when reported by SDL_GameControllerGetAxis(). Note that this is
|
||||
* not the same range that will be reported by the lower-level
|
||||
* SDL_GetJoystickAxis().
|
||||
* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX
|
||||
* (fully pressed) when reported by SDL_GameControllerGetAxis(). Note that this is not the
|
||||
* same range that will be reported by the lower-level SDL_GetJoystickAxis().
|
||||
*/
|
||||
typedef enum SDL_GameControllerAxis
|
||||
typedef enum
|
||||
{
|
||||
SDL_CONTROLLER_AXIS_INVALID = -1,
|
||||
SDL_CONTROLLER_AXIS_LEFTX,
|
||||
@@ -656,7 +641,7 @@ typedef enum SDL_GameControllerAxis
|
||||
* `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
|
||||
* respectively.
|
||||
*
|
||||
* \param str string representing a SDL_GameController axis.
|
||||
* \param str string representing a SDL_GameController axis
|
||||
* \returns the SDL_GameControllerAxis enum corresponding to the input string,
|
||||
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
||||
*
|
||||
@@ -671,7 +656,7 @@ extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromStri
|
||||
*
|
||||
* The caller should not SDL_free() the returned string.
|
||||
*
|
||||
* \param axis an enum value for a given SDL_GameControllerAxis.
|
||||
* \param axis an enum value for a given SDL_GameControllerAxis
|
||||
* \returns a string for the given axis, or NULL if an invalid axis is
|
||||
* specified. The string returned is of the format used by
|
||||
* SDL_GameController mapping strings.
|
||||
@@ -685,8 +670,8 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameC
|
||||
/**
|
||||
* Get the SDL joystick layer binding for a controller axis mapping.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param axis an axis enum value (one of the SDL_GameControllerAxis values).
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis enum value (one of the SDL_GameControllerAxis values)
|
||||
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
||||
* (like the given Controller axis doesn't exist on the device), its
|
||||
* `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
||||
@@ -705,8 +690,8 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
||||
* This merely reports whether the controller's mapping defined this axis, as
|
||||
* that is all the information SDL has about the physical device.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param axis an axis enum value (an SDL_GameControllerAxis value).
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis enum value (an SDL_GameControllerAxis value)
|
||||
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -719,15 +704,16 @@ SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameController
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*
|
||||
* For thumbsticks, the state is a value ranging from -32768 (up/left) to
|
||||
* 32767 (down/right).
|
||||
* For thumbsticks, the state is a value ranging from -32768 (up/left)
|
||||
* to 32767 (down/right).
|
||||
*
|
||||
* Triggers range from 0 when released to 32767 when fully pressed, and never
|
||||
* return a negative value. Note that this differs from the value reported by
|
||||
* the lower-level SDL_JoystickGetAxis(), which normally uses the full range.
|
||||
* Triggers range from 0 when released to 32767 when fully pressed, and
|
||||
* never return a negative value. Note that this differs from the value
|
||||
* reported by the lower-level SDL_GetJoystickAxis(), which normally uses
|
||||
* the full range.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param axis an axis index (one of the SDL_GameControllerAxis values).
|
||||
* \param gamecontroller a game controller
|
||||
* \param axis an axis index (one of the SDL_GameControllerAxis values)
|
||||
* \returns axis state (including 0) on success or 0 (also) on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -739,9 +725,9 @@ extern DECLSPEC Sint16 SDLCALL
|
||||
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* The list of buttons available from a controller
|
||||
* The list of buttons available from a controller
|
||||
*/
|
||||
typedef enum SDL_GameControllerButton
|
||||
typedef enum
|
||||
{
|
||||
SDL_CONTROLLER_BUTTON_INVALID = -1,
|
||||
SDL_CONTROLLER_BUTTON_A,
|
||||
@@ -776,7 +762,7 @@ typedef enum SDL_GameControllerButton
|
||||
* SDL_GameController mapping. You do not normally need to call this function
|
||||
* unless you are parsing SDL_GameController mappings in your own code.
|
||||
*
|
||||
* \param str string representing a SDL_GameController axis.
|
||||
* \param str string representing a SDL_GameController axis
|
||||
* \returns the SDL_GameControllerButton enum corresponding to the input
|
||||
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
|
||||
*
|
||||
@@ -789,7 +775,7 @@ extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFrom
|
||||
*
|
||||
* The caller should not SDL_free() the returned string.
|
||||
*
|
||||
* \param button an enum value for a given SDL_GameControllerButton.
|
||||
* \param button an enum value for a given SDL_GameControllerButton
|
||||
* \returns a string for the given button, or NULL if an invalid button is
|
||||
* specified. The string returned is of the format used by
|
||||
* SDL_GameController mapping strings.
|
||||
@@ -803,8 +789,8 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_Gam
|
||||
/**
|
||||
* Get the SDL joystick layer binding for a controller button mapping.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param button an button enum value (an SDL_GameControllerButton value).
|
||||
* \param gamecontroller a game controller
|
||||
* \param button an button enum value (an SDL_GameControllerButton value)
|
||||
* \returns a SDL_GameControllerButtonBind describing the bind. On failure
|
||||
* (like the given Controller button doesn't exist on the device),
|
||||
* its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
|
||||
@@ -823,8 +809,8 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
||||
* This merely reports whether the controller's mapping defined this button,
|
||||
* as that is all the information SDL has about the physical device.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param button a button enum value (an SDL_GameControllerButton value).
|
||||
* \param gamecontroller a game controller
|
||||
* \param button a button enum value (an SDL_GameControllerButton value)
|
||||
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -835,8 +821,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController
|
||||
/**
|
||||
* Get the current state of a button on a game controller.
|
||||
*
|
||||
* \param gamecontroller a game controller.
|
||||
* \param button a button index (one of the SDL_GameControllerButton values).
|
||||
* \param gamecontroller a game controller
|
||||
* \param button a button index (one of the SDL_GameControllerButton values)
|
||||
* \returns 1 for pressed state or 0 for not pressed state or error; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -872,8 +858,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameControll
|
||||
/**
|
||||
* Return whether a game controller has a particular sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param type The type of sensor to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -883,9 +869,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController
|
||||
/**
|
||||
* Set whether data reporting for a game controller sensor is enabled.
|
||||
*
|
||||
* \param gamecontroller The controller to update.
|
||||
* \param type The type of sensor to enable/disable.
|
||||
* \param enabled Whether data reporting should be enabled.
|
||||
* \param gamecontroller The controller to update
|
||||
* \param type The type of sensor to enable/disable
|
||||
* \param enabled Whether data reporting should be enabled
|
||||
* \returns 0 or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -895,8 +881,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameControlle
|
||||
/**
|
||||
* Query whether sensor data reporting is enabled for a game controller.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param type The type of sensor to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -907,8 +893,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameContr
|
||||
* Get the data rate (number of events per second) of a game controller
|
||||
* sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param type The type of sensor to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \return the data rate, or 0.0f if the data rate is not available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
@@ -921,10 +907,10 @@ extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameContro
|
||||
* The number of values and interpretation of the data is sensor dependent.
|
||||
* See SDL_sensor.h for the details for each type of sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param type The type of sensor to query.
|
||||
* \param data A pointer filled with the current sensor state.
|
||||
* \param num_values The number of values to write to data.
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \param data A pointer filled with the current sensor state
|
||||
* \param num_values The number of values to write to data
|
||||
* \return 0 or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -938,12 +924,12 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *
|
||||
* The number of values and interpretation of the data is sensor dependent.
|
||||
* See SDL_sensor.h for the details for each type of sensor.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param type The type of sensor to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \param type The type of sensor to query
|
||||
* \param timestamp A pointer filled with the timestamp in microseconds of the
|
||||
* current sensor reading if available, or 0 if not.
|
||||
* \param data A pointer filled with the current sensor state.
|
||||
* \param num_values The number of values to write to data.
|
||||
* current sensor reading if available, or 0 if not
|
||||
* \param data A pointer filled with the current sensor state
|
||||
* \param num_values The number of values to write to data
|
||||
* \return 0 or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.26.0.
|
||||
@@ -956,13 +942,13 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_Gam
|
||||
* Each call to this function cancels any previous rumble effect, and calling
|
||||
* it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate.
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if rumble isn't supported on this controller.
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if rumble isn't supported on this controller
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*
|
||||
@@ -981,13 +967,13 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecon
|
||||
* want the (more common) whole-controller rumble, use
|
||||
* SDL_GameControllerRumble() instead.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate.
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param left_rumble The intensity of the left trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* to 0xFFFF
|
||||
* \param right_rumble The intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this controller.
|
||||
* to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this controller
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
@@ -998,9 +984,9 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController
|
||||
/**
|
||||
* Query whether a game controller has an LED.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
|
||||
* modifiable LED.
|
||||
* modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
@@ -1009,9 +995,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *ga
|
||||
/**
|
||||
* Query whether a game controller has rumble support.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
|
||||
* support.
|
||||
* support
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
@@ -1022,9 +1008,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController
|
||||
/**
|
||||
* Query whether a game controller has rumble support on triggers.
|
||||
*
|
||||
* \param gamecontroller The controller to query.
|
||||
* \param gamecontroller The controller to query
|
||||
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
|
||||
* rumble support.
|
||||
* rumble support
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
@@ -1035,11 +1021,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameCon
|
||||
/**
|
||||
* Update a game controller's LED color.
|
||||
*
|
||||
* \param gamecontroller The controller to update.
|
||||
* \param red The intensity of the red LED.
|
||||
* \param green The intensity of the green LED.
|
||||
* \param blue The intensity of the blue LED.
|
||||
* \returns 0, or -1 if this controller does not have a modifiable LED.
|
||||
* \param gamecontroller The controller to update
|
||||
* \param red The intensity of the red LED
|
||||
* \param green The intensity of the green LED
|
||||
* \param blue The intensity of the blue LED
|
||||
* \returns 0, or -1 if this controller does not have a modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
@@ -1048,11 +1034,11 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecon
|
||||
/**
|
||||
* Send a controller specific effect packet
|
||||
*
|
||||
* \param gamecontroller The controller to affect.
|
||||
* \param data The data to send to the controller.
|
||||
* \param size The size of the data to send to the controller.
|
||||
* \param gamecontroller The controller to affect
|
||||
* \param data The data to send to the controller
|
||||
* \param size The size of the data to send to the controller
|
||||
* \returns 0, or -1 if this controller or driver doesn't support effect
|
||||
* packets.
|
||||
* packets
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*/
|
||||
@@ -1062,7 +1048,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gam
|
||||
* Close a game controller previously opened with SDL_GameControllerOpen().
|
||||
*
|
||||
* \param gamecontroller a game controller identifier previously returned by
|
||||
* SDL_GameControllerOpen().
|
||||
* SDL_GameControllerOpen()
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1074,9 +1060,9 @@ extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecon
|
||||
* Return the sfSymbolsName for a given button on a game controller on Apple
|
||||
* platforms.
|
||||
*
|
||||
* \param gamecontroller the controller to query.
|
||||
* \param button a button on the game controller.
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found.
|
||||
* \param gamecontroller the controller to query
|
||||
* \param button a button on the game controller
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
@@ -1088,9 +1074,9 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForBu
|
||||
* Return the sfSymbolsName for a given axis on a game controller on Apple
|
||||
* platforms.
|
||||
*
|
||||
* \param gamecontroller the controller to query.
|
||||
* \param axis an axis on the game controller.
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found.
|
||||
* \param gamecontroller the controller to query
|
||||
* \param axis an axis on the game controller
|
||||
* \returns the sfSymbolsName or NULL if the name can't be found
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryGesture
|
||||
* \file SDL_gesture.h
|
||||
*
|
||||
* Include file for SDL gesture event handling.
|
||||
* Include file for SDL gesture event handling.
|
||||
*/
|
||||
|
||||
#ifndef SDL_gesture_h_
|
||||
@@ -51,7 +51,7 @@ typedef Sint64 SDL_GestureID;
|
||||
* If the parameter `touchId` is -1 (i.e., all devices), this function will
|
||||
* always return 1, regardless of whether there actually are any devices.
|
||||
*
|
||||
* \param touchId the touch device id, or -1 for all touch devices.
|
||||
* \param touchId the touch device id, or -1 for all touch devices
|
||||
* \returns 1 on success or 0 if the specified device could not be found.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -64,7 +64,7 @@ extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
|
||||
/**
|
||||
* Save all currently loaded Dollar Gesture templates.
|
||||
*
|
||||
* \param dst a SDL_RWops to save to.
|
||||
* \param dst a SDL_RWops to save to
|
||||
* \returns the number of saved templates on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -78,8 +78,8 @@ extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
|
||||
/**
|
||||
* Save a currently loaded Dollar Gesture template.
|
||||
*
|
||||
* \param gestureId a gesture id.
|
||||
* \param dst a SDL_RWops to save to.
|
||||
* \param gestureId a gesture id
|
||||
* \param dst a SDL_RWops to save to
|
||||
* \returns 1 on success or 0 on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
@@ -94,8 +94,8 @@ extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_R
|
||||
/**
|
||||
* Load Dollar Gesture templates from a file.
|
||||
*
|
||||
* \param touchId a touch id.
|
||||
* \param src a SDL_RWops to load from.
|
||||
* \param touchId a touch id
|
||||
* \param src a SDL_RWops to load from
|
||||
* \returns the number of loaded templates on success or a negative error code
|
||||
* (or 0) on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
|
@@ -19,13 +19,10 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* WIKI CATEGORY: GUID */
|
||||
|
||||
/**
|
||||
* # CategoryGUID
|
||||
* \file SDL_guid.h
|
||||
*
|
||||
* A GUID is a 128-bit value that represents something that is uniquely
|
||||
* identifiable by this value: "globally unique."
|
||||
* Include file for handling ::SDL_GUID values.
|
||||
*/
|
||||
|
||||
#ifndef SDL_guid_h_
|
||||
@@ -41,38 +38,34 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* An SDL_GUID is a 128-bit identifier.
|
||||
* An SDL_GUID is a 128-bit identifier for an input device that
|
||||
* identifies that device across runs of SDL programs on the same
|
||||
* platform. If the device is detached and then re-attached to a
|
||||
* different port, or if the base system is rebooted, the device
|
||||
* should still report the same GUID.
|
||||
*
|
||||
* This is an acronym for "Globally Unique ID."
|
||||
* GUIDs are as precise as possible but are not guaranteed to
|
||||
* distinguish physically distinct but equivalent devices. For
|
||||
* example, two game controllers from the same vendor with the same
|
||||
* product ID and revision may have the same GUID.
|
||||
*
|
||||
* While a GUID can be used to assign a unique value to almost anything, in
|
||||
* SDL these are largely used to identify input devices across runs of SDL
|
||||
* programs on the same platform.If the device is detached and then
|
||||
* re-attached to a different port, or if the base system is rebooted, the
|
||||
* device should still report the same GUID.
|
||||
*
|
||||
* GUIDs are as precise as possible but are not guaranteed to distinguish
|
||||
* physically distinct but equivalent devices. For example, two game
|
||||
* controllers from the same vendor with the same product ID and revision may
|
||||
* have the same GUID.
|
||||
*
|
||||
* GUIDs may be platform-dependent (i.e., the same device may report different
|
||||
* GUIDs on different operating systems).
|
||||
* GUIDs may be platform-dependent (i.e., the same device may report
|
||||
* different GUIDs on different operating systems).
|
||||
*/
|
||||
typedef struct SDL_GUID {
|
||||
typedef struct {
|
||||
Uint8 data[16];
|
||||
} SDL_GUID;
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* Get an ASCII string representation for a given SDL_GUID.
|
||||
* Get an ASCII string representation for a given ::SDL_GUID.
|
||||
*
|
||||
* You should supply at least 33 bytes for pszGUID.
|
||||
*
|
||||
* \param guid the SDL_GUID you wish to convert to string.
|
||||
* \param pszGUID buffer in which to write the ASCII string.
|
||||
* \param cbGUID the size of pszGUID.
|
||||
* \param guid the ::SDL_GUID you wish to convert to string
|
||||
* \param pszGUID buffer in which to write the ASCII string
|
||||
* \param cbGUID the size of pszGUID
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*
|
||||
@@ -81,14 +74,14 @@ typedef struct SDL_GUID {
|
||||
extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
|
||||
|
||||
/**
|
||||
* Convert a GUID string into a SDL_GUID structure.
|
||||
* Convert a GUID string into a ::SDL_GUID structure.
|
||||
*
|
||||
* Performs no error checking. If this function is given a string containing
|
||||
* an invalid GUID, the function will silently succeed, but the GUID generated
|
||||
* will not be useful.
|
||||
*
|
||||
* \param pchGUID string containing an ASCII representation of a GUID.
|
||||
* \returns a SDL_GUID structure.
|
||||
* \param pchGUID string containing an ASCII representation of a GUID
|
||||
* \returns a ::SDL_GUID structure.
|
||||
*
|
||||
* \since This function is available since SDL 2.24.0.
|
||||
*
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -19,35 +19,44 @@
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* WIKI CATEGORY: HIDAPI */
|
||||
|
||||
/**
|
||||
* # CategoryHIDAPI
|
||||
* \file SDL_hidapi.h
|
||||
*
|
||||
* Header file for SDL HIDAPI functions.
|
||||
* Header file for SDL HIDAPI functions.
|
||||
*
|
||||
* This is an adaptation of the original HIDAPI interface by Alan Ott, and
|
||||
* includes source code licensed under the following license:
|
||||
* This is an adaptation of the original HIDAPI interface by Alan Ott,
|
||||
* and includes source code licensed under the following BSD license:
|
||||
*
|
||||
* ```
|
||||
* HIDAPI - Multi-Platform library for
|
||||
* communication with HID devices.
|
||||
*
|
||||
* Copyright 2009, Alan Ott, Signal 11 Software.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This software may be used by anyone for any reason so
|
||||
* long as the copyright notice in the source files
|
||||
* remains intact.
|
||||
* ```
|
||||
*
|
||||
* (Note that this license is the same as item three of SDL's zlib license, so
|
||||
* it adds no new requirements on the user.)
|
||||
Copyright (c) 2010, Alan Ott, Signal 11 Software
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Signal 11 Software nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* If you would like a version of SDL without this code, you can build SDL
|
||||
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for
|
||||
* example on iOS or tvOS to avoid a dependency on the CoreBluetooth
|
||||
* framework.
|
||||
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for example
|
||||
* on iOS or tvOS to avoid a dependency on the CoreBluetooth framework.
|
||||
*/
|
||||
|
||||
#ifndef SDL_hidapi_h_
|
||||
@@ -62,15 +71,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A handle representing an open HID device
|
||||
* \brief A handle representing an open HID device
|
||||
*/
|
||||
struct SDL_hid_device_;
|
||||
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
|
||||
|
||||
/** hidapi info structure */
|
||||
|
||||
/**
|
||||
* Information about a connected HID device
|
||||
* \brief Information about a connected HID device
|
||||
*/
|
||||
typedef struct SDL_hid_device_info
|
||||
{
|
||||
@@ -226,13 +234,13 @@ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id,
|
||||
* The path name be determined by calling SDL_hid_enumerate(), or a
|
||||
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
|
||||
*
|
||||
* \param path The path name of the device to open.
|
||||
* \param path The path name of the device to open
|
||||
* \returns a pointer to a SDL_hid_device object on success or NULL on
|
||||
* failure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive);
|
||||
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */);
|
||||
|
||||
/**
|
||||
* Write an Output report to a HID device.
|
||||
@@ -426,7 +434,7 @@ extern DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int
|
||||
/**
|
||||
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers
|
||||
*
|
||||
* \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan.
|
||||
* \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
*/
|
||||
|
3110
include/SDL_hints.h
3110
include/SDL_hints.h
File diff suppressed because it is too large
Load Diff
@@ -20,26 +20,22 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryJoystick
|
||||
* \file SDL_joystick.h
|
||||
*
|
||||
* Include file for SDL joystick event handling
|
||||
* Include file for SDL joystick event handling
|
||||
*
|
||||
* The term "device_index" identifies currently plugged in joystick devices
|
||||
* between 0 and SDL_NumJoysticks(), with the exact joystick behind a
|
||||
* device_index changing as joysticks are plugged and unplugged.
|
||||
* The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick
|
||||
* behind a device_index changing as joysticks are plugged and unplugged.
|
||||
*
|
||||
* The term "instance_id" is the current instantiation of a joystick device in
|
||||
* the system, if the joystick is removed and then re-inserted then it will
|
||||
* get a new instance_id, instance_id's are monotonically increasing
|
||||
* identifiers of a joystick plugged in.
|
||||
* The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
|
||||
* then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
|
||||
*
|
||||
* The term "player_index" is the number assigned to a player on a specific
|
||||
* controller. For XInput controllers this returns the XInput user index. Many
|
||||
* joysticks will not be able to supply this information.
|
||||
* controller. For XInput controllers this returns the XInput user index.
|
||||
* Many joysticks will not be able to supply this information.
|
||||
*
|
||||
* The term JoystickGUID is a stable 128-bit identifier for a joystick device
|
||||
* that does not change over time, it identifies class of the device (a X360
|
||||
* wired controller for example). This identifier is platform dependent.
|
||||
* The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
|
||||
* the device (a X360 wired controller for example). This identifier is platform dependent.
|
||||
*/
|
||||
|
||||
#ifndef SDL_joystick_h_
|
||||
@@ -60,7 +56,7 @@ extern "C" {
|
||||
* \file SDL_joystick.h
|
||||
*
|
||||
* In order to use these functions, SDL_Init() must have been called
|
||||
* with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||
* with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
|
||||
* for joysticks, and load appropriate drivers.
|
||||
*
|
||||
* If you would like to receive joystick updates while the application
|
||||
@@ -77,21 +73,15 @@ extern SDL_mutex *SDL_joystick_lock;
|
||||
struct _SDL_Joystick;
|
||||
typedef struct _SDL_Joystick SDL_Joystick;
|
||||
|
||||
/**
|
||||
* A structure that encodes the stable unique id for a joystick device.
|
||||
*
|
||||
* This is just a standard SDL_GUID by a different name.
|
||||
*/
|
||||
/* A structure that encodes the stable unique id for a joystick device */
|
||||
typedef SDL_GUID SDL_JoystickGUID;
|
||||
|
||||
/**
|
||||
* This is a unique ID for a joystick for the time it is connected to the
|
||||
* system, and is never reused for the lifetime of the application.
|
||||
* This is a unique ID for a joystick for the time it is connected to the system,
|
||||
* and is never reused for the lifetime of the application. If the joystick is
|
||||
* disconnected and reconnected, it will get a new ID.
|
||||
*
|
||||
* If the joystick is disconnected and reconnected, it will get a new ID.
|
||||
*
|
||||
* The ID value starts at 0 and increments from there. The value -1 is an
|
||||
* invalid ID.
|
||||
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
|
||||
*/
|
||||
typedef Sint32 SDL_JoystickID;
|
||||
|
||||
@@ -182,7 +172,7 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system).
|
||||
* on the system)
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -199,7 +189,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system).
|
||||
* on the system)
|
||||
* \returns the path of the selected joystick. If no path can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -225,9 +215,9 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
|
||||
* This function can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the GUID of the selected joystick. If called on an invalid index,
|
||||
* this function returns a zero GUID.
|
||||
* this function returns a zero GUID
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -243,9 +233,9 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_in
|
||||
* available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the USB vendor ID of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero.
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
@@ -258,9 +248,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
|
||||
* available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the USB product ID of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero.
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
@@ -273,9 +263,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
|
||||
* isn't available this function returns 0.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the product version of the selected joystick. If called on an
|
||||
* invalid index, this function returns zero.
|
||||
* invalid index, this function returns zero
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
@@ -287,9 +277,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_in
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the SDL_JoystickType of the selected joystick. If called on an
|
||||
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`.
|
||||
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
*/
|
||||
@@ -301,7 +291,7 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* \param device_index the index of the joystick to query (the N'th joystick
|
||||
* on the system.
|
||||
* on the system
|
||||
* \returns the instance id of the selected joystick. If called on an invalid
|
||||
* index, this function returns -1.
|
||||
*
|
||||
@@ -320,7 +310,7 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int devic
|
||||
* The joystick subsystem must be initialized before a joystick can be opened
|
||||
* for use.
|
||||
*
|
||||
* \param device_index the index of the joystick to query.
|
||||
* \param device_index the index of the joystick to query
|
||||
* \returns a joystick identifier or NULL if an error occurred; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -334,7 +324,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
|
||||
/**
|
||||
* Get the SDL_Joystick associated with an instance id.
|
||||
*
|
||||
* \param instance_id the instance id to get the SDL_Joystick for.
|
||||
* \param instance_id the instance id to get the SDL_Joystick for
|
||||
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
@@ -345,7 +335,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
|
||||
/**
|
||||
* Get the SDL_Joystick associated with a player index.
|
||||
*
|
||||
* \param player_index the player index to get the SDL_Joystick for.
|
||||
* \param player_index the player index to get the SDL_Joystick for
|
||||
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
|
||||
* for more information.
|
||||
*
|
||||
@@ -368,10 +358,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
|
||||
/**
|
||||
* The structure that defines an extended virtual joystick description
|
||||
*
|
||||
* The caller must zero the structure and then initialize the version with
|
||||
* `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to
|
||||
* SDL_JoystickAttachVirtualEx() All other elements of this structure are
|
||||
* optional and can be left 0.
|
||||
* The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx()
|
||||
* All other elements of this structure are optional and can be left 0.
|
||||
*
|
||||
* \sa SDL_JoystickAttachVirtualEx
|
||||
*/
|
||||
@@ -402,7 +390,7 @@ typedef struct SDL_VirtualJoystickDesc
|
||||
} SDL_VirtualJoystickDesc;
|
||||
|
||||
/**
|
||||
* The current version of the SDL_VirtualJoystickDesc structure
|
||||
* \brief The current version of the SDL_VirtualJoystickDesc structure
|
||||
*/
|
||||
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
|
||||
|
||||
@@ -419,7 +407,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystic
|
||||
* Detach a virtual joystick.
|
||||
*
|
||||
* \param device_index a value previously returned from
|
||||
* SDL_JoystickAttachVirtual().
|
||||
* SDL_JoystickAttachVirtual()
|
||||
* \returns 0 on success, or -1 if an error occurred.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -497,7 +485,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, in
|
||||
/**
|
||||
* Get the implementation dependent name of a joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -511,7 +499,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Get the implementation dependent path of a joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the path of the selected joystick. If no path can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -527,7 +515,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickPath(SDL_Joystick *joystick);
|
||||
* For XInput controllers this returns the XInput user index. Many joysticks
|
||||
* will not be able to supply this information.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the player index, or -1 if it's not available.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
@@ -537,7 +525,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Set the player index of an opened joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \param player_index Player index to assign to this joystick, or -1 to clear
|
||||
* the player index and turn off player LEDs.
|
||||
*
|
||||
@@ -550,7 +538,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick,
|
||||
*
|
||||
* This function requires an open joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the GUID of the given joystick. If called on an invalid index,
|
||||
* this function returns a zero GUID; call SDL_GetError() for more
|
||||
* information.
|
||||
@@ -567,7 +555,7 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joyst
|
||||
*
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
@@ -579,7 +567,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
|
||||
*
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the USB product ID of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
@@ -591,7 +579,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
|
||||
*
|
||||
* If the product version isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the product version of the selected joystick, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
@@ -603,7 +591,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joyst
|
||||
*
|
||||
* If the firmware version isn't available this function returns 0.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the firmware version of the selected joystick, or 0 if
|
||||
* unavailable.
|
||||
*
|
||||
@@ -616,7 +604,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetFirmwareVersion(SDL_Joystick *joys
|
||||
*
|
||||
* Returns the serial number of the joystick, or NULL if it is not available.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the serial number of the selected joystick, or NULL if
|
||||
* unavailable.
|
||||
*
|
||||
@@ -627,7 +615,7 @@ extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystic
|
||||
/**
|
||||
* Get the type of an opened joystick.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
|
||||
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen()
|
||||
* \returns the SDL_JoystickType of the selected joystick.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.6.
|
||||
@@ -639,9 +627,9 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joyst
|
||||
*
|
||||
* You should supply at least 33 bytes for pszGUID.
|
||||
*
|
||||
* \param guid the SDL_JoystickGUID you wish to convert to string.
|
||||
* \param pszGUID buffer in which to write the ASCII string.
|
||||
* \param cbGUID the size of pszGUID.
|
||||
* \param guid the SDL_JoystickGUID you wish to convert to string
|
||||
* \param pszGUID buffer in which to write the ASCII string
|
||||
* \param cbGUID the size of pszGUID
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -658,7 +646,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, ch
|
||||
* an invalid GUID, the function will silently succeed, but the GUID generated
|
||||
* will not be useful.
|
||||
*
|
||||
* \param pchGUID string containing an ASCII representation of a GUID.
|
||||
* \param pchGUID string containing an ASCII representation of a GUID
|
||||
* \returns a SDL_JoystickGUID structure.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -670,15 +658,15 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const cha
|
||||
/**
|
||||
* Get the device information encoded in a SDL_JoystickGUID structure
|
||||
*
|
||||
* \param guid the SDL_JoystickGUID you wish to get info about.
|
||||
* \param guid the SDL_JoystickGUID you wish to get info about
|
||||
* \param vendor A pointer filled in with the device VID, or 0 if not
|
||||
* available.
|
||||
* available
|
||||
* \param product A pointer filled in with the device PID, or 0 if not
|
||||
* available.
|
||||
* available
|
||||
* \param version A pointer filled in with the device version, or 0 if not
|
||||
* available.
|
||||
* available
|
||||
* \param crc16 A pointer filled in with a CRC used to distinguish different
|
||||
* products with the same VID/PID, or 0 if not available.
|
||||
* products with the same VID/PID, or 0 if not available
|
||||
*
|
||||
* \since This function is available since SDL 2.26.0.
|
||||
*
|
||||
@@ -689,7 +677,7 @@ extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint
|
||||
/**
|
||||
* Get the status of a specified joystick.
|
||||
*
|
||||
* \param joystick the joystick to query.
|
||||
* \param joystick the joystick to query
|
||||
* \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -703,7 +691,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick)
|
||||
/**
|
||||
* Get the instance ID of an opened joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the instance ID of the specified joystick on success or a negative
|
||||
* error code on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -720,7 +708,7 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joys
|
||||
* separate buttons or a POV hat, and not axes, but all of this is up to the
|
||||
* device and platform.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of axis controls/number of axes on success or a
|
||||
* negative error code on failure; call SDL_GetError() for more
|
||||
* information.
|
||||
@@ -740,7 +728,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
|
||||
*
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of trackballs on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -753,7 +741,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Get the number of POV hats on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of POV hats on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -767,7 +755,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Get the number of buttons on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of buttons on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -806,10 +794,10 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
* `SDL_ENABLE`, this function accepts any value, with any non-zero value that
|
||||
* isn't `SDL_QUERY` being treated as `SDL_ENABLE`.
|
||||
*
|
||||
* If SDL was built with events disabled (extremely uncommon!), this will do
|
||||
* nothing and always return `SDL_IGNORE`.
|
||||
* If SDL was built with events disabled (extremely uncommon!), this will
|
||||
* do nothing and always return `SDL_IGNORE`.
|
||||
*
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`.
|
||||
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`
|
||||
* \returns If `state` is `SDL_QUERY` then the current state is returned,
|
||||
* otherwise `state` is returned (even if it was not one of the
|
||||
* allowed values).
|
||||
@@ -820,7 +808,6 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
||||
|
||||
/* Limits for joystick axes... */
|
||||
#define SDL_JOYSTICK_AXIS_MAX 32767
|
||||
#define SDL_JOYSTICK_AXIS_MIN -32768
|
||||
|
||||
@@ -837,8 +824,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
|
||||
* 32767) representing the current position of the axis. It may be necessary
|
||||
* to impose certain tolerances on these values to account for jitter.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param axis the axis to query; the axis indices start at index 0.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param axis the axis to query; the axis indices start at index 0
|
||||
* \returns a 16-bit signed integer representing the current position of the
|
||||
* axis or 0 on failure; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -856,8 +843,8 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param axis the axis to query; the axis indices start at index 0.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param axis the axis to query; the axis indices start at index 0
|
||||
* \param state Upon return, the initial value is supplied here.
|
||||
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
|
||||
*
|
||||
@@ -896,8 +883,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *j
|
||||
* - `SDL_HAT_LEFTUP`
|
||||
* - `SDL_HAT_LEFTDOWN`
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param hat the hat index to get the state from; indices start at index 0.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param hat the hat index to get the state from; indices start at index 0
|
||||
* \returns the current hat position.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -915,10 +902,10 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
|
||||
*
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick the SDL_Joystick to query.
|
||||
* \param ball the ball index to query; ball indices start at index 0.
|
||||
* \param dx stores the difference in the x axis position since the last poll.
|
||||
* \param dy stores the difference in the y axis position since the last poll.
|
||||
* \param joystick the SDL_Joystick to query
|
||||
* \param ball the ball index to query; ball indices start at index 0
|
||||
* \param dx stores the difference in the x axis position since the last poll
|
||||
* \param dy stores the difference in the y axis position since the last poll
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -932,9 +919,9 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
|
||||
/**
|
||||
* Get the current state of a button on a joystick.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information.
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \param button the button index to get the state from; indices start at
|
||||
* index 0.
|
||||
* index 0
|
||||
* \returns 1 if the specified button is pressed, 0 otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -950,13 +937,13 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
|
||||
* Each call to this function cancels any previous rumble effect, and calling
|
||||
* it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \param joystick The joystick to vibrate.
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right)
|
||||
* rumble motor, from 0 to 0xFFFF.
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if rumble isn't supported on this joystick.
|
||||
* rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if rumble isn't supported on this joystick
|
||||
*
|
||||
* \since This function is available since SDL 2.0.9.
|
||||
*
|
||||
@@ -975,13 +962,13 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 lo
|
||||
* want the (more common) whole-controller rumble, use SDL_JoystickRumble()
|
||||
* instead.
|
||||
*
|
||||
* \param joystick The joystick to vibrate.
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param left_rumble The intensity of the left trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* to 0xFFFF
|
||||
* \param right_rumble The intensity of the right trigger rumble motor, from 0
|
||||
* to 0xFFFF.
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds.
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this joystick.
|
||||
* to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
* \returns 0, or -1 if trigger rumble isn't supported on this joystick
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*
|
||||
@@ -995,7 +982,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, U
|
||||
* An example of a joystick LED is the light on the back of a PlayStation 4's
|
||||
* DualShock 4 controller.
|
||||
*
|
||||
* \param joystick The joystick to query.
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
@@ -1005,7 +992,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Query whether a joystick has rumble support.
|
||||
*
|
||||
* \param joystick The joystick to query.
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
@@ -1017,7 +1004,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Query whether a joystick has rumble support on triggers.
|
||||
*
|
||||
* \param joystick The joystick to query.
|
||||
* \param joystick The joystick to query
|
||||
* \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.18.
|
||||
@@ -1032,11 +1019,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joy
|
||||
* An example of a joystick LED is the light on the back of a PlayStation 4's
|
||||
* DualShock 4 controller.
|
||||
*
|
||||
* \param joystick The joystick to update.
|
||||
* \param red The intensity of the red LED.
|
||||
* \param green The intensity of the green LED.
|
||||
* \param blue The intensity of the blue LED.
|
||||
* \returns 0 on success, -1 if this joystick does not have a modifiable LED.
|
||||
* \param joystick The joystick to update
|
||||
* \param red The intensity of the red LED
|
||||
* \param green The intensity of the green LED
|
||||
* \param blue The intensity of the blue LED
|
||||
* \returns 0 on success, -1 if this joystick does not have a modifiable LED
|
||||
*
|
||||
* \since This function is available since SDL 2.0.14.
|
||||
*/
|
||||
@@ -1045,11 +1032,10 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red
|
||||
/**
|
||||
* Send a joystick specific effect packet
|
||||
*
|
||||
* \param joystick The joystick to affect.
|
||||
* \param data The data to send to the joystick.
|
||||
* \param size The size of the data to send to the joystick.
|
||||
* \returns 0, or -1 if this joystick or driver doesn't support effect
|
||||
* packets.
|
||||
* \param joystick The joystick to affect
|
||||
* \param data The data to send to the joystick
|
||||
* \param size The size of the data to send to the joystick
|
||||
* \returns 0, or -1 if this joystick or driver doesn't support effect packets
|
||||
*
|
||||
* \since This function is available since SDL 2.0.16.
|
||||
*/
|
||||
@@ -1058,7 +1044,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_JoystickOpen().
|
||||
*
|
||||
* \param joystick The joystick device to close.
|
||||
* \param joystick The joystick device to close
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -1069,9 +1055,9 @@ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
|
||||
/**
|
||||
* Get the battery level of a joystick as SDL_JoystickPowerLevel.
|
||||
*
|
||||
* \param joystick the SDL_Joystick to query.
|
||||
* \param joystick the SDL_Joystick to query
|
||||
* \returns the current battery level as SDL_JoystickPowerLevel on success or
|
||||
* `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown.
|
||||
* `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
|
||||
*
|
||||
* \since This function is available since SDL 2.0.4.
|
||||
*/
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryKeyboard
|
||||
* \file SDL_keyboard.h
|
||||
*
|
||||
* Include file for SDL keyboard event handling
|
||||
* Include file for SDL keyboard event handling
|
||||
*/
|
||||
|
||||
#ifndef SDL_keyboard_h_
|
||||
@@ -40,16 +40,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The SDL keysym structure, used in key events.
|
||||
* \brief The SDL keysym structure, used in key events.
|
||||
*
|
||||
* If you are looking for translated character input, see the SDL_TEXTINPUT
|
||||
* event.
|
||||
* \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event.
|
||||
*/
|
||||
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 - see SDL_Keymod for details */
|
||||
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 */
|
||||
Uint32 unused;
|
||||
} SDL_Keysym;
|
||||
|
||||
@@ -85,7 +84,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
|
||||
* Note: This function doesn't take into account whether shift has been
|
||||
* pressed or not.
|
||||
*
|
||||
* \param numkeys if non-NULL, receives the length of the returned array.
|
||||
* \param numkeys if non-NULL, receives the length of the returned array
|
||||
* \returns a pointer to an array of key states.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -130,7 +129,7 @@ extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
|
||||
* This does not change the keyboard state, only the key modifier flags that
|
||||
* SDL reports.
|
||||
*
|
||||
* \param modstate the desired SDL_Keymod for the keyboard.
|
||||
* \param modstate the desired SDL_Keymod for the keyboard
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -144,7 +143,7 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
|
||||
*
|
||||
* See SDL_Keycode for details.
|
||||
*
|
||||
* \param scancode the desired SDL_Scancode to query.
|
||||
* \param scancode the desired SDL_Scancode to query
|
||||
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -160,7 +159,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode
|
||||
*
|
||||
* See SDL_Scancode for details.
|
||||
*
|
||||
* \param key the desired SDL_Keycode to query.
|
||||
* \param key the desired SDL_Keycode to query
|
||||
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
@@ -184,7 +183,7 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
|
||||
* unsuitable for creating a stable cross-platform two-way mapping between
|
||||
* strings and scancodes.
|
||||
*
|
||||
* \param scancode the desired SDL_Scancode to query.
|
||||
* \param scancode the desired SDL_Scancode to query
|
||||
* \returns a pointer to the name for the scancode. If the scancode doesn't
|
||||
* have a name this function returns an empty string ("").
|
||||
*
|
||||
@@ -198,7 +197,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
|
||||
/**
|
||||
* Get a scancode from a human-readable name.
|
||||
*
|
||||
* \param name the human-readable scancode name.
|
||||
* \param name the human-readable scancode name
|
||||
* \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
|
||||
* recognized; call SDL_GetError() for more information.
|
||||
*
|
||||
@@ -215,7 +214,7 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
|
||||
*
|
||||
* See SDL_Scancode and SDL_Keycode for details.
|
||||
*
|
||||
* \param key the desired SDL_Keycode to query.
|
||||
* \param key the desired SDL_Keycode to query
|
||||
* \returns a pointer to a UTF-8 string that stays valid at least until the
|
||||
* next call to this function. If you need it around any longer, you
|
||||
* must copy it. If the key doesn't have a name, this function
|
||||
@@ -232,7 +231,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
|
||||
/**
|
||||
* Get a key code from a human-readable name.
|
||||
*
|
||||
* \param name the human-readable key name.
|
||||
* \param name the human-readable key name
|
||||
* \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
@@ -254,10 +253,6 @@ 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
|
||||
* video subsystem initialization which will cause SDL_TextInputEvent and
|
||||
* SDL_TextEditingEvent to begin emitting.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
* \sa SDL_SetTextInputRect
|
||||
@@ -303,11 +298,10 @@ extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
|
||||
|
||||
/**
|
||||
* Set the rectangle used to type Unicode text inputs.
|
||||
*
|
||||
* Native input methods will place a window with word suggestions near it,
|
||||
* without covering the text being inputted.
|
||||
*
|
||||
* Set the rectangle used to type Unicode text inputs. Native input methods
|
||||
* will place a window with word suggestions near it, without covering the
|
||||
* text being inputted.
|
||||
*
|
||||
* To start text input in a given location, this function is intended to be
|
||||
* called before SDL_StartTextInput, although some platforms support moving
|
||||
* the rectangle even while text input (and a composition) is active.
|
||||
@@ -317,7 +311,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
|
||||
* any feedback.
|
||||
*
|
||||
* \param rect the SDL_Rect structure representing the rectangle to receive
|
||||
* text (ignored if NULL).
|
||||
* text (ignored if NULL)
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
*
|
||||
@@ -341,7 +335,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
|
||||
/**
|
||||
* Check whether the screen keyboard is shown for given window.
|
||||
*
|
||||
* \param window the window for which screen keyboard should be queried.
|
||||
* \param window the window for which screen keyboard should be queried
|
||||
* \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not.
|
||||
*
|
||||
* \since This function is available since SDL 2.0.0.
|
||||
|
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* # CategoryKeycode
|
||||
* \file SDL_keycode.h
|
||||
*
|
||||
* Defines constants which identify keyboard keys and modifiers.
|
||||
* Defines constants which identify keyboard keys and modifiers.
|
||||
*/
|
||||
|
||||
#ifndef SDL_keycode_h_
|
||||
@@ -32,28 +32,22 @@
|
||||
#include "SDL_scancode.h"
|
||||
|
||||
/**
|
||||
* The SDL virtual key representation.
|
||||
* \brief The SDL virtual key representation.
|
||||
*
|
||||
* Values of this type are used to represent keyboard keys using the current
|
||||
* layout of the keyboard. These values include Unicode values representing
|
||||
* the unmodified character that would be generated by pressing the key, or an
|
||||
* SDLK_* constant for those keys that do not generate characters.
|
||||
* Values of this type are used to represent keyboard keys using the current
|
||||
* layout of the keyboard. These values include Unicode values representing
|
||||
* the unmodified character that would be generated by pressing the key, or
|
||||
* an SDLK_* constant for those keys that do not generate characters.
|
||||
*
|
||||
* A special exception is the number keys at the top of the keyboard which map
|
||||
* to SDLK_0...SDLK_9 on AZERTY layouts.
|
||||
*
|
||||
* The actual values that might be set for this type are listed in the
|
||||
* SDL_KeyCode (capital C) enumeration.
|
||||
* A special exception is the number keys at the top of the keyboard which
|
||||
* map to SDLK_0...SDLK_9 on AZERTY layouts.
|
||||
*/
|
||||
typedef Sint32 SDL_Keycode;
|
||||
|
||||
#define SDLK_SCANCODE_MASK (1<<30)
|
||||
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
|
||||
|
||||
/**
|
||||
* The possible values for keycodes.
|
||||
*/
|
||||
typedef enum SDL_KeyCode
|
||||
typedef enum
|
||||
{
|
||||
SDLK_UNKNOWN = 0,
|
||||
|
||||
@@ -333,9 +327,9 @@ typedef enum SDL_KeyCode
|
||||
} SDL_KeyCode;
|
||||
|
||||
/**
|
||||
* Enumeration of valid key mods (possibly OR'd together).
|
||||
* \brief Enumeration of valid key mods (possibly OR'd together).
|
||||
*/
|
||||
typedef enum SDL_Keymod
|
||||
typedef enum
|
||||
{
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT = 0x0001,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user