Jump to content
  • Advertisement
Sign in to follow this  
sarthakz99

input in realtime.

This topic is 1412 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

Advertisement

1.) It would be helpful to know what operating system you want to use.

 

2.) What is "realtime" in your case? You know, realtime means fast enough to not cause noticeable artifacts, but that depends also on the environment where the input should be handled.

Share this post


Link to post
Share on other sites
i'm creating a game in c++ .
i need to take input from user....while the display function still continue its work...

but actually in my program...
compiler is waiting for user input in every frame.

i'm using win xp sp 3.

Share this post


Link to post
Share on other sites

A few things:

 

The compiler runs only once, to create the executable file, it is not running when you run the game (compile time and run time are completelly different things), so the compiler can't be waiting for user input. I guess you mean the app itself, you'll get more help using the correct words.

 

Most APIs like SDL and SMFL have 2 methods for handling input, event driven  and state drive.

 

Event driven means the API stores events in one place, and when you checks for events (keyUp, keyDown, etc) they are removed. This way you don't wait for input, you just process everything that happened since your last check and move on, if there's nothing to process, nothing is blocked.

 

State driven means that you check for the state of the input when you need to, and do stuff if the state is the one you need.

 

The aproach of "wait until there's input" is mostly used in console applications where you stop while waiting for something from "standard input" or a network, which is actually a text input, it's not really meant to be used to detect key presses.

 

Anyway, if you can't use events or check the state of a particular key, you can run separated threads, one for rendering and one for input handling and game state update, but you need to take care of concurrency.

Edited by DiegoSLTS

Share this post


Link to post
Share on other sites

You will never be able to get real-time input from any Windows operating system, as these are not real-time operating systems (RTOS). Windows lets you get keyboard presses and depresses as events (and you can also get the internal timer value for when this happened) as window messages sent to a window, or to get the state of the keys (pressed or not) at any time. It's up to you to use all of these in such a way that the user thinks everything is happening in real-time.

 

Also, console programs are a bit different, as they put the key events into an input buffer that you can read from, and in this case, I don't think you can get the timer value for when the event happened...

 

Since you haven't specified what sort of program you are writing (console or GUI), the question still remains too broad for us to give you a straight answer.

Edited by tonemgub

Share this post


Link to post
Share on other sites

You will never be able to get real-time input from any Windows operating system, as these are not real-time operating systems (RTOS). Windows lets you get keyboard presses and depresses as events (and you can also get the internal timer value for when this happened) as window messages sent to a window, or to get the state of the keys (pressed or not) at any time. It's up to you to use all of these in such a way that the user thinks everything is happening in real-time.

 

Also, console programs are a bit different, as they put the key events into an input buffer that you can read from, and in this case, I don't think you can get the timer value for when the event happened...

 

Since you haven't specified what sort of program you are writing (console or GUI), the question still remains too broad for us to give you a straight answer.

 

Every time I see a "realtime" thread, one moronic wannabe just shows up trying to make the OP feel as stupid as possible.

It is incredibly obvious that the OP is a beginner, and doesn't need actual realtime input.

 

Edit:

Lol at the downvotes. I'm speaking the damn truth. It's okay to mention that realtime isn't the correct term.

However: "omg but realtime is not possible on Windows" etc... that is the kind of attitude that I am talking about here.

Why not just casually mention it and move on to actually answering the question?

Don't just treat the topic as if it actually is something else than what the OP intended.

Edited by diventurer

Share this post


Link to post
Share on other sites


Every time I see a "realtime" thread, one moronic wannabe just shows up trying to make the OP feel as stupid as possible.

It is incredibly obvious that the OP is a beginner, and doesn't need actual realtime input.

Sorry... I wasn't trying to make anyone feel stupid.

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!