@@ -42,13 +42,13 @@ namespace sds
4242 // Key repeat loop
4343 KeyRepeatLoop ();
4444 // search the map for a matching virtual key and send it
45- std::for_each (m_map_token_info.begin (), m_map_token_info.end (), [this , &stroke](auto &w)
45+ for (auto &w: m_map_token_info)
46+ {
47+ if (w.SendingElementVK == stroke.VirtualKey )
4648 {
47- if (w.SendingElementVK == stroke.VirtualKey )
48- {
49- this ->Normal (w, stroke);
50- }
51- });
49+ this ->Normal (w, stroke);
50+ }
51+ }
5252 }
5353 std::string AddKeyMap (KeyboardKeyMap w)
5454 {
@@ -71,25 +71,25 @@ namespace sds
7171 {
7272 // If enough time has passed, reset the key for use again, provided it uses the key-repeat behavior--
7373 // otherwise reset it immediately.
74- std::for_each (m_map_token_info. begin (), m_map_token_info. end (), []( auto & e )
75- {
76- const bool DoUpdate = (e.LastAction == InpType::KEYUP && e.LastSentTime .IsElapsed ()) && e.UsesRepeat ;
77- const bool DoImmediate = e.LastAction == InpType::KEYUP && !e.UsesRepeat ;
78- if (DoUpdate || DoImmediate)
79- e.LastAction = InpType::NONE;
80- });
74+ for ( auto &e: m_map_token_info )
75+ {
76+ const bool DoUpdate = (e.LastAction == InpType::KEYUP && e.LastSentTime .IsElapsed ()) && e.UsesRepeat ;
77+ const bool DoImmediate = e.LastAction == InpType::KEYUP && !e.UsesRepeat ;
78+ if (DoUpdate || DoImmediate)
79+ e.LastAction = InpType::NONE;
80+ }
8181 }
8282 void KeyRepeatLoop ()
8383 {
84- std::for_each (m_map_token_info.begin (), m_map_token_info.end (), [this ](auto & w)
84+ for (auto &w: m_map_token_info)
85+ {
86+ using AT = sds::KeyboardKeyMap::ActionType;
87+ if (w.UsesRepeat && (((w.LastAction == AT::KEYDOWN) || (w.LastAction == AT::KEYREPEAT))))
8588 {
86- using AT = sds::KeyboardKeyMap::ActionType;
87- if (w.UsesRepeat && (((w.LastAction == AT::KEYDOWN) || (w.LastAction == AT::KEYREPEAT))))
88- {
89- if (w.LastSentTime .IsElapsed ())
90- this ->SendTheKey (w, true , AT::KEYREPEAT);
91- }
92- });
89+ if (w.LastSentTime .IsElapsed ())
90+ this ->SendTheKey (w, true , AT::KEYREPEAT);
91+ }
92+ }
9393 }
9494 // / <summary>
9595 // / Normal keypress simulation logic.
@@ -128,8 +128,8 @@ namespace sds
128128 bool IsOvertaking (const KeyboardKeyMap &detail, KeyboardKeyMap &outOvertaken)
129129 {
130130 // Is detail a thumbstick direction map, and if so, which thumbstick.
131- const auto leftAxisIterator = std::find (KeyboardSettings::THUMBSTICK_L_VK_LIST. begin (), KeyboardSettings::THUMBSTICK_L_VK_LIST. end () , detail.SendingElementVK );
132- const auto rightAxisIterator = std::find (KeyboardSettings::THUMBSTICK_R_VK_LIST. begin (), KeyboardSettings::THUMBSTICK_R_VK_LIST. end () , detail.SendingElementVK );
131+ const auto leftAxisIterator = std::ranges::find ( KeyboardSettings::THUMBSTICK_L_VK_LIST, detail.SendingElementVK );
132+ const auto rightAxisIterator = std::ranges::find ( KeyboardSettings::THUMBSTICK_R_VK_LIST, detail.SendingElementVK );
133133 const bool leftStick = leftAxisIterator != KeyboardSettings::THUMBSTICK_L_VK_LIST.end ();
134134 const bool rightStick = rightAxisIterator != KeyboardSettings::THUMBSTICK_R_VK_LIST.end ();
135135 // find a key-down'd or repeat'd direction of the same thumbstick
@@ -140,10 +140,10 @@ namespace sds
140140 auto TestFunc = [&stickSettingList, &detail](const KeyboardKeyMap& elem)
141141 {
142142 if ((elem.LastAction == InpType::KEYDOWN || elem.LastAction == InpType::KEYREPEAT) && elem.SendingElementVK != detail.SendingElementVK )
143- return std::find (stickSettingList. begin (), stickSettingList. end () , elem.SendingElementVK ) != stickSettingList.end ();
143+ return std::ranges:: find (stickSettingList, elem.SendingElementVK ) != stickSettingList.end ();
144144 return false ;
145145 };
146- const auto mpit = std::find_if (m_map_token_info. begin (), m_map_token_info. end () , TestFunc);
146+ const auto mpit = std::ranges:: find_if (m_map_token_info, TestFunc);
147147 if (mpit == m_map_token_info.end ())
148148 return false ;
149149 outOvertaken = *mpit;
0 commit comments