wavelength 1.0.0
Loading...
Searching...
No Matches
breugpad.h
Go to the documentation of this file.
1#pragma once
2
3#include <libpad.h>
4
13class BreugPad {
14public:
16 static constexpr int kActuatorByteCount = 6;
17
19 static constexpr int kPressureByteCount = 12;
20
22 static constexpr int kDmaFrameCount = 2;
23
25 static constexpr int kLastAxisCount = 4;
26
28 static constexpr int kAxisDeltaCount = 4;
29
41 void SetActuators(int nSmallMotor, unsigned char nBigMotor);
42
57 void Init(int nPort, int nSlot, int nDeadZone);
58
71 static short ApplyDeadzone(short nAxis, int nDeadZone);
72
93 int Read(int *pButtons,
94 unsigned char *pAxis0,
95 unsigned char *pAxis1,
96 unsigned char *pAxis2,
97 unsigned char *pAxis3,
98 unsigned char *pPressures,
99 short *pPressureDeltas);
100
102 alignas(64) scePadDmaFrame mDmaArea[kDmaFrameCount];
103
104private:
110 bool WaitForRequest();
111
117 void AdvancePhase(int nState);
118
120 int mButtons;
121
122 int mHeldButtonsSeen; // +0x104, every button pressed since Init()
123
124 int mToggledButtons; // +0x108, each new press toggles its bit
125
126 int mPreviousButtons; // +0x10c, mButtons before the latest report
127
129 int mPort;
130
132 int mSlot;
133
134 unsigned short mRawButtons; // +0x118, the latest report's button word
135
137 int mPhase;
138
139 int mReportMode; // +0x120, the latest report's mode byte
140
145 int mReadyLevel;
146
147 int mDeadZone; // +0x128, Init()'s fourth argument
148
149 int mReadCount; // +0x12c, counted by Read()
150
151 unsigned char mLastAxes[kLastAxisCount]; // +0x130, cleared by Init() and otherwise unused
152
153 short mAxisDeltas[kAxisDeltaCount]; // +0x134, cleared by Init() and otherwise unused
154
156 unsigned char mPressureBaseline[kPressureByteCount];
157
159 unsigned char mActDirect[kActuatorByteCount];
160
162 unsigned char mActAlign[kActuatorByteCount];
163};
One controller's pad-library state: the DMA area libpad fills and the decoder's working state.
Definition breugpad.h:13
static constexpr int kActuatorByteCount
Bytes of the actuator buffers scePadSetActDirect() and scePadSetActAlign() receive.
Definition breugpad.h:16
void Init(int nPort, int nSlot, int nDeadZone)
Reset the record and open the pad at nPort and nSlot.
static short ApplyDeadzone(short nAxis, int nDeadZone)
Rescale an analog axis centred on zero to remove the dead zone.
void SetActuators(int nSmallMotor, unsigned char nBigMotor)
Drive the two vibration motors.
static constexpr int kLastAxisCount
Entries of mLastAxes.
Definition breugpad.h:25
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 constexpr int kPressureByteCount
Bytes of the pressure baseline Read() subtracts from each pressure reading.
Definition breugpad.h:19
static constexpr int kAxisDeltaCount
Entries of mAxisDeltas.
Definition breugpad.h:28
static constexpr int kDmaFrameCount
Frames of the DMA area scePadPortOpen() receives.
Definition breugpad.h:22
scePadDmaFrame mDmaArea[kDmaFrameCount]
The area libpad writes reports into.
Definition breugpad.h:102