RetroArch
Macros | Enumerations | Functions
ir.c File Reference
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include "definitions.h"
#include "wiiuse_internal.h"
#include "ir.h"
Include dependency graph for ir.c:

Macros

#define HEIGHT   (384.0f / 512.0f)
 
#define MAX_SB_SLOPE   0.7f
 
#define MIN_SB_WIDTH   0.1f
 
#define SB_MIDDOT_REJECT   0.05f
 
#define SB_WIDTH   19.5f
 
#define SB_DOT_WIDTH   2.25f
 
#define SB_DOT_HEIGHT   1.0f
 
#define SB_DOT_WIDTH_RATIO   (SB_DOT_WIDTH / SB_WIDTH)
 
#define SB_DOT_HEIGHT_RATIO   (SB_DOT_HEIGHT / SB_WIDTH)
 
#define SB_OFF_SCREEN_X   0.0f
 
#define SB_OFF_SCREEN_Y   0.0f
 
#define SB_SINGLE_NOGUESS_DISTANCE   (100.0 * 100.0)
 
#define SB_Z_COEFFICIENT   256.0f
 
#define WIIMOTE_FOV_COEFFICIENT   0.39f
 
#define SQUARED(x)   ((x)*(x))
 
#define WMAX(x, y)   ((x>y)?(x):(y))
 
#define WMIN(x, y)   ((x<y)?(x):(y))
 
#define SMOOTH_IR_RADIUS   8.0f
 
#define SMOOTH_IR_SPEED   0.25f
 
#define SMOOTH_IR_DEADZONE   2.5f
 
#define ERROR_MAX_COUNT   8
 
#define GLITCH_MAX_COUNT   5
 
#define GLITCH_DIST   (150.0f * 150.0f)
 

Enumerations

enum  { IR_STATE_DEAD = 0, IR_STATE_GOOD, IR_STATE_SINGLE, IR_STATE_LOST }
 

Functions

static int ir_correct_for_bounds (float *x, float *y, enum aspect_t aspect, int offset_x, int offset_y)
 Correct for the IR bounding box. More...
 
static void ir_convert_to_vres (float *x, float *y, enum aspect_t aspect, unsigned int vx, unsigned int vy)
 Interpolate the point to the user defined virtual screen resolution. More...
 
static int get_ir_sens (struct wiimote_t *wm, char **block1, char **block2)
 Get the IR sensitivity settings. More...
 
static void rotate_dots (struct fdot_t *in, struct fdot_t *out, int count, float ang)
 
void wiiuse_set_ir_mode (struct wiimote_t *wm)
 
void wiiuse_set_ir (struct wiimote_t *wm, int status)
 
void wiiuse_set_ir_vres (struct wiimote_t *wm, unsigned int x, unsigned int y)
 Set the virtual screen resolution for IR tracking. More...
 
void wiiuse_set_ir_position (struct wiimote_t *wm, enum ir_position_t pos)
 Set the XY position for the IR cursor. More...
 
void wiiuse_set_aspect_ratio (struct wiimote_t *wm, enum aspect_t aspect)
 Set the aspect ratio of the TV/monitor. More...
 
void wiiuse_set_ir_sensitivity (struct wiimote_t *wm, int level)
 Set the IR sensitivity. More...
 
void calculate_basic_ir (struct wiimote_t *wm, ubyte *data)
 Calculate the data from the IR spots. Basic IR mode. More...
 
void calculate_extended_ir (struct wiimote_t *wm, ubyte *data)
 Calculate the data from the IR spots. Extended IR mode. More...
 
void find_sensorbar (struct ir_t *ir, struct orient_t *orient)
 Interpret IR data into more user friendly variables. More...
 
void apply_ir_smoothing (struct ir_t *ir)
 Smooth the IR pointer position. More...
 
void interpret_ir_data (struct ir_t *ir, struct orient_t *orient)
 Interpret IR data into more user friendly variables. More...
 
float calc_yaw (struct ir_t *ir)
 Calculate yaw given the IR data. More...
 

Macro Definition Documentation

◆ ERROR_MAX_COUNT

#define ERROR_MAX_COUNT   8

◆ GLITCH_DIST

#define GLITCH_DIST   (150.0f * 150.0f)

◆ GLITCH_MAX_COUNT

#define GLITCH_MAX_COUNT   5

◆ HEIGHT

#define HEIGHT   (384.0f / 512.0f)

◆ MAX_SB_SLOPE

#define MAX_SB_SLOPE   0.7f

◆ MIN_SB_WIDTH

#define MIN_SB_WIDTH   0.1f

◆ SB_DOT_HEIGHT

#define SB_DOT_HEIGHT   1.0f

◆ SB_DOT_HEIGHT_RATIO

#define SB_DOT_HEIGHT_RATIO   (SB_DOT_HEIGHT / SB_WIDTH)

◆ SB_DOT_WIDTH

#define SB_DOT_WIDTH   2.25f

◆ SB_DOT_WIDTH_RATIO

#define SB_DOT_WIDTH_RATIO   (SB_DOT_WIDTH / SB_WIDTH)

◆ SB_MIDDOT_REJECT

#define SB_MIDDOT_REJECT   0.05f

◆ SB_OFF_SCREEN_X

#define SB_OFF_SCREEN_X   0.0f

◆ SB_OFF_SCREEN_Y

#define SB_OFF_SCREEN_Y   0.0f

◆ SB_SINGLE_NOGUESS_DISTANCE

#define SB_SINGLE_NOGUESS_DISTANCE   (100.0 * 100.0)

◆ SB_WIDTH

#define SB_WIDTH   19.5f

◆ SB_Z_COEFFICIENT

#define SB_Z_COEFFICIENT   256.0f

◆ SMOOTH_IR_DEADZONE

#define SMOOTH_IR_DEADZONE   2.5f

◆ SMOOTH_IR_RADIUS

#define SMOOTH_IR_RADIUS   8.0f

◆ SMOOTH_IR_SPEED

#define SMOOTH_IR_SPEED   0.25f

◆ SQUARED

#define SQUARED (   x)    ((x)*(x))

◆ WIIMOTE_FOV_COEFFICIENT

#define WIIMOTE_FOV_COEFFICIENT   0.39f

◆ WMAX

#define WMAX (   x,
  y 
)    ((x>y)?(x):(y))

◆ WMIN

#define WMIN (   x,
  y 
)    ((x<y)?(x):(y))

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IR_STATE_DEAD 
IR_STATE_GOOD 
IR_STATE_SINGLE 
IR_STATE_LOST 

Function Documentation

◆ apply_ir_smoothing()

void apply_ir_smoothing ( struct ir_t ir)

Smooth the IR pointer position.

Parameters
irPointer to an ir_t structure.
Here is the caller graph for this function:

◆ calc_yaw()

float calc_yaw ( struct ir_t ir)

Calculate yaw given the IR data.

Parameters
irIR data structure.
Here is the caller graph for this function:

◆ calculate_basic_ir()

void calculate_basic_ir ( struct wiimote_t wm,
ubyte data 
)

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

Parameters
wmPointer to a wiimote_t structure.
dataData returned by the wiimote for the IR spots.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_extended_ir()

void calculate_extended_ir ( struct wiimote_t wm,
ubyte data 
)

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

Parameters
wmPointer to a wiimote_t structure.
dataData returned by the wiimote for the IR spots.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_sensorbar()

void find_sensorbar ( struct ir_t ir,
struct orient_t orient 
)

Interpret IR data into more user friendly variables.

Parameters
wmPointer to a wiimote_t structure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_ir_sens()

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

Get the IR sensitivity settings.

Parameters
wmPointer 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.
Here is the caller graph for this function:

◆ interpret_ir_data()

void interpret_ir_data ( struct ir_t ir,
struct orient_t orient 
)

Interpret IR data into more user friendly variables.

Parameters
irPointer to an ir_t structure.
orientPointer to an orient_t structure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ir_convert_to_vres()

static void ir_convert_to_vres ( float *  x,
float *  y,
enum aspect_t  aspect,
unsigned int  vx,
unsigned int  vy 
)
static

Interpolate the point to the user defined virtual screen resolution.

Here is the caller graph for this function:

◆ ir_correct_for_bounds()

static int ir_correct_for_bounds ( float *  x,
float *  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.
aspectAspect ratio of the screen.
offset_xThe X offset of the bounding box.
offset_yThe 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.

Here is the caller graph for this function:

◆ rotate_dots()

static void rotate_dots ( struct fdot_t in,
struct fdot_t out,
int  count,
float  ang 
)
static
Here is the caller graph for this function:

◆ wiiuse_set_aspect_ratio()

void wiiuse_set_aspect_ratio ( struct wiimote_t wm,
enum aspect_t  aspect 
)

Set the aspect ratio of the TV/monitor.

Parameters
wmPointer to a wiimote_t structure.
aspectEither WIIUSE_ASPECT_16_9 or WIIUSE_ASPECT_4_3
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiiuse_set_ir()

void wiiuse_set_ir ( struct wiimote_t wm,
int  status 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiiuse_set_ir_mode()

void wiiuse_set_ir_mode ( struct wiimote_t wm)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiiuse_set_ir_position()

void wiiuse_set_ir_position ( struct wiimote_t wm,
enum ir_position_t  pos 
)

Set the XY position for the IR cursor.

Parameters
wmPointer to a wiimote_t structure.
Here is the caller graph for this function:

◆ wiiuse_set_ir_sensitivity()

void wiiuse_set_ir_sensitivity ( struct wiimote_t wm,
int  level 
)

Set the IR sensitivity.

Parameters
wmPointer to a wiimote_t structure.
level1-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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wiiuse_set_ir_vres()

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

Set the virtual screen resolution for IR tracking.

Parameters
wmPointer to a wiimote_t structure.
status1 to enable, 0 to disable.
Here is the caller graph for this function: