Basic Program structure

Dec 13, 2011 at 2:49 PM

Hello everyone,

I actually just want to get the coordinates from the 4 wiiremots tracked infrared points.

I started learning C++ new and i came from PHP.

Now I never really worked object orientated, so I am totally confused about how things go in the WiimoteTest Program.

How can I just have the present IR coordinates in an array in realtime, Like the stand in the window form of the wiimote test programm?

using System;
using WiimoteLib;

void main() {
    Wiimote mywm =  new Wiimote();
   // i dont know how it could go further perhaps a while loop which //is always true and puts the data in an array but i dont know how to //access it

I know that it is a really dumb point of view I have, but i dont need more than just the values which i want to send via OSC after i processed them in a procedual c ++ programm.
What can i do to understand the system i want to use. I very much respect this work even though i couldnt use it yet. so please give me some advice = )

If some of my english is weird, excuse me.


Dec 13, 2011 at 4:49 PM

This is not a C++ library, it is a managed library for use with .NET and C#/VB.  You will not be able to use this from C++ code.

Dec 13, 2011 at 7:06 PM

Okay I know, i just meant that i started with c++ before I now have to use c#. So I still have the same question to ask.

Dec 13, 2011 at 7:08 PM

Ah, ok.  My best advice to you would be to look at the WiimoteTest source code included in the distribution.  There you'll see how to connect to the Wiimote and hook up and event to get data when the Wiimote state has changed.  C# typically deals with an event-model interface vs. the procedural model you'd be used to with C++.

Dec 14, 2011 at 10:43 AM
Edited Dec 14, 2011 at 10:43 AM

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WiimoteLib;

namespace WindowsFormsApplication1
    public partial class Form1 : Form
        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            // create a new instance of the Wiimote    
            Wiimote wm = new Wiimote();

            // setup the event to handle state changes
            wm.WiimoteChanged += wm_WiimoteChanged;

            // connect to the Wiimote   

            // set the report type to return the IR sensor and accelerometer data (buttons always come back)   
            //wm.SetReportType(Wiimote.InputReport.IRAccel, true);

        void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args)
            // current state information
            WiimoteState ws = args.WiimoteState;

            // write out the state of the A button    
            if (ws.ButtonState.A) label1.Text = "jo";

        private void label1_Click(object sender, EventArgs e)


So this is my next try to get something interactive, now the compiler doesnt know the InputReport part of the SetReportType method, whats wrong with this?

The other problem is that the window closes everytime i push the a button I never see the label text "jo";

Thank you for the support!


Dec 19, 2011 at 6:10 PM

InputReport.IRAccel is not part of the Wiimote namespace/object.  It's just a public enum, so just use it directly.  SetReportType(InputReport.IRAccel);

As for the form closing, you're likely hitting the issue where the app will 'splode when you try to update the UI from a background thread, which that event posts on.  Take a look at the WiimoteTest code and find the BeginInvoke code.  You'll need to post any UI updates to the main thread using the BeginInvoke method, which you'll see used in the sample.