diff --git a/src/classic.c b/src/classic.c index db576b3..d543409 100644 --- a/src/classic.c +++ b/src/classic.c @@ -157,8 +157,8 @@ void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg) { rx = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7); ry = (msg[2] & 0x1F); - calc_joystick_state(&cc->ljs, lx, ly); - calc_joystick_state(&cc->rjs, rx, ry); + calc_joystick_state(&cc->ljs, (float)lx, (float)ly); + calc_joystick_state(&cc->rjs, (float)rx, (float)ry); } diff --git a/src/ir.c b/src/ir.c index 8c6e4cd..f7e833a 100644 --- a/src/ir.c +++ b/src/ir.c @@ -459,10 +459,10 @@ static void interpret_ir_data(struct wiimote_t* wm) { if (dot[i].order == 1) /* visible is the left dot - estimate where the right is */ - ox = dot[i].x + wm->ir.distance; + ox = (int32_t)(dot[i].x + wm->ir.distance); else if (dot[i].order == 2) /* visible is the right dot - estimate where the left is */ - ox = dot[i].x - wm->ir.distance; + ox = (int32_t)(dot[i].x - wm->ir.distance); x = ((signed int)dot[i].x + ox) / 2; y = dot[i].y; @@ -570,8 +570,8 @@ static void fix_rotated_ir_dots(struct ir_dot_t* dot, float ang) { return; } - s = sin(DEGREE_TO_RAD(ang)); - c = cos(DEGREE_TO_RAD(ang)); + s = sinf(DEGREE_TO_RAD(ang)); + c = cosf(DEGREE_TO_RAD(ang)); /* * [ cos(theta) -sin(theta) ][ ir->rx ] @@ -585,8 +585,8 @@ static void fix_rotated_ir_dots(struct ir_dot_t* dot, float ang) { x = dot[i].rx - (1024/2); y = dot[i].ry - (768/2); - dot[i].x = (c * x) + (-s * y); - dot[i].y = (s * x) + (c * y); + dot[i].x = (uint32_t)((c * x) + (-s * y)); + dot[i].y = (uint32_t)((s * x) + (c * y)); dot[i].x += (1024/2); dot[i].y += (768/2); @@ -673,7 +673,7 @@ static float ir_distance(struct ir_dot_t* dot) { xd = dot[i2].x - dot[i1].x; yd = dot[i2].y - dot[i1].y; - return sqrt(xd*xd + yd*yd); + return sqrtf(xd*xd + yd*yd); } @@ -738,8 +738,8 @@ static void ir_convert_to_vres(int* x, int* y, enum aspect_t aspect, int vx, int *x -= ((1024-xs)/2); *y -= ((768-ys)/2); - *x = (*x / (float)xs) * vx; - *y = (*y / (float)ys) * vy; + *x = (int)((*x / (float)xs) * vx); + *y = (int)((*y / (float)ys) * vy); } @@ -751,7 +751,7 @@ static void ir_convert_to_vres(int* x, int* y, enum aspect_t aspect, int vx, int float calc_yaw(struct ir_t* ir) { float x; - x = ir->ax - 512; + x = (float)(ir->ax - 512); x = x * (ir->z / 1024.0f); return RAD_TO_DEGREE( atanf(x / ir->z) ); diff --git a/src/motion_plus.c b/src/motion_plus.c index 27d0d0e..8c15fb9 100644 --- a/src/motion_plus.c +++ b/src/motion_plus.c @@ -261,27 +261,27 @@ static void calculate_gyro_rates(struct motion_plus_t* mp) /* We convert to degree/sec according to fast/slow mode */ if (mp->acc_mode & 0x04) - tmp_roll = tmp_r / 20.0; + tmp_roll = (float)tmp_r / 20.0f; else - tmp_roll = tmp_r / 4.0; + tmp_roll = (float)tmp_r / 4.0f; if (mp->acc_mode & 0x02) - tmp_pitch = tmp_p / 20.0; + tmp_pitch = (float)tmp_p / 20.0f; else - tmp_pitch = tmp_p / 4.0; + tmp_pitch = (float)tmp_p / 4.0f; if (mp->acc_mode & 0x01) - tmp_yaw = tmp_y / 20.0; + tmp_yaw = (float)tmp_y / 20.0f; else - tmp_yaw = tmp_y / 4.0; + tmp_yaw = (float)tmp_y / 4.0f; /* Simple filtering */ - if (fabs(tmp_roll) < 0.5) - tmp_roll = 0.0; - if (fabs(tmp_pitch) < 0.5) - tmp_pitch = 0.0; - if (fabs(tmp_yaw) < 0.5) - tmp_yaw = 0.0; + if (fabs(tmp_roll) < 0.5f) + tmp_roll = 0.0f; + if (fabs(tmp_pitch) < 0.5f) + tmp_pitch = 0.0f; + if (fabs(tmp_yaw) < 0.5f) + tmp_yaw = 0.0f; mp->angle_rate_gyro.roll = tmp_roll; mp->angle_rate_gyro.pitch = tmp_pitch; diff --git a/src/os.h b/src/os.h index 2d18c48..21d9c16 100644 --- a/src/os.h +++ b/src/os.h @@ -40,13 +40,12 @@ #define OS_H_INCLUDED #ifdef _MSC_VER + #include /* windows with visual c */ - #define isnan(x) _isnan(x) - #define isinf(x) !_finite(x) + #define isnan(x) (_isnan(x)) + #define isinf(x) (!_finite(x)) /* disable warnings I don't care about */ - #pragma warning(disable:4244) /* possible loss of data conversion */ - #pragma warning(disable:4273) /* inconsistent dll linkage */ - #pragma warning(disable:4217) + /*#pragma warning(disable:4273) */ /* inconsistent dll linkage */ #endif #endif /* OS_H_INCLUDED */