wavelength 1.0.0
Loading...
Searching...
No Matches
BreugPad Class Reference

One controller's pad-library state: the DMA area libpad fills and the decoder's working state. More...

#include <breugpad.h>

Public Member Functions

void SetActuators (int nSmallMotor, unsigned char nBigMotor)
 Drive the two vibration motors.
void Init (int nPort, int nSlot, int nDeadZone)
 Reset the record and open the pad at nPort and nSlot.
int Read (int *pButtons, unsigned char *pAxis0, unsigned char *pAxis1, unsigned char *pAxis2, unsigned char *pAxis3, unsigned char *pPressures, short *pPressureDeltas)
 Advance the pad's setup state machine and decode the latest report.

Static Public Member Functions

static short ApplyDeadzone (short nAxis, int nDeadZone)
 Rescale an analog axis centred on zero to remove the dead zone.

Public Attributes

scePadDmaFrame mDmaArea [kDmaFrameCount]
 The area libpad writes reports into.

Static Public Attributes

static constexpr int kActuatorByteCount = 6
 Bytes of the actuator buffers scePadSetActDirect() and scePadSetActAlign() receive.
static constexpr int kPressureByteCount = 12
 Bytes of the pressure baseline Read() subtracts from each pressure reading.
static constexpr int kDmaFrameCount = 2
 Frames of the DMA area scePadPortOpen() receives.
static constexpr int kLastAxisCount = 4
 Entries of mLastAxes.
static constexpr int kAxisDeltaCount = 4
 Entries of mAxisDeltas.

Detailed Description

One controller's pad-library state: the DMA area libpad fills and the decoder's working state.

The class is not polymorphic and emits no RTTI. The title comes from the prefix of its messages. The joypad layer has a table of eight at 0x00480240, one per port and multitap slot. The record is 0x180 bytes. The first 0x100 bytes are the area scePadPortOpen() receives, and the record therefore starts on a 64-byte boundary.

Member Function Documentation

◆ SetActuators()

void BreugPad::SetActuators ( int nSmallMotor,
unsigned char nBigMotor )

Drive the two vibration motors.

Does nothing until mReadyLevel arrives at 2. Otherwise the small motor runs whenever nSmallMotor is positive, and the big motor takes nBigMotor as its level.

Parameters
nSmallMotorPositive to run the small motor.
nBigMotorThe big motor's level.
Ghidra address:
NTSC-U/C: 0x0028d4a0
Ghidra address:
PAL: 0x00296e80

◆ Init()

void BreugPad::Init ( int nPort,
int nSlot,
int nDeadZone )

Reset the record and open the pad at nPort and nSlot.

Clears the actuator levels and the pressure baseline, aligns actuator 0 to byte 0 and actuator 1 to byte 1 with the rest unused, starts libpad through scePadInit(0) the first time any record opens, and opens the port with mDmaArea. Also sets the scale of ApplyDeadzone() from nDeadZone, which every record shares.

Parameters
nPortThe port, from 0.
nSlotThe multitap slot, from 0.
nDeadZoneStored in mDeadZone.
Ghidra address:
NTSC-U/C: 0x0028d4e8
Ghidra address:
PAL: 0x00296ec8

◆ ApplyDeadzone()

short BreugPad::ApplyDeadzone ( short nAxis,
int nDeadZone )
static

Rescale an analog axis centred on zero to remove the dead zone.

A magnitude below nDeadZone reads 0. A larger one maps linearly from the dead zone's edge to 127, rounded, with the sign of nAxis.

Parameters
nAxisThe axis, from -128 to 127.
nDeadZoneThe dead zone's magnitude.
Returns
The rescaled axis.
Ghidra address:
NTSC-U/C: 0x0028d650
Ghidra address:
PAL: 0x00297030

◆ Read()

int BreugPad::Read ( int * pButtons,
unsigned char * pAxis0,
unsigned char * pAxis1,
unsigned char * pAxis2,
unsigned char * pAxis3,
unsigned char * pPressures,
short * pPressureDeltas )

Advance the pad's setup state machine and decode the latest report.

mPhase indexes a 78-entry jump table at 0x0041c5e0 that walks the pad through analog mode, actuator alignment, and pressure-sensitive mode, and mReadyLevel records how far it has got. Each non-null output receives one value of the decoded report, the analog values centred on zero and passed through ApplyDeadzone(). A pad that is not stable reports only mButtons and zero axes.

Parameters
pButtonsReceives the button word at mButtons, or null.
pAxis0Receives the left stick's horizontal axis, or null.
pAxis1Receives the left stick's vertical axis, or null.
pAxis2Receives the right stick's horizontal axis, or null.
pAxis3Receives the right stick's vertical axis, or null.
pPressuresReceives the twelve pressure bytes, or null.
pPressureDeltasReceives each pressure less its baseline, or null.
Returns
mReadyLevel, or 0 when the read fails.
Ghidra address:
NTSC-U/C: 0x0028d6f8
Ghidra address:
PAL: 0x002970d8

Member Data Documentation

◆ kActuatorByteCount

int BreugPad::kActuatorByteCount = 6
staticconstexpr

Bytes of the actuator buffers scePadSetActDirect() and scePadSetActAlign() receive.

◆ kPressureByteCount

int BreugPad::kPressureByteCount = 12
staticconstexpr

Bytes of the pressure baseline Read() subtracts from each pressure reading.

◆ kDmaFrameCount

int BreugPad::kDmaFrameCount = 2
staticconstexpr

Frames of the DMA area scePadPortOpen() receives.

◆ kLastAxisCount

int BreugPad::kLastAxisCount = 4
staticconstexpr

Entries of mLastAxes.

◆ kAxisDeltaCount

int BreugPad::kAxisDeltaCount = 4
staticconstexpr

Entries of mAxisDeltas.

◆ mDmaArea

scePadDmaFrame BreugPad::mDmaArea[kDmaFrameCount]

The area libpad writes reports into.

+0x000


The documentation for this class was generated from the following file: