Search Unity

Question How to I use IXboxOneRumble?

Discussion in 'Input System' started by KYL3R, Nov 21, 2020.

  1. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    135
    I want to let my Xbox ONE Controller's trigger vibrate. Not just the left/right motor.

    The corresponding Interface IXboxOneRumble offers the 4-parameter function:

    Code (CSharp):
    1. void SetMotorSpeeds(float lowFrequency, float highFrequency, float leftTrigger, float rightTrigger)
    And I am debugging it like this:
    Code (CSharp):
    1. var gamepad = XInputController.current;
    2. Debug.Log("type " + gamepad.GetType());
    3. if (gamepad.aButton.isPressed)
    4. {
    5.     Debug.Log("a pressed");
    6.     if (gamepad is IXboxOneRumble rumble)
    7.     {
    8.         Debug.Log("is IXboxOneRumble!");
    9.         rumble.SetMotorSpeeds(0f, 0f, 0f, 1f);
    10.     }
    11.     else if (gamepad is IDualMotorRumble rumble2)
    12.     {
    13.         Debug.Log("is IDualMotorRumble");
    14.         rumble2.SetMotorSpeeds(1f, 1f);
    15.     }
    16. }
    But it always says "IDualMotorRumble". Windows detects my controller as an actual xbox ONE controller.
    How do I use that IXboxOneRumble interface?
     
  2. FGallorini

    FGallorini

    Joined:
    Aug 2, 2018
    Posts:
    28
    I am interested too, there is no documentation about it and many games have this feature
     
  3. KYL3R

    KYL3R

    Joined:
    Nov 16, 2012
    Posts:
    135
    I mean I got curious because Sony added the Adaptive Triggers on the PS5. Then I realized Xbox One doesn't have Adaptive Triggers, but at least Trigger Vibration (for years!).
    I downloaded "Xbox Accessories App" and could successfully test the Trigger Motors. So Windows can do this. So should xinput.dll...

    When I connect my controller Unity even says "Xbox One Controller" and not just "xbox controller". So it correctly detects it. So I wonder why it doesn't work :/
     
    The_Swiss_Guy likes this.
  4. FGallorini

    FGallorini

    Joined:
    Aug 2, 2018
    Posts:
    28
    same story
     
  5. The_Swiss_Guy

    The_Swiss_Guy

    Joined:
    Jul 30, 2019
    Posts:
    3
    KYL3R likes this.
  6. rootCBR

    rootCBR

    Joined:
    Mar 10, 2018
    Posts:
    4
    So is this still not a thing? The documentation page for an old version of InputSystem has this comment in it:
    The current version of that page doesn't mention impulse triggers in the Xbox section anymore.
    In Unity's source on Github, as far as I can see, there are no references to IXboxOneRumble either.

    What's the deal? Why is there no communication on how to use impulse triggers?
     
    KYL3R likes this.
  7. nikescar

    nikescar

    Joined:
    Nov 16, 2011
    Posts:
    165
    The IXboxOneRumble.cs interface has been there since 2019 unchanged but I don't think it is used anywhere.

    Games like WRC 8 support the triggers on PC and it isn't UWP.

    I managed to get the trigger rumbling by putting X1nput.dll and Windows.Gaming.Input.dll in the Plugins folder. Problem is that rumble came through the triggers fine but you couldn't rumble the standard rumble motors anymore