Search Unity

Android TV ADT-1 Gamepad Input

Discussion in 'Android' started by thelackey3326, Aug 25, 2014.

  1. thelackey3326

    thelackey3326

    Joined:
    Sep 17, 2010
    Posts:
    34
    I poked around with the joystick settings and found pretty much all of the buttons. The buttons in the center are for system use, so they seem not to be mapped.

    See attached zip for .cs and InputManager.asset as a plain text. Of course, for OnGUI you'll need to have a GUI Layer on your camera!

    NOTE: Make sure that your axis names match those listed here in your Input Manager. Otherwise you won't get any axis input. Use the InputManager.asset in the zip in a test project. Please don't overwrite your InputManager.asset file in a project you're working on without a backup!

    Okay. Notice the peculiarities: buttons 6 & 7 are skipped; axes 9, 10, & 11 are skipped; axis 12 is a duplicate of 8, axis 13 is a duplicate of 7. Peculiar.


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4.  
    5. //Testing Android TV ADT-1 gamepad
    6. //    thelackey3326
    7. public class InputTest : MonoBehaviour
    8. {
    9.     private Dictionary<KeyCode, bool> m_JoystickButtons = new Dictionary<KeyCode, bool>();
    10.     private Dictionary<string, float> m_JoystickAxes = new Dictionary<string, float>();
    11.  
    12.  
    13.     void Start()
    14.     {
    15.         m_JoystickButtons.Add(KeyCode.JoystickButton0, false);
    16.         m_JoystickButtons.Add(KeyCode.JoystickButton1, false);
    17.         m_JoystickButtons.Add(KeyCode.JoystickButton2, false);
    18.         m_JoystickButtons.Add(KeyCode.JoystickButton3, false);
    19.         m_JoystickButtons.Add(KeyCode.JoystickButton4, false);
    20.         m_JoystickButtons.Add(KeyCode.JoystickButton5, false);
    21.         m_JoystickButtons.Add(KeyCode.JoystickButton8, false);
    22.         m_JoystickButtons.Add(KeyCode.JoystickButton9, false);
    23.  
    24.         m_JoystickAxes.Add("Joystick Axis X", 0.0f);
    25.         m_JoystickAxes.Add("Joystick Axis Y", 0.0f);
    26.         m_JoystickAxes.Add("Joystick Axis 3", 0.0f);
    27.         m_JoystickAxes.Add("Joystick Axis 4", 0.0f);
    28.         m_JoystickAxes.Add("Joystick Axis 5", 0.0f);
    29.         m_JoystickAxes.Add("Joystick Axis 6", 0.0f);
    30.         m_JoystickAxes.Add("Joystick Axis 7", 0.0f);
    31.         m_JoystickAxes.Add("Joystick Axis 8", 0.0f);
    32.         m_JoystickAxes.Add("Joystick Axis 12", 0.0f);
    33.         m_JoystickAxes.Add("Joystick Axis 13", 0.0f);
    34.     }
    35.  
    36.     void Update()
    37.     {
    38.         m_JoystickButtons[KeyCode.JoystickButton0] = Input.GetKey(KeyCode.JoystickButton0);
    39.         m_JoystickButtons[KeyCode.JoystickButton1] = Input.GetKey(KeyCode.JoystickButton1);
    40.         m_JoystickButtons[KeyCode.JoystickButton2] = Input.GetKey(KeyCode.JoystickButton2);
    41.         m_JoystickButtons[KeyCode.JoystickButton3] = Input.GetKey(KeyCode.JoystickButton3);
    42.         m_JoystickButtons[KeyCode.JoystickButton4] = Input.GetKey(KeyCode.JoystickButton4);
    43.         m_JoystickButtons[KeyCode.JoystickButton5] = Input.GetKey(KeyCode.JoystickButton5);
    44.         m_JoystickButtons[KeyCode.JoystickButton8] = Input.GetKey(KeyCode.JoystickButton8);
    45.         m_JoystickButtons[KeyCode.JoystickButton9] = Input.GetKey(KeyCode.JoystickButton9);
    46.  
    47.         m_JoystickAxes["Joystick Axis X"] = Input.GetAxis("Joystick Axis X");
    48.         m_JoystickAxes["Joystick Axis Y"] = Input.GetAxis("Joystick Axis Y");
    49.         m_JoystickAxes["Joystick Axis 3"] = Input.GetAxis("Joystick Axis 3");
    50.         m_JoystickAxes["Joystick Axis 4"] = Input.GetAxis("Joystick Axis 4");
    51.         m_JoystickAxes["Joystick Axis 5"] = Input.GetAxis("Joystick Axis 5");
    52.         m_JoystickAxes["Joystick Axis 6"] = Input.GetAxis("Joystick Axis 6");
    53.         m_JoystickAxes["Joystick Axis 7"] = Input.GetAxis("Joystick Axis 7");
    54.         m_JoystickAxes["Joystick Axis 8"] = Input.GetAxis("Joystick Axis 8");
    55.         m_JoystickAxes["Joystick Axis 12"] = Input.GetAxis("Joystick Axis 12");
    56.         m_JoystickAxes["Joystick Axis 13"] = Input.GetAxis("Joystick Axis 13");
    57.     }
    58.  
    59.     void OnGUI()
    60.     {
    61.         GUILayout.BeginArea(new Rect(50.0f, 50.0f, Screen.width - 50.0f, Screen.height - 50.0f));
    62.  
    63.         GUILayout.BeginHorizontal();
    64.         {
    65.             GUILayout.BeginVertical(GUILayout.Width(200.0f));
    66.             {
    67.                 foreach (KeyValuePair<KeyCode, bool> buttonState in m_JoystickButtons)
    68.                 {
    69.                     GUILayout.Label(buttonState.Key.ToString() + ": " + buttonState.Value.ToString());
    70.                 }
    71.             }
    72.             GUILayout.EndVertical();
    73.  
    74.             GUILayout.BeginVertical(GUILayout.Width(200.0f));
    75.             {
    76.                 foreach (KeyValuePair<string, float> axisState in m_JoystickAxes)
    77.                 {
    78.                     GUILayout.Label(axisState.Key + ": " + axisState.Value.ToString());
    79.                 }
    80.             }
    81.             GUILayout.EndVertical();
    82.         }
    83.         GUILayout.EndHorizontal();
    84.  
    85.         GUILayout.EndArea();
    86.     }
    87. }
    88.  
     

    Attached Files:

  2. thelackey3326

    thelackey3326

    Joined:
    Sep 17, 2010
    Posts:
    34
  3. NETRIDER

    NETRIDER

    Joined:
    May 29, 2013
    Posts:
    2
    thank you kindly!

    I've been waiting to get this working on my ADT-1's.
    I have to build from Ubuntu, yea?

    kick ass thread..thank you again!:)
     
    Last edited: Oct 21, 2014
  4. thelackey3326

    thelackey3326

    Joined:
    Sep 17, 2010
    Posts:
    34
    Well you are welcome kindly! I'm guessing that all of this will still work for those new Asus boxes that will be coming out soon.
     
  5. NETRIDER

    NETRIDER

    Joined:
    May 29, 2013
    Posts:
    2
    I'm hopeful for a smooth transition. I've heard good things about the Transformer series.

    I prefer Wacom graphics tablets and digitizers. Is there any wacom x asus action out of the box available (like samsung's sPen)?

    Also, do you remember how painful it was to port to Google TV circa 2012?

    https://developers.google.com/tv/android/docs/gtv_setup_android

    and

    https://developers.google.com/tv/android/docs/gtv_addon


    mention Linux as a prerequisite. TBT, I never fully exhausted myself with porting back then. But I'm excited to work across the Google platforms. Currently I'm working to port my current twin stick shooter Vast Cosmos to the platform.

    Here's a post I found about the Samsung Smart TV - http://blogs.unity3d.com/2014/08/20/unity-4-5-for-samsung-smart-tv/

    A user comments something along the lines of he wishes this was officially supported. Me too.


    So far, I've had trouble with gradle wizardry and this new Android Studio. TBT, I've been away from Unity3D since VGU Con late this summer. I left there feeling so inspired by all the talented geniuses who had great Unity wares to showcase.

    If you published any content using your code to the store or need legit QA, I'm here for YOU!

    YOUR GUIDANCE HAS BEEN A BLESSING ON THIS INCREDIBLE JOURNEY!!!
    again, THANK YOU!!!!!
     
  6. thelackey3326

    thelackey3326

    Joined:
    Sep 17, 2010
    Posts:
    34
    Oh this certainly isn't production code. To clarify, I've never really developed anything for a Google platform. I was just tinkering with the ADT-1 in my free time and I believe in sharing knowledge. The openness of the community is what makes Unity special.

    My apologies. Specifically, when I said "Asus boxes," I was thinking of the new Nexus Player, which apparently is made by Asus. I should probably have been more clear. But, it looks like the thing that the ADT-1 is to become. Just wishing that I had that little remote that comes with the Nexus Player!

    Good luck porting your game!