From c10ae6bcbad402e9b93598ac566220d253f7eb56 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 25 May 2011 14:42:05 -0500 Subject: [PATCH] Re-organize and comment the new functionality --- src/wiiuse.h | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/wiiuse.h b/src/wiiuse.h index da1f6e0..2fe5dba 100644 --- a/src/wiiuse.h +++ b/src/wiiuse.h @@ -688,6 +688,26 @@ typedef struct wiimote_t { WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ } wiimote; +/** @brief Data passed to a callback during wiiuse_update() */ +typedef struct WiimoteState_t { + WCONST int uid; + WCONST byte leds; + WCONST float battery_level; + WCONST struct vec3b_t accel; + WCONST struct orient_t orient; + WCONST struct gforce_t gforce; + WCONST struct ir_t ir; + WCONST uint16_t buttons; + WCONST uint16_t buttons_held; + WCONST uint16_t buttons_released; + WCONST WIIUSE_EVENT_TYPE event; + WCONST int state; + WCONST struct expansion_t expansion; +} WiimoteState; + +/** @brief Callback type */ +typedef void (*wiiuse_update_cb)(struct WiimoteState_t* wm); + /** * @brief Loglevels supported by wiiuse. */ @@ -758,6 +778,15 @@ WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); /* events.c */ WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); +/** + * @brief Poll Wiimotes, and call the provided callback with information + * on each Wiimote that had an event. + * + * Alternative to calling wiiuse_poll yourself, and provides the same + * information struct on all platforms. + */ +WIIUSE_EXPORT extern int wiiuse_update(struct wiimote_t** wm, int wiimotes, wiiuse_update_cb callback); + /* ir.c */ WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); @@ -773,29 +802,6 @@ WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* w /* this function not currently implemented... */ WIIUSE_EXPORT extern void wiiuse_set_wii_board_calib(struct wiimote_t *wm); -/* wiiuse.c harts API */ -typedef struct WiimoteState_t { - WCONST int uid; - WCONST byte leds; - WCONST float battery_level; - WCONST struct vec3b_t accel; - WCONST struct orient_t orient; - WCONST struct gforce_t gforce; - WCONST struct ir_t ir; - WCONST uint16_t buttons; - WCONST uint16_t buttons_held; - WCONST uint16_t buttons_released; - WCONST WIIUSE_EVENT_TYPE event; - WCONST int state; - WCONST struct expansion_t expansion; -} WiimoteState; - -typedef void (*wiiuse_update_cb)(struct WiimoteState_t* wm); - -WIIUSE_EXPORT extern int wiiuse_update(struct wiimote_t** wm, int wiimotes, wiiuse_update_cb callback); - -/* end harts API */ - #ifdef __cplusplus } #endif