Improve balance board, use stdint.h

This commit is contained in:
Ryan Pavlik
2010-07-22 18:42:04 -05:00
parent db3c0e1e7b
commit dde5bb965a
9 changed files with 804 additions and 815 deletions

View File

@@ -53,6 +53,8 @@
#define WCONST const
#endif
#include <stdint.h>
/* led bit masks */
#define WIIMOTE_LED_NONE 0x00
#define WIIMOTE_LED_1 0x10
@@ -231,7 +233,7 @@ struct gforce_t;
* library when the wiimote has returned the full data requested by a previous
* call to wiiuse_read_data().
*/
typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len);
typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, uint16_t len);
/**
@@ -241,9 +243,9 @@ typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short
struct read_req_t {
wiiuse_read_cb cb; /**< read data callback */
byte* buf; /**< buffer where read data is written */
unsigned int addr; /**< the offset that the read started at */
unsigned short size; /**< the length of the data read */
unsigned short wait; /**< num bytes still needed to finish read */
uint32_t addr; /**< the offset that the read started at */
uint16_t size; /**< the length of the data read */
uint16_t wait; /**< num bytes still needed to finish read */
byte dirty; /**< set to 1 if not using callback and needs to be cleaned up */
struct read_req_t* next; /**< next read request in the queue */
@@ -326,8 +328,8 @@ typedef struct ir_dot_t {
unsigned int x; /**< interpolated X coordinate */
unsigned int y; /**< interpolated Y coordinate */
short rx; /**< raw X coordinate (0-1023) */
short ry; /**< raw Y coordinate (0-767) */
int16_t rx; /**< raw X coordinate (0-1023) */
int16_t ry; /**< raw Y coordinate (0-767) */
byte order; /**< increasing order by x-axis value */
@@ -425,9 +427,9 @@ typedef struct nunchuk_t {
* @brief Classic controller expansion device.
*/
typedef struct classic_ctrl_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
int16_t btns; /**< what buttons have just been pressed */
int16_t btns_held; /**< what buttons are being held down */
int16_t btns_released; /**< what buttons were just released this */
float r_shoulder; /**< right shoulder button (range 0-1) */
float l_shoulder; /**< left shoulder button (range 0-1) */
@@ -442,9 +444,9 @@ typedef struct classic_ctrl_t {
* @brief Guitar Hero 3 expansion device.
*/
typedef struct guitar_hero_3_t {
short btns; /**< what buttons have just been pressed */
short btns_held; /**< what buttons are being held down */
short btns_released; /**< what buttons were just released this */
int16_t btns; /**< what buttons have just been pressed */
int16_t btns_held; /**< what buttons are being held down */
int16_t btns_released; /**< what buttons were just released this */
float whammy_bar; /**< whammy bar (range 0-1) */
@@ -455,22 +457,19 @@ typedef struct guitar_hero_3_t {
Wii board
*/
typedef struct wii_board_t {
short tl; /* Interpolated */
short tr;
short bl;
short br; /* End interp */
short rtl; /* RAW */
short rtr;
short rbl;
short rbr; /* /RAW */
short ltl;
short ltr;
short lbl;
short lbr;
short ctl[3]; /* Calibration */
short ctr[3];
short cbl[3];
short cbr[3]; /* /Calibration */
float tl; /* Interpolated */
float tr;
float bl;
float br; /* End interp */
uint16_t rtl; /* RAW */
uint16_t rtr;
uint16_t rbl;
uint16_t rbr; /* /RAW */
uint16_t ctl[3]; /* Calibration */
uint16_t ctr[3];
uint16_t cbl[3];
uint16_t cbr[3]; /* /Calibration */
uint8_t update_calib;
} wii_board_t;
@@ -511,19 +510,25 @@ typedef struct wiimote_state_t {
float exp_rjs_ang;
float exp_ljs_mag;
float exp_rjs_mag;
unsigned short exp_btns;
uint16_t exp_btns;
struct orient_t exp_orient;
struct vec3b_t exp_accel;
float exp_r_shoulder;
float exp_l_shoulder;
/* wiiboard */
uint16_t exp_wb_rtr;
uint16_t exp_wb_rtl;
uint16_t exp_wb_rbr;
uint16_t exp_wb_rbl;
/* ir_t */
int ir_ax;
int ir_ay;
float ir_distance;
struct orient_t orient;
unsigned short btns;
uint16_t btns;
struct vec3b_t accel;
} wiimote_state_t;
@@ -590,12 +595,12 @@ typedef struct wiimote_t {
WCONST struct ir_t ir; /**< IR data */
WCONST unsigned short btns; /**< what buttons have just been pressed */
WCONST unsigned short btns_held; /**< what buttons are being held down */
WCONST unsigned short btns_released; /**< what buttons were just released this */
WCONST uint16_t btns; /**< what buttons have just been pressed */
WCONST uint16_t btns_held; /**< what buttons are being held down */
WCONST uint16_t btns_released; /**< what buttons were just released this */
WCONST float orient_threshold; /**< threshold for orient to generate an event */
WCONST int accel_threshold; /**< threshold for accel to generate an event */
WCONST int32_t accel_threshold; /**< threshold for accel to generate an event */
WCONST struct wiimote_state_t lstate; /**< last saved state */
@@ -638,7 +643,7 @@ WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm);
WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds);
WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status);
WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len);
WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, uint16_t len);
WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm);
WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid);