Skip to content

Commit ac5ec0e

Browse files
committed
backends: add SDL1.2 Compat backend
Added the SDL12-Compat backend, using a shim library which implements the `sdl1.2` API over SDL2. The new `sdl12-compat` backend should be used for SDL1 applications when: * the platform doesn't have `dispmanx` anymore (e.g. `rpi` platforms with RaspiOS Bullseye and later) * `sdl2` has a working accelerated video & rendering drivers * not running under `x11` (i.e. KMS) Note: for SDL1+Videocore specific applications, which use directly the dispmanx/legacy GL stack (e.g. `pcsx-rearmed`, `advmame-1.4`, etc.), the backend will not help.
1 parent 75cfcb1 commit ac5ec0e

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

scriptmodules/supplementary/backends.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ function _list_backends() {
1818
local id="$1"
1919
backends=()
2020

21+
# skip the 'depends' packages
22+
[[ ${__mod_info[$id/section]} == "depends" ]] && return 1
23+
2124
local flags="${__mod_info[$id/flags]}"
2225
local sdl
2326
if isPlatform "videocore" && hasFlag "$flags" "sdl1-videocore"; then
@@ -35,6 +38,7 @@ function _list_backends() {
3538
if [[ "$sdl" == "sdl1" ]]; then
3639
backends["default"]="SDL1 Framebuffer driver"
3740
isPlatform "dispmanx" && backends["dispmanx"]="SDL1 DispmanX driver"
41+
isPlatform "kms" && ! isPlatform "dispmanx" && backends["sdl12-compat"]="SDL1 Compat driver"
3842
elif [[ "$sdl" == "sdl2" ]]; then
3943
if isPlatform "videocore"; then
4044
default="SDL2 videocore driver"
@@ -109,6 +113,9 @@ function gui_configure_backends() {
109113
continue
110114
fi
111115
fi
116+
if [[ "$choice" == "sdl12-compat" ]] && ! rp_isInstalled "sdl12-compat"; then
117+
rp_callModule "sdl12-compat" _auto_
118+
fi
112119
local func="_backend_set_$id"
113120
if fnExists "$func"; then
114121
rp_callModule "$id" _backend_set "$choice" 1

scriptmodules/supplementary/runcommand/runcommand.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,9 @@ function config_backend() {
10621062
fi
10631063
COMMAND="SDL1_VIDEODRIVER=dispmanx $COMMAND"
10641064
;;
1065+
sdl12-compat)
1066+
COMMAND="LD_PRELOAD=\"$ROOTDIR/supplementary/sdl12-compat/libSDL-1.2.so.0\" $COMMAND"
1067+
;;
10651068
x11)
10661069
XINIT=1
10671070
XINIT_WM=1

scriptmodules/supplementary/sdl1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
rp_module_id="sdl1"
1313
rp_module_desc="SDL 1.2.15 with rpi fixes and dispmanx"
14-
rp_module_licence="GPL2 https://hg.libsdl.org/SDL/raw-file/7676476631ce/COPYING"
14+
rp_module_licence="GPL2 https://raw.githubusercontent.com/libsdl-org/SDL-1.2/main/COPYING"
1515
rp_module_section="depends"
16-
rp_module_flags="!all rpi"
16+
rp_module_flags="!all rpi dispmanx"
1717

1818
function get_pkg_ver_sdl1() {
1919
local basever
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
3+
# This file is part of The RetroPie Project
4+
#
5+
# The RetroPie Project is the legal property of its developers, whose names are
6+
# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source.
7+
#
8+
# See the LICENSE.md file at the top-level directory of this distribution and
9+
# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md
10+
#
11+
12+
rp_module_id="sdl12-compat"
13+
rp_module_desc="SDL1.2 compatibility layer that uses SDL2 under the hood"
14+
rp_module_help="Provides a binary and source compatible API for programs written against SDL 1.2, but it uses SDL 2.0 behind the scenes"
15+
rp_module_licence="ZLIB https://raw.githubusercontent.com/libsdl-org/sdl12-compat/main/LICENSE.txt"
16+
rp_module_repo="git https://github.com/libsdl-org/sdl12-compat :_version_sdl12-compat"
17+
rp_module_section="depends"
18+
rp_module_flags="!x11"
19+
20+
function _version_sdl12-compat() {
21+
local ver="1.2.68"
22+
if [[ "$1" == "short" ]]; then
23+
echo $ver
24+
else
25+
echo "release-$ver"
26+
fi
27+
}
28+
function depend_sdl12-compat() {
29+
getDepends libsdl2-dev cmake
30+
}
31+
32+
function sources_sdl12-compat() {
33+
gitPullOrClone
34+
}
35+
36+
function build_sdl12-compat() {
37+
cmake -DSDL12TESTS=OFF -DSDL12DEVEL=OFF .
38+
make
39+
md_ret_require="$md_build/libSDL-1.2.so.$(_version_sdl12-compat short)"
40+
}
41+
42+
function install_sdl12-compat() {
43+
md_ret_files=(
44+
libSDL-1.2.so."$(_version_sdl12-compat short)"
45+
README.md
46+
LICENSE.txt
47+
)
48+
}
49+
50+
function configure_sdl12-compat() {
51+
ldconfig -nN "$md_inst"
52+
}

0 commit comments

Comments
 (0)