@@ -276,8 +276,13 @@ _pg_clear_event_timer_type(int ev_type)
276276
277277/* Timer callback function
278278 * TODO: This needs better error handling and a way to report to the user */
279+ #if SDL_VERSION_ATLEAST (3 , 0 , 0 )
280+ static Uint32
281+ timer_callback (void * param , SDL_TimerID timerID , Uint32 interval )
282+ #else
279283static Uint32
280284timer_callback (Uint32 interval , void * param )
285+ #endif
281286{
282287 pgEventTimer * evtimer ;
283288 PG_LOCK_TIMER_MUTEX
@@ -316,12 +321,14 @@ accurate_delay(Sint64 ticks)
316321 if (ticks <= 0 )
317322 return 0 ;
318323
324+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
319325 if (!SDL_WasInit (SDL_INIT_TIMER )) {
320326 if (SDL_InitSubSystem (SDL_INIT_TIMER )) {
321327 PyErr_SetString (pgExc_SDLError , SDL_GetError ());
322328 return -1 ;
323329 }
324330 }
331+ #endif
325332
326333 funcstart = PG_GetTicks ();
327334 if (ticks >= WORST_CLOCK_ACCURACY ) {
@@ -342,8 +349,10 @@ accurate_delay(Sint64 ticks)
342349static PyObject *
343350time_get_ticks (PyObject * self , PyObject * _null )
344351{
352+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
345353 if (!SDL_WasInit (SDL_INIT_TIMER ))
346354 return PyLong_FromLong (0 );
355+ #endif
347356 return PyLong_FromUnsignedLongLong (PG_GetTicks ());
348357}
349358
@@ -371,11 +380,13 @@ time_wait(PyObject *self, PyObject *arg)
371380 if (!PyLong_Check (arg ))
372381 return RAISE (PyExc_TypeError , "wait requires one integer argument" );
373382
383+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
374384 if (!SDL_WasInit (SDL_INIT_TIMER )) {
375385 if (SDL_InitSubSystem (SDL_INIT_TIMER )) {
376386 return RAISE (pgExc_SDLError , SDL_GetError ());
377387 }
378388 }
389+ #endif
379390
380391 ticks = PyLong_AsLongLong (arg );
381392 if (ticks < 0 )
@@ -455,13 +466,15 @@ time_set_timer(PyObject *self, PyObject *args, PyObject *kwargs)
455466 goto end ;
456467 }
457468
469+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
458470 /* just doublecheck that timer is initialized */
459471 if (!SDL_WasInit (SDL_INIT_TIMER )) {
460472 if (SDL_InitSubSystem (SDL_INIT_TIMER )) {
461473 ecode = PG_TIMER_SDL_ERROR ;
462474 goto end ;
463475 }
464476 }
477+ #endif
465478
466479 ecode = _pg_add_event_timer (ev_type , ev_dict , loops );
467480 if (ecode != PG_TIMER_NO_ERROR ) {
@@ -522,12 +535,14 @@ clock_tick_base(pgClockObject *self, PyObject *arg, int use_accurate_delay)
522535 self -> rawpassed = PG_GetTicks () - self -> last_tick ;
523536 delay = endtime - self -> rawpassed ;
524537
538+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
525539 /*just doublecheck that timer is initialized*/
526540 if (!SDL_WasInit (SDL_INIT_TIMER )) {
527541 if (SDL_InitSubSystem (SDL_INIT_TIMER )) {
528542 return RAISE (pgExc_SDLError , SDL_GetError ());
529543 }
530544 }
545+ #endif
531546
532547 if (use_accurate_delay )
533548 delay = accurate_delay (delay );
@@ -639,11 +654,13 @@ clock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
639654 return NULL ;
640655 }
641656
657+ #if !SDL_VERSION_ATLEAST (3 , 0 , 0 )
642658 if (!SDL_WasInit (SDL_INIT_TIMER )) {
643659 if (SDL_InitSubSystem (SDL_INIT_TIMER )) {
644660 return RAISE (pgExc_SDLError , SDL_GetError ());
645661 }
646662 }
663+ #endif
647664
648665 pgClockObject * self = (pgClockObject * )(type -> tp_alloc (type , 0 ));
649666 self -> fps_tick = 0 ;
0 commit comments