fix bug preventing use of joysticks for hotkeys (even though they could be bound)
This commit is contained in:
parent
e502d5b656
commit
a248e403d6
|
@ -23,6 +23,8 @@
|
||||||
#ifndef INPUTDX_INCLUDED
|
#ifndef INPUTDX_INCLUDED
|
||||||
#define INPUTDX_INCLUDED
|
#define INPUTDX_INCLUDED
|
||||||
|
|
||||||
|
#include <mmsystem.h>
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
COLORREF crForeGnd; // Foreground text colour
|
COLORREF crForeGnd; // Foreground text colour
|
||||||
|
@ -78,7 +80,7 @@ struct SJoypad {
|
||||||
|
|
||||||
struct SJoyState{
|
struct SJoyState{
|
||||||
bool Attached;
|
bool Attached;
|
||||||
//JOYCAPS Caps;
|
JOYCAPS Caps;
|
||||||
int Threshold;
|
int Threshold;
|
||||||
bool Left;
|
bool Left;
|
||||||
bool Right;
|
bool Right;
|
||||||
|
|
|
@ -332,7 +332,8 @@ LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
static int KeyInDelayMSec = 0;
|
static int KeyInDelayMSec = 0;
|
||||||
static int KeyInRepeatMSec = 16;
|
static int KeyInRepeatMSec = 16;
|
||||||
|
|
||||||
VOID CALLBACK KeyInputTimer( UINT idEvent, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
template<bool JOYSTICK>
|
||||||
|
static void InputTimer()
|
||||||
{
|
{
|
||||||
bool S9xGetState (WORD KeyIdent);
|
bool S9xGetState (WORD KeyIdent);
|
||||||
|
|
||||||
|
@ -355,30 +356,37 @@ VOID CALLBACK KeyInputTimer( UINT idEvent, UINT uMsg, DWORD_PTR dwUser, DWORD_PT
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int z = 0; z < 256; z++) {
|
||||||
|
int i = z | (JOYSTICK?0x8000:0);
|
||||||
bool active = !S9xGetState(i);
|
bool active = !S9xGetState(i);
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
bool keyRepeat = (currentTime - joyState[i].firstPressedTime) >= (DWORD)KeyInDelayMSec;
|
bool keyRepeat = (currentTime - joyState[z].firstPressedTime) >= (DWORD)KeyInDelayMSec;
|
||||||
if (!joyState[i].wasPressed || keyRepeat) {
|
if (!joyState[z].wasPressed || keyRepeat) {
|
||||||
if (!joyState[i].wasPressed)
|
if (!joyState[z].wasPressed)
|
||||||
joyState[i].firstPressedTime = currentTime;
|
joyState[z].firstPressedTime = currentTime;
|
||||||
joyState[i].lastPressedTime = currentTime;
|
joyState[z].lastPressedTime = currentTime;
|
||||||
if (keyRepeat && joyState[i].repeatCount < 0xffff)
|
if (keyRepeat && joyState[z].repeatCount < 0xffff)
|
||||||
joyState[i].repeatCount++;
|
joyState[z].repeatCount++;
|
||||||
PostMessage(MainWindow->getHWnd(), WM_CUSTKEYDOWN, (WPARAM)(i),(LPARAM)(joyState[i].repeatCount | (joyState[i].wasPressed ? 0x40000000 : 0)));
|
PostMessage(MainWindow->getHWnd(), WM_CUSTKEYDOWN, (WPARAM)(i),(LPARAM)(joyState[z].repeatCount | (joyState[z].wasPressed ? 0x40000000 : 0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
joyState[i].repeatCount = 1;
|
joyState[z].repeatCount = 1;
|
||||||
if (joyState[i].wasPressed)
|
if (joyState[z].wasPressed)
|
||||||
PostMessage(MainWindow->getHWnd(), WM_CUSTKEYUP, (WPARAM)(i),(LPARAM)(joyState[i].repeatCount | (joyState[i].wasPressed ? 0x40000000 : 0)));
|
PostMessage(MainWindow->getHWnd(), WM_CUSTKEYUP, (WPARAM)(i),(LPARAM)(joyState[z].repeatCount | (joyState[z].wasPressed ? 0x40000000 : 0)));
|
||||||
}
|
}
|
||||||
joyState[i].wasPressed = active;
|
joyState[z].wasPressed = active;
|
||||||
}
|
}
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID CALLBACK KeyInputTimer( UINT idEvent, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
|
||||||
|
{
|
||||||
|
InputTimer<false>();
|
||||||
|
InputTimer<true>();
|
||||||
|
}
|
||||||
|
|
||||||
void ScaleScreen(float factor)
|
void ScaleScreen(float factor)
|
||||||
{
|
{
|
||||||
if(windowSize == 0)
|
if(windowSize == 0)
|
||||||
|
|
Loading…
Reference in New Issue