Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question XR input mapping Vive wand sandwich/menu button

Discussion in 'XR Interaction Toolkit and Input' started by Wattosan, Dec 3, 2020.

  1. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    Hello,

    In the "XR input mappings" section found in the documentation we can see that the InputFeatureUsage primary button is set to the sandwich button on the Vive wand. Below the table we can see the text "(1) Sandwich button refers to the Vive menu button. This button is mapped to primaryButton, rather than menuButton, in order to better handle cross-platform applications.".

    How does it handle cross-platform applications better? Isn't it clear that the sandwich button is the default menu button for the Vive? Why is it called the primary button instead? It was really confusing that the "menu" feature does not mean the sandwich button on the Vive. We developed for Oculus first and later wondered why wouldn't our in-game menu open when the player presses the sandwich button on the Vive wand.

    So instead of just using a "menu" input feature across all platforms, we have to firstly discover which platform is currently used and then based on that either use the "menu" feature or the "primary" feature to open up an in-game menu. It seems more logical that the buttons, which by convention are used as menu buttons, would be a "menu" InputFeatureUsage, instead of "primary".

    Anyhow, how can we detect whether the controller is a Vive wand or an Oculus?

    Thanks!
     
  2. kittik

    kittik

    Joined:
    Mar 6, 2015
    Posts:
    565
    Hi,

    Did you find an answer to your question? I too am also looking for a way to define what sort of device is found.

    Thanks
     
  3. Wattosan

    Wattosan

    Joined:
    Mar 22, 2013
    Posts:
    456
    This is a quick solution

    Code (CSharp):
    1. private void InitializeMainDevice()
    2. {
    3.     List<InputDevice> allDevices = new List<InputDevice>();
    4.     InputDevices.GetDevices(allDevices);
    5.            
    6.     foreach (var inputDevice in allDevices)
    7.     {
    8.         if (inputDevice.characteristics.HasFlag(InputDeviceCharacteristics.HeadMounted))
    9.         {
    10.             Debug.Log("found device: " + inputDevice.name);
    11.             if (inputDevice.name.Contains("Oculus") || inputDevice.name.Contains("Quest"))
    12.             {
    13.                 Debug.Log("it is Oculus!");
    14.                 MainDevice = "Oculus";
    15.                 DeviceEvent.MainDeviceUpdated("Oculus");
    16.             }
    17.             else if (inputDevice.name.Contains("Vive"))
    18.             {
    19.                 Debug.Log("it is Vive!");
    20.                 MainDevice = "Vive";
    21.                 DeviceEvent.MainDeviceUpdated("Vive");
    22.             }
    23.             else if (inputDevice.name.Contains("Index"))
    24.             {
    25.                 Debug.Log("it is Index!");
    26.                 MainDevice = "Index";
    27.                 DeviceEvent.MainDeviceUpdated("Index");
    28.             }
    29.         }
    30.         // Debug.Log("-----NAME: " + inputDevice.name);
    31.         // Debug.Log("-characteristics: " + inputDevice.characteristics);
    32.         // Debug.Log("-manufacturer: " + inputDevice.manufacturer);
    33.         // Debug.Log("-subsystem: " + inputDevice.subsystem);
    34.         // Debug.Log("-serialNumber: " + inputDevice.serialNumber);
    35.         // Debug.Log("-isValid: " + inputDevice.isValid);
    36.     }
    37. }