ExamineKeyboard -> KeyMap
Posted: Wed Sep 12, 2007 10:30 pm
I don't know if it was requested before...
as far I understand it, I estimate that ExamineKeyboard() requests a KeyMap
(256byte Array, quite similar to GetKeyboardState_() )
and KeyboardPushed() or KeyboardReleased() handle upon that keymap.
would it be possible to implement a more direct Handling of the KeyMap?
I'd like to access it via array,
- to handle first press of several keys more conveniant
setting a flag for each key is not that good show,
copying the "actual pressed"-Array into a "last pressed"-Array
and comparing them would greatly reduce the efford.
- to perform custom control-maps
in most games you can define your own controls.
those are best handeled via an transformation-Array
having all keys "pressed or not" in one array with greatly simplify the handling in our own games.
I estimate there already is an "actual pressed"-Array for KeyboardPushed(),
perhaps there is also a "last pressed"-Array for KeyboardReleased().
more basic access to the internal Data of the Keyboard-Lib would be a bless for Game-Programming.
(KeyboardInkey is no alternative to this)
;***********************************************
PS:
just thought a little bit more about it....
an additional KeyboardWasPushed() would do it.
maybe it's already in there, because
KeyboardWasPushed() would at once ease handling of the First Push of any Key.
at the moment I handle it via an own Array KeyOld()
..the ControlMapping is an additional topic, I have to think more about this,
to figure out what would be the easiest solution.
;***********************************************
PPS:
I post my actual Procedure to solve the FirstPress here:
works with any #PB_Key_ Constant, except #PB_Key_Any
as far I understand it, I estimate that ExamineKeyboard() requests a KeyMap
(256byte Array, quite similar to GetKeyboardState_() )
and KeyboardPushed() or KeyboardReleased() handle upon that keymap.
would it be possible to implement a more direct Handling of the KeyMap?
I'd like to access it via array,
- to handle first press of several keys more conveniant
setting a flag for each key is not that good show,
copying the "actual pressed"-Array into a "last pressed"-Array
and comparing them would greatly reduce the efford.
- to perform custom control-maps
in most games you can define your own controls.
those are best handeled via an transformation-Array
having all keys "pressed or not" in one array with greatly simplify the handling in our own games.
I estimate there already is an "actual pressed"-Array for KeyboardPushed(),
perhaps there is also a "last pressed"-Array for KeyboardReleased().
more basic access to the internal Data of the Keyboard-Lib would be a bless for Game-Programming.
(KeyboardInkey is no alternative to this)
;***********************************************
PS:
just thought a little bit more about it....
an additional KeyboardWasPushed() would do it.
maybe it's already in there, because
Code: Select all
KeyboardReleased(#Key) = Not KeyboardPushed(#Key) And KeyboardWasPushed(#Key)
at the moment I handle it via an own Array KeyOld()
Code: Select all
If KeyboardPushed(#PB_Key_Escape)
If Not KeyOld(#PB_Key_Escape) ; first press
KeyOld(#PB_Key_Escape) = 1 ; set KeyFlag
If MENU ; in Menu
EXIT = 1 ; leave Game
Else ; in Play
MENU = 1 ; exit to Menu
EndIf
EndIf
Else
KeyOld(#PB_Key_Escape) = 0 ; reset KeyFlag
EndIf
to figure out what would be the easiest solution.
;***********************************************
PPS:
I post my actual Procedure to solve the FirstPress here:
Code: Select all
Global Dim KeyOld.l(255)
Procedure.l KeyHit( Key.l )
Protected HIT = #False
If KeyboardPushed(Key)
If Not KeyOld(Key) ; first press
KeyOld(Key) = #True ; set KeyFlag
HIT = #True
EndIf
Else
KeyOld(Key) = #False ; reset KeyFlag
EndIf
ProcedureReturn HIT
EndProcedure