| Version 6 (modified by dsmith, 6 years ago) |
|---|
API
wiimote_connect
Synopsis
wiimote_t *wiimote_connect(bdaddr_t bdaddr, wiimote_mesg_callback_t *mesg_callback, int *id);
Parameters
- bdaddr
- in: bluetooth device address of the wiimote. Use *BDADDR_ANY to connect to the any (one) available wiimote.
- mesg_callback
- in: message callback function
- id
- out: NULL, or pointer to unique id
Description
Connect to a wiimote.
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
