MCPcopy Create free account
hub / github.com/Kitware/VTK / RecoverKeyEventInformation

Function RecoverKeyEventInformation

Rendering/UI/vtkWin32RenderWindowInteractor.cxx:143–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void RecoverKeyEventInformation(
144 UINT vCode, UINT nFlags, int& ctrl, int& shift, int& alt, char& keyCode, const char*& keySym)
145{
146 RecoverModifiersStatus(ctrl, shift, alt);
147 // WORD is unsigned short
148 WORD nChar = 0;
149 WORD nCharWithoutMod = 0;
150 {
151#ifndef _WIN32_WCE
152 BYTE keyState[256];
153 GetKeyboardState(keyState);
154 if (ToAscii(vCode, nFlags & 0xff, keyState, &nChar, 0) == 0)
155 {
156 nChar = 0;
157 }
158 nCharWithoutMod = nChar;
159 if (ctrl != 0 || alt != 0)
160 {
161 // When using modifiers, recover a keyCode without modifiers
162 // except Shift in order to unsure behavior consistency with
163 // other OSes.
164 keyState[VK_CONTROL] = 0;
165 keyState[VK_MENU] = 0;
166 if (ToAscii(vCode, nFlags & 0xff, keyState, &nCharWithoutMod, 0) == 0)
167 {
168 nCharWithoutMod = 0;
169 }
170 }
171#endif
172 }
173
174 // keyCode is the modified one except when it is 0
175 // in that case, fallback on the version without modifiers
176 keyCode = static_cast<char>(nChar);
177 if (keyCode == 0)
178 {
179 keyCode = static_cast<char>(nCharWithoutMod);
180 }
181
182 // Try to recover any valid keySym
183 if (nChar < 256)
184 {
185 keySym = UnicodeToKeySymTable[nChar];
186 }
187 if (keySym == nullptr && nCharWithoutMod < 256)
188 {
189 keySym = UnicodeToKeySymTable[nCharWithoutMod];
190 }
191 if (keySym == nullptr && vCode < 256)
192 {
193 keySym = VKeyCodeToKeySymTable[vCode];
194 }
195 if (keySym == nullptr)
196 {
197 keySym = "None";
198 }
199}
200

Callers 2

OnKeyDownMethod · 0.85
OnKeyUpMethod · 0.85

Calls 1

RecoverModifiersStatusFunction · 0.85

Tested by

no test coverage detected