Make custom input devices available to scripting via "Input"

Hi everybody,

I know this has been asked before, but it’s been a while since the last posts:

The answers all look the same: it’s not possible, you need to wrap it yourself and not use UnityEngine.Input.
Sadly, the wishlist-link from the first post cannot be found anymore. Since we reached Unity 5 already, has anything about this changed?

On the other note I need to describe my real needs: In my project there are several different types of pointer devices. We have an absolute pointing device (like a graphics-tablet), we have a Gaze-Tracker and we have relative pointing devices. Only one of those will/can be enabled at a time, but they should behave the same: giving a current pointer position just like a mouse.

I also want to mention: I would also create a native c++ plugin if that would be neccessary to do the trick and on the other hand restrict the target platform. It’s just a fact: having to use multiple different inputs non-unified to UnityEngine.Input simply seems like the wrong way to go.

Any good news on this would be greatly appreciated, maybe som Unity-Devs would care to make a statement?

Thanks a lot in advance.

As nobody cared to answer, I’ll answer myself.

The way to go in such a situation is pretty simple:

  • implement the new input devices in a way that works quite as standard input (like in a dll)
  • create a static class that will become your pendant to ‘Input’
  • feed that static class with your new custom input devices
  • create a Monobehaviour right next to your static class, which feeds the static class with necessary standard input via its ‘Update()’ function
  • create a GameObject that represents your custom input (utilizing mentioned Monobehaviour)
  • use your static class just as you’d have used ‘UnityEngine.Input’

I hope this’ll help others running into my problems.

I also posted this here.

If it’s a HID device you can use GitHub - mikeobrien/HidLibrary: This library enables you to enumerate and communicate with Hid compatible USB devices in .NET. . I tried this for GriffinPowermatUsb and found it works, but locks up the Unity3D editor. It may work fine for builds.

I ended up using AutoHotKey with this script AHKHID - An AHK implementation of the HID functions - Scripts and Functions - AutoHotkey Community It requires installing additional software on the machine.