Skip to content

Commit 7d51100

Browse files
committed
Changed KeyboardTranslator to work with multiple keys mapped to a single controller button. Updated example to include more keymaps.
1 parent 7c5a80f commit 7d51100

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

XMapLib/KeyboardTranslator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ namespace sds
139139
const auto stickSettingList = leftStick ? KeyboardSettings::THUMBSTICK_L_VK_LIST : KeyboardSettings::THUMBSTICK_R_VK_LIST;
140140
auto TestFunc = [&stickSettingList, &detail](const KeyboardKeyMap& elem)
141141
{
142-
if ((elem.LastAction == InpType::KEYDOWN || elem.LastAction == InpType::KEYREPEAT) && elem != detail)
142+
if ((elem.LastAction == InpType::KEYDOWN || elem.LastAction == InpType::KEYREPEAT) && elem.SendingElementVK != detail.SendingElementVK)
143143
return std::find(stickSettingList.begin(), stickSettingList.end(), elem.SendingElementVK) != stickSettingList.end();
144144
return false;
145145
};

XMapLib/XMapLib.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,27 @@ void AddTestKeyMappings(sds::KeyboardMapper& mapper)
7474
const auto buttons =
7575
{
7676
//https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
77-
KeyboardKeyMap{VK_PAD_LTRIGGER, VK_RBUTTON, false},
78-
KeyboardKeyMap{VK_PAD_RTRIGGER, VK_LBUTTON, false},
77+
KeyboardKeyMap{VK_PAD_LTRIGGER, VK_RBUTTON, false}, // right click
78+
KeyboardKeyMap{VK_PAD_RTRIGGER, VK_LBUTTON, false}, // left click
7979
KeyboardKeyMap{VK_PAD_LTHUMB_UP, 0x57, true}, // 'w'
8080
KeyboardKeyMap{VK_PAD_LTHUMB_LEFT, 0x41, true}, // 'a'
8181
KeyboardKeyMap{VK_PAD_LTHUMB_DOWN, 0x53, true}, // 's'
8282
KeyboardKeyMap{VK_PAD_LTHUMB_RIGHT, 0x44, true}, // 'd'
8383
KeyboardKeyMap{VK_PAD_DPAD_DOWN, VK_DOWN, true}, // 'downarrow'
8484
KeyboardKeyMap{VK_PAD_DPAD_UP, VK_UP, true}, // 'uparrow'
8585
KeyboardKeyMap{VK_PAD_DPAD_LEFT, VK_LEFT, true}, // 'leftarrow'
86-
KeyboardKeyMap{VK_PAD_DPAD_RIGHT, VK_RIGHT, true} // 'rightarrow'
86+
KeyboardKeyMap{VK_PAD_DPAD_RIGHT, VK_RIGHT, true}, // 'rightarrow'
87+
KeyboardKeyMap{VK_PAD_LTHUMB_UPLEFT, 0x57, true}, // 'w'
88+
KeyboardKeyMap{VK_PAD_LTHUMB_UPLEFT, 0x41, true}, // 'a'
89+
KeyboardKeyMap{VK_PAD_LTHUMB_UPRIGHT, 0x57, true}, // 'w'
90+
KeyboardKeyMap{VK_PAD_LTHUMB_UPRIGHT, 0x44, true}, // 'd'
91+
KeyboardKeyMap{VK_PAD_LTHUMB_DOWNLEFT, 0x53, true}, // 's'
92+
KeyboardKeyMap{VK_PAD_LTHUMB_DOWNLEFT, 0x41, true}, // 'a'
93+
KeyboardKeyMap{VK_PAD_LTHUMB_DOWNRIGHT, 0x53, true}, // 's'
94+
KeyboardKeyMap{VK_PAD_LTHUMB_DOWNRIGHT, 0x44, true}, // 'd'
95+
KeyboardKeyMap{VK_PAD_A, VK_SPACE, false}, // ' '
96+
KeyboardKeyMap{VK_PAD_B, 0x45, false}, // 'e'
97+
KeyboardKeyMap{VK_PAD_X, 0x52, false} // 'r'
8798
};
8899
std::string errorCondition;
89100
ranges::for_each(ranges::begin(buttons), ranges::end(buttons), [&mapper, &errorCondition](const KeyboardKeyMap& m)

0 commit comments

Comments
 (0)