SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
WPadPointer.cpp
1#include "Game/System/WPadPointer.hpp"
2#include "Game/Util.hpp"
3#include <JSystem/JUtility/JUTVideo.hpp>
4
5#ifdef NON_MATCHING
6// arrays are generating a constructor for some reason
7WPadPointer::WPadPointer(const WPad* pPad) {
8 mPad = pPad;
9 mPosPlayRadius = 0.029999999f;
10 mPosSensitivity = 0.5f;
11 mHoriPlayRadius = 0.0;
12 mHoriSensitivity = 1.0f;
13 mDistPlayRadius = 0.0f;
14 mDistSensitivity = 1.0f;
15 _2C = 0;
16 _30 = 0.0f;
17 _34 = 0;
18 _38 = 0;
19 _3C = 0;
20 mEnablePastCount = 0;
21 _44 = 0;
22 _45 = 0;
23 mPointingPosArray = new TVec2f[0x78];
24 mHorizonArray = new TVec2f[0x78];
25 _C = 120;
26 reset();
27}
28#endif
29
30void WPadPointer::reset() {
31 for (s32 i = 0; i < _C; i++) {
32 TVec2f* cur = &mPointingPosArray[i];
33 cur->x = 0.0f;
34 cur->y = 0.0f;
35 cur = &mHorizonArray[i];
36 cur->x = 0.0f;
37 cur->y = 0.0f;
38 }
39
40 _34 = 0;
41 _30 = 0.0f;
42 _38 = 0;
43 mEnablePastCount = 0;
44 _2C = 0;
45 _44 = 0;
46 _45 = 0;
47 KPADSetPosParam(mPad->mChannel, mPosPlayRadius, mPosSensitivity);
48 KPADSetHoriParam(mPad->mChannel, mHoriPlayRadius, mHoriSensitivity);
49 KPADSetDistParam(mPad->mChannel, mDistPlayRadius, mDistSensitivity);
50}
51
52
53void WPadPointer::setSensorBarLevel(f32 lvl) {
54 KPADSetSensorHeight(mPad->mChannel, lvl);
55}
56
57/*void WPadPointer::update() {
58 KPADStatus* status = mPad->getKPadStatus(0);
59
60 if (status != nullptr) {
61 _45 = 0;
62 _30 = status->dist;
63 _34 = status->dpd_valid_fg;
64 s32 validCount = mPad->getValidStatusCount();
65 mEnablePastCount = 0;
66
67 if (_C > validCount) {
68 validCount = _C;
69 }
70
71 bool isAnyDPDValid = false;
72
73 while (validCount - 1 >= 0) {
74 KPADStatus* curStatus = mPad->getKPadStatus(validCount);
75
76 if (curStatus->dpd_valid_fg) {
77 isAnyDPDValid = true;
78 }
79
80 if (curStatus->dpd_valid_fg >= 2) {
81 if (!_44 && _38 >= 5 || !_44 && _3C <= 10) {
82 mPointingPosArray[mEnablePastCount] = (TVec2f)curStatus->pos;
83 }
84 }
85 }
86 }
87}*/
88
89
90void WPadPointer::getPointingPos(TVec2f* pOut) const {
91 if (_44 != 0) {
92 pOut->set(mPointingPosArray[mEnablePastCount - 1]);
93 }
94 else {
95 pOut->x = 0.0f;
96 pOut->y = 0.0f;
97 }
98}
99
100void WPadPointer::getHorizonVec(TVec2f* pOut) const {
101 if (_44 != 0) {
102 pOut->set(mHorizonArray[mEnablePastCount - 1]);
103 }
104 else {
105 pOut->x = 0.0f;
106 pOut->y = 0.0f;
107 }
108}
109
110void WPadPointer::getPastPointingPos(TVec2f* pOut, s32 idx) const {
111 pOut->set(mPointingPosArray[mEnablePastCount - 1 - idx]);
112}
113
114u32 WPadPointer::getEnablePastCount() const {
115 return mEnablePastCount;
116}
117
118void WPadPointer::getPointingPosBasedOnScreen(TVec2f* pOut) const {
119 pOut->x = (0.5f + (0.5f * mPointingPosArray->x)) * (int)MR::getScreenWidth();
120 pOut->y = (0.5f + (0.5f * mPointingPosArray->y)) * (int)(JUTVideo::sManager->mRenderModeObj->efbHeight);
121}
Definition WPad.hpp:15