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 / Release Key

Author
Message
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 06:29
dbKeyState is driving me nuts! Is there any function available in any library for C++ that resembles a release key function which I can use with DGDK? 'Cuz I am really fed up with KeyState...

~~It's not who you are underneath, but what you do that defines you.~~
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th May 2008 07:48
While there are functions for reading the keyboard in C/C++ you'll find that they're designed to work in console mode rather than a windowed mode. I just tried a quick test of getch(), which returns a character typed at the keyboard. It should have waited until I pressed a key but it didn't.

So, I guess the answer is no.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 08:15
Quote: "So, I guess the answer is no"


Oh... Oh well... I found sort of a way around it... But why? WHY???

Quote: "I just tried a quick test of getch(), which returns a character typed at the keyboard. It should have waited until I pressed a key but it didn't.
"


What do you mean by it didn't wait until you pressed a key? Does that function have mind-reading powers that detect what key you are about to press and goes ahead and displays it?

~~It's not who you are underneath, but what you do that defines you.~~
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 10th May 2008 08:27
In a console program if you have code like

char ch;
ch = getch(); // sometimes getchar()

When the program gets to the second statement it pauses until you press a key and returns the character that was pressed. That would then be assigned to ch. Usually this input is done in a loop and the character would be added to a string or character buffer. Normally the loop would be designed to exit when you pressed the Enter key.

In my test program it didn't pause at the ch = getch(); statement. It did leave a value in ch but that might have been a random value from when the storage was allocated.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 09:17
Oh... OK... Anyways... Thanks for trying!

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 14:01 Edited at: 10th May 2008 22:34
Try something like this...

Declaration...


example in your loop somewhere...


Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 10th May 2008 20:37
Wonderful...

I haven't tried it yet but I see how the logic works ... Thanks a lot...

~~It's not who you are underneath, but what you do that defines you.~~
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA

Login to post a reply

Server time is: 2024-11-20 09:21:32
Your offset time is: 2024-11-20 09:21:32