32#define PAD_TRIANGLE 14
36#define PAD_ID_DIGITAL 4
37#define PAD_ID_ANALOG 7
40#define PAD_MULTITAP_ID 0x80
43#define PAD_MODE_UNLOCKED 2
44#define PAD_MODE_LOCKED 3
47#define RAW_TRIANGLE 12
50#define FACE_BUTTONS (1 << PAD_CIRCLE | 1 << PAD_CROSS | 1 << PAD_TRIANGLE)
54#define STICK_HIGH 0xC0
93#define PAD_FLAG_DEMO_PLAYBACK 0x00400000
94#define PAD_FLAG_DEMO_RECORDING 0x00800000
95#define PAD_FLAG_ALIGNING 0x04000000
96#define PAD_FLAG_VIBRATION 0x08000000
97#define PAD_FLAG_STARTED 0x20000000
98#define PAD_FLAG_INITIALIZED 0x40000000
99#define PAD_FLAG_MULTITAP 0x80000000
102#define PAD_DATA_SIZE 0x3E0
108#define DEMO_FRAME_COUNT 0x707
140#define PAD_PRESSED(button) ((PAD.getPressed(0) >> PAD.getButtonBit(0, button)) & 1)
141#define PAD_REPEATED(button) ((PAD.getRepeated(0) >> PAD.getButtonBit(0, button)) & 1)
142#define PAD_HELD(button) ((PAD.getHeld(0) >> PAD.getButtonBit(0, button)) & 1)
s32 startDemoRecording(void)
Demo recording was left out of the release: it never starts.
s32 getButtonBit(s32 pad, s32 index)
The bit that logical button index sets on pad 1 or 2.
s32 setVibration(u16 port, s32 motor, s16 time, u8 value)
Starts a motor for time vsyncs (0 stops it)
s32 pollPadState(u32 port)
The libpad state of a port while it can be read (0 otherwise); a stable pad gets its actuators aligne...
void updatePad(void)
Reads every pad, or the demo data while a demo plays.
void shutdownPad(void)
Stops reading the pads and forgets every flag, so the next startPad opens them again.
s32 getPadHeld(s32 pad)
The logical buttons held on pad 1 or 2.
s32 readPad(u16 port, PadData *data)
Reads one pad (vibration included), or clears its buttons when it is missing.
void initPad(s32 multitap, s32 repeatRate)
Opens the pads (PadInitMtap or PadInitDirect); repeatRate 0 means DEFAULT_REPEAT_RATE.
s32 getPadPressed(s32 pad)
The logical buttons newly pressed on pad 1 or 2 this frame.
void updateVibration(u16 port)
Counts down a pad's vibration timers and stops each motor whose time is up.
PadState PAD
Controller input: cleared by initPad, then the methods.
void readPadButtons(s32 port, PadData *data, PadData *record)
Builds held/pressed/repeated from the raw data (the demo record replaces all but Start)
void stopPad(void)
Stops reading the pads every vsync.
s32 isDemoRecording(s32 pad)
1 while pad pad records a demo, -1 while another pad does, 0 otherwise (never set)
void stopDemoRecording(void)
Does nothing: demo recording was left out.
u8 DEFAULT_BUTTON_MAP[16]
The identity: logical button i is bit i.
void stopDemoPlayback(void)
Gives the pads back to the players.
s32 isDemoPlaying(s32 pad)
1 while pad pad replays a demo, -1 while another pad does, 0 otherwise
s32 startDemoPlayback(s16 pad, PadBuffer *data)
Replays data (one raw buffer a frame) as the input of pad.
s32 lockPadMode(s32 port, s32 lock)
Locks or unlocks the analog button of a DualShock, keeping its current mode.
s32 getPadRepeated(s32 pad)
The logical buttons pressed on pad 1 or 2, repeating while held.
s32 alignActuators(u16 port)
Sends a DualShock its actuator alignment, so setVibration can drive the motors.
void swapButtons(u16 port, s32 a, s32 b)
Swaps two logical buttons in a pad slot's button map.
void startPad(void)
Opens the pads with the defaults if needed, then starts reading them every vsync.
void resetButtonMap(u16 port)
Gives a pad slot the default button map, where button i is bit i.
What a pad sends (libpad's receive buffer)
u16 buttons
raw: a bit is clear while its button is pressed
One controller: a port, or one of the four multitap slots behind it.
u16 repeated
pressed, or held long enough to repeat
s32(* getRepeated)(s32 pad)
s32(* getButtonBit)(s32 pad, s32 button)
void(* resetButtonMap)(u16 port)
s32(* startDemoPlayback)(s16 pad, PadBuffer *data)
s32(* lockMode)(s32 port, s32 lock)
void(* stopDemoRecording)()
void(* swapButtons)(u16 port, s32 a, s32 b)
void(* stopDemoPlayback)()
s32(* getPressed)(s32 pad)
void(* update)()
PAD_UPDATE.
s32(* setVibration)(u16 port, s32 motor, s16 time, u8 value)
s32(* startDemoRecording)()
PadBuffer * demoData
a buffer a frame
A port's receive buffer, and a frame of a demo: a pad, or a multitap and the four pads behind it.
struct PadBuffer::@11 tap