Beispiel #1
0
/*!
  Function telling what to do before each frame.
  Calls customframeStarted() and see if the program has to be stopped.

  This function is called before every frame is rendered by Ogre.

  \param evt : Frame event to process.
  \return True if everything went well.
*/
bool vpAROgre::frameStarted(const Ogre::FrameEvent& evt)
{
  // custom method telling what to do at the beginning of each frame
  bool result = customframeStarted(evt);

  // Listen to the window
  Ogre::WindowEventUtilities::messagePump();
  processInputEvent(evt);

  // See if we have to stop rendering
  if(result) return stopTest(evt);
  else return result;
}
void  CInputManager::EventsMouseBDown(int x, int y, unsigned short button)
{
	MyGUI::InputManager* guiInputManager = MyGUI::InputManager::getInstancePtr();
	CSyncHelper::getInstance()->getInputMutex()->lock();
	switch (button)
	{
	case SDL_BUTTON_LEFT:
		guiInputManager->injectMousePress(x, y, MyGUI::MouseButton::Enum::Left);
		break;
	case SDL_BUTTON_MIDDLE:
		guiInputManager->injectMousePress(x, y, MyGUI::MouseButton::Enum::Middle);
		break;
	case SDL_BUTTON_RIGHT:
		guiInputManager->injectMousePress(x, y, MyGUI::MouseButton::Enum::Right);
		break;
	}
	CSyncHelper::getInstance()->getInputMutex()->unlock();

	inputEvent.clearEventData();
	inputEvent.eventId = SDL_MOUSEBUTTONDOWN;
	inputEvent.mouse.button = button;
	processInputEvent(&inputEvent, CInputEvent::IEVENT_MOUSE_KEYDOWN);
}
Beispiel #3
0
void Lingo::processEvent(LEvent event) {
	switch (event) {
		case kEventKeyUp:
		case kEventKeyDown:
		case kEventMouseUp:
		case kEventMouseDown:
			processInputEvent(event);
			break;

		case kEventEnterFrame:
		case kEventExitFrame:
			processFrameEvent(event);
			break;

		case kEventStartMovie:
		case kEventStopMovie:
		case kEventIdle:
		case kEventTimeout:
			processGenericEvent(event);

		default:
			warning("processEvent: Unhandled event %s", _eventHandlerTypes[event]);
	}
}
void ReceiverBehaviorTCP::run(){

    socklen_t sin_size;
    struct sockaddr_in addr_local; /* server addr */
    struct sockaddr_in addr_remote; /* server addr */
    BehaviorEventPacket packet;

    /* Get the Socket file descriptor */
    if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1 )
    {
        qFatal("ERROR: Failed to obtain Socket Descriptor. (errno = %d)", errno);
        this->exit();
    }
    else
         qDebug() << "Obtaining socket descriptor successfully";

    sin_size = sizeof(struct sockaddr_in);

    /* Fill the client socket address struct */
    addr_local.sin_family = AF_INET; // Protocol Family
    addr_local.sin_port = htons(port); // Port number
    addr_local.sin_addr.s_addr = INADDR_ANY; // AutoFill local address
    bzero(&(addr_local.sin_zero), 8); // Flush the rest of struct
    int opt = true;
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
                  (char *)&opt,sizeof(opt));
    /* Bind a special Port */
    if( bind(sockfd, (struct sockaddr*)&addr_local, sizeof(struct sockaddr)) == -1 )
    {
        qCritical("ERROR: Failed to bind Port. (errno = %d)", errno);
        this->exit();
    }
    else
        qDebug("Binded tcp port %d in addr %s sucessfully.",port, "sss");

    /* Listen remote connect/calling */
    if(listen(sockfd, BACKLOG) == -1)
    {
        qCritical("ERROR: Failed to listen Port. (errno = %d)", errno);
        this->exit();
    }
    else
        qDebug("Listening the port %d successfully.", port);

    /* Wait a connection, and obtain a new socket file despriptor for single connection */
    if ((nsockfd = accept(sockfd, (struct sockaddr *)&addr_remote, &sin_size)) == -1)
    {
        qFatal("ERROR: Obtaining new Socket Despcritor. (errno = %d)", errno);
        this->exit();
    }
    else
        qDebug("Server has got connected from %s.", inet_ntoa(addr_remote.sin_addr));

    while(!stop) {
        int fr_block_sz = 0;
        if((fr_block_sz = recv(nsockfd, (void *)&packet, sizeof(BehaviorEventPacket), 0)) > 0)
        {
            if(fr_block_sz == sizeof(BehaviorEventPacket)) {
                if(!test){
                    qCritical("Behavior packet received %d. Event at pin: %d", packet.pktBehaviorContext.id, packet.pktBehaviorContext.pin);
                    emit processAddNewEvent(this->getKeyStream(), packet);
                    emit processAddPacketDB(this->getKeyStream(), idtask, packet, port, QDateTime::currentDateTime().toTime_t());
                    qDebug("behaviortask id: %d", idtask);
                    if(packet.pktBehaviorContext.pin == 0 && packet.pktBehaviorContext.typeEvent == 1){
                        stop = true;
                    }

                }else{
                    qCritical("Input test received. Event at pin: %d", packet.pktBehaviorContext.pin);
                    emit processInputEvent(packet.pktBehaviorContext.pin);
                }
            }
        }else{
            qCritical("ERROR: Error receiving command. (errno = %d)", errno);
            stop = true;
        }
    }
    qDebug("Behavior Receiver ended");
    close(nsockfd);
    close(sockfd);
}
void  CInputManager::SDLEvents(float dt)
{
	MyGUI::InputManager* guiInputManager = MyGUI::InputManager::getInstancePtr();
	if (guiInputManager == NULL)
	{
		CLog::getInstance()->addWarning("CInputManager::SDLEvents() \t| guiInputManager == NULL");
	}

	SDL_Event& e = CVideoManeger::GetInstance()->event;
	if (SDL_WaitEvent(&e))
	{		
		if (&e == NULL) return;
		
		switch (e.type)
		{
		case SDL_QUIT:
			inputEvent.clearEventData();
			inputEvent.eventId = SDL_WINDOWEVENT;
			inputEvent.window.windowEvent = SDL_QUIT;			
			processInputEvent(&inputEvent, CInputEvent::IEVENT_WINDOW);
		break;
		case SDL_MOUSEMOTION:
			CSyncHelper::getInstance()->getInputMutex()->lock();
			guiInputManager->injectMouseMove(e.motion.x, e.motion.y, 0);
			CSyncHelper::getInstance()->getInputMutex()->unlock();

			inputEvent.clearEventData();
			inputEvent.eventId = SDL_MOUSEMOTION;
			inputEvent.mouse.coords[0] = e.motion.x;
			inputEvent.mouse.coords[1] = e.motion.y;
			processInputEvent(&inputEvent, CInputEvent::IEVENT_MOUSE_MOVE);
		break;
		case SDL_MOUSEBUTTONDOWN:
			EventsMouseBDown(e.motion.x, e.motion.y, e.button.button);
		break;
		case SDL_MOUSEBUTTONUP:
			EventsMouseBUp(e.motion.x, e.motion.y, e.button.button);
		break;
		case SDL_MOUSEWHEEL:
			inputEvent.clearEventData();
			inputEvent.eventId = SDL_MOUSEWHEEL;
			inputEvent.mouse.wheelDelta = e.wheel.y;
			processInputEvent(&inputEvent, CInputEvent::IEVENT_MOUSE_WHEEL);
		break;
		case SDL_WINDOWEVENT:
			if (e.window.event == SDL_WINDOWEVENT_RESIZED)
			{
//				if (isCEGUIEnabled)	CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Sizef(e.window.data1, e.window.data2));
				
				inputEvent.clearEventData();
				inputEvent.eventId = SDL_WINDOWEVENT;
				inputEvent.window.windowEvent = SDL_WINDOWEVENT_RESIZED;
				inputEvent.window.data1 = e.window.data1;
				inputEvent.window.data2 = e.window.data2;
				processInputEvent(&inputEvent, CInputEvent::IEVENT_WINDOW);
			}
		break;
		case SDL_KEYDOWN:
//			if (isCEGUIEnabled)context->injectKeyDown((*m_keymap)[e.key.keysym.sym]);
//			guiInputManager->injectKeyPress(e.key.keysym.sym);

			keyHandler.setKeyState(e.key.keysym.sym, true);

			inputEvent.clearEventData();
			inputEvent.eventId = SDL_KEYDOWN;
			inputEvent.keyboard.keyboardEvent = e.key.keysym.sym;
			processInputEvent(&inputEvent, CInputEvent::IEVENT_KEY_DOWN);		
		break;

		case SDL_KEYUP:
//			if (isCEGUIEnabled)context->injectKeyUp((*m_keymap)[e.key.keysym.sym]);
			
			keyHandler.setKeyState(e.key.keysym.sym, false);

			inputEvent.clearEventData();
			inputEvent.eventId = SDL_KEYUP;
			inputEvent.keyboard.keyboardEvent = e.key.keysym.sym;			
			processInputEvent(&inputEvent, CInputEvent::IEVENT_KEY_UP);
		break;
		}
	}
}
Beispiel #6
0
static int32_t inputHandler(struct android_app* app, AInputEvent* event) {
    return processInputEvent(event);
}