Can I use my own input device?

Hi,

My problem seems fairly simple. I am a research student at a Lab, and this lab has developed a haptic 3d input device. Naturally I am to do something with this device and Unity. I have DLLs to use in C# (using PInvoke).

So would it be possible to use both the device as a pointing device (like a 3D mouse) and an haptic device (force feedback) if I was to buy the Pro version of Unity? Can you add your own input device into unity?

Yes you can, provided A) you have Pro (which can use Plugins, and B) the project is a stand-alone executable (browsers have security limitations).

Here's a similar Question where I listed some sample code that might make it more clear: How to import Neurosky Mindset data into Unity

On second thought, that code might be misleading - Neurosky provides some boilerplate code in a C# file, that is required to call the .dll. If you are starting from scratch, you would have to write code to use the Plugin that looks something like this:

// This tells unity to look up the function FooPluginFunction inside the plugin named "PluginName"
[DllImport ("PluginName")]
private static extern float FooPluginFunction ();

And you can download Unity Pro Trial. The trial version is only valid for 30 days, but if this is a short, one-time project, that might be enough to complete it.

... A follow on...

I also am trying to link in a haptic device... I have it running on Android through bluetooth and windows through c/c++/and c# dlls

I understand that I should be able to get this running no problem with windows, but what about android or iphone?

Will Unity allow my code to connect to a bluetooth device and send and recieve packets?

If not could I do it if the device has an IP address with udp/tcp?

I have been able to call a objective-c dll from C# scripts thanks to the info you provided. However, I wish to receive callbacks from my C++ dll. I thought of using a delegate to catch the callbacks as I have done before, but I get errors saying I'm trying to JIT compile my delegate. Is there a way to get callbacks from a dll in unity?

Hi, sorry to budge in with another question relating to “using my own input device”. I am using a 3D input device, which I believe is similar to haptic, posted by simaldeff. I have the DDL in the plugin folder. I was able to read the data from the input device using the DLL API.

I am now experiencing this problem. When I move the device, the data I read and displayed using Debug.Log, lagged by about 1 second. This is not good because whatever I want to animate in Unity cannot respond to me instantanteously. I have no idea what causes the lagging.

I wrote another program in C++ to read the data from the same DLL and display it. Interestingly, there is no lagging at all. Seem like the problem is interaction between Unity and the DLL.

I have been looking through the forum for anyone with similar problem and any advice and pointers will be deeply appreciated. Thanks.