This commit is contained in:
Pheenoh 2021-01-04 10:37:18 -05:00
commit 90eb3341bc
No known key found for this signature in database
GPG Key ID: 4312662758CE7D5A
6 changed files with 65 additions and 72 deletions

View File

@ -36,19 +36,19 @@ public:
u32 update(PADStatus const*, u32 unk); u32 update(PADStatus const*, u32 unk);
void setRepeat(u32 unk0, u32 unk1, u32 unk2); void setRepeat(u32 unk0, u32 unk1, u32 unk2);
u32 button_flags; u32 mButtonFlags;
u32 field_0x4; u32 mPressedButtonFlags;
u32 field_0x8; u32 mReleasedButtonFlags;
u8 analog_a; u8 mAnalogARaw;
u8 analog_b; u8 mAnalogBRaw;
u8 trigger_left; u8 mTriggerLeftRaw;
u8 trigger_right; u8 mTriggerRightRaw;
f32 analog_left; f32 mTriggerLeft;
f32 analog_right; f32 mTriggerRight;
u32 field_0x18; u32 field_0x18; // padding?
u32 field_0x1c; u32 field_0x1c;
u32 field_0x20; u32 field_0x20;
u32 field_0x24; u32 field_0x24;
@ -63,10 +63,10 @@ public:
u32 update(s8 unk0, s8 unk1, EStickMode mode, EWhichStick stick, u32 unk2); u32 update(s8 unk0, s8 unk1, EStickMode mode, EWhichStick stick, u32 unk2);
u32 getButton(u32 unk); u32 getButton(u32 unk);
float stick_x; float mPosX;
float stick_y; float mPosY;
float length_from_neutral; float mValue;
u16 angle; s16 mAngle;
s8 field_0xe; s8 field_0xe;
s8 field_0xf; s8 field_0xf;
}; };

View File

@ -72,8 +72,8 @@ struct g_HIO_struct {
struct mDoCPd_c { struct mDoCPd_c {
void create(); void create();
void read(); void read();
static void convert(interface_of_controller_pad* controllerInteface, JUTGamePad* gamePad); static void convert(interface_of_controller_pad* pInterface, JUTGamePad* pPad);
static void LRlockCheck(interface_of_controller_pad* controllerInterface); static void LRlockCheck(interface_of_controller_pad* pInterface);
static void recalibrate(void); static void recalibrate(void);
JUTGamePad* gamePad; JUTGamePad* gamePad;

View File

@ -107,14 +107,14 @@ void JUTGamePad::clearForReset() {
} }
void JUTGamePad::CButton::clear() { void JUTGamePad::CButton::clear() {
this->button_flags = 0; this->mButtonFlags = 0;
this->field_0x4 = 0; this->mPressedButtonFlags = 0;
this->field_0x8 = 0; this->mReleasedButtonFlags = 0;
this->field_0x18 = 0; this->field_0x18 = 0;
this->analog_a = 0; this->mAnalogARaw = 0;
this->analog_b = 0; this->mAnalogBRaw = 0;
this->trigger_left = 0; this->mTriggerLeftRaw = 0;
this->trigger_right = 0; this->mTriggerRightRaw = 0;
this->field_0x1c = 0; this->field_0x1c = 0;
this->field_0x20 = 0; this->field_0x20 = 0;
this->field_0x24 = 0; this->field_0x24 = 0;
@ -129,10 +129,10 @@ asm u32 JUTGamePad::CButton::update(PADStatus const*, u32 unk) {
void JUTGamePad::CStick::clear() { void JUTGamePad::CStick::clear() {
float zero = lbl_80456028; // 0.0f float zero = lbl_80456028; // 0.0f
this->stick_x = zero; this->mPosX = zero;
this->stick_y = zero; this->mPosY = zero;
this->length_from_neutral = zero; this->mValue = zero;
this->angle = 0; this->mAngle = 0;
} }
asm u32 JUTGamePad::CStick::update(s8 unk0, s8 unk1, EStickMode mode, EWhichStick stick, u32 unk2) { asm u32 JUTGamePad::CStick::update(s8 unk0, s8 unk1, EStickMode mode, EWhichStick stick, u32 unk2) {

View File

@ -6,8 +6,10 @@
#include "m_Do/m_Do_main/m_Do_main.h" #include "m_Do/m_Do_main/m_Do_main.h"
#include "pad/pad.h" #include "pad/pad.h"
// TODO: m_cpadInfo uses a bad type in a number of the NONMATCHING functions,
// and references need to be updated to reflect its correct type.
#ifdef NONMATCHING #ifdef NONMATCHING
// TODO: change the cpadinfo stuff to use the new type of m_cpadInfo
void mDoCPd_c::create() { void mDoCPd_c::create() {
JUTGamePad* JUTGamePad_ptr; JUTGamePad* JUTGamePad_ptr;
cpadInfo* m_cpadInfo_addr; cpadInfo* m_cpadInfo_addr;
@ -86,50 +88,41 @@ asm void mDoCPd_c::read() {
#endif #endif
#ifdef NONMATCHING #ifdef NONMATCHING
void mDoCPd_c::convert(interface_of_controller_pad* controllerInterface, JUTGamePad* gamePad) { // off on load order, regalloc, const placement (int-to-float conversion magic).
controllerInterface->button_flags = gamePad->buttons.button_flags; void mDoCPd_c::convert(interface_of_controller_pad* pInterface, JUTGamePad* pPad) {
controllerInterface->field_0x34 = gamePad->buttons.field_0x4; pInterface->mButtonFlags = pPad->buttons.mButtonFlags;
controllerInterface->stick_x = gamePad->control_stick.stick_x; pInterface->mPressedButtonFlags = pPad->buttons.mPressedButtonFlags;
controllerInterface->stick_y = gamePad->control_stick.stick_y; pInterface->mMainStickPosX = pPad->control_stick.mPosX;
controllerInterface->length_from_neutral = gamePad->control_stick.length_from_neutral; pInterface->mMainStickPosY = pPad->control_stick.mPosY;
controllerInterface->controlStick_angle = gamePad->control_stick.angle; pInterface->mMainStickValue = pPad->control_stick.mValue;
controllerInterface->cStick_x = gamePad->c_stick.stick_x; pInterface->mMainStickAngle = pPad->control_stick.mAngle;
controllerInterface->cStick_y = gamePad->c_stick.stick_y; pInterface->mCStickPosX = pPad->c_stick.mPosX;
controllerInterface->cStick_length_from_neutral = gamePad->c_stick.length_from_neutral; pInterface->mCStickPosY = pPad->c_stick.mPosY;
controllerInterface->cStick_angle = gamePad->c_stick.angle; pInterface->mCStickValue = pPad->c_stick.mValue;
controllerInterface->analog_a = pInterface->mCStickAngle = pPad->c_stick.mAngle;
(gamePad->buttons.analog_a - lbl_80451A30) *
lbl_80451A20; //@3709 * pInterface->mAnalogA = lbl_80451A20 * pPad->buttons.mAnalogARaw;
//(float)((double)CONCAT44(0x43300000,(uint)(gamePad->buttons).analog_a) if (pInterface->mAnalogA > lbl_80451A24 /* 1.0 */) {
//- @3713); pInterface->mAnalogA = lbl_80451A24;
if (controllerInterface->analog_a > lbl_80451A24) {
controllerInterface->analog_a = lbl_80451A24;
} }
controllerInterface->analog_b =
(gamePad->buttons.analog_b - lbl_80451A30) * pInterface->mAnalogB = lbl_80451A20 * pPad->buttons.mAnalogBRaw;
lbl_80451A20; //@3709 * if (pInterface->mAnalogB > lbl_80451A24 /* 1.0 */) {
//(float)((double)CONCAT44(0x43300000,(uint)(gamePad->buttons).analog_b) pInterface->mAnalogB = lbl_80451A24;
//- @3713);
if (controllerInterface->analog_b > lbl_80451A24) {
controllerInterface->analog_b = lbl_80451A24;
} }
controllerInterface->trigger_left =
(gamePad->buttons.trigger_left - lbl_80451A30) * // pInterface->mTriggerLeft = pPad->buttons.mTriggerLeftRaw * (1/140.0f);
lbl_80451A28; //@3711 * pInterface->mTriggerLeft = lbl_80451A28 * pPad->buttons.mTriggerLeftRaw;
//(float)((double)CONCAT44(0x43300000,(uint)(gamePad->buttons).trigger_left) if (pInterface->mTriggerLeft > lbl_80451A24 /* 1.0 */) {
//- @3713); pInterface->mTriggerLeft = lbl_80451A24;
if (controllerInterface->trigger_left > lbl_80451A24) {
controllerInterface->trigger_left = lbl_80451A24;
} }
controllerInterface->trigger_right =
(gamePad->buttons.trigger_right - lbl_80451A30) * pInterface->mTriggerRight = lbl_80451A28 * pPad->buttons.mTriggerRightRaw;
lbl_80451A28; //@3711 * if (pInterface->mTriggerRight > lbl_80451A24 /* 1.0 */) {
//(float)((double)CONCAT44(0x43300000,(uint)(gamePad->buttons).trigger_right) pInterface->mTriggerRight = lbl_80451A24;
//- @3713);
if (controllerInterface->trigger_right > lbl_80451A24) {
controllerInterface->trigger_right = lbl_80451A24;
} }
controllerInterface->error_value = gamePad->error_value;
pInterface->mGamepadErrorFlags = pPad->error_value;
} }
#else #else
asm void mDoCPd_c::convert(interface_of_controller_pad* controllerInteface, JUTGamePad* gamePad) { asm void mDoCPd_c::convert(interface_of_controller_pad* controllerInteface, JUTGamePad* gamePad) {

View File

@ -150,14 +150,14 @@ void debug(void) {
CheckHeap(2); CheckHeap(2);
} }
if (((m_gamePad[2]->buttons.button_flags & ~0x10) == 0x20) && if (((m_gamePad[2]->buttons.mButtonFlags & ~0x10) == 0x20) &&
(m_gamePad[2]->buttons.field_0x4 & 0x10)) { (m_gamePad[2]->buttons.mPressedButtonFlags & 0x10)) {
lbl_80450B18 ^= 0x1; lbl_80450B18 ^= 0x1;
} }
if (lbl_80450B18) { if (lbl_80450B18) {
if (((m_gamePad[2]->buttons.button_flags & ~0x10) == 0x40) && if (((m_gamePad[2]->buttons.mButtonFlags & ~0x10) == 0x40) &&
(m_gamePad[2]->buttons.field_0x4 & 0x10)) { (m_gamePad[2]->buttons.mPressedButtonFlags & 0x10)) {
lbl_80450588[0] < 0x5 ? lbl_80450588[0]++ : lbl_80450588[0] = 0x1; lbl_80450588[0] < 0x5 ? lbl_80450588[0]++ : lbl_80450588[0] = 0x1;
} }

0
tools/clang-format-all.sh Normal file → Executable file
View File