Skip to content

Commit

Permalink
Raise minimum supported SDL2 to 2.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed Nov 4, 2024
1 parent de88561 commit 8ee6032
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 131 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Dependency versions:
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/reST/ref/event.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pygame 2 also supports controller hot-plugging
CLIPBOARDUPDATE
RENDER_TARGETS_RESET
RENDER_DEVICE_RESET
LOCALECHANGED (SDL backend >= 2.0.14)
LOCALECHANGED

Also in this version, ``instance_id`` attributes were added to joystick events,
and the ``joy`` attribute was deprecated.
Expand Down
2 changes: 1 addition & 1 deletion docs/reST/ref/joystick.rst
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ variable. See :ref:`environment variables <environment-variables>` for more deta
playing, then it will be overwritten.

Returns True if the rumble was played successfully or False if the
joystick does not support it or :meth:`pygame.version.SDL` is below 2.0.9.
joystick does not support it.

.. versionaddedold:: 2.0.2

Expand Down
8 changes: 2 additions & 6 deletions docs/reST/ref/sdl2_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ always the leftmost button of the 4 buttons on the right.
Controllers can generate the following events::

CONTROLLERAXISMOTION, CONTROLLERBUTTONDOWN, CONTROLLERBUTTONUP,
CONTROLLERDEVICEREMAPPED, CONTROLLERDEVICEADDED, CONTROLLERDEVICEREMOVED

Additionally if pygame is built with SDL 2.0.14 or higher the following events can also be generated
(to get the version of sdl pygame is built with use :meth:`pygame.version.SDL`)::

CONTROLLERDEVICEREMAPPED, CONTROLLERDEVICEADDED, CONTROLLERDEVICEREMOVED,
CONTROLLERTOUCHPADDOWN, CONTROLLERTOUCHPADMOTION, CONTROLLERTOUCHPADUP

These events can be enabled/disabled by :meth:`pygame._sdl2.controller.set_eventstate`
Expand Down Expand Up @@ -274,7 +270,7 @@ events related to controllers.
playing, then it will be overwritten.

Returns True if the rumble was played successfully or False if the
controller does not support it or :meth:`pygame.version.SDL` is below 2.0.9.
controller does not support it.

.. versionaddedold:: 2.0.2

Expand Down
5 changes: 1 addition & 4 deletions docs/reST/ref/system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
'LASX': False
}

.. Note:: The value of ``ARMSIMD`` will be always False if
SDL version < 2.0.12.

The values of ``LSX`` and ``LASX`` will be always False if
.. Note:: The values of ``LSX`` and ``LASX`` will be always False if
SDL version < 2.24.0.

.. versionadded:: 2.3.1
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.es.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Versiones de dependencia:
+----------+-----------------------------+
| CPython | >= 3.8 (Ou utiliser PyPy3) |
+----------+-----------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+-----------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+-----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.fa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ Dependencies (وابستگی ها)
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.fr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Versions des dépendances:
+----------+-----------------------------+
| CPython | >= 3.8 (Ou utiliser PyPy3) |
+----------+-----------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+-----------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+-----------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.it.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Le versioni dei requisiti:
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.ja.rst
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ gfxdraw には SDL_gfx の埋め込みバージョンが含まれています。
+----------+------------------------+
| CPython | >= 3.8 (Or use PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readmes/README.zh-cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pygame显然依赖于SDL和Python。此外pygame还嵌入了几个较小的库
+----------+------------------------+
| CPython | >= 3.8 (或 PyPy3) |
+----------+------------------------+
| SDL | >= 2.0.10 |
| SDL | >= 2.0.14 |
+----------+------------------------+
| SDL_mixer| >= 2.0.4 |
+----------+------------------------+
Expand Down
2 changes: 1 addition & 1 deletion src_c/_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ camera_get_image(pgCameraObject *self, PyObject *arg)
return NULL;

if (!surfobj) {
surf = PG_CreateSurface(width, height, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(width, height, SDL_PIXELFORMAT_XRGB8888);
}
else {
surf = pgSurface_AsSurface(surfobj);
Expand Down
40 changes: 0 additions & 40 deletions src_c/_pygame.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,47 +188,7 @@ PG_UnlockMutex(SDL_mutex *mutex)

#define PG_INIT_TIMER SDL_INIT_TIMER

#if SDL_VERSION_ATLEAST(2, 0, 14)
#define PG_SurfaceHasRLE SDL_HasSurfaceRLE
#else
// vendored in until our lowest SDL version is 2.0.14
typedef struct {
Uint8 *src;
int src_w, src_h;
int src_pitch;
int src_skip;
Uint8 *dst;
int dst_w, dst_h;
int dst_pitch;
int dst_skip;
SDL_PixelFormat *src_fmt;
SDL_PixelFormat *dst_fmt;
Uint8 *table;
int flags;
Uint32 colorkey;
Uint8 r, g, b, a;
} SDL_InternalBlitInfo;

struct SDL_BlitMap {
SDL_Surface *dst;
int identity;
SDL_blit blit;
void *data;
SDL_InternalBlitInfo info;

/* the version count matches the destination; mismatch indicates
an invalid mapping */
Uint32 dst_palette_version;
Uint32 src_palette_version;
};
#define SDL_COPY_RLE_DESIRED 0x00001000

#define PG_SurfaceHasRLE(surface) \
(((surface) == NULL) \
? 0 \
: ((surface)->map->info.flags & SDL_COPY_RLE_DESIRED))

#endif

#endif

Expand Down
6 changes: 0 additions & 6 deletions src_c/_sdl2/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ controller_rumble(pgControllerObject *self, PyObject *args, PyObject *kwargs)
return RAISE(pgExc_SDLError, "Controller is not initalized");
}

#if SDL_VERSION_ATLEAST(2, 0, 9)
// rumble takes values in range 0 to 0xFFFF (65535)
low_freq = MAX(MIN(low_freq, 1.0f), 0.0f) * 65535;
high_freq = MAX(MIN(high_freq, 1.0f), 0.0f) * 65535;
Expand All @@ -376,9 +375,6 @@ controller_rumble(pgControllerObject *self, PyObject *args, PyObject *kwargs)
(Uint16)high_freq, duration);

return PyBool_FromLong(success == 0);
#else
Py_RETURN_FALSE;
#endif
}

static PyObject *
Expand All @@ -388,9 +384,7 @@ controller_stop_rumble(pgControllerObject *self, PyObject *_null)
if (!self->controller) {
return RAISE(pgExc_SDLError, "Controller is not initalized");
}
#if SDL_VERSION_ATLEAST(2, 0, 9)
SDL_GameControllerRumble(self->controller, 0, 0, 1);
#endif
Py_RETURN_NONE;
}

Expand Down
8 changes: 0 additions & 8 deletions src_c/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,11 @@ MODINIT_DEFINE(constants)
DEC_CONST(CONTROLLERDEVICEADDED);
DEC_CONST(CONTROLLERDEVICEREMOVED);
DEC_CONST(CONTROLLERDEVICEREMAPPED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
DEC_CONST(CONTROLLERTOUCHPADDOWN);
DEC_CONST(CONTROLLERTOUCHPADMOTION);
DEC_CONST(CONTROLLERTOUCHPADUP);
DEC_CONST(CONTROLLERSENSORUPDATE);
DEC_CONST(LOCALECHANGED);
#else
DEC_CONSTS(CONTROLLERTOUCHPADDOWN, -1);
DEC_CONSTS(CONTROLLERTOUCHPADMOTION, -1);
DEC_CONSTS(CONTROLLERTOUCHPADUP, -1);
DEC_CONSTS(CONTROLLERSENSORUPDATE, -1);
DEC_CONSTS(LOCALECHANGED, -1);
#endif

DEC_CONST(JOYDEVICEADDED);
DEC_CONST(JOYDEVICEREMOVED);
Expand Down
19 changes: 4 additions & 15 deletions src_c/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ pg_ResizeEventWatch(void *userdata, SDL_Event *event)
int h = event->window.data2;
pgSurfaceObject *display_surface = pg_GetDefaultWindowSurface();
SDL_Surface *surf =
PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);

SDL_FreeSurface(display_surface->surf);
display_surface->surf = surf;
Expand Down Expand Up @@ -1156,7 +1156,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
So we make a fake surface.
*/
surf = PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);
newownedsurf = surf;
}
else {
Expand Down Expand Up @@ -1265,7 +1265,7 @@ pg_set_mode(PyObject *self, PyObject *arg, PyObject *kwds)
pg_renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, w, h);
}
surf = PG_CreateSurface(w, h, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(w, h, SDL_PIXELFORMAT_XRGB8888);
newownedsurf = surf;
}
else {
Expand Down Expand Up @@ -1571,7 +1571,7 @@ pg_list_modes(PyObject *self, PyObject *args, PyObject *kwds)
}
/* use reasonable defaults (cf. SDL_video.c) */
if (!mode.format)
mode.format = PG_PIXELFORMAT_XRGB8888;
mode.format = SDL_PIXELFORMAT_XRGB8888;
if (!mode.w)
mode.w = 640;
if (!mode.h)
Expand Down Expand Up @@ -2803,9 +2803,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
return NULL;
}

#if SDL_VERSION_ATLEAST(2, 0, 12)
msgbox_data.flags |= SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT;
#endif

if (parent_window == Py_None) {
msgbox_data.window = NULL;
Expand Down Expand Up @@ -2896,12 +2894,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)

buttons_data = malloc(sizeof(SDL_MessageBoxButtonData) * num_buttons);
for (Py_ssize_t i = 0; i < num_buttons; i++) {
#if SDL_VERSION_ATLEAST(2, 0, 12)
PyObject *btn_name_obj = PySequence_GetItem(buttons, i);
#else
PyObject *btn_name_obj =
PySequence_GetItem(buttons, num_buttons - i - 1);
#endif
if (!btn_name_obj)
goto error;

Expand All @@ -2916,11 +2909,7 @@ pg_message_box(PyObject *self, PyObject *arg, PyObject *kwargs)
goto error;

buttons_data[i].text = btn_name;
#if SDL_VERSION_ATLEAST(2, 0, 12)
buttons_data[i].buttonid = (int)i;
#else
buttons_data[i].buttonid = (int)(num_buttons - i - 1);
#endif
buttons_data[i].flags = 0;
if (return_button_index == buttons_data[i].buttonid)
buttons_data[i].flags |=
Expand Down
12 changes: 0 additions & 12 deletions src_c/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,10 @@ _pg_pgevent_proxify_helper(Uint32 type, Uint8 proxify)
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEADDED);
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEREMOVED);
_PG_HANDLE_PROXIFY(CONTROLLERDEVICEREMAPPED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADDOWN);
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADMOTION);
_PG_HANDLE_PROXIFY(CONTROLLERTOUCHPADUP);
_PG_HANDLE_PROXIFY(CONTROLLERSENSORUPDATE);
#endif
_PG_HANDLE_PROXIFY(DOLLARGESTURE);
_PG_HANDLE_PROXIFY(DOLLARRECORD);
_PG_HANDLE_PROXIFY(DROPFILE);
Expand All @@ -367,9 +365,7 @@ _pg_pgevent_proxify_helper(Uint32 type, Uint8 proxify)
_PG_HANDLE_PROXIFY(JOYBUTTONUP);
_PG_HANDLE_PROXIFY(JOYDEVICEADDED);
_PG_HANDLE_PROXIFY(JOYDEVICEREMOVED);
#if SDL_VERSION_ATLEAST(2, 0, 14)
_PG_HANDLE_PROXIFY(LOCALECHANGED);
#endif
_PG_HANDLE_PROXIFY(MOUSEMOTION);
_PG_HANDLE_PROXIFY(MOUSEBUTTONDOWN);
_PG_HANDLE_PROXIFY(MOUSEBUTTONUP);
Expand Down Expand Up @@ -756,10 +752,8 @@ _pg_name_from_eventtype(int type)
return "KeyUp";
case SDL_KEYMAPCHANGED:
return "KeyMapChanged";
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_LOCALECHANGED:
return "LocaleChanged";
#endif
case SDL_MOUSEMOTION:
return "MouseMotion";
case SDL_MOUSEBUTTONDOWN:
Expand Down Expand Up @@ -828,7 +822,6 @@ _pg_name_from_eventtype(int type)
return "JoyDeviceAdded";
case SDL_JOYDEVICEREMOVED:
return "JoyDeviceRemoved";
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_CONTROLLERTOUCHPADDOWN:
return "ControllerTouchpadDown";
case SDL_CONTROLLERTOUCHPADMOTION:
Expand All @@ -837,7 +830,6 @@ _pg_name_from_eventtype(int type)
return "ControllerTouchpadUp";
case SDL_CONTROLLERSENSORUPDATE:
return "ControllerSensorUpdate";
#endif /*SDL_VERSION_ATLEAST(2, 0, 14)*/
case SDL_AUDIODEVICEADDED:
return "AudioDeviceAdded";
case SDL_AUDIODEVICEREMOVED:
Expand Down Expand Up @@ -1215,7 +1207,6 @@ dict_from_event(SDL_Event *event)
_pg_insobj(dict, "instance_id",
PyLong_FromLong(event->jdevice.which));
break;
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_CONTROLLERTOUCHPADDOWN:
case SDL_CONTROLLERTOUCHPADMOTION:
case SDL_CONTROLLERTOUCHPADUP:
Expand All @@ -1230,7 +1221,6 @@ dict_from_event(SDL_Event *event)
_pg_insobj(dict, "pressure",
PyFloat_FromDouble(event->ctouchpad.pressure));
break;
#endif /*SDL_VERSION_ATLEAST(2, 0, 14)*/

#ifdef WIN32
case SDL_SYSWMEVENT:
Expand Down Expand Up @@ -1318,14 +1308,12 @@ dict_from_event(SDL_Event *event)
window = SDL_GetWindowFromID(event->button.windowID);
break;
}
#if SDL_VERSION_ATLEAST(2, 0, 14)
case SDL_FINGERMOTION:
case SDL_FINGERDOWN:
case SDL_FINGERUP: {
window = SDL_GetWindowFromID(event->tfinger.windowID);
break;
}
#endif
default: {
return dict;
}
Expand Down
2 changes: 1 addition & 1 deletion src_c/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ font_render(PyObject *self, PyObject *args, PyObject *kwds)

if (strlen(astring) == 0) { /* special 0 string case */
int height = TTF_FontHeight(font);
surf = PG_CreateSurface(0, height, PG_PIXELFORMAT_XRGB8888);
surf = PG_CreateSurface(0, height, SDL_PIXELFORMAT_XRGB8888);
}
else { /* normal case */
if (antialias && bg_rgba_obj == Py_None) {
Expand Down
Loading

0 comments on commit 8ee6032

Please sign in to comment.