Skip to content

Commit 94efbc8

Browse files
committed
Correct test in vstinput witch Capslock pressed and Shift for capital symbols
1 parent bd74da3 commit 94efbc8

1 file changed

Lines changed: 66 additions & 17 deletions

File tree

include/vsg/platform/win32/Win32_Window.h

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace vsgWin32
5353
// Get virtual key code
5454
uint32_t virtualKey = static_cast<uint32_t>(wParam);
5555

56-
// Left and right modofier detection
56+
// Left and right modifier detection
5757
if (virtualKey == VK_SHIFT)
5858
{
5959
virtualKey = (scanCode == 0x2A) ? VK_RSHIFT : VK_LSHIFT;
@@ -101,22 +101,7 @@ namespace vsgWin32
101101
{
102102
wchar_t ch = unicodeChar[0];
103103

104-
if (ch >= L'A' && ch <= L'Z')
105-
{
106-
modifiedKeySymbol = static_cast<vsg::KeySymbol>(L'a' + (ch - L'A'));
107-
}
108-
else if (ch >= L'a' && ch <= L'z')
109-
{
110-
modifiedKeySymbol = static_cast<vsg::KeySymbol>(ch);
111-
}
112-
else if (ch >= L'0' && ch <= L'9')
113-
{
114-
modifiedKeySymbol = static_cast<vsg::KeySymbol>(ch);
115-
}
116-
else
117-
{
118-
modifiedKeySymbol = mapUnicodeToKeySymbol(ch);
119-
}
104+
modifiedKeySymbol = mapCharToKeySymbol(ch);
120105
}
121106
else
122107
{
@@ -128,6 +113,70 @@ namespace vsgWin32
128113

129114
protected:
130115

116+
vsg::KeySymbol mapCharToKeySymbol(wchar_t ch)
117+
{
118+
// Letters
119+
if (ch >= L'A' && ch <= L'Z')
120+
{
121+
return static_cast<vsg::KeySymbol>(ch); // Capital
122+
}
123+
if (ch >= L'a' && ch <= L'z')
124+
{
125+
return static_cast<vsg::KeySymbol>(ch);
126+
}
127+
128+
// Digits
129+
if (ch >= L'0' && ch <= L'9')
130+
{
131+
return static_cast<vsg::KeySymbol>(ch);
132+
}
133+
134+
// Special characters (with and without Shift)
135+
switch (ch)
136+
{
137+
case L'!': return vsg::KEY_Exclaim;
138+
case L'\"': return vsg::KEY_Quotedbl;
139+
case L'#': return vsg::KEY_Hash;
140+
case L'$': return vsg::KEY_Dollar;
141+
case L'%': return vsg::KEY_Percent;
142+
case L'&': return vsg::KEY_Ampersand;
143+
case L'\'': return vsg::KEY_Quote;
144+
case L'(': return vsg::KEY_Leftparen;
145+
case L')': return vsg::KEY_Rightparen;
146+
case L'*': return vsg::KEY_Asterisk;
147+
case L'+': return vsg::KEY_Plus;
148+
case L',': return vsg::KEY_Comma;
149+
case L'-': return vsg::KEY_Minus;
150+
case L'.': return vsg::KEY_Period;
151+
case L'/': return vsg::KEY_Slash;
152+
case L':': return vsg::KEY_Colon;
153+
case L';': return vsg::KEY_Semicolon;
154+
case L'<': return vsg::KEY_Less;
155+
case L'=': return vsg::KEY_Equals;
156+
case L'>': return vsg::KEY_Greater;
157+
case L'?': return vsg::KEY_Question;
158+
case L'@': return vsg::KEY_At;
159+
case L'[': return vsg::KEY_Leftbracket;
160+
case L'\\': return vsg::KEY_Backslash;
161+
case L']': return vsg::KEY_Rightbracket;
162+
case L'^': return vsg::KEY_Caret;
163+
case L'_': return vsg::KEY_Underscore;
164+
case L'`': return vsg::KEY_Backquote;
165+
case L'{': return vsg::KEY_Leftcurlybracket;
166+
case L'|': return vsg::KEY_Verticalslash;
167+
case L'}': return vsg::KEY_Rightcurlybracket;
168+
case L'~': return vsg::KEY_Tilde;
169+
170+
// Whitespace and control characters
171+
case L' ': return vsg::KEY_Space;
172+
case L'\t': return vsg::KEY_Tab;
173+
case L'\r': return vsg::KEY_Return;
174+
}
175+
176+
// Return for other non-ASCII
177+
return mapUnicodeToKeySymbol(ch);
178+
}
179+
131180
// Helper function for Unicode cahracters
132181
vsg::KeySymbol mapUnicodeToKeySymbol(wchar_t ch)
133182
{

0 commit comments

Comments
 (0)