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.

Code Snippets / [DBP (maybe DBC] Advanced Keyboard Input Example

Author
Message
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 19th Oct 2008 13:00
For the sake of keeping this to the point, the code contains a list of constants for every key on a standard 101 keyboard, plus an example on how to use it, by making it print out to the screen text descriptions of the modern FPS WASD style controls with capslock to toggle autorun, and ctrl to crouch




Everything I needed to know about trigonometry, I learned by becoming a game programmer.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 20th Oct 2008 05:01 Edited at: 20th Oct 2008 05:08
Pretty useful for those too lazy to use the keystate chart. It looks like it was time consuming... Anyway, it would be a pretty useful #include file to say the least

Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 16th Jan 2009 06:48
although the keystate can't use the f1 f2 ect. keys. well in dbc atleast as far asi know
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jan 2009 11:24
Quote: "Pretty useful for those too lazy to use the keystate chart."


Where can we find this keystate chart?
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Jan 2009 12:40 Edited at: 22nd Jan 2009 12:41
I think it was GogetaX that made this one:



It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Attachments

Login to view attachments
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 4th Apr 2009 01:01 Edited at: 4th Apr 2009 01:33
I actually prefer to use the constants because it means that I don't have to go look at a graphical chart to turn a number in my source into as key. It's easier for me just to use the constants so that I'm not wondering "wait, what key is this number again?"

To Caleb, DBPro's keystate() can handle the entire keyboard.

Everything I needed to know about trigonometry, I learned by becoming a game programmer.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 7th Apr 2009 00:12
My keyboard even gives keystates for all the wierd buttons like the volume controls, back and forward, sleep mode, etc.



Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 10th Apr 2009 18:44
Quote: "My keyboard even gives keystates for all the wierd buttons like the volume controls, back and forward, sleep mode, etc."


Yeah, those keystates are fairly standard by these days... I have put together a hackintosh that actually runs stock, retail copies of MacOSX and even it takes my volume controls and whatnot. when I get a moment away from my current project, I'll update my snippet here with all those extra keystates...

Everything I needed to know about trigonometry, I learned by becoming a game programmer.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Apr 2009 22:37
@Caleb
DBC can use the keystates of all of the keyboard. You just have to query the scancode



Just a note for DBC, scancode() returns keys by priority so if you press 2 keys on the keyboard, the only value that will be returned is the highest priority (the lowest scancode). For example, try holding K and pressing A. The code will switch to A. But if you do the opposite, A will not switch to K. However, as the example Lucy posted shows, keystate() will return the condition of simultaneous keypresses for DBC.

Enjoy your day.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Apr 2009 09:19 Edited at: 12th Apr 2009 09:20
instead of

You could do

Since a keystate can only be 1 or 0, if the new keystate is greater than the last then it must be 1 and the old keystate must be 0.

can't read?

Login to post a reply

Server time is: 2024-11-22 01:11:19
Your offset time is: 2024-11-22 01:11:19