AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxMouseLook.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: mouse-look delta, free of engine types so it can be unit tested
3 * (tests/cpp/test_mouse_look.cpp).
4 */
5#ifndef LUX_MOUSE_LOOK_H
6#define LUX_MOUSE_LOOK_H
7
8#include <cmath>
9
10// Stock behaviour divides by the screen height. The fix uses this fixed reference instead, so
11// turning speed does not change with resolution (1080p feels the same as stock).
12static const float kLuxMouseLookReferenceHeight = 1080.0f;
13
14/**
15 * Converts a relative mouse movement (pixels) into a look delta.
16 * afMul is the product of all sensitivity factors.
17 * abFix=false reproduces the stock exe exactly: it rounds the scaled movement to whole pixels
18 * and divides by 1.7 * the screen height.
19 */
20inline void LuxMouseLookDelta(int alRelX, int alRelY, float afMul, float afScreenHeight, bool abFix,
21 float &afOutX, float &afOutY)
22{
23 float fX = alRelX * afMul;
24 float fY = alRelY * afMul;
25 if(!abFix)
26 {
27 fX = std::floor(fX + 0.5f);
28 fY = std::floor(fY + 0.5f);
29 }
30 float fDiv = 1.7f * (abFix ? kLuxMouseLookReferenceHeight : afScreenHeight);
31 afOutX = fX / fDiv;
32 afOutY = fY / fDiv;
33}
34
35#endif
void LuxMouseLookDelta(int alRelX, int alRelY, float afMul, float afScreenHeight, bool abFix, float &afOutX, float &afOutY)
Converts a relative mouse movement (pixels) into a look delta.
static const float kLuxMouseLookReferenceHeight