From 5b4df91b414e95fc10f53d2e98e49eb7a4447878 Mon Sep 17 00:00:00 2001 From: OV2 Date: Fri, 3 May 2013 20:18:51 +0200 Subject: [PATCH] win32: detect gamepad changes --- win32/win32.cpp | 11 ++++++++--- win32/wsnes9x.cpp | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/win32/win32.cpp b/win32/win32.cpp index db4eedfb..454f87f4 100644 --- a/win32/win32.cpp +++ b/win32/win32.cpp @@ -980,6 +980,13 @@ void S9xWinScanJoypads () #endif } +void S9xDetectJoypads() +{ + for (int C = 0; C != 16; C ++) + Joystick[C].Attached = joyGetDevCaps (JOYSTICKID1+C, &Joystick[C].Caps, + sizeof( JOYCAPS)) == JOYERR_NOERROR; +} + void InitSnes9X( void) { #ifdef DEBUGGER @@ -1023,9 +1030,7 @@ void InitSnes9X( void) S9xMovieInit (); - for (int C = 0; C != 16; C ++) - Joystick[C].Attached = joyGetDevCaps (JOYSTICKID1+C, &Joystick[C].Caps, - sizeof( JOYCAPS)) == JOYERR_NOERROR; + S9xDetectJoypads(); } void DeinitS9x() { diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 932c5e44..ab9295c3 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -282,6 +282,8 @@ HRESULT CALLBACK EnumModesCallback( LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpCo VOID CALLBACK HotkeyTimer( UINT idEvent, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2); +void S9xDetectJoypads(); + #define NOTKNOWN "Unknown Company " #define HEADER_SIZE 512 #define INFO_LEN (0xFF - 0xC0) @@ -2685,6 +2687,9 @@ LRESULT CALLBACK WinProc( #endif break; #endif + case WM_DEVICECHANGE: + S9xDetectJoypads(); + break; } return DefWindowProc (hWnd, uMsg, wParam, lParam); }