Skip to content

Commit

Permalink
fix windows ci builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kethen committed Jan 16, 2025
1 parent b7b4398 commit e3ab06a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
30 changes: 14 additions & 16 deletions src/haptic/hidapi/SDL_hidapihaptic_lg4ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static Uint16 get_effect_direction(SDL_HapticEffect *effect)

static Uint32 get_effect_replay_length(SDL_HapticEffect *effect)
{
int length = 0;
Uint32 length = 0;
if (effect_is_periodic(effect)) {
length = effect->periodic.length;
} else if (effect_is_condition(effect)) {
Expand All @@ -276,7 +276,7 @@ static Uint32 get_effect_replay_length(SDL_HapticEffect *effect)

static Uint16 get_effect_replay_delay(SDL_HapticEffect *effect)
{
int delay = 0;
Uint16 delay = 0;
if (effect_is_periodic(effect)) {
delay = effect->periodic.delay;
} else if (effect_is_condition(effect)) {
Expand Down Expand Up @@ -601,7 +601,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
}
}

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

if (slot->cmd_op == 3) {
slot->current_cmd[1] = 0;
Expand Down Expand Up @@ -639,20 +639,20 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
k2 -= 2048;
}
slot->current_cmd[1] = 0x0b;
slot->current_cmd[2] = d1 >> 3;
slot->current_cmd[3] = d2 >> 3;
slot->current_cmd[2] = (Uint8)(d1 >> 3);
slot->current_cmd[3] = (Uint8)(d2 >> 3);
slot->current_cmd[4] = (SCALE_COEFF(k2, 4) << 4) + SCALE_COEFF(k1, 4);
slot->current_cmd[5] = ((d2 & 7) << 5) + ((d1 & 7) << 1) + (s2 << 4) + s1;
slot->current_cmd[5] = (Uint8)(((d2 & 7) << 5) + ((d1 & 7) << 1) + (s2 << 4) + s1);
slot->current_cmd[6] = SCALE_VALUE_U16(parameters->clip, 8);
break;
case SDL_HAPTIC_DAMPER:
s1 = parameters->k1 < 0;
s2 = parameters->k2 < 0;
slot->current_cmd[1] = 0x0c;
slot->current_cmd[2] = SCALE_COEFF(parameters->k1, 4);
slot->current_cmd[3] = s1;
slot->current_cmd[3] = (Uint8)s1;
slot->current_cmd[4] = SCALE_COEFF(parameters->k2, 4);
slot->current_cmd[5] = s2;
slot->current_cmd[5] = (Uint8)s2;
slot->current_cmd[6] = SCALE_VALUE_U16(parameters->clip, 8);
break;
case SDL_HAPTIC_FRICTION:
Expand All @@ -662,7 +662,7 @@ static void lg4ff_update_slot(struct lg4ff_slot *slot, struct lg4ff_effect_param
slot->current_cmd[2] = SCALE_COEFF(parameters->k1, 8);
slot->current_cmd[3] = SCALE_COEFF(parameters->k2, 8);
slot->current_cmd[4] = SCALE_VALUE_U16(parameters->clip, 8);
slot->current_cmd[5] = (s2 << 4) + s1;
slot->current_cmd[5] = (Uint8)((s2 << 4) + s1);
slot->current_cmd[6] = 0;
break;
}
Expand Down Expand Up @@ -740,7 +740,7 @@ static int lg4ff_timer(struct lg4ff_device *device)

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

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

count = device->effects_used;

Expand Down Expand Up @@ -809,7 +809,7 @@ static int lg4ff_timer(struct lg4ff_device *device)
parameters[i].k1 = (Sint64)parameters[i].k1 * gain / 0xffff;
parameters[i].k2 = (Sint64)parameters[i].k2 * gain / 0xffff;
parameters[i].clip = parameters[i].clip * gain / 0xffff;
ffb_level += parameters[i].clip * 0x7fff / 0xffff;
ffb_level = (Sint32)(ffb_level + parameters[i].clip * 0x7fff / 0xffff);
}
if (ffb_level > device->peak_ffb_level) {
device->peak_ffb_level = ffb_level;
Expand Down Expand Up @@ -1029,8 +1029,6 @@ static int SDL_HIDAPI_HapticDriverLg4ff_CreateEffect(SDL_HIDAPI_HapticDevice *de
SDL_SetError("Bad effect parameters");
return -1;
}

return 0;
}

// assumes ctx->mutex locked
Expand Down Expand Up @@ -1206,9 +1204,9 @@ static bool SDL_HIDAPI_HapticDriverLg4ff_SetAutocenter(SDL_HIDAPI_HapticDevice *
SDL_memset(cmd, 0x00, 7);
cmd[0] = 0xfe;
cmd[1] = 0x0d;
cmd[2] = expand_a / 0xaaaa;
cmd[3] = expand_a / 0xaaaa;
cmd[4] = expand_b / 0xaaaa;
cmd[2] = (Uint8)(expand_a / 0xaaaa);
cmd[3] = (Uint8)(expand_a / 0xaaaa);
cmd[4] = (Uint8)(expand_b / 0xaaaa);

ret = SDL_SendJoystickEffect(ctx->hid_handle, cmd, sizeof(cmd));
if (!ret) {
Expand Down
20 changes: 10 additions & 10 deletions src/joystick/hidapi/SDL_hidapi_lg4ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static bool HIDAPI_DriverLg4ff_SetRange(SDL_HIDAPI_Device *device, int range)
range = 900;
}

ctx->range = range;
ctx->range = (Uint16)range;
switch (device->product_id) {
case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
case USB_DEVICE_ID_LOGITECH_G27_WHEEL:
Expand Down Expand Up @@ -357,8 +357,8 @@ static bool HIDAPI_DriverLg4ff_SetRange(SDL_HIDAPI_Device *device, int range)
start_left = (((full_range - range + 1) * 2047) / full_range);
start_right = 0xfff - start_left;

cmd[2] = start_left >> 4;
cmd[3] = start_right >> 4;
cmd[2] = (Uint8)(start_left >> 4);
cmd[3] = (Uint8)(start_right >> 4);
cmd[4] = 0xff;
cmd[5] = (start_right & 0xe) << 4 | (start_left & 0xe);
cmd[6] = 0xff;
Expand Down Expand Up @@ -444,9 +444,9 @@ static bool HIDAPI_DriverLg4ff_SetAutoCenter(SDL_HIDAPI_Device *device, int magn
SDL_memset(cmd, 0x00, sizeof(cmd));
cmd[0] = 0xfe;
cmd[1] = 0x0d;
cmd[2] = expand_a / 0xaaaa;
cmd[3] = expand_a / 0xaaaa;
cmd[4] = expand_b / 0xaaaa;
cmd[2] = (Uint8)(expand_a / 0xaaaa);
cmd[3] = (Uint8)(expand_a / 0xaaaa);
cmd[4] = (Uint8)(expand_b / 0xaaaa);

ret = SDL_hid_write(device->dev, cmd, sizeof(cmd));
if (ret == -1) {
Expand Down Expand Up @@ -572,7 +572,7 @@ static bool HIDAPI_DriverLg4ff_HandleState(SDL_HIDAPI_Device *device,
int bit_offset = 0;
Uint64 timestamp = SDL_GetTicksNS();

bool state_changed;
bool state_changed = false;

switch (device->product_id) {
case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
Expand Down Expand Up @@ -653,7 +653,7 @@ static bool HIDAPI_DriverLg4ff_HandleState(SDL_HIDAPI_Device *device,
bool button_was_on = HIDAPI_DriverLg4ff_GetBit(ctx->last_report_buf, bit_num, report_size);
if(button_on != button_was_on){
state_changed = true;
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_SOUTH + i, button_on);
SDL_SendJoystickButton(timestamp, joystick, (Uint8)(SDL_GAMEPAD_BUTTON_SOUTH + i), button_on);
}
}

Expand Down Expand Up @@ -810,7 +810,7 @@ static bool HIDAPI_DriverLg4ff_UpdateDevice(SDL_HIDAPI_Device *device)
/* Failed to read from controller */
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
return false;
} else if (r == report_size) {
} else if ((size_t)r == report_size) {
bool state_changed = HIDAPI_DriverLg4ff_HandleState(device, joystick, report_buf, report_size);
if(state_changed && !ctx->initialized) {
ctx->initialized = true;
Expand Down Expand Up @@ -934,7 +934,7 @@ static bool HIDAPI_DriverLg4ff_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joy
max_led = blue;
}

return HIDAPI_DriverLg4ff_SendLedCommand(device, (5 * max_led) / 255);
return HIDAPI_DriverLg4ff_SendLedCommand(device, (Uint8)((5 * max_led) / 255));
}

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

0 comments on commit e3ab06a

Please sign in to comment.