Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / User-Input Commands

Author
Message
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 29th Mar 2010 00:28
I know that there are functions for acquiring user-input but would like to know just when are the user-inputs recognized? That is, are keystrokes recognized immediately upon occurance (and thus two sequential calls to dbKeyState(17) could return different results) or are key-states polled within LoopGDK (where both calls to dbKeyState(17) would return the same results)?

Thanks,
JTK
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 29th Mar 2010 01:59
Key states are updated in every dbSync() call. I tested it with this:



"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 29th Mar 2010 03:26
That doesn't make sense. dbSync is used to refresh the screen, not user input. From reading the documentation, the dbSync command is essentially the equivalent of the proverbial Flip() in the older days (show the back-buffer).

How exactly did you test it? Are you sure that user-input isn't threaded?

Just asking,
JTK
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 29th Mar 2010 04:55
Whoops I was wrong. It is real time just like GetAsyncKeyState.

Nevermind

"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 29th Mar 2010 06:17
That's what I thought. Basically, as far as I can tell, the following code snippet has a potential for, not just a bug - but a virtually unreproduceable bug:



This is definately the makings of a virtually untraceable bug! That's why I never really liked the code snippets that show such possible conditions...

Is there a way to tell GDK *when* to read the keyboard/mouse/joystick? Or do we have to resort to WIN32's GetKeyboardState() and related functions? Personally, I don't mind if I have to, but would rather not - if for no other reason than to be consistant...


Anyone?

JTK
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 29th Mar 2010 21:36
Well, you could use a boolean.



But I'm not sure if a user could press and release a key that fast to make what you said true.

I made an input class a while ago that updates only when you want it to, and includes double click, release, etc.

"A computer once beat me at chess, but it was no match for me at kick boxing."
Emo Philips
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 30th Mar 2010 03:42
One word: Multithreaded!

That would most likely be how it would happen... we perform the first test, process is stopped for the new thread to take over, user removes their finger, process is restarted where it left off...


Just my take on it, anyway.

JTK
entomophobiac
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location: United States
Posted: 30th Mar 2010 13:54
Generally speaking, I don't think it's a good idea to make the same check several times in one cycle, anyway. Store the input at the start of the cycle and then refer to your storage rather than the built-in functions.

I think that's generally a better idea.

Login to post a reply

Server time is: 2024-11-20 01:27:19
Your offset time is: 2024-11-20 01:27:19