

#include <nitro/pad.h> PAD_Read( void );None.
Current key information
In response to prohibited input, such as simultaneous presses of either (1) UP and DOWN or (2) LEFT and RIGHT on the +Control Pad, a filter is applied so that only UP will considered to have been pressed in the former case, and only LEFT will be considered to have been pressed in the latter case.
Gets the information for pressed keys or buttons. The key/button information is the logical sum of the following values.
| Value (Definition) | State | Value (Value) |
|---|---|---|
PAD_BUTTON_A |
A Button is being pressed | 0x0001 |
PAD_BUTTON_B |
B Button is being pressed. | 0x0002 |
PAD_BUTTON_SELECT |
SELECT is being pressed. | 0x0004 |
PAD_BUTTON_START |
START is being pressed. | 0x0008 |
PAD_KEY_RIGHT |
+Control Pad Right key is being pressed. | 0x0010 |
PAD_KEY_LEFT |
+Control Pad Left key is being pressed. | 0x0020 |
PAD_KEY_UP |
+Control Pad Up key is being pressed. | 0x0040 |
PAD_KEY_DOWN |
+Control Pad Down key is being pressed. | 0x0080 |
PAD_BUTTON_R |
R Button is being pressed. | 0x0100 |
PAD_BUTTON_L |
L Button is being pressed. | 0x0200 |
PAD_BUTTON_X |
X Button is being pressed. | 0x0400 |
PAD_BUTTON_Y |
Y Button is being pressed. | 0x0800 |
PAD_BUTTON_DEBUG |
DEBUG Button is being pressed. | 0x2000 |
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, the 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 the 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.
| Bit | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 |
|
u16 padData = PAD_Read();
if ( padData & PAD_BUTTON_A )
{
OS_Printf( "You're pushing the A Button\n" );
}
if ( padData & PAD_PLUS_KEY_MASK )
{
OS_Printf( "You're pushing one of the +Control Pad keys\n" );
}
The PAD_Read function 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.
The DEBUG Button can be used freely by an application for development purposes. With IS-NITRO-DEBUGGER, the Power Button of the DS connected to the debugger serves as the DEBUG Button. (It will not work as the Power Button.)
The Power button of the TWL system connected to the debugger will also serve as the DEBUG button with IS-TWL-DEBUGGER. However, it will also function as an actual Power button, so its intended purpose is slightly different than that of IS-NITRO-DEBUGGER.
2008/04/16 Added a description of the prohibited input filter.
2004/08/06 Removed PAD_SetIrq and PAD_ClearIrq from See Also.
2004/04/13 Added the DEBUG button.
2004/02/19 Added the X and Y Buttons.
2003/12/01 Initial version.
CONFIDENTIAL