wiiuse
Functions
Internal: Device I/O

Functions

void wiiuse_handshake (struct wiimote_t *wm, byte *data, uint16_t len)
 Get initialization data from the wiimote. More...
 
int wiiuse_wait_report (struct wiimote_t *wm, int report, byte *buffer, int bufferLength, unsigned long timeout_ms)
 Wait until specified report arrives and return it. More...
 
void wiiuse_read_data_sync (struct wiimote_t *wm, byte memory, unsigned addr, unsigned short size, byte *data)
 Read memory/register data synchronously. More...
 
void wiiuse_init_platform_fields (struct wiimote_t *wm)
 
void wiiuse_cleanup_platform_fields (struct wiimote_t *wm)
 
int wiiuse_os_find (struct wiimote_t **wm, int max_wiimotes, int timeout)
 
int wiiuse_os_connect (struct wiimote_t **wm, int wiimotes)
 
void wiiuse_os_disconnect (struct wiimote_t *wm)
 
int wiiuse_os_poll (struct wiimote_t **wm, int wiimotes)
 
int wiiuse_os_read (struct wiimote_t *wm, byte *buf, int len)
 
int wiiuse_os_write (struct wiimote_t *wm, byte report_type, byte *buf, int len)
 
unsigned long wiiuse_os_ticks ()
 

Detailed Description

Function Documentation

◆ wiiuse_handshake()

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

Get initialization data from the wiimote.

Parameters
wmPointer to a wiimote_t structure.
dataunused
lenunused

When first called for a wiimote_t structure, a request is sent to the wiimote for initialization information. This includes factory set accelerometer data. The handshake will be concluded when the wiimote responds with this data.

◆ wiiuse_read_data_sync()

void wiiuse_read_data_sync ( struct wiimote_t wm,
byte  memory,
unsigned  addr,
unsigned short  size,
byte *  data 
)

Read memory/register data synchronously.

Parameters
wmPointer to a wiimote_t structure.
memoryIf set to non-zero, reads EEPROM, otherwise registers
addrAddress offset to read from
sizeHow many bytes to read
dataPre-allocated memory to store the received data

Synchronous/blocking read, this function will not return until it receives the specified amount of data from the Wiimote.

◆ wiiuse_wait_report()

int wiiuse_wait_report ( struct wiimote_t wm,
int  report,
byte *  buffer,
int  bufferLength,
unsigned long  timeout_ms 
)

Wait until specified report arrives and return it.

Parameters
wmPointer to a wiimote_t structure.
bufferPre-allocated memory to store the received data
bufferLengthsize of buffer in bytes
timeout_mstimeout in ms, 0 = wait forever

Synchronous/blocking, this function will not return until it receives the specified report from the Wiimote or timeout occurs.

Returns 1 on success, -1 on failure.