/** * @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; }
/** * @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; }
/** * Shutdown api. */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_shutdownApi (JNIEnv *env, jobject obj) { wiiuse_shutdown(); }