keyboard.h File Reference

nds stdio keyboard integration. More...

#include <nds/ndstypes.h>
#include <nds/arm9/background.h>

Data Structures

struct  Keyboard
 describes a keyboard. More...
struct  KeyMap
 defines a key mapping. More...

Typedefs

typedef struct Keyboard Keyboard
 describes a keyboard.
typedef void(* KeyChangeCallback )(int key)
 callback function pointer for a key changed.
typedef struct KeyMap KeyMap
 defines a key mapping.

Enumerations

enum  KeyboardState {
  Lower = 0,
  Upper = 1,
  Numeric = 2,
  Reduced = 3
}
 

States the keyboard can be in, currently only Lower and Upper supported.

More...
enum  Keys {
  NOKEY = -1,
  DVK_FOLD = -23,
  DVK_TAB = 9,
  DVK_BACKSPACE = 8,
  DVK_CAPS = -15,
  DVK_SHIFT = -14,
  DVK_SPACE = 32,
  DVK_MENU = -5,
  DVK_ENTER = 10,
  DVK_CTRL = -16,
  DVK_UP = -17,
  DVK_RIGHT = -18,
  DVK_DOWN = -19,
  DVK_LEFT = -20,
  DVK_ALT = -26
}
 

enum values for the keyboard control keys. negative values are keys with no sensible ascii representation. numbers are chosen to mimic ascii control sequences.

More...

Functions

KeyboardkeyboardDemoInit (void)
 initializes the keyboard with default options. Same as calling keyboardInit(NULL, 3, BgType_Text4bpp, BgSize_T_256x512, 20, 0, false, true)
int keyboardGetChar (void)
 Waits for user to press a key and returns the key pressed. Use keyboardUpdate instead for async operation.
KeyboardkeyboardGetDefault (void)
 Gets the default keyboard.
int keyboardGetKey (int x, int y)
 returns the ascii code for the key located at the supplied x and y. Will not effect keyboard shift state.
void keyboardGetString (char *buffer, int maxLen)
 reads the input until a the return key is pressed or the maxLen is exceeded.
void keyboardHide (void)
 Hides the keyboard.
KeyboardkeyboardInit (Keyboard *keyboard, int layer, BgType type, BgSize size, int mapBase, int tileBase, bool mainDisplay, bool loadGraphics)
 initializes the keyboard system with the supplied keyboard
void keyboardShow (void)
 Displays the keyboard.
int keyboardUpdate (void)
 Processes the keyboard. Should be called once per frame when using the keyboard in an async manner.

Detailed Description

nds stdio keyboard integration.

The keyboard component allows the use of a default keyboard via stdin as well as direct via the functions exposed below. The default behavior is a hidden keyboard that shows on a call to scanf(stdin, ...).
By default the keyboard uses background 3 of the sub display, consumes approximatly 40KiB of background vram begining at tile base 1 and 2KB of map stored at map base 30. The default is designed to function along side a default instance of the console print functionality.
To customize keyboard behavior and resource usage modify the keyboard structure returned by keyboardGetDefault() or create your own keyboard.

Enumeration Type Documentation

States the keyboard can be in, currently only Lower and Upper supported.

Enumerator:
Lower 

Normal keyboard display (lowercase letters)

Upper 

Caps lock Held

Numeric 

Numeric only keypad (not provided by the default keyboard)

Reduced 

Reduced footprint keyboard (not provided by the default keyboard)

enum Keys

enum values for the keyboard control keys. negative values are keys with no sensible ascii representation. numbers are chosen to mimic ascii control sequences.

Enumerator:
NOKEY 

will be returned if no key was pressed.

DVK_FOLD 

will be returned if the fold key was pressed (topleft on the default keyboard).

DVK_TAB 

will be returned if the tab key was pressed.

DVK_BACKSPACE 

will be returned if the backspace key was pressed.

DVK_CAPS 

will be returned if the caps key was pressed.

DVK_SHIFT 

will be returned if the shift key was pressed.

DVK_SPACE 

will be returned if the space key was pressed.

DVK_MENU 

will be returned if the menu key was pressed.

DVK_ENTER 

will be returned if the enter key was pressed.

DVK_CTRL 

will be returned if the ctrl key was pressed.

DVK_UP 

will be returned if the up key was pressed.

DVK_RIGHT 

will be returned if the right key was pressed.

DVK_DOWN 

will be returned if the down key was pressed.

DVK_LEFT 

will be returned if the left key was pressed.

DVK_ALT 

will be returned if the alt key was pressed.


Function Documentation

Keyboard* keyboardDemoInit ( void   ) 

initializes the keyboard with default options. Same as calling keyboardInit(NULL, 3, BgType_Text4bpp, BgSize_T_256x512, 20, 0, false, true)

Returns:
a pointer to the current keyboard.
Examples:
input/keyboard/keyboard_async/source/template.c, and input/keyboard/keyboard_stdin/source/keymain.c.
int keyboardGetKey ( int  x,
int  y 
)

returns the ascii code for the key located at the supplied x and y. Will not effect keyboard shift state.

Parameters:
x the pixel x location
y the pixel y location
Returns:
the key pressed or NOKEY if user pressed outside the keypad
void keyboardGetString ( char *  buffer,
int  maxLen 
)

reads the input until a the return key is pressed or the maxLen is exceeded.

Parameters:
buffer a buffer to hold the input string
maxLen the maximum length to read
Keyboard* keyboardInit ( Keyboard keyboard,
int  layer,
BgType  type,
BgSize  size,
int  mapBase,
int  tileBase,
bool  mainDisplay,
bool  loadGraphics 
)

initializes the keyboard system with the supplied keyboard

Parameters:
keyboard the keyboard struct to initialize (can be NULL)
layer the background layer to use
type the background type to initialize
size the background size to initialize
mapBase the map base to use for the background
tileBase the graphics tile base to use for the background
mainDisplay if true the keyboard will render on the main display
loadGraphics if true the keyboard graphics will be loaded
Returns:
returns the initialized keyboard struct
int keyboardUpdate ( void   ) 

Processes the keyboard. Should be called once per frame when using the keyboard in an async manner.

Returns:
the ascii code of the key pressed or -1 if no key was pressed.
Examples:
input/keyboard/keyboard_async/source/template.c.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Oct 2 12:55:13 2010 for libnds by  doxygen 1.6.3