xbmc
Macros | Functions
events.c File Reference

Handles wiimote events. More...

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
#include <math.h>
#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"
Include dependency graph for events.c:

Macros

#define STATE_CHANGED(a, b)   if (a != b) return 1
 
#define CROSS_THRESH(last, now, thresh)
 
#define CROSS_THRESH_XYZ(last, now, thresh)
 

Functions

int wiiuse_poll (struct wiimote_t **wm, int wiimotes)
 Poll the wiimotes for any events. More...
 
void wiiuse_pressed_buttons (struct wiimote_t *wm, byte *msg)
 Find what buttons are pressed. More...
 
void handshake_expansion (struct wiimote_t *wm, byte *data, unsigned short len)
 Handle the handshake data from the expansion device. More...
 
void disable_expansion (struct wiimote_t *wm)
 Disable the expansion device if it was enabled. More...
 

Detailed Description

Handles wiimote events.

The file includes functions that handle the events that are sent from the wiimote to us.

Macro Definition Documentation

◆ CROSS_THRESH

#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)

◆ CROSS_THRESH_XYZ

#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)

Function Documentation

◆ disable_expansion()

void disable_expansion ( struct wiimote_t wm)

Disable the expansion device if it was enabled.

Parameters
wmA pointer to a wiimote_t structure.
dataThe data read in from the device.
lenThe length of the data block, in bytes.

If the data is NULL then this function will try to start a handshake with the expansion.

◆ handshake_expansion()

void handshake_expansion ( struct wiimote_t wm,
byte *  data,
unsigned short  len 
)

Handle the handshake data from the expansion device.

Parameters
wmA pointer to a wiimote_t structure.
dataThe data read in from the device.
lenThe length of the data block, in bytes.

Tries to determine what kind of expansion was attached and invoke the correct handshake function.

If the data is NULL then this function will try to start a handshake with the expansion.

◆ wiiuse_poll()

int wiiuse_poll ( struct wiimote_t **  wm,
int  wiimotes 
)

Poll the wiimotes for any events.

Parameters
wmAn array of pointers to wiimote_t structures.
wiimotesThe number of wiimote_t structures in the wm array.
Returns
Returns number of wiimotes that an event has occurred on.

It is necessary to poll the wiimote devices for events that occur. If an event occurs on a particular wiimote, the event variable will be set.

◆ wiiuse_pressed_buttons()

void wiiuse_pressed_buttons ( struct wiimote_t wm,
byte *  msg 
)

Find what buttons are pressed.

Parameters
wmPointer to a wiimote_t structure.
msgThe message specified in the event packet.