MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / iPadUpdate

Function iPadUpdate

src/SB/Core/gc/iPad.cpp:61–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61S32 iPadUpdate(_tagxPad* pad, U32* on)
62{
63 U16 buttons;
64 U32 temp_on;
65
66 if (pad->port == 0)
67 {
68 PADRead(sPadData);
69 PADClamp(sPadData);
70 }
71
72 PADStatus* padData = (PADStatus*)&sPadData;
73 switch (padData[pad->port].err)
74 {
75 case PAD_ERR_NO_CONTROLLER:
76 xTRCPad(pad->port, TRC_PadMissing);
77 PADReset(0x80000000 >> pad->port);
78 goto defaultError;
79
80 case PAD_ERR_NOT_READY:
81 case PAD_ERR_TRANSFER:
82 return 0;
83
84 default:
85 defaultError:
86 return 0;
87
88 case PAD_ERR_NONE:
89 temp_on = iPadConvFromGCN(padData[pad->port].button, 1, 0x80);
90 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 2, 0x20);
91 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 4, 0x40);
92 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 8, 0x10);
93 buttons = sPadData[pad->port].button;
94
95 if (buttons & 0x10)
96 {
97 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 0x20, 0x2000);
98 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 0x40, 0x200);
99 if (sPadData[pad->port].triggerLeft >= 0x18)
100 {
101 temp_on |= 0x200;
102 }
103 if (sPadData[pad->port].triggerRight >= 0x18)
104 {
105 temp_on |= 0x2000;
106 }
107 temp_on |= 0x100000;
108 }
109 else
110 {
111 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 0x20, 0x1000);
112 temp_on |= iPadConvFromGCN(sPadData[pad->port].button, 0x40, 0x100);
113 if (sPadData[pad->port].triggerLeft >= 0x18)
114 {
115 temp_on |= 0x100;
116 }
117 if (sPadData[pad->port].triggerRight >= 0x18)
118 {

Callers 1

xPadUpdateFunction · 0.50

Calls 6

PADReadFunction · 0.85
PADClampFunction · 0.85
PADResetFunction · 0.85
iPadConvFromGCNFunction · 0.85
iPadConvStickFunction · 0.85
xTRCPadFunction · 0.50

Tested by

no test coverage detected