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

New Input System: Possible to prevent device from being recognized (or remove it completely)?

Discussion in 'Input System' started by okXR, Sep 24, 2021.

  1. okXR

    okXR

    Joined:
    Sep 24, 2021
    Posts:
    2
    We are using a third-party USB device called a Phidget Interface Kit. They offer a C# library to communicate with it. We can talk to it if we set our Unity project to use the old Input Manager, but if we switch to the new Input System or use both, then we get a persistent Resource Busy error when attempting to connect to it. It can't be connected to if it's already in use by anything else.

    We have tried calling RemoveDevice on it, but even once it has been removed, something inside Unity is holding a reference to it because we still get Resource Busy. We think this is what's causing our problem: "Note that Devices are not destroyed when removed. Device instances remain valid and you can still access them in code. However, trying to read values from the controls of these Devices leads to exceptions." We also tried calling FlushDisconnectedDevices after removing it but that didn't help either.

    We can't find code samples on how to destroy a device once it's been removed, or better yet how to never add it in the first place. Is there an intended hook to do this, and if so could you provide a sample of it?
     
  2. okXR

    okXR

    Joined:
    Sep 24, 2021
    Posts:
    2
    One more try. Any help appreciated.
     
  3. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    33
  4. simonkendrew

    simonkendrew

    Joined:
    Aug 31, 2017
    Posts:
    33
    I've just checked this issue again, it is still present in Unity 2022.3.5f1 & Input System 1.6.3.

    Is it possible for someone at Unity support to look into this issue and comment here? Many thanks.
     
    Last edited: Jul 24, 2023
  5. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    114
    Unfortunately, no, I don't think that's currently possible.

    Last I checked, at least on Windows, Unity will invariably open all HIDs it can get its hands on. There's means of suppressing them being turned into InputDevices but yeah, as you found, Unity will still hold on to the file descriptors for them and thus block others.

    Would be great if this could be influenced from the managed side such that any HID that isn't actively turned into an InputDevice (managed side) will also not be held on to from the native side. It's slightly complicated by the fact that this is an async process and an InputDevice may appear for a HID at a much later point than its discovery. Ideally, the native side would not actively *open* a HID until after the managed side has established a connection (i.e. it would only *report* the device's presence and open a channel and send events only once the device has been connected to an InputDevice). This would also help with the input system getting useless HID events for devices it's not interested in.