HPGCC3 Documentation 3.0 R003

keyb.h File Reference

Keyboard management routines for the HP49. More...

Go to the source code of this file.

Defines

#define _LONGLONG_DEF
#define KB_A   41
 Constant for the F1 (A) key.
#define KB_B   42
 Constant for the F2 (B) key.
#define KB_C   43
 Constant for the F3 (C) key.
#define KB_D   44
 Constant for the F4 (D) key.
#define KB_E   45
 Constant for the F5 (E) key.
#define KB_F   46
 Constant for the F6 (F) key.
#define KB_G   47
 Constant for the APPS (G) key.
#define KB_H   53
 Constant for the MODE (H) key.
#define KB_I   54
 Constant for the TOOL (I) key.
#define KB_J   55
 Constant for the VAR (J) key.
#define KB_K   57
 Constant for the STO (K) key.
#define KB_L   58
 Constant for the NXT (L) key.
#define KB_M   33
 Constant for the HIST (M) key.
#define KB_N   25
 Constant for the EVAL (N) key.
#define KB_O   17
 Constant for the ' (O) key.
#define KB_P   9
 Constant for the SYMB (P) key.
#define KB_Q   34
 Constant for the Y^X (Q) key.
#define KB_R   26
 Constant for the Sqrt (R) key.
#define KB_S   18
 Constant for the SIN (S) key.
#define KB_T   10
 Constant for the COS (T) key.
#define KB_U   2
 Constant for the TAN (U) key.
#define KB_V   35
 Constant for the EEX (V) key.
#define KB_W   27
 Constant for the +/- (W) key.
#define KB_X   19
 Constant for the X (X) key.
#define KB_Y   11
 Constant for the 1/X (Y) key.
#define KB_Z   KB_DIV
 Constant for the / (Z) key.
#define KB_0   31
 Constant for the 0 key.
#define KB_1   30
 Constant for the 1 key.
#define KB_2   22
 Constant for the 2 key.
#define KB_3   14
 Constant for the 3 key.
#define KB_4   29
 Constant for the 4 key.
#define KB_5   21
 Constant for the 5 key.
#define KB_6   13
 Constant for the 6 key.
#define KB_7   28
 Constant for the 7 key.
#define KB_8   20
 Constant for the 8 key.
#define KB_9   12
 Constant for the 9 key.
#define KB_BKS   1
 Constant for the backspace key.
#define KB_DIV   3
 Constant for the / (Z) key.
#define KB_MUL   4
 Constant for the * key.
#define KB_ADD   6
 Constant for the + key.
#define KB_SUB   5
 Constant for the - key.
#define KB_DOT   23
 Constant for the . key.
#define KB_SPC   15
 Constant for the SPC key.
#define KB_ENT   7
 Constant for the ENT key.
#define KB_UP   49
 Constant for the up arrow key.
#define KB_DN   51
 Constant for the down arrow key.
#define KB_LF   50
 Constant for the left arrow key.
#define KB_RT   52
 Constant for the right arrow key.
#define KB_ALPHA   60
 Constant for the ALPHA key.
#define KB_LSHIFT   61
 Constant for the left shift key.
#define KB_RSHIFT   62
 Constant for the right shift key.
#define KB_ON   63
 Constant for the ON key.
#define KB_MASK(a)   (((ULONGLONG)1)<<(a))
 Create a bitmask representing the given key.
#define KB_CURS   ((ULONGLONG)0x001e000000000000)
 A bitmask to represent the arrow keys.
#define KB_FUNC   ((ULONGLONG)0x00007e0000000000)
 A bitmask to represent the function keys.
#define SHIFT_LS   0x40
 Shift constant to use in a combined shiftcode. Left Shift.
#define SHIFT_LSHOLD   0x80
 Shift constant to use in a combined shiftcode. Hold-Left Shift.
#define SHIFT_RS   0x100
 Shift constant to use in a combined shiftcode. Right Shift.
#define SHIFT_RSHOLD   0x200
 Shift constant to use in a combined shiftcode. Hold-Right Shift.
#define SHIFT_ALPHA   0x400
 Shift constant to use in a combined shiftcode. Alpha.
#define SHIFT_ALPHAHOLD   0x800
 Shift constant to use in a combined shiftcode. Hold-Alpha.
#define SHIFT_ONHOLD   0x1000
 Shift constant to use in a combined shiftcode. Hold-On key.
#define SHIFT_ANY   0x1fc0
 Shift constant to use in a combined shiftcode. Any Shift or ON.
#define KEYCODE(SHIFTcode)   ((SHIFTcode)&0x3f)
 Extracts a keycode from a combined shiftcode.
#define SHIFTPLANE(SHIFTcode)   ((SHIFTcode)&SHIFT_ANY)
 Extracts shift plane from a combined shiftcode.
#define keyb_isKeyPressed(keycode)   (keyb_getkey(0)==keycode)
 Tests the current state of a key.
#define keyb_isAnyKeyPressed()   (keyb_getmatrix()!=0LL)
 Tests whether any key is being pressed on the keyboard.
#define keyb_isLeft()   ((keyb_getmatrix()&KB_MASK(KB_LF))!=0)
 Tests if the left arrow key is down.
#define keyb_isRight()   ((keyb_getmatrix()&KB_MASK(KB_RT))!=0)
 Tests if the right arrow key is down.
#define keyb_isUp()   ((keyb_getmatrix()&KB_MASK(KB_UP))!=0)
 Tests if the up arrow key is down.
#define keyb_isDown()   ((keyb_getmatrix()&KB_MASK(KB_DN))!=0)
 Tests if the down arrow key is down.
#define keyb_isAlpha()   ((keyb_getmatrix()&KB_MASK(KB_ALPHA))!=0)
 Tests if the alpha key is down.
#define keyb_isLS()   ((keyb_getmatrix()&KB_MASK(KB_LSHIFT))!=0)
 Tests if the left-shift key is down.
#define keyb_isRS()   ((keyb_getmatrix()&KB_MASK(KB_RSHIFT))!=0)
 Tests if the right-shift key is down.
#define keyb_isON()   ((keyb_getmatrix()&KB_MASK(KB_ON))!=0)
 Tests if the ON key is down.
#define WAIT_CANCEL   {while(keyb_isON()); while(! keyb_isON());}
#define SLOW_WAIT_CANCEL   {cpu_setspeed(6*1000000);while(keyb_isON()); while(! keyb_isON());}
#define KM_PRESS   0x0000
 Keyboard message constant, to be combined with one of the KB_XXX key constants.
#define KM_KEYDN   0x4000
 Keyboard message constant, to be combined with one of the KB_XXX key constants.
#define KM_KEYUP   0x8000
 Keyboard message constant, to be combined with one of the KB_XXX key constants.
#define KM_SHIFT   0xc000
 Keyboard message constant, to be combined with one of the KB_XXX key constants.
#define KM_SHIFTMASK   0x1fc0
 Mask to isolate the key shift plane bits.
#define KM_KEYMASK   0x003f
 Mask to isolate the key value bits.
#define KM_MSGMASK   0xc000
 Mask to isolate the key message bits.
#define KEYB_BUFFER   128
 Keyboard message queue size (# of messages)
#define KEYB_SCANSPEED   20
 Keyboard scanning speed in milliseconds.
#define KM_MESSAGE(a)   ( (a) & KM_MSGMASK)
 Convenience macro to extract message type from a message.
#define KM_KEY(a)   ( (a) & KM_KEYMASK)
 Convenience macro to extract pure key code from a message.
#define KM_SHIFTEDKEY(a)   ( (a) & (KM_KEYMASK|KM_SHIFTMASK))
 Convenience macro to extract shifted key code from a message.
#define KM_SHIFTPLANE(a)   ( (a) & KM_SHIFTMASK)
 Convenience macro to extract shift plane from a message.

Typedefs

typedef unsigned long long ULONGLONG
typedef long long LONGLONG
typedef ULONGLONG keymatrix
 A matrix of simultaneous key states.

Functions

keymatrix keyb_getmatrix ()
 Retrieves the state of the complete keyboard.
int keyb_getkey (int wait)
 Returns the key constant of the first key pressed.
void keyb_postmsg (unsigned int msg)
 Inserts a key message into the keyboard buffer.
unsigned int keyb_getmsg ()
 Get a key message from the keyboard buffer.
void keyb_settiming (int repeat, int longpress, int debounce)
 Set all keyboard timing constants.
void keyb_setrepeat (int repeat)
 Activate/deactivate keyboard autorepeat.
void keyb_setalphalock (int single_alpha_lock)
 Activate/deactivate single-alhpa lock mode.
void keyb_setshiftplane (int leftshift, int rightshift, int alpha, int alphalock)
 Manualy set the shift plane.

Detailed Description

Keyboard management routines for the HP49.

Interaction with the calculator keyboard can be done at a high level, or a low level. Functions defined in this file are used to interact at a low level with the calculator keyboard. For higher-level user input routines, see getchar, gets, ::getkey, scanf.

There are 2 ways to access the keyboard: 1) Instantaneous state. All keyb_isXXX functions and keyb_getmatrix check the state of the keyboard at a particular instant of time. Therefore, they can only detect whether a key is pressed or not at the moment of the call (no keyplanes). This method is more often used in games. 2) Asynchronous using keyboard messages. Functions keyb_XXXmsg use a message queue. The keyboard is monitored automatically and messages are posted to the queue. A program can later retrieve those messages to know which keys and in which order were pressed. This set of functions can detect shift planes, and can autorepeat keys when the user holds the key. This method is more appropriate for text-inputting applications, and is the method used by the higher level functions.

Definition in file keyb.h.


Define Documentation

#define _LONGLONG_DEF

Definition at line 16 of file keyb.h.

#define KB_0   31

Constant for the 0 key.

Definition at line 152 of file keyb.h.

#define KB_1   30

Constant for the 1 key.

Definition at line 154 of file keyb.h.

#define KB_2   22

Constant for the 2 key.

Definition at line 156 of file keyb.h.

#define KB_3   14

Constant for the 3 key.

Definition at line 158 of file keyb.h.

#define KB_4   29

Constant for the 4 key.

Definition at line 160 of file keyb.h.

#define KB_5   21

Constant for the 5 key.

Definition at line 162 of file keyb.h.

#define KB_6   13

Constant for the 6 key.

Definition at line 164 of file keyb.h.

#define KB_7   28

Constant for the 7 key.

Definition at line 166 of file keyb.h.

#define KB_8   20

Constant for the 8 key.

Definition at line 168 of file keyb.h.

#define KB_9   12

Constant for the 9 key.

Definition at line 170 of file keyb.h.

#define KB_A   41

Constant for the F1 (A) key.

Definition at line 100 of file keyb.h.

#define KB_ADD   6

Constant for the + key.

Definition at line 178 of file keyb.h.

#define KB_ALPHA   60

Constant for the ALPHA key.

Definition at line 196 of file keyb.h.

#define KB_B   42

Constant for the F2 (B) key.

Definition at line 102 of file keyb.h.

#define KB_BKS   1

Constant for the backspace key.

Definition at line 172 of file keyb.h.

#define KB_C   43

Constant for the F3 (C) key.

Definition at line 104 of file keyb.h.

#define KB_CURS   ((ULONGLONG)0x001e000000000000)

A bitmask to represent the arrow keys.

The keymatrix can be combined with this mask via a bitwise and (&) to eliminate everything except the state of the arrow keys (aka cursor keys). This is a convenience constant, and its value is equivalent to: KB_MASK(KB_UP) | KB_MASK(KB_DN) | KB_MASK(KB_LF) | KB_MASK(KB_RT).

Definition at line 224 of file keyb.h.

#define KB_D   44

Constant for the F4 (D) key.

Definition at line 106 of file keyb.h.

#define KB_DIV   3

Constant for the / (Z) key.

Definition at line 174 of file keyb.h.

#define KB_DN   51

Constant for the down arrow key.

Definition at line 190 of file keyb.h.

#define KB_DOT   23

Constant for the . key.

Definition at line 182 of file keyb.h.

#define KB_E   45

Constant for the F5 (E) key.

Definition at line 108 of file keyb.h.

#define KB_ENT   7

Constant for the ENT key.

Definition at line 186 of file keyb.h.

#define KB_F   46

Constant for the F6 (F) key.

Definition at line 110 of file keyb.h.

#define KB_FUNC   ((ULONGLONG)0x00007e0000000000)

A bitmask to represent the function keys.

The keymatrix can be combined with this mask via a bitwise and (&) to eliminate everything except the state of the function keys. This is a convenience constant, and its value is equivalent to: KB_MASK(KB_A) | KB_MASK(KB_B) | KB_MASK(KB_C) | KB_MASK(KB_D) | KB_MASK(KB_E) | KB_MASK(KB_F).

Definition at line 236 of file keyb.h.

#define KB_G   47

Constant for the APPS (G) key.

Definition at line 112 of file keyb.h.

#define KB_H   53

Constant for the MODE (H) key.

Definition at line 114 of file keyb.h.

#define KB_I   54

Constant for the TOOL (I) key.

Definition at line 116 of file keyb.h.

#define KB_J   55

Constant for the VAR (J) key.

Definition at line 118 of file keyb.h.

#define KB_K   57

Constant for the STO (K) key.

Definition at line 120 of file keyb.h.

#define KB_L   58

Constant for the NXT (L) key.

Definition at line 122 of file keyb.h.

#define KB_LF   50

Constant for the left arrow key.

Definition at line 192 of file keyb.h.

#define KB_LSHIFT   61

Constant for the left shift key.

Definition at line 198 of file keyb.h.

#define KB_M   33

Constant for the HIST (M) key.

Definition at line 124 of file keyb.h.

#define KB_MASK (   a)    (((ULONGLONG)1)<<(a))

Create a bitmask representing the given key.

The bitmask returned by this macro can be compared with the keymatrix result.

Definition at line 210 of file keyb.h.

#define KB_MUL   4

Constant for the * key.

Definition at line 176 of file keyb.h.

#define KB_N   25

Constant for the EVAL (N) key.

Definition at line 126 of file keyb.h.

#define KB_O   17

Constant for the ' (O) key.

Definition at line 128 of file keyb.h.

#define KB_ON   63

Constant for the ON key.

Definition at line 202 of file keyb.h.

#define KB_P   9

Constant for the SYMB (P) key.

Definition at line 130 of file keyb.h.

#define KB_Q   34

Constant for the Y^X (Q) key.

Definition at line 132 of file keyb.h.

#define KB_R   26

Constant for the Sqrt (R) key.

Definition at line 134 of file keyb.h.

#define KB_RSHIFT   62

Constant for the right shift key.

Definition at line 200 of file keyb.h.

#define KB_RT   52

Constant for the right arrow key.

Definition at line 194 of file keyb.h.

#define KB_S   18

Constant for the SIN (S) key.

Definition at line 136 of file keyb.h.

#define KB_SPC   15

Constant for the SPC key.

Definition at line 184 of file keyb.h.

#define KB_SUB   5

Constant for the - key.

Definition at line 180 of file keyb.h.

#define KB_T   10

Constant for the COS (T) key.

Definition at line 138 of file keyb.h.

#define KB_U   2

Constant for the TAN (U) key.

Definition at line 140 of file keyb.h.

#define KB_UP   49

Constant for the up arrow key.

Definition at line 188 of file keyb.h.

#define KB_V   35

Constant for the EEX (V) key.

Definition at line 142 of file keyb.h.

#define KB_W   27

Constant for the +/- (W) key.

Definition at line 144 of file keyb.h.

#define KB_X   19

Constant for the X (X) key.

Definition at line 146 of file keyb.h.

#define KB_Y   11

Constant for the 1/X (Y) key.

Definition at line 148 of file keyb.h.

#define KB_Z   KB_DIV

Constant for the / (Z) key.

Definition at line 150 of file keyb.h.

#define KEYB_BUFFER   128

Keyboard message queue size (# of messages)

Definition at line 449 of file keyb.h.

#define keyb_isAlpha ( )    ((keyb_getmatrix()&KB_MASK(KB_ALPHA))!=0)

Tests if the alpha key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 352 of file keyb.h.

#define keyb_isAnyKeyPressed ( )    (keyb_getmatrix()!=0LL)

Tests whether any key is being pressed on the keyboard.

Returns:
TRUE if a key is pressed; FALSE otherwise

Definition at line 306 of file keyb.h.

#define keyb_isDown ( )    ((keyb_getmatrix()&KB_MASK(KB_DN))!=0)

Tests if the down arrow key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 342 of file keyb.h.

#define keyb_isKeyPressed (   keycode)    (keyb_getkey(0)==keycode)

Tests the current state of a key.

This macro detects if a key is pressed.

Parameters:
keycodeThe KB_... constant of a key.
Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 298 of file keyb.h.

#define keyb_isLeft ( )    ((keyb_getmatrix()&KB_MASK(KB_LF))!=0)

Tests if the left arrow key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 315 of file keyb.h.

#define keyb_isLS ( )    ((keyb_getmatrix()&KB_MASK(KB_LSHIFT))!=0)

Tests if the left-shift key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 362 of file keyb.h.

#define keyb_isON ( )    ((keyb_getmatrix()&KB_MASK(KB_ON))!=0)

Tests if the ON key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 381 of file keyb.h.

#define keyb_isRight ( )    ((keyb_getmatrix()&KB_MASK(KB_RT))!=0)

Tests if the right arrow key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 324 of file keyb.h.

#define keyb_isRS ( )    ((keyb_getmatrix()&KB_MASK(KB_RSHIFT))!=0)

Tests if the right-shift key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 372 of file keyb.h.

#define keyb_isUp ( )    ((keyb_getmatrix()&KB_MASK(KB_UP))!=0)

Tests if the up arrow key is down.

This is a convenience macro.

Returns:
TRUE if the key is pressed; FALSE otherwise

Definition at line 333 of file keyb.h.

#define KEYB_SCANSPEED   20

Keyboard scanning speed in milliseconds.

Definition at line 451 of file keyb.h.

#define KEYCODE (   SHIFTcode)    ((SHIFTcode)&0x3f)

Extracts a keycode from a combined shiftcode.

Definition at line 263 of file keyb.h.

#define KM_KEY (   a)    ( (a) & KM_KEYMASK)

Convenience macro to extract pure key code from a message.

Definition at line 456 of file keyb.h.

#define KM_KEYDN   0x4000

Keyboard message constant, to be combined with one of the KB_XXX key constants.

Definition at line 434 of file keyb.h.

#define KM_KEYMASK   0x003f

Mask to isolate the key value bits.

Definition at line 443 of file keyb.h.

#define KM_KEYUP   0x8000

Keyboard message constant, to be combined with one of the KB_XXX key constants.

Definition at line 436 of file keyb.h.

#define KM_MESSAGE (   a)    ( (a) & KM_MSGMASK)

Convenience macro to extract message type from a message.

Definition at line 454 of file keyb.h.

#define KM_MSGMASK   0xc000

Mask to isolate the key message bits.

Definition at line 445 of file keyb.h.

#define KM_PRESS   0x0000

Keyboard message constant, to be combined with one of the KB_XXX key constants.

Definition at line 432 of file keyb.h.

#define KM_SHIFT   0xc000

Keyboard message constant, to be combined with one of the KB_XXX key constants.

Definition at line 438 of file keyb.h.

#define KM_SHIFTEDKEY (   a)    ( (a) & (KM_KEYMASK|KM_SHIFTMASK))

Convenience macro to extract shifted key code from a message.

Definition at line 458 of file keyb.h.

#define KM_SHIFTMASK   0x1fc0

Mask to isolate the key shift plane bits.

Definition at line 441 of file keyb.h.

#define KM_SHIFTPLANE (   a)    ( (a) & KM_SHIFTMASK)

Convenience macro to extract shift plane from a message.

Definition at line 460 of file keyb.h.

#define SHIFT_ALPHA   0x400

Shift constant to use in a combined shiftcode. Alpha.

Definition at line 251 of file keyb.h.

#define SHIFT_ALPHAHOLD   0x800

Shift constant to use in a combined shiftcode. Hold-Alpha.

Definition at line 253 of file keyb.h.

#define SHIFT_ANY   0x1fc0

Shift constant to use in a combined shiftcode. Any Shift or ON.

Definition at line 259 of file keyb.h.

#define SHIFT_LS   0x40

Shift constant to use in a combined shiftcode. Left Shift.

Definition at line 242 of file keyb.h.

#define SHIFT_LSHOLD   0x80

Shift constant to use in a combined shiftcode. Hold-Left Shift.

Definition at line 244 of file keyb.h.

#define SHIFT_ONHOLD   0x1000

Shift constant to use in a combined shiftcode. Hold-On key.

Definition at line 256 of file keyb.h.

#define SHIFT_RS   0x100

Shift constant to use in a combined shiftcode. Right Shift.

Definition at line 246 of file keyb.h.

#define SHIFT_RSHOLD   0x200

Shift constant to use in a combined shiftcode. Hold-Right Shift.

Definition at line 248 of file keyb.h.

#define SHIFTPLANE (   SHIFTcode)    ((SHIFTcode)&SHIFT_ANY)

Extracts shift plane from a combined shiftcode.

Definition at line 265 of file keyb.h.

#define SLOW_WAIT_CANCEL   {cpu_setspeed(6*1000000);while(keyb_isON()); while(! keyb_isON());}

Definition at line 425 of file keyb.h.

#define WAIT_CANCEL   {while(keyb_isON()); while(! keyb_isON());}

Definition at line 424 of file keyb.h.


Typedef Documentation

A matrix of simultaneous key states.

This data type is a 64-bit integer used to represent the complete state of the keyboard.

Definition at line 275 of file keyb.h.

typedef long long LONGLONG

Definition at line 15 of file keyb.h.

typedef unsigned long long ULONGLONG

Definition at line 14 of file keyb.h.


Function Documentation

int keyb_getkey ( int  wait)

Returns the key constant of the first key pressed.

Optionally waits for a non-shift key to be pressed, and then returns a shiftplane specifying which key was pressed and the shift state.

If the wait parameter is non-zero, this function does not return until a key has been completely pressed and released (only the key, shift can remain pressed). If multiple keys are pressed simultaneously, the function does not return until all keys have been released; but the return value will be the identifier of the first key. If the wait parameter is zero, the function will wait neither for a key to be pressed or released. The ON key is detected as a normal key, but Shift-ON is not detected.

Parameters:
waitIf 0, return a 0 identifier if no key is pressed; If non-zero, wait until a key is pressed.
Returns:
A shiftcode for the key pressed, or 0 if no key was pressed and the wait parameter was zero. The shiftcode will be comprised of a KB_... constant and a combination of the SHIFT_... constants. Use the KEYCODE() macro to extract the keycode from the shiftcode. For example, int key=keyb_getkey(1); To check for A regardless of shift state: if(KEYCODE(key)==KB_A) ... To check for LS-A (LS only): if(key==(KB_A | SHIFT_LS | SHIFT_LSHOLD)) ... or if(KEYCODE(key)==KB_A && SHIFTPLANE(key)==SHIFT_LS|SHIFT_LSHOLD)
Note:
Because this function uses instantaneous keyboard readings, it can only detect shift-hold planes. Therefore, it always return a combination of (SHIFT_LS|SHIFT_LSHOLD), (SHIFT_RS|SHIFT_RSHOLD), or (SHIFT_ALPHA|SHIFT_ALPHAHOLD) for the shift plane.
keymatrix keyb_getmatrix ( )

Retrieves the state of the complete keyboard.

This function retrieves the state of the entire keyboard in one operation. The result can then be inspected using the various KB_* preprocessor macros and constants.

Returns:
A keymatrix, which will hold the result.
unsigned int keyb_getmsg ( )

Get a key message from the keyboard buffer.

Use this function to extract key messages from the queue. This function gives access to the most basic keyboard functions. Consider using other higher level keyboard functions for more advanced features, like functions from the stdio module. When a key is pressed, 2 messages are immediately generated: KM_KEYDN and KM_PRESS. Then, if the user keeps the key pressed for a long period of time (see keyb_settiming), an additional KM_PRESS message will be posted. If the user continues to hold the key, an extra KM_PRESS message will be generated at the keyboard repeat rate (see keyb_settiming). When the user releases the key, a KM_KEYUP message will be posted. Notice that Alpha, Left Shift, Right Shift and ON do not generate KM_PRESS messages, only KM_KEYDN/KM_KEYUP pairs. Every time the shift plane changes, a KM_SHIFT message is generated, indicating the new plane. Each KM_PRESS message already carries shift plane information, the KM_SHIFT message is posted to do other tasks like updating the annunciator icons.

Returns:
A keyboard message, composed of KM_KEYUP, KM_KEYDN or KM_PRESS plus a key value (a KB_XXX constant). To isolate the key value in the message use the bit mask KM_KEYMASK (like in key=full_msg&KM_KEYMASK). Similarly, to isolate the message type use the bit mask KM_MSGMASK (msg=full_msg&KM_MSGMASK). The KM_PRESS and KM_SHIFT messages include shift planes, that can be isolated using the KM_SHIFTMASK bit mask.
void keyb_postmsg ( unsigned int  msg)

Inserts a key message into the keyboard buffer.

Use this function to simulate a keystroke by inserting the proper messages into the keyboard queue. A valid keypress sequence is composed of a KM_KEYDN message, followed by a KM_PRESS and a KM_KEYUP.

Parameters:
msgA keyboard message, composed of KM_KEYUP, KM_KEYDN or KM_PRESS plus a key value (a KB_XXX constant). KM_PRESS messages can optionally have a SHIFT_XXX shift plane.

For example, to simulate pressing the key A in Alpha mode, the sequence of messages can be formed as: (KM_KEYDN | KB_A), then (KM_PRESS | KB_A | SHIFT_ALPHA) and finally (KM_KEYUP | KB_A). If the client program does not require the complete sequence to work, sending only the KM_PRESS message will do the job.

void keyb_setalphalock ( int  single_alpha_lock)

Activate/deactivate single-alhpa lock mode.

Parameters:
single_alpha_lockNonzero to lock alpha mode with a single alpha keypress, zero to require double alpha keypress to lock.
void keyb_setrepeat ( int  repeat)

Activate/deactivate keyboard autorepeat.

Parameters:
repeatNonzero to activate autorepeat, zero to disable the feature.
void keyb_setshiftplane ( int  leftshift,
int  rightshift,
int  alpha,
int  alphalock 
)

Manualy set the shift plane.

Parameters:
leftshiftNonzero to activate left shift plane.
rightshiftNonzero to activate right shift plane.
alphaNonzero to activate alpha shift plane for the next keypress only.
alphalockNonzero to activate alpha mode for all subsequent keypresses.
Note:
This function will wait until all keys have been released prior to changing the shift plane.
void keyb_settiming ( int  repeat,
int  longpress,
int  debounce 
)

Set all keyboard timing constants.

This function defines keyboard timing through 3 parameters.

Parameters:
repeatTime in milliseconds between KM_PRESS messages when the user holds down a key.
longpressTime in milliseconds the user needs to hold down a key to generate the first KM_LPRESS message and start autorepeating the keypress.
debounceTime in milliseconds measured from the moment the user releases a key, in which the keyboard handler will ignore additional keypresses of the same key