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

Resolved [SOLVED!] How to access Thumb Touch capacitive sensor on Quest 2 using Oculus XR plugin?

Discussion in 'VR' started by battou, Sep 21, 2021.

  1. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    213
    Hi. Is there a way to access thumbrest sensor of Quest 2 controllers using Oculus XR Plugin? It should be OculusUsages.thumbrest, but it always returns false.

    Im using Unity 2019.4.16f1. Tried 1.6.1 and 1.10.0 versions of the Plugin.

    Can someone help me?
     
  2. Dark-Table

    Dark-Table

    Joined:
    Nov 25, 2008
    Posts:
    315
    If you're using QuestLink (i.e. Testing in the editor) you won't be able to read the thumbrest. This appears to be a limitation of QuestLink, maybe since it was designed for Quest 1, which doesn't have the thumbrest. (Might want to file a bug with Oculus?)

    If you're running on device (Android build) you should be able to read the thumbrest, but I can't remember if I've tried with OpenXR. It definitely works with the legacy OVRInput system.
     
  3. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    213
    Hi. Thanks. But Im using Oculus XR plugin. The Unity.XR.Oculus library.

    I can get Thumbrest using 1.6.1 version and device.TryGetFeatureValue(CommonUsages.thumbTouch, out thumb) code. But device.TryGetFeatureValue(Unity.XR.Oculus.OculusUsages.thumbrest, out thumb) always return false in any version. In versions above 1.6.1 even CommonUsages.thumbTouch dont work.((

    Can someone PLEASE tell me if Unity.XR.Oculus.OculusUsages.thumbrest is can be used somehow or is it bugged and dont work??
     
  4. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    213
    So Ive found a way to access ThumbTouch! Here is the code:

    Code (CSharp):
    1.  
    2.         InputDevice leftController = InputDevices.GetDeviceAtXRNode( XRNode.LeftHand);
    3.  
    4.         List<InputFeatureUsage> inputFeatures = new List<InputFeatureUsage>();
    5.         leftController.TryGetFeatureUsages(inputFeatures);
    6.         bool thumb;
    7.         leftController.TryGetFeatureValue(inputFeatures[11].As<bool>(), out thumb);
    8.         text.text = "11 ThumbTouch: " + thumb;
    Its 11 index for Left controller and 10 index for Right!
     
    Last edited: Sep 22, 2021
    falsevaccume likes this.
  5. BumbleByte

    BumbleByte

    Joined:
    Sep 3, 2016
    Posts:
    8
    Thanks for spending time on this battou, for me the indexing was right=11 left=12.
     
  6. Sonicfex

    Sonicfex

    Joined:
    Feb 23, 2019
    Posts:
    1
    Hello!!! I recommend use this if to avoid throw exception (from the function: .As<bool>)


    Code (CSharp):
    1.  
    2.         InputDevice leftController = InputDevices.GetDeviceAtXRNode( XRNode.LeftHand);
    3.  
    4.         List<InputFeatureUsage> inputFeatures = new List<InputFeatureUsage>();
    5.         leftController.TryGetFeatureUsages(inputFeatures);
    6.         bool thumb;
    7.  
    8.  
    9.   //Avoid the exception of wrong object type comparassion. (because inputFeatures list returns a bool and a Vector2)
    10.  if (inputFeatures[index].type == typeof(bool)){
    11.         leftController.TryGetFeatureValue(inputFeatures[11].As<bool>(), out thumb);
    12.         text.text = "11 ThumbTouch: " + thumb;
    13. }
    14.  
    15.