mirror of
https://github.com/zeldaret/ss
synced 2026-08-12 11:52:22 -04:00
Pad stuff
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "egg/audio/eggAudioRmtSpeakerMgr.h"
|
||||
|
||||
#include "nw4r/snd/snd_SoundSystem.h"
|
||||
|
||||
#include "rvl/OS.h" // IWYU pragma: export
|
||||
|
||||
namespace EGG {
|
||||
@@ -21,7 +22,7 @@ void AudioRmtSpeakerMgr::setupCallback(s32 arg1, s32 arg2) {
|
||||
}
|
||||
sAudioRmtSpeakerWpadVolume = WPADGetSpeakerVolume();
|
||||
} else {
|
||||
fn_804B6D80(arg1, sTasks[mTaskFinishCount].mpCallback);
|
||||
setup(arg1, sTasks[mTaskFinishCount].mpCallback);
|
||||
}
|
||||
sTasks[mTaskFinishCount].field_0x01 = true;
|
||||
}
|
||||
@@ -32,12 +33,12 @@ void AudioRmtSpeakerMgr::shutdownCallback(s32 arg1, s32 arg2) {
|
||||
(sTasks[mTaskFinishCount].mpCallback)(arg1, arg2);
|
||||
}
|
||||
} else {
|
||||
fn_804B6DE0(arg1, sTasks[mTaskFinishCount].mpCallback);
|
||||
shutdown(arg1, sTasks[mTaskFinishCount].mpCallback);
|
||||
}
|
||||
sTasks[mTaskFinishCount].field_0x01 = true;
|
||||
}
|
||||
|
||||
void AudioRmtSpeakerMgr::fn_804B6AF0(s32 i, WPADCallback *pCallback, bool enable) {
|
||||
void AudioRmtSpeakerMgr::add_task(s32 i, WPADCallback *pCallback, bool enable) {
|
||||
BOOL intr = OSDisableInterrupts();
|
||||
|
||||
u32 index = mTaskRequestCount;
|
||||
@@ -52,14 +53,14 @@ void AudioRmtSpeakerMgr::fn_804B6AF0(s32 i, WPADCallback *pCallback, bool enable
|
||||
OSRestoreInterrupts(intr);
|
||||
}
|
||||
|
||||
void AudioRmtSpeakerMgr::fn_804B6B80(s32 i, WPADCallback *pCallback) {
|
||||
void AudioRmtSpeakerMgr::doSetup(s32 i, WPADCallback *pCallback) {
|
||||
if (!nw4r::snd::SoundSystem::GetRemoteSpeaker(i).Setup(pCallback)) {
|
||||
fn_804B6AF0(i, pCallback, true);
|
||||
add_task(i, pCallback, true);
|
||||
sTasks[mTaskRequestCount].field_0x01 = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRmtSpeakerMgr::fn_804B6C00(s32 i, WPADCallback *pCallback) {
|
||||
void AudioRmtSpeakerMgr::doShutdown(s32 i, WPADCallback *pCallback) {
|
||||
nw4r::snd::SoundSystem::GetRemoteSpeaker(i).Shutdown(pCallback);
|
||||
}
|
||||
|
||||
@@ -67,9 +68,9 @@ void AudioRmtSpeakerMgr::calc() {
|
||||
if (!sTask) {
|
||||
if (mTaskRequestCount != mTaskFinishCount) {
|
||||
if (sTasks[mTaskFinishCount].field_0x00) {
|
||||
fn_804B6B80(sTasks[mTaskFinishCount].mChannel, setupCallback);
|
||||
doSetup(sTasks[mTaskFinishCount].mChannel, setupCallback);
|
||||
} else {
|
||||
fn_804B6C00(sTasks[mTaskFinishCount].mChannel, shutdownCallback);
|
||||
doShutdown(sTasks[mTaskFinishCount].mChannel, shutdownCallback);
|
||||
}
|
||||
sTask = true;
|
||||
}
|
||||
@@ -86,7 +87,7 @@ void AudioRmtSpeakerMgr::setupCallbackDirect(s32 arg1, s32 arg2) {
|
||||
if (arg2 == 0) {
|
||||
sAudioRmtSpeakerWpadVolume = WPADGetSpeakerVolume();
|
||||
} else {
|
||||
fn_804B6B80(arg1, setupCallbackDirect);
|
||||
doSetup(arg1, setupCallbackDirect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,17 +98,17 @@ void AudioRmtSpeakerMgr::shutdownCallbackDirect(s32 arg1, s32 arg2) {
|
||||
if (arg2 == 0) {
|
||||
return;
|
||||
}
|
||||
fn_804B6C00(arg1, shutdownCallbackDirect);
|
||||
doShutdown(arg1, shutdownCallbackDirect);
|
||||
}
|
||||
|
||||
void AudioRmtSpeakerMgr::fn_804B6D80(s32 i, WPADCallback *pCallback) {
|
||||
void AudioRmtSpeakerMgr::setup(s32 i, WPADCallback *pCallback) {
|
||||
WPADDeviceType ty;
|
||||
if (!sAudioRmtSpeakerConnectCanncelSw && WPADProbe(i, &ty) != WPAD_ERR_NO_CONTROLLER) {
|
||||
fn_804B6AF0(i, pCallback, true);
|
||||
add_task(i, pCallback, true);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRmtSpeakerMgr::fn_804B6DE0(s32 i, WPADCallback *pCallback) {
|
||||
void AudioRmtSpeakerMgr::shutdown(s32 i, WPADCallback *pCallback) {
|
||||
WPADDeviceType ty;
|
||||
if (!sAudioRmtSpeakerConnectCanncelSw) {
|
||||
if (WPADProbe(i, &ty) == WPAD_ERR_NO_CONTROLLER) {
|
||||
@@ -115,7 +116,7 @@ void AudioRmtSpeakerMgr::fn_804B6DE0(s32 i, WPADCallback *pCallback) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
fn_804B6AF0(i, pCallback, false);
|
||||
add_task(i, pCallback, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ void AudioRmtSpeakerMgr::connectAllByForce() {
|
||||
sAudioRmtSpeakerConnectCanncelSw = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (WPADProbe(i, &ty) != WPAD_ERR_NO_CONTROLLER) {
|
||||
fn_804B6B80(i, setupCallbackDirect);
|
||||
doSetup(i, setupCallbackDirect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +135,7 @@ void AudioRmtSpeakerMgr::disconnectAllByForce() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
WPADProbe(i, &ty); // ignoring result here
|
||||
if (nw4r::snd::SoundSystem::GetRemoteSpeaker(i).IsAvailable()) {
|
||||
fn_804B6C00(i, shutdownCallbackDirect);
|
||||
doShutdown(i, shutdownCallbackDirect);
|
||||
}
|
||||
}
|
||||
sAudioRmtSpeakerConnectCanncelSw = true;
|
||||
|
||||
+106
-102
@@ -5,16 +5,20 @@
|
||||
#include "egg/core/eggExpHeap.h"
|
||||
#include "egg/core/eggSystem.h"
|
||||
#include "egg/math/eggMath.h"
|
||||
#include "rvl/VI.h" // IWYU pragma: export
|
||||
#include "egg/math/eggVector.h"
|
||||
#include "rvl/WPAD/WPAD.h"
|
||||
#include "string.h"
|
||||
|
||||
EGG::NullController null_controller;
|
||||
#include "rvl/VI.h" // IWYU pragma: export
|
||||
|
||||
namespace EGG {
|
||||
|
||||
NullController null_controller;
|
||||
|
||||
CoreControllerMgr *CoreControllerMgr::sInstance;
|
||||
CoreControllerMgr::T__Disposer *CoreControllerMgr::T__Disposer::sStaticDisposer;
|
||||
ControllerFactory CoreControllerMgr::sCoreControllerFactory;
|
||||
ConnectCallback CoreControllerMgr::sConnectCallback;
|
||||
CoreControllerFactory CoreControllerMgr::sCoreControllerFactory;
|
||||
CoreControllerConnectCallback CoreControllerMgr::sConnectCallback;
|
||||
// This controls whether EggController registers an allocator within the WPAD driver
|
||||
bool CoreControllerMgr::sUseBuiltinWpadAllocator;
|
||||
s32 CoreControllerMgr::sWPADWorkSize = 0x32000;
|
||||
@@ -23,7 +27,7 @@ void CoreStatus::init() {
|
||||
memset(this, 0, sizeof(CoreStatus));
|
||||
}
|
||||
|
||||
u32 CoreStatus::getFSStickButton() const {
|
||||
u32 CoreStatus::getFSStickButton() {
|
||||
f32 stick = getFSStickX();
|
||||
u32 result = 0;
|
||||
|
||||
@@ -51,47 +55,47 @@ u32 CoreStatus::getFSStickButton() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
CoreController::CoreController() : mDpdPos(), mAccel(), mAccelFlags(), mFlag(0) {
|
||||
CoreController::CoreController() : mDpdPosPrev(), mStableAccel(), mFlag(0) {
|
||||
mRumbleMgr = nullptr;
|
||||
mButtonHeld = 0;
|
||||
mButtonTriggered = 0;
|
||||
mButtonReleased = 0;
|
||||
mFSStickHold = 0;
|
||||
mFSStickTrig = 0;
|
||||
mFSStickRelease = 0;
|
||||
sceneReset();
|
||||
mFlag.makeAllZero();
|
||||
}
|
||||
|
||||
void CoreController::sceneReset() {
|
||||
mAccel.set(0.0, 0.0, 0.0);
|
||||
mDpdPos.x = 0.0f;
|
||||
mDpdPos.y = 0.0f;
|
||||
mAccelPrev.set(0.0, 0.0, 0.0);
|
||||
mDpdPosPrev.x = 0.0f;
|
||||
mDpdPosPrev.y = 0.0f;
|
||||
mIdleTime = 0;
|
||||
mPostureMatrixPrev.makeIdentity();
|
||||
mPostureMatrix.makeIdentity();
|
||||
mMaxAccelFrameTime = 10;
|
||||
mMaxAccelDiff = 0.13;
|
||||
mPrevAccel.set(0.0, 0.0, 0.0);
|
||||
mAccelFlags.makeAllZero();
|
||||
mAccelFrameTime[2] = 0;
|
||||
mAccelFrameTime[1] = 0;
|
||||
mAccelFrameTime[0] = 0;
|
||||
mMotorPattern = 0;
|
||||
mMotorFrameDuration = 0;
|
||||
mEnableMotor = false;
|
||||
mMotorPatternLength = 0x20;
|
||||
mMotorPatternPos = 0x1f;
|
||||
mStableFrame = 10;
|
||||
mStableMag = 0.13;
|
||||
mStableAccel.set(0.0, 0.0, 0.0);
|
||||
mStableFlags = 0;
|
||||
mStableTimer[2] = 0;
|
||||
mStableTimer[1] = 0;
|
||||
mStableTimer[0] = 0;
|
||||
mSimpleRumblePattern = 0;
|
||||
mSimpleRumbleFrame = 0;
|
||||
mEnableSimpleRumble = false;
|
||||
mSimpleRumbleSize = 0x20;
|
||||
mSimpleRumbleIndex = 0x1f;
|
||||
stopRumbleMgr();
|
||||
}
|
||||
|
||||
Vector2f CoreController::getDpdRawPos() {
|
||||
return Vector2f(mCoreStatus[0].mDpdRawX, mCoreStatus[0].mDpdRawY);
|
||||
return Vector2f(mCoreStatus[0].pos.x, mCoreStatus[0].pos.y);
|
||||
}
|
||||
|
||||
f32 CoreController::getDpdDistance() {
|
||||
return mCoreStatus[0].mDpdDistance;
|
||||
return mCoreStatus[0].dist;
|
||||
}
|
||||
|
||||
s32 CoreController::getDpdValidFlag() {
|
||||
return mCoreStatus[0].getDpdValidFlag();
|
||||
return mCoreStatus[0].getDPDValidFlag();
|
||||
}
|
||||
|
||||
void CoreController::startMotor() {
|
||||
@@ -169,15 +173,15 @@ void CoreController::calc_posture_matrix(Matrix34f &posture, bool checkStable) {
|
||||
|
||||
void CoreController::beginFrame(PADStatus *padStatus) {
|
||||
s32 kpad_result;
|
||||
mReadStatusIdx = KPADReadEx(mChannelID, mCoreStatus, 0x10, &kpad_result);
|
||||
if (mReadStatusIdx == 0 && kpad_result == -1 /* Rvl usually uses negative nums for results */) {
|
||||
mReadStatusIdx = 1;
|
||||
mKPADReadLength = KPADReadEx(mChannelID, mCoreStatus, 0x10, &kpad_result);
|
||||
if (mKPADReadLength == 0 && kpad_result == WPAD_ERR_NO_CONTROLLER) {
|
||||
mKPADReadLength = 1;
|
||||
}
|
||||
|
||||
WPADDeviceType dev_type;
|
||||
switch (WPADProbe(mChannelID, &dev_type)) {
|
||||
case WPAD_ERR_OK: {
|
||||
if ((u32)dev_type == WPAD_DEV_NONE) {
|
||||
if ((u32)dev_type == WPAD_DEV_NOT_FOUND) {
|
||||
mFlag.resetBit(0);
|
||||
} else {
|
||||
mFlag.setBit(0);
|
||||
@@ -188,59 +192,59 @@ void CoreController::beginFrame(PADStatus *padStatus) {
|
||||
} break;
|
||||
}
|
||||
|
||||
if (mReadStatusIdx > 0) {
|
||||
if (mKPADReadLength > 0) {
|
||||
CoreStatus *pStatus = mCoreStatus;
|
||||
u32 prev_held = mButtonHeld;
|
||||
u32 prev_held = mFSStickHold;
|
||||
if (pStatus->isFreestyle()) {
|
||||
mButtonHeld = pStatus->getFSStickButton();
|
||||
mFSStickHold = pStatus->getFSStickButton();
|
||||
} else {
|
||||
mButtonHeld = 0;
|
||||
mFSStickHold = 0;
|
||||
}
|
||||
|
||||
mButtonTriggered = mButtonHeld & ~prev_held;
|
||||
mButtonReleased = prev_held & ~mButtonHeld;
|
||||
pStatus->mHold &= ~0xF0000;
|
||||
pStatus->mTrig &= ~0xF0000;
|
||||
pStatus->mRelease &= ~0xF0000;
|
||||
pStatus->mHold |= (mButtonHeld & 0xF0000);
|
||||
pStatus->mTrig |= (mButtonTriggered & 0xF0000);
|
||||
pStatus->mRelease |= (mButtonReleased & 0xF0000);
|
||||
mFSStickTrig = mFSStickHold & ~prev_held;
|
||||
mFSStickRelease = prev_held & ~mFSStickHold;
|
||||
pStatus->hold &= ~0xF0000;
|
||||
pStatus->trig &= ~0xF0000;
|
||||
pStatus->release &= ~0xF0000;
|
||||
pStatus->hold |= (mFSStickHold & 0xF0000);
|
||||
pStatus->trig |= (mFSStickTrig & 0xF0000);
|
||||
pStatus->release |= (mFSStickRelease & 0xF0000);
|
||||
}
|
||||
|
||||
mPostureMatrixPrev.copyFrom(mPostureMatrix);
|
||||
mAccelFlags.makeAllZero();
|
||||
mStableFlags = 0;
|
||||
Vector3f acc = mCoreStatus->getAccel();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (acc(i) - mAccel(i) < mMaxAccelDiff) {
|
||||
if (mMaxAccelFrameTime <= ++mAccelFrameTime[i]) {
|
||||
mAccelFrameTime[i] = mMaxAccelFrameTime;
|
||||
mAccelFlags.set(1 << i);
|
||||
mPrevAccel(i) = acc(i);
|
||||
if (acc(i) - mAccelPrev(i) < mStableMag) {
|
||||
if (mStableFrame <= ++mStableTimer[i]) {
|
||||
mStableTimer[i] = mStableFrame;
|
||||
mStableFlags |= (1 << i);
|
||||
mStableAccel(i) = acc(i);
|
||||
}
|
||||
} else {
|
||||
mAccelFlags.value &= ~(1 << i); // ?
|
||||
mAccelFrameTime[i] = 0;
|
||||
mStableFlags &= ~(1 << i);
|
||||
mStableTimer[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
calc_posture_matrix(mPostureMatrix, true);
|
||||
|
||||
if (mEnableMotor) {
|
||||
if (mMotorPattern & (1 << mMotorPatternPos)) {
|
||||
if (mEnableSimpleRumble) {
|
||||
if (mSimpleRumblePattern & (1 << mSimpleRumbleIndex)) {
|
||||
startMotor();
|
||||
} else {
|
||||
stopMotor();
|
||||
}
|
||||
if (mMotorPatternPos == 0) {
|
||||
mMotorPatternPos = mMotorPatternLength - 1;
|
||||
if (mSimpleRumbleIndex == 0) {
|
||||
mSimpleRumbleIndex = mSimpleRumbleSize - 1;
|
||||
} else {
|
||||
mMotorPatternPos = mMotorPatternPos - 1;
|
||||
mSimpleRumbleIndex = mSimpleRumbleIndex - 1;
|
||||
}
|
||||
|
||||
if (--mMotorFrameDuration == 0) {
|
||||
if (--mSimpleRumbleFrame == 0) {
|
||||
stopMotor();
|
||||
mEnableMotor = false;
|
||||
mEnableSimpleRumble = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,13 +258,13 @@ void CoreController::beginFrame(PADStatus *padStatus) {
|
||||
}
|
||||
|
||||
if (increment) {
|
||||
Vector3f diff = (mAccel - mCoreStatus->getAccel());
|
||||
Vector3f diff = (mAccelPrev - mCoreStatus->getAccel());
|
||||
if (diff.squaredLength() > 0.01f) {
|
||||
increment = false;
|
||||
}
|
||||
}
|
||||
if (increment) {
|
||||
Vector2f diff = (mDpdPos - getDpdRawPos());
|
||||
Vector2f diff = (mDpdPosPrev - getDpdRawPos());
|
||||
if (diff.squaredLength() > 0.05f) {
|
||||
increment = false;
|
||||
}
|
||||
@@ -278,8 +282,8 @@ void CoreController::beginFrame(PADStatus *padStatus) {
|
||||
}
|
||||
|
||||
void CoreController::endFrame() {
|
||||
mAccel = getAccel();
|
||||
mDpdPos = getDpdRawPos();
|
||||
mAccelPrev = *reinterpret_cast<Vector3f *>(&mCoreStatus[0].acc);
|
||||
mDpdPosPrev = getDpdRawPos();
|
||||
}
|
||||
|
||||
/* 0x80499AC0 */
|
||||
@@ -343,7 +347,7 @@ int free(void *ptr) {
|
||||
|
||||
/* 0x80499CD0 */
|
||||
void CoreControllerMgr::connectCallback(s32 a1, s32 a2) {
|
||||
int args[] = {a1, a2};
|
||||
CoreControllerConnectArg args = {a1, a2};
|
||||
if (sConnectCallback != nullptr) {
|
||||
(sConnectCallback)(args);
|
||||
}
|
||||
@@ -393,7 +397,7 @@ void CoreControllerMgr::beginFrame() {
|
||||
|
||||
/* 0x8049A1E0 */
|
||||
void CoreControllerMgr::endFrame() {
|
||||
for (int i = 0; i < mControllers.mSize; i++) {
|
||||
for (int i = 0; i < mControllers.getSize(); i++) {
|
||||
mControllers(i)->endFrame();
|
||||
|
||||
WPADDeviceType dev_type;
|
||||
@@ -403,7 +407,7 @@ void CoreControllerMgr::endFrame() {
|
||||
if (result == WPAD_ERR_OK) {
|
||||
res_dev_type = dev_type;
|
||||
} else if (result == WPAD_ERR_NO_CONTROLLER) {
|
||||
res_dev_type = WPAD_DEV_NONE;
|
||||
res_dev_type = WPAD_DEV_NOT_FOUND;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@@ -425,77 +429,77 @@ void CoreControllerMgr::endFrame() {
|
||||
|
||||
/* 0x8049A3B0 */
|
||||
void ControllerRumbleUnit::init() {
|
||||
mPattern = nullptr;
|
||||
mPatternPos = nullptr;
|
||||
mTimer = 0;
|
||||
mIntensity = 0.0f;
|
||||
mRampUp = 0.0f;
|
||||
mFlag.makeAllZero();
|
||||
mRumblePattern = nullptr;
|
||||
mRumblePatternPtr = nullptr;
|
||||
mRumbleFrame = 0;
|
||||
mRumbleValue = 0.0f;
|
||||
mRumblePower = 0.0f;
|
||||
mFlags.makeAllZero();
|
||||
}
|
||||
|
||||
/* 0x8049A3E0 */
|
||||
void ControllerRumbleUnit::startPattern(const char *pattern, int duration) {
|
||||
mPattern = pattern;
|
||||
mPatternPos = pattern;
|
||||
mRumblePattern = pattern;
|
||||
mRumblePatternPtr = pattern;
|
||||
|
||||
mFlag.value &= 0xef;
|
||||
mFlag.value &= 0xdf;
|
||||
mFlags.value &= 0xef;
|
||||
mFlags.value &= 0xdf;
|
||||
|
||||
if (duration < 0) {
|
||||
mFlag.set(0x10);
|
||||
mFlags.set(0x10);
|
||||
} else if (duration > 0) {
|
||||
mFlag.set(0x30);
|
||||
mFlags.set(0x30);
|
||||
}
|
||||
|
||||
mTimer = duration;
|
||||
mRumbleFrame = duration;
|
||||
|
||||
mFlag.setBit(0);
|
||||
mFlag.resetBit(1);
|
||||
mFlag.setBit(3);
|
||||
mFlags.setBit(0);
|
||||
mFlags.resetBit(1);
|
||||
mFlags.setBit(3);
|
||||
}
|
||||
|
||||
/* 0x8049A440 */
|
||||
f32 ControllerRumbleUnit::calc() {
|
||||
f32 result = 0.0f;
|
||||
if (mFlag.onBit(3)) {
|
||||
if (mFlag.onBit(0)) {
|
||||
char x = *++mPatternPos;
|
||||
if (mFlags.onBit(3)) {
|
||||
if (mFlags.onBit(0)) {
|
||||
char x = *++mRumblePatternPtr;
|
||||
if (x == '\0') {
|
||||
if (mFlag.onBit(4)) {
|
||||
mPatternPos = mPattern;
|
||||
if (mFlags.onBit(4)) {
|
||||
mRumblePatternPtr = mRumblePattern;
|
||||
} else {
|
||||
mFlag.resetBit(3);
|
||||
mFlags.resetBit(3);
|
||||
}
|
||||
} else if (x == '*') {
|
||||
result = 1.0f;
|
||||
}
|
||||
|
||||
if (mFlag.offBit(5)) {
|
||||
if (mFlags.offBit(5)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (--mTimer > 0) {
|
||||
if (--mRumbleFrame > 0) {
|
||||
return result;
|
||||
}
|
||||
mFlag.resetBit(3);
|
||||
mFlags.resetBit(3);
|
||||
return result;
|
||||
} else {
|
||||
f32 intensity = mIntensity + mRampUp;
|
||||
mIntensity = intensity;
|
||||
f32 intensity = mRumbleValue + mRumblePower;
|
||||
mRumbleValue = intensity;
|
||||
if (intensity >= 1.0f) {
|
||||
result = 1.0f;
|
||||
mIntensity = 0.0f;
|
||||
mRumbleValue = 0.0f;
|
||||
}
|
||||
|
||||
if (mFlag.onBit(2)) {
|
||||
if (mFlags.onBit(2)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (--mTimer > 0) {
|
||||
if (--mRumbleFrame > 0) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
mFlag.resetBit(3);
|
||||
mFlags.resetBit(3);
|
||||
return result;
|
||||
} else {
|
||||
return -1.0f;
|
||||
@@ -506,14 +510,14 @@ f32 ControllerRumbleUnit::calc() {
|
||||
ControllerRumbleMgr::ControllerRumbleMgr() {
|
||||
mController = nullptr;
|
||||
List_Init(&mActiveUnitList, offsetof(ControllerRumbleUnit, mNode));
|
||||
List_Init(&mInactiveUnitList, offsetof(ControllerRumbleUnit, mNode));
|
||||
List_Init(&mStoppedUnitList, offsetof(ControllerRumbleUnit, mNode));
|
||||
}
|
||||
|
||||
/* 0x8049A590 */
|
||||
void ControllerRumbleMgr::createUnit(u8 numUnits, CoreController *ctrl) {
|
||||
for (u8 created = 0; created < numUnits; created++) {
|
||||
ControllerRumbleUnit *unit = new ControllerRumbleUnit();
|
||||
List_Append(&mInactiveUnitList, unit);
|
||||
List_Append(&mStoppedUnitList, unit);
|
||||
}
|
||||
mController = ctrl;
|
||||
}
|
||||
@@ -524,7 +528,7 @@ void ControllerRumbleMgr::stop() {
|
||||
while (List_GetSize(&mActiveUnitList) != 0) {
|
||||
ControllerRumbleUnit *unit = static_cast<ControllerRumbleUnit *>(List_GetNext(&mActiveUnitList, nullptr));
|
||||
List_Remove(&mActiveUnitList, unit);
|
||||
List_Append(&mInactiveUnitList, unit);
|
||||
List_Append(&mStoppedUnitList, unit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +544,7 @@ void ControllerRumbleMgr::calc() {
|
||||
void *nextObject = List_GetNext(&mActiveUnitList, object);
|
||||
if (x < 0.0f) {
|
||||
List_Remove(&mActiveUnitList, object);
|
||||
List_Append(&mInactiveUnitList, object);
|
||||
List_Append(&mStoppedUnitList, object);
|
||||
} else {
|
||||
acc += x;
|
||||
}
|
||||
@@ -565,9 +569,9 @@ void ControllerRumbleMgr::startPattern(const char *pattern, int duration, bool b
|
||||
|
||||
/* 0x8049A7F0 */
|
||||
ControllerRumbleUnit *ControllerRumbleMgr::getUnitFromList(bool bGrabActive) {
|
||||
void *first = List_GetFirst(&this->mInactiveUnitList);
|
||||
void *first = List_GetFirst(&this->mStoppedUnitList);
|
||||
if (first) {
|
||||
List_Remove(&mInactiveUnitList, first);
|
||||
List_Remove(&mStoppedUnitList, first);
|
||||
List_Append(&mActiveUnitList, first);
|
||||
} else if (bGrabActive && (first = List_GetFirst(&mActiveUnitList), first != nullptr)) {
|
||||
List_Remove(&mActiveUnitList, first);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "nw4r/db/db_directPrint.h"
|
||||
#include "nw4r/db/db_exception.h"
|
||||
#include "nw4r/db/db_mapFile.h"
|
||||
|
||||
#include "rvl/KPAD.h" // IWYU pragma: export
|
||||
#include "rvl/OS.h" // IWYU pragma: export
|
||||
|
||||
@@ -52,9 +53,9 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data)
|
||||
while (((u16 *)data)[u4] != 0) {
|
||||
KPADRead(0, &status, 1);
|
||||
ExceptionWaitTime(50);
|
||||
if (status.mTrig) {
|
||||
if (status.trig) {
|
||||
// Reset the sequence on wrong button press, advance on right button press
|
||||
u4 = status.mTrig & (((u16 *)data)[u4]) ? u4 + 1 : 0;
|
||||
u4 = status.trig & (((u16 *)data)[u4]) ? u4 + 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,7 +80,7 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data)
|
||||
while (true) {
|
||||
KPADRead(0, &status, 1);
|
||||
ExceptionWaitTime(100);
|
||||
if (status.mTrig & (/* HOME */ 0x8000)) {
|
||||
if (status.trig & cCORE_BUTTON_HOME) {
|
||||
sUserCallbackMode = !sUserCallbackMode;
|
||||
}
|
||||
if (sUserCallbackMode && sUserCallbackFunc != nullptr) {
|
||||
@@ -91,22 +92,22 @@ bool Exception::ExceptionCallback_(nw4r::db::ConsoleHandle console, void *data)
|
||||
;
|
||||
prevY = newY;
|
||||
|
||||
if (status.mHold & (/* DPAD_DOWN */ 0x4)) {
|
||||
if (status.hold & cCORE_BUTTON_DOWN) {
|
||||
newY += 1;
|
||||
if (newY > end) {
|
||||
newY = end;
|
||||
}
|
||||
} else if (status.mHold & (/* DPAD_UP */ 0x8)) {
|
||||
} else if (status.hold & cCORE_BUTTON_UP) {
|
||||
newY -= 1;
|
||||
if (newY < start) {
|
||||
newY = start;
|
||||
}
|
||||
} else if (status.mHold & (/* DPAD_RIGHT */ 0x2)) {
|
||||
} else if (status.hold & cCORE_BUTTON_RIGHT) {
|
||||
newX -= 5;
|
||||
if (newX < -150) {
|
||||
newX = -150;
|
||||
}
|
||||
} else if (status.mHold & (/* DPAD_LEFT */ 0x1)) {
|
||||
} else if (status.hold & cCORE_BUTTON_LEFT) {
|
||||
newX += 5;
|
||||
if (newX > 10) {
|
||||
newX = 10;
|
||||
|
||||
Reference in New Issue
Block a user