Exemplo n.º 1
0
/**
 *	@brief Load the wiiuse library and initialize the function pointers.
 *
 *	@param wiiuse_file	The relative or absolute path to the wiiuse library file.
 *
 *	@return The version of the wiiuse library loaded.
 *
 *	@see wiiuse_shutdown()
 *
 *	If the version of wiiuse being used has a different API
 *	version as expected, this function will fail and return 0.
 */
float wiiuse_startup(char* wiiuse_file) {
	entry_func_t entry_func = NULL;

	if (!wiiuse_file)
		return 0;

	if (wiiuse_api)
		/* already loaded */
		return 0;

	/* load the module */
	wiiuse_mod = dlopen(wiiuse_file, RTLD_NOW);

	if (!wiiuse_mod)
		/* can not load module */
		return 0;

	/* get the entry point */
	entry_func = (entry_func_t)dlsym(wiiuse_mod, "wiiuse_main");

	if (!entry_func) {
		wiiuse_shutdown();
		return 0;
	}

	/* call the entry function */
	entry_func(&wiiuse_api);

	/* make sure the API versions are the same */
	if (CHECK_VERSIONS_EQUAL(wiiuse_api->api_version, WIIUSE_API_VERSION)) {
		wiiuse_shutdown();
		return 0;
	}

	/* set all the function pointers */
	wiimote_init			= wiiuse_api->_wiimote_init;
	wiimote_disconnected	= wiiuse_api->_wiimote_disconnected;
	wiimote_rumble			= wiiuse_api->_wiimote_rumble;
	wiimote_toggle_rumble	= wiiuse_api->_wiimote_toggle_rumble;
	wiimote_set_leds		= wiiuse_api->_wiimote_set_leds;
	wiimote_motion_sensing	= wiiuse_api->_wiimote_motion_sensing;
	wiimote_read_data		= wiiuse_api->_wiimote_read_data;
	wiimote_status			= wiiuse_api->_wiimote_status;
	wiimote_get_by_id		= wiiuse_api->_wiimote_get_by_id;
	wiimote_find			= wiiuse_api->_wiimote_find;
	wiimote_connect			= wiiuse_api->_wiimote_connect;
	wiimote_disconnect		= wiiuse_api->_wiimote_disconnect;
	wiimote_poll			= wiiuse_api->_wiimote_poll;

	return wiiuse_api->version;
}
Exemplo n.º 2
0
void selfboot(void *entry)
{
    void (*entry_func)(void) = entry;
    entry_func();
}
Exemplo n.º 3
0
/**
 *	@brief Load the wiiuse library and initialize the function pointers.
 *
 *	@param wiiuse_file	The relative or absolute path to the wiiuse library file.
 *
 *	@return The version of the wiiuse library loaded.
 *
 *	@see wiiuse_shutdown()
 *
 *	If the version of wiiuse being used has a different API
 *	version as expected, this function will fail and return 0.
 */
const char* wiiuse_startup(char* wiiuse_file) {
	entry_func_t entry_func = NULL;

	if (wiiuse_api)
		/* already loaded */
		return wiiuse_api->version;

	if (!wiiuse_file)
		return NULL;

	/* load the module */
	wiiuse_mod = dlopen(wiiuse_file, RTLD_NOW);

	if (!wiiuse_mod)
		/* can not load module */
		return NULL;

	/* get the entry point */
	entry_func = (entry_func_t)dlsym(wiiuse_mod, "wiiuse_main");

	if (!entry_func) {
		wiiuse_shutdown();
		return NULL;
	}

	/* call the entry function */
	entry_func(&wiiuse_api);

	/* make sure the API versions are the same */
	if (wiiuse_api->api_version != WIIUSE_API_VERSION) {
		wiiuse_shutdown();
		return NULL;
	}

	/* set all the function pointers */
	wiiuse_init					= wiiuse_api->_wiiuse_init;
	wiiuse_disconnected			= wiiuse_api->_wiiuse_disconnected;
	wiiuse_rumble				= wiiuse_api->_wiiuse_rumble;
	wiiuse_toggle_rumble		= wiiuse_api->_wiiuse_toggle_rumble;
	wiiuse_set_leds				= wiiuse_api->_wiiuse_set_leds;
	wiiuse_motion_sensing		= wiiuse_api->_wiiuse_motion_sensing;
	wiiuse_read_data			= wiiuse_api->_wiiuse_read_data;
	wiiuse_write_data			= wiiuse_api->_wiiuse_write_data;
	wiiuse_status				= wiiuse_api->_wiiuse_status;
	wiiuse_get_by_id			= wiiuse_api->_wiiuse_get_by_id;
	wiiuse_set_flags			= wiiuse_api->_wiiuse_set_flags;
	wiiuse_set_smooth_alpha		= wiiuse_api->_wiiuse_set_smooth_alpha;
	wiiuse_set_ir				= wiiuse_api->_wiiuse_set_ir;
	wiiuse_set_ir_vres			= wiiuse_api->_wiiuse_set_ir_vres;
	wiiuse_set_ir_position		= wiiuse_api->_wiiuse_set_ir_position;
	wiiuse_set_aspect_ratio		= wiiuse_api->_wiiuse_set_aspect_ratio;
	wiiuse_set_bluetooth_stack	= wiiuse_api->_wiiuse_set_bluetooth_stack;
	wiiuse_set_orient_threshold	= wiiuse_api->_wiiuse_set_orient_threshold;
	wiiuse_find					= wiiuse_api->_wiiuse_find;
	wiiuse_connect				= wiiuse_api->_wiiuse_connect;
	wiiuse_disconnect			= wiiuse_api->_wiiuse_disconnect;
	wiiuse_poll					= wiiuse_api->_wiiuse_poll;

	printf("wiiuse v%s loaded ( http://wiiuse.net http://wiiuse.sf.net/ ).\n", wiiuse_api->version);

	return wiiuse_api->version;
}
Exemplo n.º 4
0
void selfboot(void *entry)
{
    void (*entry_func)(void *) = entry;
    entry_func(cb_header_ptr);
}
Exemplo n.º 5
0
static void 
__glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p )
{
     __GlutWindow *window;
     
     window = __glutFindWindow( e->window_id );
     if (!window) /* window was destroyed */
          return;
     
     switch (e->type) {
          case DWET_KEYDOWN:
               window->modifiers = __glutModifiers( e->modifiers );
               if (g_ignore_key_repeat && p) {
                    if (p->type       == DWET_KEYDOWN &&
                        p->window_id  == e->window_id &&
                        p->key_symbol == e->key_symbol)
                         break;
               }
               if (DFB_KEY_IS_ASCII( e->key_symbol )) {
                    if (keyboard_func) {
                         __glutSetWindow( window );
                         keyboard_func( e->key_symbol, e->x, e->y );
                    }
               }
               else {
                    int key = __glutSpecialKey( e->key_symbol );
                    if (key && special_func) {
                         __glutSetWindow( window );
                         special_func( key, e->x, e->y );
                    }
               }
               break;
          case DWET_KEYUP:
               window->modifiers = __glutModifiers( e->modifiers );
               if (DFB_KEY_IS_ASCII( e->key_symbol )) {
                    if (keyboard_up_func) {
                         __glutSetWindow( window );
                         keyboard_up_func( e->key_symbol, e->x, e->y );
                    }
               }
               else {
                    int key = __glutSpecialKey( e->key_symbol );
                    if (key && special_up_func) {
                         __glutSetWindow( window );
                         special_up_func( key, e->x, e->y );
                    }
               }
               break;
          case DWET_BUTTONDOWN:
               if (mouse_func) {
                    __glutSetWindow( window );
                    mouse_func( __glutButton( e->button ), GLUT_DOWN, e->x, e->y );
               }
               break;
          case DWET_BUTTONUP:
               if (mouse_func) {
                    __glutSetWindow( window );
                    mouse_func( __glutButton( e->button ), GLUT_UP, e->x, e->y );
               }
               break;
          case DWET_MOTION:
               if (e->buttons) {
                    if (motion_func) {
                         __glutSetWindow( window );
                         motion_func( e->cx, e->cy );
                    }
               }
               else {
                    if (passive_motion_func) {
                         __glutSetWindow( window );
                         passive_motion_func( e->cx, e->cy );
                    }
               }
               break;
          case DWET_ENTER:
               if (entry_func) {
                    __glutSetWindow( window );
                    entry_func( GLUT_ENTERED );
               }
               break;
          case DWET_LEAVE:
               if (entry_func) {
                    __glutSetWindow( window );
                    entry_func( GLUT_LEFT );
               }
               break;
          case DWET_SIZE:
               window->reshape = GL_TRUE;
               window->redisplay = GL_TRUE;
               break;
          default:
               break;
     }
}