Hey OUYA Devs, >> SCROLL TO BOTTOM TO FIND THE NEWEST VERSION
or better:
HEAD OVER TO THE NEW THREADI read a lot of questions about controllers and during the last days fought myself through the new Ouya Unity Input (and before that through the Ouya legacy input). Thanks to Tim's great support the new input framework becomes better every day. It not only works on the OUYA but also solves a lot of controller mapping issues on other platforms. Tim has done an awesome job there. Still the examples have some (minor) bugs and the setup can be somehow confusing. That's why I thought, we devs should contribute to the plugin and upload our solutions.
Here is a proposal for a nice helper script. Right-Click to save as OuyaInput.cs to your disc.
I had a close look on Tim's
ShowUnityInput.cs and the connected
OuyaCommonExample.cs . In order to implement that stuff in our ongoing project I stripped these scripts down (killing all the example stuff) to a barebone static class that you can directly copy into a project and use instead of Unity's Input class. Most of this stuff is a direct copy of Tim's example, but I isolated the core code, commented it, fixed some axis invert issues and added new access methods. The static class now
mirrors Unity's Input class closely on offers identical getters.
You can access the controller data via:OuyaInput.GetAxis(string ouyaMapping, OuyaSDK.OuyaPlayer player)
OuyaInput.GetButton(OuyaSDK.OuyaPlayer player, OuyaSDK.KeyEnum ouyaButton)
OuyaInput.GetButtonDown(OuyaSDK.OuyaPlayer player, OuyaSDK.KeyEnum ouyaButton)
//NEWOuyaInput.GetButtonUp(OuyaSDK.OuyaPlayer player, OuyaSDK.KeyEnum ouyaButton)
//NEW// The new methods are returning true just for the frame the button goes down or up.
// So they mirror Unity's Input.GetButtonDown() and Input.GetButtonDown().// In contrast to OuyaInput.GetButton() these can be used to retreive down/up EVENTS.Examples:// get the value for a left joystick's x-axis:OuyaInput.GetAxis("LY", OuyaSDK.OuyaPlayer.player1)
// get the button state for a button on Ouya's O-button position (eg. XBOX360 A-button):OuyaInput.GetButton(OuyaSDK.OuyaPlayer.player1, OuyaSDK.KeyEnum.BUTTON_O)
// get the button down event for a button on Ouya's U-button position (eg. XBOX360 X-button):OuyaInput.GetButtonDown(OuyaSDK.OuyaPlayer.player1, OuyaSDK.KeyEnum.BUTTON_U)
// get the button up event for the click press on the right joystick:OuyaInput.GetButtonUp(OuyaSDK.OuyaPlayer.player1, OuyaSDK.KeyEnum.R3)
In addition you want to call OuyaInput.updateJoystickList() in your FixedUpdate() method!This makes sure that new joysticks are found or unplugging is covered.
Setup:1. Just import the OujaSDK core package to your project.
(Plugins/Android, Ouya/SDK, Ouya/ProjectSettings, LitJson, ProjectSettings)2. Check out the Menu >> Windows >> Open Ouya Panel and set it up (see Tim's videos).
3. Click Menu >> OUYA >> Use Ouya Project Input Settings.
4. Drop the script provided here into your project scripts.
5. ACCESS OuyaInput. methods instead of Input. methods.
Known issues:The script is far from perfect (just a help for starters).
There still might be axis iversion issues that I did not discover (just fixed the ones i found).
GetButtonUp() and GetButtonDown() should not be called for the Triggers (they are analog and don't work based on Unty's Input.GetButtonDown() – they are treated like axis.
Credits:This script is mostly Tim's work. But as these legacy input and mapping issues are very confusing I thought it would be good to melt it down to one clean static class that can be used directly. I hope this script is not full of bugs and does not confuse anyone. If there are any issues with this code, please tell me and I will remove it.
Comments
Don't forget to uncheck the Legacy Input in the OuyaGameObject.
CLARK
by GoldenTricycle
Developer for CLARK / GoldenTricycle
Developer of OuyaInput Framework >> GIT
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
your ButtonDown() and ButtonUp() methods don't work for X360 DPAD because that gets info from Axis
to fix that you would have to create a button state manager for each of the timelines (Update, FixedUpdate, any others)
you need to normalize the axis inputs for playstation controllers
you need a better controller detection
you need a better way to detect connect/disconnect
for a console that is defined by having a controller ... all this should have been done months ago
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
great that this stuff did prove somehow usefull. I think to create a corner for community contributions would be awesome – GIT could be a good place for that (although I am not really into it yet). In that way we all improve the framework, fix bugs quicker and streamline the available stuff according to our needs. In a way it's open sourcing the Ouya Unity plugin, which could be the way to go for on open console. Of course there is always the issue of bringing all these contributions together, review and test...
For my part: I will have to finish some stuff for our presentation at E3. Afterwards I will collect all the proposals and feedback comming up in this discussion and continue my work on that convenient wrapper class. I think the methods you proposed should definately find their way into the code.
Hey and if anyone finds the time to implement more stuff into the script: PLAESE UPLOAD your improved versions here. We also have to solve these invert issues once and for all. On my MacOSX and the OUYA the Ouya controller delivers the correct values – as does the XBOX360 controller with Tattiebogle driver.
CLARK
by GoldenTricycle
Developer for CLARK / GoldenTricycle
Developer of OuyaInput Framework >> GIT
I had a closer look in the issue of inverted axis. I solved mine just my testing and adjusting manually in the OuyaInput.cs class. It's not much work but not cool if you don't have all the different controllers and platforms to test.
The mess comes from the Ouya Unity Input Settings we all use. In these settings there is a check box for axis inversion – now some are set and some are not. In the mapping methods I copied from Tim's example there are again adjustments for axis inversions (a bool added in the mapping). Well now we screw on these values twice – not good. In my underständing it's better to bring it all to one place – I would prefer the mapping method for there is a better overview there and no easy click manipulation.
Proposal: Let's remove all the check invert checks in the Input Settings and then test all controllers on all platforms (call for the community). If we collect the results we can do the adjustments via the bool in the convinient mapping method.
So: Up is positive / Right is positive
Let's test and collect all data to find out which controllers on which platform have inverted axis according to this convention. For testing please remove all checks in the Input Settings and all bool flags in the mapping method of OuyaInput.cs .
Example:
case "LY": axisName = string.Format("Joy{0} Axis 2", (int)player); invert = true; break;
invert = true has to be deleted in similar lines for testing.
CLARK
by GoldenTricycle
Developer for CLARK / GoldenTricycle
Developer of OuyaInput Framework >> GIT
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
as we are now done with our E3 stuff, I found some time to improve on the OuyaInput Framework.
I have opened up a new thread to get a fresh start there. I think this is justified as the scripts where completely recoded, tested and expanded. Please head over to:
NEW OuyaInput Framework
I am still posting the framework here to close this thread with our results
(right-click to download):
Updated to Version_0.02
Documentation
Core Unity Input Access
Barebone InputHandler (Starter Kit)
Input Tester example (GUI overlay)
Important Project Settings
Everything a Package
Hope that works for you – tell me. Cheers,
Matthias CLARK / GoldenTricycle
our Game >> CLARK
CLARK
by GoldenTricycle
Developer for CLARK / GoldenTricycle
Developer of OuyaInput Framework >> GIT
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].