MCPcopy Create free account
hub / github.com/JibbSmart/JoyShockMapper / nameToKey

Function nameToKey

JoyShockMapper/src/linux/PlatformDefinitions.cpp:76–339  ·  view source on GitHub ↗

Valid inputs: 0-9, N0-N9, F1-F29, A-Z, (L, R, )CONTROL, (L, R, )ALT, (L, R, )SHIFT, TAB, ENTER (L, M, R)MOUSE, SCROLL(UP, DOWN) NONE And characters: ; ' , . / \ [ ] + - ` Yes, this looks slow. But it's only there to help set up faster mappings

Source from the content-addressed store, hash-verified

74/// And characters: ; ' , . / \ [ ] + - `
75/// Yes, this looks slow. But it's only there to help set up faster mappings
76WORD nameToKey(const std::string &name)
77{
78 // https://msdn.microsoft.com/en-us/library/dd375731%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
79 auto length = name.length();
80 if (length == 1)
81 {
82 // direct mapping to a number or character key
83 char character = name.at(0);
84 if (character >= '0' && character <= '9')
85 {
86 return character - '0' + 0x30;
87 }
88 if (character >= 'A' && character <= 'Z')
89 {
90 return character - 'A' + 0x41;
91 }
92 if (character == '+')
93 {
94 return VK_OEM_PLUS;
95 }
96 if (character == '-')
97 {
98 return VK_OEM_MINUS;
99 }
100 if (character == ',')
101 {
102 return VK_OEM_COMMA;
103 }
104 if (character == '.')
105 {
106 return VK_OEM_PERIOD;
107 }
108 if (character == ';')
109 {
110 return VK_OEM_1;
111 }
112 if (character == '/')
113 {
114 return VK_OEM_2;
115 }
116 if (character == '`')
117 {
118 return VK_OEM_3;
119 }
120 if (character == '[')
121 {
122 return VK_OEM_4;
123 }
124 if (character == '\\')
125 {
126 return VK_OEM_5;
127 }
128 if (character == ']')
129 {
130 return VK_OEM_6;
131 }
132 if (character == '\'')
133 {

Callers 1

KeyCodeMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected