Amulets & Armor  v1.02
Open Source Game
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions
KEYBOARD

Keyboad Controls. More...

Macros

#define KEYBOARD_HIGHEST_SCAN_CODE   255
 
#define MAX_SCAN_KEY_BUFFER   128
 

Functions

T_void KeyboardAllowKeyScans (T_void)
 
T_byte8 KeyboardBufferGet (T_void)
 
T_void KeyboardBufferOff (T_void)
 
T_void KeyboardBufferOn (T_void)
 
E_Boolean KeyboardBufferReady (T_void)
 
T_void KeyboardDebounce (T_void)
 
T_void KeyboardDisallowKeyScans (T_void)
 
T_keyboardEventHandler KeyboardGetEventHandler (T_void)
 
T_word32 KeyboardGetHeldTimeAndClear (T_word16 scanCode)
 
E_Boolean KeyboardGetScanCode (T_word16 scanCodes)
 
T_void KeyboardOff (T_void)
 
T_void KeyboardOn (T_void)
 
T_void KeyboardPopEventHandler (T_void)
 
T_void KeyboardPushEventHandler (T_keyboardEventHandler keyboardEventHandler)
 
T_void KeyboardSetEventHandler (T_keyboardEventHandler keyboardEventHandler)
 
T_void KeyboardUpdateEvents (T_void)
 

Detailed Description

Keyboad Controls.

Routines for tracking which keys are being pressed. In DOS, we even tried to make so we could tell how long a key was pressed. This is less of an issue these days.

See Also
http://www.amuletsandarmor.com/AALicense.txt

Macro Definition Documentation

#define KEYBOARD_HIGHEST_SCAN_CODE   255
#define MAX_SCAN_KEY_BUFFER   128

Function Documentation

T_void KeyboardAllowKeyScans ( T_void  )
T_byte8 KeyboardBufferGet ( T_void  )

If you are using a buffer, you can get keystrokes from the buffer by using this routine.

Returns
ASCII character of gained character or 0 for none.
T_void KeyboardBufferOff ( T_void  )

KeyboardBufferOff will not allow keys to be buffered up for use later. Although useful in word processors, when the buffer gets full it causes a beeping noise that is not wonderful in games. Depending on your need, you may wnat the buffer off.

NOTE: KeyboardBufferOff CAN be called even if KeyboardOn is not. The default is for the buffer to be on.

T_void KeyboardBufferOn ( T_void  )

KeyboardBufferOn will allow keys to be buffered up for use later. Although useful in word processors, when the buffer gets full it causes a beeping noise that is not wonderful in games. Depending on your need, you may wnat the buffer on.

NOTE: KeyboardBufferOn CAN be called even if KeyboardOn is not.

E_Boolean KeyboardBufferReady ( T_void  )
T_void KeyboardDebounce ( T_void  )

Sometimes it is useful to wait for all keys to be released. KeyboardDebounce is a simple routine that just waits until the user has released all pressed keys.

T_void KeyboardDisallowKeyScans ( T_void  )
T_keyboardEventHandler KeyboardGetEventHandler ( T_void  )
T_word32 KeyboardGetHeldTimeAndClear ( T_word16  scanCode)

KeyboardGetHeldTimeAndClear tells how long a key has been held down since the key was last cleared. This capability is useful for getting accurate readings of how long the user desired the key to be pressed, and not based on when calls were able to be made.

NOTE: Calling this routine can be a problem if it has been a long time since it was previously called on a key. If you are unsure, be sure to make a call to KeyboardDebounce which clears the timing values.

E_Boolean KeyboardGetScanCode ( T_word16  scanCodes)
T_void KeyboardOff ( T_void  )

When you are done with the keyboard, you can turn it off by calling KeyboardOff. This will remove the keyboard driver from memory.

NOTE: This routine MUST be called before exiting or DOS will crash.

T_void KeyboardOn ( T_void  )

KeyboardOn installs the keyboard functions of the following commands.

NOTE: This routine can not be called twice in a row and must be called once for the rest of the routines to work correctly (Except the keyboard buffer commands).

T_void KeyboardPopEventHandler ( T_void  )

KeyboardPopEventHandler restores the last handler on the stack (if there is one).

T_void KeyboardPushEventHandler ( T_keyboardEventHandler  keyboardEventHandler)

KeyboardPushEventHandler removes the old handler by placing it on a stack and sets up the new event handler. The old event handler will be restored when a call to KeyboardPopEventHandler is called.

Parameters
keyboardEventHandler– function to call on events, or NULL for none.
T_void KeyboardSetEventHandler ( T_keyboardEventHandler  keyboardEventHandler)

KeyboardSetEventHandler declares the function to be called for each keyboard event as dispatched by the KeyboardUpdateEvents routine. If you no longer need a keyboard handler, give this routine an input parameter of NULL.

Parameters
keyboardEventHandler– function to call on events, or NULL for none.
T_void KeyboardUpdateEvents ( T_void  )

KeyboardUpdateEvents should be called often for it to work correctly with a keyboard event handler. Events are sent by this routine to tell what keys are being pressed and released.