When an object is created in C++ the objects constructor is called. The constructor sets up the initial state of the GiiMote object, giving variables their initial values, allocating memory, etc. Below is a commented version of the GiiMote classes current constructor which explains exactly what happens when the GiiMote library is loaded.
GiiMote()
{
/* Store a pointer to the current GiiMote instance so that it can be referenced by external functions. */
GiiMote::gm = this;
/* Now store the index at which the currently active Wii Remote resides in... */
this->wmIndex = 0;
/* ...the actual collection (fancy array) of Wii Remotes which are currently paired with the system. */
this->wc = gcnew WiimoteCollection();
/* This array contains the point at which each IR dot is currently located with respect to the display. */
ir_screen_pos = gcnew cli::array<Point>(0);
/* The following arrays store information about dead zones; that is, how far a joystick, trigger, infrared dot, etc. can change before that change is registered. */
joystick_dead_zone = gcnew cli::array<double>(0);
trigger_dead_zone = gcnew cli::array<double>(0);
accel_dead_zone = gcnew cli::array<double , 2>(0, 6);
/* Stores the current report type which determines how much and what data the Wii Remote reports on each update. */
report_type = gcnew cli::array<int>(0);
/* Should we continuously update the Wii Remote’s state, or only when something changes? */
continuous = gcnew cli::array<bool>(0);
/* The IR sensitivity levels are stored in this array. */
ir_sensitivity = gcnew cli::array<IRSensitivity>(0);
/* The previous position of each IR dot (used for tracking). */
ir_last_pos = gcnew cli::array<PointF, 2>(0, 4);
ir_last_raw_pos = gcnew cli::array<Point, 2>(0, 4);
ir_last_mid_pos = gcnew cli::array<PointF>(0);
ir_last_rawmid_pos = gcnew cli::array<Point>(0);
/* A call to wm_find_all populates the Wii Remote collection with data about each of the Wii Remotes currently paired with the system. */
wm_find_all();
/* Set the first connected Wii Remote to be the active remote. */
wm_set_using_val(-1);
/* The display height and width are stored and used in infrared pointer calculations. */
this->display_height = System::Windows::Forms::Screen::PrimaryScreen->Bounds.Height;
this->display_width = System::Windows::Forms::Screen::PrimaryScreen->Bounds.Width;
/* GiiMote is now fully initialized. */
GiiMote::initialized = true;
}
--
Posted By Sam to
GiiMote at 5/18/2009 06:59:00 PM