libtonc
Input

Routines for synchronous and asynchronous button states. More...

Macros

#define KEY_FULL   0xFFFFFFFF
 Define for checking all keys.
 
#define KEY_DOWN_NOW(key)   (~(REG_KEYINPUT) & key)
 
#define KEY_UP_NOW(key)   ( (REG_KEYINPUT) & key)
 
#define KEY_EQ(key_fun, keys)   ( key_fun(keys) == (keys) )
 
#define KEY_TRIBOOL(fnKey, plus, minus)    ( bit_tribool(fnKey(KEY_FULL), plus, minus) )
 

Typedefs

typedef enum eKeyIndex eKeyIndex
 

Enumerations

enum  eKeyIndex {
  KI_A =0 , KI_B , KI_SELECT , KI_START ,
  KI_RIGHT , KI_LEFT , KI_UP , KI_DOWN ,
  KI_R , KI_L , KI_MAX
}
 

Functions

void key_wait_for_clear (u32 key)
 

Variables

u16 __key_curr
 
u16 __key_prev
 

Basic synchonous keystates

void key_poll ()
 Poll for keystates and repeated keys.
 
INLINE u32 key_curr_state (void)
 Get current keystate.
 
INLINE u32 key_prev_state (void)
 Get previous key state.
 
INLINE u32 key_is_down (u32 key)
 Gives the keys of key that are currently down.
 
INLINE u32 key_is_up (u32 key)
 Gives the keys of key that are currently up.
 
INLINE u32 key_was_down (u32 key)
 Gives the keys of key that were previously down.
 
INLINE u32 key_was_up (u32 key)
 Gives the keys of key that were previously down.
 

Transitional keystates

INLINE u32 key_transit (u32 key)
 Gives the keys of key that are different from before.
 
INLINE u32 key_held (u32 key)
 Gives the keys of key that are being held down.
 
INLINE u32 key_hit (u32 key)
 Gives the keys of key that are pressed (down now but not before)
 
INLINE u32 key_released (u32 key)
 Gives the keys of key that are being released.
 

Tribools

INLINE int key_tri_horz (void)
 Horizontal tribool (right,left)=(+,-)
 
INLINE int key_tri_vert (void)
 Vertical tribool (down,up)=(+,-)
 
INLINE int key_tri_shoulder (void)
 Shoulder-button tribool (R,L)=(+,-)
 
INLINE int key_tri_fire (void)
 Fire-button tribool (A,B)=(+,-)
 

Key repeats

u32 key_repeat (u32 keys)
 Get status of repeated keys.
 
void key_repeat_mask (u32 mask)
 Set repeat mask. Only these keys will be considered for repeats.
 
void key_repeat_limits (uint delay, uint repeat)
 Set the delay and repeat limits for repeated keys.
 
void key_wait_till_hit (u16 key)
 Wait until key is hit.
 

Detailed Description

Routines for synchronous and asynchronous button states.

For details, see tonc:keys.

Function Documentation

◆ key_repeat_limits()

void key_repeat_limits ( uint  delay,
uint  repeat 
)

Set the delay and repeat limits for repeated keys.

Parameters
delaySet first repeat limit. If 0, repeats are off.
repeatSets later repeat limit.
Note
Both limits have a range of [0, 255]. If either argument is <0, the old value will be kept.

References REPEAT_REC::count, REPEAT_REC::delay, and REPEAT_REC::repeat.