mirror of
https://github.com/zeldaret/tp
synced 2026-08-17 21:33:42 -04:00
npcT / JUTGamePad work
This commit is contained in:
@@ -29,26 +29,25 @@ enum {
|
||||
extern bool struct_80451500;
|
||||
extern bool struct_80451501; // sResetOccured
|
||||
|
||||
struct JUTGamePadRecordBase {
|
||||
virtual void unk0() {}
|
||||
virtual void unk1(PADStatus* pad) {}
|
||||
virtual void unk2() {}
|
||||
|
||||
/* 0x4 */ bool mActive;
|
||||
};
|
||||
|
||||
struct JUTGamePad : public JKRDisposer {
|
||||
public:
|
||||
// TODO: fix types
|
||||
// static JSUList<JUTGamePad> mPadList;
|
||||
static u8 mPadList[12];
|
||||
static PADStatus mPadStatus[4];
|
||||
static u8 mPadButton[192];
|
||||
static u8 mPadMStick[64];
|
||||
static u8 mPadSStick[64];
|
||||
static u32 sStickMode;
|
||||
static u32 sClampMode;
|
||||
static u8 mPadAssign[4];
|
||||
static u8 sSuppressPadReset[4];
|
||||
static s32 sAnalogMode;
|
||||
static u32 sRumbleSupported;
|
||||
|
||||
enum EStickMode {};
|
||||
enum EWhichStick {};
|
||||
enum EStickMode {
|
||||
STICK_MODE_1 = 1,
|
||||
};
|
||||
enum EWhichStick {
|
||||
WS_MAIN_STICK,
|
||||
WS_SUB_STICK,
|
||||
};
|
||||
enum EPadPort {
|
||||
Port_Unknown = -1, // used by JUTException
|
||||
Port_Unknown = -1,
|
||||
Port_1,
|
||||
Port_2,
|
||||
Port_3,
|
||||
@@ -61,15 +60,15 @@ public:
|
||||
void initList();
|
||||
static s32 init();
|
||||
void clear();
|
||||
static void read();
|
||||
static u32 read();
|
||||
void assign();
|
||||
void checkResetCallback(OSTime unk); // todo: weird arg
|
||||
void checkResetCallback(OSTime unk);
|
||||
void update();
|
||||
void stopPatternedRumble() { mRumble.stopPatternedRumble(mPortNum); }
|
||||
static void checkResetSwitch();
|
||||
static void clearForReset();
|
||||
static JUTGamePad* getGamePad(int pad_index);
|
||||
static bool recalibrate(/*PADMask*/ u32 pad_mask);
|
||||
static bool recalibrate(u32 pad_mask);
|
||||
|
||||
static void setAnalogMode(u32 mode) {
|
||||
sAnalogMode = mode;
|
||||
@@ -112,6 +111,12 @@ public:
|
||||
u8 getAnalogR() const { return mButton.mAnalogR; }
|
||||
|
||||
s8 getErrorStatus() const { return mErrorStatus; }
|
||||
|
||||
s16 getPortNum() const { return mPortNum; }
|
||||
|
||||
JUTGamePadRecordBase* getPadReplay() const { return mPadReplay; }
|
||||
|
||||
JUTGamePadRecordBase* getPadRecord() const { return mPadRecord; }
|
||||
|
||||
u32 testTrigger(u32 button) const { return mButton.mTrigger & button; }
|
||||
|
||||
@@ -124,12 +129,14 @@ public:
|
||||
return isPushingReset;
|
||||
}
|
||||
|
||||
void stopMotorHard() { mRumble.stopMotorHard(mPortNum); }
|
||||
|
||||
static s8 getPortStatus(u32 port) { return mPadStatus[port].error; }
|
||||
|
||||
struct CButton {
|
||||
CButton(); // inline
|
||||
CButton() { clear(); }
|
||||
void clear();
|
||||
u32 update(PADStatus const*, u32 unk);
|
||||
void update(PADStatus const*, u32 unk);
|
||||
void setRepeat(u32 unk0, u32 unk1, u32 unk2);
|
||||
|
||||
/* 0x00 */ u32 mButton;
|
||||
@@ -150,7 +157,8 @@ public:
|
||||
}; // Size: 0x30
|
||||
|
||||
struct C3ButtonReset {
|
||||
// TODO: fix types
|
||||
C3ButtonReset() { mReset = false; }
|
||||
|
||||
static u32 sResetPattern;
|
||||
static u32 sResetMaskPattern;
|
||||
static callbackFn sCallback;
|
||||
@@ -165,7 +173,7 @@ public:
|
||||
static f32 sPressPoint;
|
||||
static f32 sReleasePoint;
|
||||
|
||||
CStick(); // inline
|
||||
CStick() { clear(); }
|
||||
void clear();
|
||||
void clear(JUTGamePad* pad);
|
||||
u32 update(s8 unk0, s8 unk1, JUTGamePad::EStickMode mode, JUTGamePad::EWhichStick stick,
|
||||
@@ -183,6 +191,8 @@ public:
|
||||
void stopMotorWaveHard() { mRumble.stopPatternedRumble(mPortNum); }
|
||||
|
||||
struct CRumble {
|
||||
CRumble(JUTGamePad* pad) { clear(pad); }
|
||||
|
||||
static PADMask sChannelMask[4];
|
||||
static bool mStatus[4];
|
||||
static PADMask mEnabled;
|
||||
@@ -204,6 +214,11 @@ public:
|
||||
void stopPatternedRumbleAtThePeriod();
|
||||
static void setEnabled(u32 pad_mask);
|
||||
|
||||
void stopMotorHard(int portNo) { stopMotor(portNo, true); }
|
||||
|
||||
static bool isEnabled(u32 mask) { return mEnabled & mask; }
|
||||
static bool isEnabledPort(int port) { return isEnabled(sChannelMask[port]); }
|
||||
|
||||
/* 0x00 */ u32 field_0x0;
|
||||
/* 0x04 */ u32 field_0x4;
|
||||
/* 0x08 */ u8* field_0x8;
|
||||
@@ -218,32 +233,45 @@ public:
|
||||
/* 0x7C */ s16 mPortNum;
|
||||
/* 0x7E */ s8 mErrorStatus;
|
||||
/* 0x80 */ JSULink<JUTGamePad> mLink;
|
||||
/* 0x90 */ u32 mPadRecord;
|
||||
/* 0x94 */ u32 mPadReplay;
|
||||
/* 0x90 */ JUTGamePadRecordBase* mPadRecord;
|
||||
/* 0x94 */ JUTGamePadRecordBase* mPadReplay;
|
||||
/* 0x98 */ C3ButtonReset mButtonReset;
|
||||
/* 0x9C */ u8 field_0x9c[4];
|
||||
/* 0xA0 */ OSTime mResetTime;
|
||||
/* 0xA8 */ u8 field_0xa8;
|
||||
|
||||
friend class CRumble;
|
||||
static JSUList<JUTGamePad> mPadList;
|
||||
static bool mListInitialized;
|
||||
static PADStatus mPadStatus[4];
|
||||
static CButton mPadButton[4];
|
||||
static CStick mPadMStick[4];
|
||||
static CStick mPadSStick[4];
|
||||
static EStickMode sStickMode;
|
||||
static u32 sClampMode;
|
||||
static u8 mPadAssign[4];
|
||||
static u32 sSuppressPadReset;
|
||||
static s32 sAnalogMode;
|
||||
static u32 sRumbleSupported;
|
||||
};
|
||||
|
||||
struct JUTGamePadLongPress {
|
||||
// TODO: fix type
|
||||
// static JSUList<JUTGamePadLongPress> sPatternList;
|
||||
static u8 sPatternList[12];
|
||||
void checkCallback(int unk0, u32 unk2);
|
||||
static JSUList<JUTGamePadLongPress> sPatternList;
|
||||
void checkCallback(int port, u32 timer);
|
||||
|
||||
u8 unk0[17];
|
||||
bool field_0x11; // bool?
|
||||
u8 unk1[10];
|
||||
u32 field_0x1c;
|
||||
u8 unk2[28];
|
||||
u8 field_0x3c;
|
||||
u8 unk3[11];
|
||||
bool field_0x48[4]; // bool[4]?
|
||||
void (*callback)(s32, JUTGamePadLongPress*, s32);
|
||||
s32 field_0x50;
|
||||
u32 getMaskPattern() const { return mMaskPattern; }
|
||||
u32 getPattern() const { return mPattern; }
|
||||
|
||||
/* 0x00 */ u8 field_0x0[0x10];
|
||||
/* 0x10 */ bool mValid;
|
||||
/* 0x11 */ bool field_0x11;
|
||||
/* 0x14 */ u32 mPattern;
|
||||
/* 0x18 */ u32 mMaskPattern;
|
||||
/* 0x1C */ u32 field_0x1c;
|
||||
/* 0x20 */ bool field_0x20[4];
|
||||
/* 0x28 */ OSTime mTimer[4];
|
||||
/* 0x48 */ bool field_0x48[4];
|
||||
/* 0x4C */ void (*mCallback)(s32, JUTGamePadLongPress*, s32);
|
||||
/* 0x50 */ s32 field_0x50;
|
||||
};
|
||||
|
||||
#endif /* JUTGAMEPAD_H */
|
||||
|
||||
Reference in New Issue
Block a user