Skip to content

Commit

Permalink
fix(input/five): sniper zoom bug for scroll wheel
Browse files Browse the repository at this point in the history
Since the mouse scroll delta stuff, sniper zoom with a mouse wheel would
either be zoomed all the way in, or all the way out, as apparently this
'other' value derived from dZ is a count of scroll intervals.

Technically this should be accumulated from partial scrolls still but to
fix the regression we just make it divide by 120 as integer again.

Smooth scrolling from the delta axis has still been confirmed to work.
  • Loading branch information
blattersturm committed Jul 7, 2023
1 parent 585cd7e commit 291d43c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions code/components/rage-input-five/src/PatchMouseScrollDelta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,44 @@ void DoPatchMouseScrollDelta()
hook::jump(location, patch.GetCode());
}

// int 'stacking' for non-float parts (breaks sniper zoom otherwise)
{
static struct : jitasm::Frontend
{
uintptr_t dZAddr = 0;
uintptr_t returnAddr = 0;

virtual void InternalMain() override
{
// eax = *dZAddr
mov(rax, dZAddr);
mov(eax, dword_ptr[rax]);

// ecx = 120
mov(ecx, 120);

// rax = (int64_t)eax
cdq();

// rax /= ecx
idiv(ecx);

// r8d = eax
mov(r8d, eax);

// return
mov(rax, returnAddr);
jmp(rax);
}
} patch;

auto location = hook::get_pattern<char>("41 89 7E 20 44 8B 05", 4);
patch.returnAddr = (uintptr_t)(location + 7);
patch.dZAddr = hook::get_address<uintptr_t>(location, 3, 7);
hook::nop(location, 7);
hook::jump(location, patch.GetCode());
}

// adding / 120.0 to CGalleryMenu

// 1st
Expand Down

0 comments on commit 291d43c

Please sign in to comment.