Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Psychophanta
Always Here
Posts: 5153 Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:
Post
by Psychophanta » Wed Nov 19, 2003 1:13 pm
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
blueznl
PureBasic Expert
Posts: 6172 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Wed Nov 19, 2003 2:47 pm
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?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide
right here ... )
Psychophanta
Always Here
Posts: 5153 Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:
Post
by Psychophanta » Wed Nov 19, 2003 3:27 pm
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.
blueznl
PureBasic Expert
Posts: 6172 Joined: Sat May 17, 2003 11:31 am
Contact:
Post
by blueznl » Wed Nov 19, 2003 3:54 pm
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)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide
right here ... )
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Thu Nov 20, 2003 2:14 am
> 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
Doobrey
Enthusiast
Posts: 218 Joined: Sat Apr 26, 2003 4:47 am
Location: Dullsville..population: me
Contact:
Post
by Doobrey » Thu Nov 20, 2003 2:16 am
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])
Psychophanta
Always Here
Posts: 5153 Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:
Post
by Psychophanta » Thu Nov 20, 2003 12:15 pm
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