[SDL] Problem with events in a console application

Started by
3 comments, last by ericode 16 years, 11 months ago
I want to use SDL for handling the windows-console input, but SDL doesn't get any inputs, until I don't create a "video" window. I've searched the forum, but the only topic I found was: http://www.gamedev.net/community/forums/topic.asp?topic_id=382423&forum_id=31&gforum_id=0 And there is the problem unsolved, too. Maybe can somebody help me now? [Edited by - am2pm on July 7, 2006 3:35:54 AM]
Advertisement
SDL only can capture input from a window created with SDL_SetVideoMode. Notice that there is no SDL_INIT_EVENTS flag to pass to SDL_Init. The video and event subsystems go hand in hand.

I don't think there is any way around this sorry.
Don't know if this is an answer or not - but have you tried to do the SDL_INIT_EVENTTHREAD?

It says it's supposed to run the event manager in a seperate thread, whether or not this goes hand in hand with the video init still is beyond me though.

Check it out and let us know.
-AfroFire is Brin & Brin is AfroFire
In addition to the problems already observed with using SDL to write a console application there is the added problem that stdout and stderr get redirected to files unless you do something special to main().

I've written a sound player that used SDL_mixer using command line arguments but can't display the usage text on the console because of the output redirection and I DO have an SDL window open. It's just a hassle to output text to an SDL window unless you use SDL_TTF or something similar to do the job. [sad]
I've been having a headache recently with SDL for our Windows multiplayer game we are making. We wanted to see console output (not stdout.txt redirection) in the beginning part of the game when connections to servers are being made. None of the solutions I saw worked except for this one. Perhaps it will also work for getting console input.

The solution was at this site: http://osdir.com/ml/lib.sdl/2002-11/msg00246.html
and the makefile options soultion didn't work for me, but this one did:

Just add this code right inside your main method:

AllocConsole();
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);

Hope this helps someone avoid the trouble we had.

~ericode

This topic is closed to new replies.

Advertisement