1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +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 #endif
#if OOT_DEBUG #if OOT_DEBUG
#define LOG(exp, value, format, file, line) \ #define LOG(exp, value, format, file, line) \
do { \ do { \
LogUtils_LogThreadId(file, line); \ LogUtils_LogThreadId(file, line); \
osSyncPrintf(exp " = " format "\n", value); \ osSyncPrintf(exp " = " format "\n", value); \
} while (0) } while (0)
#else #else
#define LOG(exp, value, format, file, line) (void)0 #define LOG(exp, value, format, file, line) (void)(value)
#endif #endif
#define LOG_STRING(string, file, line) LOG(#string, string, "%s", file, line) #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 osMotorStart(x) __osMotorAccess((x), MOTOR_START)
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) #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); s32 osMotorInit(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel);
#endif #endif

View File

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

View File

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

View File

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