SDL_Settimer not functioning in Mingw32/Dev C++

First, thanks to Bob Pendleton who helped me with my OpenGL/SDL problem.

Here’s my latest problem: I decided to port a game I was writing, Lords of Chaos (a semi-official remake of the old 8-bit game), to SDL, both to learn and so the game would run on non-Windows platforms.

I have a timer to enable key repeats (it runs 10 times a second so when the user holds down a key, it repeats until a KEYUP event).

Once I got the game working in Visual C++ 6, I then got it working with Mingw32 (using the Dev C++ IDE). Everything looks fine and it compiles, but the call to SetTimer seems to be ignored (and the same code works under VC6). I am using Mingw32.a, and the 1.2 SDL library for Mingw32. In my IDE, I set a breakpoint on a line of code in the timer routine, and nothing happened!

I just tried this on Dev C++ with a build of SDL specially for Dev C++, the same problem occurred.

Here’s my code.

In main:

SDL_SetTimer(150,mycallback);

Which calls:

Uint32 mycallback(Uint32 interval)
{
MyUI.DrawMap(NULL);
handlekeys();
return interval;
}

And I should point out that this function is not called once (so it’s not the return value not causing another timer to take place).

I hope this is enough information!

Cheers,

Jeremy.

I have a timer to enable key repeats (it runs 10 times a second so when the user holds down a key, it repeats until a KEYUP event).

First, you know that SDL supports variable key repeat rate directly, right?
Second, did you initialize SDL with SDL_INIT_TIMER?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment