rewrite TargetInspector to directly access memory, and add experimental ShouldVibrate bool
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetHitStates
|
||||
enum TargetHitStates : int32_t
|
||||
{
|
||||
COOL,
|
||||
FINE,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
}
|
||||
@@ -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];
|
||||
};
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace TLAC::Components
|
||||
{
|
||||
enum TargetTypes
|
||||
enum TargetTypes : int32_t
|
||||
{
|
||||
SANKAKU,
|
||||
MARU,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user