@@ -191,7 +191,7 @@ static Uint16 to_linux_direction(SDL_HapticDirection *src)
191
191
} else if (!src -> dir [0 ]) {
192
192
return (Uint16 ) (src -> dir [1 ] >= 0 ? 0x8000 : 0 );
193
193
} else {
194
- float f = SDL_atan2 (src -> dir [1 ], src -> dir [0 ]); /* Ideally we'd use fixed point math instead of floats... */
194
+ float f = ( float ) SDL_atan2 (src -> dir [1 ], src -> dir [0 ]); /* Ideally we'd use fixed point math instead of floats... */
195
195
/*
196
196
SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
197
197
- Y-axis-value is the second coordinate (from center to SOUTH)
@@ -405,9 +405,9 @@ static Sint32 lg4ff_calculate_constant(struct lg4ff_effect_state *state)
405
405
if (state -> time_playing < constant -> attack_length ) {
406
406
level_sign = level < 0 ? -1 : 1 ;
407
407
d = level - level_sign * constant -> attack_level ;
408
- level = level_sign * constant -> attack_level + d * state -> time_playing / constant -> attack_length ;
408
+ level = ( Sint32 ) ( level_sign * constant -> attack_level + d * state -> time_playing / constant -> attack_length ) ;
409
409
} else if (constant -> length && constant -> fade_length ) {
410
- t = state -> time_playing - constant -> length + constant -> fade_length ;
410
+ t = ( Sint32 ) ( state -> time_playing - constant -> length + constant -> fade_length ) ;
411
411
if (t > 0 ) {
412
412
level_sign = level < 0 ? -1 : 1 ;
413
413
d = level - level_sign * constant -> fade_level ;
@@ -428,17 +428,17 @@ static Sint32 lg4ff_calculate_ramp(struct lg4ff_effect_state *state)
428
428
if (state -> time_playing < ramp -> attack_length ) {
429
429
level = ramp -> start ;
430
430
level_sign = level < 0 ? -1 : 1 ;
431
- t = ramp -> attack_length - state -> time_playing ;
431
+ t = ( Sint32 ) ( ramp -> attack_length - state -> time_playing ) ;
432
432
d = level - level_sign * ramp -> attack_level ;
433
433
level = level_sign * ramp -> attack_level + d * t / ramp -> attack_length ;
434
434
} else if (ramp -> length && state -> time_playing >= ramp -> length - ramp -> fade_length && ramp -> fade_length ) {
435
435
level = ramp -> end ;
436
436
level_sign = level < 0 ? -1 : 1 ;
437
- t = state -> time_playing - ramp -> length + ramp -> fade_length ;
437
+ t = ( Sint32 ) ( state -> time_playing - ramp -> length + ramp -> fade_length ) ;
438
438
d = level_sign * ramp -> fade_level - level ;
439
439
level = level - d * t / ramp -> fade_length ;
440
440
} else {
441
- t = state -> time_playing - ramp -> attack_length ;
441
+ t = ( Sint32 ) ( state -> time_playing - ramp -> attack_length ) ;
442
442
level = ramp -> start + ((t * state -> slope ) >> 16 );
443
443
}
444
444
@@ -455,9 +455,9 @@ static Sint32 lg4ff_calculate_periodic(struct lg4ff_effect_state *state)
455
455
456
456
if (state -> time_playing < periodic -> attack_length ) {
457
457
d = magnitude - magnitude_sign * periodic -> attack_level ;
458
- magnitude = magnitude_sign * periodic -> attack_level + d * state -> time_playing / periodic -> attack_length ;
458
+ magnitude = ( Sint32 ) ( magnitude_sign * periodic -> attack_level + d * state -> time_playing / periodic -> attack_length ) ;
459
459
} else if (periodic -> length && periodic -> fade_length ) {
460
- t = state -> time_playing - get_effect_replay_length (& state -> effect ) + periodic -> fade_length ;
460
+ t = ( Sint32 ) ( state -> time_playing - get_effect_replay_length (& state -> effect ) + periodic -> fade_length ) ;
461
461
if (t > 0 ) {
462
462
d = magnitude - magnitude_sign * periodic -> fade_level ;
463
463
magnitude = magnitude - d * t / periodic -> fade_length ;
@@ -474,7 +474,7 @@ static Sint32 lg4ff_calculate_periodic(struct lg4ff_effect_state *state)
474
474
break;
475
475
*/
476
476
case SDL_HAPTIC_TRIANGLE :
477
- level += llabs ((Sint64 )state -> phase * magnitude * 2 / 360 - magnitude ) * 2 - magnitude ;
477
+ level += ( Sint32 ) ( llabs ((Sint64 )state -> phase * magnitude * 2 / 360 - magnitude ) * 2 - magnitude ) ;
478
478
break ;
479
479
case SDL_HAPTIC_SAWTOOTHUP :
480
480
level += state -> phase * magnitude * 2 / 360 - magnitude ;
@@ -762,10 +762,11 @@ static SDL_bool SDL_HIDAPI_HapticDriverLg4ff_JoystickSupported(SDL_Joystick *joy
762
762
{
763
763
Uint16 vendor_id = SDL_JoystickGetVendor (joystick );
764
764
Uint16 product_id = SDL_JoystickGetProduct (joystick );
765
+ int i ;
765
766
if (vendor_id != USB_VENDOR_ID_LOGITECH ) {
766
767
return SDL_FALSE ;
767
768
}
768
- for (int i = 0 ;i < sizeof (supported_device_ids ) / sizeof (Uint32 );i ++ ) {
769
+ for (i = 0 ; i < sizeof (supported_device_ids ) / sizeof (Uint32 ); i ++ ) {
769
770
if (supported_device_ids [i ] == product_id ) {
770
771
return SDL_TRUE ;
771
772
}
@@ -840,7 +841,7 @@ static void *SDL_HIDAPI_HapticDriverLg4ff_Open(SDL_Joystick *joystick)
840
841
841
842
ctx -> product_id = SDL_JoystickGetProduct (joystick );
842
843
843
- sprintf (ctx -> thread_name_buf , "SDL_hidapihaptic_lg4ff 0x%16llx %04x:%04x" , ( Uint64 ) joystick , USB_VENDOR_ID_LOGITECH , ctx -> product_id );
844
+ SDL_snprintf (ctx -> thread_name_buf , sizeof ( ctx -> thread_name_buf ), "SDL_hidapihaptic_lg4ff %d %04x:%04x" , SDL_JoystickInstanceID ( joystick ) , USB_VENDOR_ID_LOGITECH , ctx -> product_id );
844
845
ctx -> stop_thread = SDL_FALSE ;
845
846
ctx -> thread = SDL_CreateThread (SDL_HIDAPI_HapticDriverLg4ff_ThreadFunction , ctx -> thread_name_buf , ctx );
846
847
@@ -1179,5 +1180,5 @@ SDL_HIDAPI_HapticDriver SDL_HIDAPI_HapticDriverLg4ff = {
1179
1180
SDL_HIDAPI_HapticDriverLg4ff_StopAll ,
1180
1181
};
1181
1182
1182
- #endif // SDL_HAPTIC_HIDAPI_LG4FF
1183
- #endif // SDL_JOYSTICK_HIDAPI
1183
+ #endif /* SDL_HAPTIC_HIDAPI_LG4FF */
1184
+ #endif /* SDL_JOYSTICK_HIDAPI */
0 commit comments