[GiiMote] Initializing GiiMote

0 views
Skip to first unread message

Sam

unread,
May 20, 2009, 9:55:36 AM5/20/09
to gii...@googlegroups.com
In my last post I discussed the GiiMote constructor which sets up the new object when it is created. Today I’d like to talk about the function which actually creates the new GiiMote object: “gm_init”. This initialization function is called by the extension in Game Maker and by the script “gmInit.m” in MATLAB. It should always be the first function called in the library after it is loaded.
double gm_init()
{
/* First we check to make sure GiiMote is not already initialized, and if it is, we return the error code –1.0 */
    if (!GiiMote::initialized)
    {
/* Here we try to create a new instance of GiiMote, and if an error is thrown we return the error code 0 */
        try
        {
            gcnew GiiMote();
        }
        catch(...)
        {
            return ( 0 );
        }
    }
    else
    {
        return ( -1.0 );
    }
/* Finally we return weather the initialization was a success or not by returning the initialized variable as a double. */
    return ( (double)GiiMote::initialized );
}


--
Posted By Sam to GiiMote at 5/20/2009 09:55:00 AM
Reply all
Reply to author
Forward
0 new messages