By default, the Mappy VM key bindings are as shown in the table to the right, but they can be changed at any time using the Joypad Configuration Dialog in the Options menu. |
|
Offset | Name | Type | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
$130 | KEYS | Read Only |   | Left Shoulder | Right Shoulder | DPad Down | DPad Up | DPad Left | DPad Right | Start | Select | B Button | A Button |
KEY_A, KEY_B, KEY_SELECT, KEY_START, KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN, KEY_RSHOULDER, and KEY_LSHOULDER
Example: How to poll the joypad status.
uint16 keysPressed; // Read the joypad status register and invert the bits keysPressed = (~KEYS) & 0x3FF; // keysPressed can be tested for any keys like this if (keysPressed & KEY_A) { dprintf("The A button has been pressed\n"); }
Offset | Name | Type | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
$132 | KEYS_CR | Read Write | Condition | IRQ enabled |   | Left Shoulder | Right Shoulder | DPad Down | DPad Up | DPad Left | DPad Right | Start | Select | B Button | A Button |
KEYS_CR_ENABLE
.KEYS_CR_OR
KEYS_CR_AND
Example: How to handle joypad input without polling.
In the setup code: // Configure the hardware to generate an interrupt when any key changes KEYS_CR = KEYS_CR_ENABLED | KEYS_CR_OR | 0x3FF; IE |= KEY_IRQ; In the interrupt handler: if (IF | KEY_IRQ) { // Do something with the KEYS register }
Copyright © 2001 to 2002, Bottled Light, Inc.