|
KallistiOS git master
Independent SDK for the Sega Dreamcast
|
Definitions for using the keyboard device. More...
#include <sys/cdefs.h>#include <dc/maple.h>#include <kos/regfield.h>#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| union | kbd_mods_t |
| Modifier Keys. More... | |
| union | kbd_leds_t |
| Keyboard LEDs. More... | |
| union | key_state_t |
| Keyboard Key State. More... | |
| struct | kbd_cond_t |
| Keyboard raw condition structure. More... | |
| struct | kbd_state_t |
| Keyboard status structure. More... | |
Macros | |
| #define | KBD_MOD_LCTRL BIT(0) |
| Left Control key. | |
| #define | KBD_MOD_LSHIFT BIT(1) |
| Left Shift key. | |
| #define | KBD_MOD_LALT BIT(2) |
| Left alternate key. | |
| #define | KBD_MOD_S1 BIT(3) |
| S1 key. | |
| #define | KBD_MOD_RCTRL BIT(4) |
| Right Control key. | |
| #define | KBD_MOD_RSHIFT BIT(5) |
| Right Shift key. | |
| #define | KBD_MOD_RALT BIT(6) |
| Right Alternate key. | |
| #define | KBD_MOD_S2 BIT(7) |
| S2 key. | |
| #define | KBD_MOD_CTRL (KBD_MOD_LCTRL | KBD_MOD_RCTRL) |
| Either Control key. | |
| #define | KBD_MOD_SHIFT (KBD_MOD_LSHIFT | KBD_MOD_RSHIFT) |
| Either Shift key. | |
| #define | KBD_MOD_ALT (KBD_MOD_LALT | KBD_MOD_RALT) |
| Either Alternate key. | |
| #define | KBD_LED_NUMLOCK BIT(0) |
| Num Lock LED. | |
| #define | KBD_LED_CAPSLOCK BIT(1) |
| Caps Lock LED. | |
| #define | KBD_LED_SCRLOCK BIT(2) |
| Scroll Lock LED. | |
| #define | KBD_LED_UNKNOWN1 BIT(3) |
| Unknown LED 1. | |
| #define | KBD_LED_UNKNOWN2 BIT(4) |
| Unknown LED 2. | |
| #define | KBD_LED_KANA BIT(5) |
| Kana LED. | |
| #define | KBD_LED_POWER BIT(6) |
| Power LED. | |
| #define | KBD_LED_SHIFT BIT(7) |
| Shift LED. | |
| #define | KEY_STATE_IS_DOWN BIT(0) |
| If key is currenty down. | |
| #define | KEY_STATE_WAS_DOWN BIT(1) |
| If key was previously down. | |
| #define | KEY_STATE_MASK (KEY_STATE_IS_DOWN | KEY_STATE_WAS_DOWN) |
| Mask of all key state flags. | |
| #define | KEY_STATE_PACK(is_down, was_down) |
| Creates a packed key_state_t. | |
| #define | KBD_MAX_PRESSED_KEYS 6 |
| Maximum number of keys the DC can read simultaneously. | |
| #define | KBD_MAX_KEYS 256 |
| Maximum number of keys a DC keyboard can have. | |
| #define | KBD_QUEUE_SIZE 16 |
| Size of a keyboard queue. | |
| #define | KBD_QUEUE_END -1 |
| Delimiter value for kbd_queue_pop() | |
Typedefs | |
| typedef enum __packed kbd_key | kbd_key_t |
| Raw Keyboard Key Identifiers. | |
| typedef enum __packed key_state_value | key_state_value_t |
| Valid values for key_state_t::value. | |
| typedef void | kbd_keymap_t("Please open an issue, there should be no reason for external code to have used this.") |
| typedef void(* | kbd_event_handler_t) (maple_device_t *dev, kbd_key_t key, key_state_t state, kbd_mods_t mods, kbd_leds_t leds, void *ud) |
| Keyboard Event Handler Callback. | |
Enumerations | |
| enum | kbd_region_t { KBD_REGION_JP = 1 , KBD_REGION_US = 2 , KBD_REGION_UK = 3 , KBD_REGION_DE = 4 , KBD_REGION_FR = 5 , KBD_REGION_IT = 6 , KBD_REGION_ES = 7 } |
| Region Codes for the Dreamcast keyboard. More... | |
Functions | |
| char | kbd_key_to_ascii (kbd_key_t key, kbd_region_t region, kbd_mods_t mods, kbd_leds_t leds) |
| Converts a kbd_key_t value into its corresponding ASCII value. | |
| static const uint8_t | KEY_STATE_NONE ("Please use KEY_STATE_HELD_UP.") |
| static const uint8_t | KEY_STATE_WAS_PRESSED ("Please use KEY_STATE_CHANGED_UP.") |
| static const uint8_t | KEY_STATE_PRESSED ("Please see key_state_value_t.") |
| static const int | MAX_PRESSED_KEYS ("Please use KBD_MAX_PRESSED_KEYS.") |
| static const int | MAX_KBD_KEYS ("Please use KBD_MAX_KEYS.") |
| kbd_state_t * | kbd_get_state (maple_device_t *device) |
| Retrieves the keyboard state from a maple device. | |
| void | kbd_set_event_handler (kbd_event_handler_t callback, void *user_data) |
| Registers an Event Handler. | |
| void | kbd_get_event_handler (kbd_event_handler_t *callback, void **user_data) |
| Returns the Registered Event Handler. | |
| void | kbd_set_repeat_timing (uint16_t start, uint16_t interval) |
| Configures held key auto-repeat intervals. | |
| int | kbd_queue_pop (maple_device_t *dev, bool xlat) |
| Pop a key off a specific keyboard's queue. | |
| void | kbd_set_queue (int active) __deprecated |
| Activate or deactivate global key queueing. | |
| int | kbd_get_key (void) __deprecated |
| Pop a key off the global keyboard queue. | |
Variables | |
| enum __packed | kbd_key |
| Raw Keyboard Key Identifiers. | |
| KBD_KEY_NONE = 0x00 | |
| No key. | |
| KBD_KEY_ERROR = 0x01 | |
| ERROR_ROLLOVER. | |
| KBD_KEY_ERR2 = 0x02 | |
| Unknown error. | |
| KBD_KEY_ERR3 = 0x03 | |
| Unknown error. | |
| KBD_KEY_A = 0x04 | |
| A key. | |
| KBD_KEY_B = 0x05 | |
| B key. | |
| KBD_KEY_C = 0x06 | |
| C key. | |
| KBD_KEY_D = 0x07 | |
| D key. | |
| KBD_KEY_E = 0x08 | |
| E key. | |
| KBD_KEY_F = 0x09 | |
| F key. | |
| KBD_KEY_G = 0x0a | |
| G key. | |
| KBD_KEY_H = 0x0b | |
| H key. | |
| KBD_KEY_I = 0x0c | |
| I key. | |
| KBD_KEY_J = 0x0d | |
| J key. | |
| KBD_KEY_K = 0x0e | |
| K key. | |
| KBD_KEY_L = 0x0f | |
| L key. | |
| KBD_KEY_M = 0x10 | |
| M key. | |
| KBD_KEY_N = 0x11 | |
| N key. | |
| KBD_KEY_O = 0x12 | |
| O key. | |
| KBD_KEY_P = 0x13 | |
| P key. | |
| KBD_KEY_Q = 0x14 | |
| Q key. | |
| KBD_KEY_R = 0x15 | |
| R key. | |
| KBD_KEY_S = 0x16 | |
| S key. | |
| KBD_KEY_T = 0x17 | |
| T key. | |
| KBD_KEY_U = 0x18 | |
| U key. | |
| KBD_KEY_V = 0x19 | |
| V key. | |
| KBD_KEY_W = 0x1a | |
| W key. | |
| KBD_KEY_X = 0x1b | |
| X key. | |
| KBD_KEY_Y = 0x1c | |
| Y key. | |
| KBD_KEY_Z = 0x1d | |
| Z key. | |
| KBD_KEY_1 = 0x1e | |
| 1 key | |
| KBD_KEY_2 = 0x1f | |
| 2 key | |
| KBD_KEY_3 = 0x20 | |
| 3 key | |
| KBD_KEY_4 = 0x21 | |
| 4 key | |
| KBD_KEY_5 = 0x22 | |
| 5 key | |
| KBD_KEY_6 = 0x23 | |
| 6 key | |
| KBD_KEY_7 = 0x24 | |
| 7 key | |
| KBD_KEY_8 = 0x25 | |
| 8 key | |
| KBD_KEY_9 = 0x26 | |
| 9 key | |
| KBD_KEY_0 = 0x27 | |
| 0 key | |
| KBD_KEY_ENTER = 0x28 | |
| Enter key. | |
| KBD_KEY_ESCAPE = 0x29 | |
| Escape key. | |
| KBD_KEY_BACKSPACE = 0x2a | |
| Backspace key. | |
| KBD_KEY_TAB = 0x2b | |
| Tab key. | |
| KBD_KEY_SPACE = 0x2c | |
| Space key. | |
| KBD_KEY_MINUS = 0x2d | |
| Minus key. | |
| KBD_KEY_PLUS = 0x2e | |
| Plus key. | |
| KBD_KEY_LBRACKET = 0x2f | |
| [ key | |
| KBD_KEY_RBRACKET = 0x30 | |
| ] key | |
| KBD_KEY_BACKSLASH = 0x31 | |
| \ key | |
| KBD_KEY_SEMICOLON = 0x33 | |
| ; key | |
| KBD_KEY_QUOTE = 0x34 | |
| " key | |
| KBD_KEY_TILDE = 0x35 | |
| ~ key | |
| KBD_KEY_COMMA = 0x36 | |
| , key | |
| KBD_KEY_PERIOD = 0x37 | |
| . | |
| KBD_KEY_SLASH = 0x38 | |
| Slash key. | |
| KBD_KEY_CAPSLOCK = 0x39 | |
| Caps Lock key. | |
| KBD_KEY_F1 = 0x3a | |
| F1 key. | |
| KBD_KEY_F2 = 0x3b | |
| F2 key. | |
| KBD_KEY_F3 = 0x3c | |
| F3 key. | |
| KBD_KEY_F4 = 0x3d | |
| F4 key. | |
| KBD_KEY_F5 = 0x3e | |
| F5 key. | |
| KBD_KEY_F6 = 0x3f | |
| F6 key. | |
| KBD_KEY_F7 = 0x40 | |
| F7 key. | |
| KBD_KEY_F8 = 0x41 | |
| F8 key. | |
| KBD_KEY_F9 = 0x42 | |
| F9 key. | |
| KBD_KEY_F10 = 0x43 | |
| F10 key. | |
| KBD_KEY_F11 = 0x44 | |
| F11 key. | |
| KBD_KEY_F12 = 0x45 | |
| F12 key. | |
| KBD_KEY_PRINT = 0x46 | |
| Print Screen key. | |
| KBD_KEY_SCRLOCK = 0x47 | |
| Scroll Lock key. | |
| KBD_KEY_PAUSE = 0x48 | |
| Pause key. | |
| KBD_KEY_INSERT = 0x49 | |
| Insert key. | |
| KBD_KEY_HOME = 0x4a | |
| Home key. | |
| KBD_KEY_PGUP = 0x4b | |
| Page Up key. | |
| KBD_KEY_DEL = 0x4c | |
| Delete key. | |
| KBD_KEY_END = 0x4d | |
| End key. | |
| KBD_KEY_PGDOWN = 0x4e | |
| Page Down key. | |
| KBD_KEY_RIGHT = 0x4f | |
| Right Arrow key. | |
| KBD_KEY_LEFT = 0x50 | |
| Left Arrow key. | |
| KBD_KEY_DOWN = 0x51 | |
| Down Arrow key. | |
| KBD_KEY_UP = 0x52 | |
| Up Arrow key. | |
| KBD_KEY_PAD_NUMLOCK = 0x53 | |
| Keypad Numlock key. | |
| KBD_KEY_PAD_DIVIDE = 0x54 | |
| Keypad Divide key. | |
| KBD_KEY_PAD_MULTIPLY = 0x55 | |
| Keypad Multiply key. | |
| KBD_KEY_PAD_MINUS = 0x56 | |
| Keypad Minus key. | |
| KBD_KEY_PAD_PLUS = 0x57 | |
| Keypad Plus key. | |
| KBD_KEY_PAD_ENTER = 0x58 | |
| Keypad Enter key. | |
| KBD_KEY_PAD_1 = 0x59 | |
| Keypad 1 key. | |
| KBD_KEY_PAD_2 = 0x5a | |
| Keypad 2 key. | |
| KBD_KEY_PAD_3 = 0x5b | |
| Keypad 3 key. | |
| KBD_KEY_PAD_4 = 0x5c | |
| Keypad 4 key. | |
| KBD_KEY_PAD_5 = 0x5d | |
| Keypad 5 key. | |
| KBD_KEY_PAD_6 = 0x5e | |
| Keypad 6 key. | |
| KBD_KEY_PAD_7 = 0x5f | |
| Keypad 7 key. | |
| KBD_KEY_PAD_8 = 0x60 | |
| Keypad 8 key. | |
| KBD_KEY_PAD_9 = 0x61 | |
| Keypad 9 key. | |
| KBD_KEY_PAD_0 = 0x62 | |
| Keypad 0 key. | |
| KBD_KEY_PAD_PERIOD = 0x63 | |
| Keypad Period key. | |
| enum __packed | key_state_value |
| Valid values for key_state_t::value. | |
| KEY_STATE_HELD_UP = KEY_STATE_PACK(false, false) | |
| Key has been in an up state for at least the last two frames. | |
| KEY_STATE_CHANGED_DOWN = KEY_STATE_PACK(true, false) | |
| Key transitioned from up to pressed this frame. | |
| KEY_STATE_CHANGED_UP = KEY_STATE_PACK(false, true) | |
| Key transitioned from down to released this frame. | |
| KEY_STATE_HELD_DOWN = KEY_STATE_PACK(true, true) | |
| Key has been held down for at least the last two frames. | |
Definitions for using the keyboard device.
This file contains the definitions needed to access the Maple keyboard device. Obviously, this corresponds to the MAPLE_FUNC_KEYBOARD function code.
| KBD_KEY_0 = 0x27 |
0 key
| KBD_KEY_1 = 0x1e |
1 key
| KBD_KEY_2 = 0x1f |
2 key
| KBD_KEY_3 = 0x20 |
3 key
| KBD_KEY_4 = 0x21 |
4 key
| KBD_KEY_5 = 0x22 |
5 key
| KBD_KEY_6 = 0x23 |
6 key
| KBD_KEY_7 = 0x24 |
7 key
| KBD_KEY_8 = 0x25 |
8 key
| KBD_KEY_9 = 0x26 |
9 key
| KBD_KEY_A = 0x04 |
A key.
| KBD_KEY_B = 0x05 |
B key.
| KBD_KEY_BACKSLASH = 0x31 |
\ key
| KBD_KEY_BACKSPACE = 0x2a |
Backspace key.
| KBD_KEY_C = 0x06 |
C key.
| KBD_KEY_CAPSLOCK = 0x39 |
Caps Lock key.
| KBD_KEY_COMMA = 0x36 |
, key
| KBD_KEY_D = 0x07 |
D key.
| KBD_KEY_DEL = 0x4c |
Delete key.
| KBD_KEY_DOWN = 0x51 |
Down Arrow key.
| KBD_KEY_E = 0x08 |
E key.
| KBD_KEY_END = 0x4d |
End key.
| KBD_KEY_ENTER = 0x28 |
Enter key.
| KBD_KEY_ERR2 = 0x02 |
Unknown error.
| KBD_KEY_ERR3 = 0x03 |
Unknown error.
| KBD_KEY_ERROR = 0x01 |
ERROR_ROLLOVER.
| KBD_KEY_ESCAPE = 0x29 |
Escape key.
| KBD_KEY_F = 0x09 |
F key.
| KBD_KEY_F1 = 0x3a |
F1 key.
| KBD_KEY_F10 = 0x43 |
F10 key.
| KBD_KEY_F11 = 0x44 |
F11 key.
| KBD_KEY_F12 = 0x45 |
F12 key.
| KBD_KEY_F2 = 0x3b |
F2 key.
| KBD_KEY_F3 = 0x3c |
F3 key.
| KBD_KEY_F4 = 0x3d |
F4 key.
| KBD_KEY_F5 = 0x3e |
F5 key.
| KBD_KEY_F6 = 0x3f |
F6 key.
| KBD_KEY_F7 = 0x40 |
F7 key.
| KBD_KEY_F8 = 0x41 |
F8 key.
| KBD_KEY_F9 = 0x42 |
F9 key.
| KBD_KEY_G = 0x0a |
G key.
| KBD_KEY_H = 0x0b |
H key.
| KBD_KEY_HOME = 0x4a |
Home key.
| KBD_KEY_I = 0x0c |
I key.
| KBD_KEY_INSERT = 0x49 |
Insert key.
| KBD_KEY_J = 0x0d |
J key.
| KBD_KEY_K = 0x0e |
K key.
| KBD_KEY_L = 0x0f |
L key.
| KBD_KEY_LBRACKET = 0x2f |
[ key
| KBD_KEY_LEFT = 0x50 |
Left Arrow key.
| KBD_KEY_M = 0x10 |
M key.
| KBD_KEY_MINUS = 0x2d |
Minus key.
| KBD_KEY_N = 0x11 |
N key.
| KBD_KEY_NONE = 0x00 |
No key.
| KBD_KEY_O = 0x12 |
O key.
| KBD_KEY_P = 0x13 |
P key.
| KBD_KEY_PAD_0 = 0x62 |
Keypad 0 key.
| KBD_KEY_PAD_1 = 0x59 |
Keypad 1 key.
| KBD_KEY_PAD_2 = 0x5a |
Keypad 2 key.
| KBD_KEY_PAD_3 = 0x5b |
Keypad 3 key.
| KBD_KEY_PAD_4 = 0x5c |
Keypad 4 key.
| KBD_KEY_PAD_5 = 0x5d |
Keypad 5 key.
| KBD_KEY_PAD_6 = 0x5e |
Keypad 6 key.
| KBD_KEY_PAD_7 = 0x5f |
Keypad 7 key.
| KBD_KEY_PAD_8 = 0x60 |
Keypad 8 key.
| KBD_KEY_PAD_9 = 0x61 |
Keypad 9 key.
| KBD_KEY_PAD_DIVIDE = 0x54 |
Keypad Divide key.
| KBD_KEY_PAD_ENTER = 0x58 |
Keypad Enter key.
| KBD_KEY_PAD_MINUS = 0x56 |
Keypad Minus key.
| KBD_KEY_PAD_MULTIPLY = 0x55 |
Keypad Multiply key.
| KBD_KEY_PAD_NUMLOCK = 0x53 |
Keypad Numlock key.
| KBD_KEY_PAD_PERIOD = 0x63 |
Keypad Period key.
| KBD_KEY_PAD_PLUS = 0x57 |
Keypad Plus key.
| KBD_KEY_PAUSE = 0x48 |
Pause key.
| KBD_KEY_PERIOD = 0x37 |
.
key
| KBD_KEY_PGDOWN = 0x4e |
Page Down key.
| KBD_KEY_PGUP = 0x4b |
Page Up key.
| KBD_KEY_PLUS = 0x2e |
Plus key.
| KBD_KEY_PRINT = 0x46 |
Print Screen key.
| KBD_KEY_Q = 0x14 |
Q key.
| KBD_KEY_QUOTE = 0x34 |
" key
| KBD_KEY_R = 0x15 |
R key.
| KBD_KEY_RBRACKET = 0x30 |
] key
| KBD_KEY_RIGHT = 0x4f |
Right Arrow key.
| KBD_KEY_S = 0x16 |
S key.
| KBD_KEY_SCRLOCK = 0x47 |
Scroll Lock key.
| KBD_KEY_SEMICOLON = 0x33 |
; key
| KBD_KEY_SLASH = 0x38 |
Slash key.
| KBD_KEY_SPACE = 0x2c |
Space key.
| KBD_KEY_T = 0x17 |
T key.
| KBD_KEY_TAB = 0x2b |
Tab key.
| KBD_KEY_TILDE = 0x35 |
~ key
| KBD_KEY_U = 0x18 |
U key.
| KBD_KEY_UP = 0x52 |
Up Arrow key.
| KBD_KEY_V = 0x19 |
V key.
| KBD_KEY_W = 0x1a |
W key.
| KBD_KEY_X = 0x1b |
X key.
| KBD_KEY_Y = 0x1c |
Y key.
| KBD_KEY_Z = 0x1d |
Z key.
| KEY_STATE_CHANGED_DOWN = KEY_STATE_PACK(true, false) |
Key transitioned from up to pressed this frame.
| KEY_STATE_CHANGED_UP = KEY_STATE_PACK(false, true) |
Key transitioned from down to released this frame.
| KEY_STATE_HELD_DOWN = KEY_STATE_PACK(true, true) |
Key has been held down for at least the last two frames.
| KEY_STATE_HELD_UP = KEY_STATE_PACK(false, false) |
Key has been in an up state for at least the last two frames.