resonance 1.0.1
Loading...
Searching...
No Matches
padrecord.h
Go to the documentation of this file.
1#pragma once
2
3#include <libpad.h>
4
18class PadRecord {
19public:
21 static constexpr int kActuatorByteCount = 6;
22
24 static constexpr int kPressureByteCount = 12;
25
27 static constexpr int kDmaFrameCount = 2;
28
30 static constexpr int kLastAxisCount = 4;
31
33 static constexpr int kAxisDeltaCount = 4;
34
35#ifdef VIDEO_STANDARD_PAL
44 static void EndLibrary();
45#endif
46
48 alignas(64) scePadDmaFrame mDmaArea[kDmaFrameCount];
49
51 unsigned int mButtons;
52
53 // Cleared by BreugPadInit(), and written by BreugPadRead() and never read. +0x104 to +0x10c
54 unsigned int mHeldButtonsSeen; // every button held since BreugPadInit()
55 unsigned int mToggledButtons; // each new press toggles its bit
56 unsigned int mPreviousButtons; // mButtons before the latest report
57
59 int mPort;
60
62 int mSlot;
63
64 short mRawButtons; // +0x118, the latest report's button word, cleared by BreugPadInit()
65
70 int mPhase;
71
72 int mReportMode; // +0x120, the latest report's mode byte, cleared by BreugPadInit()
73
79
80 int mDeadZone; // +0x128, BreugPadInit()'s fourth argument
81 int mReadCount; // +0x12c, counted by BreugPadRead()
82 unsigned char mLastAxes[kLastAxisCount]; // +0x130, written by BreugPadRead()
83 short mAxisDeltas[kAxisDeltaCount]; // +0x134, written by BreugPadRead()
84
87
90
93};
94
109void BreugPadInit(PadRecord *pPad, int nPort, int nSlot, int nDeadZone);
110
134 unsigned int *pButtons,
135 unsigned char *pAxis0,
136 unsigned char *pAxis1,
137 unsigned char *pAxis2,
138 unsigned char *pAxis3,
139 unsigned char *pPressures,
140 short *pPressureDeltas);
141
154void BreugPadSetMotors(PadRecord *pPad, int nSmallMotor, int nBigMotor);
One controller's pad-library state: the DMA area libpad fills and the decoder's working state.
Definition padrecord.h:18
unsigned int mButtons
The decoded button word BreugPadRead() reports.
Definition padrecord.h:51
static constexpr int kDmaFrameCount
Frames of the DMA area scePadPortOpen() receives.
Definition padrecord.h:27
int mDeadZone
Definition padrecord.h:80
unsigned int mToggledButtons
Definition padrecord.h:55
unsigned char mActAlign[kActuatorByteCount]
The actuator alignment BreugPadRead() sends during setup.
Definition padrecord.h:92
int mPort
The port BreugPadInit() received.
Definition padrecord.h:59
int mReadCount
Definition padrecord.h:81
static constexpr int kLastAxisCount
Entries of mLastAxes.
Definition padrecord.h:30
short mAxisDeltas[kAxisDeltaCount]
Definition padrecord.h:83
unsigned char mActDirect[kActuatorByteCount]
The actuator levels BreugPadSetMotors() sends.
Definition padrecord.h:89
unsigned int mHeldButtonsSeen
Definition padrecord.h:54
static constexpr int kActuatorByteCount
Bytes of the actuator buffers scePadSetActDirect() and scePadSetActAlign() receive.
Definition padrecord.h:21
int mReportMode
Definition padrecord.h:72
int mSlot
The multitap slot BreugPadInit() received.
Definition padrecord.h:62
unsigned char mPressureBaseline[kPressureByteCount]
The pressure baseline BreugPadRead() subtracts.
Definition padrecord.h:86
static constexpr int kPressureByteCount
Bytes of the pressure baseline BreugPadRead() subtracts from each pressure reading.
Definition padrecord.h:24
static constexpr int kAxisDeltaCount
Entries of mAxisDeltas.
Definition padrecord.h:33
scePadDmaFrame mDmaArea[kDmaFrameCount]
The area libpad writes reports into.
Definition padrecord.h:48
unsigned int mPreviousButtons
Definition padrecord.h:56
int mReadyLevel
Setup progress BreugPadRead() records.
Definition padrecord.h:78
int mPhase
Index into BreugPadRead()'s setup state machine.
Definition padrecord.h:70
short mRawButtons
Definition padrecord.h:64
unsigned char mLastAxes[kLastAxisCount]
Definition padrecord.h:82
void BreugPadSetMotors(PadRecord *pPad, int nSmallMotor, int nBigMotor)
Drive a pad's two vibration motors.
void BreugPadInit(PadRecord *pPad, int nPort, int nSlot, int nDeadZone)
Reset a record and open the pad at nPort and nSlot.
int BreugPadRead(PadRecord *pPad, unsigned int *pButtons, unsigned char *pAxis0, unsigned char *pAxis1, unsigned char *pAxis2, unsigned char *pAxis3, unsigned char *pPressures, short *pPressureDeltas)
Advance a pad's setup state machine and decode the latest report.