xbmc
|
General wiimote operations. More...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "events.h"
#include "io.h"
Functions | |
const char * | wiiuse_version () |
Returns the version of the library. | |
void | wiiuse_cleanup (struct wiimote_t **wm, int wiimotes) |
Clean up wiimote_t array created by wiiuse_init() | |
struct wiimote_t ** | wiiuse_init (int wiimotes) |
Initialize an array of wiimote structures. More... | |
void | wiiuse_disconnected (struct wiimote_t *wm) |
The wiimote disconnected. More... | |
void | wiiuse_rumble (struct wiimote_t *wm, int status) |
Enable or disable the rumble. More... | |
void | wiiuse_toggle_rumble (struct wiimote_t *wm) |
Toggle the state of the rumble. More... | |
void | wiiuse_set_leds (struct wiimote_t *wm, int leds) |
Set the enabled LEDs. More... | |
void | wiiuse_motion_sensing (struct wiimote_t *wm, int status) |
Set if the wiimote should report motion sensing. More... | |
int | wiiuse_set_report_type (struct wiimote_t *wm) |
Set the report type based on the current wiimote state. More... | |
int | wiiuse_read_data_cb (struct wiimote_t *wm, wiiuse_read_cb read_cb, byte *buffer, unsigned int addr, unsigned short len) |
Read data from the wiimote (callback version). More... | |
int | wiiuse_read_data (struct wiimote_t *wm, byte *buffer, unsigned int addr, unsigned short len) |
Read data from the wiimote (event version). More... | |
void | wiiuse_send_next_pending_read_request (struct wiimote_t *wm) |
Send the next pending data read request to the wiimote. More... | |
void | wiiuse_status (struct wiimote_t *wm) |
Request the wiimote controller status. More... | |
struct wiimote_t * | wiiuse_get_by_id (struct wiimote_t **wm, int wiimotes, int unid) |
Find a wiimote_t structure by its unique identifier. More... | |
int | wiiuse_write_data (struct wiimote_t *wm, unsigned int addr, byte *data, byte len) |
Write data to the wiimote. More... | |
int | wiiuse_send (struct wiimote_t *wm, byte report_type, byte *msg, int len) |
Send a packet to the wiimote. More... | |
int | wiiuse_set_flags (struct wiimote_t *wm, int enable, int disable) |
Set flags for the specified wiimote. More... | |
float | wiiuse_set_smooth_alpha (struct wiimote_t *wm, float alpha) |
Set the wiimote smoothing alpha value. More... | |
void | wiiuse_set_bluetooth_stack (struct wiimote_t **wm, int wiimotes, enum win_bt_stack_t type) |
Set the bluetooth stack type to use. More... | |
void | wiiuse_set_orient_threshold (struct wiimote_t *wm, float threshold) |
Set the orientation event threshold. More... | |
void | wiiuse_set_accel_threshold (struct wiimote_t *wm, int threshold) |
Set the accelerometer event threshold. More... | |
void | wiiuse_resync (struct wiimote_t *wm) |
Try to resync with the wiimote by starting a new handshake. More... | |
void | wiiuse_set_timeout (struct wiimote_t **wm, int wiimotes, byte normal_timeout, byte exp_timeout) |
Set the normal and expansion handshake timeouts. More... | |
General wiimote operations.
The file includes functions that handle general tasks. Most of these are functions that are part of the API.
void wiiuse_disconnected | ( | struct wiimote_t * | wm | ) |
struct wiimote_t** wiiuse_init | ( | int | wiimotes | ) |
Initialize an array of wiimote structures.
wiimotes | Number of wiimote_t structures to create. |
The array returned by this function can be passed to various functions, including wiiuse_connect().
void wiiuse_motion_sensing | ( | struct wiimote_t * | wm, |
int | status | ||
) |
int wiiuse_read_data | ( | struct wiimote_t * | wm, |
byte * | buffer, | ||
unsigned int | addr, | ||
unsigned short | len | ||
) |
Read data from the wiimote (event version).
wm | Pointer to a wiimote_t structure. |
buffer | An allocated buffer to store the data as it arrives from the wiimote. Must be persistent in memory and large enough to hold the data. |
addr | The address of wiimote memory to read from. |
len | The 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.
int wiiuse_read_data_cb | ( | struct wiimote_t * | wm, |
wiiuse_read_cb | read_cb, | ||
byte * | buffer, | ||
unsigned int | addr, | ||
unsigned short | len | ||
) |
Read data from the wiimote (callback version).
wm | Pointer to a wiimote_t structure. |
read_cb | Function pointer to call when the data arrives from the wiimote. |
buffer | An allocated buffer to store the data as it arrives from the wiimote. Must be persistent in memory and large enough to hold the data. |
addr | The address of wiimote memory to read from. |
len | The 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.
void wiiuse_resync | ( | struct wiimote_t * | wm | ) |
void wiiuse_rumble | ( | struct wiimote_t * | wm, |
int | status | ||
) |
int wiiuse_send | ( | struct wiimote_t * | wm, |
byte | report_type, | ||
byte * | msg, | ||
int | len | ||
) |
void wiiuse_send_next_pending_read_request | ( | struct wiimote_t * | wm | ) |
Send the next pending data read request to the wiimote.
This function is not part of the wiiuse API.
void wiiuse_set_accel_threshold | ( | struct wiimote_t * | wm, |
int | threshold | ||
) |
void wiiuse_set_bluetooth_stack | ( | struct wiimote_t ** | wm, |
int | wiimotes, | ||
enum win_bt_stack_t | type | ||
) |
Set the bluetooth stack type to use.
wm | Array of wiimote_t structures. |
wiimotes | Number of objects in the wm array. |
type | The type of bluetooth stack to use. |
int wiiuse_set_flags | ( | struct wiimote_t * | wm, |
int | enable, | ||
int | disable | ||
) |
void wiiuse_set_leds | ( | struct wiimote_t * | wm, |
int | leds | ||
) |
void wiiuse_set_orient_threshold | ( | struct wiimote_t * | wm, |
float | threshold | ||
) |
Set the orientation event threshold.
wm | Pointer to a wiimote_t structure. |
threshold | The 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.
int wiiuse_set_report_type | ( | struct wiimote_t * | wm | ) |
Set the report type based on the current wiimote state.
The wiimote reports formatted packets depending on the report type that was last requested. This function will update the type of report that should be sent based on the current state of the device.
float wiiuse_set_smooth_alpha | ( | struct wiimote_t * | wm, |
float | alpha | ||
) |
Set the wiimote smoothing 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.
void wiiuse_set_timeout | ( | struct wiimote_t ** | wm, |
int | wiimotes, | ||
byte | normal_timeout, | ||
byte | exp_timeout | ||
) |
Set the normal and expansion handshake timeouts.
wm | Array of wiimote_t structures. |
wiimotes | Number of objects in the wm array. |
normal_timeout | The timeout in milliseconds for a normal read. |
exp_timeout | The timeout in millisecondsd to wait for an expansion handshake. |
void wiiuse_status | ( | struct wiimote_t * | wm | ) |
void wiiuse_toggle_rumble | ( | struct wiimote_t * | wm | ) |