MCPcopy Create free account
hub / github.com/cinder/Cinder / onKeyboard

Method onKeyboard

src/cinder/app/linux/AppImplLinuxGlfw.cpp:195–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193 }
194
195 static void onKeyboard( GLFWwindow *glfwWindow, int key, int scancode, int action, int mods ) {
196 auto iter = sWindowMapping.find( glfwWindow );
197 if( sWindowMapping.end() != iter ) {
198 auto& cinderAppImpl = iter->second.first;
199 auto& cinderWindow = iter->second.second;
200 cinderAppImpl->setWindow( cinderWindow );
201
202 int32_t nativeKeyCode = KeyEvent::translateNativeKeyCode( key );
203
204 if( glfwGetKey( glfwWindow, GLFW_KEY_CAPS_LOCK ) )
205 sCapsLockDown = ! sCapsLockDown;
206 if( glfwGetKey( glfwWindow, GLFW_KEY_NUM_LOCK ) )
207 sNumLockDown = ! sNumLockDown;
208 if( glfwGetKey( glfwWindow, GLFW_KEY_SCROLL_LOCK ) )
209 sScrollLockDown = !sScrollLockDown;
210
211 auto modifiers = extractKeyModifiers( mods );
212 char convertedChar = modifyChar( key, modifiers, sCapsLockDown );
213 uint32_t charUtf32 = convertedChar ? (uint32_t)(unsigned char)convertedChar : 0;
214
215 // Calculate KeyEvent from GLFW's parameters on both press and release
216 KeyEvent keyEvent( cinderWindow, nativeKeyCode, charUtf32, convertedChar, modifiers, scancode );
217
218 if( GLFW_PRESS == action || GLFW_REPEAT == action ) {
219 cinderWindow->emitKeyDown( &keyEvent );
220 }
221 else if( GLFW_RELEASE == action ) {
222 cinderWindow->emitKeyUp( &keyEvent );
223 }
224 }
225 }
226
227 // onCharInput removed - we now compute characters directly in onKeyboard
228

Callers

nothing calls this directly

Calls 6

glfwGetKeyFunction · 0.85
emitKeyDownMethod · 0.80
emitKeyUpMethod · 0.80
findMethod · 0.45
endMethod · 0.45
setWindowMethod · 0.45

Tested by

no test coverage detected