本文整理汇总了C++中KeyEvent::getCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getCode方法的具体用法?C++ KeyEvent::getCode怎么用?C++ KeyEvent::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyUp
void PopGameApp::keyUp(KeyEvent event)
{
if(event.getCode () == KeyEvent::KEY_UP)
{
plane->setKey(1,0);
}else if(event.getCode () == KeyEvent::KEY_DOWN)
{
plane->setKey(1,1);
}else if(event.getCode () == KeyEvent::KEY_LEFT)
{
plane->setKey(1,2);
}else if(event.getCode () == KeyEvent::KEY_RIGHT)
{
plane->setKey(1,3);
}else if(event.getCode () == KeyEvent::KEY_SPACE)
{
plane->setKey(1,4);
}
}
示例2: keyDown
void FrustumCullingApp::keyDown( KeyEvent event )
{
if( event.getChar() == 'f' ){
setFullScreen( ! isFullScreen() );
} else if( event.getChar() == '1' ){
mShapeType = SPHERE;
} else if( event.getChar() == '2' ){
mShapeType = CUBE;
} else if( event.getChar() == '3' ){
mShapeType = POINT;
} else if( event.getChar() == 'c' ){
mIsWatchingCam = ! mIsWatchingCam;
} else if( event.getChar() == '/' || event.getChar() == '?' ){
mInfoPanel.toggleState();
}
if( event.getCode() == KeyEvent::KEY_UP ){
mEyeDest += mEyeNormal * 40.0f;
} else if( event.getCode() == KeyEvent::KEY_DOWN ){
mEyeDest -= mEyeNormal * 40.0f;
}
if( event.getCode() == KeyEvent::KEY_LEFT ){
mAngleDest += 0.1f;
} else if( event.getCode() == KeyEvent::KEY_RIGHT ){
mAngleDest -= 0.1f;
}
}
示例3:
void Willard_HW02_Linked_ListApp::keyDown(KeyEvent event)
{
if(event.getCode() == KeyEvent::KEY_r){
reverseList(sentinel);
}
char yup = event.getChar();
if(yup == '/' || yup == '?')
{
if(showMenu){
showMenu = false;
} else{
showMenu = true;
}
}
if(event.getCode() == KeyEvent::KEY_SPACE){
reverseList(sentinel);
}
if(event.getCode() == KeyEvent::KEY_UP){
toTop();
}
}
示例4: if
/* The instructions say that pressing '?' should turn
the instructions on and off, so I went ahead and made
it so you can toggle the text.
-bakersc3
*/
void HW02App::keyDown(KeyEvent event)
{
if(event.getChar() == '?')//If ? is pressed, set removeText to true
{
if(removeText == true)
removeText = false;
else if(removeText == false)
removeText = true;
}
if(event.getCode() == KeyEvent::KEY_LEFT)//If left arrow key is pressed, travel to previous node
{
head = head->prev_;
}
if(event.getCode() == KeyEvent::KEY_RIGHT)
{
head = head->next_;
}
//Because of the order my nodes are drawn in, this appears to improperly reorder
//nodes in the background. It is just because my nodes are drawn in reverse order so
//the current head node always appears on top
if(event.getChar() == 'r')//If 'r' key is pressed, reverse the list
{
reverse(head);
}
}
示例5: keyDown
/*
Checks for keyboard input from the user, also moves currently selected window
*/
void RoyalSocietyApp::keyDown(KeyEvent event) {
// Matt: Added usage of the '/' key, because it's simpler to press
// one button than two!
if(event.getChar() == '?' || event.getChar() == '/')
{
if(help_)
help_ = false;
else help_ = true;
}
if(sentinel_->next_ != sentinel_)
{
// check for key input and move window accordingly
if(event.getCode() == KeyEvent::KEY_RIGHT || event.getChar() == 'd')
{
sentinel_->next_->window_->pos_.x += moveSpeed_;
}
else if(event.getCode() == KeyEvent::KEY_LEFT || event.getChar() == 'a')
{
sentinel_->next_->window_->pos_.x -= moveSpeed_;
}
else if(event.getCode() == KeyEvent::KEY_UP || event.getChar() == 'w')
{
sentinel_->next_->window_->pos_.y -= moveSpeed_;
}
else if(event.getCode() == KeyEvent::KEY_DOWN || event.getChar() == 's')
{
sentinel_->next_->window_->pos_.y += moveSpeed_;
}
}
}
示例6: keyUp
void reflection_animationApp::keyUp( KeyEvent event )
{
if (event.getCode() == KeyEvent::KEY_TAB) {
m_showInterface = !m_showInterface;
}
if (event.getCode() == KeyEvent::KEY_SPACE) {
Surface frame = copyWindowSurface();
stringstream filename;
filename << "geometry_screenshot_" << (getElapsedFrames()) << ".png";
writeImage( m_path / filename.str(), frame);
}
if (event.getCode() == KeyEvent::KEY_r) {
if (m_recording) {
m_movieWriter.finish();
}
if (!m_recording) {
stringstream filename;
filename << "geometry_animation_" << (getElapsedFrames()) << ".mov";
m_movieWriter = qtime::MovieWriter( m_path / filename.str(), getWindowWidth(), getWindowHeight() );
}
m_recording = !m_recording;
}
}
示例7: keyDown
void SamplePlayerNodeTestApp::keyDown( KeyEvent event )
{
if( event.getCode() == KeyEvent::KEY_c )
testConverter();
if( event.getCode() == KeyEvent::KEY_w )
testWrite();
if( event.getCode() == KeyEvent::KEY_s )
mSamplePlayerNode->seekToTime( 1.0 );
}
示例8: keyDown
void iosAppTestApp::keyDown( KeyEvent event )
{
std::cout << "Key: " << event.getCharUtf32() << std::endl;
if( event.getCode() == KeyEvent::KEY_BACKSPACE )
console() << "backspace!" << std::endl;
else if( event.getCode() == KeyEvent::KEY_RETURN )
console() << "return!" << std::endl;
mSecondWindowMessage = getKeyboardString();
}
示例9: PushKey
void Key_Event::PushKey(KeyEvent& key_event)
{
if (key_status->press_key.find(key_event.getCode()) == key_status->press_key.cend())
{
key_status->push_key.insert(key_event.getCode());
}
if (key_status->press_key.find(key_event.getCode()) == key_status->press_key.cend())
key_status->press_key.insert(key_event.getCode());
}
示例10: keyDown
void DeviceTestApp::keyDown( KeyEvent event )
{
TextInput *currentSelected = TextInput::getCurrentSelected();
if( ! currentSelected )
return;
if( event.getCode() == KeyEvent::KEY_RETURN ) {
#if defined( CINDER_COCOA_TOUCH )
hideKeyboard();
#endif
try {
if( currentSelected == &mSamplerateInput ) {
int sr = currentSelected->getValue();
CI_LOG_V( "updating samplerate from: " << mOutputDeviceNode->getSampleRate() << " to: " << sr );
mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().sampleRate( sr ) );
}
else if( currentSelected == &mFramesPerBlockInput ) {
int frames = currentSelected->getValue();
CI_LOG_V( "updating frames per block from: " << mOutputDeviceNode->getFramesPerBlock() << " to: " << frames );
mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().framesPerBlock( frames ) );
}
else if( currentSelected == &mNumInChannelsInput ) {
int numChannels = currentSelected->getValue();
CI_LOG_V( "updating nnm input channels from: " << mInputDeviceNode->getNumChannels() << " to: " << numChannels );
setInputDevice( mInputDeviceNode->getDevice(), numChannels );
}
else if( currentSelected == &mNumOutChannelsInput ) {
int numChannels = currentSelected->getValue();
CI_LOG_V( "updating nnm output channels from: " << mOutputDeviceNode->getNumChannels() << " to: " << numChannels );
setOutputDevice( mOutputDeviceNode->getDevice(), numChannels );
}
else if( currentSelected == &mSendChannelInput ) {
if( mTestSelector.currentSection() == "send" || mTestSelector.currentSection() == "send stereo" )
setupTest( mTestSelector.currentSection() );
}
else
CI_LOG_E( "unhandled return for string: " << currentSelected->mInputString );
}
catch( audio::AudioDeviceExc &exc ) {
CI_LOG_E( "AudioDeviceExc caught, what: " << exc.what() );
auto ctx = audio::master();
mSamplerateInput.setValue( ctx->getSampleRate() );
mFramesPerBlockInput.setValue( ctx->getFramesPerBlock() );
return;
}
}
else {
if( event.getCode() == KeyEvent::KEY_BACKSPACE )
currentSelected->processBackspace();
else {
currentSelected->processChar( event.getChar() );
}
}
}
示例11: keyDown
void SimplePlaybackApp::keyDown(KeyEvent evt)
{
if (evt.getCode() == KeyEvent::KEY_SPACE)
{
moviePlayer->pause();
}
else if (evt.getCode() == KeyEvent::KEY_q)
{
quit();
}
}
示例12: keyUp
void LooperApp::keyUp(KeyEvent event)
{
if (event.getCode() == KeyEvent::KEY_SPACE)
{
loop->toggleRecord();
}
if (event.getCode() == KeyEvent::KEY_RETURN)
{
loop->clear();
}
}
示例13: keyDown
void CinderProjectionTestApp::keyDown( KeyEvent event )
{
switch (event.getCode()) {
case KeyEvent::KEY_1:
case KeyEvent::KEY_2:
case KeyEvent::KEY_3:
mActiveCam = event.getCode() - KeyEvent::KEY_1;
break;
default:
break;
}
}
示例14: keyUp
void AvalancheApp::keyUp( KeyEvent event )
{
if(event.getCode()==KeyEvent::KEY_RIGHT){
player.setRight(false);
}
if(event.getCode()==KeyEvent::KEY_LEFT){
player.setLeft(false);
}
if(event.getCode()==KeyEvent::KEY_UP){
player.setJump(false);
}
}
示例15: keyDown
void CinderBoxFunApp::keyDown(KeyEvent event)
{
// Cast the mouse position to a constant
ConstVec pos = mLastMousePos;
if (event.getCode() == KeyEvent::KEY_b) {
addBox(pos);
} else if (event.getCode() == KeyEvent::KEY_c) {
addCircle(pos);
} else if (event.getCode() == KeyEvent::KEY_t) {
addTriangle(pos);
}
}