KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
Keyboard

Driver for the Dreamcast's Keyboard Input Device More...

Topics

 Key States
 States each key can be in.
 
 Keys
 Values representing the various keyboard keys
 
 LEDs
 Values for the different keyboard LEDs
 
 Modifier Keys
 Masks for the various keyboard modifier keys
 
 Region Codes
 Region codes for the Dreamcast keyboard
 

Files

file  keyboard.h
 Definitions for using the keyboard device.
 

Data Structures

struct  kbd_keymap_t
 Keyboard keymap. More...
 
struct  kbd_cond_t
 Keyboard raw condition structure. More...
 
struct  kbd_state_t
 Keyboard status structure. More...
 

Macros

#define MAX_PRESSED_KEYS   6
 Maximum number of keys the DC can read simultaneously.
 
#define MAX_KBD_KEYS   256
 Maximum number of keys a DC keyboard can have.
 
#define KBD_QUEUE_SIZE   16
 Size of a keyboard queue.
 

Functions

void kbd_set_queue (int active)
 Activate or deactivate global key queueing.
 
int kbd_get_key (void)
 Pop a key off the global keyboard queue.
 
int kbd_queue_pop (maple_device_t *dev, int xlat)
 Pop a key off a specific keyboard's queue.
 

Detailed Description

Driver for the Dreamcast's Keyboard Input Device

Macro Definition Documentation

◆ KBD_QUEUE_SIZE

#define KBD_QUEUE_SIZE   16

Size of a keyboard queue.

Each keyboard queue will hold this many elements. Once the queue fills, no new elements will be placed on the queue. As long as you check the queue relatively frequently, the default of 16 should be plenty.

Note
This MUST be a power of two.

◆ MAX_KBD_KEYS

#define MAX_KBD_KEYS   256

Maximum number of keys a DC keyboard can have.

This is a hardware constant. The define prevents the magic number '256' from appearing.

◆ MAX_PRESSED_KEYS

#define MAX_PRESSED_KEYS   6

Maximum number of keys the DC can read simultaneously.

This is a hardware constant. The define prevents the magic number '6' from appearing.

Function Documentation

◆ kbd_get_key()

int kbd_get_key ( void )

Pop a key off the global keyboard queue.

Deprecated

This function pops the front off of the keyboard queue, and returns the value to the caller. The value returned will be the ASCII value of the key pressed (accounting for the shift keys being pressed).

If a key does not have an ASCII value associated with it, the raw key code will be returned, shifted up by 8 bits.

Returns
The value at the front of the queue, or -1 if there are no keys in the queue or queueing is off.
Note
This function does not account for non-US keyboard layouts properly (for compatibility with old code), and is deprecated. Use the individual keyboard queues instead to properly account for non-US keyboards.
See also
kbd_queue_pop()

◆ kbd_queue_pop()

int kbd_queue_pop ( maple_device_t * dev,
int xlat )

Pop a key off a specific keyboard's queue.

This function pops the front element off of the specified keyboard queue, and returns the value of that key to the caller.

If the xlat parameter is non-zero and the key represents an ISO-8859-1 character, that is the value that will be returned from this function. Otherwise if xlat is non-zero, it will be the raw key code, shifted up by 8 bits.

If the xlat parameter is zero, the lower 8 bits of the returned value will be the raw key code. The next 8 bits will be the modifier keys that were down when the key was pressed (a bitfield of KBD_MOD_* values). The next 3 bits will be the lock key status (a bitfield of KBD_LED_* values).

Parameters
devThe keyboard device to read from.
xlatSet to non-zero to do key translation. Otherwise, you'll simply get the raw key value. Raw key values are not mapped at all, so you are responsible for figuring out what it is by the region.
Returns
The value at the front of the queue, or -1 if there are no keys in the queue.

◆ kbd_set_queue()

void kbd_set_queue ( int active)

Activate or deactivate global key queueing.

Deprecated

This function will turn the internal keyboard queueing on or off. Note that there is only one queue for the whole system, no matter how many keyboards are attached, and the queue is of fairly limited length. Turning queueing off is useful (for instance) in a game where individual keypresses don't mean as much as having the keys up or down does.

You can clear the queue (without popping all the keys off) by setting the active value to a different value than it was.

The queue is by default on, unless you turn it off.

Parameters
activeSet to non-zero to activate the queue.
Note
The global queue does not account for non-US keyboard layouts and is deprecated. Please use the individual queues instead for future code.