Search Unity

Resolved Two identical joysticks and usages for Left/Right not being applied

Discussion in 'Input System' started by MuTuF, Oct 15, 2021.

  1. MuTuF

    MuTuF

    Joined:
    Jun 7, 2021
    Posts:
    2
    I have two identical AXIS T8311 Joysticks that I want to use to control two different levers that rotate on a pivot point depending on joystick orientation. Current problem is that either one of the joysticks control both levers when setting to just AXIS or Joystick Stick, or neither work when adding Usages. I have attempted to diffrentiate the joysticks with code found here and here, however, once I add "LeftHand"/"RightHand" (or whatever string I've tried), neither works. I'm also using the RegisterLayoutOverride to add the LeftHand and RightHand to Joysticks.

    This is part of my current code:

    Code (CSharp):
    1.        List<InputDevice> joysticks = new List<InputDevice>();
    2.  
    3.         foreach (InputDevice device in InputSystem.devices)
    4.         {
    5.             if (device.description.product == "AXIS T8311 Joystick      ") //Result: finds two joysticks
    6.                 joysticks.Add(device);
    7.         }
    8.  
    9.         InputSystem.AddDeviceUsage(joysticks[0], "LeftHand");
    10.         InputSystem.AddDeviceUsage(joysticks[1], "RightHand");
    upload_2021-10-15_13-6-37.png

    The joysticks do seem to have a usage of "LeftHand" when checked through joysticks[0].usages[0], however, neither joystick has a usage when looked through the Input Debugger.

    upload_2021-10-15_12-57-19.png

    upload_2021-10-15_12-57-41.png

    By using:

    Code (CSharp):
    1.        List<InputDevice> joysticks = new List<InputDevice>();
    2.  
    3.         foreach (InputDevice device in InputSystem.devices)
    4.         {
    5.            InputSystem.AddDeviceUsage(device, "UsageTest");
    6.         }
    Keyboard and Mouse do get a "UsageTest" Usages added, however, neither of the joysticks do. Any idea why this is? Could there be something obvious I'm missing?
     

    Attached Files:

    Last edited: Oct 15, 2021
  2. MuTuF

    MuTuF

    Joined:
    Jun 7, 2021
    Posts:
    2
    Just an update for if other people are having the same issue. Quick version of what I think was happening was that the usages were applied, but controllers were not paired to the user yet. When I moved the controller for the first time, the joysticks were paired, however, they didn't have a usage anymore. Refreshing the my InputLogic script then registered the devices again with the correct usages and worked from there on.

    Here's what I did before figuring out the above, in case some of it helped.
    I created a InputControlLayout for the AXIS T8311 so it wouldn't show up as an unsupported device, but that triggered 2 joysticks per connected joysticks (one that I'll call a phantom joystick), and the phantom joystick did not register any inputs, but showed up as a device. Adding a Usage Page section to my InputDeviceMatcher seemed to fix it.

    After some testing around, I randomly found that there were "Lost Devices" with the correct usages of the joysticks sometimes for the User. However, the Lost Devices section did not always show up. Wiggling the joystick or pressing a button paired it again to the user, but the now paired devices did not have a usage applied anymore.

    Turning my InputLogic script on and off in the editor added the usages again and from there figured out the rest. At least working for now. Is there some call for when devices are paired so I could more efficiently script it?
     
    bjornsyse likes this.