Skip to content

Commit 53c0310

Browse files
committed
SDL3 compat for joy_set_led
1 parent ab26b5c commit 53c0310

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src_c/joystick.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,19 @@ joy_set_led(PyObject *self, PyObject *arg)
548548
"set_led must be passed in a Color-compatible argument");
549549
}
550550

551+
#if !SDL_VERSION_ATLEAST(3, 0, 0)
551552
if (SDL_JoystickSetLED(joy, colors[0], colors[1], colors[2]) < 0) {
552553
Py_RETURN_FALSE;
553554
}
554555
Py_RETURN_TRUE;
556+
#else
557+
// SDL3 renames the function and sets an error message on failure
558+
bool result = SDL_SetJoystickLED(joy, colors[0], colors[1], colors[2]);
559+
if (!result) {
560+
printf("%s\n", SDL_GetError());
561+
}
562+
return PyBool_FromLong(result);
563+
#endif
555564
}
556565

557566
static PyMethodDef joy_methods[] = {

0 commit comments

Comments
 (0)