libmsx
C library for MSX
Loading...
Searching...
No Matches
Joystick / Joypad inteface

Get Joypad button state. More...

+ Collaboration diagram for Joystick / Joypad inteface:

Macros

#define VK_UP   (1 << 0)
 Bitmask for UP direction of joystick or UP arrow key.
 
#define VK_DOWN   (1 << 1)
 Bitmask for DOWN direction of joystick or DOWN arrow key.
 
#define VK_LEFT   (1 << 2)
 Bitmask for LEFT direction of joystick or LEFT arrow key.
 
#define VK_RIGHT   (1 << 3)
 Bitmask for RIGHT direction of joystick or RIGHT arrow key.
 
#define VK_FIRE_0   (1 << 4)
 Bitmask for trigger button #1 or SPACE key.
 
#define VK_FIRE_1   (1 << 5)
 Bitmask for trigger button #2.
 

Functions

uint8_t joypad_get_state (uint8_t controller)
 MSX Get the status of the joystick buttons and levers.
 

Detailed Description

Get Joypad button state.

Macro Definition Documentation

◆ VK_UP

#define VK_UP   (1 << 0)

Bitmask for UP direction of joystick or UP arrow key.

See also
joypad_get_state()

Definition at line 40 of file input.h.

◆ VK_DOWN

#define VK_DOWN   (1 << 1)

Bitmask for DOWN direction of joystick or DOWN arrow key.

See also
joypad_get_state()

Definition at line 47 of file input.h.

◆ VK_LEFT

#define VK_LEFT   (1 << 2)

Bitmask for LEFT direction of joystick or LEFT arrow key.

See also
joypad_get_state()

Definition at line 54 of file input.h.

◆ VK_RIGHT

#define VK_RIGHT   (1 << 3)

Bitmask for RIGHT direction of joystick or RIGHT arrow key.

See also
joypad_get_state()

Definition at line 61 of file input.h.

◆ VK_FIRE_0

#define VK_FIRE_0   (1 << 4)

Bitmask for trigger button #1 or SPACE key.

See also
joypad_get_state()

Definition at line 68 of file input.h.

◆ VK_FIRE_1

#define VK_FIRE_1   (1 << 5)

Bitmask for trigger button #2.

See also
joypad_get_state()

Definition at line 75 of file input.h.

Function Documentation

◆ joypad_get_state()

uint8_t joypad_get_state ( uint8_t  controller)

MSX Get the status of the joystick buttons and levers.

Get the status of the two trigger buttons and eight-way lever of the specified joystick (or SPACE key and arrow keys of the keyboard).

Parameters
controllerjoystick number
  • 0 : keyboard (the arrow keys and the SPACE key)
  • 1 : joystick #1
  • 2 : joystick #2
Returns
status of buttons.
the following bits will be 1 if corresponding buttons / keys were pressed or will be 0 if released.
  • bit #0 : VK_UP
  • bit #1 : VK_DOWN
  • bit #2 : VK_LEFT
  • bit #3 : VK_RIGHT
  • bit #4 : VK_FIRE_0
  • bit #5 : VK_FIRE_1
Note
Each bit of the return value is independent and dedicated to the corresponding button/key. Therefore, a single call to joypad_get_state() can be used to get the state of all buttons on the specified joystick.
For example, if you push the joystick lever to the upper right and press trigger #1, bit #0, bit #3, and bit #4 of the return value will be set to 1 (i.e., the value VK_UP | VK_RIGHT | VK_FIRE_0 will be returned).
See also
msx_GTSTCK()
msx_GTTRIG()