I can't get SDL_WaitEvent() to work on Windows

Sorry for being galatically stupid, but I cannot seem to get SDL_WaitEvent() to work on a windows console app. Here’s what I’ve got:

WindowsXP
SDL 1.2.9
Visual Studio 2005 - Created a C++ Windows Console Application.
Run the application, hit keys, move the mouse do everything, but it never returns from SDL_WaitEvent() unless I hit “control+C” in which case it crashes somewhere in kernel32.dll (with nothing useful on the stack).

Any help would be greatly appreciated.

-phil

My source code:

#include “sdl.h”

int main(int argc, char** argv)
{
argc;
argv;

SDL_Event ev = {0};

if (-1 != SDL_Init(SDL_INIT_EVERYTHING))
{

    do
    {
        if (SDL_WaitEvent( &ev ))
        {
            printf("SDL_WaitEvent()\n");

            // handle keypress
            if (SDL_KEYDOWN == ev.type)
            {
                printf("key was pressed %d\n", ev.key);
            }
        }
        printf("SDL_WaitEvent()\n");

    } while (SDL_QUIT != ev.type);

    SDL_Quit();

}

return 0;

}____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

Im pretty sure the event system is dependant on the windowing system,
meaning you must create a window using SDL_SetVideoMode (SDL_QUIT
seems to be independent, but that’s not quite what you want :).

There are non-SDL functions you get with your compiler to do what you
want in a console program, goolge kbhit and getch (they arent standard
AFAIK and vary from compiler to compiler).On 28/07/07, Philip Pellouchoud wrote:

Sorry for being galatically stupid, but I cannot seem to get SDL_WaitEvent()
to work on a windows console app. Here’s what I’ve got:

WindowsXP
SDL 1.2.9
Visual Studio 2005 - Created a C++ Windows Console Application.
Run the application, hit keys, move the mouse do everything, but it never
returns from SDL_WaitEvent() unless I hit “control+C” in which case it
crashes somewhere in kernel32.dll (with nothing useful on the stack).

Any help would be greatly appreciated.

-phil

Yeah it’s a bummer but kbhit and getch vary widely in functionality across
compilers.

Because of this, I myself generally do something like this (so the user has
to press enter):

int I;
scanf("%i",&I);

Or this is helpful on windows…

system(“pause”);

that makes the “Press any key to continue . . .” message come up to the user
(same as putting “pause” in at the command prompt).> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Brian
Sent: Saturday, July 28, 2007 12:37 PM
To: Philip Pellouchoud; A list for developers using the SDL library.
(includes SDL-announce)
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…

Im pretty sure the event system is dependant on the windowing system,
meaning you must create a window using SDL_SetVideoMode (SDL_QUIT
seems to be independent, but that’s not quite what you want :).

There are non-SDL functions you get with your compiler to do what you
want in a console program, goolge kbhit and getch (they arent standard
AFAIK and vary from compiler to compiler).

On 28/07/07, Philip Pellouchoud wrote:

Sorry for being galatically stupid, but I cannot seem to get
SDL_WaitEvent()
to work on a windows console app. Here’s what I’ve got:

WindowsXP
SDL 1.2.9
Visual Studio 2005 - Created a C++ Windows Console Application.
Run the application, hit keys, move the mouse do everything, but it never
returns from SDL_WaitEvent() unless I hit “control+C” in which case it
crashes somewhere in kernel32.dll (with nothing useful on the stack).

Any help would be greatly appreciated.

-phil


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Uh… Not to be a whiner or anything, but isn’t that what SDL is supposed to do, abstract away platform specific details?

-phil> ----- Original Message -----

From: atrix2@cox.net (atrix2)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Saturday, July 28, 2007 1:00:10 PM
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…

Yeah it’s a bummer but kbhit and getch vary widely in functionality across
compilers.

Because of this, I myself generally do something like this (so the user has
to press enter):

int I;
scanf("%i",&I);

Or this is helpful on windows…

system(“pause”);

that makes the “Press any key to continue . . .” message come up to the user
(same as putting “pause” in at the command prompt).

-----Original Message-----
From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Brian
Sent: Saturday, July 28, 2007 12:37 PM
To: Philip Pellouchoud; A list for developers using the SDL library.
(includes SDL-announce)
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…

Im pretty sure the event system is dependant on the windowing system,
meaning you must create a window using SDL_SetVideoMode (SDL_QUIT
seems to be independent, but that’s not quite what you want :).

There are non-SDL functions you get with your compiler to do what you
want in a console program, goolge kbhit and getch (they arent standard
AFAIK and vary from compiler to compiler).

On 28/07/07, Philip Pellouchoud <@Philip_Pellouchoud> wrote:

Sorry for being galatically stupid, but I cannot seem to get
SDL_WaitEvent()
to work on a windows console app. Here’s what I’ve got:

WindowsXP
SDL 1.2.9
Visual Studio 2005 - Created a C++ Windows Console Application.
Run the application, hit keys, move the mouse do everything, but it never
returns from SDL_WaitEvent() unless I hit “control+C” in which case it
crashes somewhere in kernel32.dll (with nothing useful on the stack).

Any help would be greatly appreciated.

-phil


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
http://autos.yahoo.com/carfinder/

Perhaps I spoke too early and off topic (:

If no one else speaks up, if I were in your shoes id look to see how to
create an sdl application in MSVC. The console application might not be the
way to do it. I only used sdl with mingw/msys in windows so sorry I’m not
more help.

I’m sure there is a good explanation for it though…hopefully someone more
knowledgeable will speak up________________________________________
From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Philip Pellouchoud
Sent: Saturday, July 28, 2007 8:36 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…

Uh…? Not to be a whiner or anything, but isn’t that what SDL is supposed
to do, abstract away platform specific details?

-phil

----- Original Message -----
From: @atrix2 (atrix2)
To: A list for developers using the SDL library. (includes SDL-announce)

Sent: Saturday, July 28, 2007 1:00:10 PM
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…
Yeah it’s a bummer but kbhit and getch vary widely in functionality across
compilers.

Because of this, I myself generally do something like this (so the user has
to press enter):

int I;
scanf("%i",&I);

Or this is helpful on windows…

system(“pause”);

that makes the “Press any key to continue . . .” message come up to the user
(same as putting “pause” in at the command prompt).

-----Original Message-----
From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Brian
Sent: Saturday, July 28, 2007 12:37 PM
To: Philip Pellouchoud; A list for developers using the SDL library.
(includes SDL-announce)
Subject: Re: [SDL] I can’t get SDL_WaitEvent() to work on Windows…

Im pretty sure the event system is dependant on the windowing system,
meaning you must create a window using SDL_SetVideoMode (SDL_QUIT
seems to be independent, but that’s not quite what you want :).

There are non-SDL functions you get with your compiler to do what you
want in a console program, goolge kbhit and getch (they arent standard
AFAIK and vary from compiler to compiler).

On 28/07/07, Philip Pellouchoud wrote:

Sorry for being galatically stupid, but I cannot seem to get
SDL_WaitEvent()
to work on a windows console app.??Here’s what I’ve got:

WindowsXP
SDL 1.2.9
Visual Studio 2005 - Created a C++ Windows Console Application.
Run the application, hit keys, move the mouse do everything, but it never
returns from SDL_WaitEvent() unless I hit “control+C” in which case it
crashes somewhere in kernel32.dll (with nothing useful on the stack).

Any help would be greatly appreciated.

-phil


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Be a better Globetrotter. Get better travel answers from someone who knows.
Yahoo! Answers - Check it out.

Perhaps I spoke too early and off topic (:

If no one else speaks up, if I were in your shoes id look to see how to
create an sdl application in MSVC. The console application might not be the
way to do it.

Yes, SDL abstracts keyboard events in a windowed application, not stdin.

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