Search Unity

  1. How has 2019.2 and the beta been for you so far? Give us feedback in this thread.
    Dismiss Notice

Input System Update

Discussion in 'New Input System' started by Rene-Damm, Dec 12, 2017.

  1. rorylane

    rorylane

    Joined:
    Apr 10, 2013
    Posts:
    22
    Hi everybody. Is this worth using yet for a project using Vive?

    I'm working on a new Cross-Platform Input Module for AR/VR.

    As I got started on it, I became aware of this new Input System. It seems great conceptually, and appears to solve a lot of the issues that have forced me into the Cross-Platform Input-Module business in the first place.

    But, I've not gotten it to receive Vive Input, and it seems a little premature maybe to attempt to incorporate this new package into a real project. Then again, I'm unfamiliar with how it works, and it's possible I'm doing something wrong.

    I'm using Unity 2019.3.0a5 and a Package generated from the "develop" branch of the GIT Repo https://github.com/Unity-Technologies/InputSystem.git.

    I've tried most of the obvious Option Binding options available, which are somewhat nebulous.
    HR_Controller_Options.jpg
    In the Input Debugger, it lists the HTC Vive in the "Unsupported" category, but with several Device IDs with the "HTC" Prefix.

    Input_Debugger.jpg



    I can get mouse and keyboard input, but I haven't been able to register an event for anything generated from the Vive or the Vive Controllers.

    Is this worth pursuing, or should I check back in a few months from now?
     
    scvnathan likes this.
  2. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    238
    I have started using this and so far it seems to be a much better way to do things. The only thing i've always had in update is input which always caused problems for me. Now that this is possible I will have NOTHING in updates. This is just amazing.

    I would like to know how to do conditionals though. It seems like i have to make a separate interaction for every single possible thing which starts to create a ton of callbacks.

    How do you do this for example:
    Code (CSharp):
    1.     int minX = -120;
    2.     public static int maxX = 120;
    3.     int minZ = -200;
    4.     int maxZ = 110;
    5.     int multiplier = 100;
    6.     Vector3 v3Cam;
    7.  
    8.     void InitWASD()
    9.     {
    10.         v3Cam = Camera.main.transform.position;
    11.     }
    12.  
    13.     float CalculateDirection(float value, float min, float max)
    14.     {
    15.         if (Input.GetKey(KeyCode.LeftShift))
    16.             return Mathf.Clamp(value + (multiplier * 2 * Time.deltaTime), min, max);
    17.         else
    18.             return Mathf.Clamp(value + (multiplier * Time.deltaTime), min, max);
    19.     }
    20.  
    21.     float CalculateDirectionReverse(float value, float min, float max)
    22.     {
    23.         if (Input.GetKey(KeyCode.LeftShift))
    24.             return Mathf.Clamp(value - (multiplier * 2 * Time.deltaTime), min, max);
    25.         else
    26.             return Mathf.Clamp(value - (multiplier * Time.deltaTime), min, max);
    27.     }
    28.  
    29.     void WASDUpdate()
    30.     {
    31.         if (!BC_Singleton.Instance.SceneGlobals.InUpgrading)
    32.         {
    33.             if (Input.GetKey(KeyCode.D))
    34.             {
    35.                 var tempMaxX = maxX;
    36.                 if (BC_Singleton.Instance.SceneGlobals.IsBuildingMenuOpen)
    37.                     tempMaxX = maxX + 35;
    38.                 v3Cam.x = CalculateDirection(v3Cam.x, minX, tempMaxX);
    39.                 Camera.main.transform.position = v3Cam;
    40.             }
    41.             if (Input.GetKey(KeyCode.A))
    42.             {
    43.                 v3Cam.x = CalculateDirectionReverse(v3Cam.x, minX, maxX);
    44.                 Camera.main.transform.position = v3Cam;
    45.             }
    46.             if (Input.GetKey(KeyCode.W))
    47.             {
    48.                 v3Cam.z = CalculateDirection(v3Cam.z, minZ, maxZ);
    49.                 Camera.main.transform.position = v3Cam;
    50.             }
    51.             if (Input.GetKey(KeyCode.S))
    52.             {
    53.                 v3Cam.z = CalculateDirectionReverse(v3Cam.z, minZ, maxZ);
    54.                 Camera.main.transform.position = v3Cam;
    55.             }
    56.         }
    57.     }
    To be more specific, how would you handle shift?
    Also, how many callbacks do you think can be handled before a system starts to eat bricks?
     
  3. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    238
    I have successfully done this. Wow this is a better structure. Less methods + faster?
    Code (CSharp):
    1.     void InitWASD()
    2.     {
    3.         v3Cam = Camera.main.transform.position;
    4.     }
    5.  
    6.     float CalculateDirection(float value, float min, float max, float multiplier, Keyboard keyboard)
    7.     {
    8.         if (keyboard.leftShiftKey.isPressed)// Input.GetKey(KeyCode.LeftShift))
    9.             return Mathf.Clamp(value + (multiplier * 2 * Time.deltaTime), min, max);
    10.         else
    11.             return Mathf.Clamp(value + (multiplier * Time.deltaTime), min, max);
    12.     }
    13.  
    14.     private void OnWASD_performed(InputAction.CallbackContext obj)
    15.     {
    16.         var values = obj.ReadValue<Vector2>();
    17.         var keyboard = Keyboard.current;
    18.  
    19.         var tempMaxX = maxX;
    20.         if (BC_Singleton.Instance.SceneGlobals.IsBuildingMenuOpen)
    21.             tempMaxX = maxX + 35;
    22.  
    23.         v3Cam.x = CalculateDirection(v3Cam.x, minX, tempMaxX, values.x * 100, keyboard);
    24.         v3Cam.z = CalculateDirection(v3Cam.z, minZ, maxZ, values.y * 100, keyboard);
    25.  
    26.         Camera.main.transform.position = v3Cam;
    27.     }
    28.  
     
  4. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    1,042
    I've been testing recent development branch on 2019.3 now but I'm having issues with Logitech G25 wheel. My Thrustmaster TX servo works fine as HID device on new input system but logitech wheel gives me these errors when I try to use "listen" and use the G25 wheel:


    I also tested this on Input System's 0.2.10 preview using 2019.1.8 and there Logitech G25 didn't throw these errors but it didn't recognize any input I put to the wheel (despite it showing the controller on input debugger and recognizing if it was plugged in or out, altho need to mention I couldn't open the input debuggers device view for it).

    edit: I don't really need built-in DirectInput handling from new input system as I'm going to replace it with FFB wheel input lib anyway but I'd love to use the new input systems binding API for it. So this brings me to a new question:

    What is the easiest entry point for 3rd party/custom input? Is there some specific class that would be a good example when implementing this on your own (modifying input system itself for this is not an issue).
     
    Last edited: Jul 17, 2019 at 8:09 AM
  5. ZelekPL

    ZelekPL

    Joined:
    Nov 22, 2018
    Posts:
    1
    I would be interested in this as well. For instance, how would I start to add support for Magic Leap controller bindings?