AMFP Enhanced
C++ reference: the code this unofficial fork added
Toggle main menu visibility
Loading...
Searching...
No Matches
LuxPadLook.h
Go to the documentation of this file.
1
/*
2
* AMFP-2026: gamepad look response (Input tab: dead zone, look acceleration, separate X / Y
3
* speed). Pure math, unit tested in tests/cpp/test_pad_look.cpp.
4
*/
5
#ifndef LUX_PAD_LOOK_H
6
#define LUX_PAD_LOOK_H
7
8
#include <cmath>
9
10
static
const
float
kLuxLookCurveStock
= 1.5f;
// the original: v * sqrt(|v|)
11
static
const
float
kLuxLookCurveAccel
= 2.2f;
// finer aim near the centre
12
static
const
float
kLuxLookBoostDelay
= 0.25f;
// full tilt held this long before turning faster
13
static
const
float
kLuxLookBoostRamp
= 0.4f;
14
static
const
float
kLuxLookBoostMax
= 1.8f;
15
static
const
float
kLuxLookBoostTilt
= 0.92f;
16
17
/** One stick axis after the dead zone (rescaled so it starts from 0) and the response curve. */
18
inline
float
LuxPadLookAxis
(
float
afValue,
float
afDeadZone,
bool
abAccel)
19
{
20
float
fAbs = std::fabs(afValue);
21
if
(fAbs <= afDeadZone || afDeadZone >= 1.0f)
return
0;
22
float
fT = (fAbs - afDeadZone) / (1.0f - afDeadZone);
23
if
(fT > 1.0f) fT = 1.0f;
24
float
fOut = std::pow(fT, abAccel ?
kLuxLookCurveAccel
:
kLuxLookCurveStock
);
25
return
afValue < 0 ? -fOut : fOut;
26
}
27
28
/** Turning speed boost while the stick is held at full tilt (acceleration only). */
29
class
cLuxPadLookBoost
30
{
31
public
:
32
cLuxPadLookBoost
() : mfHeld(0) {}
33
void
Update
(
float
afTimeStep,
float
afTilt)
34
{
35
if
(std::fabs(afTilt) >=
kLuxLookBoostTilt
) mfHeld += afTimeStep > 0 ? afTimeStep : 0;
36
else
mfHeld = 0;
37
}
38
float
Multiplier
()
const
39
{
40
float
fT = (mfHeld -
kLuxLookBoostDelay
) /
kLuxLookBoostRamp
;
41
if
(fT <= 0)
return
1.0f;
42
if
(fT > 1) fT = 1;
43
return
1.0f + (
kLuxLookBoostMax
- 1.0f) * fT;
44
}
45
private
:
46
float
mfHeld;
47
};
48
49
#endif
LuxPadLookAxis
float LuxPadLookAxis(float afValue, float afDeadZone, bool abAccel)
One stick axis after the dead zone (rescaled so it starts from 0) and the response curve.
Definition
LuxPadLook.h:18
kLuxLookBoostRamp
static const float kLuxLookBoostRamp
Definition
LuxPadLook.h:13
kLuxLookBoostMax
static const float kLuxLookBoostMax
Definition
LuxPadLook.h:14
kLuxLookBoostDelay
static const float kLuxLookBoostDelay
Definition
LuxPadLook.h:12
kLuxLookCurveStock
static const float kLuxLookCurveStock
Definition
LuxPadLook.h:10
kLuxLookCurveAccel
static const float kLuxLookCurveAccel
Definition
LuxPadLook.h:11
kLuxLookBoostTilt
static const float kLuxLookBoostTilt
Definition
LuxPadLook.h:15
cLuxPadLookBoost::Multiplier
float Multiplier() const
Definition
LuxPadLook.h:38
cLuxPadLookBoost::cLuxPadLookBoost
cLuxPadLookBoost()
Definition
LuxPadLook.h:32
cLuxPadLookBoost::Update
void Update(float afTimeStep, float afTilt)
Definition
LuxPadLook.h:33
Game
src
game
LuxPadLook.h
Generated by
1.18.0