If you are using subversion sources, this page is out of date. It will be updated after the planned API overhaul.
API
wiimote_connect
Synopsis
wiimote_t *wiimote_connect(bdaddr_t *bdaddr, wiimote_mesg_callback_t *mesg_callback, int *id);
Parameters
- bdaddr
- pointer to bluetooth device address of the wiimote
- mesg_callback
- message callback function
- id
- NULL, or pointer to be populated with unique id
Description
Establish connection with a wiimote. Pass the address of a bdaddr set to *BDADDR_ANY to connect to any (one) available wiimote. In this case, the bdaddr will be filled with the address of the connected wiimote. Due to the bizarre way in which BlueZ implements BDADDR_ANY, it is not recommended that BDADDR_ANY not be passed directly to wiimote_connect if more than one wiimote connection will be made during the same instance of the program, as this may change the value of BDADDR_ANY.
Return Value
wiimote handle, or NULL on error
wiimote_disconnect
Synopsis
int wiimote_disconnect(wiimote_t *wiimote);
Parameters
- wiimote
- wiimote handle
Description
Disconnect from wiimote.
Return Value
zero on success or nonzero on error
wiimote_command
Synopsis
int wiimote_command(wiimote_t *wiimote, enum wiimote_command command, unsigned char flags);
Parameters
- wiimote
- wiimote handle
- command
- wiimote command
- flags
- command-specific flags
Description
Issue command to wiimote.
Commands and associated flags
- WIIMOTE_CMD_STATUS
- Request a status message (delivered to the message callback) (flags ignored)
- WIIMOTE_CMD_LED
- Set the LED state. The following flags may be bitwise ORed:
- WIIMOTE_LED1_ON
- WIIMOTE_LED2_ON
- WIIMOTE_LED3_ON
- WIIMOTE_LED4_ON
- WIIMOTE_CMD_RUMBLE
- Set the Rumble state. Set flags to 0 for off, anything else for on.
- WIIMOTE_CMD_RPT_MODE
- Set the reporting mode of the wiimote, which determines which messages are delivered to the message callback.
The following flags may be bitwise ORed (Note that it may not be assumed that each flag is a single bit - specifically, WIIMOTE_RPT_EXT = WIIMOTE_RPT_NUNCHUK | WIIMOTE_RPT_CLASSIC):
- WIIMOTE_RPT_STATUS
- WIIMOTE_RPT_BTN
- WIIMOTE_RPT_ACC
- WIIMOTE_RPT_IR
- WIIMOTE_RPT_NUNCHUK
- WIIMOTE_RPT_CLASSIC
- WIIMOTE_RPT_EXT
Return Value
zero on success or nonzero on error
wiimote_read
Synopsis
int wiimote_read(wiimote_t *wiimote, unsigned int flags, unsigned int offset, unsigned int len, unsigned char *data);
Parameters
- wiimote
- wiimote handle
- flags
- read flags
- offset
- start address
- len
- number of bytes to read
- data
- destination buffer
Description
Read data from the Wiimote. Mutually exclusive flags WIIMOTE_RW_EEPROM and WIIMOTE_RW_REG select the address space (EEPROM/flash or register, respectively). The WIIMOTE_RW_DECODE flag performs any necessary decoding algorithms to data read from the register address space.
Return Value
zero on success or nonzero on error
wiimote_write
Synopsis
int wiimote_write(wiimote_t *wiimote, unsigned int flags, unsigned int offset, unsigned int len, unsigned char *data);
Parameters
- wiimote
- wiimote handle
- flags
- write flags
- offset
- start address
- len
- number of bytes to write
- data
- source buffer
Description
Write data to the Wiimote. Mutually exclusive flags WIIMOTE_RW_EEPROM and WIIMOTE_RW_REG select the address space (EEPROM/flash or register, respectively). The WIIMOTE_RW_DECODE flag is ignored.
Return Value
zero on success or nonzero on error
wiimote_mesg_callback
Synopsis
typedef void wiimote_mesg_callback_t(int, int, union wiimote_mesg* []); void mesg_callback(int id, int mesg_count, union wiimote_mesg* mesg[]);
Parameters
- id
- unique wiimote identifier
- mesg_count
- count of elements in mesg array
- mesg
- array of pointers to wiimote messages
Description
A pointer to a function of this type is passed to wiimote_connect, and is called when data is received from wiimote for which reporting has been enabled with wiimote_command.
