Support for SDL Joysticks

This enables use of non-controller peripherals,
such as DirectInput steering wheels or flight sticks
This commit is contained in:
Silent
2020-11-15 14:56:52 +01:00
parent 99ec667b20
commit 2880b71b48
14 changed files with 570 additions and 73 deletions

View File

@ -63,9 +63,8 @@ void NeGcon::SetAxisState(s32 axis_code, float value)
return;
}
// I, II, L: 0..1 -> 0..255 or -1..0 -> 0..255 to support negative axis ranges,
// e.g. if bound to analog stick instead of trigger
const u8 u8_value = static_cast<u8>(std::clamp(std::abs(value) * 255.0f, 0.0f, 255.0f));
// I, II, L: -1..1 -> 0..255
const u8 u8_value = static_cast<u8>(std::clamp(((value + 1.0f) / 2.0f) * 255.0f, 0.0f, 255.0f));
SetAxisState(static_cast<Axis>(axis_code), u8_value);
}