#include <bluetooth/bluetooth.h>


Data Structures | |
| struct | read_req_t |
| Data read request structure. More... | |
| struct | vec2b_t |
| Unsigned x,y byte vector. More... | |
| struct | vec3b_t |
| Unsigned x,y,z byte vector. More... | |
| struct | vec3f_t |
| Signed x,y,z float struct. More... | |
| struct | orient_t |
| Orientation struct. More... | |
| struct | gforce_t |
| Gravity force struct. More... | |
| struct | accel_t |
| Accelerometer struct. For any device with an accelerometer. More... | |
| struct | ir_dot_t |
| A single IR source. More... | |
| struct | ir_t |
| IR struct. Hold all data related to the IR tracking. More... | |
| struct | joystick_t |
| Joystick calibration structure. More... | |
| struct | nunchuk_t |
| Nunchuk expansion device. More... | |
| struct | classic_ctrl_t |
| Classic controller expansion device. More... | |
| struct | guitar_hero_3_t |
| Guitar Hero 3 expansion device. More... | |
| struct | expansion_t |
| Generic expansion device plugged into wiimote. More... | |
| struct | wiimote_state_t |
| Significant data from the previous event. More... | |
| struct | wiimote_t |
| Wiimote structure. More... | |
Defines | |
| #define | WCONST const |
| #define | WIIMOTE_LED_NONE 0x00 |
| #define | WIIMOTE_LED_1 0x10 |
| #define | WIIMOTE_LED_2 0x20 |
| #define | WIIMOTE_LED_3 0x40 |
| #define | WIIMOTE_LED_4 0x80 |
| #define | WIIMOTE_BUTTON_TWO 0x0001 |
| #define | WIIMOTE_BUTTON_ONE 0x0002 |
| #define | WIIMOTE_BUTTON_B 0x0004 |
| #define | WIIMOTE_BUTTON_A 0x0008 |
| #define | WIIMOTE_BUTTON_MINUS 0x0010 |
| #define | WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 |
| #define | WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 |
| #define | WIIMOTE_BUTTON_HOME 0x0080 |
| #define | WIIMOTE_BUTTON_LEFT 0x0100 |
| #define | WIIMOTE_BUTTON_RIGHT 0x0200 |
| #define | WIIMOTE_BUTTON_DOWN 0x0400 |
| #define | WIIMOTE_BUTTON_UP 0x0800 |
| #define | WIIMOTE_BUTTON_PLUS 0x1000 |
| #define | WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 |
| #define | WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 |
| #define | WIIMOTE_BUTTON_UNKNOWN 0x8000 |
| #define | WIIMOTE_BUTTON_ALL 0x1F9F |
| #define | NUNCHUK_BUTTON_Z 0x01 |
| #define | NUNCHUK_BUTTON_C 0x02 |
| #define | NUNCHUK_BUTTON_ALL 0x03 |
| #define | CLASSIC_CTRL_BUTTON_UP 0x0001 |
| #define | CLASSIC_CTRL_BUTTON_LEFT 0x0002 |
| #define | CLASSIC_CTRL_BUTTON_ZR 0x0004 |
| #define | CLASSIC_CTRL_BUTTON_X 0x0008 |
| #define | CLASSIC_CTRL_BUTTON_A 0x0010 |
| #define | CLASSIC_CTRL_BUTTON_Y 0x0020 |
| #define | CLASSIC_CTRL_BUTTON_B 0x0040 |
| #define | CLASSIC_CTRL_BUTTON_ZL 0x0080 |
| #define | CLASSIC_CTRL_BUTTON_FULL_R 0x0200 |
| #define | CLASSIC_CTRL_BUTTON_PLUS 0x0400 |
| #define | CLASSIC_CTRL_BUTTON_HOME 0x0800 |
| #define | CLASSIC_CTRL_BUTTON_MINUS 0x1000 |
| #define | CLASSIC_CTRL_BUTTON_FULL_L 0x2000 |
| #define | CLASSIC_CTRL_BUTTON_DOWN 0x4000 |
| #define | CLASSIC_CTRL_BUTTON_RIGHT 0x8000 |
| #define | CLASSIC_CTRL_BUTTON_ALL 0xFEFF |
| #define | GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 |
| #define | GUITAR_HERO_3_BUTTON_YELLOW 0x0008 |
| #define | GUITAR_HERO_3_BUTTON_GREEN 0x0010 |
| #define | GUITAR_HERO_3_BUTTON_BLUE 0x0020 |
| #define | GUITAR_HERO_3_BUTTON_RED 0x0040 |
| #define | GUITAR_HERO_3_BUTTON_ORANGE 0x0080 |
| #define | GUITAR_HERO_3_BUTTON_PLUS 0x0400 |
| #define | GUITAR_HERO_3_BUTTON_MINUS 0x1000 |
| #define | GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 |
| #define | GUITAR_HERO_3_BUTTON_ALL 0xFEFF |
| #define | WIIUSE_SMOOTHING 0x01 |
| #define | WIIUSE_CONTINUOUS 0x02 |
| #define | WIIUSE_ORIENT_THRESH 0x04 |
| #define | WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) |
| #define | WIIUSE_ORIENT_PRECISION 100.0f |
| #define | EXP_NONE 0 |
| #define | EXP_NUNCHUK 1 |
| #define | EXP_CLASSIC 2 |
| #define | EXP_GUITAR_HERO_3 3 |
| #define | IS_PRESSED(dev, button) ((dev->btns & button) == button) |
| Check if a button is pressed. | |
| #define | IS_HELD(dev, button) ((dev->btns_held & button) == button) |
| Check if a button is being held. | |
| #define | IS_RELEASED(dev, button) ((dev->btns_released & button) == button) |
| Check if a button is released on this event. This does not mean the button is not pressed, it means this button was just now released. | |
| #define | IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) |
| Check if a button has just been pressed this event. | |
| #define | WIIUSE_GET_IR_SENSITIVITY(dev, lvl) |
| Return the IR sensitivity level. | |
| #define | WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) |
| #define | WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) |
| #define | WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) |
| #define | WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) |
| #define | WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) |
| #define | MAX_PAYLOAD 32 |
| #define | WIIUSE_EXPORT_DECL |
| #define | WIIUSE_IMPORT_DECL |
| #define | WIIUSE_EXPORT WIIUSE_IMPORT_DECL |
Typedefs | |
| typedef unsigned char | byte |
| typedef char | sbyte |
| typedef void(* | wiiuse_read_cb )(struct wiimote_t *wm, byte *data, unsigned short len) |
| Callback that handles a read event. | |
| typedef struct wiimote_t | wiimote |
Enumerations | |
| enum | ir_position_t { WIIUSE_IR_ABOVE, WIIUSE_IR_BELOW } |
| enum | aspect_t { WIIUSE_ASPECT_4_3, WIIUSE_ASPECT_16_9 } |
| Screen aspect ratio. | |
| enum | win_bt_stack_t { WIIUSE_STACK_UNKNOWN, WIIUSE_STACK_MS, WIIUSE_STACK_BLUESOLEIL } |
| enum | WIIUSE_EVENT_TYPE { WIIUSE_NONE = 0, WIIUSE_EVENT, WIIUSE_STATUS, WIIUSE_CONNECT, 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 } |
| Events that wiiuse can generate from a poll. | |
Functions | |
| WIIUSE_EXPORT const char * | wiiuse_version () |
| WIIUSE_EXPORT struct wiimote_t ** | wiiuse_init (int wiimotes) |
| Initialize an array of wiimote structures. | |
| WIIUSE_EXPORT void | wiiuse_disconnected (struct wiimote_t *wm) |
| The wiimote disconnected. | |
| WIIUSE_EXPORT void | wiiuse_cleanup (struct wiimote_t **wm, int wiimotes) |
| Clean up wiimote_t array created by wiiuse_init(). | |
| WIIUSE_EXPORT void | wiiuse_rumble (struct wiimote_t *wm, int status) |
| Enable or disable the rumble. | |
| WIIUSE_EXPORT void | wiiuse_toggle_rumble (struct wiimote_t *wm) |
| Toggle the state of the rumble. | |
| WIIUSE_EXPORT void | wiiuse_set_leds (struct wiimote_t *wm, int leds) |
| Set the enabled LEDs. | |
| WIIUSE_EXPORT void | wiiuse_motion_sensing (struct wiimote_t *wm, int status) |
| Set if the wiimote should report motion sensing. | |
| WIIUSE_EXPORT int | wiiuse_read_data (struct wiimote_t *wm, byte *buffer, unsigned int offset, unsigned short len) |
| Read data from the wiimote (event version). | |
| WIIUSE_EXPORT int | wiiuse_write_data (struct wiimote_t *wm, unsigned int addr, byte *data, byte len) |
| Write data to the wiimote. | |
| WIIUSE_EXPORT void | wiiuse_status (struct wiimote_t *wm) |
| Request the wiimote controller status. | |
| WIIUSE_EXPORT struct wiimote_t * | wiiuse_get_by_id (struct wiimote_t **wm, int wiimotes, int unid) |
| Find a wiimote_t structure by its unique identifier. | |
| WIIUSE_EXPORT int | wiiuse_set_flags (struct wiimote_t *wm, int enable, int disable) |
| Set flags for the specified wiimote. | |
| WIIUSE_EXPORT float | wiiuse_set_smooth_alpha (struct wiimote_t *wm, float alpha) |
| Set the wiimote smoothing alpha value. | |
| WIIUSE_EXPORT void | wiiuse_set_bluetooth_stack (struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t type) |
| Set the bluetooth stack type to use. | |
| WIIUSE_EXPORT void | wiiuse_set_orient_threshold (struct wiimote_t *wm, float threshold) |
| Set the orientation event threshold. | |
| WIIUSE_EXPORT void | wiiuse_resync (struct wiimote_t *wm) |
| Try to resync with the wiimote by starting a new handshake. | |
| WIIUSE_EXPORT void | wiiuse_set_timeout (struct wiimote_t **wm, int wiimotes, byte normal_timeout, byte exp_timeout) |
| Set the normal and expansion handshake timeouts. | |
| WIIUSE_EXPORT void | wiiuse_set_accel_threshold (struct wiimote_t *wm, int threshold) |
| Set the accelerometer event threshold. | |
| WIIUSE_EXPORT int | wiiuse_find (struct wiimote_t **wm, int max_wiimotes, int timeout) |
| Find a wiimote or wiimotes. | |
| WIIUSE_EXPORT int | wiiuse_connect (struct wiimote_t **wm, int wiimotes) |
| Connect to a wiimote or wiimotes once an address is known. | |
| WIIUSE_EXPORT void | wiiuse_disconnect (struct wiimote_t *wm) |
| Disconnect a wiimote. | |
| WIIUSE_EXPORT int | wiiuse_poll (struct wiimote_t **wm, int wiimotes) |
| Poll the wiimotes for any events. | |
| WIIUSE_EXPORT void | wiiuse_set_ir (struct wiimote_t *wm, int status) |
| Set if the wiimote should track IR targets. | |
| WIIUSE_EXPORT void | wiiuse_set_ir_vres (struct wiimote_t *wm, unsigned int x, unsigned int y) |
| Set the virtual screen resolution for IR tracking. | |
| WIIUSE_EXPORT void | wiiuse_set_ir_position (struct wiimote_t *wm, enum ir_position_t pos) |
| Set the XY position for the IR cursor. | |
| WIIUSE_EXPORT void | wiiuse_set_aspect_ratio (struct wiimote_t *wm, enum aspect_t aspect) |
| Set the aspect ratio of the TV/monitor. | |
| WIIUSE_EXPORT void | wiiuse_set_ir_sensitivity (struct wiimote_t *wm, int level) |
| Set the IR sensitivity. | |
| WIIUSE_EXPORT void | wiiuse_set_nunchuk_orient_threshold (struct wiimote_t *wm, float threshold) |
| Set the orientation event threshold for the nunchuk. | |
| WIIUSE_EXPORT void | wiiuse_set_nunchuk_accel_threshold (struct wiimote_t *wm, int threshold) |
| Set the accelerometer event threshold for the nunchuk. | |
If this file is included from inside the wiiuse source and not from a third party program, then wiimote_internal.h is also included which extends this file.
| #define IS_HELD | ( | dev, | |||
| button | ) | ((dev->btns_held & button) == button) |
Check if a button is being held.
| dev | Pointer to a wiimote_t or expansion structure. | |
| button | The button you are interested in. |
| #define IS_JUST_PRESSED | ( | dev, | |||
| button | ) | (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) |
Check if a button has just been pressed this event.
| dev | Pointer to a wiimote_t or expansion structure. | |
| button | The button you are interested in. |
| #define IS_PRESSED | ( | dev, | |||
| button | ) | ((dev->btns & button) == button) |
Check if a button is pressed.
| dev | Pointer to a wiimote_t or expansion structure. | |
| button | The button you are interested in. |
| #define IS_RELEASED | ( | dev, | |||
| button | ) | ((dev->btns_released & button) == button) |
Check if a button is released on this event.
This does not mean the button is not pressed, it means
this button was just now released.
| dev | Pointer to a wiimote_t or expansion structure. | |
| button | The button you are interested in. |
| #define WIIUSE_GET_IR_SENSITIVITY | ( | dev, | |||
| lvl | ) |
Value:
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)
| wm | Pointer to a wiimote_t structure. | |
| lvl | [out] Pointer to an int that will hold the level setting. If no level is set 'lvl' will be set to 0. |
| typedef void(* wiiuse_read_cb)(struct wiimote_t *wm, byte *data, unsigned short len) |
Callback that handles a read event.
| wm | Pointer to a wiimote_t structure. | |
| data | Pointer to the filled data block. | |
| len | Length in bytes of the data block. |
| WIIUSE_EXPORT int wiiuse_connect | ( | struct wiimote_t ** | wm, | |
| int | wiimotes | |||
| ) |
Connect to a wiimote or wiimotes once an address is known.
| wm | An array of wiimote_t structures. | |
| wiimotes | The number of wiimote structures in wm. |
| WIIUSE_EXPORT void wiiuse_disconnect | ( | struct wiimote_t * | wm | ) |
Disconnect a wiimote.
| wm | Pointer to a wiimote_t structure. |
| WIIUSE_EXPORT void wiiuse_disconnected | ( | struct wiimote_t * | wm | ) |
| WIIUSE_EXPORT int wiiuse_find | ( | struct wiimote_t ** | wm, | |
| int | max_wiimotes, | |||
| int | timeout | |||
| ) |
Find a wiimote or wiimotes.
| wm | An array of wiimote_t structures. | |
| max_wiimotes | The number of wiimote structures in wm. | |
| timeout | The number of seconds before the search times out. |
| WIIUSE_EXPORT struct wiimote_t** wiiuse_init | ( | int | wiimotes | ) | [read] |
Initialize an array of wiimote structures.
| wiimotes | Number of wiimote_t structures to create. |
| WIIUSE_EXPORT void wiiuse_motion_sensing | ( | struct wiimote_t * | wm, | |
| int | status | |||
| ) |
Set if the wiimote should report motion sensing.
| wm | Pointer to a wiimote_t structure. | |
| status | 1 to enable, 0 to disable. |
| WIIUSE_EXPORT int wiiuse_poll | ( | struct wiimote_t ** | wm, | |
| int | wiimotes | |||
| ) |
Poll the wiimotes for any events.
| wm | An array of pointers to wiimote_t structures. | |
| wiimotes | The number of wiimote_t structures in the wm array. |
| WIIUSE_EXPORT int wiiuse_read_data | ( | struct wiimote_t * | wm, | |
| byte * | buffer, | |||
| unsigned int | addr, | |||
| unsigned short | len | |||
| ) |
Read data from the wiimote (event version).
| wm | Pointer to a wiimote_t structure. | |
| buffer | An allocated buffer to store the data as it arrives from the wiimote. Must be persistent in memory and large enough to hold the data. | |
| addr | The address of wiimote memory to read from. | |
| len | The length of the block to be read. |
| WIIUSE_EXPORT void wiiuse_resync | ( | struct wiimote_t * | wm | ) |
Try to resync with the wiimote by starting a new handshake.
| wm | Pointer to a wiimote_t structure. |
| WIIUSE_EXPORT void wiiuse_rumble | ( | struct wiimote_t * | wm, | |
| int | status | |||
| ) |
Enable or disable the rumble.
| wm | Pointer to a wiimote_t structure. | |
| status | 1 to enable, 0 to disable. |
| WIIUSE_EXPORT void wiiuse_set_accel_threshold | ( | struct wiimote_t * | wm, | |
| int | threshold | |||
| ) |
Set the accelerometer event threshold.
| wm | Pointer to a wiimote_t structure. | |
| threshold | The decimal place that should be considered a significant change. |
Set the aspect ratio of the TV/monitor.
| wm | Pointer to a wiimote_t structure. | |
| aspect | Either WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3 |
| WIIUSE_EXPORT void wiiuse_set_bluetooth_stack | ( | struct wiimote_t ** | wm, | |
| int | wiimotes, | |||
| enum win_bt_stack_t | type | |||
| ) |
Set the bluetooth stack type to use.
| wm | Array of wiimote_t structures. | |
| wiimotes | Number of objects in the wm array. | |
| type | The type of bluetooth stack to use. |
| WIIUSE_EXPORT int wiiuse_set_flags | ( | struct wiimote_t * | wm, | |
| int | enable, | |||
| int | disable | |||
| ) |
Set flags for the specified wiimote.
| wm | Pointer to a wiimote_t structure. | |
| enable | Flags to enable. | |
| disable | Flags to disable. |
| WIIUSE_EXPORT void wiiuse_set_ir | ( | struct wiimote_t * | wm, | |
| int | status | |||
| ) |
Set if the wiimote should track IR targets.
| wm | Pointer to a wiimote_t structure. | |
| status | 1 to enable, 0 to disable. |
| WIIUSE_EXPORT void wiiuse_set_ir_position | ( | struct wiimote_t * | wm, | |
| enum ir_position_t | pos | |||
| ) |
| WIIUSE_EXPORT void wiiuse_set_ir_sensitivity | ( | struct wiimote_t * | wm, | |
| int | level | |||
| ) |
Set the IR sensitivity.
| wm | Pointer to a wiimote_t structure. | |
| level | 1-5, same as Wii system sensitivity setting. |
| WIIUSE_EXPORT void wiiuse_set_ir_vres | ( | struct wiimote_t * | wm, | |
| unsigned int | x, | |||
| unsigned int | y | |||
| ) |
Set the virtual screen resolution for IR tracking.
| wm | Pointer to a wiimote_t structure. | |
| status | 1 to enable, 0 to disable. |
| WIIUSE_EXPORT void wiiuse_set_leds | ( | struct wiimote_t * | wm, | |
| int | leds | |||
| ) |
Set the enabled LEDs.
| wm | Pointer to a wiimote_t structure. | |
| leds | What LEDs to enable. |
| WIIUSE_EXPORT void wiiuse_set_nunchuk_accel_threshold | ( | struct wiimote_t * | wm, | |
| int | threshold | |||
| ) |
Set the accelerometer event threshold for the nunchuk.
| wm | Pointer to a wiimote_t structure with a nunchuk attached. | |
| threshold | The decimal place that should be considered a significant change. |
| WIIUSE_EXPORT void wiiuse_set_nunchuk_orient_threshold | ( | struct wiimote_t * | wm, | |
| float | threshold | |||
| ) |
Set the orientation event threshold for the nunchuk.
| wm | Pointer to a wiimote_t structure with a nunchuk attached. | |
| threshold | The decimal place that should be considered a significant change. |
| WIIUSE_EXPORT void wiiuse_set_orient_threshold | ( | struct wiimote_t * | wm, | |
| float | threshold | |||
| ) |
Set the orientation event threshold.
| wm | Pointer to a wiimote_t structure. | |
| threshold | The decimal place that should be considered a significant change. |
| WIIUSE_EXPORT float wiiuse_set_smooth_alpha | ( | struct wiimote_t * | wm, | |
| float | alpha | |||
| ) |
Set the wiimote smoothing alpha value.
| wm | Pointer to a wiimote_t structure. | |
| alpha | The alpha value to set. Between 0 and 1. |
Smoothing is only performed if the WIIMOTE_USE_SMOOTHING is set.
| WIIUSE_EXPORT void wiiuse_set_timeout | ( | struct wiimote_t ** | wm, | |
| int | wiimotes, | |||
| byte | normal_timeout, | |||
| byte | exp_timeout | |||
| ) |
Set the normal and expansion handshake timeouts.
| wm | Array of wiimote_t structures. | |
| wiimotes | Number of objects in the wm array. | |
| normal_timeout | The timeout in milliseconds for a normal read. | |
| exp_timeout | The timeout in millisecondsd to wait for an expansion handshake. |
| WIIUSE_EXPORT void wiiuse_status | ( | struct wiimote_t * | wm | ) |
Request the wiimote controller status.
| wm | Pointer to a wiimote_t structure. |
| WIIUSE_EXPORT void wiiuse_toggle_rumble | ( | struct wiimote_t * | wm | ) |
| WIIUSE_EXPORT const char* wiiuse_version | ( | ) |
Returns the version of the library.
| WIIUSE_EXPORT int wiiuse_write_data | ( | struct wiimote_t * | wm, | |
| unsigned int | addr, | |||
| byte * | data, | |||
| byte | len | |||
| ) |
Write data to the wiimote.
| wm | Pointer to a wiimote_t structure. | |
| addr | The address to write to. | |
| data | The data to be written to the memory location. | |
| len | The length of the block to be written. |
1.5.4