From 5b549a4fe01408bc959e858a343883156264b4ad Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 5 Mar 2016 13:02:05 +0100 Subject: Using SDL_INIT_GAMECONTROLLER it explicitly calls SDL_INIT_JOYSTICK some experimental code (nw) --- src/osd/modules/input/input_sdl.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/osd/modules/input/input_sdl.cpp') diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 3894f25e1b4..43d4cbf6a6c 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -688,11 +688,20 @@ public: int physical_stick; for (physical_stick = 0; physical_stick < SDL_NumJoysticks(); physical_stick++) { - SDL_Joystick *joy = SDL_JoystickOpen(physical_stick); - std::string joy_name = remove_spaces(SDL_JoystickName(joy)); - SDL_JoystickClose(joy); - - devmap_register(&m_joy_map, physical_stick, joy_name.c_str()); + if (SDL_IsGameController(physical_stick)) { + osd_printf_verbose("Joystick %i is supported by the game controller interface!\n", physical_stick); + osd_printf_verbose("Compatible controller, named \'%s\'\n", SDL_GameControllerNameForIndex(physical_stick)); + SDL_GameController *joy = SDL_GameControllerOpen(physical_stick); + osd_printf_verbose("Controller is mapped as \"%s\".\n", SDL_GameControllerMapping(joy)); + std::string joy_name = remove_spaces(SDL_GameControllerName(joy)); + SDL_GameControllerClose(joy); + devmap_register(&m_joy_map, physical_stick, joy_name.c_str()); + } else { + SDL_Joystick *joy = SDL_JoystickOpen(physical_stick); + std::string joy_name = remove_spaces(SDL_JoystickName(joy)); + SDL_JoystickClose(joy); + devmap_register(&m_joy_map, physical_stick, joy_name.c_str()); + } } for (int stick = 0; stick < MAX_DEVMAP_ENTRIES; stick++) -- cgit v1.2.3-70-g09d2