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.

DarkBASIC Professional Discussion / Problems with keystate()

Author
Message
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 17th Aug 2010 00:07
This is really starting to get annoying. It seems to me that keystate assigns some keys a higher priority than others. I'm having problems with this in my current project(A one player, top-down, helo shooter), as well as others. I've checked and rechecked, and each key affects a different variable, and are independent of one another, yet some keys will block the presses of other keys. Is this a problem with DBPro? Or, am I just not getting it?

Here's the code I was using:

This code has no problem. But, I need the player to use their right hand for the mouse, and so I need WASD controls.

So, I changed it to this:


As you can see, the four function work independently. Yet unlike the leftkey(), upkey(), etc. commands, you can only have one or two pressed, and then the keyboard no longer receives input from any other keys... Is there a better way to detect key presses?

Thanks in advance, ADM.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Aug 2010 00:38
It's just the way keyboards are designed. They don't allow too many keys at once. You'll never get all 4 keys to work at the same time unless you have a special keyboard. At the most you'll be moving forward or back and either going left or right. Not forward, back and left at the same time.



Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 17th Aug 2010 00:39
You share the same variable names, maybe that's why you're having problems??

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2010 00:41 Edited at: 17th Aug 2010 00:44
Quote: "Yet unlike the leftkey(), upkey(), etc. commands, you can only have one or two pressed,"


What do you mean? The following program seems to detect all four without problem.



Edit @Grog GrueSlayer

Quote: "You'll never get all 4 keys to work at the same time unless you have a special keyboard."


How do I check whether I have a special keyboard?
Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 17th Aug 2010 00:57
You could just test this simple program I guess. Holding down all 4 keys.
My keyboard registers 3 at maximum.


My computer can render anything no matter the complexity of it in real time.
The memory is enormous. My computer is unique to everyone else’s. What computer do I have?

Jeff032
18
Years of Service
User Offline
Joined: 13th Aug 2007
Location:
Posted: 17th Aug 2010 01:03
Mine is able to detect all 4 keys at the same time

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2010 01:10
With this code I can detect 5 keys



Perhaps my keyboard is special after all.
Alsan
21
Years of Service
User Offline
Joined: 20th May 2005
Location: Germany - Nähe Kassel
Posted: 17th Aug 2010 01:14 Edited at: 17th Aug 2010 01:16
Hiho,

here's some more info on that problem: http://www.akuhost.com/binaryagents/download.php?file=keyboardghosts.pdf

/edit: On a further look, it might also describe another problem. But at least it gives an insight into the keyboard.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 17th Aug 2010 02:50 Edited at: 17th Aug 2010 02:50
Quote: "How do I check whether I have a special keyboard?"


Probably anything better than a $10 keyboard like mine.

Here's Microsofts SideWinder X4 keyboard that lets you press 26 keys at a time: http://www.microsoft.com/hardware/gaming/ProductDetails.aspx?pid=105&active_tab=systemRequirements

Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 17th Aug 2010 06:18
So, is there no way to read any bits or bytes anywhere in the memory to detect for as many keys as you need? It's limited by the hardware itself?

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Aug 2010 14:30
Why on earth would anyone need to press 26 keys at once?
Non Sequitur M
17
Years of Service
User Offline
Joined: 28th Oct 2008
Location: Where am I!? Where are YOU?
Posted: 17th Aug 2010 19:19
I don't know! A little absurd. I'd think that 8 max would be the necessary limit, being that you only really use 4 fingers from each hand on average!

But, I did find if I ordered the commands differently, and in pairs, that I could make the opposing keys clash instead of the forward and rotate left controls! Now, my helo works fine.

If life were like a box of chocolates, I'd know what I would get... The one that got dropped on the floor and put back in the box.

Iye nehvur yoose spehl chehk, ahn mie tippyng izz fiyne.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Aug 2010 01:32
Quote: "It's limited by the hardware itself?"


Yes, you saw the variety of keys everybody could press at a time. It's definitely hardware and not Darkbasic Pro.

Yeah, 26 keys is a little crazy but it would be an interesting security measure to make a program that required 10+ keys to start. People could copy the program but never be able to run it since no other keyboard could come close to detecting that many keys at a time.

Madscientist
16
Years of Service
User Offline
Joined: 23rd Aug 2009
Location: Between a rock and a hard place
Posted: 18th Aug 2010 18:11
I could just imagine that program:
"Welcome. Please enter a 26 letter password holding down every key at once to begin."

My computer surpasses all the technologies of the day. What computer do I have?

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 18th Aug 2010 18:30
You could even tell them which keys to hold down and try as they might they wouldn't be able to do it.

Login to post a reply

Server time is: 2026-07-25 02:46:38
Your offset time is: 2026-07-25 02:46:38