diff --git a/source-code/source/plugins/TLAC/Components/GameTargets/TargetHitStates.h b/source-code/source/plugins/TLAC/Components/GameTargets/TargetHitStates.h index 2dbe423..f56400d 100644 --- a/source-code/source/plugins/TLAC/Components/GameTargets/TargetHitStates.h +++ b/source-code/source/plugins/TLAC/Components/GameTargets/TargetHitStates.h @@ -2,7 +2,7 @@ namespace TLAC::Components { - enum TargetHitStates + enum TargetHitStates : int32_t { COOL, FINE, diff --git a/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.cpp b/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.cpp index 803670a..7805c31 100644 --- a/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.cpp +++ b/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.cpp @@ -3,6 +3,7 @@ namespace TLAC::Components { bool TargetInspector::repressTbl[maxTargetSlots]; + bool TargetInspector::ShouldVibrate; TargetInspector::TargetInspector() { @@ -14,15 +15,13 @@ namespace TLAC::Components void TargetInspector::Initialize(ComponentsManager*) { - tgtTypePtr = (int*)TGT_TYPE_BASE_ADDRESS; - tgtHitStatePtr = (int*)TGT_HIT_STATE_BASE_ADDRESS; - tgtRemainingTimePtr = (float*)TGT_REMAINING_DURATION_BASE_ADDRESS; + tgtStates = (TargetState*)TGT_STATES_BASE_ADDRESS; } void TargetInspector::Update() { - GetTargetStates(); UpdateRepressTbl(); + UpdateShouldVibrate(); } const char* TargetInspector::GetDisplayName() @@ -30,16 +29,6 @@ namespace TLAC::Components return "target_inspector"; } - void TargetInspector::GetTargetStates() - { - for (int i = 0; i < maxTargetSlots; ++i) - { - tgtStates[i].tgtType = *((int*)((char*)tgtTypePtr + (i * offset))); - tgtStates[i].tgtHitState = *((int*)((char*)tgtHitStatePtr + (i * offset))); - tgtStates[i].tgtRemainingTime = *((float*)((char*)tgtRemainingTimePtr + (i * offset))); - } - } - void TargetInspector::UpdateRepressTbl() { for (int i = 0; i < maxTargetSlots; ++i) @@ -50,6 +39,22 @@ namespace TLAC::Components } } + void TargetInspector::UpdateShouldVibrate() + { + for (int i = 0; i < maxTargetSlots; ++i) + { + if (IsWithinRange(tgtStates[i].tgtRemainingTime) + && (tgtStates[i].tgtType == SLIDE_LONG_L || tgtStates[i].tgtType == SLIDE_LONG_R) + && tgtStates[i].tgtHitState == NONE) + { + //printf("%d\n", tgtStates[i].tgtHitState); + ShouldVibrate = true; + return; + } + } + ShouldVibrate = false; + } + bool TargetInspector::IsWithinRange(float time) { return time < timingThreshold && time > -timingThreshold && time != 0; diff --git a/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.h b/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.h index 87fb103..6beb6fc 100644 --- a/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.h +++ b/source-code/source/plugins/TLAC/Components/GameTargets/TargetInspector.h @@ -7,7 +7,7 @@ namespace TLAC::Components { - const int maxTargetSlots = 32; + const int maxTargetSlots = 64; class TargetInspector : public EmulatorComponent { @@ -21,23 +21,20 @@ namespace TLAC::Components virtual void Update() override; virtual const char* GetDisplayName() override; - void GetTargetStates(); static bool IsAnyRepress(); + static bool ShouldVibrate; + private: - const uint64_t offset = 0x4A8; + //const uint64_t offset = 0x4A8; const float timingThreshold = 0.13f; // PS4 estimate - TargetState tgtStates[maxTargetSlots]; - - int* tgtTypePtr; - int* tgtHitStatePtr; - float* tgtRemainingTimePtr; + TargetState* tgtStates; bool IsSlide(int); bool IsWithinRange(float); bool HasNotBeenHit(int); void UpdateRepressTbl(); - + void UpdateShouldVibrate(); }; } \ No newline at end of file diff --git a/source-code/source/plugins/TLAC/Components/GameTargets/TargetState.h b/source-code/source/plugins/TLAC/Components/GameTargets/TargetState.h index 7ea6cff..4b12d70 100644 --- a/source-code/source/plugins/TLAC/Components/GameTargets/TargetState.h +++ b/source-code/source/plugins/TLAC/Components/GameTargets/TargetState.h @@ -4,8 +4,17 @@ namespace TLAC::Components { struct TargetState { - int tgtType; - int tgtHitState; + // seems to be some kind of linked list.. + // not sure if these are for all active targets or just used in some functions + TargetState* prev; + TargetState* next; + byte padding10[0x4]; + TargetTypes tgtType; float tgtRemainingTime; + byte padding1C[0x434]; + byte ToBeRemoved; // FromList + byte padding451[0xB]; + TargetHitStates tgtHitState; + byte padding460[0x48]; }; } \ No newline at end of file diff --git a/source-code/source/plugins/TLAC/Components/GameTargets/TargetTypes.h b/source-code/source/plugins/TLAC/Components/GameTargets/TargetTypes.h index f152417..da87d35 100644 --- a/source-code/source/plugins/TLAC/Components/GameTargets/TargetTypes.h +++ b/source-code/source/plugins/TLAC/Components/GameTargets/TargetTypes.h @@ -2,7 +2,7 @@ namespace TLAC::Components { - enum TargetTypes + enum TargetTypes : int32_t { SANKAKU, MARU, diff --git a/source-code/source/plugins/TLAC/Constants.h b/source-code/source/plugins/TLAC/Constants.h index 12bbc95..e526547 100644 --- a/source-code/source/plugins/TLAC/Constants.h +++ b/source-code/source/plugins/TLAC/Constants.h @@ -45,9 +45,9 @@ constexpr uint64_t GLUT_SET_CURSOR_ADDRESS = 0x00000001408B68E6; constexpr uint64_t CHANGE_MODE_ADDRESS = 0x00000001401953D0; constexpr uint64_t CHANGE_SUB_MODE_ADDRESS = 0x0000000140195260; -constexpr uint64_t TGT_TYPE_BASE_ADDRESS = 0x0000000140D0B69C; -constexpr uint64_t TGT_REMAINING_DURATION_BASE_ADDRESS = 0x0000000140D0B6A0; -constexpr uint64_t TGT_HIT_STATE_BASE_ADDRESS = 0x0000000140D0BAE4; +constexpr uint64_t TGT_CLASS_ADDRESS = 0x0000000140D0B660; +constexpr uint64_t TGT_STATES_FIRST_POINTER_ADDRESS = 0x0000000140D0B680; +constexpr uint64_t TGT_STATES_BASE_ADDRESS = 0x0000000140D0B688; constexpr uint64_t TGT_ON_SCREEN_ADDRESS = 0x0000000140D0B678; constexpr uint64_t HOLD_STATE_ADDRESS = 0x0000000140D1E20C; diff --git a/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp b/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp index 7ecf435..8aff81b 100644 --- a/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp +++ b/source-code/source/plugins/TLAC/Input/Xinput/Xinput.cpp @@ -3,6 +3,7 @@ #include "../../Constants.h" #include "../../FileSystem/ConfigFile.h" #include "../../framework.h" +#include "../../Components/GameTargets/TargetInspector.h" namespace TLAC::Input { @@ -226,6 +227,25 @@ namespace TLAC::Input SetTapStates(i, elapsed); } + if (TLAC::Components::TargetInspector::ShouldVibrate) + { + XINPUT_VIBRATION vibration; + ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION)); + vibration.wLeftMotorSpeed = 8000; // use any value between 0-65535 here + vibration.wRightMotorSpeed = 4000; // use any value between 0-65535 here + //XInputSetState(xc_pref, &vibration); + //printf("1"); + } + else + { + XINPUT_VIBRATION vibration; + ZeroMemory(&vibration, sizeof(XINPUT_VIBRATION)); + vibration.wLeftMotorSpeed = 0; // use any value between 0-65535 here + vibration.wRightMotorSpeed = 0; // use any value between 0-65535 here + //XInputSetState(xc_pref, &vibration); + //printf("0"); + } + break; } else if (n == 3) {