Skip to content

Commit 66bc50e

Browse files
author
Niko
committed
GAMEPAD new enum for PLUGGED
1 parent 65be1fe commit 66bc50e

File tree

13 files changed

+70
-83
lines changed

13 files changed

+70
-83
lines changed

decompile/General/GAMEPAD/GAMEPAD_03_PollVsync.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ void DECOMP_GAMEPAD_PollVsync(struct GamepadSystem *gGamepads)
1414
maxPadsPerPort = 1;
1515

1616
// If there is a multitap present
17-
if ((gGamepads->slotBuffer[0].isControllerConnected == 0) && gGamepads->slotBuffer[0].controllerData == (PAD_ID_MULTITAP << 4))
17+
if (
18+
(gGamepads->slotBuffer[0].plugged == PLUGGED) &&
19+
(gGamepads->slotBuffer[0].controllerData == (PAD_ID_MULTITAP << 4))
20+
)
1821
{
1922
// 4 players, with multitap
2023
numPorts = 1;
@@ -43,19 +46,16 @@ void DECOMP_GAMEPAD_PollVsync(struct GamepadSystem *gGamepads)
4346
// to this gamepad port. 1 for no mtap, 4 for mtap
4447
for (char i = 0; i < maxPadsPerPort; i++)
4548
{
46-
// if this is not a multitap,
47-
// skip next block, and just start
48-
// if-body with ptrPadBuff
4949
if
5050
(
5151
(
52-
// multitap here, and controller connected
52+
// multitap here, and unplugged
5353
(gGamepads->slotBuffer[port].controllerData == (PAD_ID_MULTITAP << 4)) &&
54-
(gGamepads->slotBuffer[port].controllers[i].isControllerConnected != 0)
54+
(gGamepads->slotBuffer[port].controllers[i].plugged != PLUGGED)
5555
) ||
5656

57-
// controller connected
58-
(gGamepads->slotBuffer[port].isControllerConnected != 0)
57+
// controller unplugged
58+
(gGamepads->slotBuffer[port].plugged != PLUGGED)
5959
)
6060
{
6161
// no analog sticks found

decompile/General/GAMEPAD/GAMEPAD_04_GetNumConnected.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int DECOMP_GAMEPAD_GetNumConnected(struct GamepadSystem* gGamepads)
1818

1919
if(
2020
// multitap detected
21-
(gGamepads->slotBuffer[0].isControllerConnected == 0) &&
21+
(gGamepads->slotBuffer[0].plugged == PLUGGED) &&
2222
(gGamepads->slotBuffer[0].controllerData == (PAD_ID_MULTITAP << 4))
2323
)
2424
{
@@ -50,15 +50,15 @@ int DECOMP_GAMEPAD_GetNumConnected(struct GamepadSystem* gGamepads)
5050
for(int Port = 0; Port < numPortsPerSlot; Port++)
5151
{
5252
ptrControllerPacket = &gGamepads->slotBuffer[Slot];
53-
if(ptrControllerPacket->isControllerConnected == 0)
53+
if(ptrControllerPacket->plugged == PLUGGED)
5454
{
5555
// if multitap plugged in
5656
if(ptrControllerPacket->controllerData == (PAD_ID_MULTITAP << 4))
5757
{
5858
ptrControllerPacket = (struct MultitapPacket*)&ptrControllerPacket->controllers[Port];
5959
}
6060

61-
if(ptrControllerPacket->isControllerConnected == 0)
61+
if(ptrControllerPacket->plugged == PLUGGED)
6262
{
6363
bitwiseConnected |= 1 << (Slot*4 + Port);
6464

decompile/General/GAMEPAD/GAMEPAD_05_ProcessHold.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void DECOMP_GAMEPAD_ProcessHold(struct GamepadSystem *gGamepads)
3030
}
3131

3232
// must be zero to confirm connection
33-
else if (ptrControllerPacket->isControllerConnected == 0)
33+
else if (ptrControllerPacket->plugged == PLUGGED)
3434
{
3535
// endian flip
3636
uVar4 = (ptrControllerPacket->controllerInput1 << 8) | ptrControllerPacket->controllerInput2;

decompile/General/GAMEPAD/GAMEPAD_06_ProcessSticks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void DECOMP_GAMEPAD_ProcessSticks(struct GamepadSystem *gGS)
2929
// if pointer is valid
3030
if (packet == NULL) continue;
3131

32-
if (packet->isControllerConnected == 0)
32+
if (packet->plugged == PLUGGED)
3333
{
3434
bVar1 = packet->controllerData;
3535

decompile/General/MAIN/MainFrame_06_HaveAllPads.c

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,28 @@
22

33
int DECOMP_MainFrame_HaveAllPads(short numPlyrNextGame)
44
{
5-
short isGamepadsConnected = 1;
6-
7-
#ifdef USE_4PADTEST
8-
return 1;
9-
#endif
10-
5+
6+
#ifndef USE_4PADTEST
7+
118
// if game is not loading
129
if (sdata->Loading.stage == -1)
1310
{
14-
// if there are no players (cutscene)
15-
if (numPlyrNextGame == 0)
11+
struct GamepadBuffer* gb =
12+
&sdata->gGamepads->gamepad[0];
13+
14+
for (int i = 0; i < numPlyrNextGame; i++)
1615
{
17-
// return 0 means gamepad is missing
18-
isGamepadsConnected = 0;
16+
struct ControllerPacket* packet =
17+
gb->ptrControllerPacket;
18+
19+
if (packet == NULL) return 0;
20+
if (packet->plugged != PLUGGED) return 0;
21+
22+
gb++
1923
}
20-
21-
// if number of players is not zero
22-
else
23-
{
24-
u_int uVar4 = 1;
25-
for (int i = 0; i < numPlyrNextGame; i++)
26-
{
27-
bool bVar1 = uVar4 != 0;
28-
uVar4 = 0;
29-
if (
30-
// if there are no other gamepads unplugged (so far)
31-
(bVar1) &&
32-
33-
// if this gamepad is plugged in
34-
(sdata->gGamepads->gamepad[i].ptrControllerPacket != NULL)
35-
)
36-
{
37-
// Check if gamepad is compatible with game (not a gun or mouse)
38-
uVar4 = (u_int)(sdata->gGamepads->gamepad[i].ptrControllerPacket->isControllerConnected == 0);
39-
}
40-
41-
// save the result
42-
isGamepadsConnected = (short)uVar4;
43-
}
44-
}
45-
46-
// return 0 only if a gamepad is missing
47-
// that is currently needed in the game
48-
return isGamepadsConnected;
4924
}
25+
26+
#endif
27+
5028
return 1;
5129
}

decompile/General/MAIN/MainFrame_08_RenderFrame.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ void DrawUnpluggedMsg(struct GameTracker* gGT, struct GamepadSystem* gGamepads)
523523
struct ControllerPacket* ptrControllerPacket = gGamepads->gamepad[i].ptrControllerPacket;
524524

525525
if(ptrControllerPacket != 0)
526-
if(ptrControllerPacket->isControllerConnected == 0) continue;
526+
if(ptrControllerPacket->plugged == PLUGGED)
527+
continue;
527528

528529
// if controller is unplugged
529530

decompile/General/MAIN/MainFreeze_03_MenuPtrOptions.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ force_inline void IDENTIFYGAMEPADS_MainFreeze_MenuPtrOptions(struct RectMenu* me
2020
{
2121
struct ControllerPacket* ptrControllerPacket = sdata->gGamepads->gamepad[i].ptrControllerPacket;
2222

23+
// === THIS IS NOT CORRECT ===
24+
// Since discovering plugged enum, this is not right
25+
// Last checked Mar 27 2025, this is NOT on buildList,
26+
// need to double-check with ghidra, what should this do?
27+
2328
// if gamepad is not an "analog controller", as CTR uses to refer to jogcons and negcons
2429
if
2530
(
2631
(
2732
(ptrControllerPacket == 0) ||
28-
(ptrControllerPacket->isControllerConnected != 0)
33+
(ptrControllerPacket->plugged != PLUGGED)
2934
) ||
3035

3136
(
@@ -354,16 +359,14 @@ force_inline void DISPLAYRECTMENU_MainFreeze_MenuPtrOptions(struct RectMenu* men
354359

355360
for(int i = 0; i < gamepad->numGamepads; i++)
356361
{
357-
int gamepadConnected = false;
358362
int dualShockRowColor = ORANGE;
359363
int currPad = gamepad->gamepadId[i];
360364

361365
struct ControllerPacket* ptrControllerPacket =
362366
sdata->gGamepads->gamepad[currPad].ptrControllerPacket;
363367

364-
if (ptrControllerPacket == 0 || ptrControllerPacket->isControllerConnected != 0)
368+
if (ptrControllerPacket == 0 || ptrControllerPacket->plugged != PLUGGED)
365369
{
366-
gamepadConnected = true;
367370
dualShockRowColor = GRAY;
368371
}
369372

@@ -386,8 +389,7 @@ force_inline void DISPLAYRECTMENU_MainFreeze_MenuPtrOptions(struct RectMenu* men
386389
int boolDisabled =
387390
(gGT->gameMode1 & data.gGT_gameMode1_VibPerPlayer[currPad]) == 0;
388391

389-
dualShockRowColor = GRAY;
390-
if (!gamepadConnected)
392+
if (dualShockRowColor != GRAY)
391393
{
392394
// RED: 3
393395
// WHITE: 4

decompile/General/MAIN/MainMain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ u_int DECOMP_main()
406406
}
407407

408408
if ((gGT->gameMode1 & LOADING) == 0)
409-
{
409+
{
410410
#ifdef USE_PROFILER
411411
void DebugProfiler_SectionStart(char* name, char r, char g, char b);
412412
DebugProfiler_SectionStart(0, 0xFF, 0, 0);

decompile/General/zRegionJapan/Retail/DecalFont_boolRacingWheel.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,28 @@ u_int DECOMP_DecalFont_boolRacingWheel()
1111
(
1212
(
1313
(
14-
// check if ptrControllerPacket in non-P1 controllers is null
15-
// or check if non-P1 controller types aren't multitaps (?)
16-
17-
// if P1 controller exists, is a MadCatz Racing Wheel (neGcon with payload length 3), and is "not connected", then return true
18-
// this check will then be used to replace all instances of PS1 button icons with appropriate racing wheel ones
19-
2014
// controllerPacketP1->payLoadLength == 3
2115
// controllerPacketP1->controllerType == PAD_ID_NEGCON
2216
(controllerPacketP1->controllerData == ((PAD_ID_NEGCON << 4) | 3)) &&
2317
(
2418
(
25-
sdata->gGamepads->gamepad[1].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[1].ptrControllerPacket->isControllerConnected != 0
19+
sdata->gGamepads->gamepad[1].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[1].ptrControllerPacket->plugged != PLUGGED
2620
)
2721
)
2822
) &&
2923
(
3024
(
31-
sdata->gGamepads->gamepad[2].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[2].ptrControllerPacket->isControllerConnected != 0
25+
sdata->gGamepads->gamepad[2].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[2].ptrControllerPacket->plugged != PLUGGED
3226
)
3327
)
3428
) &&
3529
(
3630
(
3731
(
3832
(
39-
sdata->gGamepads->gamepad[3].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[3].ptrControllerPacket->isControllerConnected != 0
33+
sdata->gGamepads->gamepad[3].ptrControllerPacket == 0 || sdata->gGamepads->gamepad[3].ptrControllerPacket->plugged != PLUGGED
4034
) && (controllerPacketP1 != 0)
41-
) && (controllerPacketP1->isControllerConnected == 0)
35+
) && (controllerPacketP1->plugged == PLUGGED)
4236
)
4337
)
4438
)

decompile/WorkInProgress/src/MAIN/MainFreeze_ConfigSetupEntry.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void DECOMP_MainFreeze_ConfigSetupEntry()
3434
sdata_boolOpenWheelConfig = 0;
3535
return;
3636
}
37-
if (psVar4->isControllerConnected != '\0')
37+
if (psVar4->plugged != PLUGGED)
3838
{
3939
sdata_boolOpenWheelConfig = 0;
4040
return;

0 commit comments

Comments
 (0)