Skip to content

Commit bac234e

Browse files
committed
Merge branch 'main' of https://github.com/pygame-community/pygame-ce into SDL_JoystickSetLED
2 parents b4a9f62 + 787650b commit bac234e

File tree

10 files changed

+525
-1778
lines changed

10 files changed

+525
-1778
lines changed

meson.build

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,38 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
9494
# yes, this is a bit ugly and hardcoded but it is what it is
9595
# TODO (middle-term goal) - Should migrate away from this
9696
# consider meson wraps? Hopefully can also get the same build path as below
97+
sdl_ver = (sdl_api == 3) ? '3.2.10' : '2.32.8'
98+
sdl_image_ver = (sdl_api == 3) ? '3.2.4' : '2.8.8'
99+
sdl_mixer_ver = '2.8.1'
100+
sdl_ttf_ver = (sdl_api == 3) ? '3.2.2' : '2.24.0'
101+
97102
arch_suffix = 'x' + host_machine.cpu_family().substring(-2)
98103
base_dir = meson.current_source_dir()
99104
prebuilt_dir = base_dir / 'prebuilt-' + arch_suffix
100105

101-
# download prebuilts (uses legacy builconfig code)
102-
if not fs.is_dir(prebuilt_dir)
106+
sdl_dir = prebuilt_dir / '@0@-@1@'.format(sdl, sdl_ver)
107+
sdl_image_dir = prebuilt_dir / '@0@-@1@'.format(sdl_image, sdl_image_ver)
108+
sdl_mixer_dir = prebuilt_dir / '@0@-@1@'.format(sdl_mixer, sdl_mixer_ver)
109+
sdl_ttf_dir = prebuilt_dir / '@0@-@1@'.format(sdl_ttf, sdl_ttf_ver)
110+
common_lib_dir = prebuilt_dir / 'lib'
111+
112+
# download prebuilts (uses legacy buildconfig code)
113+
required_dirs = [
114+
prebuilt_dir,
115+
sdl_dir,
116+
sdl_image_dir,
117+
sdl_mixer_dir,
118+
sdl_ttf_dir,
119+
common_lib_dir,
120+
]
121+
any_missing = false
122+
foreach d : required_dirs
123+
if not fs.is_dir(d)
124+
any_missing = true
125+
break
126+
endif
127+
endforeach
128+
if any_missing
103129
run_command(
104130
[
105131
find_program('python3', 'python'),
@@ -109,23 +135,16 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
109135
)
110136
endif
111137

112-
sdl_ver = (sdl_api == 3) ? '3.2.10' : '2.32.8'
113-
sdl_image_ver = (sdl_api == 3) ? '3.2.4' : '2.8.8'
114-
sdl_mixer_ver = '2.8.1'
115-
sdl_ttf_ver = (sdl_api == 3) ? '3.2.2' : '2.24.0'
116-
117138
dlls = []
118139

119140
# SDL
120-
sdl_dir = prebuilt_dir / '@0@-@1@'.format(sdl, sdl_ver)
121141
sdl_lib_dir = sdl_dir / 'lib' / arch_suffix
122142
pg_inc_dirs += fs.relative_to(sdl_dir / 'include', base_dir)
123143
pg_lib_dirs += sdl_lib_dir
124144
dlls += sdl_lib_dir / '@0@.dll'.format(sdl)
125145

126146
# SDL_image
127147
if get_option('image').enabled()
128-
sdl_image_dir = prebuilt_dir / '@0@-@1@'.format(sdl_image, sdl_image_ver)
129148
sdl_image_lib_dir = sdl_image_dir / 'lib' / arch_suffix
130149
pg_inc_dirs += fs.relative_to(sdl_image_dir / 'include', base_dir)
131150
pg_lib_dirs += sdl_image_lib_dir
@@ -147,7 +166,6 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
147166

148167
# SDL_mixer
149168
if get_option('mixer').enabled()
150-
sdl_mixer_dir = prebuilt_dir / '@0@-@1@'.format(sdl_mixer, sdl_mixer_ver)
151169
sdl_mixer_lib_dir = sdl_mixer_dir / 'lib' / arch_suffix
152170
pg_inc_dirs += fs.relative_to(sdl_mixer_dir / 'include', base_dir)
153171
pg_lib_dirs += sdl_mixer_lib_dir
@@ -163,7 +181,6 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
163181

164182
# SDL_ttf
165183
if get_option('font').enabled()
166-
sdl_ttf_dir = prebuilt_dir / '@0@-@1@'.format(sdl_ttf, sdl_ttf_ver)
167184
sdl_ttf_lib_dir = sdl_ttf_dir / 'lib' / arch_suffix
168185
pg_inc_dirs += fs.relative_to(sdl_ttf_dir / 'include', base_dir)
169186
pg_lib_dirs += sdl_ttf_lib_dir
@@ -172,7 +189,6 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
172189

173190
# freetype, portmidi and porttime
174191
if get_option('freetype').enabled() and get_option('midi').enabled()
175-
common_lib_dir = prebuilt_dir / 'lib'
176192
pg_inc_dirs += fs.relative_to(prebuilt_dir / 'include', base_dir)
177193
pg_lib_dirs += common_lib_dir
178194
dlls += [common_lib_dir / 'freetype.dll', common_lib_dir / 'portmidi.dll']

src_c/_pygame.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ PG_GetSurfaceFormat(SDL_Surface *surf)
151151
#define PG_EventEnabled(type) SDL_EventEnabled(type)
152152
#define PG_SetJoystickEventsEnabled(enabled) \
153153
SDL_SetJoystickEventsEnabled(enabled)
154+
#define PG_InitSubSystem(flags) SDL_InitSubSystem(flags)
154155

155156
#define PG_FIND_VNUM_MAJOR(ver) SDL_VERSIONNUM_MAJOR(ver)
156157
#define PG_FIND_VNUM_MINOR(ver) SDL_VERSIONNUM_MINOR(ver)
@@ -316,6 +317,12 @@ PG_MapRGB(PG_PixelFormat *format, const SDL_Palette *palette, Uint8 r, Uint8 g,
316317
return SDL_MapRGB(format, r, g, b);
317318
}
318319

320+
static inline bool
321+
PG_InitSubSystem(Uint32 flags)
322+
{
323+
return SDL_InitSubSystem(flags) == 0;
324+
}
325+
319326
/* Mask to test if surface flags are in a fullscreen window.
320327
* SDL_WINDOW_FULLSCREEN_DESKTOP works here because it also contains
321328
* SDL_WINDOW_FULLSCREEN. */

src_c/_sdl2/controller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static PyObject *
2626
controller_module_init(PyObject *module, PyObject *_null)
2727
{
2828
if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER)) {
29-
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)) {
29+
if (!PG_InitSubSystem(SDL_INIT_GAMECONTROLLER)) {
3030
return RAISE(pgExc_SDLError, SDL_GetError());
3131
}
3232
}

0 commit comments

Comments
 (0)