wiiuse
Macros | Functions
events.c File Reference

Handles wiimote events. More...

#include "wiiuse_internal.h"
#include "events.h"
#include "classic.h"
#include "dynamics.h"
#include "guitar_hero_3.h"
#include "io.h"
#include "ir.h"
#include "motion_plus.h"
#include "nunchuk.h"
#include "wiiboard.h"
#include "tatacon.h"
#include "os.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for events.c:

Macros

#define STATE_CHANGED(a, b)
 
#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...
 
int wiiuse_update (struct wiimote_t **wiimotes, int nwiimotes, wiiuse_update_cb callback)
 Poll Wiimotes, and call the provided callback with information on each Wiimote that had an event. More...
 
void idle_cycle (struct wiimote_t *wm)
 Called on a cycle where no significant change occurs. More...
 
void clear_dirty_reads (struct wiimote_t *wm)
 Clear out all old 'dirty' read requests. More...
 
void propagate_event (struct wiimote_t *wm, byte event, byte *msg)
 Analyze the event that occurred on a wiimote. 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, uint16_t 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)

◆ STATE_CHANGED

#define STATE_CHANGED (   a,
 
)
Value:
if (a != b) \
return 1