OuyaGameObject.onKeyUp() and others taking 4-40ms

BovineBovine Posts: 81Member
More profiling, the OuyaGameObject.onKeyUp() method is reporting anything from a few ms (which is somewhat unacceptable anyway) to 40ms which is terrible.

Any thoughts? :(

Comments

  • BovineBovine Posts: 81Member
    Maybe false alarm... I was doing a deep profile at the time
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Well technically that's old legacy. You want to use ShowUnityInput.cs which uses the Unity Input API.
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    Hmmmm, darn. I'll think about ripping that out and plugging the new thing in then...
  • BovineBovine Posts: 81Member
    Tim, is there a video for using this new system?

    Thanks
    Ian H
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    I didn't make a video explicitly, but I will.

    In the meantime in your initial scene with OuyaGameObject, turn off the UseLegacy flag.

    And then use Unity Input API normally.


    If you try to follow my ShowUnityInput example it expects you to call OuyaExampleCommon.UpdateJoysticks to update the joystick list of names in an update loop. And then you can use my example mappings.

    ~Tim Graupmann
    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].
  • ClarkGameClarkGame Posts: 74Member
    Hey Tim,
    it would be absolutely great if you could do this video – also explaining the background behind your mapping framework. Witha ll that legacy examples and ToDos in the code the system is pretty messy now and hard to grasp. This could help us to solve issues (for example when using other XBOX drivers that are not recognized at all). As the documentation is now, I couldn't figure it out and by chance ended up using legacy input.
    Matthias Titze
    CLARK

    by
    GoldenTricycle


    Developer for CLARK / GoldenTricycle
    Developer of OuyaInput Framework >> GIT


  • BovineBovine Posts: 81Member
    I think the system in general is pretty messy as you first have to understand how the Unity controllers work. I don't so any 'complete' guide would help jump start refactoring to the new low-latency system :D
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Yeah I'll do a video of the examples. It's in the plans....
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    I would add that it's the unity controller system that's the start of the complexity and maybe mess is not the right word :D
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    20 minute video encoding and incoming...
    ~Tim Graupmann
    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].
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    edited June 2013
    Unity - Example - ShowUnityInput - Part 1
    Post edited by tgraupmann on
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    You're a star, Tim!
  • BovineBovine Posts: 81Member
    edited June 2013
    Tim, great stuff. So I think the confusion is the Unity way has you define the functional input where best practise is to map all available inputs and have a translation layer as you have in your common cs that takes inspects the relevant raw input for a given controller and returns that mapping it to a specific function of the OUYA controller.

    I see XBox well supported here, is there a set of pre-baked PS3 mappings or do I need to burn those myself, using the raw values to create the relevant section for the name of my PS3 controller device?

    When the mappings are set up, I should expect the virtual controller to move with changes in the editor, right?

    Thanks
    Ian H



    Post edited by Bovine on
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    If you use the OuyaExampleCommon like the example then you need switch statements for ps2/ps3 controllers to handle those controller mappings.

    It is an example. However, Marco/I have been talking about moving most of the OuyaExampleCommon input mapping code into OuyaInputManager which would still be cross-platform. Plus you'd also get event based input, and you could use the Unity input API.

    That way if you have multiple input objects it just has to check the input API once and notify the subscribed objects for state changes.
    ~Tim Graupmann
    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].
  • ClarkGameClarkGame Posts: 74Member
    Hey Tim,
    awesome video, explains a lot – you are great. Also the shitty Mac-XBOX driver is somehow included in the new code, which was my concern. Thank you very much for that. It seems that the OUYA Unity support is improving very much. I will try the new input out today. I know that you guys are working under a lot of pressure and do what you can (which is great). Still I would like to give you some opinions, how to improve the docs section on your developers portal:

    1. We game developers are now very much in a rush to provide our stuff for your E3 presentation and want to port for OUYA as quick as possible (I had four days, since I had the OUYA. I got everything done for the 29th of May but now I am stuck with the legacy input and its latency. So I am changing that stuff again. This could have been avoided if the legacy input was removed from your SDK and if the examples you can find on your downloaded package didn't use it. I worked myself through the examples, was confused by multiple input methods (which were not tagged as new or outdated at all) and finally chose the wrong. Now I scan through the forum and find out that there are two versions. That messes you up big time – especially if you don't have time to check changelogs and forums before. A starter package should be clean and simple. so, please throw out the legacy stuff or point it out clearly in your documentation or intro texts.

    2. Your video is great, but I believe that a developer new to the OUYA will be confused. When I started porting I was looking for a video that could show me how to implement a controller. Instead of scanning through the complex examples and analysing your code (again finding legacy stuff and messing up), I would propose a video where you start from scratch and implement a simple controller setup – let's say for moving a sphere around. That would show the beginner what he had to do, to get it done for his own project. Seeing your vedeo I now understand what's going on behind the scene (diving into Java...), but I am still wondering which scripts I need to include into my framework, how to set my own custom controller (in case the Mac one does not work) and which methods to use to get my input. My proposal is to do a step by step from scratch instead of diving into a complex example which has a lot of additional code for visual controller representation that you have to filter out. Example: you could have all the base code for a sphere that can be moved around. Now you want to add controller support – how do you do it. That is my case: You have a game already done for touch input. Now I need to add OUYA support, so what's the deal?

    3. Please add a simple method listing to you documentation (like the scripting reference in Unity or iTween). That would help a lot to figure out which methods to use and which ones to avoid for they are legacy input. I for myself tried to fix some errors, dived in your SDK scripts and stumbled over all the legacy methods, which I used.

    AGAIN THANKS FOR YOUR SUPPORT.
    I am not complaining here. I know that you have a lot to do and lot's of things need to be done in a rush and are for that reason WIP. I also appreciate your extremely quick responses in the forums: man, that last video was done nearly instantly after my request. So please don't get me wrong – the OUYA team is doing a great job. However I wanted to described the traps I fell in.

    Matthias Titze
    CLARK

    by
    GoldenTricycle


    Developer for CLARK / GoldenTricycle
    Developer of OuyaInput Framework >> GIT


  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    edited June 2013
    Thanks for the detailed feedback. And yes that's something I'll totally do. I'm in the process of creating content for a tutorial section that does what you describe for the unity engine, and non-unity engines.

    I should document the starter kit with a video and add a character with controller input.

    Instead of deleting the legacy input stuff, I can actually replace the implementation, clean it up, and then change it to also use the Unity input API. I was going to do that after E3.
    Post edited by tgraupmann on
    ~Tim Graupmann
    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].
  • ClarkGameClarkGame Posts: 74Member
    Cool, sorry I totally overlooked that your office must be burning now. Good luck with the E3. one of our devs will be there with our game for the Ouya. will you be there?
    This is our game, just for info. Submitted it to Bob and Kellee.
    http://forums.ouya.tv/discussion/1469/clark-save-nuclear-missiles-on-mars#latest
    Matthias Titze
    CLARK

    by
    GoldenTricycle


    Developer for CLARK / GoldenTricycle
    Developer of OuyaInput Framework >> GIT


  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    LOL in that case we were just talking over email. Game looks awesome. Can't wait to play!

    I personally don't expect to be at E3. I have a ton of cool videos to record for new cool knowledge I need to share with the community.
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    While I agree it isn't easy to understand the right workflow for gettings the controller working, there being a legacy and a low-latency, but I wouldn't yank it from the ODK just yet as some people may be using it and if they update their ODK they probably don't want to be forced to yank the legacy stuff there and then...
  • BovineBovine Posts: 81Member
    So I had to leave this and come back to it, and....  I'm a bit confused.

    Looking at the GetAxis() method, it seems that the code is:

    * Choosing what to do based on the upper case name of the controller
    * If we're on ANDROID and not in the editor, it selects one code path
    * Otherwise it selects the other

    So this suggests that if we're running on the device we could get different mappings appearing for a given controller than we would see when using the device in our dev environment.

    I also note hat there is a lot of string.Format(), which I image would lead to a lot of strings being created every frame that need garbage collection - is this likely to be the case?

    Thanks
    Ian H






  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    That's how it works because each platform has different mappings. The same controller will have different mappings on each device.

    If the string.Format is a performance concern or even a GC concern, we could put the string mapping into a lookup table and cache it.

    And then string.Format("Joystick{0} Axis{1}") is supposed to be 300 times faster than "Joystick" + 1 + " Axis + 1;
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    I've done some caching on this myself and made it a bit more OOP like and it's working well - I can use my PS3 controller in Unity and then the OUYA controller when a swap to the device and of course I could add other mappings.

    I was thinking of sharing it with you perhaps as I think it makes adding mappings and using the system a bit easier (but then I would say that, right?) :)
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    If you submit a pull requests against github they go to me to approve where I can review and accept.
    ~Tim Graupmann
    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].
  • BovineBovine Posts: 81Member
    edited June 2013
    Okay great - I'll tidy it up and submit it (at some point) it's new code rather than a re-factoring, it could have been a better design but it is a bit easier (for me at least) to get my head around it
    Post edited by Bovine on
Sign In or Register to comment.