Skip to content
Browse files

Support a WIIUSE_STATIC flag for building a static lib on windows

  • Loading branch information...
1 parent 2570ba3 commit f5c25ea6801c335ce4279b3ed9268d9d73a144d4 @paulburton committed Mar 10, 2010
Showing with 73 additions and 68 deletions.
  1. +73 −68 src/wiiuse.h
View
141 src/wiiuse.h
@@ -169,23 +169,23 @@ typedef enum ir_position_t {
* @param button The button you are interested in.
* @return 1 if the button is pressed, 0 if not.
*/
-#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
-
-/**
- * @brief Return the IR sensitivity level.
- * @param wm Pointer to a wiimote_t structure.
- * @param lvl [out] Pointer to an int that will hold the level setting.
- * If no level is set 'lvl' will be set to 0.
- */
-#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \
- do { \
- if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
- else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
- else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
- else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
- else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
- else *lvl = 0; \
- } while (0)
+#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
+
+/**
+ * @brief Return the IR sensitivity level.
+ * @param wm Pointer to a wiimote_t structure.
+ * @param lvl [out] Pointer to an int that will hold the level setting.
+ * If no level is set 'lvl' will be set to 0.
+ */
+#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \
+ do { \
+ if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \
+ else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \
+ else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \
+ else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \
+ else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \
+ else *lvl = 0; \
+ } while (0)
#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020)
#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040)
@@ -243,7 +243,7 @@ struct read_req_t {
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 */
+ unsigned short 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 */
@@ -410,9 +410,9 @@ typedef struct nunchuk_t {
byte btns; /**< what buttons have just been pressed */
byte btns_held; /**< what buttons are being held down */
byte btns_released; /**< what buttons were just released this */
-
- float orient_threshold; /**< threshold for orient to generate an event */
- int accel_threshold; /**< threshold for accel to generate an event */
+
+ float orient_threshold; /**< threshold for orient to generate an event */
+ int accel_threshold; /**< threshold for accel to generate an event */
struct vec3b_t accel; /**< current raw acceleration data */
struct orient_t orient; /**< current orientation on each axis */
@@ -453,31 +453,31 @@ typedef struct guitar_hero_3_t {
/**
- * @struct balance_board_data_t
- * @brief Balance board l/r, t/b corner data data.
- */
-typedef struct balance_board_data_t {
- int tr;
- int br;
- int tl;
- int bl;
-} balance_board_data_t;
-
-
-/**
- * @struct balance_board_t
- * @brief Balance board expansion device.
- */
-typedef struct balance_board_t {
- float tr; /** Top Right weight */
- float br; /** Bottom Right weight */
- float tl; /** Top Left weight */
- float bl; /** Bottom Left weight */
- struct balance_board_data_t raw; /** Raw actual values */
- struct balance_board_data_t cal_0; /** Calibration values at 0kg */
- struct balance_board_data_t cal_17; /** Calibration values at 17kg */
- struct balance_board_data_t cal_34; /** Calibration values at 34kg */
-} balance_board_t;
+ * @struct balance_board_data_t
+ * @brief Balance board l/r, t/b corner data data.
+ */
+typedef struct balance_board_data_t {
+ int tr;
+ int br;
+ int tl;
+ int bl;
+} balance_board_data_t;
+
+
+/**
+ * @struct balance_board_t
+ * @brief Balance board expansion device.
+ */
+typedef struct balance_board_t {
+ float tr; /** Top Right weight */
+ float br; /** Bottom Right weight */
+ float tl; /** Top Left weight */
+ float bl; /** Bottom Left weight */
+ struct balance_board_data_t raw; /** Raw actual values */
+ struct balance_board_data_t cal_0; /** Calibration values at 0kg */
+ struct balance_board_data_t cal_17; /** Calibration values at 17kg */
+ struct balance_board_data_t cal_34; /** Calibration values at 34kg */
+} balance_board_t;
/**
@@ -519,7 +519,7 @@ typedef struct wiimote_state_t {
float exp_rjs_mag;
unsigned short exp_btns;
struct orient_t exp_orient;
- struct vec3b_t exp_accel;
+ struct vec3b_t exp_accel;
float exp_r_shoulder;
float exp_l_shoulder;
struct balance_board_data_t exp_bb_raw;
@@ -543,19 +543,19 @@ typedef struct wiimote_state_t {
typedef enum WIIUSE_EVENT_TYPE {
WIIUSE_NONE = 0,
WIIUSE_EVENT,
- WIIUSE_STATUS,
+ WIIUSE_STATUS,
WIIUSE_CONNECT,
- WIIUSE_DISCONNECT,
- WIIUSE_UNEXPECTED_DISCONNECT,
- WIIUSE_READ_DATA,
+ WIIUSE_DISCONNECT,
+ WIIUSE_UNEXPECTED_DISCONNECT,
+ WIIUSE_READ_DATA,
WIIUSE_NUNCHUK_INSERTED,
- WIIUSE_NUNCHUK_REMOVED,
- WIIUSE_CLASSIC_CTRL_INSERTED,
- WIIUSE_CLASSIC_CTRL_REMOVED,
- WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
- WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
- WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
- WIIUSE_BALANCE_BOARD_CTRL_REMOVED
+ WIIUSE_NUNCHUK_REMOVED,
+ WIIUSE_CLASSIC_CTRL_INSERTED,
+ WIIUSE_CLASSIC_CTRL_REMOVED,
+ WIIUSE_GUITAR_HERO_3_CTRL_INSERTED,
+ WIIUSE_GUITAR_HERO_3_CTRL_REMOVED,
+ WIIUSE_BALANCE_BOARD_CTRL_INSERTED,
+ WIIUSE_BALANCE_BOARD_CTRL_REMOVED
} WIIUSE_EVENT_TYPE;
/**
@@ -583,8 +583,8 @@ typedef struct wiimote_t {
WCONST byte leds; /**< currently lit leds */
WCONST float battery_level; /**< battery level */
- WCONST int flags; /**< options flag */
-
+ WCONST int flags; /**< options flag */
+
WCONST byte handshake_state; /**< the state of the connection handshake */
WCONST struct read_req_t* read_req; /**< list of data read requests */
@@ -618,8 +618,13 @@ typedef struct wiimote_t {
*****************************************/
#ifdef _WIN32
- #define WIIUSE_EXPORT_DECL __declspec(dllexport)
- #define WIIUSE_IMPORT_DECL __declspec(dllimport)
+ #ifdef WIIUSE_STATIC
+ #define WIIUSE_EXPORT_DECL
+ #define WIIUSE_IMPORT_DECL
+ #else
+ #define WIIUSE_EXPORT_DECL __declspec(dllexport)
+ #define WIIUSE_IMPORT_DECL __declspec(dllimport)
+ #endif
#else
#define WIIUSE_EXPORT_DECL
#define WIIUSE_IMPORT_DECL
@@ -669,12 +674,12 @@ WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes);
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);
WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos);
-WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
-WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
-
-/* nunchuk.c */
-WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
-WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
+WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect);
+WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level);
+
+/* nunchuk.c */
+WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold);
+WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold);
#ifdef __cplusplus

0 comments on commit f5c25ea

Please sign in to comment.
Something went wrong with that request. Please try again.