Nintendo wiimote C++ API

사용자 삽입 이미지

Wiimote C++ API

reference : http://wiiyourself.gl.tter.org
 
 

1. Include Wiimote header file to current source.
   #include “Wiimote.h”

2. Link Library files in Visual Studio.

  hid.lib
  setupapi.lib
  winmm.lib

 

3. Create Instance of Wiimote.

   -. create Instance of Wiimote (*.h)

   wiimote wiimote;

   -. Connect Wiimote (*.cpp)

 wiimote.CallbackTriggerFlags = NO_CHANGE;
 while(!wiimote.Connect(wiimote::FIRST_AVAILABLE))  Sleep(1000);
 if(wiimote.bExtension)  wiimote.SetReportType(wiimote::IN_BUTTONS_ACCEL_IR_EXT); // no IR dots
 else            wiimote.SetReportType(wiimote::IN_BUTTONS_ACCEL_IR);     //    IR dots
 wiimote.SetLEDs(0x01);

 

4. This is an example; how to use the Acceleration?
refer to the picture – each axis of motion sensor

 wiimote.RefreshState();  

 wiimote.Acceleration.X;

 wiimote.Acceleration.Y;

 wiimote.Acceleration.Z;

 

5. An example of using Button.(if the button has pushed, sets TRUE)

 wiimote.RefreshState();  
 if(wiimote.Button.Up())  g_fmY += 0.3f;
 if(wiimote.Button.Down()) g_fmY -= 0.3f;
 if(wiimote.Button.Left())   g_fmX -= 0.3f;
 if(wiimote.Button.Right())  g_fmX += 0.3f;
 if(wiimote.Button.Minus()) g_fY -= 0.3f;
 if(wiimote.Button.Plus()) g_fY += 0.3f;

 if(wiimote.Button.A()) g_fmZ -= 0.3f;
 if(wiimote.Button.B()) g_fmZ += 0.3f;

 if(wiimote.Button.Minus()) g_fY -= 0.03f;
 if(wiimote.Button.Plus()) g_fY  += 0.03f;

 

6. Vibration ON : True, vice versa

 wiimote.SetRumble(true);

 wiimote.SetRumble(false);

 

7. The LED indicates blue LED on Wiimote, Bit  unit. (use only Low Nibble)

  wiimote.SetLEDs(0x01);   // turn on only first LED

  wiimote.SetLEDs(0x00);   // whole LED OFF

 

8. Wiimote Disconnect at end of program.

// wii mote Disconnect
 wiimote.Disconnect();

Dr.kchris

Hello, I'm Dr.kchris, a neuroscience researcher. I love studying and trying new things and also love challenging myself. Have a great day! :)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.