@@ -249,7 +249,7 @@ static Uint16 get_effect_direction(SDL_HapticEffect *effect)
249
249
250
250
static Uint32 get_effect_replay_length (SDL_HapticEffect * effect )
251
251
{
252
- int length = 0 ;
252
+ Uint32 length = 0 ;
253
253
if (effect_is_periodic (effect )) {
254
254
length = effect -> periodic .length ;
255
255
} else if (effect_is_condition (effect )) {
@@ -276,7 +276,7 @@ static Uint32 get_effect_replay_length(SDL_HapticEffect *effect)
276
276
277
277
static Uint16 get_effect_replay_delay (SDL_HapticEffect * effect )
278
278
{
279
- int delay = 0 ;
279
+ Uint16 delay = 0 ;
280
280
if (effect_is_periodic (effect )) {
281
281
delay = effect -> periodic .delay ;
282
282
} else if (effect_is_condition (effect )) {
@@ -601,7 +601,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
601
601
}
602
602
}
603
603
604
- slot -> current_cmd [0 ] = (0x10 << slot -> id ) + slot -> cmd_op ;
604
+ slot -> current_cmd [0 ] = (Uint8 )(( 0x10 << slot -> id ) + slot -> cmd_op ) ;
605
605
606
606
if (slot -> cmd_op == 3 ) {
607
607
slot -> current_cmd [1 ] = 0 ;
@@ -639,20 +639,20 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
639
639
k2 -= 2048 ;
640
640
}
641
641
slot -> current_cmd [1 ] = 0x0b ;
642
- slot -> current_cmd [2 ] = d1 >> 3 ;
643
- slot -> current_cmd [3 ] = d2 >> 3 ;
642
+ slot -> current_cmd [2 ] = ( Uint8 )( d1 >> 3 ) ;
643
+ slot -> current_cmd [3 ] = ( Uint8 )( d2 >> 3 ) ;
644
644
slot -> current_cmd [4 ] = (SCALE_COEFF (k2 , 4 ) << 4 ) + SCALE_COEFF (k1 , 4 );
645
- slot -> current_cmd [5 ] = (( d2 & 7 ) << 5 ) + ((d1 & 7 ) << 1 ) + (s2 << 4 ) + s1 ;
645
+ slot -> current_cmd [5 ] = (Uint8 )((( d2 & 7 ) << 5 ) + ((d1 & 7 ) << 1 ) + (s2 << 4 ) + s1 ) ;
646
646
slot -> current_cmd [6 ] = SCALE_VALUE_U16 (parameters -> clip , 8 );
647
647
break ;
648
648
case SDL_HAPTIC_DAMPER :
649
649
s1 = parameters -> k1 < 0 ;
650
650
s2 = parameters -> k2 < 0 ;
651
651
slot -> current_cmd [1 ] = 0x0c ;
652
652
slot -> current_cmd [2 ] = SCALE_COEFF (parameters -> k1 , 4 );
653
- slot -> current_cmd [3 ] = s1 ;
653
+ slot -> current_cmd [3 ] = ( Uint8 ) s1 ;
654
654
slot -> current_cmd [4 ] = SCALE_COEFF (parameters -> k2 , 4 );
655
- slot -> current_cmd [5 ] = s2 ;
655
+ slot -> current_cmd [5 ] = ( Uint8 ) s2 ;
656
656
slot -> current_cmd [6 ] = SCALE_VALUE_U16 (parameters -> clip , 8 );
657
657
break ;
658
658
case SDL_HAPTIC_FRICTION :
@@ -662,7 +662,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
662
662
slot -> current_cmd [2 ] = SCALE_COEFF (parameters -> k1 , 8 );
663
663
slot -> current_cmd [3 ] = SCALE_COEFF (parameters -> k2 , 8 );
664
664
slot -> current_cmd [4 ] = SCALE_VALUE_U16 (parameters -> clip , 8 );
665
- slot -> current_cmd [5 ] = (s2 << 4 ) + s1 ;
665
+ slot -> current_cmd [5 ] = (Uint8 )(( s2 << 4 ) + s1 ) ;
666
666
slot -> current_cmd [6 ] = 0 ;
667
667
break ;
668
668
}
@@ -740,7 +740,7 @@ static int lg4ff_timer(struct lg4ff_device *device)
740
740
741
741
SDL_memset (parameters , 0 , sizeof (parameters ));
742
742
743
- gain = (Uint32 )device -> gain * device -> app_gain / 0xffff ;
743
+ gain = (Uint16 )(( Uint32 )device -> gain * device -> app_gain / 0xffff ) ;
744
744
745
745
count = device -> effects_used ;
746
746
@@ -809,7 +809,7 @@ static int lg4ff_timer(struct lg4ff_device *device)
809
809
parameters [i ].k1 = (Sint64 )parameters [i ].k1 * gain / 0xffff ;
810
810
parameters [i ].k2 = (Sint64 )parameters [i ].k2 * gain / 0xffff ;
811
811
parameters [i ].clip = parameters [i ].clip * gain / 0xffff ;
812
- ffb_level += parameters [i ].clip * 0x7fff / 0xffff ;
812
+ ffb_level = ( Sint32 )( ffb_level + parameters [i ].clip * 0x7fff / 0xffff ) ;
813
813
}
814
814
if (ffb_level > device -> peak_ffb_level ) {
815
815
device -> peak_ffb_level = ffb_level ;
@@ -1029,8 +1029,6 @@ static int SDL_HIDAPI_HapticDriverLg4ff_CreateEffect(SDL_HIDAPI_HapticDevice *de
1029
1029
SDL_SetError ("Bad effect parameters" );
1030
1030
return -1 ;
1031
1031
}
1032
-
1033
- return 0 ;
1034
1032
}
1035
1033
1036
1034
// assumes ctx->mutex locked
@@ -1206,9 +1204,9 @@ static bool SDL_HIDAPI_HapticDriverLg4ff_SetAutocenter(SDL_HIDAPI_HapticDevice *
1206
1204
SDL_memset (cmd , 0x00 , 7 );
1207
1205
cmd [0 ] = 0xfe ;
1208
1206
cmd [1 ] = 0x0d ;
1209
- cmd [2 ] = expand_a / 0xaaaa ;
1210
- cmd [3 ] = expand_a / 0xaaaa ;
1211
- cmd [4 ] = expand_b / 0xaaaa ;
1207
+ cmd [2 ] = ( Uint8 )( expand_a / 0xaaaa ) ;
1208
+ cmd [3 ] = ( Uint8 )( expand_a / 0xaaaa ) ;
1209
+ cmd [4 ] = ( Uint8 )( expand_b / 0xaaaa ) ;
1212
1210
1213
1211
ret = SDL_SendJoystickEffect (ctx -> hid_handle , cmd , sizeof (cmd ));
1214
1212
if (!ret ) {
0 commit comments