From 3a7865ac3f5b1c68cd161acece97da6557a3e37c Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sun, 3 May 2009 19:30:38 +0000 Subject: [PATCH] ZeroPad: Patch to fix a bug introduced in r1125. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1128 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/zeropad/Linux/linux.cpp | 14 +++++++++----- plugins/zeropad/Windows/win.cpp | 16 ++++++++++------ plugins/zeropad/zeropad.h | 1 + 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/plugins/zeropad/Linux/linux.cpp b/plugins/zeropad/Linux/linux.cpp index 67afc24340..6cea5ae5fe 100644 --- a/plugins/zeropad/Linux/linux.cpp +++ b/plugins/zeropad/Linux/linux.cpp @@ -317,6 +317,7 @@ int _GetJoystickIdFromPAD(int pad) } } } + return joyid; } void CALLBACK PADupdate(int pad) @@ -382,9 +383,10 @@ void CALLBACK PADupdate(int pad) #endif i = FindKey(key, pad); - keyPress |= (1 << i); - keyRelease &= ~(1 << i); - + if (i != -1) { + keyPress |= (1 << i); + keyRelease &= ~(1 << i); + } event.evt = KEYPRESS; event.key = key; break; @@ -423,8 +425,10 @@ void CALLBACK PADupdate(int pad) #endif i = FindKey(key, pad); - keyPress &= ~(1 << i); - keyRelease |= (1 << i); + if (i != -1) { + keyPress &= ~(1 << i); + keyRelease |= (1 << i); + } event.evt = KEYRELEASE; event.key = key; break; diff --git a/plugins/zeropad/Windows/win.cpp b/plugins/zeropad/Windows/win.cpp index 132ac8abb8..34a4eefc18 100644 --- a/plugins/zeropad/Windows/win.cpp +++ b/plugins/zeropad/Windows/win.cpp @@ -190,17 +190,21 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) if (lParam & 0x40000000) return TRUE; - i = FindKey(wparam, pad); - keyPress[pad] |= (1 << i); - keyRelease[pad] &= ~(1 << i); + i = FindKey(wParam, pad); + if (i != -1) { + keyPress[pad] |= (1 << i); + keyRelease[pad] &= ~(1 << i); + } event.evt = KEYPRESS; event.key = wParam; break; case WM_KEYUP: - i = FindKey(wparam, pad); - keyPress[pad] &= ~(1 << i); - keyRelease[pad] |= (1 << i); + i = FindKey(wParam, pad); + if (i != -1) { + keyPress[pad] &= ~(1 << i); + keyRelease[pad] |= (1 << i); + } event.evt = KEYRELEASE; event.key = wParam; break; diff --git a/plugins/zeropad/zeropad.h b/plugins/zeropad/zeropad.h index eb7ac4e9ba..43a422faff 100644 --- a/plugins/zeropad/zeropad.h +++ b/plugins/zeropad/zeropad.h @@ -162,6 +162,7 @@ inline int FindKey(int key, int pad) for (int p = 0; p < PADSUBKEYS; p++) for (int i = 0; i < PADKEYS; i++) if (key == conf.keys[(PadEnum[pad][p])][i]) return i; + return -1; } #endif