MCPcopy Create free account
hub / github.com/ddnet/ddnet / Relative

Method Relative

src/engine/client/input.cpp:238–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238bool CInput::CJoystick::Relative(float *pX, float *pY)
239{
240 if(!Input()->m_MouseFocus || !Input()->m_InputGrabbed || !g_Config.m_InpControllerEnable)
241 return false;
242
243 const vec2 RawJoystickPos = vec2(GetAxisValue(g_Config.m_InpControllerX), GetAxisValue(g_Config.m_InpControllerY));
244 const float Len = length(RawJoystickPos);
245 const float DeadZone = Input()->GetJoystickDeadzone();
246 if(Len > DeadZone)
247 {
248 const float Factor = 2500.0f * Input()->GetUpdateTime() * maximum((Len - DeadZone) / (1.0f - DeadZone), 0.001f) / Len;
249 *pX = RawJoystickPos.x * Factor;
250 *pY = RawJoystickPos.y * Factor;
251 return true;
252 }
253 return false;
254}
255
256bool CInput::CJoystick::Absolute(float *pX, float *pY)
257{

Callers 1

CursorRelativeMethod · 0.80

Calls 5

InputFunction · 0.85
lengthFunction · 0.85
maximumFunction · 0.85
GetJoystickDeadzoneMethod · 0.80
GetUpdateTimeMethod · 0.80

Tested by

no test coverage detected