Keypad Registers

There are 10 inputs available, corresponding to a 4 way direction pad, start, select, A, B, and two shoulder buttons L and R.

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.
DPad LeftLeft cursor
DPad RightRight cursor
DPad UpUp cursor
DPad DownDown cursor
Start1
Select2
A buttonZ
B buttonX
L shoulderA
R shoulderS


Joypad Status Register (KEYS)

OffsetNameType FEDCBA98 76543210
$130 KEYS Read Only   Left Shoulder Right Shoulder DPad Down DPad Up DPad Left DPad Right Start Select B Button A Button

Details

Uses and examples

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");
  }

Joypad Interrupt Control Register (KEYS_CR)

OffsetNameType FEDCBA98 76543210
$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

Details

Uses and examples

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.