Skip to content

Commit de8a143

Browse files
committed
more mouse related fixes
- fixes #47 - fixes #42
1 parent b9f257e commit de8a143

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

data/plugins/GTAIV.EFLC.FusionFix.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AimingZoomFix = 1
1010
FlickeringShadowsFix = 1
1111

1212
[FRAMELIMIT]
13-
FrameLimitType = 2 // 1: realtime (thread-lock) | 2: accurate (sleep-yield)
13+
FrameLimitType = 2 // 1: realtime (thread-lock) | 2: accurate (sleep-yield), uses less resources
1414
FpsLimit = 0
1515
CutsceneFpsLimit = 60
1616
ScriptCutsceneFovLimit = 20
@@ -19,5 +19,4 @@ ScriptCutsceneFovLimit = 20
1919
DefaultCameraAngleInTLAD = 0
2020
PedDeathAnimFixFromTBOGT = 1
2121
DisableCameraCenteringInCover = 1
22-
MouseFix = 0
23-
22+
MouseFix = 1

source/dllmain.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void Init()
253253
bool bFlickeringShadowsFix = iniReader.ReadInteger("MAIN", "FlickeringShadowsFix", 1) != 0;
254254

255255
//[FRAMELIMIT]
256-
nFrameLimitType = iniReader.ReadInteger("FRAMELIMIT", "FrameLimitType", 1);
256+
nFrameLimitType = iniReader.ReadInteger("FRAMELIMIT", "FrameLimitType", 2);
257257
fFpsLimit = static_cast<float>(iniReader.ReadInteger("FRAMELIMIT", "FpsLimit", 0));
258258
fCutsceneFpsLimit = static_cast<float>(iniReader.ReadInteger("FRAMELIMIT", "CutsceneFpsLimit", 0));
259259
fScriptCutsceneFpsLimit = static_cast<float>(iniReader.ReadInteger("FRAMELIMIT", "ScriptCutsceneFpsLimit", 0));
@@ -263,7 +263,7 @@ void Init()
263263
bool bDefaultCameraAngleInTLAD = iniReader.ReadInteger("MISC", "DefaultCameraAngleInTLAD", 0) != 0;
264264
bool bPedDeathAnimFixFromTBOGT = iniReader.ReadInteger("MISC", "PedDeathAnimFixFromTBOGT", 1) != 0;
265265
bool bDisableCameraCenteringInCover = iniReader.ReadInteger("MISC", "DisableCameraCenteringInCover", 1) != 0;
266-
bool bMouseFix = iniReader.ReadInteger("MISC", "MouseFix", 0) != 0;
266+
bool bMouseFix = iniReader.ReadInteger("MISC", "MouseFix", 1) != 0;
267267

268268
//[BudgetedIV]
269269
uint32_t nVehicleBudget = iniReader.ReadInteger("BudgetedIV", "VehicleBudget", 0);
@@ -447,12 +447,22 @@ void Init()
447447

448448
if (bHandbrakeCamFix)
449449
{
450+
static auto unk_117E700 = hook::get_pattern("68 ? ? ? ? B9 ? ? ? ? E8 ? ? ? ? E8 ? ? ? ? F6 D8 1A C0", 1);
451+
static auto GET_POSITION_OF_ANALOGUE_STICKS = hook::get_pattern("6A 00 E8 ? ? ? ? 83 C4 04 80 B8 ? ? ? ? ? 74 78", 0);
450452
auto pattern = hook::pattern("F3 0F 10 44 24 ? F3 0F 11 04 24 8D 44 24 34 50 8D 44 24 28 50 53 8B CF");
451453
struct HandbrakeCam
452454
{
453455
void operator()(injector::reg_pack& regs)
454456
{
455-
*(float*)(regs.esp + 0x2C) *= (1.0f / 30.0f) / fTimeStep;
457+
int pLeftX = 0;
458+
int pLeftY = 0;
459+
int pRightX = 0;
460+
int pRightY = 0;
461+
injector::cstd<void(int, int*, int*, int*, int*)>::call(GET_POSITION_OF_ANALOGUE_STICKS, 0, &pLeftX, &pLeftY, &pRightX, &pRightY);
462+
if (pRightX == 0 && pRightY == 0)
463+
*(float*)(regs.esp + 0x2C) *= (1.0f / 30.0f) / fTimeStep;
464+
//if (!*(uint8_t*)(*(uint32_t*)unk_117E700 + 0x328C))
465+
// *(float*)(regs.esp + 0x2C) *= (1.0f / 30.0f) / fTimeStep;
456466
float f = *(float*)(regs.esp + 0x2C);
457467
_asm movss xmm0, dword ptr[f]
458468
}
@@ -491,6 +501,22 @@ void Init()
491501
dword_1826D6C = *pattern.get_first<int32_t>(34);
492502
pattern = hook::pattern("51 8B 54 24 0C C7 04 24 ? ? ? ? 85 D2 75 0D 39 15 ? ? ? ? 75 17 D9 04 24 59 C3");
493503
injector::MakeJMP(pattern.get_first(0), MouseFix, true);
504+
505+
//ped cam behaves the same way as aiming cam
506+
static constexpr float f255 = 255.0f;
507+
pattern = hook::pattern("F3 0F 59 05 ? ? ? ? F3 0F 2C C0 83 C4 0C");
508+
injector::WriteMemory(pattern.get_first(4), &f255, true);
509+
510+
//sniper scope is slow
511+
static constexpr float f01 = 0.1f;
512+
pattern = hook::pattern("F3 0F 59 15 ? ? ? ? F3 0F 58 97");
513+
injector::WriteMemory(pattern.get_first(4), &f01, true);
514+
injector::WriteMemory(pattern.get_first(28), &f01, true);
515+
516+
//first person vehicle view is slow
517+
pattern = hook::pattern("F3 0F 59 15 ? ? ? ? F3 0F 58 96");
518+
injector::WriteMemory(pattern.get_first(4), &f01, true);
519+
injector::WriteMemory(pattern.get_first(28), &f01, true);
494520
}
495521

496522
if (fFpsLimit || fCutsceneFpsLimit || fScriptCutsceneFpsLimit)

0 commit comments

Comments
 (0)