示例#1
0
void EventSystem::pollEvents()
{
    Event* ev;
    SDL_Event event;
    while(SDL_PollEvent(&event)) {
        switch(event.type)
        {
        case SDL_ACTIVEEVENT:
            ev = new Event("window_focus");
            if(event.active.gain == 0)
                ev->add("bool(False)");
            else
                ev->add("bool(True)");
            events.push(*ev);
            delete ev;
            break;
        case SDL_VIDEORESIZE:
            events.push(Event("window_resize"));
            break;
        case SDL_KEYDOWN:
            handleKeyPress(&event.key.keysym, true);
            break;
        case SDL_KEYUP:
            handleKeyPress(&event.key.keysym, false);
            break;
        case SDL_QUIT:
            events.push(Event("window_quit"));
            break;
        default:
            break;
        }
    }
}
示例#2
0
void update_input()
{
    while (SDL_PollEvent(&event))
    {
        switch (event.type)
        {
            case SDL_KEYDOWN:
                handleKeyPress(&event.key.keysym);
                break;
            case SDL_MOUSEMOTION:
                handleMouseMove(&event.motion);
                break;
            case SDL_MOUSEBUTTONDOWN:
            case SDL_MOUSEBUTTONUP:
                handleMousePress();
                break;
            case SDL_QUIT:
                done = TRUE;
                break;
            default:
                break;
        }
    }
    handleKeyDown();

    if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT))
        mouse_left();

    if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT))
        mouse_right();
}
示例#3
0
bool ScreenshotGrabber::eventFilter(QObject* object, QEvent* event)
{
    if (event->type() == QEvent::KeyPress)
        return handleKeyPress(static_cast<QKeyEvent*>(event));

    return QObject::eventFilter(object, event);
}
void WebEditorClient::handleKeyboardEvent(WebCore::KeyboardEvent* event)
{
    Node* node = event->target()->toNode();
    ASSERT(node);
    Frame* frame = node->document().frame();
    ASSERT(frame);

    // FIXME: Reorder the checks in a more sensible way.

    const PlatformKeyboardEvent* platformEvent = event->keyEvent();
    if (!platformEvent)
        return;

    // If this was an IME event don't do anything.
    if (platformEvent->windowsVirtualKeyCode() == VK_PROCESSKEY)
        return;

    // Don't allow text insertion for nodes that cannot edit.
    if (!frame->editor().canEdit())
        return;

    // This is just a normal text insertion, so wait to execute the insertion
    // until a keypress event happens. This will ensure that the insertion will not
    // be reflected in the contents of the field until the keyup DOM event.
    if (event->type() == eventNames().keypressEvent)
        return handleKeyPress(*frame, *event, *platformEvent);
    if (event->type() == eventNames().keydownEvent)
        return handleKeyDown(*frame, *event, *platformEvent);
}
示例#5
0
int SceneMultiplayer::handle(sf::Event* xevent)
{
	event = xevent;

	// Checking instance, and go to battlefield when connected
	if (instance->isConnected())
	{
		return 1;
	}

	switch (event->type)
	{
		case sf::Event::MouseButtonReleased:
		{
			// Delegate mouse click event
			return handleMouseClick(event->mouseButton.x, event->mouseButton.y);
			break;
		}

		case sf::Event::KeyPressed:
		{
			// Delegate keypress event
			return handleKeyPress(event->key.code);
			break;
		}
	}

	return 2; // Multiplayer Prompt Scene is 2
}
示例#6
0
bool BoxOfficeMainForm::handleEvent(EventType& event)
{
    bool handled=false;
    switch (event.eType)
    {
        case keyDownEvent:
            handled = handleKeyPress(event);
            break;

        case ctlSelectEvent:
            handleControlSelect(event);
            break;
               
        case LookupManager::lookupFinishedEvent:
            handleLookupFinished(event);
            handled = true;
            break;     
            
        //case lstSelectEvent:
            //handleListItemSelect(event.data.lstSelect.listID, event.data.lstSelect.selection);
            //break;
            
        default:
            handled = MoriartyForm::handleEvent(event);
    }
    return handled;
}
bool RKConsole::eventFilter (QObject *, QEvent *e) {
	if (e->type () == QEvent::KeyPress) {
		QKeyEvent *k = (QKeyEvent *)e;
		return handleKeyPress (k);
	} else if (e->type () == QEvent::MouseButtonPress){
		QMouseEvent *m = (QMouseEvent *)e;
		if (m->button() == Qt::RightButton) {
			doPopupMenu (m->globalPos ());
			return (true);
		}
		return (false);
	} else if (e->type () == QEvent::MouseButtonRelease){
		QMouseEvent *m = (QMouseEvent *)e;
		if (m->button() == Qt::MidButton) {
			QClipboard *cb = QApplication::clipboard ();
			submitBatch (cb->text (QClipboard::Selection));
			return (true);
		} /* else if (m->button () == Qt::LeftButton) {
			// prevent cursor from leaving last line
			uint para=0; uint p=0;
			view->cursorPosition (&para, &p);
			if (para != doc->numLines () - 1) {
				int y = view->y ();
				view->setCursorPosition (doc->numLines() -1, p);
				int y2 = view->y ();
				qDebug ("%d, %d", y, y2);
				view->scroll (0, y - y2);
			}
		} */ // not good, yet: always jumps to bottom of view
		return (false);
	} else {
		return false;
	}
}
示例#8
0
/**
    Process all user events in a loop
	Returns true, when user wants to quit

*/	
bool Controller::handleEvents() {
	// Handle events
	SDL_Event event;
	allowStep = false;

	while ( SDL_PollEvent(&event) ) 
	{
		switch( event.type )
		{
		case SDL_MOUSEMOTION:
			if (event.motion.state & SDL_BUTTON(SDL_BUTTON_LEFT)) {
				// Left mouse button dragging
				visualization->camera->orient(0.5f*event.motion.yrel, 0.5f*event.motion.xrel);
			}
			else if (event.motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) {
				// Panning happens here
				visualization->camera->panning(event.motion.x, event.motion.y);			
			}
			break;
		case SDL_MOUSEBUTTONDOWN:
			// Scroll wheel down
			if ( event.button.button == SDL_BUTTON_WHEELDOWN ) {
				// Zoom out
				visualization->camera->zoomOut(1.2f);
			} else if (event.button.button == SDL_BUTTON_RIGHT) {
				visualization->camera->startPanning(event.button.x, event.button.y);
			}
			break;
		case SDL_MOUSEBUTTONUP:
			// Scroll wheel up
			if ( event.button.button == SDL_BUTTON_WHEELUP ) {
				// Zoom in
				visualization->camera->zoomIn(1.15f);
			}
			break;
		case SDL_ACTIVEEVENT:
			// Don't draw anything if we're getting minimized
			if ( event.active.state & SDL_APPACTIVE ) {
				isActive = (event.active.gain != 0);	
			}
			break;			    
		case SDL_VIDEORESIZE:
			// Our window was resized
			visualization->resizeWindow(event.resize.w, event.resize.h);
			break;
		case SDL_KEYDOWN:
			// User has pressed a key
			done = handleKeyPress( &event.key.keysym);
			break;
		case SDL_QUIT:
			// Window close request
			done = true;
			break;
		default:
			break;
		}
	}
	return done;
}
示例#9
0
bool ComponentPeer::handleKeyPress (const int keyCode, const juce_wchar textCharacter)
{
    ModifierKeys::updateCurrentModifiers();

    return handleKeyPress (KeyPress (keyCode,
                                     ModifierKeys::getCurrentModifiers().withoutMouseButtons(),
                                     textCharacter));
}
示例#10
0
文件: kernel.cpp 项目: edmondas/ncwm
int Kernel::run() {
    XEvent event;

    LOGDEBUG("main event loop launched");
    ostringstream oss;
    while (runlevel_ == Kernel::RUN) {

        XCORE->nextEvent(&event);
        switch (event.type) {
        case ButtonPress:
            LOGDEBUG("button press event");
            handleButtonPress(&event.xbutton);
            break;
        case ButtonRelease:
            LOGDEBUG("button release event");
            handleButtonRelease(&event.xbutton);
            break;
        case ClientMessage:
            LOGDEBUG("client message event");
            handleClientMessage(&event.xclient);
            break;
        case ConfigureRequest:
            LOGDEBUG("configure request event");
            handleConfigureRequest(&event.xconfigurerequest);
            break;
        case DestroyNotify:
            LOGDEBUG("destroy window event");
            handleDestroyNotify(&event.xdestroywindow);
            break;
        case Expose:
            LOGDEBUG("expose event");
            handleExpose(&event.xexpose);
            break;
        case KeyPress:
            LOGDEBUG("keypress event");
            handleKeyPress(&event.xkey);
            break;
        case MapRequest:
            LOGDEBUG("map request event");
            handleMapRequest(&event.xmaprequest);
            break;
        case MotionNotify:
            LOGDEBUG("motion event");
            handleMotionNotify(&event.xmotion);
            break;
        case PropertyNotify:
            LOGDEBUG("property event");
            handlePropertyNotify(&event.xproperty);
            break;
        case UnmapNotify:
            LOGDEBUG("unmap event");
            handleUnmapNotify(&event.xunmap);
            break;
        }

    }
    return 0;
}
示例#11
0
void WindowSelector::processEvent(xcb_generic_event_t *event)
{
    if (event->response_type == XCB_BUTTON_RELEASE) {
        xcb_button_release_event_t *buttonEvent = reinterpret_cast<xcb_button_release_event_t*>(event);
        handleButtonRelease(buttonEvent->detail, buttonEvent->child);
    } else if (event->response_type == XCB_KEY_PRESS) {
        xcb_key_press_event_t *keyEvent = reinterpret_cast<xcb_key_press_event_t*>(event);
        handleKeyPress(keyEvent->detail, keyEvent->state);
    }
}
示例#12
0
文件: WHexValueEdit.C 项目: 8l/rose
void
WHexValueEdit::value(rose_addr_t v, const AddressInterval &limits) {
    value_ = v;
    limits_ = limits;
    if (v) {
        wValue_->setText(StringUtility::addrToString(v));
    } else {
        wValue_->setText("");
    }
    handleKeyPress();
}
bool UIGChooserHandlerKeyboard::handle(QKeyEvent *pEvent, UIKeyboardEventType type) const
{
    /* Process passed event: */
    switch (type)
    {
        case UIKeyboardEventType_Press: return handleKeyPress(pEvent);
        case UIKeyboardEventType_Release: return handleKeyRelease(pEvent);
    }
    /* Pass event if unknown: */
    return false;
}
示例#14
0
void TitleScreen::handleEvent(sf::Event& event)
{
  switch (event.type)
  {
  case sf::Event::KeyPressed:
    handleKeyPress(event.key.code);

    break;
  default:
    break;
  }
}
示例#15
0
int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{

		//Event handler
		SDL_Event e;
		
		//Enable text input
		SDL_StartTextInput();

		//While application is running
		while( !quit )
		{
			//Handle events on queue
			while( SDL_PollEvent( &e ) != 0 )
			{
				//User requests quit
				if( e.type == SDL_QUIT )
				{
					quit = true;
				}
				//Handle keypress with current mouse position
				else if( e.type == SDL_KEYDOWN )
				{
					handleKeyPress( &e.key.keysym );
				}
			}

			SDL_Delay(50);

			//Render quad
			render();
			
			//Update screen
			SDL_GL_SwapWindow( gWindow );
		}
		
	}


	//Free resources and close SDL
	close();

	return 0;
}
示例#16
0
bool VisualizationsEditor::eventFilter(QObject *obj, QEvent *e)
{
    if (obj == selectedList || obj == availableList)
    {
        if (e->type() == QEvent::KeyPress)
        {
            QKeyEvent *k = (QKeyEvent *) e;
            if (handleKeyPress(k))
                return true;
        }
    }

    return false;
}
示例#17
0
	//-------------------------------------------------------------------------
	void AppScreenBase::keyPressEvent( int keyCode, int nativeCode )
	//-------------------------------------------------------------------------
	{
		(void)handleKeyPress( keyCode );
		if ( mKeyTimer == NULL )
		{
			mKeyTimer = newobject( KeyRepeatTimer, new KeyRepeatTimer( this, keyCode ) );
			Environment::getEnvironment( ).addTimer( mKeyTimer, KeyRepeatMs, 0 );
		}
		else
		{
			// n-key rollover
			mKeyTimer->mKeyCode = keyCode;
		}
	}
示例#18
0
 /**
  * @brief keyPressed gets calles by OIS. If key F11 got pressed rendering mode gets changed to wireframe.
  * @param arg
  * @return
  */
 bool keyPressed(const OIS::KeyEvent &arg)
 {
     if (arg.key == OIS::KC_F11)
     {
         if (camera->getPolygonMode() == Ogre::PM_WIREFRAME)
         {
             camera->setPolygonMode(Ogre::PM_SOLID);
         }
         else
         {
             camera->setPolygonMode(Ogre::PM_WIREFRAME);
         }
         return true;
     }
     return handleKeyPress(arg, true);
 }
示例#19
0
void doEventLoop()
{
	EventRecord anEvent;
	WindowPtr   evtWind;
	short       clickArea;
	Rect        screenRect;

	while (!gDone)
	{
		if (WaitNextEvent( everyEvent, &anEvent, 0, nil ))
		{
			if (anEvent.what == mouseDown)
			{
				clickArea = FindWindow( anEvent.where, &evtWind );
				
				if (clickArea == inMenuBar)
					handleMenuSelection(MenuSelect(anEvent.where));
				else if (clickArea == inDrag)
				{
					//screenRect = (**GetGrayRgn ()).rgnBBox;
					GetRegionBounds(GetGrayRgn(), &screenRect);
					DragWindow( evtWind, anEvent.where, &screenRect );
				}
				else if (clickArea == inContent)
				{
					if (evtWind != FrontWindow())
						SelectWindow( evtWind );
				}
				else if (clickArea == inGoAway)
					if (TrackGoAway( evtWind, anEvent.where ))
						gDone = true;
			}
			else if (anEvent.what == updateEvt)
			{
				evtWind = (WindowPtr)anEvent.message;	
				//SetPort( evtWind );
				SetPortWindowPort( evtWind );
				
				BeginUpdate( evtWind );
				drawImage( evtWind );
				EndUpdate (evtWind);
			}
			else if (anEvent.what == autoKey || anEvent.what == keyDown)
				handleKeyPress(&anEvent);
		}
	}
}
示例#20
0
static void handleEvent(SDL_Event const *event, sState *state,
	SDL_Surface *surface, int videoFlags)
{
	switch(event->type)
	{
		case SDL_ACTIVEEVENT:
		{
			state->active = event->active.gain;
			break;
		}	
		case SDL_VIDEORESIZE:
		{
			/* handle resize event */
			surface = SDL_SetVideoMode( event->resize.w,
				event->resize.h, 16, videoFlags );
			if ( !surface )
			{
				fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) );
				Quit( 1 );
			}
			resizeWindow( event->resize.w, event->resize.h );
			break;
		}
		case SDL_KEYDOWN:
		{
			/* handle key presses */
			handleKeyPress(surface, state, &event->key.keysym);
			break;
		}
		case SDL_MOUSEMOTION:
		{
			state->y += event->motion.yrel/10.0f;
			state->x += event->motion.xrel/10.0f;
			break;
		}
		case SDL_QUIT:
		{
			state->quit = TRUE;
			break;
		}
		default:
			break;
	}
}
示例#21
0
void PopupMenu::init() {
	_menu->setResizedCallback([this] { handleMenuResize(); });
	_menu->setActivatedCallback([this](QAction *action, int actionTop, TriggeredSource source) {
		handleActivated(action, actionTop, source);
	});
	_menu->setTriggeredCallback([this](QAction *action, int actionTop, TriggeredSource source) {
		handleTriggered(action, actionTop, source);
	});
	_menu->setKeyPressDelegate([this](int key) { return handleKeyPress(key); });
	_menu->setMouseMoveDelegate([this](QPoint globalPosition) { handleMouseMove(globalPosition); });
	_menu->setMousePressDelegate([this](QPoint globalPosition) { handleMousePress(globalPosition); });
	_menu->setMouseReleaseDelegate([this](QPoint globalPosition) { handleMouseRelease(globalPosition); });

	handleCompositingUpdate();

	setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint) | Qt::BypassWindowManagerHint | Qt::Popup | Qt::NoDropShadowWindowHint);
	setMouseTracking(true);

	hide();

	setAttribute(Qt::WA_NoSystemBackground, true);
	setAttribute(Qt::WA_TranslucentBackground, true);
}
示例#22
0
void World::update()
{
	handleKeyPress();

	m_playerShip.update(*this);
	int i = 0;
	// bullet
	for (; i < Const::BULLET_COUNT; i++)
	{ 
		m_bullets[i].update(*this);
	}
	int abc = 0;
	// enemy ships
	Vector3 playerPosition = m_playerShip.getPosition();
	for (i = 0; i < Const::ENEMY_SHIP_AMOUNT;i++){

		if (m_ships[i].isAlive()){
			double distance = m_ships[i].getPosition().getDistanceSquared(playerPosition);
			if (distance < Const::NEAR_TO_PLAYER){
				m_ships[i].runAi(*this);
				m_ships[i].update(*this);
				abc++;
			}
		}
	}

	CoordinateSystem cs = m_playerShip.getCoordinate();
	Vector3 position = cs.getPosition();
	Vector3 up = cs.getUp();
	m_camera.setUp(cs.getUp());
	Vector3 forward = cs.getForward();
	m_camera.setForward(forward);
	position += 20 * up;
	position -= 100 * forward;
	m_camera.setPosition(position);
	checkCollision();
}
示例#23
0
bool MoviesMainForm::handleEvent(EventType& event)
{

    if (showDetailedInfo == displayMode_ && infoRenderer_.handleEventInForm(event))
        return true;
        
    bool handled = false;
    switch (event.eType)
    {
        case keyDownEvent:
            handled = handleKeyPress(event);
            break;
            
        case ctlSelectEvent:
            handleControlSelect(event);
            break;
        
        case LookupManager::lookupFinishedEvent:
            handleLookupFinished(event);
            handled = true;
            break;     
            
        case lstSelectEvent:
            handleListItemSelect(event.data.lstSelect.listID, event.data.lstSelect.selection);
            break;

        case MoriartyApplication::appSelectMovieEvent:
        case MoriartyApplication::appSelectTheatreEvent:
            handleSelectItemEvent(event);
            handled = true;
            break;
            
        default:
            handled = MoriartyForm::handleEvent(event);
    }
    return handled;
}
示例#24
0
void
EventsHandler::Run() {
	XSelectInput(mShared.display, mShared.RootWindow, 
		SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
|EnterWindowMask|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask|KeyPressMask);

	while (isRunning) {
		XNextEvent(mShared.display, &event);
		RunHandlers();
		
		std::cout << event.type << std::endl;
		//std::cout << "ConfigureRequest is " << ConfigureRequest << std::endl;
		//std::cout << "RootWindow:" << mShared.RootWindow << std::endl;

		switch (event.type) {
			case Expose:
			break;
			case ConfigureRequest:
			break;
			case KeyPress:
				handleKeyPress(&event);
			break;
			case ButtonPress:
				handleButtonPress(&event);
			break;
			case MotionNotify:
				handleMotion(&event);
			break;
			default:
				//std::cout << event.type << std::endl;
			break;
		}
	
	}

	XCloseDisplay(mShared.display);
}
 void handleKeyDownCallback (int k, int kc)
 {
     handleKeyPress (k, kc);
 }
示例#26
0
int main( int argc, char **argv )
{
    /* Flags to pass to SDL_SetVideoMode */
    int videoFlags;
    /* main loop variable */
    int done = FALSE;
    /* used to collect events */
    SDL_Event event;
    /* this holds some info about our display */
    const SDL_VideoInfo *videoInfo;
    /* whether or not the window is active */
    int isActive = TRUE;

    /* initialize SDL */
    if ( SDL_Init( SDL_INIT_VIDEO ) < 0 )
	{
	    fprintf( stderr, "Video initialization failed: %s\n",
		     SDL_GetError( ) );
	    Quit( 1 );
	}

    /* Fetch the video info */
    videoInfo = SDL_GetVideoInfo( );

    if ( !videoInfo )
	{
	    fprintf( stderr, "Video query failed: %s\n",
		     SDL_GetError( ) );
	    Quit( 1 );
	}

    /* the flags to pass to SDL_SetVideoMode */
    videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
    videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
    videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
    videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */

    /* This checks to see if surfaces can be stored in memory */
    if ( videoInfo->hw_available )
	videoFlags |= SDL_HWSURFACE;
    else
	videoFlags |= SDL_SWSURFACE;

    /* This checks if hardware blits can be done */
    if ( videoInfo->blit_hw )
	videoFlags |= SDL_HWACCEL;

    /* Sets up OpenGL double buffering */
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

    /* get a SDL surface */
    surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP,
				videoFlags );

    /* Verify there is a surface */
    if ( !surface )
	{
	    fprintf( stderr,  "Video mode set failed: %s\n", SDL_GetError( ) );
	    Quit( 1 );
	}

    /* initialize OpenGL */
    initGL( );

    /* resize the initial window */
    resizeWindow( SCREEN_WIDTH, SCREEN_HEIGHT );

    /* wait for events */
    while ( !done )
	{
	    /* handle the events in the queue */

	    while ( SDL_PollEvent( &event ) )
		{
		    switch( event.type )
			{
			case SDL_ACTIVEEVENT:
			    /* Something's happend with our focus
			     * If we lost focus or we are iconified, we
			     * shouldn't draw the screen
			     */
			    if ( event.active.gain == 0 )
				isActive = FALSE;
			    else
				isActive = TRUE;
			    break;			    
			case SDL_VIDEORESIZE:
			    /* handle resize event */
			    surface = SDL_SetVideoMode( event.resize.w,
							event.resize.h,
							16, videoFlags );
			    if ( !surface )
				{
				    fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) );
				    Quit( 1 );
				}
			    resizeWindow( event.resize.w, event.resize.h );
			    break;
			case SDL_KEYDOWN:
			    /* handle key presses */
			    handleKeyPress( &event.key.keysym );
			    break;
			case SDL_QUIT:
			    /* handle quit requests */
			    done = TRUE;
			    break;
			default:
			    break;
			}
		}

	    /* draw the scene */
	    if ( isActive )
		drawGLScene( );
	}

    /* clean ourselves up and exit */
    Quit( 0 );

    /* Should never get here */
    return( 0 );
}
示例#27
0
void LCD::ReadyRead(void)
{
    QMutexLocker locker(&m_socketLock);

    if (!m_socket)
        return;

    QString lineFromServer;
    QStringList aList;
    QStringList::Iterator it;

    // This gets activated automatically by the MythSocket class whenever
    // there's something to read.
    //
    // We currently spend most of our time (except for the first line sent
    // back) ignoring it.

    int dataSize = m_socket->bytesAvailable() + 1;
    QByteArray data(dataSize + 1, 0);

    m_socket->read(data.data(), dataSize);

    lineFromServer = data;
    lineFromServer = lineFromServer.replace( QRegExp("\n"), " " );
    lineFromServer = lineFromServer.replace( QRegExp("\r"), " " );
    lineFromServer = lineFromServer.simplified();

    // Make debugging be less noisy
    if (lineFromServer != "OK")
        LOG(VB_NETWORK, LOG_DEBUG, LOC + QString("Received from server: %1")
                .arg(lineFromServer));

    aList = lineFromServer.split(' ');
    if (aList[0] == "CONNECTED")
    {
        // We got "CONNECTED", which is a response to "HELLO"
        // get lcd width & height
        if (aList.count() != 3)
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + "received bad no. of arguments in "
                                           "CONNECTED response from LCDServer");
        }

        bool bOK;
        m_lcdWidth = aList[1].toInt(&bOK);
        if (!bOK)
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + "received bad int for width in "
                                           "CONNECTED response from LCDServer");
        }

        m_lcdHeight = aList[2].toInt(&bOK);
        if (!bOK)
        {
            LOG(VB_GENERAL, LOG_ERR, LOC + "received bad int for height in "
                                           "CONNECTED response from LCDServer");
        }

        init();
    }
    else if (aList[0] == "HUH?")
    {
        LOG(VB_GENERAL, LOG_WARNING, LOC + "Something is getting passed to "
                                       "LCDServer that it does not understand");
        LOG(VB_GENERAL, LOG_WARNING, LOC +
            QString("last command: %1").arg(m_lastCommand));
    }
    else if (aList[0] == "KEY")
        handleKeyPress(aList.last().trimmed());
}
示例#28
0
int main(int argc, char *argv[]) {
	if (argc < 3 || argc > 5) {
		printf("Usage: %s <vertexfile> <fragmentfile> [(xres) (yres)]\n",argv[0]);
		quit(0);
	}

	if (argc > 3) {
		xres = atoi(argv[3]);
		yres = atoi(argv[4]);
	}
	else
	{
		xres = _DEFAULT_XRES;
		yres = _DEFAULT_YRES;
	}

	testShader = new shader;

	SDL_Surface * surface;
	SDL_Event event;

	printf("\n(r) to reload and recompile the shader from disk\n[esc] to close\n\n");

	fragmentFile = argv[2];
	vertexFile = argv[1];

	SDL_Init(SDL_INIT_VIDEO);
	/* the flags to pass to SDL_SetVideoMode */
    videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
    videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
    videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */

	SDL_SetVideoMode(xres,yres,32,videoFlags);
	SDL_WM_SetCaption("GLSL Shader Test Bed", NULL);

	glewInit();
	glViewport(0,0,xres,480);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

    glShadeModel( GL_SMOOTH );
    glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
    glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

	testShader->loadFromFile(argv[1],argv[2]);
	testShader->compileShader();
	testShader->linkShader();
	testShader->printLog(testShader->programObject);

	testShader->useShader(true);

	while(running) 	{
		while(SDL_PollEvent(&event)) {
			switch(event.type) {
			case SDL_KEYDOWN:
				handleKeyPress(&event.key.keysym);
				break;
			case SDL_QUIT:
				running = false;
				break;
			default:
				break;
			}
		}
	render();
	}
	
	return 0;
}
示例#29
0
void Engine::Run()
{
	m_Running = true;

	SDL_Event event;
	const EventType keydown("keydownEvent");

	while (m_Running)
	{
		SINGLETONINSTANCE(Profiler)->Begin("ClearSingleFrameAllocator");
		m_SingleFrameAllocator->Clear();
		SINGLETONINSTANCE(Profiler)->End("ClearSingleFrameAllocator");

		SINGLETONINSTANCE(Profiler)->Begin("EventHandling");
		while (SDL_PollEvent(&event))
		{
			switch(event.type)
			{
			case SDL_QUIT:
				m_Running = false;
				break;

			case SDL_VIDEORESIZE:
				GetWindow()->Resize(event.resize.w, event.resize.h);

				break;
			
			case SDL_KEYDOWN:
				threadSafeQueEvent( IEventDataPointer( new EventData<SDL_KeyboardEvent>(event.key, keydown)) );
				handleKeyPress(&event.key, event.type);
				break;

			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				handleMouseButtonPress(&event.button, event.type);
				break;
				
			case SDL_MOUSEMOTION:				
				handleMouseMove(&event.motion, event.type);
				break;
			
			default:
				break;
			}
		}
		
		//Process eventQueue
		//10ms event handling
		safeProcessEventQueue(10);
		SINGLETONINSTANCE(Profiler)->End("EventHandling");

		int currentTime = Time::GetCurrentMS();
		int deltaT = (currentTime - lastTime);

		SINGLETONINSTANCE(Profiler)->Begin("StepPhysics");
		//Step the physics system
		m_Physics->Step(deltaT);
		SINGLETONINSTANCE(Profiler)->End("StepPhysics");

		SINGLETONINSTANCE(Profiler)->Begin("CameraUpdate");
		m_Graphics->m_SceneGraph->m_CameraObject->Update(deltaT);
		SINGLETONINSTANCE(Profiler)->End("CameraUpdate");

		// Display the graphics
		SINGLETONINSTANCE(Profiler)->Begin("Rendering");
		m_Graphics->Render();
		SINGLETONINSTANCE(Profiler)->End("Rendering");

		// Calculate and show FPS in title bar
		m_FPSCalculator->SetCurrentTime(currentTime);

		//char *title = new char[sizeof(char) * 50];
		char *title = (char *)m_SingleFrameAllocator->Allocate(sizeof(char) * 50);
		sprintf_s(title, (sizeof(char) * 50), "FPS: %d, Memory: %d bytes", m_FPSCalculator->GetFPS(), m_SingleFrameAllocator->GetMemoryUsage());
		m_Window->SetWindowTitle(title);

		lastTime = currentTime;

	} // while(m_Running)
}
示例#30
0
void KeyController::updateCoordinates() { handleKeyPress(m_exCode);}