Page 1 of 1
Keyboard test...
Posted: Wed Nov 19, 2003 1:13 pm
by Psychophanta
Should be easely possible to add a directinput Keyboard funtion to examine and capture in memory all the complete keyboard status matrix and work with it?
It would avoid to call lot of times to KeyboardPushed() function inside a loop.
Thanx

Posted: Wed Nov 19, 2003 2:47 pm
by blueznl
euh, isn't that what's currently happening? examinekeyboard() fills the memory and then you check the dfferent keys? or am i missing the point here?
Posted: Wed Nov 19, 2003 3:27 pm
by Psychophanta
I just requested for a keyboard function which dump the keyboard status to a 128-bit variable.
A 128-bit variable (memory address) would be enough for all keyboard keys (a bit, a key) to see whether a key is pushed or not.
Posted: Wed Nov 19, 2003 3:54 pm
by blueznl
ah... didn't get it at first
i think a simple directx call should do the job (though don't ask me how to do it, i do not have a clue)

Posted: Thu Nov 20, 2003 2:14 am
by PB
> I just requested for a keyboard function which dump the keyboard
> status to a 128-bit variable.
The GetKeyboardState API is supposed to do just that, but I haven't
tried it -- maybe you can get this VB example working in PureBasic:
http://www.mentalis.org/apilist/GetKeyboardState.shtml
Re: Keyboard test...
Posted: Thu Nov 20, 2003 2:16 am
by Doobrey
Psychophanta wrote:Should be easely possible to add a directinput Keyboard funtion to examine and capture in memory all the complete keyboard status matrix and work with it?
No need for DirectInput.. Use GetKeyboardState_() API command.
According to API Guide, "The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer."
Dim Keys.b(256)
GetKeyboardState(@Keys[0])
Posted: Thu Nov 20, 2003 12:15 pm
by Psychophanta
This should work:
Code: Select all
*mem=AllocateMemory(0,256,0)
If *mem
GetKeyboardState_(*mem)
For *t=*mem To *mem+255
Debug PeekB(*t)
Next
EndIf
however, I've tried and GetKeyboardState() is too slow. It is a weak
Thanks anyway you Doobrey and PB.
Doobrey, i guess you can't assure that an array has its elements contiguous in memory.
For those interested here is a complete list for that which Microsoft calls Virtual Key Codes:
http://msdn.microsoft.com/library/defau ... _codes.asp