Forum Discussion
Welby
12 years agoAdventurer
Best and Fastest way to implement the GamePad support
Hi!
I was thinking about the best and fastest way to implement the Gamepad support in my game. It will be to add in the code also the lines to support the gamepad or there is a faster way to make it?
Like a software or something else where i can map the keys from the keyboard to the gamepad?
Thanks!
I was thinking about the best and fastest way to implement the Gamepad support in my game. It will be to add in the code also the lines to support the gamepad or there is a faster way to make it?
Like a software or something else where i can map the keys from the keyboard to the gamepad?
Thanks!
6 Replies
Replies have been turned off for this discussion
- moltonExplorerI haven't had a chance to mess with DirectInput gamepads but I think Unity has some pretty good support for that built in, the XBOX360, xinput gamepad support is pretty much all layed out for us by Oculus, the implimentation is all in OVRPlayerController.cs script.
- WelbyAdventurer
"molton" wrote:
I haven't had a chance to mess with DirectInput gamepads but I think Unity has some pretty good support for that built in, the XBOX360, xinput gamepad support is pretty much all layed out for us by Oculus, the implimentation is all in OVRPlayerController.cs script.
The OVRPlayerController has the Gamepad support for the movements. I need to map all the keys for other actions like : interactions,use skills etc.
So i've to check a bit the DirectInput gamepads of Unity! - moltonExplorerOh, right, you can find an example of that in the OVRMainMenu.cs script
bool curStartDown = OVRGamepadController.GPC_GetButton(OVRGamepadController.Button.Start);
Monodevelop sohuld give you any of the other buttons you can assign if you just type "OVRGamepadController.Button." or look them up in the OVRGamepad.cs script. - weasel47Heroic ExplorerYou can configure axes and buttons in Edit -> Project Settings -> Input. If you set up multiple inputs with the same name (keyboard for one, gamepad for another), they will both be treated the same. You can then use, for example:
Input.GetButtonDown("Fire1");
This will detect any button that has been named "Fire1" in the settings. - WelbyAdventurer
"weasel47" wrote:
You can configure axes and buttons in Edit -> Project Settings -> Input. If you set up multiple inputs with the same name (keyboard for one, gamepad for another), they will both be treated the same. You can then use, for example:
Input.GetButtonDown("Fire1");
This will detect any button that has been named "Fire1" in the settings.
This is really useful to know. Maybe more useful if i know it some time ago,now i've to change the keys as you have said in every scripts :lol:
However that's really interesting,i'm going to try it now! Thanks both of you :)
Edit: Your solution works perfectly,thanks! :) - hash280689Honored GuestHere's one I made. It works fine for me. I just use this file in all my projects. I'd suggest making a backup of your 'Project Settings" folder before doing this. Then put my file in the Project Settings folder.
Hope this helps
EDIT: I realise I have not implemented the DPAD in this setup, but if you look at how I've done R-Horizontal and R-Vertical, you just do the same except with 6th and 7th axis (respectively)
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device