Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
JUTGamePad.h
Go to the documentation of this file.
1#ifndef JUTGAMEPAD_H
2#define JUTGAMEPAD_H
3
5#include "dolphin/os/OSTime.h"
6#include "dolphin/pad.h"
7
8typedef void (*callbackFn)(int, void*);
9
10namespace CButton {
11enum {
12 DPAD_LEFT = 0x0001,
13 DPAD_RIGHT = 0x0002,
14 DPAD_DOWN = 0x0004,
15 DPAD_UP = 0x0008,
16 Z = 0x0010,
17 R = 0x0020,
18 L = 0x0040,
19 A = 0x0100,
20 B = 0x0200,
21 X = 0x0400,
22 Y = 0x0800,
23 START = 0x1000,
24};
25}
26
28
34 virtual void unk0() {}
35 virtual void unk1(PADStatus* pad) {}
36 virtual void unk2() {}
37
38 /* 0x4 */ bool mActive;
39};
40
45struct JUTGamePad : public JKRDisposer {
46public:
49 };
61
63 virtual ~JUTGamePad();
64
65 void initList();
66 static s32 init();
67 void clear();
68 static u32 read();
69 void assign();
70 void checkResetCallback(OSTime unk);
71 void update();
73 static void checkResetSwitch();
74 static void clearForReset();
75 static JUTGamePad* getGamePad(int pad_index);
76 static bool recalibrate(u32 pad_mask);
77
78 static void setAnalogMode(u32 mode) {
79 sAnalogMode = mode;
80 PADSetAnalogMode(mode);
81 }
82
84
85 static void setResetCallback(callbackFn callback, void* param_0) {
86 C3ButtonReset::sCallback = callback;
88 }
89
90 u32 getButton() const { return mButton.mButton; }
91
92 u32 getTrigger() const { return mButton.mTrigger; }
93
94 f32 getMainStickX() const { return mMainStick.mPosX; }
95
96 f32 getMainStickY() const { return mMainStick.mPosY; }
97
99
101
102 f32 getSubStickX() const { return mSubStick.mPosX; }
103
104 f32 getSubStickY() const { return mSubStick.mPosY; }
105
109
110 u8 getAnalogA() const { return mButton.mAnalogA; }
111
112 u8 getAnalogB() const { return mButton.mAnalogB; }
113
114 u8 getAnalogL() const { return mButton.mAnalogL; }
115
116 u8 getAnalogR() const { return mButton.mAnalogR; }
117
118 s8 getErrorStatus() const { return mErrorStatus; }
119
120 s16 getPortNum() const { return mPortNum; }
121
123
125
126 u32 testTrigger(u32 button) const { return mButton.mTrigger & button; }
127
129 bool isPushingReset = false;
130
131 if (mPortNum != -1 && mButtonReset.mReset != false) {
132 isPushingReset = true;
133 }
134 return isPushingReset;
135 }
136
140
142
143 struct CButton {
144 CButton() { clear(); }
145 void clear();
146 void update(PADStatus const*, u32 unk);
147 void setRepeat(u32 unk0, u32 unk1, u32 unk2);
148
149 /* 0x00 */ u32 mButton;
150 /* 0x04 */ u32 mTrigger; // Pressed Buttons
151 /* 0x08 */ u32 mRelease; // Released Buttons
152 /* 0x0C */ u8 mAnalogA;
153 /* 0x0D */ u8 mAnalogB;
154 /* 0x0E */ u8 mAnalogL;
155 /* 0x0F */ u8 mAnalogR;
156 /* 0x10 */ f32 mAnalogLf;
157 /* 0x14 */ f32 mAnalogRf;
158 /* 0x18 */ u32 mRepeat;
159 /* 0x1C */ u32 field_0x1c;
160 /* 0x20 */ u32 field_0x20;
161 /* 0x24 */ u32 field_0x24;
162 /* 0x28 */ u32 field_0x28;
163 /* 0x2C */ u32 field_0x2c;
164 }; // Size: 0x30
165
167 C3ButtonReset() { mReset = false; }
168
172 static void* sCallbackArg;
175 static bool sResetOccurred;
177
178 /* 0x0 */ bool mReset;
179 }; // Size: 0x4
180
181 struct CStick {
184
185 CStick() { clear(); }
186 void clear();
187 void clear(JUTGamePad* pad);
189 u32 unk2);
190 u32 getButton(u32 unk);
191
192 /* 0x0 */ f32 mPosX;
193 /* 0x4 */ f32 mPosY;
194 /* 0x8 */ f32 mValue;
195 /* 0xC */ s16 mAngle;
196 /* 0xE */ s8 field_0xe;
197 /* 0xF */ s8 field_0xf;
198 }; // Size: 0x10
199
201
202 struct CRumble {
203 CRumble(JUTGamePad* pad) { clear(pad); }
204
205 static u32 sChannelMask[4];
206 static bool mStatus[4];
207 static u32 mEnabled;
208
209 enum ERumble {
210 VAL_0 = 0,
211 VAL_1 = 1,
212 VAL_2 = 2,
213 };
214
215 void clear();
216 void clear(JUTGamePad* pad);
217 static void startMotor(int channel);
218 static void stopMotor(int channel, bool stop);
219 void update(s16 unk0);
220 void triggerPatternedRumble(u32 unk0);
221 void startPatternedRumble(void* unk0, ERumble rumble, u32 unk1);
224 static void setEnabled(u32 pad_mask);
225
226 void stopMotorHard(int portNo) { stopMotor(portNo, true); }
227
228 static bool isEnabled(u32 mask) { return mEnabled & mask; }
229 static bool isEnabledPort(int port) { return isEnabled(sChannelMask[port]); }
230
231 /* 0x00 */ u32 field_0x0;
232 /* 0x04 */ u32 field_0x4;
233 /* 0x08 */ u8* field_0x8;
234 /* 0x0C */ u32 field_0xc;
235 /* 0x10 */ u8* field_0x10;
236 }; // Size: 0x14
237
241
242 /* 0x18 */ CButton mButton;
243 /* 0x48 */ CStick mMainStick;
244 /* 0x58 */ CStick mSubStick;
245 /* 0x68 */ CRumble mRumble;
246 /* 0x7C */ s16 mPortNum;
247 /* 0x7E */ s8 mErrorStatus;
252 /* 0x9C */ u8 field_0x9c[4];
253 /* 0xA0 */ OSTime mResetTime;
254 /* 0xA8 */ u8 field_0xa8;
255
257 static bool mListInitialized;
264 static u8 mPadAssign[4];
268};
269
276 void checkCallback(int port, u32 timer);
277
278 u32 getMaskPattern() const { return mMaskPattern; }
279 u32 getPattern() const { return mPattern; }
280
281 /* 0x00 */ u8 field_0x0[0x10];
282 /* 0x10 */ bool mValid;
283 /* 0x11 */ bool field_0x11;
284 /* 0x14 */ u32 mPattern;
285 /* 0x18 */ u32 mMaskPattern;
286 /* 0x1C */ u32 field_0x1c;
287 /* 0x20 */ bool field_0x20[4];
288 /* 0x28 */ OSTime mTimer[4];
289 /* 0x48 */ bool field_0x48[4];
291 /* 0x50 */ s32 field_0x50;
292};
293
294#endif /* JUTGAMEPAD_H */
void(* callbackFn)(int, void *)
Definition JUTGamePad.h:8
bool sResetSwitchPushing__Q210JUTGamePad13C3ButtonReset
s64 OSTime
Definition OSTime.h:10
void PADSetAnalogMode(u32 mode)
Definition Pad.c:736
T cLib_calcTimer(T *value)
Definition c_lib.h:74
Definition JKRDisposer.h:12
Definition JSUList.h:96
static void stick(b_gos_class *i_this)
Definition d_a_b_gos.cpp:136
Definition JUTGamePad.h:10
@ R
Definition JUTGamePad.h:17
@ X
Definition JUTGamePad.h:21
@ L
Definition JUTGamePad.h:18
@ B
Definition JUTGamePad.h:20
@ DPAD_DOWN
Definition JUTGamePad.h:14
@ START
Definition JUTGamePad.h:23
@ A
Definition JUTGamePad.h:19
@ DPAD_RIGHT
Definition JUTGamePad.h:13
@ Y
Definition JUTGamePad.h:22
@ DPAD_LEFT
Definition JUTGamePad.h:12
@ Z
Definition JUTGamePad.h:16
@ DPAD_UP
Definition JUTGamePad.h:15
Definition JUTGamePad.h:274
u32 getPattern() const
Definition JUTGamePad.h:279
static JSUList< JUTGamePadLongPress > sPatternList
Definition JUTGamePad.h:275
bool field_0x48[4]
Definition JUTGamePad.h:289
bool field_0x11
Definition JUTGamePad.h:283
bool field_0x20[4]
Definition JUTGamePad.h:287
void checkCallback(int port, u32 timer)
Definition JUTGamePad.cpp:775
OSTime mTimer[4]
Definition JUTGamePad.h:288
u8 field_0x0[0x10]
Definition JUTGamePad.h:281
u32 field_0x1c
Definition JUTGamePad.h:286
bool mValid
Definition JUTGamePad.h:282
u32 mPattern
Definition JUTGamePad.h:284
u32 mMaskPattern
Definition JUTGamePad.h:285
void(* mCallback)(s32, JUTGamePadLongPress *, s32)
Definition JUTGamePad.h:290
u32 getMaskPattern() const
Definition JUTGamePad.h:278
s32 field_0x50
Definition JUTGamePad.h:291
Definition JUTGamePad.h:33
virtual void unk1(PADStatus *pad)
Definition JUTGamePad.h:35
virtual void unk0()
Definition JUTGamePad.h:34
bool mActive
Definition JUTGamePad.h:38
virtual void unk2()
Definition JUTGamePad.h:36
Definition JUTGamePad.h:166
static u32 sResetMaskPattern
Definition JUTGamePad.h:170
static s32 sResetOccurredPort
Definition JUTGamePad.h:174
static OSTime sThreshold
Definition JUTGamePad.h:173
static callbackFn sCallback
Definition JUTGamePad.h:171
static bool sResetSwitchPushing
Definition JUTGamePad.h:176
C3ButtonReset()
Definition JUTGamePad.h:167
static bool sResetOccurred
Definition JUTGamePad.h:175
static u32 sResetPattern
Definition JUTGamePad.h:169
static void * sCallbackArg
Definition JUTGamePad.h:172
bool mReset
Definition JUTGamePad.h:178
u32 field_0x28
Definition JUTGamePad.h:162
u32 field_0x1c
Definition JUTGamePad.h:159
u32 mButton
Definition JUTGamePad.h:149
u8 mAnalogL
Definition JUTGamePad.h:154
void clear()
Definition JUTGamePad.cpp:443
u8 mAnalogB
Definition JUTGamePad.h:153
f32 mAnalogRf
Definition JUTGamePad.h:157
u32 mTrigger
Definition JUTGamePad.h:150
u8 mAnalogR
Definition JUTGamePad.h:155
f32 mAnalogLf
Definition JUTGamePad.h:156
u32 mRepeat
Definition JUTGamePad.h:158
u32 field_0x20
Definition JUTGamePad.h:160
u32 field_0x24
Definition JUTGamePad.h:161
u8 mAnalogA
Definition JUTGamePad.h:152
u32 field_0x2c
Definition JUTGamePad.h:163
u32 mRelease
Definition JUTGamePad.h:151
void setRepeat(u32 unk0, u32 unk1, u32 unk2)
Definition JUTGamePad.cpp:755
CButton()
Definition JUTGamePad.h:144
Definition JUTGamePad.h:202
u8 * field_0x8
Definition JUTGamePad.h:233
CRumble(JUTGamePad *pad)
Definition JUTGamePad.h:203
static bool isEnabled(u32 mask)
Definition JUTGamePad.h:228
static u32 mEnabled
Definition JUTGamePad.h:207
u32 field_0x4
Definition JUTGamePad.h:232
static void stopMotor(int channel, bool stop)
Definition JUTGamePad.cpp:623
static bool isEnabledPort(int port)
Definition JUTGamePad.h:229
static void setEnabled(u32 pad_mask)
Definition JUTGamePad.cpp:738
u32 field_0xc
Definition JUTGamePad.h:234
static void startMotor(int channel)
Definition JUTGamePad.cpp:615
u8 * field_0x10
Definition JUTGamePad.h:235
void stopPatternedRumble(s16 pad_port)
Definition JUTGamePad.cpp:713
void startPatternedRumble(void *unk0, ERumble rumble, u32 unk1)
Definition JUTGamePad.cpp:694
u32 field_0x0
Definition JUTGamePad.h:231
void stopMotorHard(int portNo)
Definition JUTGamePad.h:226
ERumble
Definition JUTGamePad.h:209
@ VAL_1
Definition JUTGamePad.h:211
@ VAL_2
Definition JUTGamePad.h:212
@ VAL_0
Definition JUTGamePad.h:210
static u32 sChannelMask[4]
Definition JUTGamePad.h:107
void stopPatternedRumbleAtThePeriod()
Definition JUTGamePad.cpp:720
static bool mStatus[4]
Definition JUTGamePad.h:206
void triggerPatternedRumble(u32 unk0)
Definition JUTGamePad.cpp:685
void clear()
Definition JUTGamePad.cpp:595
Definition JUTGamePad.h:181
f32 mValue
Definition JUTGamePad.h:194
void clear()
Definition JUTGamePad.cpp:516
void clear(JUTGamePad *pad)
static f32 sPressPoint
Definition JUTGamePad.h:182
f32 mPosY
Definition JUTGamePad.h:193
s8 field_0xe
Definition JUTGamePad.h:196
s8 field_0xf
Definition JUTGamePad.h:197
static f32 sReleasePoint
Definition JUTGamePad.h:183
f32 mPosX
Definition JUTGamePad.h:192
CStick()
Definition JUTGamePad.h:185
s16 mAngle
Definition JUTGamePad.h:195
Definition JUTGamePad.h:45
void stopMotor()
Definition JUTGamePad.h:138
static bool recalibrate(u32 pad_mask)
Definition JUTGamePad.cpp:764
void stopPatternedRumble()
Definition JUTGamePad.h:72
static bool mListInitialized
Definition JUTGamePad.h:257
static u32 sRumbleSupported
Definition JUTGamePad.h:267
static u8 mPadAssign[4]
Definition JUTGamePad.h:264
f32 getMainStickX() const
Definition JUTGamePad.h:94
static EStickMode sStickMode
Definition JUTGamePad.h:262
f32 getMainStickValue() const
Definition JUTGamePad.h:98
u8 field_0xa8
Definition JUTGamePad.h:254
u8 getAnalogR() const
Definition JUTGamePad.h:116
s16 getMainStickAngle() const
Definition JUTGamePad.h:100
EPadPort
Definition JUTGamePad.h:54
@ Port_2
Definition JUTGamePad.h:57
@ Port_4
Definition JUTGamePad.h:59
@ Port_1
Definition JUTGamePad.h:56
@ Port_3
Definition JUTGamePad.h:58
@ Port_Unknown
Definition JUTGamePad.h:55
JSULink< JUTGamePad > mLink
Definition JUTGamePad.h:248
static CButton mPadButton[4]
Definition JUTGamePad.h:259
void assign()
Definition JUTGamePad.cpp:291
JUTGamePadRecordBase * getPadReplay() const
Definition JUTGamePad.h:122
EWhichStick
Definition JUTGamePad.h:50
@ WS_MAIN_STICK
Definition JUTGamePad.h:51
@ WS_SUB_STICK
Definition JUTGamePad.h:52
u8 getAnalogB() const
Definition JUTGamePad.h:112
virtual ~JUTGamePad()
Definition JUTGamePad.cpp:143
static void setResetCallback(callbackFn callback, void *param_0)
Definition JUTGamePad.h:85
static u32 read()
Definition JUTGamePad.cpp:210
CStick mSubStick
Definition JUTGamePad.h:244
static void setAnalogMode(u32 mode)
Definition JUTGamePad.h:78
void checkResetCallback(OSTime unk)
Definition JUTGamePad.cpp:332
f32 getSubStickValue() const
Definition JUTGamePad.h:106
s16 mPortNum
Definition JUTGamePad.h:246
static u32 sSuppressPadReset
Definition JUTGamePad.h:265
CRumble mRumble
Definition JUTGamePad.h:245
JUTGamePadRecordBase * mPadRecord
Definition JUTGamePad.h:249
void stopMotorWaveHard()
Definition JUTGamePad.h:200
void clear()
Definition JUTGamePad.cpp:175
void startMotorWave(void *param_2, CRumble::ERumble rumble, u32 param_4)
Definition JUTGamePad.h:238
s16 getPortNum() const
Definition JUTGamePad.h:120
static void checkResetSwitch()
Definition JUTGamePad.cpp:418
static PADStatus mPadStatus[4]
Definition JUTGamePad.h:258
static u32 sClampMode
Definition JUTGamePad.h:263
f32 getMainStickY() const
Definition JUTGamePad.h:96
JUTGamePadRecordBase * getPadRecord() const
Definition JUTGamePad.h:124
u8 field_0x9c[4]
Definition JUTGamePad.h:252
static s8 getPortStatus(u32 port)
Definition JUTGamePad.h:141
C3ButtonReset mButtonReset
Definition JUTGamePad.h:251
CButton mButton
Definition JUTGamePad.h:242
u32 testTrigger(u32 button) const
Definition JUTGamePad.h:126
void stopMotorHard()
Definition JUTGamePad.h:139
static JSUList< JUTGamePad > mPadList
Definition JUTGamePad.h:256
void update()
Definition JUTGamePad.cpp:366
static JUTGamePad * getGamePad(int pad_index)
Definition JUTGamePad.cpp:725
EStickMode
Definition JUTGamePad.h:47
@ STICK_MODE_1
Definition JUTGamePad.h:48
f32 getSubStickX() const
Definition JUTGamePad.h:102
static s32 init()
Definition JUTGamePad.cpp:168
s8 getErrorStatus() const
Definition JUTGamePad.h:118
bool isPushing3ButtonReset() const
Definition JUTGamePad.h:128
CStick mMainStick
Definition JUTGamePad.h:243
static void clearResetOccurred()
Definition JUTGamePad.h:83
u32 getButton() const
Definition JUTGamePad.h:90
static CStick mPadMStick[4]
Definition JUTGamePad.h:260
static CStick mPadSStick[4]
Definition JUTGamePad.h:261
s16 getSubStickAngle() const
Definition JUTGamePad.h:108
void stopMotorWave()
Definition JUTGamePad.h:137
f32 getSubStickY() const
Definition JUTGamePad.h:104
u32 getTrigger() const
Definition JUTGamePad.h:92
s8 mErrorStatus
Definition JUTGamePad.h:247
JUTGamePadRecordBase * mPadReplay
Definition JUTGamePad.h:250
static void clearForReset()
Definition JUTGamePad.cpp:437
static s32 sAnalogMode
Definition JUTGamePad.h:266
u8 getAnalogL() const
Definition JUTGamePad.h:114
u8 getAnalogA() const
Definition JUTGamePad.h:110
OSTime mResetTime
Definition JUTGamePad.h:253
void initList()
Definition JUTGamePad.cpp:153
Definition pad.h:47
s8 error
Definition pad.h:57
signed char s8
Definition types.h:4
unsigned long u32
Definition types.h:10
float f32
Definition types.h:22
signed short s16
Definition types.h:5
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8