forked from Lephenixnoir/gint
37 lines
960 B
C
37 lines
960 B
C
#include <keyboard.h>
|
|
|
|
/*
|
|
key_char()
|
|
Returns the ASCII character associated with a character key, and 0 for
|
|
other keys. This function expects a matrix code and not a key_id()
|
|
code, and heeds for the ALPHA modifier.
|
|
*/
|
|
int key_char(int matrix_key)
|
|
{
|
|
char flat[] = {
|
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
0x0, '2', '^', 0x0, 0x0, 0x0,
|
|
'X', 'L', 'l', 's', 'c', 't',
|
|
0x0, 0x0, '(', ')', ',', '>',
|
|
'7', '8', '9', 0x0, 0x0, 0x0,
|
|
'4', '5', '6', '*', '/', 0x0,
|
|
'1', '2', '3', '+', '-', 0x0,
|
|
'0', '.', 'e', '_', 0x0, 0x0
|
|
};
|
|
char alpha[] = {
|
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
|
0x0, 'r', 'o', 0x0, 0x0, 0x0,
|
|
'A', 'B', 'C', 'D', 'E', 'F',
|
|
'G', 'H', 'I', 'J', 'K', 'L',
|
|
'M', 'N', 'O', 0x0, 0x0, 0x0,
|
|
'P', 'Q', 'R', 'S', 'T', 0x0,
|
|
'U', 'V', 'W', 'X', 'Y', 0x0,
|
|
'Z', ' ', '"', 0x0, 0x0, 0x0
|
|
};
|
|
|
|
int id = key_id(matrix_key);
|
|
return (matrix_key & MOD_ALPHA) ? alpha[id] : flat[id];
|
|
}
|