WiiUse  0.14.2
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
External API

Data Structures

struct  read_req_t
 Data read request structure. More...
struct  ang3s_t
 Roll/Pitch/Yaw short angles. More...
struct  ang3f_t
 Roll/Pitch/Yaw float angles. 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  motion_plus_t
 Motion Plus expansion device. More...
struct  wii_board_t
 Wii Balance Board "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
 Main Wiimote device structure. More...
struct  wiimote_callback_data_t
 Data passed to a callback during wiiuse_update() More...
struct  data_req_t
 Data write request structure. More...

Macros

#define WIIMOTE_DEFAULT_TIMEOUT   10
#define WIIMOTE_EXP_TIMEOUT   10
#define WIIUSE_SYNC_HANDSHAKE
#define WIIUSE_EXPORT_DECL   __declspec(dllexport)
#define WIIUSE_IMPORT_DECL   __declspec(dllimport)
#define WIIUSE_EXPORT   WIIUSE_IMPORT_DECL
#define WIIUSE_HAS_OUTPUT_REDIRECTION

Typedefs

typedef unsigned char byte
typedef char sbyte
typedef void(* wiiuse_read_cb )(struct wiimote_t *wm, byte *data, uint16_t len)
typedef void(* wiiuse_update_cb )(struct wiimote_callback_data_t *wm)
typedef void(* wiiuse_write_cb )(struct wiimote_t *wm, unsigned char *data, unsigned short len)

Enumerations

enum  ir_position_t { WIIUSE_IR_ABOVE, WIIUSE_IR_BELOW }
enum  aspect_t { WIIUSE_ASPECT_4_3, WIIUSE_ASPECT_16_9 }
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_WRITE_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_WII_BOARD_CTRL_INSERTED, WIIUSE_WII_BOARD_CTRL_REMOVED,
  WIIUSE_MOTION_PLUS_ACTIVATED, WIIUSE_MOTION_PLUS_REMOVED
}
enum  data_req_s { REQ_READY = 0, REQ_SENT, REQ_DONE }
enum  wiiuse_loglevel { LOGLEVEL_ERROR = 0, LOGLEVEL_WARNING = 1, LOGLEVEL_INFO = 2, LOGLEVEL_DEBUG = 3 }

Functions

WIIUSE_EXPORT const char * wiiuse_version ()
WIIUSE_EXPORT void wiiuse_set_output (enum wiiuse_loglevel loglevel, FILE *logtarget)
WIIUSE_EXPORT struct wiimote_t ** wiiuse_init (int wiimotes)
WIIUSE_EXPORT void wiiuse_disconnected (struct wiimote_t *wm)
WIIUSE_EXPORT void wiiuse_cleanup (struct wiimote_t **wm, int wiimotes)
WIIUSE_EXPORT void wiiuse_rumble (struct wiimote_t *wm, int status)
WIIUSE_EXPORT void wiiuse_toggle_rumble (struct wiimote_t *wm)
WIIUSE_EXPORT void wiiuse_set_leds (struct wiimote_t *wm, int leds)
WIIUSE_EXPORT void wiiuse_motion_sensing (struct wiimote_t *wm, int status)
WIIUSE_EXPORT int wiiuse_read_data (struct wiimote_t *wm, byte *buffer, unsigned int offset, uint16_t len)
WIIUSE_EXPORT int wiiuse_write_data (struct wiimote_t *wm, unsigned int addr, const byte *data, byte len)
WIIUSE_EXPORT void wiiuse_status (struct wiimote_t *wm)
WIIUSE_EXPORT struct wiimote_t * wiiuse_get_by_id (struct wiimote_t **wm, int wiimotes, int unid)
WIIUSE_EXPORT int wiiuse_set_flags (struct wiimote_t *wm, int enable, int disable)
WIIUSE_EXPORT float wiiuse_set_smooth_alpha (struct wiimote_t *wm, float alpha)
WIIUSE_EXPORT void wiiuse_set_bluetooth_stack (struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t type)
WIIUSE_EXPORT void wiiuse_set_orient_threshold (struct wiimote_t *wm, float threshold)
WIIUSE_EXPORT void wiiuse_resync (struct wiimote_t *wm)
WIIUSE_EXPORT void wiiuse_set_timeout (struct wiimote_t **wm, int wiimotes, byte normal_timeout, byte exp_timeout)
WIIUSE_EXPORT void wiiuse_set_accel_threshold (struct wiimote_t *wm, int threshold)
WIIUSE_EXPORT int wiiuse_find (struct wiimote_t **wm, int max_wiimotes, int timeout)
WIIUSE_EXPORT int wiiuse_connect (struct wiimote_t **wm, int wiimotes)
WIIUSE_EXPORT void wiiuse_disconnect (struct wiimote_t *wm)
WIIUSE_EXPORT int wiiuse_poll (struct wiimote_t **wm, int wiimotes)
WIIUSE_EXPORT int wiiuse_update (struct wiimote_t **wm, int wiimotes, wiiuse_update_cb callback)
WIIUSE_EXPORT void wiiuse_set_ir (struct wiimote_t *wm, int status)
WIIUSE_EXPORT void wiiuse_set_ir_vres (struct wiimote_t *wm, unsigned int x, unsigned int y)
WIIUSE_EXPORT void wiiuse_set_ir_position (struct wiimote_t *wm, enum ir_position_t pos)
WIIUSE_EXPORT void wiiuse_set_aspect_ratio (struct wiimote_t *wm, enum aspect_t aspect)
WIIUSE_EXPORT void wiiuse_set_ir_sensitivity (struct wiimote_t *wm, int level)
WIIUSE_EXPORT void wiiuse_set_nunchuk_orient_threshold (struct wiimote_t *wm, float threshold)
WIIUSE_EXPORT void wiiuse_set_nunchuk_accel_threshold (struct wiimote_t *wm, int threshold)
WIIUSE_EXPORT void wiiuse_set_wii_board_calib (struct wiimote_t *wm)
WIIUSE_EXPORT void wiiuse_set_motion_plus (struct wiimote_t *wm, int status)

Wiimote state flags and macros

#define WIIMOTE_STATE_DEV_FOUND   0x0001
#define WIIMOTE_STATE_HANDSHAKE   0x0002 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_HANDSHAKE_COMPLETE   0x0004 /* actual connection exists but no handshake yet */
#define WIIMOTE_STATE_CONNECTED   0x0008
#define WIIMOTE_STATE_RUMBLE   0x0010
#define WIIMOTE_STATE_ACC   0x0020
#define WIIMOTE_STATE_EXP   0x0040
#define WIIMOTE_STATE_IR   0x0080
#define WIIMOTE_STATE_SPEAKER   0x0100
#define WIIMOTE_STATE_IR_SENS_LVL1   0x0200
#define WIIMOTE_STATE_IR_SENS_LVL2   0x0400
#define WIIMOTE_STATE_IR_SENS_LVL3   0x0800
#define WIIMOTE_STATE_IR_SENS_LVL4   0x1000
#define WIIMOTE_STATE_IR_SENS_LVL5   0x2000
#define WIIMOTE_STATE_EXP_HANDSHAKE   0x10000 /* actual M+ connection exists but no handshake yet */
#define WIIMOTE_STATE_EXP_EXTERN   0x20000 /* actual M+ connection exists but handshake failed */
#define WIIMOTE_STATE_EXP_FAILED   0x40000 /* actual M+ connection exists but handshake failed */
#define WIIMOTE_STATE_MPLUS_PRESENT   0x80000 /* Motion+ is connected */
#define WIIMOTE_ID(wm)   (wm->unid)
#define WIIMOTE_IS_SET(wm, s)   ((wm->state & (s)) == (s))
#define WIIMOTE_IS_CONNECTED(wm)   (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))

LED bit masks

#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

Button codes

#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

Nunchuk button codes

#define NUNCHUK_BUTTON_Z   0x01
#define NUNCHUK_BUTTON_C   0x02
#define NUNCHUK_BUTTON_ALL   0x03

Classic controller button codes

#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

Guitar Hero 3 button codes

#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

Wiimote option flags

#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

Expansion codes

#define EXP_NONE   0
#define EXP_NUNCHUK   1
#define EXP_CLASSIC   2
#define EXP_GUITAR_HERO_3   3
#define EXP_WII_BOARD   4
#define EXP_MOTION_PLUS   5
#define EXP_MOTION_PLUS_NUNCHUK   6 /* Motion+ in nunchuk pass-through mode */
#define EXP_MOTION_PLUS_CLASSIC   7 /* Motion+ in classic ctr. pass-through mode */

Device Inquiry Macros

#define IS_PRESSED(dev, button)   ((dev->btns & button) == button)
#define IS_HELD(dev, button)   ((dev->btns_held & button) == button)
#define IS_RELEASED(dev, button)   ((dev->btns_released & button) == button)
#define IS_JUST_PRESSED(dev, button)   (IS_PRESSED(dev, button) && !IS_HELD(dev, button))
#define WIIUSE_GET_IR_SENSITIVITY(wm, lvl)
#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)

Detailed Description

Macro Definition Documentation

#define IS_HELD (   dev,
  button 
)    ((dev->btns_held & button) == button)

Check if a button is being held.

Parameters
devPointer to a wiimote_t or expansion structure.
buttonThe button you are interested in.
Returns
1 if the button is held, 0 if not.

Definition at line 270 of file wiiuse.h.

#define IS_JUST_PRESSED (   dev,
  button 
)    (IS_PRESSED(dev, button) && !IS_HELD(dev, button))

Check if a button has just been pressed this event.

Parameters
devPointer to a wiimote_t or expansion structure.
buttonThe button you are interested in.
Returns
1 if the button is pressed, 0 if not.

Definition at line 289 of file wiiuse.h.

#define IS_PRESSED (   dev,
  button 
)    ((dev->btns & button) == button)

Check if a button is pressed.

Parameters
devPointer to a wiimote_t or expansion structure.
buttonThe button you are interested in.
Returns
1 if the button is pressed, 0 if not.

Definition at line 262 of file wiiuse.h.

#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.

Parameters
devPointer to a wiimote_t or expansion structure.
buttonThe button you are interested in.
Returns
1 if the button is released, 0 if not.

Definition at line 281 of file wiiuse.h.

#define WIIUSE_GET_IR_SENSITIVITY (   wm,
  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)

Return the IR sensitivity level.

Parameters
wmPointer 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.

Definition at line 297 of file wiiuse.h.

Typedef Documentation

typedef void(* wiiuse_read_cb)(struct wiimote_t *wm, byte *data, uint16_t len)

Callback that handles a read event.

Parameters
wmPointer to a wiimote_t structure.
dataPointer to the filled data block.
lenLength in bytes of the data block.
See Also
wiiuse_init()

A registered function of this type is called automatically by the wiiuse library when the wiimote has returned the full data requested by a previous call to wiiuse_read_data().

Definition at line 349 of file wiiuse.h.

typedef void(* wiiuse_write_cb)(struct wiimote_t *wm, unsigned char *data, unsigned short len)

Callback that handles a write event.

Parameters
wmPointer to a wiimote_t structure.
dataPointer to the sent data block.
lenLength in bytes of the data block.
See Also
wiiuse_init()

A registered function of this type is called automatically by the wiiuse library when the wiimote has returned the full data requested by a previous call to wiiuse_write_data().

Definition at line 824 of file wiiuse.h.

Function Documentation

WIIUSE_EXPORT int wiiuse_connect ( struct wiimote_t **  wm,
int  wiimotes 
)

Connect to a wiimote or wiimotes once an address is known.

Parameters
wmAn array of wiimote_t structures.
wiimotesThe number of wiimote structures in wm.
Returns
The number of wiimotes that successfully connected.
See Also
wiiuse_find()
wiiuse_disconnect()
wiiuse_os_connect()

Connect to a number of wiimotes when the address is already set in the wiimote_t structures. These addresses are normally set by the wiiuse_find() function, but can also be set manually.

This function only delegates to the platform-specific implementation wiiuse_os_connect.

This function is declared in wiiuse.h

Definition at line 89 of file io.c.

References wiiuse_os_connect().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_disconnect ( struct wiimote_t *  wm)

Disconnect a wiimote.

Parameters
wmPointer to a wiimote_t structure.
See Also
wiiuse_connect()
wiiuse_os_disconnect()

Note that this will not free the wiimote structure.

This function only delegates to the platform-specific implementation wiiuse_os_disconnect.

This function is declared in wiiuse.h

Definition at line 108 of file io.c.

Referenced by wiiuse_cleanup().

+ Here is the caller graph for this function:

WIIUSE_EXPORT void wiiuse_disconnected ( struct wiimote_t *  wm)

The wiimote disconnected.

Parameters
wmPointer to a wiimote_t structure.

Definition at line 173 of file wiiuse.c.

WIIUSE_EXPORT int wiiuse_find ( struct wiimote_t **  wm,
int  max_wiimotes,
int  timeout 
)

Find a wiimote or wiimotes.

Parameters
wmAn array of wiimote_t structures.
max_wiimotesThe number of wiimote structures in wm.
timeoutThe number of seconds before the search times out.
Returns
The number of wiimotes found.
See Also
wiiuse_connect()
wiiuse_os_find()

This function will only look for wiimote devices.
When a device is found the address in the structures will be set.
You can then call wiiuse_connect() to connect to the found
devices.

This function only delegates to the platform-specific implementation wiiuse_os_find.

This function is declared in wiiuse.h

Definition at line 64 of file io.c.

WIIUSE_EXPORT struct wiimote_t* wiiuse_get_by_id ( struct wiimote_t **  wm,
int  wiimotes,
int  unid 
)
read

Find a wiimote_t structure by its unique identifier.

Parameters
wmPointer to a wiimote_t structure.
wiimotesThe number of wiimote_t structures in wm.
unidThe unique identifier to search for.
Returns
Pointer to a wiimote_t structure, or NULL if not found.

Definition at line 511 of file wiiuse.c.

WIIUSE_EXPORT struct wiimote_t** wiiuse_init ( int  wiimotes)
read

Initialize an array of wiimote structures.

Parameters
wiimotesNumber of wiimote_t structures to create.
Returns
An array of initialized wiimote_t structures.
See Also
wiiuse_connect()

The array returned by this function can be passed to various functions, including wiiuse_connect().

Definition at line 110 of file wiiuse.c.

References logtarget, wiiuse_set_aspect_ratio(), and wiiuse_set_ir_position().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_motion_sensing ( struct wiimote_t *  wm,
int  status 
)

Set if the wiimote should report motion sensing.

Parameters
wmPointer to a wiimote_t structure.
status1 to enable, 0 to disable.

Since reporting motion sensing sends a lot of data, the wiimote saves power by not transmitting it by default.

Definition at line 286 of file wiiuse.c.

References wiiuse_set_report_type().

+ Here is the call graph for this function:

WIIUSE_EXPORT int wiiuse_poll ( struct wiimote_t **  wm,
int  wiimotes 
)

Poll the wiimotes for any events.

Parameters
wmAn array of pointers to wiimote_t structures.
wiimotesThe number of wiimote_t structures in the wm array.
Returns
Returns number of wiimotes that an event has occurred on.

It is necessary to poll the wiimote devices for events that occur. If an event occurs on a particular wiimote, the event variable will be set.

Definition at line 74 of file events.c.

Referenced by wiiuse_update().

+ Here is the caller graph for this function:

WIIUSE_EXPORT int wiiuse_read_data ( struct wiimote_t *  wm,
byte *  buffer,
unsigned int  addr,
uint16_t  len 
)

Read data from the wiimote (event version).

Parameters
wmPointer to a wiimote_t structure.
bufferAn allocated buffer to store the data as it arrives from the wiimote. Must be persistent in memory and large enough to hold the data.
addrThe address of wiimote memory to read from.
lenThe length of the block to be read.

The library can only handle one data read request at a time because it must keep track of the buffer and other events that are specific to that request. So if a request has already been made, subsequent requests will be added to a pending list and be sent out when the previous finishes.

Definition at line 437 of file wiiuse.c.

References wiiuse_read_data_cb().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_resync ( struct wiimote_t *  wm)

Try to resync with the wiimote by starting a new handshake.

Parameters
wmPointer to a wiimote_t structure.

Definition at line 825 of file wiiuse.c.

References wiiuse_handshake().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_rumble ( struct wiimote_t *  wm,
int  status 
)

Enable or disable the rumble.

Parameters
wmPointer to a wiimote_t structure.
status1 to enable, 0 to disable.

Definition at line 204 of file wiiuse.c.

References wiiuse_send().

Referenced by wiiuse_toggle_rumble().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WIIUSE_EXPORT void wiiuse_set_accel_threshold ( struct wiimote_t *  wm,
int  threshold 
)

Set the accelerometer event threshold.

Parameters
wmPointer to a wiimote_t structure.
thresholdThe decimal place that should be considered a significant change.

Definition at line 811 of file wiiuse.c.

WIIUSE_EXPORT void wiiuse_set_aspect_ratio ( struct wiimote_t *  wm,
enum aspect_t  aspect 
)

Set the aspect ratio of the TV/monitor.

Parameters
wmPointer to a wiimote_t structure.
aspectEither WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3

Definition at line 271 of file ir.c.

References wiiuse_set_ir_position().

Referenced by wiiuse_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
wmArray of wiimote_t structures.
wiimotesNumber of objects in the wm array.
typeThe type of bluetooth stack to use.

Definition at line 771 of file wiiuse.c.

WIIUSE_EXPORT int wiiuse_set_flags ( struct wiimote_t *  wm,
int  enable,
int  disable 
)

Set flags for the specified wiimote.

Parameters
wmPointer to a wiimote_t structure.
enableFlags to enable.
disableFlags to disable.
Returns
The flags set after 'enable' and 'disable' have been applied.

The values 'enable' and 'disable' may be any flags OR'ed together. Flags are defined in wiiuse.h.

Definition at line 715 of file wiiuse.c.

WIIUSE_EXPORT void wiiuse_set_ir ( struct wiimote_t *  wm,
int  status 
)

Set if the wiimote should track IR targets.

Parameters
wmPointer to a wiimote_t structure.
status1 to enable, 0 to disable.

Definition at line 83 of file ir.c.

References wiiuse_millisleep(), wiiuse_send(), wiiuse_set_report_type(), and wiiuse_write_data().

Referenced by wiiuse_handshake().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WIIUSE_EXPORT void wiiuse_set_ir_position ( struct wiimote_t *  wm,
enum ir_position_t  pos 
)

Set the XY position for the IR cursor.

Parameters
wmPointer to a wiimote_t structure.

Definition at line 228 of file ir.c.

Referenced by wiiuse_init(), and wiiuse_set_aspect_ratio().

+ Here is the caller graph for this function:

WIIUSE_EXPORT void wiiuse_set_ir_sensitivity ( struct wiimote_t *  wm,
int  level 
)

Set the IR sensitivity.

Parameters
wmPointer to a wiimote_t structure.
level1-5, same as Wii system sensitivity setting.

If the level is < 1, then level will be set to 1. If the level is > 5, then level will be set to 5.

Definition at line 300 of file ir.c.

References wiiuse_write_data().

+ Here is the call graph for this function:

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.

Parameters
wmPointer to a wiimote_t structure.
status1 to enable, 0 to disable.

Definition at line 213 of file ir.c.

WIIUSE_EXPORT void wiiuse_set_leds ( struct wiimote_t *  wm,
int  leds 
)

Set the enabled LEDs.

Parameters
wmPointer to a wiimote_t structure.
ledsWhat LEDs to enable.

leds is a bitwise or of WIIMOTE_LED_1, WIIMOTE_LED_2, WIIMOTE_LED_3, or WIIMOTE_LED_4.

Definition at line 255 of file wiiuse.c.

References wiiuse_send().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_set_motion_plus ( struct wiimote_t *  wm,
int  status 
)

Enable/disable Motion+ expansion.

Parameters
wmPointer to the wiimote with Motion+
status0 - off, 1 - on, standalone, 2 - nunchuk pass-through

Definition at line 184 of file motion_plus.c.

References disable_expansion(), and wiiuse_write_data_cb().

+ Here is the call graph for this function:

WIIUSE_EXPORT void wiiuse_set_nunchuk_accel_threshold ( struct wiimote_t *  wm,
int  threshold 
)

Set the accelerometer event threshold for the nunchuk.

Parameters
wmPointer to a wiimote_t structure with a nunchuk attached.
thresholdThe decimal place that should be considered a significant change.

See wiiuse_set_orient_threshold() for details.

Definition at line 206 of file nunchuk.c.

WIIUSE_EXPORT void wiiuse_set_nunchuk_orient_threshold ( struct wiimote_t *  wm,
float  threshold 
)

Set the orientation event threshold for the nunchuk.

Parameters
wmPointer to a wiimote_t structure with a nunchuk attached.
thresholdThe decimal place that should be considered a significant change.

See wiiuse_set_orient_threshold() for details.

Definition at line 189 of file nunchuk.c.

WIIUSE_EXPORT void wiiuse_set_orient_threshold ( struct wiimote_t *  wm,
float  threshold 
)

Set the orientation event threshold.

Parameters
wmPointer to a wiimote_t structure.
thresholdThe decimal place that should be considered a significant change.

If threshold is 0.01, and any angle changes by 0.01 then a significant change has occurred and the event callback will be invoked. If threshold is 1 then the angle has to change by a full degree to generate an event.

Definition at line 796 of file wiiuse.c.

WIIUSE_EXPORT void wiiuse_set_output ( enum wiiuse_loglevel  loglevel,
FILE *  logfile 
)

Specify an alternate FILE stream for a log level.

Parameters
loglevelThe loglevel, for which the output should be set.
logfileA valid, writeable FILE*, or 0, if output should be disabled.

The default FILE* for all loglevels is stderr

Definition at line 70 of file wiiuse.c.

References logtarget.

WIIUSE_EXPORT float wiiuse_set_smooth_alpha ( struct wiimote_t *  wm,
float  alpha 
)

Set the wiimote smoothing alpha value.

Parameters
wmPointer to a wiimote_t structure.
alphaThe alpha value to set. Between 0 and 1.
Returns
Returns the old alpha value.

The alpha value is between 0 and 1 and is used in an exponential smoothing algorithm.

Smoothing is only performed if the WIIMOTE_USE_SMOOTHING is set.

Definition at line 744 of file wiiuse.c.

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.

Parameters
wmArray of wiimote_t structures.
wiimotesNumber of objects in the wm array.
normal_timeoutThe timeout in milliseconds for a normal read.
exp_timeoutThe timeout in millisecondsd to wait for an expansion handshake.

Definition at line 845 of file wiiuse.c.

WIIUSE_EXPORT void wiiuse_set_wii_board_calib ( struct wiimote_t *  wm)
Todo:
not implemented!

Definition at line 145 of file wiiboard.c.

WIIUSE_EXPORT void wiiuse_status ( struct wiimote_t *  wm)

Request the wiimote controller status.

Parameters
wmPointer to a wiimote_t structure.

Controller status includes: battery level, LED status, expansions

Definition at line 489 of file wiiuse.c.

References read_req_t::buf, and wiiuse_send().

Referenced by handshake_expansion(), and wiiuse_handshake().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WIIUSE_EXPORT void wiiuse_toggle_rumble ( struct wiimote_t *  wm)

Toggle the state of the rumble.

Parameters
wmPointer to a wiimote_t structure.

Definition at line 238 of file wiiuse.c.

References wiiuse_rumble().

+ Here is the call graph for this function:

WIIUSE_EXPORT int wiiuse_update ( struct wiimote_t **  wm,
int  wiimotes,
wiiuse_update_cb  callback 
)

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.

Returns
Number of wiimotes that had an event.

Definition at line 78 of file events.c.

References wiiuse_poll().

+ Here is the call graph for this function:

WIIUSE_EXPORT int wiiuse_write_data ( struct wiimote_t *  wm,
unsigned int  addr,
const byte *  data,
byte  len 
)

Write data to the wiimote.

Parameters
wmPointer to a wiimote_t structure.
addrThe address to write to.
dataThe data to be written to the memory location.
lenThe length of the block to be written.

Definition at line 538 of file wiiuse.c.

References buffer_big_endian_uint32_t(), buffer_big_endian_uint8_t(), and wiiuse_send().

Referenced by wiiuse_send_next_pending_write_request(), wiiuse_set_ir(), and wiiuse_set_ir_sensitivity().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: