Changeset View
Changeset View
Standalone View
Standalone View
source/ps/KeyName.cpp
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | static const std::unordered_map<int, std::vector<CStr>> scancodemap {{ | ||||
{ MOUSE_X2, { "WheelRight", "MouseX2" } }, | { MOUSE_X2, { "WheelRight", "MouseX2" } }, | ||||
{ UNIFIED_SHIFT, { "Shift", "Left Shift", "Right Shift" } }, | { UNIFIED_SHIFT, { "Shift", "Left Shift", "Right Shift" } }, | ||||
{ UNIFIED_CTRL, { "Ctrl", "Left Ctrl", "Right Ctrl" } }, | { UNIFIED_CTRL, { "Ctrl", "Left Ctrl", "Right Ctrl" } }, | ||||
{ UNIFIED_ALT, { "Alt", "Left Alt", "Right Alt" } }, | { UNIFIED_ALT, { "Alt", "Left Alt", "Right Alt" } }, | ||||
{ UNIFIED_SUPER, { "Super", "Left Gui", "Right Gui" } }, | { UNIFIED_SUPER, { "Super", "Left Gui", "Right Gui" } }, | ||||
}}; | }}; | ||||
SDL_Scancode FindScancode(const CStr& keyname) | SDL_Scancode FindScancode(const CStr8& keyname) | ||||
{ | { | ||||
// Find (ignoring case) a corresponding scancode, if one exists. | // Find (ignoring case) a corresponding scancode, if one exists. | ||||
std::unordered_map<int, std::vector<CStr>>::const_iterator it = | std::unordered_map<int, std::vector<CStr>>::const_iterator it = | ||||
std::find_if(scancodemap.begin(), scancodemap.end(), [&keyname](const std::pair<int, std::vector<CStr>>& names) { | std::find_if(scancodemap.begin(), scancodemap.end(), [&keyname](const std::pair<int, std::vector<CStr>>& names) { | ||||
return std::find_if(names.second.begin(), names.second.end(), [&keyname](const CStr& t) { | return std::find_if(names.second.begin(), names.second.end(), [&keyname](const CStr& t) { | ||||
return t.LowerCase() == keyname.LowerCase(); | return t.LowerCase() == keyname.LowerCase(); | ||||
})!= names.second.end(); | })!= names.second.end(); | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator