- Home /
InputManager, Gamepads, Wheels: remapping and calibrating
My current project will benefit from uniform support for Keyboard, Gamepad, and Racing Wheel, but I am at the mercy of the InputManager and the controllers which map their axes in different ways. I have tested the Xbox Controller, WingMan cordless gamepad, and Thrustmaster Ferrari Challenge Wheel.
Axis X: Steering [is ok]
Xbox: Left stick horizontal, InputManager value resting at 0, range [-1,1]
WingMan: Left stick horizontal, InputManager value resting at 0, range [-1,1]
Wheel: Wheel centered, InputManager value resting at 0, range [-1,1]
Axis Y:
Xbox: Left stick Vertical, InputManager value resting at 0, range [-1,1]
WingMan: Left stick Vertical, InputManager value resting at 0, range [-1,1]
Wheel: Left (brake) pedal, InputManager value resting at 1, range [1,-1]
Axiz Z/3:
Xbox: Left Trigger + Right Trigger, (resting at 0, range [0,1])+(resting at 0, range [0,-1])
WingMan: Throttle Slider, inverted, range [-1,1]
Wheel: Right (accelerator) pedal, InputManager value resting at 1, range [1,-1]
Problem:
For my driving game, Steering is just fine, but I also want values from brake and accelerator in the range [0,1]. The racing wheel's pedals will need to be remapped to more sensible values, given their rest state and range.
Hypothesis:
I expect the solution to involve bypassing the InputManager in some fashion. I could configure the InputManager's axes to allow me access each possible axis. The value would be interpreted during Update() according to the name of the controller detected. This will limit support to those devices for which I code custom mappings. Also, the user will need to have only one controller plugged in at a time.
TL;DR: Is there a GOOD way around the InputManager for mapping and calibrating ANY controller from within the game?
Answer by iwaldrop · Apr 18, 2013 at 04:26 AM
There is an easier way. :)
void Update()
{
float value = Input.GetAxis("LeftVertical");
value = Mathf.Lerp(0, 1, value/2);
Debug.Log(value);
}
EDIT:
I must have been really tired last night when I posted this answer because I was pretty sure I saw it working in the editor. Then I was thinking about it at work today and realized that it couldn't have possibly worked. Sure enough, I got home and found that the equation is fundamentally flawed. This is the closest I can get:
value = Mathf.Lerp(0, 1, (value + 1) * 0.5f);
Still, it has a margin of error of 0.5, so there is still something that needs to be done to bring it inline with the 0-1 range.
That doesn't exactly address the problem of controllers mapping their controls to different axes, with different values, sometimes even inverted.
I've currently got a wrapper function that interprets correctly for the wheel and xbox controller (it seems to be the popular way), but it is annoying to try getting the Input$$anonymous$$anager to play nice while there's a whole industry of other peripherals out there mapping things slightly differently.
Firstly, this should have been a comment not an answer.
Secondly, you're right, it doesn't address different axes. You should use your wrapper to use the axis that the controller uses and detect it at runtime. That's why so many games allow you to either pick the controller that you're using or allow you to calibrate the game. It'll ask you to fully depress the accelerator, then the brake. Essentially, you'll have to map it internally using a class of your own devising.
(Still finding my way around: pressed the wrong button)
I guess it's resolved then. I was afraid it would come to that.
Yeah, sorry about that. But maybe I'm wrong too (it wouldn't be the first time). I hope, for your sake, someone will drop in here and correct me. :)
Your answer
Follow this Question
Related Questions
Mapping multiple controllers 1 Answer
Axis 9 and 10 not working with 2 Xbox 360 controllers plugged in 1 Answer
How to get gamepad for player 2 to control player? 1 Answer
What's the best way to retrieve input from more than 4 controllers ? 1 Answer
How do I standardize my game's input to different types of controllers? 1 Answer