Skip to content

Commit

Permalink
issue 68
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 19, 2011
1 parent 0067863 commit 3f99acd
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 91 deletions.
46 changes: 26 additions & 20 deletions sixaxis-emu/calibration.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#define DEFAULT_MULTIPLIER_STEP 0.01
#define EXPONENT_STEP 0.01
#define DURATION 1000000 //1s

extern int refresh;
extern int mean_axis_value;
Expand All @@ -43,14 +44,19 @@ static int test_time = 1000;
*/
s_mouse_cal mouse_cal[MAX_DEVICES][MAX_CONFIGURATIONS] = {};

#define DURATION 1000000 //1s
int mouse_controller[MAX_DEVICES];

inline int cal_get_controller(int controller)
{
return mouse_controller[controller];
}

void cal_init()
{
memset(mouse_cal, 0x00, sizeof(mouse_cal));
}

s_mouse_cal* cal_get_mouse(int mouse, int conf)
inline s_mouse_cal* cal_get_mouse(int mouse, int conf)
{
return &(mouse_cal[mouse][conf]);
}
Expand Down Expand Up @@ -368,8 +374,8 @@ void cal_key(int device_id, int sym, int down)
{
printf("calibrating dead zone x\n");
current_cal = DZX;
mc->merge_x[mc->merge_x_index] = 1;
mc->merge_y[mc->merge_y_index] = 0;
mc->merge_x[mc->index] = 1;
mc->merge_y[mc->index] = 0;
mc->change = 1;
}
}
Expand All @@ -381,8 +387,8 @@ void cal_key(int device_id, int sym, int down)
{
printf("calibrating dead zone y\n");
current_cal = DZY;
mc->merge_x[mc->merge_x_index] = 0;
mc->merge_y[mc->merge_y_index] = 1;
mc->merge_x[mc->index] = 0;
mc->merge_y[mc->index] = 1;
mc->change = 1;
}
}
Expand All @@ -394,8 +400,8 @@ void cal_key(int device_id, int sym, int down)
{
printf("calibrating dead zone shape\n");
current_cal = DZS;
mc->merge_x[mc->merge_x_index] = 1;
mc->merge_y[mc->merge_y_index] = 1;
mc->merge_x[mc->index] = 1;
mc->merge_y[mc->index] = 1;
mc->change = 1;
}
}
Expand Down Expand Up @@ -525,8 +531,8 @@ void cal_button(int which, int button)
{
*mcal->dzx = mean_axis_value;
}
mc->merge_x[mc->merge_x_index] = 1;
mc->merge_y[mc->merge_y_index] = 0;
mc->merge_x[mc->index] = 1;
mc->merge_y[mc->index] = 0;
mc->change = 1;
}
break;
Expand All @@ -538,8 +544,8 @@ void cal_button(int which, int button)
{
*mcal->dzy = mean_axis_value;
}
mc->merge_x[mc->merge_x_index] = 0;
mc->merge_y[mc->merge_y_index] = 1;
mc->merge_x[mc->index] = 0;
mc->merge_y[mc->index] = 1;
mc->change = 1;
}
break;
Expand All @@ -554,8 +560,8 @@ void cal_button(int which, int button)
{
*mcal->dzs = E_SHAPE_CIRCLE;
}
mc->merge_x[mc->merge_x_index] = 1;
mc->merge_y[mc->merge_y_index] = 1;
mc->merge_x[mc->index] = 1;
mc->merge_y[mc->index] = 1;
mc->change = 1;
}
break;
Expand Down Expand Up @@ -620,8 +626,8 @@ void cal_button(int which, int button)
{
*mcal->dzx = 0;
}
mc->merge_x[mc->merge_x_index] = -1;
mc->merge_y[mc->merge_y_index] = 0;
mc->merge_x[mc->index] = -1;
mc->merge_y[mc->index] = 0;
mc->change = 1;
}
break;
Expand All @@ -633,8 +639,8 @@ void cal_button(int which, int button)
{
*mcal->dzy = 0;
}
mc->merge_x[mc->merge_x_index] = 0;
mc->merge_y[mc->merge_y_index] = -1;
mc->merge_x[mc->index] = 0;
mc->merge_y[mc->index] = -1;
mc->change = 1;
}
break;
Expand All @@ -649,8 +655,8 @@ void cal_button(int which, int button)
{
*mcal->dzs = E_SHAPE_CIRCLE;
}
mc->merge_x[mc->merge_x_index] = -1;
mc->merge_y[mc->merge_y_index] = -1;
mc->merge_x[mc->index] = -1;
mc->merge_y[mc->index] = -1;
mc->change = 1;
}
break;
Expand Down
3 changes: 2 additions & 1 deletion sixaxis-emu/calibration.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

void cal_button(int, int);
void cal_key(int, int, int);
s_mouse_cal* cal_get_mouse(int, int);
inline s_mouse_cal* cal_get_mouse(int, int);
int cal_skip_event(SDL_Event*);
void cal_init();
inline int cal_get_controller(int);

#endif /* CALIBRATION_H_ */
Loading

0 comments on commit 3f99acd

Please sign in to comment.