本文整理汇总了C++中KeyEvent::getNativeKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getNativeKeyCode方法的具体用法?C++ KeyEvent::getNativeKeyCode怎么用?C++ KeyEvent::getNativeKeyCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getNativeKeyCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyDown
void StarsApp::keyDown( KeyEvent event )
{
#ifdef WIN32
// allows the use of the media buttons on your Windows keyboard to control the music
switch( event.getNativeKeyCode() )
{
case VK_MEDIA_NEXT_TRACK:
// play next music file
playMusic( getNextFile(mMusicPath) );
return;
case VK_MEDIA_PREV_TRACK:
// play next music file
playMusic( getPrevFile(mMusicPath) );
return;
case VK_MEDIA_STOP:
stopMusic();
return;
case VK_MEDIA_PLAY_PAUSE:
if( mSoundEngine && mMusic ) {
if( mMusic->isFinished() )
playMusic( mMusicPath );
else
mMusic->setIsPaused( !mMusic->getIsPaused() );
}
return;
}
#endif
switch( event.getCode() )
{
case KeyEvent::KEY_f:
// toggle full screen
setFullScreen( !isFullScreen() );
if( !isFullScreen() )
forceShowCursor();
break;
case KeyEvent::KEY_v:
gl::enableVerticalSync( !gl::isVerticalSyncEnabled() );
break;
case KeyEvent::KEY_ESCAPE:
// quit the application
quit();
break;
case KeyEvent::KEY_SPACE:
// enable animation
mCamera.setup();
break;
case KeyEvent::KEY_g:
// toggle grid
mIsGridVisible = !mIsGridVisible;
break;
case KeyEvent::KEY_l:
// toggle labels
mIsLabelsVisible = !mIsLabelsVisible;
break;
case KeyEvent::KEY_c:
// toggle constellations
mIsConstellationsVisible = !mIsConstellationsVisible;
break;
case KeyEvent::KEY_a:
// toggle cursor arrow
if(mIsCursorVisible)
forceHideCursor();
else
forceShowCursor();
break;
case KeyEvent::KEY_s:
// toggle stereoscopic view
mIsStereoscopic = !mIsStereoscopic;
mIsCylindrical = false;
mStars.setAspectRatio( mIsStereoscopic ? 0.5f : 1.0f );
break;
case KeyEvent::KEY_d:
// cylindrical panorama
mIsCylindrical = !mIsCylindrical;
mIsStereoscopic = false;
// adjust line width
mGrid.setLineWidth( mIsCylindrical ? 3.0f : 1.5f );
mConstellations.setLineWidth( mIsCylindrical ? 2.0f : 1.0f );
break;
case KeyEvent::KEY_RETURN:
createShader();
break;
case KeyEvent::KEY_PLUS:
case KeyEvent::KEY_EQUALS:
case KeyEvent::KEY_KP_PLUS:
mCamera.setFov( mCamera.getFov() + 0.1 );
break;
case KeyEvent::KEY_MINUS:
case KeyEvent::KEY_UNDERSCORE:
case KeyEvent::KEY_KP_MINUS:
mCamera.setFov( mCamera.getFov() - 0.1 );
break;
}
}
示例2: keyDown
void StarsApp::keyDown( KeyEvent event )
{
#ifdef WIN32
// allows the use of the media buttons on your Windows keyboard to control the music
switch( event.getNativeKeyCode() )
{
case VK_MEDIA_NEXT_TRACK:
// play next music file
playMusic( getNextFile(mMusicPath) );
return;
case VK_MEDIA_PREV_TRACK:
// play next music file
playMusic( getPrevFile(mMusicPath) );
return;
case VK_MEDIA_STOP:
stopMusic();
return;
case VK_MEDIA_PLAY_PAUSE:
if( mSoundEngine && mMusic ) {
if( mMusic->isFinished() )
playMusic( mMusicPath );
else
mMusic->setIsPaused( !mMusic->getIsPaused() );
}
return;
}
#endif
switch( event.getCode() )
{
case KeyEvent::KEY_f:
// toggle full screen
setFullScreen( !isFullScreen() );
if( !isFullScreen() )
forceShowCursor();
break;
case KeyEvent::KEY_v:
gl::enableVerticalSync( !gl::isVerticalSyncEnabled() );
break;
case KeyEvent::KEY_ESCAPE:
// quit the application
quit();
break;
case KeyEvent::KEY_SPACE:
// enable animation
mCamera.setup();
break;
case KeyEvent::KEY_g:
// toggle grid
mIsGridVisible = !mIsGridVisible;
break;
case KeyEvent::KEY_l:
// toggle labels
mIsLabelsVisible = !mIsLabelsVisible;
break;
case KeyEvent::KEY_c:
// toggle constellations
mIsConstellationsVisible = !mIsConstellationsVisible;
break;
case KeyEvent::KEY_a:
// toggle cursor arrow
if(mIsCursorVisible)
forceHideCursor();
else
forceShowCursor();
break;
case KeyEvent::KEY_s:
// toggle stereoscopic view
mIsStereoscopic = !mIsStereoscopic;
mStars.setAspectRatio( mIsStereoscopic ? 0.5f : 1.0f );
break;
/*//
case KeyEvent::KEY_KP7:
mBackground.rotateX(-0.05f);
break;
case KeyEvent::KEY_KP9:
mBackground.rotateX(+0.05f);
break;
case KeyEvent::KEY_KP4:
mBackground.rotateY(-0.05f);
break;
case KeyEvent::KEY_KP6:
mBackground.rotateY(+0.05f);
break;
case KeyEvent::KEY_KP1:
mBackground.rotateZ(-0.05f);
break;
case KeyEvent::KEY_KP3:
mBackground.rotateZ(+0.05f);
break;
//*/
}
}