- Home /
Custom Hardware through Input Manager
I have been looking around trying to find any info on making a plugin or a .Net library that will allow me to use a custom piece of hardware through the input manager. What I want to do is take, say a head tracker and write some code to make it compatible with the input manager.
The goal is write one line of code to control the camera rotations based on the input manager. This will allow me setup the input manager so I can use the mouse, the arrows or the head tracker to rotate the camera. The benefit to this is if someone doesn't have a head tracker they can use the mouse to rotate the camera and I don't have to write special conditions to check if the hardware is present.
Is there way to write a plugin or library that follows some set of rules to be compatible with the input manager? All of the tracking devices out there have APIs to make it easy to use in a library or a plugin but I can't find anything about making it usable through the input manager. I would really like find out if this is possible because it can save time prototyping new hardware and eliminate special hardware logic.
Answer by thelackey3326 · Sep 13, 2011 at 05:55 PM
Unity does not currently provide a way to create a custom input device. I've added a feature request in the Wishlist/Feedback, but it doesn't have very many votes. I think this feature is a huge weak spot that reduces Unity's candidacy as a development platform in markets that don't exactly fit into the same mold as commercial video games.
Here's a link to the Wishlist. Please upvote!
Expose Input system for custom devices
Hardware that the OS does not see as a game input device (joystick/gamepad), a keyboard, or a mouse will not be "seen" by the Unity Input Manager and will require a plugin. My suggestion would be to create an event system that will send out input changes from all relevant devices and have your object subscribe to that event. Or, you could wrap all valid input devices with a single class which would do its own polling, and then have your object poll that class.
Depending on how much time you have for development, a custom driver could probably be created to make your input device look like a game controller at the OS level. Unity would then likely treat it as any other joystick device.
I was afraid that was the answer. I wanted to avoid writing the drivers for different hardware devices but figured more then likely I would have to write my own hardware input system. It just makes sense to have generic system for all hardware inputs so you can swap out new devices without change your code.
Input seems to be one of the more ignored systems in Unity. The available workarounds also tend to be platform specific and/or incompatible with the web player. Hopefully this will be addressed at some point.
If my answer was satisfactory, would you please "accept" it?
Answer by ShawnFeatherly · Jan 12, 2018 at 04:18 AM
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
how to get a custom built controller/joystick working with unity game? 1 Answer
Make custom input devices available to scripting via "Input" 2 Answers
Thrust controller (hardware) as input in Unity 0 Answers
Create an input module to support exotic input devices 1 Answer
Use of volume hardware keys on Android? 0 Answers