1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-10 19:20:13 +00:00

Match retail padmgr.c and sys_rumble.c (#1693)

* Match retail padmgr.c

* Match retail sys_rumble.c

* Poke jenkins
This commit is contained in:
cadmic 2024-02-02 09:25:44 -08:00 committed by GitHub
parent 8f481b648d
commit 4e2d2885bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 17 deletions

View file

@ -117,14 +117,13 @@
#endif
#if OOT_DEBUG
#define LOG(exp, value, format, file, line) \
do { \
LogUtils_LogThreadId(file, line); \
osSyncPrintf(exp " = " format "\n", value); \
} while (0)
#else
#define LOG(exp, value, format, file, line) (void)0
#define LOG(exp, value, format, file, line) (void)(value)
#endif
#define LOG_STRING(string, file, line) LOG(#string, string, "%s", file, line)

View file

@ -9,7 +9,7 @@
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP)
s32 __osMotorAccess(OSPfs* pfs, u32 vibrate);
s32 __osMotorAccess(OSPfs* pfs, s32 vibrate);
s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel);
#endif

View file

@ -32,7 +32,7 @@
#include "terminal.h"
#define PADMGR_LOG(controllerNum, msg) \
if (1) { \
if (OOT_DEBUG) { \
PRINTF(VT_FGCOL(YELLOW)); \
/* padmgr: Controller %d: %s */ \
PRINTF("padmgr: %dコン: %s\n", (controllerNum) + 1, (msg)); \
@ -66,7 +66,11 @@ s32 gPadMgrLogSeverity = LOG_SEVERITY_CRITICAL;
* @see PadMgr_ReleaseSerialEventQueue
*/
OSMesgQueue* PadMgr_AcquireSerialEventQueue(PadMgr* padMgr) {
OSMesgQueue* serialEventQueue = NULL;
OSMesgQueue* serialEventQueue;
#if OOT_DEBUG
serialEventQueue = NULL;
#endif
if (gPadMgrLogSeverity >= LOG_SEVERITY_VERBOSE) {
// "serialMsgQ Waiting for lock"
@ -135,13 +139,10 @@ void PadMgr_UnlockPadData(PadMgr* padMgr) {
void PadMgr_UpdateRumble(PadMgr* padMgr) {
static u32 sRumbleErrorCount = 0; // original name: "errcnt"
static u32 sRumbleUpdateCounter;
s32 motorStart = MOTOR_START; // required for matching?
s32 triedRumbleComm;
OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
s32 ret;
s32 i;
triedRumbleComm = false;
s32 ret;
OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
s32 triedRumbleComm = false;
for (i = 0; i < MAXCONTROLLERS; i++) {
if (padMgr->ctrlrIsConnected[i]) {
@ -153,9 +154,7 @@ void PadMgr_UpdateRumble(PadMgr* padMgr) {
// "Rumble pack brrr"
PADMGR_LOG(i, "振動パック ぶるぶるぶるぶる");
// This should be the osMotorStart macro, however the temporary variable motorStart is
// currently required for matching
if (__osMotorAccess(&padMgr->rumblePfs[i], motorStart) != 0) {
if (osMotorStart(&padMgr->rumblePfs[i]) != 0) {
padMgr->pakType[i] = CONT_PAK_NONE;
// "A communication error has occurred with the vibration pack"
@ -186,7 +185,7 @@ void PadMgr_UpdateRumble(PadMgr* padMgr) {
}
} else {
if (padMgr->pakType[i] != CONT_PAK_NONE) {
if (padMgr->pakType[i] == CONT_PAK_RUMBLE) {
if (padMgr->pakType[i] == CONT_PAK_RUMBLE || !OOT_DEBUG) {
// "It seems that a vibration pack was pulled out"
PADMGR_LOG(i, "振動パックが抜かれたようです");
padMgr->pakType[i] = CONT_PAK_NONE;
@ -352,9 +351,9 @@ void PadMgr_UpdateInputs(PadMgr* padMgr) {
}
void PadMgr_HandleRetrace(PadMgr* padMgr) {
s32 i;
OSMesgQueue* serialEventQueue = PadMgr_AcquireSerialEventQueue(padMgr);
u32 mask;
s32 i;
// Begin reading controller data
osContStartReadData(serialEventQueue);
@ -368,6 +367,12 @@ void PadMgr_HandleRetrace(PadMgr* padMgr) {
osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK);
osContGetReadData(padMgr->pads);
#if !OOT_DEBUG
// Clear controllers 2 and 4
bzero(&padMgr->pads[1], sizeof(OSContPad));
bzero(&padMgr->pads[3], sizeof(OSContPad));
#endif
// If resetting, clear all controllers
if (padMgr->isResetting) {
bzero(padMgr->pads, sizeof(padMgr->pads));

View file

@ -147,5 +147,7 @@ void RumbleMgr_Init(RumbleMgr* rumbleMgr) {
}
void RumbleMgr_Destroy(RumbleMgr* rumbleMgr) {
#if OOT_DEBUG
bzero(rumbleMgr, sizeof(RumbleMgr));
#endif
}

View file

@ -4,7 +4,7 @@
OSPifRam __MotorDataBuf[MAXCONTROLLERS];
s32 __osMotorAccess(OSPfs* pfs, u32 vibrate) {
s32 __osMotorAccess(OSPfs* pfs, s32 vibrate) {
s32 i;
s32 ret;
u8* ptr = (u8*)&__MotorDataBuf[pfs->channel];