# PAD_Read

## C Specification

  `#include <nitro/pad.h>`
  u16`PAD_Read( void );`

## Arguments

None.

## Return Values

Current key information

## Description

Gets the information for pressed keys/buttons. The key/button information is the logical sum of the following values.

PAD_BUTTON_A | The A Button is being pressed
PAD_BUTTON_B | The B Button is being pressed
PAD_BUTTON_SELECT | SELECT is being pressed
PAD_BUTTON_START | START is being pressed
PAD_KEY_RIGHT | +Control Pad Right key is being pressed
PAD_KEY_LEFT | +Control Pad Left key is being pressed
PAD_KEY_UP | +Control Pad Up key is being pressed
PAD_KEY_DOWN | +Control Pad Down key is being pressed
PAD_BUTTON_R | R Button is being pressed
PAD_BUTTON_L | L Button is being pressed
PAD_BUTTON_X | X Button is being pressed
PAD_BUTTON_Y | Y Button is being pressed
PAD_BUTTON_DEBUG | DEBUG Button is being pressed

The X and Y buttons can be read from ARM9 because ARM7 checks a general purpose port and writes in a shared region. Therefore, if the ARM7 read module is not operating, X and Y buttons cannot be read. `PAD_BUTTON_MASK` is defined as the logical sum of all buttons (`PAD_BUTTON_`...), and `PAD_PLUS_KEY_MASK` is defined as the logical sum of all keys (`PAD_KEY_`...). PAD_ALL_MASK is defined as the sum of all buttons and keys.
Only the sum of X, Y, and `DEBUG` buttons read by ARM7 will be defined as `PAD_RCNTPORT_MASK`. Sums of other buttons are defined as `PAD_KEYPORT_MASK`.

D
e
b
u
g

N
/
A

Y

X

L

R

D
o
w
n

U
p

L
e
f
t

R
i
g
h
t

S
t
a
r
t

S
e
l
e
c
t

B

A

Value

PAD_BUTTON_MASK | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0x2F0F
PAD_PLUS_KEY_MASK | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0x00F0
PAD_ALL_MASK | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0x2FFF
PAD_RCNPORT_MASK | 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0x2C00
PAD_KEYPORT_MASK | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0x03FF

> (Example)
> `u16 padData = PAD_Read();
> if ( padData & PAD_BUTTON_A )
> {
> OS_Printf( "you're pushing A-BUTTON\n" );
> }
> if ( padData & PAD_PLUS_KEY_MASK )
> {
> OS_Printf( "you're pushing any PLUS-KEY\n" );
> }`

`PAD_Read()` reads the `KEYINPUT IO` register internally, aligns with the value from the `RCNT` register of the generic port that ARM7 acquired, and returns a value with the Key/Button mask `PAD_ALL_MASK` applied.

## See Also

## Revision History

08/06/2004 Deleted `PAD_SetIrq` and `PAD_ClearIrq` from See Also
04/13/2004 Added `DEBUG` button
02/19/2004 Added X, Y buttons
12/01/2003 Initial version

CONFIDENTIAL