hrnm
This commit is contained in:
parent
2c9076a27d
commit
d3b1be57cb
|
@ -1,6 +1,6 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by C:\Aaron\Projects\OpenXDK\cxbx\Resource\Cxbx.rc
|
||||
// Used by D:\OpenXDK\cxbx\Resource\Cxbx.rc
|
||||
//
|
||||
#define IDI_CXBX 101
|
||||
#define IDB_SPLASH 102
|
||||
|
|
|
@ -83,6 +83,7 @@ INT_PTR CALLBACK DlgControllerConfigProc(HWND hWndDlg, UINT uMsg, WPARAM wParam,
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
SetClassLong(hWndDlg, GCL_HICON, (LONG)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_CXBX)));
|
||||
SetFocus(GetDlgItem(hWndDlg, IDC_SET_X));
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
EndDialog(hWndDlg, wParam);
|
||||
|
|
|
@ -57,7 +57,6 @@ LPDIRECTINPUTDEVICE8 g_pInputDev[MAX_INPUT_DEVICES] = {0};
|
|||
int g_pInputCur = 0;
|
||||
xapi::XINPUT_STATE g_EmuController1;
|
||||
|
||||
|
||||
// ******************************************************************
|
||||
// * statics
|
||||
// ******************************************************************
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
// ******************************************************************
|
||||
Mutex::Mutex()
|
||||
{
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
InterlockedExchange(&m_OwnerProcess, 0);
|
||||
InterlockedExchange(&m_OwnerThread, 0);
|
||||
InterlockedExchange(&m_LockCount, 0);
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
InterlockedExchange(&m_OwnerProcess, 0);
|
||||
InterlockedExchange(&m_OwnerThread, 0);
|
||||
InterlockedExchange(&m_LockCount, 0);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
@ -51,44 +51,45 @@ void Mutex::Lock()
|
|||
{
|
||||
while(true)
|
||||
{
|
||||
// Grab the lock, letting us look at the variables
|
||||
while(InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0))
|
||||
Sleep(1);
|
||||
// Grab the lock, letting us look at the variables
|
||||
while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0))
|
||||
// while(InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0))
|
||||
Sleep(1);
|
||||
|
||||
// Are we the the new owner?
|
||||
if (!m_OwnerProcess)
|
||||
{
|
||||
// Take ownership
|
||||
InterlockedExchange(&m_OwnerProcess, (LONG)GetCurrentProcessId());
|
||||
InterlockedExchange(&m_OwnerThread, (LONG)GetCurrentThreadId());
|
||||
InterlockedExchange(&m_LockCount, 1);
|
||||
// Are we the the new owner?
|
||||
if (!m_OwnerProcess)
|
||||
{
|
||||
// Take ownership
|
||||
InterlockedExchange(&m_OwnerProcess, (LONG)GetCurrentProcessId());
|
||||
InterlockedExchange(&m_OwnerThread, (LONG)GetCurrentThreadId());
|
||||
InterlockedExchange(&m_LockCount, 1);
|
||||
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// If a different process owns this mutex right now, unlock
|
||||
// the mutex lock and wait. The reading need not be
|
||||
// interlocked.
|
||||
if ((m_OwnerProcess != (LONG) GetCurrentProcessId()) ||
|
||||
(m_OwnerThread != (LONG) GetCurrentThreadId()))
|
||||
{
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
// If a different process owns this mutex right now, unlock
|
||||
// the mutex lock and wait. The reading need not be
|
||||
// interlocked.
|
||||
if ((m_OwnerProcess != (LONG) GetCurrentProcessId()) ||
|
||||
(m_OwnerThread != (LONG) GetCurrentThreadId()))
|
||||
{
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
|
||||
// Wait and try again
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
// Wait and try again
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// The mutex was already locked, but by us. Just increment
|
||||
// the lock count and unlock the mutex itself.
|
||||
InterlockedIncrement(&m_LockCount);
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
// The mutex was already locked, but by us. Just increment
|
||||
// the lock count and unlock the mutex itself.
|
||||
InterlockedIncrement(&m_LockCount);
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,18 +98,19 @@ void Mutex::Lock()
|
|||
// ******************************************************************
|
||||
void Mutex::Unlock()
|
||||
{
|
||||
// Grab the lock, letting us look at the variables
|
||||
while (InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0))
|
||||
Sleep(1);
|
||||
// Grab the lock, letting us look at the variables
|
||||
while(InterlockedCompareExchange((LPVOID*)&m_MutexLock, (LPVOID)1, (LPVOID)0))
|
||||
// while (InterlockedCompareExchange((LPLONG volatile)&m_MutexLock, (LONG)1, (LONG)0))
|
||||
Sleep(1);
|
||||
|
||||
// Decrement the lock count
|
||||
if (!InterlockedDecrement(&m_LockCount))
|
||||
{
|
||||
// Mark the mutex as now unused
|
||||
InterlockedExchange(&m_OwnerProcess, 0);
|
||||
InterlockedExchange(&m_OwnerThread, 0);
|
||||
}
|
||||
// Decrement the lock count
|
||||
if (!InterlockedDecrement(&m_LockCount))
|
||||
{
|
||||
// Mark the mutex as now unused
|
||||
InterlockedExchange(&m_OwnerProcess, 0);
|
||||
InterlockedExchange(&m_OwnerThread, 0);
|
||||
}
|
||||
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
// Unlock the mutex itself
|
||||
InterlockedExchange(&m_MutexLock, 0);
|
||||
}
|
Loading…
Reference in New Issue