Skip to content

Commit 1fcae71

Browse files
committed
Fix device helper for xinput devices with recent SDL2 versions
1 parent 88d348f commit 1fcae71

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Version 3.1:
22

3+
* Fix device helper for xinput devices with recent SDL2 versions.
34
* Support for multiple mice disabled by default on macOS due to security
45
warning. Use option multiple_mice = 1 to enable.
56
* Disable expect_version option (no longer synchronized with launcher).

src/fs-uae/device-helper.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ static void print_events(void)
217217
printf("# Support for multiple mice not enabled\n");
218218
}
219219

220-
printf("# SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS))\n");
220+
// With recent SDL2 versions (SDL 2.0.14+?), it seems that the video
221+
// subsystem must be initialized to get events from xinput controllers.
222+
printf("# SDL_Init(SDL_INIT_EVERYTHING)\n");
221223
flush_stdout();
222-
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) < 0) {
223-
printf("# SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)) < 0\n");
224+
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
225+
printf("# SDL_Init(SDL_INIT_EVERYTHING) < 0\n");
224226
flush_stdout();
225227
return;
226228
}
@@ -314,7 +316,6 @@ static void print_events(void)
314316

315317
static void print_state(SDL_Joystick* joystick, const char* name)
316318
{
317-
318319
int num_buttons = SDL_JoystickNumButtons(joystick);
319320
int num_hats = SDL_JoystickNumHats(joystick);
320321
int num_axes = SDL_JoystickNumAxes(joystick);
@@ -397,9 +398,12 @@ int main(int argc, char* argv[])
397398

398399
char* compare_name = joystick_config_name(argv[1], 1);
399400

400-
printf("# SDL_Init(SDL_INIT_JOYSTICK)\n");
401-
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
402-
printf("# SDL_Init(SDL_INIT_JOYSTICK) < 0\n");
401+
// With recent SDL2 versions (SDL 2.0.14+?), it seems that the video
402+
// subsystem must be initialized to get events from xinput controllers.
403+
printf("# SDL_Init(SDL_INIT_EVERYTHING)\n");
404+
flush_stdout();
405+
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
406+
printf("# SDL_Init(SDL_INIT_EVERYTHING) < 0\n");
403407
flush_stdout();
404408
return 2;
405409
}

0 commit comments

Comments
 (0)