Win32: fix joypad hotkeys on joypads > 0

This commit is contained in:
OV2 2015-04-20 17:55:57 +02:00
parent 56a4ce5ef8
commit 9ca3bcce39
1 changed files with 25 additions and 21 deletions

View File

@ -2784,28 +2784,32 @@ VOID CALLBACK HotkeyTimer( UINT idEvent, UINT uMsg, DWORD dwUser, DWORD dw1, DWO
if(GUI.JoystickHotkeys) if(GUI.JoystickHotkeys)
{ {
static int counter = 0; static int counter = 0;
static uint32 joyState [256]; static uint32 joyState[6][53];
for(int i = 0 ; i < 255 ; i++) for(int j = 0 ; j < 6 ; j++)
{ {
if(counter%2 && !joyState[i]) for(int i = 0 ; i < 53 ; i++)
continue; {
if(counter%2 && !joyState[j][i])
continue;
bool active = !S9xGetState(0x8000|i); WPARAM wp = (WPARAM)(0x8000 | (j << 8) | i);
if(active) bool active = !S9xGetState(wp);
{ if(active)
if(joyState[i] < ULONG_MAX) // 0xffffffffUL {
joyState[i]++; if(joyState[j][i] < ULONG_MAX) // 0xffffffffUL
if(joyState[i] == 1 || joyState[i] >= 12) joyState[j][i]++;
PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, (WPARAM)(0x8000|i),(LPARAM)(NULL)); if(joyState[j][i] == 1 || joyState[j][i] >= 12)
} PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, wp,(LPARAM)(NULL));
else }
if(joyState[i]) else
{ if(joyState[j][i])
joyState[i] = 0; {
PostMessage(GUI.hWnd, WM_CUSTKEYUP, (WPARAM)(0x8000|i),(LPARAM)(NULL)); joyState[j][i] = 0;
} PostMessage(GUI.hWnd, WM_CUSTKEYUP, wp,(LPARAM)(NULL));
} }
counter++; }
}
counter++;
} }
if(GUI.BackgroundInput && !GUI.InactivePause) if(GUI.BackgroundInput && !GUI.InactivePause)
{ {