mirror of https://github.com/PCSX2/pcsx2.git
xpad: repaired broken keyboard event forwarding to pcsx2
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@803 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
e5f8c7dbe9
commit
6982207440
|
@ -99,8 +99,6 @@ EXPORT_C_(UINT32) PSEgetLibVersion()
|
||||||
|
|
||||||
EXPORT_C_(UINT32) PS2EgetLibType()
|
EXPORT_C_(UINT32) PS2EgetLibType()
|
||||||
{
|
{
|
||||||
s_ps2 = true;
|
|
||||||
|
|
||||||
return PS2E_LT_PAD;
|
return PS2E_LT_PAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +109,8 @@ EXPORT_C_(char*) PS2EgetLibName()
|
||||||
|
|
||||||
EXPORT_C_(UINT32) PS2EgetLibVersion2(UINT32 type)
|
EXPORT_C_(UINT32) PS2EgetLibVersion2(UINT32 type)
|
||||||
{
|
{
|
||||||
|
s_ps2 = true;
|
||||||
|
|
||||||
return (s_ver.build << 0) | (s_ver.revision << 8) | (PS2E_PAD_VERSION << 16) | (s_ver.minor << 24);
|
return (s_ver.build << 0) | (s_ver.revision << 8) | (PS2E_PAD_VERSION << 16) | (s_ver.minor << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +553,34 @@ public:
|
||||||
static int s_nRefs = 0;
|
static int s_nRefs = 0;
|
||||||
static HWND s_hWnd = NULL;
|
static HWND s_hWnd = NULL;
|
||||||
static WNDPROC s_GSWndProc = NULL;
|
static WNDPROC s_GSWndProc = NULL;
|
||||||
static KeyEvent s_event = {0, 0};
|
|
||||||
|
static class CKeyEventList : protected CAtlList<KeyEvent>, protected CCritSec
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Push(UINT32 event, UINT32 key)
|
||||||
|
{
|
||||||
|
CAutoLock cAutoLock(this);
|
||||||
|
|
||||||
|
KeyEvent e;
|
||||||
|
|
||||||
|
e.event = event;
|
||||||
|
e.key = key;
|
||||||
|
|
||||||
|
AddTail(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Pop(KeyEvent& e)
|
||||||
|
{
|
||||||
|
CAutoLock cAutoLock(this);
|
||||||
|
|
||||||
|
if(IsEmpty()) return false;
|
||||||
|
|
||||||
|
e = RemoveHead();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} s_event;
|
||||||
|
|
||||||
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -561,17 +588,14 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
if(lParam & 0x40000000) return TRUE;
|
if(lParam & 0x40000000) return TRUE;
|
||||||
s_event.event = KEYPRESS;
|
s_event.Push(KEYPRESS, wParam);
|
||||||
s_event.key = wParam;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
s_event.event = KEYRELEASE;
|
s_event.Push(KEYRELEASE, wParam);
|
||||||
s_event.key = wParam;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
case WM_QUIT:
|
case WM_QUIT:
|
||||||
s_event.event = KEYPRESS;
|
s_event.Push(KEYPRESS, VK_ESCAPE);
|
||||||
s_event.key = VK_ESCAPE;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,10 +690,9 @@ EXPORT_C_(UINT32) PADreadPort2(PadDataS* ppds)
|
||||||
|
|
||||||
EXPORT_C_(KeyEvent*) PADkeyEvent()
|
EXPORT_C_(KeyEvent*) PADkeyEvent()
|
||||||
{
|
{
|
||||||
static KeyEvent event;
|
static KeyEvent e;
|
||||||
event = s_event;
|
|
||||||
s_event.event = 0;
|
return s_event.Pop(e) ? &e : NULL;
|
||||||
return &event;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C PADconfigure()
|
EXPORT_C PADconfigure()
|
||||||
|
|
|
@ -87,3 +87,34 @@ struct KeyEvent
|
||||||
|
|
||||||
#define KEYPRESS 1
|
#define KEYPRESS 1
|
||||||
#define KEYRELEASE 2
|
#define KEYRELEASE 2
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
class CCritSec
|
||||||
|
{
|
||||||
|
CCritSec(const CCritSec &refCritSec);
|
||||||
|
CCritSec &operator=(const CCritSec &refCritSec);
|
||||||
|
|
||||||
|
CRITICAL_SECTION m_CritSec;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CCritSec() {InitializeCriticalSection(&m_CritSec);};
|
||||||
|
~CCritSec() {DeleteCriticalSection(&m_CritSec);};
|
||||||
|
|
||||||
|
void Lock() {EnterCriticalSection(&m_CritSec);};
|
||||||
|
void Unlock() {LeaveCriticalSection(&m_CritSec);};
|
||||||
|
};
|
||||||
|
|
||||||
|
class CAutoLock
|
||||||
|
{
|
||||||
|
CAutoLock(const CAutoLock &refAutoLock);
|
||||||
|
CAutoLock &operator=(const CAutoLock &refAutoLock);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CCritSec * m_pLock;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAutoLock(CCritSec * plock) {m_pLock = plock; m_pLock->Lock();};
|
||||||
|
~CAutoLock() {m_pLock->Unlock();};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue