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 / Controls Help!!!

Author
Message
ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 25th Sep 2008 23:55
I've asked this question two times already but no one seems to be able to give me a straight answer.

What I want to do is be a key, lets say 'a', and I want something to happen, lets say "do stuff".

So:

If(a)
{
Do stuff;
}

How do I write this using DarkGDK?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 26th Sep 2008 01:02
You use the dbKeystate function (as per your previous question), passing it the scancode value (as per Mista Wilson's/my answer to your previous question).



ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 26th Sep 2008 01:36
DIK_A is an undelcared identifier
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 26th Sep 2008 07:28 Edited at: 27th Sep 2008 07:20
DIK_A is a previously defined keyboard scancode... EDIT -> an ASCII number... - incorrect usage of term ascii apologies, should read "a Simple integer number"

here is something that might work..



That basically just declares an integer variable to represent the value of the scancode for the A key, which is 30, and passes it to the dbKeyState function. The dbKeyState function returns either 1 or 0 for true or false depending on if the A key is pressed, the variable iIsPressed hold either a 1 or a 0(the return value from dbKeyState()) we check if iIsPressed is equal to 1 each iteration of the while loop, when it tests true, it drops into its loop where //Do Stuff is.

That is just 1 way(and kind of inefficient, just did it like this for ease of understanding), there are many other techniques you can use to detect input. You can use the char* dbEntry() keybuffer.. and read a value from that. Maybe if you download some of the various tutorials and also look through the samples, Dark Invaders is a good one, you can pickup some quite good techniques for using input. Hope this is some help to you, sorry for any kind of confusion.

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: 26th Sep 2008 19:20
First, the answer to ReiKumar's question - the definition is in the dinput.h header file, so just #include it.

Next, let's deal with this scancode/ASCII thing.

The ASCII value of A is 65. The keyboard scancode of A is 30. Why do you keep on referring to an ASCII scancode? In fact I believe that there is no letter, number or symbol on the US/UK keyboard (or most probably, *any* keyboard) where the scancode is the same as the ASCII value of that letter.

Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 27th Sep 2008 07:45
Apologies, I have editted my previous post above... I have used the term ASCII incorrectly, as pointed out, and apologise for any confusion my typos have caused.

To answer the question :
Quote: "Why do you keep on referring to an ASCII scancode? "


I assume the question was asked of myself and in relation to the above post of mine.(I have now editted the 2 occurances of my incorrect usage of the term in that post) I apologise if I have incorrectly used the term elsewhere in a similarly incorrect manner..... I shall try to be more precise in my usage of technical terms in the future, and hopefully avoid any confusion.

Quote: "In fact I believe that there is no letter, number or symbol on the US/UK keyboard (or most probably, *any* keyboard) where the scancode is the same as the ASCII value of that letter.
"


I would have to agree.... (again apologies for my incorrect usage of the term and any confusion it causeed)

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: 27th Sep 2008 14:05
No problem - I was just trying to reduce confusion.

ReiKumar
16
Years of Service
User Offline
Joined: 23rd Sep 2008
Location:
Posted: 28th Sep 2008 06:57
Including the library makes everything work! Thanks!

Login to post a reply

Server time is: 2024-09-30 07:14:31
Your offset time is: 2024-09-30 07:14:31