Skip to content

Instantly share code, notes, and snippets.

@seaders
Created November 16, 2015 19:06
Show Gist options
  • Save seaders/97b5ea801704001a15d5 to your computer and use it in GitHub Desktop.
Save seaders/97b5ea801704001a15d5 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class InputScript : MonoBehaviour
{
float _lastLR;
void Start ()
{
UnityEngine.Apple.TV.Remote.reportAbsoluteDpadValues = true;
UnityEngine.Apple.TV.Remote.touchesEnabled = false;
}
void Update ()
{
float PadLR = Input.GetAxisRaw("Horizontal");
if(_lastLR != PadLR)
{
_lastLR = PadLR;
print("lr: " + PadLR);
}
checkKeys(
KeyCode.JoystickButton0, KeyCode.Pause,
KeyCode.Joystick8Button12, KeyCode.Joystick8Button13, KeyCode.Joystick8Button14, KeyCode.Joystick8Button15,
KeyCode.Joystick8Button4, KeyCode.Joystick8Button5, KeyCode.Joystick8Button6, KeyCode.Joystick8Button7,
KeyCode.Joystick8Button8, KeyCode.Joystick8Button9, KeyCode.Joystick8Button10, KeyCode.Joystick8Button11
);
checkButtons("A", "B", "X", "Y", "Left Stick", "Right Stick", "Dpad", "Pause", "L1/R1", "L2/R2");
}
void checkKeys(params KeyCode[] keyCodes)
{
foreach(KeyCode keyCode in keyCodes)
{
if( Input.GetKeyDown(keyCode) )
{
print("keycode " + keyCode.ToString() + " down");
}
}
}
void checkButtons(params string[] buttonNames)
{
foreach(string buttonName in buttonNames)
{
if( Input.GetButtonDown(buttonName) )
{
print("button " + buttonName + " down");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment