Skip to content

Commit e3ab06a

Browse files
committed
fix windows ci builds
1 parent b7b4398 commit e3ab06a

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/haptic/hidapi/SDL_hidapihaptic_lg4ff.c

+14-16
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static Uint16 get_effect_direction(SDL_HapticEffect *effect)
249249

250250
static Uint32 get_effect_replay_length(SDL_HapticEffect *effect)
251251
{
252-
int length = 0;
252+
Uint32 length = 0;
253253
if (effect_is_periodic(effect)) {
254254
length = effect->periodic.length;
255255
} else if (effect_is_condition(effect)) {
@@ -276,7 +276,7 @@ static Uint32 get_effect_replay_length(SDL_HapticEffect *effect)
276276

277277
static Uint16 get_effect_replay_delay(SDL_HapticEffect *effect)
278278
{
279-
int delay = 0;
279+
Uint16 delay = 0;
280280
if (effect_is_periodic(effect)) {
281281
delay = effect->periodic.delay;
282282
} else if (effect_is_condition(effect)) {
@@ -601,7 +601,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
601601
}
602602
}
603603

604-
slot->current_cmd[0] = (0x10 << slot->id) + slot->cmd_op;
604+
slot->current_cmd[0] = (Uint8)((0x10 << slot->id) + slot->cmd_op);
605605

606606
if (slot->cmd_op == 3) {
607607
slot->current_cmd[1] = 0;
@@ -639,20 +639,20 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
639639
k2 -= 2048;
640640
}
641641
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);
644644
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);
646646
slot->current_cmd[6] = SCALE_VALUE_U16(parameters->clip, 8);
647647
break;
648648
case SDL_HAPTIC_DAMPER:
649649
s1 = parameters->k1 < 0;
650650
s2 = parameters->k2 < 0;
651651
slot->current_cmd[1] = 0x0c;
652652
slot->current_cmd[2] = SCALE_COEFF(parameters->k1, 4);
653-
slot->current_cmd[3] = s1;
653+
slot->current_cmd[3] = (Uint8)s1;
654654
slot->current_cmd[4] = SCALE_COEFF(parameters->k2, 4);
655-
slot->current_cmd[5] = s2;
655+
slot->current_cmd[5] = (Uint8)s2;
656656
slot->current_cmd[6] = SCALE_VALUE_U16(parameters->clip, 8);
657657
break;
658658
case SDL_HAPTIC_FRICTION:
@@ -662,7 +662,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
662662
slot->current_cmd[2] = SCALE_COEFF(parameters->k1, 8);
663663
slot->current_cmd[3] = SCALE_COEFF(parameters->k2, 8);
664664
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);
666666
slot->current_cmd[6] = 0;
667667
break;
668668
}
@@ -740,7 +740,7 @@ static int lg4ff_timer(struct lg4ff_device *device)
740740

741741
SDL_memset(parameters, 0, sizeof(parameters));
742742

743-
gain = (Uint32)device->gain * device->app_gain / 0xffff;
743+
gain = (Uint16)((Uint32)device->gain * device->app_gain / 0xffff);
744744

745745
count = device->effects_used;
746746

@@ -809,7 +809,7 @@ static int lg4ff_timer(struct lg4ff_device *device)
809809
parameters[i].k1 = (Sint64)parameters[i].k1 * gain / 0xffff;
810810
parameters[i].k2 = (Sint64)parameters[i].k2 * gain / 0xffff;
811811
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);
813813
}
814814
if (ffb_level > device->peak_ffb_level) {
815815
device->peak_ffb_level = ffb_level;
@@ -1029,8 +1029,6 @@ static int SDL_HIDAPI_HapticDriverLg4ff_CreateEffect(SDL_HIDAPI_HapticDevice *de
10291029
SDL_SetError("Bad effect parameters");
10301030
return -1;
10311031
}
1032-
1033-
return 0;
10341032
}
10351033

10361034
// assumes ctx->mutex locked
@@ -1206,9 +1204,9 @@ static bool SDL_HIDAPI_HapticDriverLg4ff_SetAutocenter(SDL_HIDAPI_HapticDevice *
12061204
SDL_memset(cmd, 0x00, 7);
12071205
cmd[0] = 0xfe;
12081206
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);
12121210

12131211
ret = SDL_SendJoystickEffect(ctx->hid_handle, cmd, sizeof(cmd));
12141212
if (!ret) {

src/joystick/hidapi/SDL_hidapi_lg4ff.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static bool HIDAPI_DriverLg4ff_SetRange(SDL_HIDAPI_Device *device, int range)
303303
range = 900;
304304
}
305305

306-
ctx->range = range;
306+
ctx->range = (Uint16)range;
307307
switch (device->product_id) {
308308
case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
309309
case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
@@ -357,8 +357,8 @@ static bool HIDAPI_DriverLg4ff_SetRange(SDL_HIDAPI_Device *device, int range)
357357
start_left = (((full_range - range + 1) * 2047) / full_range);
358358
start_right = 0xfff - start_left;
359359

360-
cmd[2] = start_left >> 4;
361-
cmd[3] = start_right >> 4;
360+
cmd[2] = (Uint8)(start_left >> 4);
361+
cmd[3] = (Uint8)(start_right >> 4);
362362
cmd[4] = 0xff;
363363
cmd[5] = (start_right & 0xe) << 4 | (start_left & 0xe);
364364
cmd[6] = 0xff;
@@ -444,9 +444,9 @@ static bool HIDAPI_DriverLg4ff_SetAutoCenter(SDL_HIDAPI_Device *device, int magn
444444
SDL_memset(cmd, 0x00, sizeof(cmd));
445445
cmd[0] = 0xfe;
446446
cmd[1] = 0x0d;
447-
cmd[2] = expand_a / 0xaaaa;
448-
cmd[3] = expand_a / 0xaaaa;
449-
cmd[4] = expand_b / 0xaaaa;
447+
cmd[2] = (Uint8)(expand_a / 0xaaaa);
448+
cmd[3] = (Uint8)(expand_a / 0xaaaa);
449+
cmd[4] = (Uint8)(expand_b / 0xaaaa);
450450

451451
ret = SDL_hid_write(device->dev, cmd, sizeof(cmd));
452452
if (ret == -1) {
@@ -572,7 +572,7 @@ static bool HIDAPI_DriverLg4ff_HandleState(SDL_HIDAPI_Device *device,
572572
int bit_offset = 0;
573573
Uint64 timestamp = SDL_GetTicksNS();
574574

575-
bool state_changed;
575+
bool state_changed = false;
576576

577577
switch (device->product_id) {
578578
case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
@@ -653,7 +653,7 @@ static bool HIDAPI_DriverLg4ff_HandleState(SDL_HIDAPI_Device *device,
653653
bool button_was_on = HIDAPI_DriverLg4ff_GetBit(ctx->last_report_buf, bit_num, report_size);
654654
if(button_on != button_was_on){
655655
state_changed = true;
656-
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SOUTH + i, button_on);
656+
SDL_SendJoystickButton(timestamp, joystick, (Uint8)(SDL_GAMEPAD_BUTTON_SOUTH + i), button_on);
657657
}
658658
}
659659

@@ -810,7 +810,7 @@ static bool HIDAPI_DriverLg4ff_UpdateDevice(SDL_HIDAPI_Device *device)
810810
/* Failed to read from controller */
811811
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
812812
return false;
813-
} else if (r == report_size) {
813+
} else if ((size_t)r == report_size) {
814814
bool state_changed = HIDAPI_DriverLg4ff_HandleState(device, joystick, report_buf, report_size);
815815
if(state_changed && !ctx->initialized) {
816816
ctx->initialized = true;
@@ -934,7 +934,7 @@ static bool HIDAPI_DriverLg4ff_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joy
934934
max_led = blue;
935935
}
936936

937-
return HIDAPI_DriverLg4ff_SendLedCommand(device, (5 * max_led) / 255);
937+
return HIDAPI_DriverLg4ff_SendLedCommand(device, (Uint8)((5 * max_led) / 255));
938938
}
939939

940940
static bool HIDAPI_DriverLg4ff_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size)

0 commit comments

Comments
 (0)