#include "classes.h" // 00a22940 void KAGE::Input::InputDeviceGamepad::vfunc_30() { ushort uVar1; uint local_EAX_6; int boundButton; uint local_ECX_26; uint *bindingCursor; int *axisBindingCursor; uint maskHigh; int *piVar2; float axisValue; uint axisButton; uint axisHalf; int *savedDevice; uint isPassUnbound; byte isNegativeHalf; float axisRest; local_EAX_6 = 0; local_ECX_26 = DAT_00c79bf0 - GHIDRA_INT(g_gamepadDevices) >> 2; if (local_ECX_26 != 0) { do { piVar2 = g_gamepadDevices[local_EAX_6]; if (*piVar2 == *GHIDRA_CAST((GHIDRA_CAST(this) + 0x370))) { if (piVar2 == GHIDRA_CAST(0x0)) { return 0; } local_EAX_6 = 0; uVar1 = *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) & 0x20; isPassUnbound = GHIDRA_UINT(uVar1); if (piVar2[5] != 0) goto LAB_00a229a0; goto LAB_00a22a04; } local_EAX_6 = local_EAX_6 + 1; } while (local_EAX_6 < local_ECX_26); } return 0; LAB_00a229a0: do { if (0x1f < local_EAX_6) break; local_ECX_26 = 0; bindingCursor = GHIDRA_CAST((GHIDRA_INT(this) + 0x38c)); do { if (*bindingCursor == local_EAX_6) { boundButton = *GHIDRA_CAST((GHIDRA_CAST(this) + local_ECX_26 * 8 + 0x388)); goto LAB_00a229c9; } local_ECX_26 = local_ECX_26 + 1; bindingCursor = bindingCursor + 2; } while (local_ECX_26 < 0x1d); boundButton = -1; LAB_00a229c9: if (((uVar1 != 0) || (boundButton != -1)) && (*GHIDRA_CAST((local_EAX_6 + piVar2[7])) != '\0')) { local_ECX_26 = 1 << (local_EAX_6 & 0x1f); maskHigh = 0; if (0x1f < local_EAX_6) { maskHigh = local_ECX_26; } local_ECX_26 = local_ECX_26 ^ maskHigh; if (0x3f < local_EAX_6) { maskHigh = local_ECX_26; } *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) | local_ECX_26; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) | maskHigh; } local_EAX_6 = local_EAX_6 + 1; } while (local_EAX_6 < GHIDRA_UINT(piVar2[5])); LAB_00a22a04: axisHalf = 0; savedDevice = piVar2; if ((piVar2[4] & 0x7fffffffU) != 0) { do { if (0x1f < axisHalf) break; if ((*GHIDRA_CAST((GHIDRA_CAST(this) + 8)) & 0x40) == 0) { *GHIDRA_CAST((GHIDRA_CAST(this) + axisHalf * 4 + 0x470)) = *GHIDRA_CAST((piVar2[6] + (axisHalf >> 1) * 4)); } else { axisRest = *GHIDRA_CAST((GHIDRA_CAST(this) + axisHalf * 4 + 0x470)); isNegativeHalf = ~(byte)axisHalf & 1; axisValue = *GHIDRA_CAST((piVar2[6] + (axisHalf >> 1) * 4)) - axisRest; if (axisRest < 0.0) { axisValue = axisValue / (1.0 - axisRest); } axisButton = 0xffffffff; if ((short)isPassUnbound == 0) { local_EAX_6 = 0; axisBindingCursor = GHIDRA_CAST((GHIDRA_INT(this) + 0x38c)); do { piVar2 = savedDevice; if (*axisBindingCursor == axisHalf + 0xabab) { axisButton = *GHIDRA_CAST((GHIDRA_CAST(this) + local_EAX_6 * 8 + 0x388)); goto LAB_00a22ac5; } local_EAX_6 = local_EAX_6 + 1; axisBindingCursor = axisBindingCursor + 2; } while (local_EAX_6 < 0x1d); axisButton = 0xffffffff; } LAB_00a22ac5: if (isNegativeHalf == 0) { if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0xd4)) < axisValue) goto LAB_00a22ae2; LAB_00a22b4a: if (axisValue <= 0.0) { axisValue = 0.0; } } else { if (axisValue < -*GHIDRA_CAST((GHIDRA_CAST(this) + 0xd4))) { LAB_00a22ae2: if (((short)isPassUnbound != 0) || (axisButton != 0xffffffff)) { this->FUN_00a1f910(&axisButton); if (axisButton == 0xffffffff) { axisButton = axisHalf; } local_EAX_6 = 1 << (axisButton & 0x1f); local_ECX_26 = 0; if (0x1f < axisButton) { local_ECX_26 = local_EAX_6; } local_EAX_6 = local_EAX_6 ^ local_ECX_26; if (0x3f < axisButton) { local_ECX_26 = local_EAX_6; } *GHIDRA_CAST((GHIDRA_CAST(this) + 0x30)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x30)) | local_EAX_6; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x34)) | local_ECX_26; } if (isNegativeHalf == 0) goto LAB_00a22b4a; } if (0.0 <= axisValue) { axisValue = 0.0; } else { axisValue = -axisValue; } } *GHIDRA_CAST((GHIDRA_CAST(this) + axisHalf * 4 + 0x40)) = axisValue; } axisHalf = axisHalf + 1; } while (axisHalf < GHIDRA_UINT((piVar2[4] * 2))); } *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) | 0x40; return 1; }