#include
#include
#include
#include
#include
#include
#include
#include "definitions.h"
#include "io.h"
#include "wiiuse_internal.h"
#include "dynamics.h"
#include "ir.h"
#include "nunchuk.h"
#include "classic.h"
#include "guitar_hero_3.h"
#include "events.h"
Defines |
|
#define | STATE_CHANGED(a, b) if (a != b) return 1 |
#define | CROSS_THRESH(last, now, thresh) |
#define | CROSS_THRESH_XYZ(last, now, thresh) |
Functions |
|
static void | idle_cycle (struct wiimote_t *wm) |
Called on a cycle where no significant change occurs. |
|
static void | clear_dirty_reads (struct wiimote_t *wm) |
Clear out all old 'dirty' read requests. |
|
static void | propagate_event (struct wiimote_t *wm, byte event, byte *msg) |
Analyze the event that occured on a wiimote. |
|
static void | event_data_read (struct wiimote_t *wm, byte *msg) |
Received a data packet from a read request. |
|
static void | event_status (struct wiimote_t *wm, byte *msg) |
Read the controller status. |
|
static void | handle_expansion (struct wiimote_t *wm, byte *msg) |
Handle data from the expansion. |
|
static void | save_state (struct wiimote_t *wm) |
Save important state data. |
|
static int | state_changed (struct wiimote_t *wm) |
Determine if the current state differs significantly from the previous. |
|
int | wiiuse_poll (struct wiimote_t **wm, int wiimotes) |
Poll the wiimotes for any events. |
|
void | wiiuse_pressed_buttons (struct wiimote_t *wm, byte *msg) |
Find what buttons are pressed. |
|
void | handshake_expansion (struct wiimote_t *wm, byte *data, unsigned short len) |
Handle the handshake data from the expansion device. |
|
void | disable_expansion (struct wiimote_t *wm) |
Disable the expansion device if it was enabled. |
The file includes functions that handle the events that are sent from the wiimote to us.
#define CROSS_THRESH | ( | last, | |||
now, | |||||
thresh | ) |
Value:
do { \ if (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_ORIENT_THRESH)) { \ if ((diff_f(last.roll, now.roll) >= thresh) || \ (diff_f(last.pitch, now.pitch) >= thresh) || \ (diff_f(last.yaw, now.yaw) >= thresh)) \ { \ last = now; \ return 1; \ } \ } else { \ if (last.roll != now.roll) return 1; \ if (last.pitch != now.pitch) return 1; \ if (last.yaw != now.yaw) return 1; \ } \ } while (0)
#define CROSS_THRESH_XYZ | ( | last, | |||
now, | |||||
thresh | ) |
Value:
do { \ if (WIIMOTE_IS_FLAG_SET(wm, WIIUSE_ORIENT_THRESH)) { \ if ((diff_f(last.x, now.x) >= thresh) || \ (diff_f(last.y, now.y) >= thresh) || \ (diff_f(last.z, now.z) >= thresh)) \ { \ last = now; \ return 1; \ } \ } else { \ if (last.x != now.x) return 1; \ if (last.y != now.y) return 1; \ if (last.z != now.z) return 1; \ } \ } while (0)
static void clear_dirty_reads | ( | struct wiimote_t * | wm | ) | [static] |
Clear out all old 'dirty' read requests.
wm | Pointer to a wiimote_t structure. |
void disable_expansion | ( | struct wiimote_t * | wm | ) |
Disable the expansion device if it was enabled.
wm | A pointer to a wiimote_t structure. | |
data | The data read in from the device. | |
len | The length of the data block, in bytes. |
static void event_data_read | ( | struct wiimote_t * | wm, | |
byte * | msg | |||
) | [static] |
Received a data packet from a read request.
wm | Pointer to a wiimote_t structure. | |
msg | The message specified in the event packet. |
static void event_status | ( | struct wiimote_t * | wm, | |
byte * | msg | |||
) | [static] |
Read the controller status.
wm | Pointer to a wiimote_t structure. | |
msg | The message specified in the event packet. |
static void handle_expansion | ( | struct wiimote_t * | wm, | |
byte * | msg | |||
) | [static] |
Handle data from the expansion.
wm | A pointer to a wiimote_t structure. | |
msg | The message specified in the event packet for the expansion. |
void handshake_expansion | ( | struct wiimote_t * | wm, | |
byte * | data, | |||
unsigned short | len | |||
) |
Handle the handshake data from the expansion device.
wm | A pointer to a wiimote_t structure. | |
data | The data read in from the device. | |
len | The length of the data block, in bytes. |
If the data is NULL then this function will try to start a handshake with the expansion.
static void idle_cycle | ( | struct wiimote_t * | wm | ) | [static] |
Called on a cycle where no significant change occurs.
wm | Pointer to a wiimote_t structure. |
static void propagate_event | ( | struct wiimote_t * | wm, | |
byte | event, | |||
byte * | msg | |||
) | [static] |
Analyze the event that occured on a wiimote.
wm | An array of pointers to wiimote_t structures. | |
event | The event that occured. | |
msg | The message specified in the event packet. |
static void save_state | ( | struct wiimote_t * | wm | ) | [static] |
Save important state data.
wm | A pointer to a wiimote_t structure. |
static int state_changed | ( | struct wiimote_t * | wm | ) | [static] |
Determine if the current state differs significantly from the previous.
wm | A pointer to a wiimote_t structure. |
int wiiuse_poll | ( | struct wiimote_t ** | wm, | |
int | wiimotes | |||
) |
Poll the wiimotes for any events.
wm | An array of pointers to wiimote_t structures. | |
wiimotes | The number of wiimote_t structures in the wm array. |
void wiiuse_pressed_buttons | ( | struct wiimote_t * | wm, | |
byte * | msg | |||
) |
Find what buttons are pressed.
wm | Pointer to a wiimote_t structure. | |
msg | The message specified in the event packet. |