PVSnesLib  3.4.0
Macros | Typedefs | Enumerations | Functions | Variables
pad.h File Reference

pad support. More...

#include <snes/snestypes.h>
#include <snes/interrupt.h>

Go to the source code of this file.

Macros

#define padsCurrent(value)   (pad_keys[value])
 Return current value of selected pad. More...
 
#define REG_JOYxLH(a)   (((vuint16*)0x4218)[(a)])
 SNES Controllers I/O Ports - Automatic Reading. 4218h/4219h - JOY1L/JOY1H - Joypad 1 (gameport 1, pin 4) (R) 421Ah/421Bh - JOY2L/JOY2H - Joypad 2 (gameport 2, pin 4) (R) 421Ch/421Dh - JOY3L/JOY3H - Joypad 3 (gameport 1, pin 5) (R) 421Eh/421Fh - JOY4L/JOY4H - Joypad 4 (gameport 2, pin 5) (R) More...
 

Typedefs

typedef enum KEYPAD_BITS KEYPAD_BITS
 enum values for the pad buttons.
 

Enumerations

enum  KEYPAD_BITS {
  KEY_A = BIT(7), KEY_B = BIT(15), KEY_SELECT = BIT(13), KEY_START = BIT(12),
  KEY_RIGHT = BIT(8), KEY_LEFT = BIT(9), KEY_DOWN = BIT(10), KEY_UP = BIT(11),
  KEY_R = BIT(4), KEY_L = BIT(5), KEY_X = BIT(6), KEY_Y = BIT(14)
}
 enum values for the pad buttons. More...
 

Functions

void detectMPlay5 (void)
 Check if MultiPlayer5 is connected and populate snes_mplay5 (0 or 1 for connected)
 
void padsClear (u16 value)
 Clear internal variables for selected pad. More...
 
unsigned short padsDown (u16 value)
 Return value of down keys for selected pad. More...
 
unsigned short padsUp (u16 value)
 Return value of up keys for selected pad. More...
 
void scanMPlay5 (void)
 Wait for multiplayer5 pads ready and read pad values in .
 
void scanPads (void)
 Wait for pad ready and read pad values in .
 

Variables

u8 snes_mplay5
 1 if MultiPlay5 connected
 

Detailed Description

pad support.

common values for pad input.

common values that can be used to test auto pad.

Macro Definition Documentation

◆ padsCurrent

padsCurrent (   value)    (pad_keys[value])

◆ REG_JOYxLH

#define REG_JOYxLH (   a)    (((vuint16*)0x4218)[(a)])

SNES Controllers I/O Ports - Automatic Reading. 4218h/4219h - JOY1L/JOY1H - Joypad 1 (gameport 1, pin 4) (R) 421Ah/421Bh - JOY2L/JOY2H - Joypad 2 (gameport 2, pin 4) (R) 421Ch/421Dh - JOY3L/JOY3H - Joypad 3 (gameport 1, pin 5) (R) 421Eh/421Fh - JOY4L/JOY4H - Joypad 4 (gameport 2, pin 5) (R)

Register Serial Default Bit Transfer Purpose Number______Order______(Joypads)_____ 15 1st B Button (1=Low=Pressed) 14 2nd Y Button 13 3rd Select Button 12 4th Start Button 11 5th Up 10 6th Down 9 7th Left 8 8th Right 7 9th A Button 6 10th X Button 5 11th L Button 4 12th R Button 3 13th 0 (High) 2 14th 0 (High) 1 15th 0 (High) 0 16th 0 (High)

When enabled, the SNES will read 16 bits from each of the 4 controller port data lines into registers $4218-f. This begins between H=32.5 and H=95.5 of the first V-Blank scanline, and ends 4224 master cycles later. Register $4212 bit 0 is set during this time. Specifically, it begins at H=74.5 on the first frame, and thereafter some multiple of 256 cycles after the start of the previous read that falls within the observed range.

Reading $4218-f during this time will read back incorrect values. The only reliable value is that no buttons pressed will return 0 (however, if buttons are pressed 0 could still be returned incorrectly). Presumably reading $4016/7 or writing $4016 during this time will also screw things up.

Enumeration Type Documentation

◆ KEYPAD_BITS

enum values for the pad buttons.

Enumerator
KEY_A 

pad A button.

KEY_B 

pad B button.

KEY_SELECT 

pad SELECT button.

KEY_START 

pad START button.

KEY_RIGHT 

pad RIGHT button.

KEY_LEFT 

pad LEFT button.

KEY_DOWN 

pad DOWN button.

KEY_UP 

pad UP button.

KEY_R 

Right shoulder button.

KEY_L 

Left shoulder button.

KEY_X 

pad X button.

KEY_Y 

pad Y button.

Function Documentation

◆ padsClear()

padsClear ( u16  value)

Clear internal variables for selected pad.

Parameters
valueAddress of the pad to use (0 or 1 to 4 if multiplayer 5 connected)

◆ padsDown()

padsDown ( u16  value)

Return value of down keys for selected pad.

Parameters
valueAddress of the pad to use (0 or 1 to 4 if multiplayer 5 connected)
Returns
unsigned short of the current pad value
Examples:
graphics/Effects/HDMAGradient/HDMAGradient.c.

◆ padsUp()

padsUp ( u16  value)

Return value of up keys for selected pad.

Parameters
valueAddress of the pad to use (0 or 1 to 4 if multiplayer 5 connected)
Returns
unsigned short of the current pad value