xbmc
Macros | Functions
example.c File Reference

Example using the wiiuse API. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "wiiuse.h"
Include dependency graph for example.c:

Macros

#define MAX_WIIMOTES   4
 

Functions

void handle_event (struct wiimote_t *wm)
 Callback that handles an event. More...
 
void handle_read (struct wiimote_t *wm, byte *data, unsigned short len)
 Callback that handles a read event. More...
 
void handle_ctrl_status (struct wiimote_t *wm)
 Callback that handles a controller status event. More...
 
void handle_disconnect (wiimote *wm)
 Callback that handles a disconnection event. More...
 
void test (struct wiimote_t *wm, byte *data, unsigned short len)
 
int main (int argc, char **argv)
 main() More...
 

Detailed Description

Example using the wiiuse API.

This file is an example of how to use the wiiuse library.

Function Documentation

◆ handle_ctrl_status()

void handle_ctrl_status ( struct wiimote_t wm)

Callback that handles a controller status event.

Parameters
wmPointer to a wiimote_t structure.
attachmentIs there an attachment? (1 for yes, 0 for no)
speakerIs the speaker enabled? (1 for yes, 0 for no)
irIs the IR support enabled? (1 for yes, 0 for no)
ledWhat LEDs are lit.
battery_levelBattery level, between 0.0 (0%) and 1.0 (100%).

This occurs when either the controller status changed or the controller status was requested explicitly by wiiuse_status().

One reason the status can change is if the nunchuk was inserted or removed from the expansion port.

◆ handle_disconnect()

void handle_disconnect ( wiimote wm)

Callback that handles a disconnection event.

Parameters
wmPointer to a wiimote_t structure.

This can happen if the POWER button is pressed, or if the connection is interrupted.

◆ handle_event()

void handle_event ( struct wiimote_t wm)

Callback that handles an event.

Parameters
wmPointer to a wiimote_t structure.

This function is called automatically by the wiiuse library when an event occurs on the specified wiimote.

◆ handle_read()

void handle_read ( struct wiimote_t wm,
byte *  data,
unsigned short  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.

This function is called automatically by the wiiuse library when the wiimote has returned the full data requested by a previous call to wiiuse_read_data().

You can read data on the wiimote, such as Mii data, if you know the offset address and the length.

The data pointer was specified on the call to wiiuse_read_data(). At the time of this function being called, it is not safe to deallocate this buffer.

◆ main()

int main ( int  argc,
char **  argv 
)

main()

Connect to up to two wiimotes and print any events that occur on either device.