- Home /
Getting Raw Joystick Input via Script
I'm trying to deal with controllers in a programmatic way. The InputManager is a massive hassle.
I want to work out what Unity calls each of the buttons I press, for a few reasons: - Binding input from unknown controller types to actions. - Debugging what Unity calls each button (e.g. controller type A has button X, which Unity thinks is Button7
For keyboard it seems i can do:
void OnGUI() {
Event e = Event.current;
if (e.isButton && Input.anyKeyDown) {
Debug.Log(e.keyCode.ToString());
}
}
I couldn't find anything in Event for joysticks. What do other people do?
Answer by Waz · May 24, 2013 at 01:57 AM
There are no events for joysticks - you'll have to iterate through all buttons.
Thanks for the quick reply! Don't I have to set up all buttons manually through the Input$$anonymous$$anager before being able to iterate through them?
Sorry I see now, I use the Joystick entries on $$anonymous$$eyCode