I am looking for a guide on connecting WiiMote with Unity 5 as an Input device. I found this library here but I do not understand how to install it and what the prerequisites are for it to work.
Answer
Although DMGregory's answer is a really thorough and good I have found a different solution and more robust that suit's my needs. I have found a dll (which I cannot find the link currently but will upload somewhere and edit my answer to encompass the link) and using DLLImport and these functions
[DllImport ("UniWii")]
private static extern void wiimote_start();
[DllImport ("UniWii")]
private static extern void wiimote_stop();
[DllImport ("UniWii")]
private static extern int wiimote_count();
[DllImport ("UniWii")]
private static extern byte wiimote_getAccX(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getAccY(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getAccZ(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getIrX(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getIrY(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getRoll(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getPitch(int which);
[DllImport ("UniWii")]
private static extern float wiimote_getYaw(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonA(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonB(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonUp(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonLeft(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonRight(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonDown(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButton1(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButton2(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonPlus(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonMinus(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonHome(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getNunchuckStickX(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getNunchuckStickY(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getNunchuckAccX(int which);
[DllImport ("UniWii")]
private static extern byte wiimote_getNunchuckAccZ(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonNunchuckC(int which);
[DllImport ("UniWii")]
private static extern bool wiimote_getButtonNunchuckZ(int which);
I managed to interface with the WiiMote and get the functionality I need.
The original publisher of the dll is no longer supporting it, or don't care any more. I emailed them about it and they still have not replied after a few months. I found it though in a project hosted in google code (here). It's a full project with examples and the .dll.
EDIT Also keep in mind if you are to use this dll for a commercial application you will have to contact the original publisher to get licenced (if you manage to get a response from them). And also I had some issues using this dll while building on a 64-bit machine using 64-bit Unity (if it was built on a 32-bit machine everything was ok and it ran perfectly on both 64-bit and 32-bit)
No comments:
Post a Comment