libnds
Loading...
Searching...
No Matches
Functions
input.h File Reference

NDS button and touchscreen input support. More...

#include <nds/input.h>
#include <nds/ndstypes.h>
#include <nds/touch.h>

Functions

uint32_t keysCurrent (void)
 Obtains the current keypad state.
 
uint32_t keysDown (void)
 Obtains the keys that have been pressed right now.
 
uint32_t keysDownRepeat (void)
 Obtains the keys that have been pressed right now (or repeated press).
 
uint32_t keysHeld (void)
 Obtains the current keypad held state.
 
void keysSetRepeat (u8 setDelay, u8 setRepeat)
 Sets the key repeat parameters.
 
uint32_t keysUp (void)
 Obtains the keys that have just been released.
 
void scanKeys (void)
 Obtains the current keypad state.
 
void touchRead (touchPosition *data)
 Obtains the current touchpad state.
 

Detailed Description

NDS button and touchscreen input support.

The state of the keypad must be read from hardware into memory using scanKeys() whenever you want an updated input state. After reading, call one of the associated "keys" functions to see what event was triggered. These events are computed as the difference between the current and previous key state you read. It's generally a good idea to scan keys frequently to ensure your application's input system is responsive.

After reading the key state, you will be given an integer representing which keys are in the requested state. To mask of specific buttons, use the key masks described in nds/input.h .

See also
nds/input.h available key masks on the Nintendo DS

Function Documentation

◆ keysCurrent()

uint32_t keysCurrent ( void  )

Obtains the current keypad state.

Call this function to get keypad state without affecting state of other key functions (keysUp keysHeld etc...).

Returns
Bitmask of keys that are pressed.

◆ keysDown()

uint32_t keysDown ( void  )

Obtains the keys that have been pressed right now.

Returns
Bitmask of keys that have just been pressed.

◆ keysDownRepeat()

uint32_t keysDownRepeat ( void  )

Obtains the keys that have been pressed right now (or repeated press).

Returns
Bitmask of keys that have just been pressed or have been held for long enough to repeat the press.

◆ keysHeld()

uint32_t keysHeld ( void  )

Obtains the current keypad held state.

Returns
Bitmask of keys that are pressed.

◆ keysSetRepeat()

void keysSetRepeat ( u8  setDelay,
u8  setRepeat 
)

Sets the key repeat parameters.

Parameters
setDelayNumber of scanKeys calls before keys start to repeat.
setRepeatNumber of scanKeys calls before keys repeat.

◆ keysUp()

uint32_t keysUp ( void  )

Obtains the keys that have just been released.

Returns
Bitmask of keys that have just been released.

◆ scanKeys()

void scanKeys ( void  )

Obtains the current keypad state.

Call this function once per main loop in order to use the keypad functions.

◆ touchRead()

void touchRead ( touchPosition data)

Obtains the current touchpad state.

Parameters
dataA touchPosition pointer which will be filled by the function.