MCPcopy Create free account
hub / github.com/defold/defold / ApplyGamepadModifiers

Function ApplyGamepadModifiers

engine/input/src/input.cpp:1088–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1086 }
1087
1088 float ApplyGamepadModifiers(dmHID::GamepadPacket* packet, const GamepadInput& input)
1089 {
1090 float v = 0.0f;
1091 switch (input.m_Type)
1092 {
1093 case dmInputDDF::GAMEPAD_TYPE_AXIS:
1094 v = packet->m_Axis[input.m_Index];
1095 if (input.m_Negate)
1096 v = -v;
1097 if (input.m_Scale)
1098 v = (v + 1.0f) * 0.5f;
1099 if (input.m_Clamp)
1100 v = dmMath::Clamp(v, 0.0f, 1.0f);
1101 break;
1102 case dmInputDDF::GAMEPAD_TYPE_BUTTON:
1103 v = dmHID::GetGamepadButton(packet, input.m_Index) ? 1.0f : 0.0f;
1104 break;
1105 case dmInputDDF::GAMEPAD_TYPE_HAT:
1106 {
1107 uint8_t t = 0;
1108 bool s = dmHID::GetGamepadHat(packet, input.m_Index, &t);
1109 if (s && (t & input.m_HatMask)) {
1110 v = 1.0f;
1111 }
1112 }
1113 break;
1114 }
1115 return v;
1116 }
1117
1118 void InitKeyMap()
1119 {

Callers 1

UpdateBindingFunction · 0.85

Calls 3

GetGamepadButtonFunction · 0.85
GetGamepadHatFunction · 0.85
ClampFunction · 0.50

Tested by

no test coverage detected