mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-06-02 20:41:38 +00:00
Cmd line support for remapping button0&1: (#743)
. -left-control-alt-buttons : l-ctrl=button0, l-alt=button1 . -right-alt-control-buttons : r-alt=button0, r-ctrl=button1 . -swap-buttons
This commit is contained in:
parent
0f473d44b6
commit
29c0f1e4f0
|
@ -1576,6 +1576,20 @@ static void ProcessCmdLine(LPSTR lpCmdLine)
|
||||||
{
|
{
|
||||||
JoySetHookAltKeys(false);
|
JoySetHookAltKeys(false);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(lpCmdLine, "-left-control-alt-buttons") == 0)
|
||||||
|
{
|
||||||
|
JoySetButtonVirtualKey(0, VK_CONTROL);
|
||||||
|
JoySetButtonVirtualKey(1, VK_MENU);
|
||||||
|
}
|
||||||
|
else if (strcmp(lpCmdLine, "-right-alt-control-buttons") == 0)
|
||||||
|
{
|
||||||
|
JoySetButtonVirtualKey(0, VK_MENU | KF_EXTENDED);
|
||||||
|
JoySetButtonVirtualKey(1, VK_CONTROL | KF_EXTENDED);
|
||||||
|
}
|
||||||
|
else if (strcmp(lpCmdLine, "-swap-buttons") == 0)
|
||||||
|
{
|
||||||
|
JoySwapButton0and1(true);
|
||||||
|
}
|
||||||
else if (strcmp(lpCmdLine, "-spkr-inc") == 0)
|
else if (strcmp(lpCmdLine, "-spkr-inc") == 0)
|
||||||
{
|
{
|
||||||
lpCmdLine = GetCurrArg(lpNextArg);
|
lpCmdLine = GetCurrArg(lpNextArg);
|
||||||
|
|
|
@ -303,6 +303,24 @@ void JoyInitialize()
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
|
static bool g_swapButton0and1 = false;
|
||||||
|
|
||||||
|
void JoySwapButton0and1(bool swap)
|
||||||
|
{
|
||||||
|
g_swapButton0and1 = swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UINT g_buttonVirtKey[2] = { VK_MENU, VK_MENU | KF_EXTENDED };
|
||||||
|
|
||||||
|
void JoySetButtonVirtualKey(UINT button, UINT virtKey)
|
||||||
|
{
|
||||||
|
_ASSERT(button < 2);
|
||||||
|
if (button >= 2) return;
|
||||||
|
g_buttonVirtKey[button] = virtKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
#define SUPPORT_CURSOR_KEYS
|
#define SUPPORT_CURSOR_KEYS
|
||||||
|
|
||||||
BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
|
BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
|
||||||
|
@ -330,11 +348,17 @@ BOOL JoyProcessKey(int virtkey, bool extended, bool down, bool autorep)
|
||||||
|
|
||||||
BOOL keychange = 0;
|
BOOL keychange = 0;
|
||||||
bool bIsCursorKey = false;
|
bool bIsCursorKey = false;
|
||||||
|
UINT virtKeyWithExtended = ((UINT)virtkey) | (extended ? KF_EXTENDED : 0);
|
||||||
|
|
||||||
if (virtkey == VK_MENU) // VK_MENU == ALT Key (Button #0 or #1)
|
if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 0 : 1])
|
||||||
{
|
{
|
||||||
keychange = 1;
|
keychange = 1;
|
||||||
keydown[JK_OPENAPPLE+(extended != 0)] = down;
|
keydown[JK_OPENAPPLE] = down;
|
||||||
|
}
|
||||||
|
else if (virtKeyWithExtended == g_buttonVirtKey[!g_swapButton0and1 ? 1 : 0])
|
||||||
|
{
|
||||||
|
keychange = 1;
|
||||||
|
keydown[JK_CLOSEDAPPLE] = down;
|
||||||
}
|
}
|
||||||
else if (!extended)
|
else if (!extended)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,8 @@ void JoySetTrim(short nValue, bool bAxisX);
|
||||||
short JoyGetTrim(bool bAxisX);
|
short JoyGetTrim(bool bAxisX);
|
||||||
void JoyportControl(const UINT uControl);
|
void JoyportControl(const UINT uControl);
|
||||||
void JoySetHookAltKeys(bool hook);
|
void JoySetHookAltKeys(bool hook);
|
||||||
|
void JoySwapButton0and1(bool swap);
|
||||||
|
void JoySetButtonVirtualKey(UINT button, UINT virtKey);
|
||||||
void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
void JoySaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||||
void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
void JoyLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user