Homebrew Question Are SDL_Timers working on Switch?

Nightfox_

Active Member
OP
Newcomer
Joined
Jun 4, 2018
Messages
40
Trophies
0
Age
36
XP
320
Country
Australia
I'm working with SDL on Switch and I can't seem to get SDL Timers to work.

When the equivalent code is compiled for PC, the timer works perfectly

Code:
int testNumber = 0;

Uint32 my_callbackfunc(Uint32 interval, void *param)
{
    TRACE("The timer has now called this function");
    testNumber++;
    return(interval);
}

int main(int argc, char* argv[])
{
    SDL_Init(SDL_INIT_TIMER);
    SDL_TimerID timer = SDL_AddTimer(1000,my_callbackfunc,NULL);
    // Set mesa configuration (useful for debugging)
    setMesaConfig();

    // Initialize EGL on the default window
    if (!initEgl(nwindowGetDefault()))
        return EXIT_FAILURE;

    // Load OpenGL routines using glad
    gladLoadGL();

    // Initialize our scene
    sceneInit();

    // Main graphics loop
    while (appletMainLoop())
    {
        TRACE("%d",narmba);
        // Get and process input
        hidScanInput();
        u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
        if (kDown & KEY_PLUS)
            break;

        // Render stuff!
        sceneRender();
        eglSwapBuffers(s_display, s_surface);
    }

    // Deinitialize our scene
    sceneExit();

    // Deinitialize EGL
    deinitEgl();
    return EXIT_SUCCESS;
}

my_callbackfunc() should be called every second, but it doesn't even get called once when running on Switch. But when doing the same thing for PC, the timer works fine.

Is there an extra step that needs to be done for Switch SDL timers or is the SDL library buggy?

Thanks
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
Hi, i "guess" it should work, but didn't test it like that. It may be an issue, but I won't be able to test soon. You can add an issue on github so I take a closer look as soon as possible (https://github.com/devkitPro/SDL/tree/switch-sdl2).
Also, for timers to work you may need to init video? I think its the case on most distribution?
 
Last edited by cpasjuste,

Nightfox_

Active Member
OP
Newcomer
Joined
Jun 4, 2018
Messages
40
Trophies
0
Age
36
XP
320
Country
Australia
Hi, i "guess" it should work, but didn't test it like that. It may be an issue, but I won't be able to test soon. You can add an issue on github so I take a closer look as soon as possible (https://github.com/devkitPro/SDL/tree/switch-sdl2).
Also, for timers to work you may need to init video? I think its the case on most distribution?

It doesn't work either for my main project which does init video, audio and joysticks too. Also the PC build of that SDL Timer testing program above works fine just initialising timer.

I'll add an issue to github thanks :)

--------------------- MERGED ---------------------------

Hmm the issues section is missing on the github page. Have public issues been disabled for that repository?
 

cpasjuste

Well-Known Member
Member
Joined
Aug 27, 2015
Messages
1,108
Trophies
1
Age
44
XP
4,481
Country
France
It doesn't work either for my main project which does init video, audio and joysticks too. Also the PC build of that SDL Timer testing program above works fine just initialising timer.

I'll add an issue to github thanks :)

--------------------- MERGED ---------------------------

Hmm the issues section is missing on the github page. Have public issues been disabled for that repository?
I think you need to select the master branch.
 

Nightfox_

Active Member
OP
Newcomer
Joined
Jun 4, 2018
Messages
40
Trophies
0
Age
36
XP
320
Country
Australia
Issues tab still missing on master branch
 

Attachments

  • sdlissue.PNG
    sdlissue.PNG
    21.8 KB · Views: 119

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • DinohScene @ DinohScene:
    tbf I haven't been around on the last pokeflood
  • DinohScene @ DinohScene:
    did it happen?
  • SylverReZ @ SylverReZ:
    @DinohScene, Wasn't it Scarlet and Violet?
  • Veho @ Veho:
    Dunno, I stay in the EoF.
  • SylverReZ @ SylverReZ:
    The craze must've had died down by then.
  • DinohScene @ DinohScene:
    I'm much more on the killing floor :x
  • SylverReZ @ SylverReZ:
    Imagine that every Pokemon game is the exact same but with slight tweaks.
  • SylverReZ @ SylverReZ:
    @DinohScene, I'm not much of a gaymer, more-so a creator.
  • Maximumbeans @ Maximumbeans:
    @SylverReZ Syl my beloved :bow: gm
    +1
  • Maximumbeans @ Maximumbeans:
    It is friday
  • SylverReZ @ SylverReZ:
    Last time I played a game was hmmm... can't exactly recall. :wacko:
  • Maximumbeans @ Maximumbeans:
    I can't believe you got me with that
    +1
  • SylverReZ @ SylverReZ:
    I haven't been gaming for such a long time. Been mostly busy with sleep, hardware tinkering and checking GBAtemp frequently.
  • SylverReZ @ SylverReZ:
    Hope you've had a good morning.
  • Maximumbeans @ Maximumbeans:
    It's going alright thanks :) I know what you mean with gaming time. It's precious where I can get it these days.
    +1
  • Maximumbeans @ Maximumbeans:
    I think that's why I focus on just enjoying single player experiences that aren't too competitive
  • Maximumbeans @ Maximumbeans:
    How are you doing?
  • SylverReZ @ SylverReZ:
    There's also this thing where I'm hyperfocused at night and cannot get to sleep.
  • SylverReZ @ SylverReZ:
    @Maximumbeans, I'm doing alright, thanks.
    +1
  • Maximumbeans @ Maximumbeans:
    That must be rough. Productive I'm sure but hard to balance with daily life
    +1
  • SylverReZ @ SylverReZ:
    @Maximumbeans, Indeed. I've been working on getting this Infecutus chip to work on my PS2. But after soldering, I realised that a plastic piece was missing from the power ribbon cable to the power and eject buttons.
  • SylverReZ @ SylverReZ:
    Now I could go with soldering the contacts from the cable to the connector on the mobo, but doesn't sound like a good permanent solution.
    SylverReZ @ SylverReZ: Now I could go with soldering the contacts from the cable to the connector on the mobo, but...