--check: 938/3256 method bodies compile for x86_64 (28.8%), 32-bit layout asserts hold; boot path 3/626 curated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
242 lines
8.0 KiB
C++
242 lines
8.0 KiB
C++
#include "classes.h"
|
|
|
|
// 0090ac70
|
|
void * InputManager::GetDeviceByPlayerEntity(Entity_Player *player)
|
|
{
|
|
void *pvVar1;
|
|
uint32_t uVar2;
|
|
int *playerCursor;
|
|
Entity_Player *mainTwin;
|
|
int *piVar3;
|
|
uint32_t uVar4;
|
|
int extraout_ECX;
|
|
Entity_Player *devicePlayer;
|
|
uint32_t uVar5;
|
|
uint32_t deviceIdx;
|
|
int *deviceCursor;
|
|
int deviceId;
|
|
|
|
if (player == GHIDRA_CAST<Entity_Player *>(0x0)) {
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("[Frame %d] GetDeviceByPlayerEntity() given NULL player entity \n"));
|
|
return (void *)0x0;
|
|
}
|
|
deviceCursor = *GHIDRA_CAST<int **>(this);
|
|
deviceIdx = 0;
|
|
uVar2 = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - GHIDRA_INT(deviceCursor) >> 2;
|
|
if (uVar2 != 0) {
|
|
piVar3 = (g_game->_playerManager)._playerList._begin;
|
|
uVar5 = GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT(piVar3) >> 2;
|
|
do {
|
|
pvVar1 = (void *)*deviceCursor;
|
|
uVar4 = 0;
|
|
deviceId = *GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(pvVar1) + 0xc));
|
|
if (uVar5 != 0) {
|
|
playerCursor = piVar3;
|
|
do {
|
|
devicePlayer = GHIDRA_CAST<Entity_Player *>(*playerCursor);
|
|
if (devicePlayer->_controllerIndex == deviceId) goto LAB_0090ad07;
|
|
uVar4 = uVar4 + 1;
|
|
playerCursor = playerCursor + 1;
|
|
} while (uVar4 < uVar5);
|
|
}
|
|
devicePlayer = GHIDRA_CAST<Entity_Player *>(0x0);
|
|
LAB_0090ad07:
|
|
mainTwin = (GHIDRA_CAST<Entity_Player *>((player)))->Entity_Player::GetMainTwin();
|
|
if ((devicePlayer == mainTwin) || (deviceId == *GHIDRA_CAST<int *>((extraout_ECX + 0x1618)))) {
|
|
return pvVar1;
|
|
}
|
|
deviceIdx = deviceIdx + 1;
|
|
deviceCursor = deviceCursor + 1;
|
|
} while (deviceIdx < uVar2);
|
|
}
|
|
KAGE_LogMessage(8,(uint8_t *)
|
|
"[Frame %d] GetDeviceByPlayerEntity() cannot find device for the given player entity \n "
|
|
);
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("----------------------------------------------------------- \n "));
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("playerEntity PlayerType: %d, Device ID: %d \n "));
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("Device List: \n "));
|
|
uVar2 = 0;
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>(this) >> 2 == 0) {
|
|
LAB_0090ae59:
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>("----------------------------------------------------------- \n"));
|
|
return (void *)0x0;
|
|
}
|
|
LAB_0090ada1:
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>(" - UserID(%llu), DeviceID(%d), SourceDeviceID(%d) \n "));
|
|
uVar5 = 0;
|
|
deviceId = *GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>((*GHIDRA_CAST<int *>(this) + uVar2 * 4)) + 0xc));
|
|
piVar3 = (g_game->_playerManager)._playerList._begin;
|
|
uVar4 = GHIDRA_INT((g_game->_playerManager)._playerList._end) - GHIDRA_INT(piVar3) >> 2;
|
|
if (uVar4 != 0) {
|
|
do {
|
|
if (*GHIDRA_CAST<int *>((piVar3[uVar5] + 0x1618)) == deviceId) {
|
|
if (piVar3[uVar5] != 0) {
|
|
uVar5 = 0;
|
|
goto LAB_0090ae80;
|
|
}
|
|
break;
|
|
}
|
|
uVar5 = uVar5 + 1;
|
|
} while (uVar5 < uVar4);
|
|
}
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>(" - Device is not associated with a player entity!!! \n "));
|
|
goto LAB_0090ae42;
|
|
while( true ) {
|
|
uVar5 = uVar5 + 1;
|
|
piVar3 = piVar3 + 1;
|
|
if (uVar4 <= uVar5) break;
|
|
LAB_0090ae80:
|
|
if (*GHIDRA_CAST<int *>((*piVar3 + 0x1618)) == deviceId) break;
|
|
}
|
|
KAGE_LogMessage(8,GHIDRA_CAST<uint8_t *>(" - Device\'s Player Type: %d \n "));
|
|
LAB_0090ae42:
|
|
uVar2 = uVar2 + 1;
|
|
if (GHIDRA_UINT((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - *GHIDRA_CAST<int *>(this) >> 2)) <= uVar2) goto LAB_0090ae59;
|
|
goto LAB_0090ada1;
|
|
}
|
|
|
|
// 0090aeb0
|
|
int InputManager::FirstLocalDeviceID()
|
|
{
|
|
char isLocal;
|
|
int iVar1;
|
|
uint32_t slotIndex;
|
|
|
|
slotIndex = 0;
|
|
iVar1 = *GHIDRA_CAST<int *>(this);
|
|
if (*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - iVar1 >> 2 != 0) {
|
|
do {
|
|
iVar1 = *GHIDRA_CAST<int *>((iVar1 + slotIndex * 4));
|
|
isLocal = (**(code **)(*GHIDRA_CAST<int *>((iVar1 + 0x370)) + 0x14))();
|
|
if (isLocal != '\0') {
|
|
iVar1 = *GHIDRA_CAST<int *>((iVar1 + 0x378));
|
|
if (iVar1 == 0) {
|
|
return -1;
|
|
}
|
|
return *GHIDRA_CAST<int *>((iVar1 + 0xc));
|
|
}
|
|
slotIndex = slotIndex + 1;
|
|
iVar1 = *GHIDRA_CAST<int *>(this);
|
|
} while (slotIndex < GHIDRA_UINT((*GHIDRA_CAST<int *>((GHIDRA_CAST<char *>(this) + 4)) - iVar1 >> 2)));
|
|
}
|
|
KAGE_LogMessage(8,(uint8_t *)
|
|
"[Frame %d] FirstLocalDeviceID() Could not find a device for the local user! \n "
|
|
);
|
|
return -1;
|
|
}
|
|
|
|
// 009562d0
|
|
float InputManager::GetActionValue(int action, int controllerIndex, Entity *entity, int unused)
|
|
{
|
|
char isNetplayHandled;
|
|
uint32_t in_ECX;
|
|
int iVar1;
|
|
uint32_t deviceIndex;
|
|
long double value;
|
|
Manager *manager;
|
|
int requestedAction;
|
|
|
|
requestedAction = action;
|
|
manager = g_manager;
|
|
if (((*GHIDRA_CAST<int *>(&(*GHIDRA_CAST<uint8_t *>((GHIDRA_CAST<char *>((g_manager)) + 0x8)))) != 2) || (g_luaEngine == (void *)0x0)) ||
|
|
(isNetplayHandled = FUN_00864d80(entity,in_ECX,action,&action), isNetplayHandled == '\0')) {
|
|
iVar1 = manager->_netplayManager;
|
|
if ((iVar1 != *GHIDRA_CAST<int *>((manager + 1))) && (controllerIndex == -1)) {
|
|
deviceIndex = 0;
|
|
if (*GHIDRA_CAST<int *>((manager + 1)) - iVar1 >> 2 != 0) {
|
|
do {
|
|
action = *GHIDRA_CAST<uint32_t *>((**GHIDRA_CAST<int **>((iVar1 + deviceIndex * 4)) + 0x38));
|
|
value = (long double)(*(code *)action)(requestedAction);
|
|
if ((float)value != 0.0) {
|
|
return (float)value;
|
|
}
|
|
deviceIndex = deviceIndex + 1;
|
|
iVar1 = manager->_netplayManager;
|
|
} while (deviceIndex < GHIDRA_UINT((*GHIDRA_CAST<int *>((manager + 1)) - iVar1 >> 2)));
|
|
}
|
|
return 0.0;
|
|
}
|
|
entity = GHIDRA_CAST<Entity *>(requestedAction);
|
|
action = 0;
|
|
(**(code **)(PTR_vftable_00c57b18 + 0x74))(controllerIndex,FUN_00a20ab0,&entity,&action,0);
|
|
}
|
|
return (float)action;
|
|
}
|
|
|
|
// 00a20390
|
|
void * InputManager::get_device(void *outDevice, int index)
|
|
{
|
|
int *piVar1;
|
|
int *deviceSlot;
|
|
int extraout_ECX;
|
|
int extraout_ECX_00;
|
|
int iVar2;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00b1154d;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
piVar1 = GHIDRA_CAST<int *>((GHIDRA_INT(this) + 0x14));
|
|
if (piVar1 == GHIDRA_CAST<int *>(0x0)) {
|
|
KAGE_LogMessage(0x10,GHIDRA_CAST<uint8_t *>("Invalid mutex object specified"));
|
|
iVar2 = extraout_ECX;
|
|
}
|
|
else {
|
|
(**(code **)(*piVar1 + 0xc))(0xffffffff,__security_cookie ^ GHIDRA_INT(register0x00000010) - 4U);
|
|
iVar2 = extraout_ECX_00;
|
|
}
|
|
local_8 = 0;
|
|
deviceSlot = *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 8));
|
|
do {
|
|
if (deviceSlot == *GHIDRA_CAST<int **>((GHIDRA_CAST<char *>(this) + 0xc))) {
|
|
KAGE::SmartPointer<InputDeviceBase>::SmartPointer(iVar2);
|
|
local_8 = 2;
|
|
LAB_00a2040e:
|
|
(**(code **)(*piVar1 + 0x10))();
|
|
ExceptionList = local_10;
|
|
return outDevice;
|
|
}
|
|
iVar2 = *deviceSlot;
|
|
if (*GHIDRA_CAST<int *>((iVar2 + 0xc)) == index) {
|
|
FUN_00902d60(deviceSlot);
|
|
local_8 = 1;
|
|
goto LAB_00a2040e;
|
|
}
|
|
deviceSlot = deviceSlot + 2;
|
|
} while( true );
|
|
}
|
|
|
|
// 00a205a0
|
|
uint8_t InputManager::is_device_connected(int deviceIndex)
|
|
{
|
|
char isLastRef;
|
|
int *deviceResult;
|
|
uint8_t local_1c [4];
|
|
int *deviceRefCount;
|
|
void *local_10;
|
|
uint8_t *puStack_c;
|
|
uint32_t local_8;
|
|
int devicePtr;
|
|
|
|
local_8 = 0xffffffff;
|
|
puStack_c = &LAB_00af0cf0;
|
|
local_10 = ExceptionList;
|
|
ExceptionList = &local_10;
|
|
deviceResult = GHIDRA_CAST<int *>((**(code **)(*GHIDRA_CAST<int *>(this) + 0x28)))
|
|
(local_1c,deviceIndex,__security_cookie ^ GHIDRA_UINT((local_1c + 0x18)))
|
|
;
|
|
devicePtr = *deviceResult;
|
|
local_8 = 0;
|
|
if (deviceRefCount != GHIDRA_CAST<int *>(0x0)) {
|
|
isLastRef = (**(code **)(*deviceRefCount + 0xc))();
|
|
if ((isLastRef != '\0') && (g_inputDeviceRelease != (void *)0x0)) {
|
|
(*g_inputDeviceRelease)(local_1c);
|
|
}
|
|
}
|
|
ExceptionList = local_10;
|
|
return devicePtr != 0;
|
|
}
|