1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-16 12:54:40 +00:00

More documentation for padmgr.c (#1336)

* More documentation for padmgr.c

* Update comments

* Further suggested changes

* Suggested changes

* LOG_SEVERITY_INFO -> LOG_SEVERITY_CRITICAL

* Adjust PadMgr_RequestPadData comment

* Avoid array notation for args, adjust comment, rename the FaultMgr padInput field to inputs to better reflect it's an array
This commit is contained in:
Tharo 2022-09-03 01:52:13 +01:00 committed by GitHub
parent c0cf83a814
commit 6b77ddba5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 481 additions and 338 deletions

View file

@ -1,8 +1,15 @@
#ifndef PADMGR_H
#define PADMGR_H
#include "ultra64.h"
#include "irqmgr.h"
typedef enum {
CONT_PAK_NONE,
CONT_PAK_RUMBLE,
CONT_PAK_OTHER
} ControllerPakType;
typedef struct {
/* 0x00 */ OSContPad cur;
/* 0x06 */ OSContPad prev;
@ -11,9 +18,9 @@ typedef struct {
} Input; // size = 0x18
typedef struct PadMgr {
/* 0x0000 */ OSContStatus padStatus[4];
/* 0x0010 */ OSMesg serialLockMsgBuf[1];
/* 0x0014 */ OSMesg lockMsgBuf[1];
/* 0x0000 */ OSContStatus padStatus[MAXCONTROLLERS];
/* 0x0010 */ OSMesg serialMsg;
/* 0x0014 */ OSMesg lockMsg;
/* 0x0018 */ OSMesg interruptMsgBuf[4];
/* 0x0028 */ OSMesgQueue serialLockQueue;
/* 0x0040 */ OSMesgQueue lockQueue;
@ -21,20 +28,46 @@ typedef struct PadMgr {
/* 0x0070 */ IrqMgrClient irqClient;
/* 0x0078 */ IrqMgr* irqMgr;
/* 0x0080 */ OSThread thread;
/* 0x0230 */ Input inputs[4];
/* 0x0290 */ OSContPad pads[4];
/* 0x0230 */ Input inputs[MAXCONTROLLERS];
/* 0x0290 */ OSContPad pads[MAXCONTROLLERS];
/* 0x02A8 */ vu8 validCtrlrsMask;
/* 0x02A9 */ u8 nControllers;
/* 0x02AA */ u8 ctrlrIsConnected[4]; // "Key_switch" originally
/* 0x02AE */ u8 pakType[4]; // 1 if rumble pack, 2 if mempak?
/* 0x02B2 */ vu8 rumbleEnable[4];
/* 0x02B6 */ u8 rumbleCounter[4]; // not clear exact meaning
/* 0x02BC */ OSPfs pfs[4];
/* 0x045C */ vu8 rumbleOffFrames;
/* 0x045D */ vu8 rumbleOnFrames;
/* 0x045E */ u8 preNMIShutdown;
/* 0x0460 */ void (*retraceCallback)(struct PadMgr* padmgr, s32 unk464);
/* 0x0464 */ u32 retraceCallbackValue;
/* 0x02AA */ u8 ctrlrIsConnected[MAXCONTROLLERS];
/* 0x02AE */ u8 pakType[MAXCONTROLLERS];
/* 0x02B2 */ vu8 rumbleEnable[MAXCONTROLLERS];
/* 0x02B6 */ u8 rumbleTimer[MAXCONTROLLERS];
/* 0x02BC */ OSPfs rumblePfs[MAXCONTROLLERS];
/* 0x045C */ vu8 rumbleOffTimer; // amount of VI retraces to not rumble for, takes priority over rumbleOnTimer
/* 0x045D */ vu8 rumbleOnTimer; // amount of VI retraces to rumble for
/* 0x045E */ u8 isResetting;
/* 0x0460 */ void (*retraceCallback)(struct PadMgr* padMgr, s32 arg);
/* 0x0464 */ s32 retraceCallbackValue;
} PadMgr; // size = 0x468
extern PadMgr gPadMgr;
// Initialization
void PadMgr_Init(PadMgr* padMgr, OSMesgQueue* serialEventQueue, IrqMgr* irqMgr, OSId id, OSPri priority, void* stack);
// Fetching inputs
// This function cannot be prototyped here without AVOID_UB because it is called incorrectly in fault.c (see bug in
// `Fault_PadCallback`)
#ifdef AVOID_UB
void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 gameRequest);
#endif
// For internal use by Controller Pak systems
OSMesgQueue* PadMgr_AcquireSerialEventQueue(PadMgr* padMgr);
void PadMgr_ReleaseSerialEventQueue(PadMgr* padMgr, OSMesgQueue* serialEventQueue);
// Rumble
void PadMgr_RumbleStop(PadMgr* padMgr);
void PadMgr_RumbleReset(PadMgr* padMgr);
void PadMgr_RumbleSetSingle(PadMgr* padMgr, u32 port, u32 rumble);
void PadMgr_RumbleSet(PadMgr* padMgr, u8* enable);
#endif