SSSPSXPAD: Fix for a random crashing bug when doing suspend/resume type stuff (caused by multiple threads trying to initialize directinput at the same time)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2383 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-12-22 14:18:05 +00:00
parent 916cc034ff
commit 3c03e15dc1
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
; FireWire.def : Declares the module parameters for the DLL.
LIBRARY "FWnull"
;LIBRARY "GSnull"
EXPORTS
; Explicit exports can go here

View File

@ -25,6 +25,7 @@ HWND hTargetWnd;
static std::string s_strIniPath( "inis/" );
static CRITICAL_SECTION update_lock;
static CRITICAL_SECTION init_lock;
struct EnterScopedSection
{
@ -40,7 +41,6 @@ struct EnterScopedSection
};
static struct
{
keyEvent ev;
@ -139,6 +139,8 @@ static bool ReleaseDirectInput (void)
static bool InitDirectInput (void)
{
EnterScopedSection initlock( init_lock );
if (global.pDInput)
return TRUE;
HRESULT result = DirectInput8Create (hInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&global.pDInput, NULL);
@ -760,12 +762,14 @@ u32 CALLBACK PSEgetLibVersion (void)
s32 CALLBACK PADinit (u32 flags)
{
InitializeCriticalSection( &update_lock );
InitializeCriticalSection( &init_lock );
return 0;
}
void CALLBACK PADshutdown (void)
{
DeleteCriticalSection( &update_lock );
DeleteCriticalSection( &init_lock );
}
static int n_open = 0;