- Home /
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.
Answer by St0fF · May 08, 2015 at 01:20 PM
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.
Answer by ShawnFeatherly · Jan 12, 2018 at 04:18 AM
I also posted this here.
If it's a HID device you can use https://github.com/mikeobrien/HidLibrary . 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 https://autohotkey.com/board/topic/38015-ahkhid-an-ahk-implementation-of-the-hid-functions/ It requires installing additional software on the machine.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Using Oculus headgear position as input. 0 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Object Deletion 2 Answers