2008年11月22日 星期六

Wiimote and WiimoteLib

Motion Sensor
The motion of the remote is sensed by a 3-axis linear accelerometer with the direction like the picture shown.

Calibration

The zero points, and gravity values, for the three accelerometer axes, are stored near the start of the Wiimote's flash memory.

Rumble

Rumble is provided via motor with an unbalanced weight attached inside the Wiimote which can be activated to cause the controller to vibrate.


Speaker

The Wiimote has a small low-quality speaker, used for short sound effects during gameplay.
Speaker is unavailable in WiimoteLib becuase of unknown format.

WiimoteLib

If you wish to use multiple Wiimotes, instantiate a WiimoteCollection object, call the FindAllWiimotes method to initialize it, and then use each individual Wiimote object in the collection as a separate instance.

WiimoteCollection wc = new WiimoteCollection();
wc.FindAllWiimotes();

foreach(Wiimote wm in wc)
{
wm.WiimoteChanged += wm_WiimoteChanged;
wm.WiimoteExtensionChanged += wm_WiimoteExtensionChanged;

wm.Connect();
wm.SetReportType(InputReport.IRAccel, true);
}

Data can be retrieved from the API in two ways: events and polling. In event mode, one must subscribe to the WiimoteChanged event as shown above. Then, when data is sent from the Wiimote to the PC, an event will be posted to your event handler for processing in your application. If you elect to not use the event model, you may simply retrieve state information at any time from the WiimoteState property of the Wiimote class.

Report Types

The library currently supports only a handful of the many report types the Wiimote is capable of producing, however the ones that are implemented are enough to get all required data for the Wiimote and all current extensions. Specifically, these reports are:

  • Buttons - Button data only
  • ButtonsAccel - Button and accelerometer data
  • IRAccel - Button, accelerometer and IR data
  • ButtonsExtension – Button and extension data
  • ExtensionAccel - Button, accelerometer and extension data
  • IRExtensionAccel - Button, accelerometer, extension and IR data

The report type can be set by calling the SetReportType method using the appropriate report type and whether or not you would like the data to be sent continuously or only when the state of the controller has changed.

Extensions

There are currently three Wii extensions supported by the library: the Nunchuk, the Classic Controller, and the Guitar Hero controller. If you wish to use these, you must setup an event handler for the WiimoteExtensionChanged event. When this event is called, you can check the event argument to determine if an extension was inserted or removed, and what type extension was inserted. In this event handler, you will need to change the report type with the SetReportType method to one that supports extension data, otherwise the data will not be returned to you.

沒有留言: