void CircleCropExample::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getCode() == KeyEvent::KEY_d){
		moveCamera(ci::vec3(1.0f, 0.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_a){
		moveCamera(ci::vec3(-1.0f, 0.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_w){
		moveCamera(ci::vec3(0.0f, -1.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_s){
		moveCamera(ci::vec3(0.0f, 1.0f, 0.0f));
	} else if(event.getCode() == KeyEvent::KEY_RIGHTBRACKET){
		moveCamera(ci::vec3(0.0f, 0.0f, 1.0f));
	} else if(event.getCode() == KeyEvent::KEY_LEFTBRACKET){
		moveCamera(ci::vec3(0.0f, 0.0f, -1.0f));
	} else if(event.getCode() == KeyEvent::KEY_EQUALS){
		ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
		p.mFarPlane += 1.0f;
		std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
		mEngine.setPerspectiveCamera(1, p);
	} else if(event.getCode() == KeyEvent::KEY_MINUS){
		ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
		p.mFarPlane -= 1.0f;
		std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
		mEngine.setPerspectiveCamera(1, p);
	} else if(event.getCode() == KeyEvent::KEY_c){
		if(mShaderCircleCrop){
			mShaderCircleCrop->setCircleCrop(!mShaderCircleCrop->getCircleCrop());
		}
	}
}
void PanoramicVideo::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();

	// Shows all enabled sprites with a label for class type
	} else if(event.getCode() == KeyEvent::KEY_f){

		const int numRoots = mEngine.getRootCount();
		int numPlacemats = 0;
		for(int i = 0; i < numRoots - 1; i++){
			mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
				if(sprite.isEnabled()){
					sprite.setTransparent(false);
					sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
					sprite.setOpacity(0.95f);

					ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
					labelly->setText(typeid(sprite).name());
					labelly->enable(false);
					labelly->setColor(ci::Color::black());
				} else {

					ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
					if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
				}
			}, true);
		}
	}
}
Esempio n. 3
0
	void ViewController::keyDown(ci::app::KeyEvent &event)
	{
		//  convert char to int
		int selectedInt = event.getChar() - '0';
		if (selectedInt < 0 || selectedInt > mIndicatorNames.size() - 1)
		{
			return;
		}

		activateIndicator(selectedInt);

		switch (event.getChar()) {
		case '0':
			mShapeView->setAlignment(po::scene::Alignment::NONE);
			break;

		case '1':
			mShapeView->setAlignment(po::scene::Alignment::TOP_LEFT);
			break;

		case '2':
			mShapeView->setAlignment(po::scene::Alignment::TOP_CENTER);
			break;

		case '3':
			mShapeView->setAlignment(po::scene::Alignment::TOP_RIGHT);
			break;

		case '4':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_LEFT);
			break;

		case '5':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_CENTER);
			break;

		case '6':
			mShapeView->setAlignment(po::scene::Alignment::CENTER_RIGHT);
			break;

		case '7':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_LEFT);
			break;

		case '8':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_CENTER);
			break;

		case '9':
			mShapeView->setAlignment(po::scene::Alignment::BOTTOM_RIGHT);
			break;

		default:
			break;
		}
	}
void XmlSettingsSetting::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getCode() == KeyEvent::KEY_x){
		if(mSettings){
			mSettings->toggleVisibility();
		}
	}
}
Esempio n. 5
0
void PretzelRoot::onKeyDown(ci::app::KeyEvent &event)
{
    mGuiList[0]->keyDown( event.getChar(), event.getCode() );
    
//    for( auto it = mGuiList.begin(); it!=mGuiList.end(); ++it){
//        PretzelGui *pg = *it;
//        
//        if( pg->getGlobalBounds().contains( event.getPos() ) ){
//            (*it)->keyDown( event.getChar(), event.getCode() );
//        }
//    }
}
Esempio n. 6
0
    // TODO: Fix this memory leak from new Link(...)
    bool ChatNode::keyDown(ci::app::KeyEvent event) {
        if (event.getCode() == ci::app::KeyEvent::KEY_RETURN) {
            if (active_node_identity_ != NULL && 
                active_node_identity_->object() != NULL) {
                // Finish updating by sending finished flag and deactivate
                ChatMessageNode::request_finish_update(*active_node_identity_, 
                    text_buffer_);

                active_node_ = NULL;
                text_buffer_.clear();
                active_node_identity_ = NULL;
            }
        } else {
            text_buffer_ += event.getChar();
            unsent_chars_ = true;

            if (active_node_identity_ == NULL) {
                // Request create a node, but make sure to update it
                TeteManager::instance() += ObjectController::instance()[id()];
                ID create_id_ = Utility::create_uuid();
                active_node_identity_ = Identity::create_identity(create_id_, NULL);

                LinkPtr user_link(new Link(&(Client::user_identity()),
                    LinkFlags(true, true, true)));
                
                std::deque<LinkPtr> temp_links;
                temp_links.push_back(user_link);

                if (!chat_messages_.empty()) {
                    const Identity* last_ident = Identity::get_identity_from_id(
                        chat_messages_.back()->id());
                    LinkPtr last_msg_link(new Link(last_ident, LinkFlags(true, true)));
                    temp_links.push_back(last_msg_link);
                }

                ChatMessageNode::request_create(create_id_,
                    *identity(), text_buffer_, temp_links);
            } else if (active_node_identity_ != NULL && 
                active_node_identity_->object() != NULL) {
                // Update the current node, and send an update request
                ChatMessageNode::request_update_text(*active_node_identity_,
                    text_buffer_);
                unsent_chars_ = false;
            }
        }

        return false;
    }
Esempio n. 7
0
bool Control::getIsBindedToModifier( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() && mKeyModifier == app::KeyEvent::META_DOWN )
    {
        return true;
    }
    else if ( event.isAltDown() && mKeyModifier == app::KeyEvent::ALT_DOWN )
    {
        return true;
    }
    else if( event.isControlDown() && mKeyModifier == app::KeyEvent::CTRL_DOWN )
    {
        return true;
    }
    return false;
}
Esempio n. 8
0
void XYPad::keyDown( ci::app::KeyEvent &event )
{
    if( event.isShiftDown() )
    {
        mStickyEnabled = true;
    }
}
Esempio n. 9
0
void ShadowMapSample::keyDown( ci::app::KeyEvent event )
{
	switch( event.getChar() ) {
		case ' ' :
			mPaused = ! mPaused;
		break;
		case 'r': { // create a random camera position
			vec3 eyeVec = Rand::randVec3f().normalized() * 6.0f;
			if( eyeVec.y < 0 ) eyeVec.y = -eyeVec.y;
			mCamera->lookAt( eyeVec, vec3(0,-2.5,0) );
			mLight->update( *mCamera );
		}
		break;
		case 'f':
			setFullScreen( ! isFullScreen() );
		break;
		case 'l': { // create a random light position
			vec3 lightPos = Rand::randVec3f().normalized() * 4.0f;
			if( lightPos.y < 0 ) lightPos.y = -lightPos.y;			
			mLight->lookAt( lightPos, vec3::zero() );
			mLight->update( *mCamera );
		}
		break;
		case 'c':
			mLookThroughCamera = ! mLookThroughCamera;
		break;
		case 'd':
			mDrawDepthMap = ! mDrawDepthMap;
		break;
	}
}
void GesturesDemo::keyDown(ci::app::KeyEvent event) {
  char key = event.getChar();
  if (key == 27) { //ESC
    exit(0);
  }
  else if (key == 'f') {
    setFullScreen(!isFullScreen());
  }
}
Esempio n. 11
0
void EditorState::keyDown(ci::app::KeyEvent event)
{
    // XXX duplicate raycast
    Vec2f pos = GG.mouse.getPos();
    Vec3f planeHit = GG.hexRender.raycastHexPlane(pos.x, pos.y);
    HexCoord selectedHex = GG.hexGrid.WorldToHex(planeHit);

    int keycode = event.getCode();

    Vec3f& cameraTo = GG.hexRender.getCameraTo();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_UP) {
        cameraTo += Vec3f(0, 2.0f, 0);
    }
    else if (keycode == app::KeyEvent::KEY_DOWN) {
        cameraTo += Vec3f(0, -2.0f, 0);
    }   
    else if (keycode == app::KeyEvent::KEY_LEFT) {
        cameraTo += Vec3f(-2.0f, 0, 0);
    }
    else if (keycode == app::KeyEvent::KEY_RIGHT) {
        cameraTo += Vec3f(2.0f, 0, 0);
    }
    else if (keycode == app::KeyEvent::KEY_g) {
        //  Generate hex colors
        Vec2i mapSize = GG.hexMap.getSize();
        for (int iy=0; iy < mapSize.y; ++iy) {
            for (int ix=0; ix < mapSize.x; ++ix) {
                HexCell& cell = GG.hexMap.at(HexCoord(ix, iy));
                if (cell.getLand()) {
                    int playerID = random.nextInt(0, 5);
                    cell.setOwner(playerID);
                    cell.setColor(GG.warGame.getPlayers()[playerID].getColor());
                }
            }
        }
    }
    else if (keycode == app::KeyEvent::KEY_DELETE) {
        GG.hexMap.at(selectedHex).setLand(0);
    }
    else if (keycode == app::KeyEvent::KEY_SPACE) {
        mManager.setActiveState(string("game"));
    }
    else if (keycode == app::KeyEvent::KEY_c) {
        vector<HexCoord> connected = GG.hexMap.connected(selectedHex);
        for (vector<HexCoord>::iterator it = connected.begin(); it != connected.end(); ++it) {
            HexCell& cell = GG.hexMap.at(*it);
            Color cellColor = cell.getColor();
            cellColor.r = 0.5f * cellColor.r;
            cellColor.g = 0.5f * cellColor.g;
            cellColor.b = 0.5f * cellColor.b;
            cell.setColor(cellColor);
        }
    }
}
void ImGui_ImplCinder_KeyCallback(ci::app::KeyEvent e, bool isDown)
{
    ImGuiIO& io = ImGui::GetIO();
    
    io.KeysDown[e.getCode()] = isDown;

    io.KeyCtrl = io.KeysDown[ci::app::KeyEvent::KEY_LCTRL] || io.KeysDown[ci::app::KeyEvent::KEY_RCTRL];
    io.KeyShift = io.KeysDown[ci::app::KeyEvent::KEY_LSHIFT] || io.KeysDown[ci::app::KeyEvent::KEY_RSHIFT];
    io.KeyAlt = io.KeysDown[ci::app::KeyEvent::KEY_LALT] || io.KeysDown[ci::app::KeyEvent::KEY_RALT];
}
Esempio n. 13
0
void https_example::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);
	if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();

	} else if(event.getCode() == KeyEvent::KEY_v && event.isControlDown()){
		auto fileNameOrig = ds::Environment::getClipboard();
		mHttpsRequest.makeGetRequest("https://example.com", false, false);


	} else if(event.getCode() == KeyEvent::KEY_p){
		std::string datay = "{ \"data\": { \"type\": \"collection_links\", \"attributes\": { \"story_type\": \"Achievement\", \"story_id\": \"13\" }}}";
		std::vector<std::string> headers;
		headers.push_back("Accept: application/json");
		headers.push_back("Content-Type: application/json");
		mHttpsRequest.makePostRequest("https://example.com", datay, true, true, "", headers);

	// Shows all enabled sprites with a label for class type
	} else if(event.getCode() == KeyEvent::KEY_f){

		const int numRoots = mEngine.getRootCount();
		int numPlacemats = 0;
		for(int i = 0; i < numRoots - 1; i++){
			mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
				if(sprite.isEnabled()){
					sprite.setTransparent(false);
					sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
					sprite.setOpacity(0.95f);

					ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
					labelly->setText(typeid(sprite).name());
					labelly->enable(false);
					labelly->setColor(ci::Color::black());
				} else {

					ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
					if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
				}
			}, true);
		}
	}
}
Esempio n. 14
0
//----------------------------------------------------------------------------------------------------------------------
void GAViz::onKeyPress(ci::app::KeyEvent e)
{
  const uint8_t numModes = 2;
  switch(e.getChar())
  {
  case 'n':
    m_mode = (m_mode + 1) % numModes;
    break;
  }
  
  NodeGroup::onKeyPress(e);
}
Esempio n. 15
0
void redEyeApp::keyDown(ci::app::KeyEvent event) {
	if(event.getChar()=='i') {
        mHide= !mHide;
    } else if(event.getCode()==KeyEvent::KEY_ESCAPE) {
        setFullScreen(!isFullScreen());
    } else if(event.getChar()=='f') {
        fs::path path= getOpenFilePath(mPathFrag);
        if(!path.empty()) {
			mPathFrag= path;
            loadShader();
		}
    } else if(event.getChar()=='v') {
        fs::path path= getOpenFilePath(mPathVert);
		if(!path.empty()) {
			mPathVert= path;
            loadShader();
		}
    } else if(event.getChar()=='m') {
        mMode= (mMode+1)%9;
    }
}
Esempio n. 16
0
void web_example::keyDown(ci::app::KeyEvent event){
	using ci::app::KeyEvent;
	inherited::keyDown(event);

	if(event.getChar() == KeyEvent::KEY_v && event.isControlDown()){
		auto clipboard = ds::Environment::getClipboard();
		if(!clipboard.empty() && mWebView){
			mWebView->setUrl(clipboard);
		}
	} else if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
		setupServer();
	} else if(event.getChar() == KeyEvent::KEY_b){
		if(mWebView){
			mWebView->goBack();
		}
	} else if(event.getChar() == KeyEvent::KEY_f){
		if(mWebView){
			mWebView->goForward();
		}
	} else if(event.getChar() == KeyEvent::KEY_l){
		if(mWebView){
			mWebView->reload();
		}
	}
}
Esempio n. 17
0
void ClientState::keyDown(ci::app::KeyEvent event)
{
    // Vec3f& cameraTo = GG.hexRender.getCameraTo();

    int keycode = event.getCode();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
        // XXX should push console to the top of the gui widget list
        GG.gui.attach(GG.console);
    }
}
Esempio n. 18
0
bool Control::getIsModifierDown( ci::app::KeyEvent &event )
{
    if( event.isMetaDown() )
    {
        return true;
    }
    else if ( event.isAltDown() )
    {
        return true;
    }
    else if( event.isControlDown() )
    {
        return true;
    }
    else if( event.isShiftDown() )
    {
        return true;
    }
    else if( event.isAccelDown() )
    {
        return true;
    }
    return false;
}
Esempio n. 19
0
void ServerState::keyDown(ci::app::KeyEvent event)
{
    static int count = 0;
    ++count;

    // Vec3f& cameraTo = GG.hexRender.getCameraTo();
    io::stream<GuiConsoleStream> cout = GG.console->output();

    int keycode = event.getCode();
    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
        // XXX should push console to the top of the gui widget list
        GG.gui.attach(GG.console);
    }
    else if (keycode == app::KeyEvent::KEY_SPACE) {
        cout << "That's what I said: " << count << std::endl;
    }
}
Esempio n. 20
0
bool Control::isBindedToKeyEvent( ci::app::KeyEvent &event )
{
    bool useModifier = ( mKeyModifier != -1 ) ? true : false;
    bool modDown = getIsModifierDown( event );
    bool isBindedToMod = getIsBindedToModifier( event );
    bool isBindedToKey = getIsBindedToKey( event.getCode() );

    if( isBindedToKey )
    {
        if( isBindedToMod )
        {
            return true;
        }
        else if( !modDown && !useModifier )
        {
            return true;
        }
    }
    return false;
}
Esempio n. 21
0
// ------------------------------------------------------------------------------------------------
void VisualsApp::keyDown(ci::app::KeyEvent event) {
    if (event.getCode() == 27) quit(); // quit on escape
}
Esempio n. 22
0
bool gen::Input::KeyUp(ci::app::KeyEvent event)
{
    switch (event.getCode())
    {
        case MOVE_UP_P1:
            g_pInputP1->m_keyState.MOVE_UP_STATE = false;
            g_pInputP1->FlyOff();
            break;

        case MOVE_LEFT_P1:
            g_pInputP1->m_keyState.MOVE_LEFT_STATE = false;
            if (g_pInputP1->m_keyState.MOVE_RIGHT_STATE == false)
            {
                g_pInputP1->m_pPlayer->m_pPhysicsData->m_pBtRigidBody->setAngularVelocity(btVector3(0,0,0));
            }
            break;

        case MOVE_RIGHT_P1:
            g_pInputP1->m_keyState.MOVE_RIGHT_STATE = false;
            if (g_pInputP1->m_keyState.MOVE_LEFT_STATE == false)
            {
                g_pInputP1->m_pPlayer->m_pPhysicsData->m_pBtRigidBody->setAngularVelocity(btVector3(0,0,0));
            }
            break;

        case SHOOT_P1:
            g_pInputP1->m_keyState.SHOOT_STATE = false;
            break;

        case MOVE_UP_P2:
            g_pInputP2->m_keyState.MOVE_UP_STATE = false;
            g_pInputP2->FlyOff();
            break;

        case MOVE_LEFT_P2:
            g_pInputP2->m_keyState.MOVE_LEFT_STATE = false;
            if (g_pInputP2->m_keyState.MOVE_RIGHT_STATE == false)
            {
                g_pInputP2->m_pPlayer->m_pPhysicsData->m_pBtRigidBody->setAngularVelocity(btVector3(0,0,0));
            }
            break;

        case MOVE_RIGHT_P2:
            g_pInputP2->m_keyState.MOVE_RIGHT_STATE = false;
            if (g_pInputP2->m_keyState.MOVE_LEFT_STATE == false)
            {
                g_pInputP2->m_pPlayer->m_pPhysicsData->m_pBtRigidBody->setAngularVelocity(btVector3(0,0,0));
            }
            break;

        case SHOOT_P2:
            g_pInputP2->m_keyState.SHOOT_STATE = false;
            break;

        default:
            return false;   // the input was not handled
            break;
    }

    return true;
}
Esempio n. 23
0
bool gen::Input::KeyDown(ci::app::KeyEvent event)
{
    switch (event.getCode())
    {
#ifdef _DEBUG
        case TOGGLE_STATS:
            g_pObjectManager->m_displayStats = !g_pObjectManager->m_displayStats;
            break;

        case TOGGLE_WIREFRAME:
            g_pObjectManager->m_wireframe = !g_pObjectManager->m_wireframe;
            break;

        case ADVANCE_GAME_STATE:
            switch (g_pObjectManager->m_gameState)
            {
                case TITLE:
                    g_pObjectManager->m_gameState = READY;
                    break;
                case READY:
                    g_pObjectManager->m_gameState = PLAYING;
                    break;
                case PLAYING:
                    g_pObjectManager->m_gameState = P1_WINS;
                    break;
                case P1_WINS:
                    g_pObjectManager->m_gameState = P2_WINS;
                    break;
                case P2_WINS:
                    g_pObjectManager->m_gameState = P3_WINS;
                    break;
                case P3_WINS:
                    g_pObjectManager->m_gameState = P4_WINS;
                    break;
                case P4_WINS:
                    g_pObjectManager->m_gameState = READY;
                    break;
                default:
                    break;
            }
            break;
#endif
        case TOGGLE_FULLSCREEN:
            g_pObjectManager->m_fullscreen = !g_pObjectManager->m_fullscreen;
            g_pApp->setFullScreen(g_pObjectManager->m_fullscreen);
            g_pObjectManager->m_fbo = gl::Fbo(g_pApp->getWindowWidth()*ci::app::getWindow()->getContentScale(),
                                              g_pApp->getWindowHeight()*ci::app::getWindow()->getContentScale(),
                                              g_pObjectManager->m_fboFormat);
            break;

        case TOGGLE_GUI:
            g_pObjectManager->m_displayGui = !g_pObjectManager->m_displayGui;
            break;

        case SHOOT_P1:
            if (!g_pInputP1->m_keyState.SHOOT_STATE)
            {
                g_pInputP1->Shoot();
                g_pInputP1->m_keyState.SHOOT_STATE = true;
            }
            break;

        case MOVE_UP_P1:
            if (g_pInputP1->m_keyState.MOVE_UP_STATE == false)
            {
                g_pInputP1->Fly();
            }
            g_pInputP1->m_keyState.MOVE_UP_STATE = true;
            break;

        case MOVE_LEFT_P1:
            g_pInputP1->m_keyState.MOVE_LEFT_STATE = true;
            g_pInputP1->m_keyState.MOVE_RIGHT_STATE = false;
            break;

        case MOVE_RIGHT_P1:
            g_pInputP1->m_keyState.MOVE_RIGHT_STATE = true;
            g_pInputP1->m_keyState.MOVE_LEFT_STATE = false;
            break;

        case SHOOT_P2:
            if (!g_pInputP2->m_keyState.SHOOT_STATE)
            {
                g_pInputP2->Shoot();
                g_pInputP2->m_keyState.SHOOT_STATE = true;
            }
            break;

        case MOVE_UP_P2:
            if (g_pInputP2->m_keyState.MOVE_UP_STATE == false)
            {
                g_pInputP2->Fly();
            }
            g_pInputP2->m_keyState.MOVE_UP_STATE = true;
            break;

        case MOVE_LEFT_P2:
            g_pInputP2->m_keyState.MOVE_LEFT_STATE = true;
            g_pInputP2->m_keyState.MOVE_RIGHT_STATE = false;
            break;

        case MOVE_RIGHT_P2:
            g_pInputP2->m_keyState.MOVE_RIGHT_STATE = true;
            g_pInputP2->m_keyState.MOVE_LEFT_STATE = false;
            break;

        case RESTART:
            if (g_pObjectManager->m_gameState == READY)
            {
                g_pObjectManager->Restart();
            }
            break;

        case ci::app::KeyEvent::KEY_ESCAPE:
            g_pObjectManager->m_gameState = CREDITS;
            break;

        default:
            return false;   // the input was not handled
            break;
    }

    return true;    // the input was handled
}
Esempio n. 24
0
void App::keyUp(const ci::app::KeyEvent Event)
{
    for (auto&& listener : m_InputListeners) {
        listener->OnKeyUp(Event.getCode(), Event);
    }
}
void RibbonPaint::keyDown( ci::app::KeyEvent event )
{
    if(_state != kStateNormal) return;

    char keyPressed = event.getChar();
    int colorMode;
    switch (keyPressed)
    {
    case 's':
        saveOutBrushImageAndParameters();
        break;
    case 'o':
        _drawParams = !_drawParams;
        _params.show( !_params.isVisible() );
        break;
    case 'r':
        randomizeBrush();
        break;
    case 'm':
        createBrush();
        break;
    case 'g':
        _glitchSegment = !_glitchSegment;
        break;
    case 'l':
        _useBezier = !_useBezier;
    case 'p':
        _drawPins = !_drawPins;
        break;
    case '1': // COLORMODE_HSV
    case '2': // COLORMODE_RGB
    case '3': // COLORMODE_RGBINVERSE
    case '4': // COLORMODE_RGB_B
    case '5': // COLORMODE_RGB_C
    case '6': // COLORMODE_GRAYSCALE
    case '7': // COLORMODE_ALPHABLEND_1
    case '8': // COLORMODE_ALPHABLEND_2
        colorMode = boost::lexical_cast<int>( keyPressed );
        toggleAdditiveBlending( colorMode < COLORMODE_GRAYSCALE);
        _colorMode = colorMode;
        break;
    default:
        console() << keyPressed << std::endl;
        break;
    }

    // slowdown or speed up how fast our object chases the mouse - clamp addition of speed (determined by ternary operator)
    if(event.getCode() == ci::app::KeyEvent::KEY_LEFT || event.getCode() == ci::app::KeyEvent::KEY_RIGHT) {
        if(event.getCode() == ci::app::KeyEvent::KEY_LEFT)
            _mouseChaseDamping -= 0.02;
        else if(event.getCode() == ci::app::KeyEvent::KEY_RIGHT)
            _mouseChaseDamping += 0.02;

        _mouseChaseDamping = ci::math<float>::clamp(_mouseChaseDamping, 0.02, 1.0);
        updateParams();
    }

    if(event.getCode() == ci::app::KeyEvent::KEY_UP || event.getCode() == ci::app::KeyEvent::KEY_DOWN)
    {
        _alphaWhenDrawing = ci::math<double>::clamp(_alphaWhenDrawing + ((event.getCode() == ci::app::KeyEvent::KEY_UP) ? 0.005 : -0.005), 0.0, 1.0);
        updateParams();
    }

    // exit fullscreen with escape, and toggle with F
    if ( event.getChar() == 'f' || (isFullScreen() && event.getCode() == ci::app::KeyEvent::KEY_ESCAPE) )
    {
        ci::gl::clear(_clearColor);
        setFullScreen( !isFullScreen() );
    }
}
void ImGui_ImplCinder_CharCallback(ci::app::KeyEvent e)
{
    ImGuiIO& io = ImGui::GetIO();
    if (e.getCharUtf32() > 0 && e.getCharUtf32() < 0x10000)
        io.AddInputCharacter((unsigned short)e.getCharUtf32());
}
void ShapeTextureSample::keyDown(ci::app::KeyEvent &event)
{
    switch (event.getChar()) {
        case '0':
            mCurrentFitType = TextureFit::Type::NONE;
            activateFitIndicator(0);
            break;
            
        case '1':
            mCurrentFitType = TextureFit::Type::EXACT;
            activateFitIndicator(1);
            break;
            
        case '2':
            mCurrentFitType = TextureFit::Type::WIDTH;
            activateFitIndicator(2);
            break;
            
        case '3':
            mCurrentFitType = TextureFit::Type::HEIGHT;
            activateFitIndicator(3);
            break;
            
        case '4':
            mCurrentFitType = TextureFit::Type::INSIDE;
            activateFitIndicator(4);
            break;
            
        case 'O':
        case 'o':
            mCurrentAlignment = Alignment::NONE;
            activateAlignmentIndicator(0);
            break;
            
        case 'Q':
        case 'q':
            mCurrentAlignment = Alignment::TOP_LEFT;
            activateAlignmentIndicator(1);
            break;
            
        case 'A':
        case 'a':
            mCurrentAlignment = Alignment::CENTER_LEFT;
            activateAlignmentIndicator(2);
            break;
            
        case 'Z':
        case 'z':
            mCurrentAlignment = Alignment::BOTTOM_LEFT;
            activateAlignmentIndicator(3);
            break;
            
        case 'W':
        case 'w':
            mCurrentAlignment = Alignment::TOP_CENTER;
            activateAlignmentIndicator(4);
            break;
            
        case 'S':
        case 's':
            mCurrentAlignment = Alignment::CENTER_CENTER;
            activateAlignmentIndicator(5);
            break;
            
        case 'X':
        case 'x':
            mCurrentAlignment = Alignment::BOTTOM_CENTER;
            activateAlignmentIndicator(6);
            break;
            
        case 'E':
        case 'e':
            mCurrentAlignment = Alignment::TOP_RIGHT;
            activateAlignmentIndicator(7);
            break;
            
        case 'D':
        case 'd':
            mCurrentAlignment = Alignment::CENTER_RIGHT;
            activateAlignmentIndicator(8);
            break;
            
        case 'C':
        case 'c':
            mCurrentAlignment = Alignment::BOTTOM_RIGHT;
            activateAlignmentIndicator(9);
            break;
            
        default:
            break;
    }
    
    //  reset all the shapes
    mRectShape->setTexture(mTexture, mCurrentFitType, mCurrentAlignment);
    mEllipseShape->setTexture(mTexture, mCurrentFitType, mCurrentAlignment);
    mTriangleShape->setTexture(mTexture, mCurrentFitType, mCurrentAlignment);
    
}
void HelloWorldApp::keyDown( ci::app::KeyEvent event ) {
    if( event.getChar() == ci::app::KeyEvent::KEY_q )
        quit();
}
Esempio n. 29
0
	virtual void onKeyUp(ci::app::KeyEvent &e) {
		if ( e.getCode() == ci::app::KeyEvent::KEY_SPACE && state != In  ) {
			state = Out;
		}
	}
Esempio n. 30
0
void TextInput::keyDown( ci::app::KeyEvent &event )
{
	if( mClicked ) {
		if( event.getCode() == KeyEvent::KEY_v && event.isMetaDown() ) {
			if( Clipboard::hasString() ) {
				setValue( Clipboard::getString() );
				if( (int)mTrigger & (int)Trigger::CHANGE ) {
					trigger();
				}
			}
		}
		else {
			switch( event.getCode() ) {
			case KeyEvent::KEY_RIGHT: {
				if( mCursorPosition == mMaxDisplayLength && (int)mValue.substr( mStartIndex ).length() > mMaxDisplayLength ) {
					mStartIndex++;
					mDisplayValue = mValue.substr( mStartIndex, mMaxDisplayLength );
					mLabelRef->setLabel( mDisplayValue );
				}
				else if( mCursorPosition < (int)mDisplayValue.length() ) {
					mCursorPosition = mCursorPosition + 1;
				}
				setNeedsDisplay();
			} break;

			case KeyEvent::KEY_LEFT: {
				if( mCursorPosition == 0 && mStartIndex > 0 ) {
					mStartIndex--;
					mDisplayValue = mValue.substr( mStartIndex, mMaxDisplayLength );
					mLabelRef->setLabel( mDisplayValue );
				}
				else {
					mCursorPosition = mCursorPosition > 0 ? mCursorPosition - 1 : mCursorPosition;
				}
				setNeedsDisplay();
			} break;

			case KeyEvent::KEY_DELETE:
			case KeyEvent::KEY_BACKSPACE: {
				deleteCharacter();
			} break;

			case KeyEvent::KEY_UNKNOWN:
			case KeyEvent::KEY_TAB:
			case KeyEvent::KEY_CLEAR:
			case KeyEvent::KEY_KP0:
			case KeyEvent::KEY_KP1:
			case KeyEvent::KEY_KP2:
			case KeyEvent::KEY_KP3:
			case KeyEvent::KEY_KP4:
			case KeyEvent::KEY_KP5:
			case KeyEvent::KEY_KP6:
			case KeyEvent::KEY_KP7:
			case KeyEvent::KEY_KP8:
			case KeyEvent::KEY_KP9:
			case KeyEvent::KEY_KP_DIVIDE:
			case KeyEvent::KEY_KP_MULTIPLY:
			case KeyEvent::KEY_KP_PLUS:
			case KeyEvent::KEY_KP_EQUALS:
			case KeyEvent::KEY_UP:
			case KeyEvent::KEY_DOWN:
			case KeyEvent::KEY_INSERT:
			case KeyEvent::KEY_HOME:
			case KeyEvent::KEY_END:
			case KeyEvent::KEY_PAGEUP:
			case KeyEvent::KEY_PAGEDOWN:
			case KeyEvent::KEY_F1:
			case KeyEvent::KEY_F2:
			case KeyEvent::KEY_F3:
			case KeyEvent::KEY_F4:
			case KeyEvent::KEY_F5:
			case KeyEvent::KEY_F6:
			case KeyEvent::KEY_F7:
			case KeyEvent::KEY_F8:
			case KeyEvent::KEY_F9:
			case KeyEvent::KEY_F10:
			case KeyEvent::KEY_F11:
			case KeyEvent::KEY_F12:
			case KeyEvent::KEY_F13:
			case KeyEvent::KEY_F14:
			case KeyEvent::KEY_F15:
			case KeyEvent::KEY_NUMLOCK:
			case KeyEvent::KEY_CAPSLOCK:
			case KeyEvent::KEY_SCROLLOCK:
			case KeyEvent::KEY_RSHIFT:
			case KeyEvent::KEY_LSHIFT:
			case KeyEvent::KEY_RCTRL:
			case KeyEvent::KEY_LCTRL:
			case KeyEvent::KEY_RALT:
			case KeyEvent::KEY_LALT:
			case KeyEvent::KEY_RMETA:
			case KeyEvent::KEY_LMETA:
			case KeyEvent::KEY_LSUPER:
			case KeyEvent::KEY_RSUPER:
			case KeyEvent::KEY_MODE:
			case KeyEvent::KEY_COMPOSE:
			case KeyEvent::KEY_HELP:
			case KeyEvent::KEY_PRINT:
			case KeyEvent::KEY_SYSREQ:
			case KeyEvent::KEY_BREAK:
			case KeyEvent::KEY_MENU:
			case KeyEvent::KEY_POWER:
			case KeyEvent::KEY_EURO:
			case KeyEvent::KEY_UNDO:
				break;

			case KeyEvent::KEY_KP_ENTER:
			case KeyEvent::KEY_RETURN: {
				mClicked = false;
				if( (int)mTrigger & (int)Trigger::END ) {
					trigger();
					setNeedsDisplay();
				}
				if( mFormat.mAutoClear ) {
					setValue( "" );
				}
			} break;

			default: {
				if( mFormat.mNumeric ) {
					if( event.getChar() == '-' && mValue.length() == 0 ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
					else if( event.getChar() == '.' && mValue.find( "." ) == string::npos ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
					else if( isdigit( event.getChar() ) ) {
						insertCharacter( string( 1, event.getChar() ) );
					}
				}
				else {
					insertCharacter( string( 1, event.getChar() ) );
				}
			} break;
			}
		}
	}
}