Add axis scaling support

This commit is contained in:
Cameron Gutman 2014-10-01 20:24:40 -07:00
parent ad684a6f6b
commit 23fcaa1bab
2 changed files with 23 additions and 2 deletions

Binary file not shown.

View File

@ -47,6 +47,9 @@ public class ControllerHandler {
public ControllerHandler(NvConnection conn) {
this.conn = conn;
// We want limelight-common to scale the axis values to match Xinput values
ControllerPacket.enableAxisScaling = true;
}
private ControllerMapping createMappingForDevice(InputDevice dev) {
@ -135,6 +138,15 @@ public class ControllerHandler {
InputDevice.MotionRange lsYRange = dev.getMotionRange(mapping.leftStickYAxis);
if (lsXRange != null && lsYRange != null) {
mapping.leftStickDeadzoneRadius = Math.max(lsXRange.getFlat(), lsYRange.getFlat());
// If there isn't a (reasonable) deadzone at all, use 20%
if (mapping.leftStickDeadzoneRadius < 0.02f) {
mapping.leftStickDeadzoneRadius = 0.20f;
}
// Check that the deadzone is 10% at minimum
else if (mapping.leftStickDeadzoneRadius < 0.10f) {
mapping.leftStickDeadzoneRadius = 0.10f;
}
}
}
@ -143,6 +155,15 @@ public class ControllerHandler {
InputDevice.MotionRange rsYRange = dev.getMotionRange(mapping.rightStickYAxis);
if (rsXRange != null && rsYRange != null) {
mapping.rightStickDeadzoneRadius = Math.max(rsXRange.getFlat(), rsYRange.getFlat());
// If there isn't a (reasonable) deadzone at all, use 20%
if (mapping.rightStickDeadzoneRadius < 0.02f) {
mapping.rightStickDeadzoneRadius = 0.20f;
}
// Check that the deadzone is 10% at minimum
else if (mapping.rightStickDeadzoneRadius < 0.10f) {
mapping.rightStickDeadzoneRadius = 0.10f;
}
}
}