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: 120

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Psionic Roshambo @ Psionic Roshambo:
    Sounds like it would be an exciting ride....
  • Psionic Roshambo @ Psionic Roshambo:
    Not sure I would want something on fire between my legs
  • BigOnYa @ BigOnYa:
    He ruined it basically. Sad cause it was a decent old bike. It would take more money to rewire the bike than it was worth tho.
  • Psionic Roshambo @ Psionic Roshambo:
    Yeah I'm sure at minimum the starter was fried
  • Psionic Roshambo @ Psionic Roshambo:
    Alternator and battery
  • BigOnYa @ BigOnYa:
    Prob alot of fried parts. It was still smoking when I left.
  • K3Nv2 @ K3Nv2:
    I would've said show me how it rides
  • Psionic Roshambo @ Psionic Roshambo:
    I always wanted one of those Smart Cars with a Hyabusa motor in it.
  • K3Nv2 @ K3Nv2:
    I'm getting sick and tired of cheap ass baking pans now
  • BigOnYa @ BigOnYa:
    I think it be cool to have one that would fit in my pickup truck bed, then I could put down ramps n drive it off.
  • K3Nv2 @ K3Nv2:
    Used this one 5 times already impossible to clean
  • BigOnYa @ BigOnYa:
    You need the $900 copper coated ones, they are good for 10 times cooking before they are un cleanable
  • Psionic Roshambo @ Psionic Roshambo:
    Condoms are only meant to be used once Ken lol
  • K3Nv2 @ K3Nv2:
    Well damn that explains how you were born
  • BigOnYa @ BigOnYa:
    I tried Cavier for the first time today. That shit is nasty. Don't get why people like it.
  • Psionic Roshambo @ Psionic Roshambo:
    Eh it's good with Vodka and crackers
  • Psionic Roshambo @ Psionic Roshambo:
    Gotta have the whole experience
  • Psionic Roshambo @ Psionic Roshambo:
    Drink enough vodka so you can barely taste it
  • K3Nv2 @ K3Nv2:
    Depends on brand rich rich people spend like 500 a tin
  • Psionic Roshambo @ Psionic Roshambo:
    What I'm putting down is you gotta be trashed first lol
    +1
  • K3Nv2 @ K3Nv2:
    Like if psi fucked the fish the quality of the eggs will probably come out abnormal
  • BigOnYa @ BigOnYa:
    We had it spread on crackers, n I had Rum/Coke today. I like all fish and seafoods, but not that.
    BigOnYa @ BigOnYa: We had it spread on crackers, n I had Rum/Coke today. I like all fish and seafoods, but not that.