Skip to content

Commit

Permalink
Fix device helper for xinput devices with recent SDL2 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
FrodeSolheim committed Oct 10, 2021
1 parent 88d348f commit 1fcae71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 3.1:

* Fix device helper for xinput devices with recent SDL2 versions.
* Support for multiple mice disabled by default on macOS due to security
warning. Use option multiple_mice = 1 to enable.
* Disable expect_version option (no longer synchronized with launcher).
Expand Down
18 changes: 11 additions & 7 deletions src/fs-uae/device-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ static void print_events(void)
printf("# Support for multiple mice not enabled\n");
}

printf("# SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS))\n");
// With recent SDL2 versions (SDL 2.0.14+?), it seems that the video
// subsystem must be initialized to get events from xinput controllers.
printf("# SDL_Init(SDL_INIT_EVERYTHING)\n");
flush_stdout();
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) < 0) {
printf("# SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)) < 0\n");
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
printf("# SDL_Init(SDL_INIT_EVERYTHING) < 0\n");
flush_stdout();
return;
}
Expand Down Expand Up @@ -314,7 +316,6 @@ static void print_events(void)

static void print_state(SDL_Joystick* joystick, const char* name)
{

int num_buttons = SDL_JoystickNumButtons(joystick);
int num_hats = SDL_JoystickNumHats(joystick);
int num_axes = SDL_JoystickNumAxes(joystick);
Expand Down Expand Up @@ -397,9 +398,12 @@ int main(int argc, char* argv[])

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

printf("# SDL_Init(SDL_INIT_JOYSTICK)\n");
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
printf("# SDL_Init(SDL_INIT_JOYSTICK) < 0\n");
// With recent SDL2 versions (SDL 2.0.14+?), it seems that the video
// subsystem must be initialized to get events from xinput controllers.
printf("# SDL_Init(SDL_INIT_EVERYTHING)\n");
flush_stdout();
if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
printf("# SDL_Init(SDL_INIT_EVERYTHING) < 0\n");
flush_stdout();
return 2;
}
Expand Down

0 comments on commit 1fcae71

Please sign in to comment.