#include "classes.h" // 0090ac70 void * InputManager::GetDeviceByPlayerEntity(Entity_Player *player) { void *pvVar1; uint uVar2; int *playerCursor; Entity_Player *mainTwin; int *piVar3; uint uVar4; int extraout_ECX; Entity_Player *devicePlayer; uint uVar5; uint deviceIdx; int *deviceCursor; int deviceId; if (player == GHIDRA_CAST(0x0)) { KAGE_LogMessage(8,GHIDRA_CAST("[Frame %d] GetDeviceByPlayerEntity() given NULL player entity \n")); return (void *)0x0; } deviceCursor = *GHIDRA_CAST(this); deviceIdx = 0; uVar2 = *GHIDRA_CAST((GHIDRA_CAST(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((GHIDRA_CAST(pvVar1) + 0xc)); if (uVar5 != 0) { playerCursor = piVar3; do { devicePlayer = GHIDRA_CAST(*playerCursor); if (devicePlayer->_controllerIndex == deviceId) goto LAB_0090ad07; uVar4 = uVar4 + 1; playerCursor = playerCursor + 1; } while (uVar4 < uVar5); } devicePlayer = GHIDRA_CAST(0x0); LAB_0090ad07: mainTwin = (GHIDRA_CAST((player)))->Entity_Player::GetMainTwin(); if ((devicePlayer == mainTwin) || (deviceId == *GHIDRA_CAST((extraout_ECX + 0x1618)))) { return pvVar1; } deviceIdx = deviceIdx + 1; deviceCursor = deviceCursor + 1; } while (deviceIdx < uVar2); } KAGE_LogMessage(8,(byte *) "[Frame %d] GetDeviceByPlayerEntity() cannot find device for the given player entity \n " ); KAGE_LogMessage(8,GHIDRA_CAST("----------------------------------------------------------- \n ")); KAGE_LogMessage(8,GHIDRA_CAST("playerEntity PlayerType: %d, Device ID: %d \n ")); KAGE_LogMessage(8,GHIDRA_CAST("Device List: \n ")); uVar2 = 0; if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST(this) >> 2 == 0) { LAB_0090ae59: KAGE_LogMessage(8,GHIDRA_CAST("----------------------------------------------------------- \n")); return (void *)0x0; } LAB_0090ada1: KAGE_LogMessage(8,GHIDRA_CAST(" - UserID(%llu), DeviceID(%d), SourceDeviceID(%d) \n ")); uVar5 = 0; deviceId = *GHIDRA_CAST((*GHIDRA_CAST((*GHIDRA_CAST(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((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(" - 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((*piVar3 + 0x1618)) == deviceId) break; } KAGE_LogMessage(8,GHIDRA_CAST(" - Device\'s Player Type: %d \n ")); LAB_0090ae42: uVar2 = uVar2 + 1; if (GHIDRA_UINT((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST(this) >> 2)) <= uVar2) goto LAB_0090ae59; goto LAB_0090ada1; } // 0090aeb0 int InputManager::FirstLocalDeviceID() { char isLocal; int iVar1; uint slotIndex; slotIndex = 0; iVar1 = *GHIDRA_CAST(this); if (*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - iVar1 >> 2 != 0) { do { iVar1 = *GHIDRA_CAST((iVar1 + slotIndex * 4)); isLocal = (**(code **)(*GHIDRA_CAST((iVar1 + 0x370)) + 0x14))(); if (isLocal != '\0') { iVar1 = *GHIDRA_CAST((iVar1 + 0x378)); if (iVar1 == 0) { return -1; } return *GHIDRA_CAST((iVar1 + 0xc)); } slotIndex = slotIndex + 1; iVar1 = *GHIDRA_CAST(this); } while (slotIndex < GHIDRA_UINT((*GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - iVar1 >> 2))); } KAGE_LogMessage(8,(byte *) "[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; undefined4 in_ECX; NetplayManager NVar1; uint deviceIndex; float10 value; Manager *manager; int requestedAction; requestedAction = action; manager = g_manager; if (((g_manager->_state != 2) || (g_luaEngine == (void *)0x0)) || (isNetplayHandled = FUN_00864d80(entity,in_ECX,action,&action), isNetplayHandled == '\0')) { NVar1 = manager->_netplayManager; if ((NVar1 != *GHIDRA_CAST((manager + 1))) && (controllerIndex == -1)) { deviceIndex = 0; if (GHIDRA_INT(*GHIDRA_CAST((manager + 1))) - GHIDRA_INT(NVar1) >> 2 != 0) { do { action = *GHIDRA_CAST((**GHIDRA_CAST((GHIDRA_CAST(NVar1) + deviceIndex * 4)) + 0x38)); value = (float10)(*(code *)action)(requestedAction); if ((float)value != 0.0) { return (float)value; } deviceIndex = deviceIndex + 1; NVar1 = manager->_netplayManager; } while (deviceIndex < GHIDRA_UINT((*GHIDRA_CAST((manager + 1)) - GHIDRA_INT(NVar1) >> 2))); } return 0.0; } entity = GHIDRA_CAST(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; undefined1 *puStack_c; undefined4 local_8; local_8 = 0xffffffff; puStack_c = &LAB_00b1154d; local_10 = ExceptionList; ExceptionList = &local_10; piVar1 = GHIDRA_CAST((GHIDRA_INT(this) + 0x14)); if (piVar1 == GHIDRA_CAST(0x0)) { KAGE_LogMessage(0x10,GHIDRA_CAST("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((GHIDRA_CAST(this) + 8)); do { if (deviceSlot == *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc))) { KAGE::SmartPointer::SmartPointer(iVar2); local_8 = 2; LAB_00a2040e: (**(code **)(*piVar1 + 0x10))(); ExceptionList = local_10; return outDevice; } iVar2 = *deviceSlot; if (*GHIDRA_CAST((iVar2 + 0xc)) == index) { FUN_00902d60(deviceSlot); local_8 = 1; goto LAB_00a2040e; } deviceSlot = deviceSlot + 2; } while( true ); } // 00a205a0 byte InputManager::is_device_connected(int deviceIndex) { char isLastRef; int *deviceResult; undefined1 local_1c [4]; int *deviceRefCount; void *local_10; undefined1 *puStack_c; undefined4 local_8; int devicePtr; local_8 = 0xffffffff; puStack_c = &LAB_00af0cf0; local_10 = ExceptionList; ExceptionList = &local_10; deviceResult = GHIDRA_CAST((**(code **)(*GHIDRA_CAST(this) + 0x28))) (local_1c,deviceIndex,__security_cookie ^ GHIDRA_UINT((local_1c + 0x18))) ; devicePtr = *deviceResult; local_8 = 0; if (deviceRefCount != GHIDRA_CAST(0x0)) { isLastRef = (**(code **)(*deviceRefCount + 0xc))(); if ((isLastRef != '\0') && (g_inputDeviceRelease != (void *)0x0)) { (*g_inputDeviceRelease)(local_1c); } } ExceptionList = local_10; return devicePtr != 0; }