Пример #1
0
void PageComponent::base_specialKeyDown( int inKeyCode ){
    for( int i=0; i<mComponents.size(); i++ ) {
        PageComponent *c = *( mComponents.getElement( i ) );
    
        if( c->isVisible() && c->isActive() ) {
            c->base_specialKeyDown( inKeyCode );
            }
        }

    specialKeyDown( inKeyCode );
    }
Пример #2
0
/*
================================
Input::poll

Polls for all queued SDL input events
and writes keyboard input to the input sets.

This function sits outside the unfocus/pause guard in Engine::run,
since we always need to check for SDL_Event SDL_QUIT.

NOTE: Since all inputs are clocked even when the game is paused,
all "held" inputs will be broken by unfocus pausing.
================================
*/
void Input::poll()
{
	is1.clock();
	is2.clock();

	SDL_Event event;
	while ( SDL_PollEvent( &event ) ) {
	switch ( event.type )
	{
		case SDL_KEYDOWN: {
			SDLKey sym = event.key.keysym.sym;
			std::map < SDLKey, InputKey >::iterator kmi;
			if ( (kmi = keymap1.find(sym)) != keymap1.end() ) {
				is1.set( kmi->second, true );
			}
			if ( (kmi = keymap2.find(sym)) != keymap2.end() ) {
				is2.set( kmi->second, true );
			}
			specialKeyDown( sym );
		}
		break;

		case SDL_KEYUP: {
			SDLKey sym = event.key.keysym.sym;
			std::map < SDLKey, InputKey >::iterator kmi;
			if ( (kmi = keymap1.find(sym)) != keymap1.end() ) {
				is1.set( kmi->second, false );
			}
			if ( (kmi = keymap2.find(sym)) != keymap2.end() ) {
				is2.set( kmi->second, false );
			}
		}
		break;

		case SDL_MOUSEMOTION: {
			if ( engine.states.empty() ) break;
			engine.states.back()->mouseMoved( event.motion );
			if ( event.motion.state & SDL_PRESSED ) {
				engine.states.back()->mouseDragged( event.motion );
			}
		}
		break;

		case SDL_MOUSEBUTTONUP: {
			if ( engine.states.empty() ) break;
			engine.states.back()->mouseUp( event.button );
		}
		break;

		case SDL_MOUSEBUTTONDOWN: {
			if ( engine.states.empty() ) break;
			engine.states.back()->mouseDown( event.button );
		}
		break;

		case SDL_QUIT: {
			engine.quit = true;
		}
		break;
	}
	}
}