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.
|
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.