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)
{
static int counter = 0;
static uint32 joyState [256];
for(int i = 0 ; i < 255 ; i++)
{
if(counter%2 && !joyState[i])
continue;
static uint32 joyState[6][53];
for(int j = 0 ; j < 6 ; j++)
{
for(int i = 0 ; i < 53 ; i++)
{
if(counter%2 && !joyState[j][i])
continue;
bool active = !S9xGetState(0x8000|i);
if(active)
{
if(joyState[i] < ULONG_MAX) // 0xffffffffUL
joyState[i]++;
if(joyState[i] == 1 || joyState[i] >= 12)
PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, (WPARAM)(0x8000|i),(LPARAM)(NULL));
}
else
if(joyState[i])
{
joyState[i] = 0;
PostMessage(GUI.hWnd, WM_CUSTKEYUP, (WPARAM)(0x8000|i),(LPARAM)(NULL));
}
}
counter++;
WPARAM wp = (WPARAM)(0x8000 | (j << 8) | i);
bool active = !S9xGetState(wp);
if(active)
{
if(joyState[j][i] < ULONG_MAX) // 0xffffffffUL
joyState[j][i]++;
if(joyState[j][i] == 1 || joyState[j][i] >= 12)
PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, wp,(LPARAM)(NULL));
}
else
if(joyState[j][i])
{
joyState[j][i] = 0;
PostMessage(GUI.hWnd, WM_CUSTKEYUP, wp,(LPARAM)(NULL));
}
}
}
counter++;
}
if(GUI.BackgroundInput && !GUI.InactivePause)
{