src/ir.c File Reference

Handles IR data. More...

#include
#include
#include
#include "definitions.h"
#include "wiiuse_internal.h"
#include "ir.h"

Include dependency graph for ir.c:


Functions

static int  get_ir_sens (struct wiimote_t *wm, char **block1, char **block2)
  Get the IR sensitivity settings.
static void  interpret_ir_data (struct wiimote_t *wm)
  Interpret IR data into more user friendly variables.
static void  fix_rotated_ir_dots (struct ir_dot_t *dot, float ang)
  Fix the rotation of the IR dots.
static void  get_ir_dot_avg (struct ir_dot_t *dot, int *x, int *y)
  Average IR dots.
static void  reorder_ir_dots (struct ir_dot_t *dot)
  Reorder the IR dots.
static float  ir_distance (struct ir_dot_t *dot)
  Calculate the distance between the first 2 visible IR dots.
static int  ir_correct_for_bounds (int *x, int *y, enum aspect_t aspect, int offset_x, int offset_y)
  Correct for the IR bounding box.
static void  ir_convert_to_vres (int *x, int *y, enum aspect_t aspect, int vx, int vy)
  Interpolate the point to the user defined virtual screen resolution.
void  wiiuse_set_ir (struct wiimote_t *wm, int status)
  Set if the wiimote should track IR targets.
void  wiiuse_set_ir_vres (struct wiimote_t *wm, unsigned int x, unsigned int y)
  Set the virtual screen resolution for IR tracking.
void  wiiuse_set_ir_position (struct wiimote_t *wm, enum ir_position_t pos)
  Set the XY position for the IR cursor.
void  wiiuse_set_aspect_ratio (struct wiimote_t *wm, enum aspect_t aspect)
  Set the aspect ratio of the TV/monitor.
void  wiiuse_set_ir_sensitivity (struct wiimote_t *wm, int level)
  Set the IR sensitivity.
void  calculate_basic_ir (struct wiimote_t *wm, byte *data)
  Calculate the data from the IR spots. Basic IR mode.
void  calculate_extended_ir (struct wiimote_t *wm, byte *data)
  Calculate the data from the IR spots. Extended IR mode.
float  calc_yaw (struct ir_t *ir)
  Calculate yaw given the IR data.

Detailed Description

Handles IR data.


Function Documentation

float calc_yaw ( struct ir_t ir  ) 

Calculate yaw given the IR data.

Parameters:
ir  IR data structure.

void calculate_basic_ir ( struct wiimote_t wm,
byte *  data  
)

Calculate the data from the IR spots. Basic IR mode.

Parameters:
wm  Pointer to a wiimote_t structure.
data  Data returned by the wiimote for the IR spots.

void calculate_extended_ir ( struct wiimote_t wm,
byte *  data  
)

Calculate the data from the IR spots. Extended IR mode.

Parameters:
wm  Pointer to a wiimote_t structure.
data  Data returned by the wiimote for the IR spots.

static void fix_rotated_ir_dots ( struct ir_dot_t dot,
float  ang  
) [static]

Fix the rotation of the IR dots.

Parameters:
dot  An array of 4 ir_dot_t objects.
ang  The roll angle to correct by (-180, 180)
If there is roll then the dots are rotated around the origin and give a false cursor position. Correct for the roll.

If the accelerometer is off then obviously this will not do anything and the cursor position may be inaccurate.

static void get_ir_dot_avg ( struct ir_dot_t dot,
int *  x,
int *  y  
) [static]

Average IR dots.

Parameters:
dot  An array of 4 ir_dot_t objects.
x  [out] Average X
y  [out] Average Y

static int get_ir_sens ( struct wiimote_t wm,
char **  block1,
char **  block2  
) [static]

Get the IR sensitivity settings.

Parameters:
wm  Pointer to a wiimote_t structure.
block1  [out] Pointer to where block1 will be set.
block2  [out] Pointer to where block2 will be set.
Returns:
Returns the sensitivity level.

static void interpret_ir_data ( struct wiimote_t wm  )  [static]

Interpret IR data into more user friendly variables.

Parameters:
wm  Pointer to a wiimote_t structure.

static int ir_correct_for_bounds ( int *  x,
int *  y,
enum aspect_t  aspect,
int  offset_x,
int  offset_y  
) [static]

Correct for the IR bounding box.

Parameters:
x  [out] The current X, it will be updated if valid.
y  [out] The current Y, it will be updated if valid.
aspect  Aspect ratio of the screen.
offset_x  The X offset of the bounding box.
offset_y  The Y offset of the bounding box.
Returns:
Returns 1 if the point is valid and was updated.
Nintendo was smart with this bit. They sacrifice a little precision for a big increase in usability.

static float ir_distance ( struct ir_dot_t dot  )  [static]

Calculate the distance between the first 2 visible IR dots.

Parameters:
dot  An array of 4 ir_dot_t objects.

static void reorder_ir_dots ( struct ir_dot_t dot  )  [static]

Reorder the IR dots.

Parameters:
dot  An array of 4 ir_dot_t objects.

void wiiuse_set_aspect_ratio ( struct wiimote_t wm,
enum aspect_t  aspect  
)

Set the aspect ratio of the TV/monitor.

Parameters:
wm  Pointer to a wiimote_t structure.
aspect  Either WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3

void wiiuse_set_ir ( struct wiimote_t wm,
int  status  
)

Set if the wiimote should track IR targets.

Parameters:
wm  Pointer to a wiimote_t structure.
status  1 to enable, 0 to disable.

void wiiuse_set_ir_position ( struct wiimote_t wm,
enum ir_position_t  pos  
)

Set the XY position for the IR cursor.

Parameters:
wm  Pointer to a wiimote_t structure.

void wiiuse_set_ir_sensitivity ( struct wiimote_t wm,
int  level  
)

Set the IR sensitivity.

Parameters:
wm  Pointer to a wiimote_t structure.
level  1-5, same as Wii system sensitivity setting.
If the level is < 1, then level will be set to 1. If the level is > 5, then level will be set to 5.

void wiiuse_set_ir_vres ( struct wiimote_t wm,
unsigned int  x,
unsigned int  y  
)

Set the virtual screen resolution for IR tracking.

Parameters:
wm  Pointer to a wiimote_t structure.
status  1 to enable, 0 to disable.


Generated on Wed Apr 2 19:30:09 2008 for wiiuse by  doxygen 1.5.4