Jump to content
  • Advertisement
Sign in to follow this  
am2pm

Unity [SDL] Problem with events in a console application

This topic is 4131 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!