Skip to content

Commit 81c4ef3

Browse files
committed
DSU: fix MSVC warnings and socket types
1 parent 6489767 commit 81c4ef3

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/joystick/dsu/SDL_dsujoystick.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ static void DSU_ProcessControllerData(DSU_Context *ctx, DSU_ControllerData *data
338338
slot->battery = data->info.battery;
339339
slot->model = data->info.device_model;
340340
slot->connection = data->info.connection_type;
341-
slot->slot_id = slot_id;
341+
slot->slot_id = (Uint8)slot_id;
342342

343343
/* Generate name */
344344
SDL_snprintf(slot->name, sizeof(slot->name), "DSUClient/%d", slot_id);
@@ -444,7 +444,7 @@ static void DSU_ProcessControllerData(DSU_Context *ctx, DSU_ControllerData *data
444444

445445
/* Subscribe to controller data updates if just detected */
446446
if (!was_connected && slot->detected) {
447-
DSU_RequestControllerData(ctx, slot_id);
447+
DSU_RequestControllerData(ctx, (Uint8)slot_id);
448448
}
449449
SDL_Log("DSU: Finished processing data for slot %d\n", slot_id);
450450
}

src/joystick/dsu/SDL_dsujoystick_driver.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
/* Include socket headers before SDL to avoid macro conflicts */
2323
#ifdef _WIN32
24-
#define WIN32_LEAN_AND_MEAN
2524
#include <winsock2.h>
2625
#include <ws2tcpip.h>
2726
#ifdef _MSC_VER
@@ -108,14 +107,14 @@ static bool DSU_JoystickInit(void)
108107

109108
server_port = SDL_GetHint(SDL_HINT_DSU_SERVER_PORT);
110109
if (server_port && *server_port) {
111-
ctx->server_port = SDL_atoi(server_port);
110+
ctx->server_port = (Uint16)SDL_atoi(server_port);
112111
} else {
113112
ctx->server_port = DSU_SERVER_PORT_DEFAULT;
114113
}
115114

116115
client_port = SDL_GetHint(SDL_HINT_DSU_CLIENT_PORT);
117116
if (client_port && *client_port) {
118-
ctx->client_port = SDL_atoi(client_port);
117+
ctx->client_port = (Uint16)SDL_atoi(client_port);
119118
} else {
120119
ctx->client_port = DSU_CLIENT_PORT_DEFAULT;
121120
}
@@ -207,12 +206,12 @@ static void DSU_JoystickDetect(void)
207206
/* Periodically request controller info and re-subscribe to data */
208207
now = SDL_GetTicks();
209208
if (now - ctx->last_request_time >= 500) { /* Request more frequently */
210-
DSU_RequestControllerInfo(ctx, 0xFF);
209+
DSU_RequestControllerInfo(ctx, (Uint8)0xFF);
211210

212211
/* Re-subscribe to data for detected controllers */
213212
for (i = 0; i < DSU_MAX_SLOTS; i++) {
214213
if (ctx->slots[i].detected || ctx->slots[i].connected) {
215-
DSU_RequestControllerData(ctx, i);
214+
DSU_RequestControllerData(ctx, (Uint8)i);
216215
}
217216
}
218217

@@ -389,7 +388,7 @@ static SDL_JoystickID DSU_JoystickGetDeviceInstanceID(int device_index)
389388

390389
ctx = s_dsu_ctx;
391390
if (!ctx) {
392-
return -1;
391+
return 0;
393392
}
394393

395394
mutex = ctx->slots_mutex;
@@ -607,15 +606,15 @@ static void DSU_JoystickUpdate(SDL_Joystick *joystick)
607606
if (pressed) {
608607
SDL_Log(" Button %d (%s): PRESSED", i, button_names[i]);
609608
}
610-
SDL_SendJoystickButton(timestamp, joystick, i, pressed);
609+
SDL_SendJoystickButton(timestamp, joystick, (Uint8)i, pressed);
611610
}
612611

613612
/* Update axes with detailed logging */
614613
SDL_Log("DSU UPDATE: Axes - LX=%d LY=%d RX=%d RY=%d L2=%d R2=%d",
615614
slot->axes[0], slot->axes[1], slot->axes[2],
616615
slot->axes[3], slot->axes[4], slot->axes[5]);
617616
for (i = 0; i < 6; i++) {
618-
SDL_SendJoystickAxis(timestamp, joystick, i, slot->axes[i]);
617+
SDL_SendJoystickAxis(timestamp, joystick, (Uint8)i, slot->axes[i]);
619618
}
620619

621620
/* Update hat (D-Pad) */

0 commit comments

Comments
 (0)