This project has moved and is read-only. For the latest updates, please go here.

Can I get the connection status via WiimoteLib?

Jun 6, 2009 at 5:36 AM

Hi Brian, Hello all,

Now I'm writing a sample code for my book.

There are 2 questions.

(1)What does "Disconnect()" func contains?

 Can we terminate wiimote object just calling "wm.Disconnect();"?

 I think this function contains Dispose() but I'm not sure it is clean termination on .NET style coding.
 (I hope it is clean. No problem about memory leak, garbage collection, etc.)

(2) Connection status

I've tried to find to see the connection status (connected/disconnected) using WiimoteLib,
but I could not find it.

it is linking with the question(1)...

2-1: Application is trying to connect to a Wiimote using Connect() but it was failed.

2-2: When a Wiimote battery runs out during connection,

If the object has a "connected" status, it will be useful.

What do you think?

If you already implemented such a function of property. please tell me.


Best regards,



Jun 13, 2009 at 11:01 PM

1) Disconnect closes up the stream and handles.  Dispose just internally calls Disconnect.  You really only need to do this if you need to disconnect/reconnect in the same session.  It shouldn't leak if you just terminate the app without calling Disconnect first.

2) There is no "status" as you're describing.  It's either connected or it isn't.  I suppose I could add a simple Connected boolean, or ConnectionStatus enumeration, but about the only thing I can detect currently is connected or not.  I'm not sure the battery result is sensitive enough to know if that's what really caused the disconnection.

Jun 14, 2009 at 3:52 AM

Thanks Brian for your reply.

Here are my questions on this "Simplest WiimoteLib" code. It works fine.

// Simplest WiimoteLib sample by Akihiko SHIRAI

using System.Windows.Forms;
using WiimoteLib;

namespace WiimoteLibTest {
  public partial class Form1 : Form  { 
  Wiimote wm = new Wiimote();
  public Form1()    {
      Control.CheckForIllegalCrossThreadCalls = false;
      wm.WiimoteChanged += wm_callback; // I'm not sure I need do [-=] when I call Disconnect.
      wm.SetReportType(InputReport.ButtonsAccel, true);
      wm.Connect();  //if it fails, I would like to get error handles or bool...
  void wm_callback(object sender, WiimoteChangedEventArgs args) {
     WiimoteState ws = args.WiimoteState;
     wm.SetRumble(ws.ButtonState.A); //rumble it when [A] is pressed.
     if (ws.ButtonState.Home) {      /// for example,
      wm.Disconnect();               /// I want to do such a sudden disconnect like this. Do I need "Disconnect()"?
      System.Environment.Exit(1);    /// Now it can Exit by pressing [Home], it it okay?

My question was [-=] for WiimoteChanged, but it looks automatically when it disconnects. Right?

I think Dispose works well. (I'll try it again on C++..) 
Please add a bool for Connect(), thanks.

best regards,


Sep 8, 2011 at 4:31 PM

did that connection status make it into the library? i need it but it does not seem to be there, im using version, also instead of throwing a timeout execption when the battery is pulled you could throw some thing else that indicates that its not connected any more..

Mar 15, 2013 at 11:26 AM
Edited Mar 15, 2013 at 1:12 PM
Sorry replied to wrong thread!