Balance board support?

Hey all,

So I’m trying to connect a balance board to unity…
I know i know…i’ve googled it a thousand times over and I keep seeing that people here and there found ways to do it…kinda…but nothing is working for me.
The frustrating thing is whenever I connect the board Unity pops up this little info blip telling me a Joystick has been connected and even recognizes its name as a Nintendo Balance Board…but no amount of fiddling…adjusting…plugin use…dll import…you name it…has gotten me anywhere close to being able to read input data from the board.

So now I’m turning to you, the Unity Community, in this hour of most desperate need…for help.

Any and all options are welcome. I’ve essentially got 24 hours to make this work before all hell breaks loose.

Items that have been tried:
WiiYourself
WiimoteLib
ReWired
WiiBalanceWalker (keyboard conversion is NOT an option. i need it to be used as a controller with axis)
vJoy
WiiBuddy (no windows support MAC only -_- )
Hybrids of multiple items above

You can have a look here. Maybe the Unity Indie VRPN Adapter plugin might help you to send data using sockets, which might be a easiest approach to get input data from external subroutines to Unity.

1 Like

Hi David. Thanks for the reply!
I took your mention of sockets and adapted the WiiBalanceWalker program to transmit over sockets and its working pretty well. The only issue I seem to have is properly handling the disconnect side to things…if and when the Balance Walker program stops transmitting data (as a result of being closed), I have a countdown that waits a fixed number of updates and then closes down the client…but I always get an error saying the socket is being used after being disposed…from what I can tell, the callback on beginread is not closing down like it should and keeps going even after the client.close() function is called. Ideas?

code snippets:

client received handler:

void client_Received(Client sender, byte[] data)
    {
        //data received from client

        if (data.Length > 0)
        {
            closeCount = 5000;
            //Debug.Log(Encoding.Default.GetString(data));

            //XAxis 152364 YAxis 123456

            sData = Encoding.Default.GetString(data);
        }
        else
        {
            closeCount--;
            Debug.Log("Client Received Irregular: \n" + Encoding.Default.GetString(data) + "\n" + sender.EndPoint.ToString());
            if (closeCount <= 0)
            {
                //l.Stop();
                c.Close();
                //sender.Close();
            }
        }
    }

callback:

void callback(IAsyncResult ar)
    {
        try
        {
            sck.EndReceive(ar);

            byte[] buf = new byte[8192];
            int rec = sck.Receive(buf, buf.Length, 0);

            if (rec < buf.Length)
            {
                Array.Resize<byte>(ref buf, rec);
            }

            if (Received != null)
            {
                Received(this, buf);
            }

            if (sck.Connected)
            {
                sck.BeginReceive(new byte[] { 0 }, 0, 0, 0, callback, null);
            }
        }
        catch (Exception ex)
        {
            Debug.LogError(ex.ToString());
            Close();

            if (Disconnected != null)
            {
                Disconnected(this);
            }
        }
    }

client close:

public void Close()
    {
        sck.Shutdown(SocketShutdown.Both);
        sck.Close();
    }

Also I should mention the code snippets are from the Unity side to things as I’m using Unity as the server end.

hmmm…now its not doing it…just to be safe, what is the proper way of shutting down a client server connection like this? specifically shutting down the client side and leaving the server side open for new connections?

You probably need to close the socket on the client side properly before shutting down. Something like socket.BeginDisconnect. :slight_smile:

There is a nice talk on Sockets from Unite 2012, maybe that helps.
http://unity3d.com/files/unite/2012/Unite2012-Unity_Network_Code_and_You.zip

Otherwise there are many tutorials around socket/multithreaded socket connections in the web, that should help a lot such as chat programming and general help :sunglasses:

THANK YOU! :slight_smile:

1 Like