- Home /
WiimoteLib & Unity ?
Hi,
I'd like to know if it should be possible to use WiimoteLib, because I tried unsuccessfully.
I have the Unity standard edition, and WiimoteLib is a C# .NET dll.
I made this script to test :
using UnityEngine; using System.Collections; using WiimoteLib;
public class NewBehaviourScript : MonoBehaviour {
private Wiimote wm;
// Use this for initialization void Start () { wm = new Wiimote(); try { wm.Connect(); } catch ( System.Exception e ) { Debug.Log( e.ToString() ); } wm.SetLEDs( true, true, true, false ); } }
And anyhow it always return me these exceptions :
System.IO.IOException: Invalid handle. at System.IO.FileStream..ctor (IntPtr handle, FileAccess access, Boolean ownsHandle, Int32 bufferSize, Boolean isAsync, Boolean noBuffering) [0x00000] at System.IO.FileStream..ctor (IntPtr handle, FileAccess access, Boolean ownsHandle, Int32 bufferSize, Boolean isAsync) [0x00000] at System.IO.FileStream..ctor (Microsoft.Win32.SafeHandles.SafeFileHandle handle, FileAccess access, Int32 bufferSize, Boolean isAsync) [0x00000] at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (Microsoft.Win32.SafeHandles.SafeFileHandle,System.IO.FileAccess,int,bool) at WiimoteLib.Wiimote.OpenWiimoteDeviceHandle (System.String devicePath) [0x00000] at WiimoteLib.Wiimote.WiimoteFound (System.String devicePath) [0x00000] at WiimoteLib.Wiimote.FindWiimote (WiimoteLib.WiimoteFoundDelegate wiimoteFound) [0x00000] at WiimoteLib.Wiimote.Connect () [0x00000] at NewBehaviourScript.Start () [0x0000b] in D:\Sonny_Unity_Temp\Assets\Test\NewBehaviourScript.cs:14 UnityEngine.Debug:Log(Object) NewBehaviourScript:Start() (at Assets\Test\NewBehaviourScript.cs:18)
Thanks
Answer by Komodo · Mar 05, 2010 at 11:32 AM
Was Win32.SafeHandles the issue? The fact that Unity takes control over HID devices is OK, but for this particular case its just bad. I tried Uniwii, but behavior is still buggy and the API is still limited, which is a pity. Named Pipes doesn't work, so I reckon the only possible solution would be SQLlite, but that is not really elegant. Oh, well if it works it works.
Yeah the issue is actually the SafeHandles, I took notes about SQLite. Thanks for your help
Answer by tax · Aug 09, 2010 at 07:12 PM
Hi Guys,
I wrote Brian Peek, and his oppinion from the data available in this thread:
""" Reading through that thread, it appears Unity takes over HID devices and there's some kind of incompatibility with SafeHandles. Without a major rewrite of the library, there would be no way to get that to work. It may not be possible at all.
Sorry!
Brian """
Can someone inside Unity confirm this?
Kind regards
Jesper Taxbl
Answer by jonas-echterhoff · Feb 19, 2010 at 09:19 AM
Not a direct answer to your question (never tried the WiimoteLib), but there is the UniWii plugin for accessing the WiiMote in Unity. However, that is a native C++ plugin, so you won't be able to use it in web players.
If it's a c++ plugin he can't use it in his standard edition can he?
Ah, correct - I missed that part in the question.
Answer by StephanK · Feb 19, 2010 at 11:57 AM
Just guessing, but all those [0x00000]'s look like something's not initialized correctly to me. Haven't used or heard of WiimoteLib, but if it's a .net dll it should work.
Answer by Sonny22 · Feb 22, 2010 at 08:18 AM
Yep I thought the same thing all these zeros don't look good to me. Yeah it's a .NET dll, I'll try to check if my code is really good. Thks
Your answer
![](https://koobas.hobune.stream/wayback/20220612075404im_/https://answers.unity.com/themes/thub/images/avi.jpg)