cancel
Showing results for 
Search instead for 
Did you mean: 

Unity's InputManager.asset - What Button ID do I use for the GearVR Controller's "Back" button?

justiceinc
Protege
I just began using the GearVR controller. Previously I was handling back button on the HMD with "joystick button 1" but this doesn't work on the GearVR Controller. So what must I add to my Input Manager to report this button in Unity's input system? I've searched for over an hour and can't seem to find this information, which is very frustrating!

I found this forum thread referencing a Unity_Integration_Guide.pdf that doesn't seem to exist now. I found a few similar-looking PDFs but despite being 100+ pages long do not contain anything about Unity's Input Manager.

I also found this great guide on the Unity website, but it only deals with the Touch Controllers and Oculus Remote.

So I'm at a dead end. Plz help, thanks.

3 REPLIES 3

justiceinc
Protege
I am aware of the OVRInput class, but using this will require a complete re-engineering of a very large application to support. It will also add complexity when testing on PC which I hope can be avoided. I initially assumed that, since the Gear HMD and Gear Controller both have a touchpad and back buttons, I could use at least that out of the box. Unfortunately this was not the case for multiple reasons.
  1. HMD Touchpad swipes are sent as DPad buttons, seemingly no such functionality exists on gear controller
  2. HMD sends touchpad's initial touch as mouse click 0, gear controller seems to send a mouse click any time your finger moves a certain distance (without breaking contact), which was totally unexpected
  3. HMD Back button raises an event which can be listened for in Unity (joystick button 1 i believe), but not for the gear controller
Num 3 was the main issue, but they're all interesting (and time-consuming) to learn about.

But what I really need answered is whether or not it is even possible to get the gear controller's back button as a joystick button, axis, *anything* that works in the Input manager. Then I could have a much easier time with my Input code. I'll once again link to this page, because a version of this page for GearVR Controller is all I need, really.

And if this turns out to be impossible, a tangental question - how do I get touchpad coordinates using OVRInput exclusively? I doubt that you would make it so that some input is ONLY accessible from unity's Input class and some input is ONLY accessible from OVRInput, but right now that's how it appears to me. Thanks for any guidance you can provide.

juanoldinho
Heroic Explorer
The following snippet from our documentation should provide more clarity:

A Gear VR touchpad swipe is not defined until the user removes their finger from the touchpad. Get()and GetDown() will return true on the frame that the user’s finger is pulled off, and GetUp() will return true the next frame. A Gear VR touchpad tap may be queried with Button.One/RawButton.Start, and a back button press may be queried with Button.Two/RawButton.Back.

The button mapping for the Gear VR controller can be found here (at the bottom of the page):
https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/#unity-ovrinput-gear...
Please tag me, @juanoldinho, in your forum post/response if you need immediate assistance or want additional support or context on an issue you are having with our software or integrations.

Having an issue with our platform, services, or integrations?

Try using our new bug tool to report this and receive emailed updates as we proceed to address it internally.

Woody3D
Expert Protege


Hi,

Welcome to the Oculus Developer Forums.

As I see you are using Unity as your game engine, have you considered using OVRInput to enable this behavior?

Please see the documentation here regarding OVRInput. Remember to remove Unity's input manager once you import OVRInput, as they will conflict.


Is there any way you could actually give some help when you respond? We spend a LOT of Money on your products..  We will b busy making you a Trillion Dollar Industry by 221..    What a Slap in the FACE!!  Sending people to the Sony Stereo-like 'whats in the box' Unity and Oculus documentation is about as mean as anything I ever heard of. He asked for help not to have a good laugh then a long cry!!  I am so surprised at the lacking and lackluster 2 sentence responses  from Oculus,.  What the ??   Did someone BREAK Unity Input Manager?  Why can't it just do it's thing with Touch buttons and thumbsticks?  Now even with Raw Button etc??

Could you please supply a small example BEFORE and AFTER Equivalent Scripts that incorporate Oculus Touch, and   'remove the Input manager as you say'... Show how a Input Manager script looked and how that same script would look if done for OVRInput manager and touch..  (((Is there a Oculus Input Manager like the Unity one where you select things and decide on 'axes'  etc?)))

 THIS IS ALL SO CONFUSING!  YOU GUYS HAVEN'T EVEN UPDATED THE TOOLS AND SDK ETC IN THE UNITY ASSET STORE FOR MONTHS AND MONTHS!!   WHY IN THE WORLD DIDN'T YOU GUYS JUST LET THE TOUCH WORK WITH INPUT MANAGER??  WHY ALL THIS EXTRA WORK?  3 MONTHS OF TRYING I AM NO CLOSER THAN DAY ONE GETTING THE TOUCH CONTROLLERS EVEN TO TRIGGER and FIRE!

THE EXAMPLES FROM INTEGRATION TOOLS WORK, BUT THEY ARE 100% COMPLETELY AND UTTERLY USELESS WITHOUT OLDER EXAMPLES OF THE SAME APPS. WITH THE ORIGINAL 
MOUSE/KEYBOARD./CONTROLLER  CODE TO COMPARE TO!!!  

THE GOOD DEVs OUT HERE ARE LIKE ME:
 1) SELF TAUGHT 
AND 2) LEARN BY REVERSE ENGINEERING.  
PLEASE HELP ME LEARN HOW I LEARN!!!!,..

BELOW WAS MY BEST BET :smile: 

I STARTED WITH THINGS LIKE THIS:

if (Input.GetMouseButtonDown(0)) {
   fireShot();
  }
--------------------------------------------------------------------------------------------------------
I CHANGED TO THIS HOPING IT WOLD WORK:
if (OVRInput.Get(OVRInput.RawButton.RIndexTrigger(0)) {
fireShot();
}

I AM IN THE SAME RUT AS THOUSANDS OF PEOPLE WHO LEARN LIKE I DO, BY REVERSE ENGINEERING,  AND TOTALLY STUCK WITH NO BEFORE / AFTER CODE THAT SHOWS SIMPLY AND  EXACTLY WHAT CHANGES BETWEEN AN OLD APP AND ONE UPDATED/CHANGED FOR TOUCH.  THERE IS NO POSSIBILITY FOR UNDERSTANDING WITH THE DOCUMENTATION, THEY JUST SAY WHAT EVERYTHING IS, LIKE  'SHOW AND TELL' FROM HELL, THEY DO NOT SAY HOW TO USE IT IN PRACTICE (OR I WOULD BE...)  IF YOU REALLY WANT TO HELP AND CHANGE THE WORLD OF VR,  CONVERT THIS SCRIPT BELOW TO TOUCH INPUT, 
 USING
LEFT TRIGGER TO FIRE, 
RIGHT TRIGGER TO THRUST (RIGHT GRIP FOR NEGATIVE THRUST)
RIGHT THUMBSTICK FOR PITCH AND YAW
ETC...
THEN I CAN TAKE THAT TO MY NEARLY 2,000 GAME DEV. YOUTUBE SUBSCRIBERS AND REALLY SHOW MYSELF AND THEM WHAT THE DIFFERENCE IS AND WHY WITH THE TOUCH...  PLEASE DO THIS THING FOR US!  I REPRESENT THOUSANDS OF PEOPLE  WHO ARE LEARNING TOGETHER WITH ME (MOSTLY CGI AND VISUAL FX, BUT NOW UNITY TOO)

I WISH THIS WAS AS EASY AS SETTING UP GRABABLES!!!

THANK YOU FOR YOUR TIME  SORRY FOR THE CAPS,.   HOWEVER I'M SCREAMING IN MY HEAD, AND NEAR SUICIDAL AFTER MONTHS OF 8 HOUR DAYS TRYING TO UNDERSTAND HOW TO SIMPLY GET TOUCH TRIGGER TO FIRE,   A THUMBSTICK TO TURN LEFT,.. ETC.,

"MAKE ROCKET GO NOW!" (Homer Simpson 1991)


using UnityEngine;
using System.Collections;
[System.Serializable]
public class PlayerFlightControl : MonoBehaviour
{
 //"Objects", "For the main ship Game Object and weapons"));
 public GameObject actual_model; //"Ship GameObject", "Point this to the Game Object that actually contains the mesh for the ship. Generally, this is the first child of the empty container object this controller is placed in."
 public Transform weapon_hardpoint_1; //"Weapon Hardpoint", "Transform for the barrel of the weapon"
 public GameObject bullet; //"Projectile GameObject", "Projectile that will be fired from the weapon hardpoint."
 //"Core Movement", "Controls for the various speeds for different operations."
 public float speed = 20.0f; //"Base Speed", "Primary flight speed, without afterburners or brakes"
 public float afterburner_speed = 40f; //Afterburner Speed", "Speed when the button for positive thrust is being held down"
 public float slow_speed = 4f; //"Brake Speed", "Speed when the button for negative thrust is being held down"
 public float thrust_transition_speed = 5f; //Thrust Transition Speed", "How quickly afterburners/brakes will reach their maximum effect"
 public float turnspeed = 15.0f; //"Turn/Roll Speed", "How fast turns and rolls will be executed "
 public float rollSpeedModifier = 7; //"Roll Speed", "Multiplier for roll speed. Base roll is determined by turn speed"
 public float pitchYaw_strength = 0.5f; //"Pitch/Yaw Multiplier", "Controls the intensity of pitch and yaw inputs"
 //"Banking", "Visuals only--has no effect on actual movement"
 
 public bool use_banking = true; //Will bank during turns. Disable for first-person mode, otherwise should generally be kept on because it looks cool. Your call, though.
 public float bank_angle_clamp = 360; //"Bank Angle Clamp", "Maximum angle the spacecraft can rotate along the Z axis."
 public float bank_rotation_speed = 3f; //"Bank Rotation Speed", "Rotation speed along the Z axis when yaw is applied. Higher values will result in snappier banking."
 public float bank_rotation_multiplier = 1f; //"Bank Rotation Multiplier", "Bank amount along the Z axis when yaw is applied."
 
 public float screen_clamp = 500; //"Screen Clamp (Pixels)", "Once the pointer is more than this many pixels from the center, the input in that direction(s) will be treated as the maximum value."
 
 [HideInInspector]
 public float roll, yaw, pitch; //Inputs for roll, yaw, and pitch, taken from Unity's input system.
 [HideInInspector]
 public bool afterburner_Active = false; //True if afterburners are on.
 [HideInInspector]
 public bool slow_Active = false; //True if brakes are on
 
 float distFromVertical; //Distance in pixels from the vertical center of the screen.
 float distFromHorizontal; //Distance in pixel from the horizontal center of the screen.
 Vector2 mousePos = new Vector2(0,0); //Pointer position from CustomPointer
 
 float DZ = 0; //Deadzone, taken from CustomPointer.
 float currentMag = 0f; //Current speed/magnitude
 
 bool thrust_exists = true;
 bool roll_exists = true;
 
 //---------------------------------------------------------------------------------
 
 void Start() {
 
  mousePos = new Vector2(0,0); 
  DZ = CustomPointer.instance.deadzone_radius;
  
  roll = 0; //Setting this equal to 0 here as a failsafe in case the roll axis is not set up.
  //Error handling, in case one of the inputs aren't set up.
  try {
   Input.GetAxis("Thrust");
  } catch {
   thrust_exists = false;
   Debug.LogError("(Flight Controls) Thrust input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Thrust' so the ship can change speeds.");
  }
  
  try {
   Input.GetAxis("Roll");
  } catch {
   roll_exists = false;
   Debug.LogError("(Flight Controls) Roll input axis not set up! Go to Edit>Project Settings>Input to create a new axis called 'Roll' so the ship can roll.");
  }
  
 }
 
 
 void FixedUpdate () {
  
  if (actual_model == null) {
   Debug.LogError("(FlightControls) Ship GameObject is null.");
   return;
  }
  
  
  updateCursorPosition();
  
  //Clamping the pitch and yaw values, and taking in the roll input.
  pitch = Mathf.Clamp(distFromVertical, -screen_clamp - DZ, screen_clamp  + DZ) * pitchYaw_strength;
  yaw = Mathf.Clamp(distFromHorizontal, -screen_clamp - DZ, screen_clamp  + DZ) * pitchYaw_strength;
  if (roll_exists)
   roll = (Input.GetAxis("Roll") * -rollSpeedModifier);
   
  
  //Getting the current speed.
  currentMag = GetComponent<Rigidbody>().velocity.magnitude;
  
  //If input on the thrust axis is positive, activate afterburners.
  if (thrust_exists) {
   if (Input.GetAxis("Thrust") > 0) {
    afterburner_Active = true;
    slow_Active = false;
    currentMag = Mathf.Lerp(currentMag, afterburner_speed, thrust_transition_speed * Time.deltaTime);
    
   } else if (Input.GetAxis("Thrust") < 0) {  //If input on the thrust axis is negatve, activate brakes.
    slow_Active = true;
    afterburner_Active = false;
    currentMag = Mathf.Lerp(currentMag, slow_speed, thrust_transition_speed * Time.deltaTime);
    
   } else { //Otherwise, hold normal speed.
    slow_Active = false;
    afterburner_Active = false;
    currentMag = Mathf.Lerp(currentMag, speed, thrust_transition_speed * Time.deltaTime);
    
   }
  }
    
  //Apply all these values to the rigidbody on the container.
  GetComponent<Rigidbody>().AddRelativeTorque(
   (pitch * turnspeed * Time.deltaTime),
   (yaw * turnspeed * Time.deltaTime),
   (roll * turnspeed *  (rollSpeedModifier / 2) * Time.deltaTime));
  
  GetComponent<Rigidbody>().velocity = transform.forward * currentMag; //Apply speed
  
  if (use_banking)
   updateBanking(); //Calculate banking.
  
 }  
  
  
 void updateCursorPosition() {
  mousePos = CustomPointer.pointerPosition;
  
  //Calculate distances from the center of the screen.
  float distV = Vector2.Distance(mousePos, new Vector2(mousePos.x, Screen.height / 2));
  float distH = Vector2.Distance(mousePos, new Vector2(Screen.width / 2, mousePos.y));
  
  //If the distances are less than the deadzone, then we want it to default to 0 so that no movements will occur.
  if (Mathf.Abs(distV) < DZ)
   distV = 0;
  else
   distV -= DZ;
   //Subtracting the deadzone from the distance. If we didn't do this, there would be a snap as it tries to go to from 0 to the end of the deadzone, resulting in jerky movement.
   
  if (Mathf.Abs(distH) < DZ)
   distH = 0; 
  else
   distH -= DZ;
   
  //Clamping distances to the screen bounds. 
  distFromVertical = Mathf.Clamp(distV, 0, (Screen.height));
  distFromHorizontal = Mathf.Clamp(distH, 0, (Screen.width)); 
 
  //If the mouse position is to the left, then we want the distance to go negative so it'll move left.
  if (mousePos.x < Screen.width / 2 && distFromHorizontal != 0) {
   distFromHorizontal *= -1;
  }
  //If the mouse position is above the center, then we want the distance to go negative so it'll move upwards.
  if (mousePos.y >= Screen.height / 2 && distFromVertical != 0) {
   distFromVertical *= -1;
  }
  
 }

 void updateBanking() {
  //Load rotation information.
  Quaternion newRotation = transform.rotation;
  Vector3 newEulerAngles = newRotation.eulerAngles;
  
  //Basically, we're just making it bank a little in the direction that it's turning.
  newEulerAngles.z += Mathf.Clamp((-yaw * turnspeed * Time.deltaTime ) * bank_rotation_multiplier, - bank_angle_clamp, bank_angle_clamp);
  newRotation.eulerAngles = newEulerAngles;
  
  //Apply the rotation to the gameobject that contains the model.
  actual_model.transform.rotation = Quaternion.Slerp(actual_model.transform.rotation, newRotation, bank_rotation_speed * Time.deltaTime);
 
 }
 
 void Update() {
 
  //Please remove this and replace it with a shooting system that works for your game, if you need one.
  if (Input.GetMouseButtonDown(0)) {
   fireShot();
  }
 
 }
 
 
 public void fireShot() {
 
  if (weapon_hardpoint_1 == null) {
   Debug.LogError("(FlightControls) Trying to fire weapon, but no hardpoint set up!");
   return;
  }
  
  if (bullet == null) {
   Debug.LogError("(FlightControls) Bullet GameObject is null!");
   return;
  }
  
  //Shoots it in the direction that the pointer is pointing. Might want to take note of this line for when you upgrade the shooting system.
  if (Camera.main == null) {
   Debug.LogError("(FlightControls) Main camera is null! Make sure the flight camera has the tag of MainCamera!");
   return;
  }
  
  GameObject shot1 = (GameObject) GameObject.Instantiate(bullet, weapon_hardpoint_1.position, Quaternion.identity);
  
  Ray vRay;
  
  if (!CustomPointer.instance.center_lock)
   vRay = Camera.main.ScreenPointToRay(CustomPointer.pointerPosition);
  else
   vRay = Camera.main.ScreenPointToRay(new Vector2(Screen.width / 2f, Screen.height / 2f));
   
   
  RaycastHit hit;
  
  //If we make contact with something in the world, we'll make the shot actually go to that point.
  if (Physics.Raycast(vRay, out hit)) {
   shot1.transform.LookAt(hit.point);
   shot1.GetComponent<Rigidbody>().AddForce((shot1.transform.forward) * 9000f);
  
  //Otherwise, since the ray didn't hit anything, we're just going to guess and shoot the projectile in the general direction.
  } else {
   shot1.GetComponent<Rigidbody>().AddForce((vRay.direction) * 9000f);
  }
 
 }
 
}