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

Capturing Oculus + XBox360 Reserved Button Input

Discussion in 'AR/VR (XR) Discussion' started by Kivak, Jun 13, 2017.

  1. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Hi there,

    Is there any way to capture input from the Oculus Touch Controller's "Reserved" button and/or the Xbox360 controller's "(X)" button which bring up the Oculus Menu on Windows? I would like to throw up a window and pause the application when someone presses those buttons.

    An even better solution would be to prevent someone from being able to get to that Oculus menu at all. A "Kiosk mode" or something similar. Google searches for this don't bring up anything useful thus far (if someone has a way, I'd love to know!).

    Thanks!

    PS: I know the (X) button is mapped to button 15 on MacOS, but this is used on Windows which doesn't appear to have a similar mapping http://wiki.unity3d.com/index.php?title=Xbox360Controller
     
  2. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    X button is "button 2" on windows. As far as reserved buttons (home or volume) no you can't map those. Home should suspend the app though, so have you tried OnApplicationPause?

    For unity mappings if documentation is unclear you can always use my free asset to figure out the correct button.

    https://www.assetstore.unity3d.com/en/#!/content/43621
     
    Last edited: Jun 13, 2017
  3. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    Hi @greggtwep16

    Thanks for the reply! Sorry I was unclear about the xbox controller. I meant the (X) key which is in the center of the controller and pulls up the oculus menu -- assumed to be the same as the touch controller 'Reversed' key. I tried both OnApplicationPause and OnApplicationFocus to see if either of those worked - no success. But something like that would work if it were an option.

    Still open to ideas though... I am coming up empty.

    Your asset is excellent and I'm pocketing it for later as I've needed something like this before. Thanks!
     
  4. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    Ah, on the xbox 360 controller that is called the guide button, and on Xbox one that's called the home button. Neither is mapped to xinput on windows which is what Unity uses (surprised that Mac allows it but the OS isn't reserving it for anything there so I guess it make sense). It was reserved for things like turning on your computer/console or turning off the controller or showing the guide or home screen on Windows/Console. It also is not the same as reserved on the touch controllers according to the images in the link below.

    https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovrinput/

    I'm surprised that Unity doesn't suspend the app when you hit the oculus "reserved" key in windows. Is the app still active in the background? The app I would think should be suspended but not closed but it sounds like it's still active. You should be able to set a breakpoint in one of your scripts to know for sure. If its still active perhaps check to see what "run in background" is set to in player settings. I would think there would be a way for it to be suspended so that you could get OnApplicationPause to fire.
     
    Last edited: Jun 14, 2017
  5. Kivak

    Kivak

    Joined:
    Jul 13, 2013
    Posts:
    140
    @greggtwep16 Thanks for the suggestions. Unfortunately, I wasn't able to capture anything from those buttons or get any application response. However, I just happened to be looking into something else when I found some very handy booleans from OVRManager.

    I was able to successfully isolate instances where the user was in the menu by using this code:

    Code (CSharp):
    1. if( !OVRManager.hasVRFocus ) {
    2.     if( OVRManager.instance.isUserPresent ) {
    3.         // User is in Oculus Menu
    4.     } else {
    5.         // HMD is disabled (on the table)
    6.     }
    7. }
    Now I can throw up a screen that warns that the user is in the Oculus Menu. I can't stop it, but that's at least a way to know.