mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-03 07:02:44 +02:00
Fix SDL controllers not automatically reconnecting. Fixes #563
This commit is contained in:
@@ -1776,9 +1776,9 @@ static void enter_keyboard_menu(unsigned index)
|
||||
}
|
||||
|
||||
static unsigned joypad_index = 0;
|
||||
static SDL_Joystick *joystick = NULL;
|
||||
static SDL_GameController *controller = NULL;
|
||||
SDL_Haptic *haptic = NULL;
|
||||
SDL_Joystick *joystick = NULL;
|
||||
|
||||
static const char *current_joypad_name(unsigned index)
|
||||
{
|
||||
@@ -1830,7 +1830,8 @@ static void cycle_joypads(unsigned index)
|
||||
}
|
||||
if (joystick) {
|
||||
haptic = SDL_HapticOpenFromJoystick(joystick);
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
static void cycle_joypads_backwards(unsigned index)
|
||||
{
|
||||
|
@@ -21,6 +21,7 @@ extern SDL_Window *window;
|
||||
extern SDL_Renderer *renderer;
|
||||
extern SDL_Texture *texture;
|
||||
extern SDL_PixelFormat *pixel_format;
|
||||
extern SDL_Joystick *joystick;
|
||||
extern SDL_Haptic *haptic;
|
||||
extern shader_t shader;
|
||||
|
||||
|
@@ -249,6 +249,15 @@ static void handle_events(GB_gameboy_t *gb)
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
if (joystick && event.jdevice.which == SDL_JoystickInstanceID(joystick)) {
|
||||
SDL_JoystickClose(joystick);
|
||||
joystick = NULL;
|
||||
}
|
||||
case SDL_JOYDEVICEADDED:
|
||||
connect_joypad();
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONUP:
|
||||
case SDL_JOYBUTTONDOWN: {
|
||||
joypad_button_t button = get_joypad_button(event.jbutton.button);
|
||||
|
Reference in New Issue
Block a user