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 / Taking In Controls Using KeyState()

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 25th Sep 2008 09:31
How do I take in controls using KeyState()? What arguments do I pass in?

Is there another way to do controls?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 25th Sep 2008 14:04
int dbKeyState(int iScancode); will return an integer value that is either 1 or 0 . The integer iScancode is the ACSII scancode of the keys. it will return 1 if the key represented by iScancode is pressed, otherwise it will return 0.

you can also call void dbScancode(void); .. this function will return an integer value that represents the scancode of the key currently being pressed... so if you pressed A it would return 30 ... if you pressed B it would return 48 etc..

there are a number of ways you can code "controls" it would depend on what you are controlling and how you need it controlled... i mean, if its an aircraft you do it a certain way, if its a person, another way...

There are also commands inside GDK for reading other control devices other than the keyboard alone.. mouse, forcefeed joysticks etc...

If it ain't broke.... DONT FIX IT !!!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 25th Sep 2008 15:44
Quote: "The integer iScancode is the ACSII scancode of the keys"

What's an ASCII scancode? It's just a scancode.
All the values are available within DirectX as defines with a prefix of DIK_.

E.g.
DIK_W has the scancode for the letter W
DIK_UP has the scancode for the up key

Look in the DX header file dinput.h for the full list.

Login to post a reply

Server time is: 2024-09-30 07:19:28
Your offset time is: 2024-09-30 07:19:28