Detecting X360 controllers

So, I found out that if you plug an wired X360 controller will work just like a regular Ouya controller. Is there a way to detect if the controller is an X360 one? So far I only got InputDevice.getName(), which gives the descriptive name of the controller, and I'm not sure if it's reliable.
«1

Comments

  • MommysBestGamesMommysBestGames Posts: 56Member
    Good question, important to know if users have access to the Touchpad or not.

    -Nathan, MBG Twitter
    Check out Pig Eat Ball on Facebook!
  • goodhustlegoodhustle Posts: 144Member
    On a larger scale, it would be great to find out if the ODK will map or provide a way for end users to map all joysticks to the OUYA controls, so that we only have to work through the OuyaController class (instead of everyone providing their own support for varying groups of devices). 

    I really prefer that to the current hacky solution of using regular Android input and sniffing device names to figure out what keycodes map to what OUYA virtual button.


    Beast Boxing Turbo - OUYA Launch Title!
  • Jack_McslayJack_Mcslay Posts: 100Member
    But if you do sniff different keycode names, there is a good clue to what controller the player is using. The problem is that you can't do that with the X360 controller because it already maps the keycodes to the ones used on Ouya, so the only way to be sure if a controller is not an ouya controller is if the player presses start/back buttons, which ouya doesn't have
  • goodhustlegoodhustle Posts: 144Member
    @Jack_Mcslay I would actually prefer it if the OUYA would take care of mapping any controller that was plugged in, either through automatic detection or through a system setting. Would really reduce the headache of having to sniff and remap ourselves.
    Beast Boxing Turbo - OUYA Launch Title!
  • DreamwriterDreamwriter Posts: 768Member
    The trick there is that you might want to do part of it yourself anyways, so your game can say "Press A" instead of "Press O" if the player is using an Xbox 360 controller instead of an OUYA controller.
  • apLundellapLundell Posts: 35Member
    I agree that I would prefer OUYA to automagically remap XBox (and PS3?) controllers so they match the Ouya Controller.

    ... But I also agree with Dreamwriter, that it'd be nice to be able to find out which controller they've got.


    @apLundell   <-- Follow me!
  • newmessagenewmessage Posts: 42Member
    If we look closer, the OUYA controller will look very similiar to XBox 360 controller.

    But, we what we need to find out is not its look, but how the OUYA and Controller handle its input.

    - Button 'O' -->> keycode 96 -->> scanValue 97
    - Dpad Up -->> keycode 19 -->> scanValue  312

    and so on...


    many thanks
    -sb

  • goodhustlegoodhustle Posts: 144Member

    If we look closer, the OUYA controller will look very similiar to XBox 360 controller.

    But, we what we need to find out is not its look, but how the OUYA and Controller handle its input.

    - Button 'O' -->> keycode 96 -->> scanValue 97
    - Dpad Up -->> keycode 19 -->> scanValue  312

    and so on...


    If you let OuyaController do the work, it takes care of mapping the XBOX 360 controller to the OUYA buttons. Personally, I like letting the OUYA staff do this work. :)

    What we're talking about in this thread is being able to detect that someone's on a 3rd party controller to handle it as a special case.
    Beast Boxing Turbo - OUYA Launch Title!
  • Jack_McslayJack_Mcslay Posts: 100Member
    Just yesterday I tested a steering wheel and the mapping is totally crazy, with the pedals mapping to the second analog, and a lot of buttons mapping to the same keycodes. I think they need to do some work to ensure regular USB controllers work well and are able to be determined which type/model they are. Adding the capability of discoreving the vendorId/productId/driver (is it an Ouya controller? X360? PS3? Wii? HID?) would be great
  • rumplestilzkenrumplestilzken Posts: 181Member
    Will the Ouya map a wireless controller using the Wireless kit for pc?
  • Jack_McslayJack_Mcslay Posts: 100Member
    Most likely. I don't know if anyone has tested it though
  • DreamwriterDreamwriter Posts: 768Member
    edited February 2013
    Even on PC in Windows an XBox 360 wireless kit doesn't do beans without installing a special driver, so I seriously doubt the OUYA will work with one out-of-the-box.  Even when that controller is hooked up via USB, it only uses the USB cable for power, it still communicates to its receiver wirelessly.
    Post edited by Dreamwriter on
  • ThinksquirrelThinksquirrel Posts: 20Member
    Actually, the OUYA works just fine with wireless controllers + the wireless kit. Tested that just the other day.
  • rumplestilzkenrumplestilzken Posts: 181Member
    NICE! Now i am really excited! haha.
  • rumplestilzkenrumplestilzken Posts: 181Member

    Even on PC in Windows an XBox 360 wireless kit doesn't do beans without installing a special driver, so I seriously doubt the OUYA will work with one out-of-the-box.  Even when that controller is hooked up via USB, it only uses the USB cable for power, it still communicates to its receiver wirelessly.
    From what i read, the Ouya controller was heavily based off of the 360 controller. Even sending a long of the same codes internally, so i am not so surprised that the wireless adapter was specifically supported.
  • PuzzlPuzzl Posts: 98Member
    Have a look inside /system/usr/keylayout
    You will find the input devices drivers already present on the OUYA.

    Last one is ours -> Vendor_2836_Product_0001.kl
    extract:
    #
    # OUYA Game Controller
    #

    key 0x130    BUTTON_A
    key 0x133    BUTTON_B
    key 0x131    BUTTON_X
    key 0x132    BUTTON_Y

    # Button "LB" maps to BUTTON_L1.
    key 0x134    BUTTON_L1
    # Button "RB" maps to BUTTON_R1.
    key 0x135    BUTTON_R1

    We already have support right out of the box for many controllers as we reported some weeks ago:
    - XBox 360 USB Controller;
    - XBox 360 USB Wireless Controller;
    - Sony Playstation(R)3 Controller;
    - Wii Remote (WiiMote), Nunchuk and Classic Controller;
    - OnLive Wireless Controller;
    - Logitech Dual Action Controller;
    - Logitech Gamepad F310;
    - Logitech Rumble Gamepad F51;
    - Logitech Wireless Gamepad F710;
    - Thrustmaster T Mini Wireless;
    - Saitek Gamepad.

    And keyboards too:
    - Logitech Revue Wireless keyboard;
    - Motorola Bluetooth Wireless Keyboard;
    - Apple Wireless Keyboard.

    Last but not least, full support for the Logitech G25 Racing Wheel - Steering Wheel, Accelerator / Brake / Toggles under wheel /Gear shift, everything works.

    The current OUYA SDK limits you; one can get full and proper support of those controllers if you ditch/extend it. Each device sends a string id when requested indeed, and that can be trusted; an OUYA game controller will report "OUYA Game Controller" when requested, and so on. Simple matter to know what controller you're talking to, and match the key layout accordingly - even if as @goodhustle said, it would be better to have a unified solution in the SDK - but the current implementation lacks. Alas, at least we have freedom of choice.
  • SpoonThumbSpoonThumb Posts: 426Member
    I just got hold of an xbox360 wireless controller, but I can't seem to get it to pair. I've tried going into the OUYA bluetooth settings and searching for devices whilst the OUYA is visible to nearby bluetooth devices and holding down the wireless connect button on the 360 controller. But so far, no luck. Is there something else I should be doing?
  • KonajuGamesKonajuGames Posts: 560Member
    The previous comments about the Xbox 360 wireless controller mentioned using it with the PC USB receiver (required because the Xbox 360 wireless controller uses a custom protocol).
  • SpoonThumbSpoonThumb Posts: 426Member
    That's kinda disappointing then, since my game ideally requires 4 controllers (but very few people will have 4 OUYA controllers). Since there is only one USB slot on the OUYA, I assume that limits things to one 360 controller? Or can many connect to the one dongle? Also what about PS3 controllers? Do they have to be connected by USB as well?
  • Jack_McslayJack_Mcslay Posts: 100Member
    I believe the dongle can connect several controllers, and the PS3 controller is bluetooth
  • DreamwriterDreamwriter Posts: 768Member
    edited April 2013
    PS3 controllers are awesome with OUYA - you can pair them on the normal OUYA pairing screen by just plugging them into USB, and then you don't need the USB cable. And they act like native OUYA controllers, complete with Home button (that you can hold to exit to system menu, unlike OUYA dev controllers). The button key codes don't quite match up, so games have to be programmed for them, but the joystick axes work out-of-the-box, and a surprising amount of games do support PS3 controllers already (I'm adding PS3 controller support to my game in my next update).
    Post edited by Dreamwriter on
  • SpoonThumbSpoonThumb Posts: 426Member
    PS3 controllers are awesome with OUYA - you can pair them on the normal OUYA pairing screen by just plugging them into USB, and then you don't need the USB cable. And they act like native OUYA controllers, complete with Home button (that you can hold to exit to system menu, unlike OUYA dev controllers). The button key codes don't quite match up, so games have to be programmed for them, but the joystick axes work out-of-the-box, and a surprising amount of games do support PS3 controllers already (I'm adding PS3 controller support to my game in my next update).
    Ah hah! That's what I was missing with the PS3 controllers. Need to do some work to properly support it though as the analogue sticks work very differently to OUYA (left stick seems to only produce a move event on really strong / big movements, whilst right stick gives constant movement)

    I wonder how many people have the xbox360 usb dongle? I'm going to have to go buy one now as I bought a controller without one >.<

  • HicsyHicsy Posts: 177Member
    i think its technically a windows wireless (controller) receiver... They report different names... but the button codes are the same. I have one - i bought it bundled with a controller pretty cheap. It supports 4 360 controllers and 2 headsets no problems. And yes, it is required. The USB play n charge cables only carry DC power :-(

     PS3 controller support is really beginning to excite me though :-) I think i will have start experimenting with this too!
    Can't find aapt.exe? Temp fix: Copy another one from 'android_sdk/build-tools/17.0.0' back to your 'platform-tools'
           -=Hicsy=-
    PM me        Facebook

  • PuzzlPuzzl Posts: 98Member
    :) Some news for you guys.
    http://www.pocket-lint.com/news/119164-ouya-works-xbox-360-ps3-controllers-wirelessly
    We showcased Yummy Circus @GDC on OUYA on PS3 controllers (and OUYA, Moga, and Nyko controllers as well).
    http://phandroid.com/2013/03/28/yummy-circus-ouya-video/
    Auto mapping included in Yummy Circus - you can mix any controllers :)
  • MagnesusMagnesus Posts: 304Member
    Could you share the settings (device names, button codes, axis codes) for all those controllers you support? That would help other developers enormously.

  • PuzzlPuzzl Posts: 98Member
    edited April 2013
    @Magnesus -> see our previous post in this very thread starting with "Have a look inside /system/usr/keylayout". All the info you require is there for you to work with. You'd then need to override the top views of your project (onKeyDown, onTouchEvent etc) and match the controller string ids/accordingly.
    Post edited by Puzzl on
  • DreamwriterDreamwriter Posts: 768Member
    Question: how exactly do you start using a wired XBox 360 controller with the OUYA?  I got a third-party USB controller, plugged it into USB, and the home button starts flashing.  But then it doesn't control the OUYA interface at all, no matter what I do.  Am I missing a step?  My game apparently has the buttons mapped wrong on an XBox 360 controller, so I'd like to fix that.
  • MagnesusMagnesus Posts: 304Member
    Puzzl said:
    @Magnesus -> see our previous post in this very thread starting with "Have a look inside /system/usr/keylayout". All the info you require is there for you to work with. You'd then need to override the top views of your project (onKeyDown, onTouchEvent etc) and match the controller string ids/accordingly.
    I don't have OUYA... Could someone send me the file? My e-mail: [email protected]

  • Jack_McslayJack_Mcslay Posts: 100Member
    Question: how exactly do you start using a wired XBox 360 controller with the OUYA?  I got a third-party USB controller, plugged it into USB, and the home button starts flashing.  But then it doesn't control the OUYA interface at all, no matter what I do.  Am I missing a step?  My game apparently has the buttons mapped wrong on an XBox 360 controller, so I'd like to fix that.
    It should be working out-of-the-box and work 100% in some games. Your controller must have a different vendorId/productId and that Ouya fails to identify as a X360 controller, so I guess you might have to buy an official controller
  • MagnesusMagnesus Posts: 304Member
    OK. I might be a little lost here: so OUYA is automatically detecting controllers and binding their button and axis codes to the ones OUYA controller uses. Am I right? That way developers don't need to do anything to support them, right?

Sign In or Register to comment.