Exemplo n.º 1
0
static int do_event(SDL_Event *e)
{
    switch (e->type)
    {
    case SDL_MOUSEMOTION:
        x = e->motion.x;
        y = e->motion.y;
        processMousePassiveMotion(move, x, y);
        break;

    case SDL_MOUSEBUTTONDOWN:
        processMouseButtonDown(e->button.button, move);
        break;

    case SDL_MOUSEBUTTONUP:
        processMouseButtonUp(e->button.button, move);
        break;

    case SDL_KEYDOWN:
        processKeys(e->key.keysym.sym);
        viewer->processKeys(e->key.keysym.sym);
        break;

    case SDL_QUIT:
        return 0;
    }

    return 1;
}
Exemplo n.º 2
0
/**
* Check for any keys pressed
*/
void Arcball::keyCallbackImpl(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	processKeys(window, key, action);

	m_zoom_pos = m_keys[GLFW_KEY_Z];
	m_zoom_neg = m_keys[GLFW_KEY_X];
}
Exemplo n.º 3
0
    void copySubBuffer(int x, int y, int width, int height) override {
        glXCopySubBufferMESA(display, drawable, x, y, width, height);

        if (window) {
            processKeys(window);
        }
    }
Exemplo n.º 4
0
 void swapBuffers(void) override {
     assert(!pbuffer);
     glXSwapBuffers(display, drawable);
     if (window) {
         processKeys(window);
     }
 }
Exemplo n.º 5
0
void Window::run() //timestep
{
    double time; //not used for now, but useful for later when I need time in my scene
    const double timestep = 1 / 60.0f; //for an ideal 60FPS

    double lastTime = glfwGetTime();

    while (!glfwWindowShouldClose(window))
    {
        double currentTime = glfwGetTime();
        double frameTime = currentTime - lastTime;
        if(frameTime > timestep)
        {
            glfwPollEvents();

            processKeys();
            processMouse();

            scene->processKeys(keyboard);
            scene->processMouse(mouse);

            scene->update();
            scene->render();

            glfwSwapBuffers(window);
            lastTime = glfwGetTime();
        }
    }
}
Exemplo n.º 6
0
void Player::update(float deltaTime) {
    //take input
    if(!Debugger::isShown()) processKeys(deltaTime);

    //transform coordinates for camera and other children
    float p = getGame()->getTimeSinceFixed()/getGame()->getFixedUpdateTime();
    transform = glm::translate(mat4f(1.0), lastPos*(1-p) + pos*p);

    //trace view
    traceView();
}
Exemplo n.º 7
0
 void swapBuffers(void) {
     if (ever_current) {
         // The window has been bound to a context at least once
         glXSwapBuffers(display, window);
     } else {
         // Don't call glXSwapBuffers on this window to avoid an
         // (untrappable) X protocol error with NVIDIA's driver.
         std::cerr << "warning: attempt to issue SwapBuffers on unbound window "
                      " - skipping.\n";
     }
     processKeys(window);
 }
Exemplo n.º 8
0
void runInput() {

#ifndef NO_GUI
    if (!video.sdlStarted)
        return;
#endif

    processKeys();

#ifndef NO_GUI
    processMouse();
#endif

}
void GameClient::paint(){
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    processKeys();
    mainPlayer->lookAt();
    //gluLookAt(0,10,15, 0,0,0, 0,1,0);


    wl.paint();
    //dont paint mainplayer, paint all others..
    for (std::vector<Player*>::iterator it=players.begin(); it!=players.end(); it++){
        (*it)->paint();
    }
}
Exemplo n.º 10
0
void glutDisplayCallback(void)
{
    processKeys();

    // Draw texture.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBindTexture(GL_TEXTURE_2D, tex0);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, level);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glScalef(target_scale/win_w, target_scale/win_h, 1);
    glTranslatef(target_x, target_y, 0);

    drawQuad();

    glutSwapBuffers();
}
void GameClient::mainloop(){
    gameRunning = true;
    int notifyCounter = 0;
    while (gameRunning){
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        paint();
        glfwSwapBuffers();

        //processing keys for next paint..
        processKeys();
        gameRunning = glfwGetWindowParam(GLFW_OPENED);

        notifyCounter = (notifyCounter+1)%30;
        if (!notifyCounter){
            notifyChanges();
        }
        Thread<GameClient,int>::sleep(20);
    }
    glfwTerminate();
}
Exemplo n.º 12
0
/**
 * \brief	Called every logic cycle. This triggers the events that occur and process them through various functions
 */
void CInput::pollEvents()
{
    // Semaphore
    SDL_SemWait( pollSem );

    if(remapper.mappingInput)
    {
        readNewEvent();
        SDL_SemPost( pollSem );
        return;
    }

    Vector2D<float> Pos;
#if SDL_VERSION_ATLEAST(2, 0, 0)

#else
    GsRect<Uint16> Res(SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h);
#endif

	// copy all the input of the last poll to a space for checking pressing or holding a button
	memcpy(last_immediate_keytable, immediate_keytable, KEYTABLE_SIZE*sizeof(char));

	for(int i=0 ; i<MAX_COMMANDS ; i++)
		for(int j=0 ; j<NUM_INPUTS ; j++)
			InputCommand[j][i].lastactive = InputCommand[j][i].active;


    GsRect<Uint16> activeArea = gVideoDriver.mpVideoEngine->getAspectCorrRect();

    auto &dispRect = gVideoDriver.getVidConfig().m_DisplayRect;


#if SDL_VERSION_ATLEAST(2, 0, 0)
#else
    //if( !gVideoDriver.isOpenGL() )
    {
        activeArea.x = 0;
        activeArea.y = 0;
    }
#endif



	// While there's an event to handle
	while( SDL_PollEvent( &Event ) )
	{
        bool passSDLEventVec = true;

		switch( Event.type )
		{
		case SDL_QUIT:
			gLogging.textOut("SDL: Got quit event!");
			m_exit = true;
            gDreamsForceClose = 1;

			break;
        case SDL_KEYDOWN:
            passSDLEventVec = processKeys(1);
			break;
		case SDL_KEYUP:
            passSDLEventVec = processKeys(0);
            break;
		case SDL_JOYAXISMOTION:
            passSDLEventVec = true;
			processJoystickAxis();
			break;
		case SDL_JOYBUTTONDOWN:
            passSDLEventVec = true;
			processJoystickButton(1);
			break;
		case SDL_JOYBUTTONUP:
            passSDLEventVec = true;
			processJoystickButton(0);
			break;

		case SDL_JOYHATMOTION:
            passSDLEventVec = true;
			processJoystickHat();
			break;

#if SDL_VERSION_ATLEAST(2, 0, 0)
		case SDL_FINGERDOWN:
		case SDL_FINGERUP:
		case SDL_FINGERMOTION:
			processMouse(Event);
			break;

        case SDL_WINDOWEVENT:
            if(Event.window.event == SDL_WINDOWEVENT_RESIZED)
            {
                gVideoDriver.mpVideoEngine->resizeDisplayScreen(
                        GsRect<Uint16>(Event.window.data1,
                                      Event.window.data2) );
                dispRect.w = Event.window.data1;
                dispRect.h = Event.window.data2;
            }
            break;
#else
		case SDL_VIDEORESIZE:
            gVideoDriver.mpVideoEngine->resizeDisplayScreen(
					GsRect<Uint16>(Event.resize.w, Event.resize.h) );
            dispRect.w = Event.resize.w;
            dispRect.h = Event.resize.h;
			break;
#endif

		case SDL_MOUSEBUTTONDOWN:

            // If Virtual gamepad takes control...
            if(mpVirtPad && mpVirtPad->active())
            {                                                
                if(Event.button.button <= 3)
                {
                    transMouseRelCoord(Pos, Event.motion, activeArea);
                    mpVirtPad->mouseDown(Pos);
                }
            }
            else
            {
                if(Event.button.button <= 3)
                {
                    transMouseRelCoord(Pos, Event.motion, activeArea);
                    m_EventList.add( new PointingDevEvent( Pos, PDE_BUTTONDOWN ) );
                    gPointDevice.mPointingState.mActionButton = 1;
                    gPointDevice.mPointingState.mPos = Pos;
                }
                else if(Event.button.button == 4) // scroll up
                {
                    gEventManager.add( new MouseWheelEvent( Vector2D<float>(0.0, -1.0) ) );
                }
                else if(Event.button.button == 5) // scroll down
                {
                    gEventManager.add( new MouseWheelEvent( Vector2D<float>(0.0, 1.0) ) );
                }
            }

			break;

		case SDL_MOUSEBUTTONUP:
            if(mpVirtPad && mpVirtPad->active())
            {
                transMouseRelCoord(Pos, Event.motion, activeArea);
                mpVirtPad->mouseUp(Pos);
            }
            else
            {
                passSDLEventVec = true;
                transMouseRelCoord(Pos, Event.motion, activeArea);
                m_EventList.add( new PointingDevEvent( Pos, PDE_BUTTONUP ) );
                gPointDevice.mPointingState.mActionButton = 0;
                gPointDevice.mPointingState.mPos = Pos;
            }

			break;

		case SDL_MOUSEMOTION:
            transMouseRelCoord(Pos, Event.motion, activeArea);
            m_EventList.add( new PointingDevEvent( Pos, PDE_MOVED ) );
            gPointDevice.mPointingState.mPos = Pos;
			break;
		}

        if(passSDLEventVec)
        {
            mSDLEventVec.push_back(Event);
        }
        else
        {
            mBackEventBuffer.push_back(Event);
        }
	}
#ifdef MOUSEWRAPPER
	// Handle mouse emulation layer
	processMouse();
#endif

	for(unsigned int i = 0; i < KEYTABLE_SIZE; ++i)
		firsttime_immediate_keytable[i]
		= !last_immediate_keytable[i] && immediate_keytable[i];

	for(int i=0 ; i<MAX_COMMANDS ; i++)
		for(int j=0 ; j<NUM_INPUTS ; j++)
			InputCommand[j][i].firsttimeactive
			= !InputCommand[j][i].lastactive && InputCommand[j][i].active;

#ifndef MOUSEWRAPPER

	// TODO: I'm not sure, if that should go here...
	// Check, if LALT+ENTER was pressed
	if((getHoldedKey(KALT)) && getPressedKey(KENTER))
	{
		bool value;
        value = gVideoDriver.getFullscreen();
		value = !value;
		gLogging.textOut(GREEN,"Fullscreen mode triggered by user!<br>");
        gVideoDriver.isFullscreen(value);

		// initialize/activate all drivers
		gLogging.ftextOut("Restarting graphics driver...<br>");
        if ( gVideoDriver.applyMode() && gVideoDriver.start() )
		{
			gLogging.ftextOut(PURPLE, "Toggled Fullscreen quick shortcut...<br>");
		}
		else
		{
			value = !value;
			gLogging.ftextOut(PURPLE, "Couldn't change the resolution, Rolling back...<br>");
            gVideoDriver.applyMode();
            gVideoDriver.start();
		}

		gInput.flushAll();
	}

	// Check, if LALT+Q or LALT+F4 was pressed
	if(getHoldedKey(KALT) && (getPressedKey(KF4) || getPressedKey(KQ)) )
	{
		gLogging.textOut("User exit request!");
		m_exit = true;
        gDreamsForceClose = 1;
	}
#endif

#if defined(WIZ) || defined(GP2X)
	WIZ_AdjustVolume( volume_direction );
#endif

    SDL_SemPost( pollSem );
}
Exemplo n.º 13
0
int8_t makeReport(uint8_t* report)
{
    int8_t xmit = XMIT_NONE;
    int8_t at;
    int8_t prev;

    if (!detectGhost()) {
        while (count < 8)
            current[count++] = VOID_KEY;
        memmove(keys[currentKey].keys, current + 2, 6);
        current[0] = modifiers;
        if (led & LED_SCROLL_LOCK)
            current[1] |= MOD_LEFTFN;
#ifdef ENABLE_MOUSE
        if (isMouseTouched())
            current[1] |= MOD_PAD;
#endif

        if (prefix_shift && isKanaMode(current)) {
            current[0] |= prefix;
            if (!(modifiersPrev & MOD_LEFTSHIFT) && (modifiers & MOD_LEFTSHIFT))
                prefix ^= MOD_LEFTSHIFT;
            if (!(modifiersPrev & MOD_RIGHTSHIFT) && (modifiers & MOD_RIGHTSHIFT))
                prefix ^= MOD_RIGHTSHIFT;
        }
        modifiersPrev = modifiers;

        // Copy keys that exist in both keys[prev] and keys[at] for debouncing.
        at = currentKey + DELAY_MAX + 2 - currentDelay;
        if (DELAY_MAX + 1 < at)
                at -= DELAY_MAX + 2;
        prev = at + DELAY_MAX + 1;
        if (DELAY_MAX + 1 < prev)
                prev -= DELAY_MAX + 2;
        count = 2;
        for (int8_t i = 0; i < 6; ++i) {
            uint8_t key = keys[at].keys[i];
            if (memchr(keys[prev].keys, key, 6))
                current[count++] = key;
        }
        while (count < 8)
            current[count++] = VOID_KEY;

#ifdef ENABLE_MOUSE
        if (current[1] == MOD_PAD)
            processMouseKeys(current, processed);
#endif

        if (memcmp(current, processed, 8)) {
            if (memcmp(current + 2, processed + 2, 6) || current[2] == VOID_KEY || current[1] || (current[0] & MOD_SHIFT)) {
                if (current[2] != VOID_KEY)
                    prefix = 0;
                xmit = processKeys(current, processed, report);
            } else if (processed[1] && !current[1] ||
                     (processed[0] & MOD_LEFTSHIFT) && !(current[0] & MOD_LEFTSHIFT) ||
                     (processed[0] & MOD_RIGHTSHIFT) && !(current[0] & MOD_RIGHTSHIFT))
            {
                /* empty */
            } else
                xmit = processKeys(current, processed, report);
        }
        processOSMode(report);
    } else {
        prev = currentKey + DELAY_MAX + 1;
        if (DELAY_MAX + 1 < prev)
                prev -= DELAY_MAX + 2;
        memmove(keys[currentKey].keys, keys[prev].keys, 6);
    }

    if (DELAY_MAX + 1 < ++currentKey)
        currentKey = 0;
    count = 2;
    modifiers = 0;
    current[1] = 0;

    return xmit;
}
Exemplo n.º 14
0
    void swapBuffers(void) {
        glXSwapBuffers(display, window);

        processKeys();
    }
Exemplo n.º 15
0
    void copySubBuffer(int x, int y, int width, int height) {
        glXCopySubBufferMESA(display, window, x, y, width, height);

        processKeys();
    }
Exemplo n.º 16
0
/**
 * \brief	Called every logic cycle. This triggers the events that occur and process them trough various functions
 */
void CInput::pollEvents()
{
	// copy all the input of the last poll to a space for checking pressing or holding a button
	memcpy(last_immediate_keytable, immediate_keytable, KEYTABLE_SIZE*sizeof(char));

	for(int i=0 ; i<MAX_COMMANDS ; i++)
		for(int j=0 ; j<NUM_INPUTS ; j++)
			InputCommand[j][i].lastactive = InputCommand[j][i].active;

	// While there's an event to handle
	while( SDL_PollEvent( &Event ) )
	{
		switch( Event.type )
		{
		case SDL_QUIT:
			g_pLogFile->textOut("SDL: Got quit event!");
			m_exit = true;
			break;
		case SDL_KEYDOWN:
			processKeys(1);
			break;
		case SDL_KEYUP:
			processKeys(0);
			break;
		case SDL_JOYAXISMOTION:
			processJoystickAxis();
			break;
		case SDL_JOYBUTTONDOWN:
			processJoystickButton(1);
			break;
		case SDL_JOYBUTTONUP:
			processJoystickButton(0);
			break;
#ifdef MOUSEWRAPPER
		case SDL_MOUSEBUTTONDOWN:
		case SDL_MOUSEBUTTONUP:
		case SDL_MOUSEMOTION:
			processMouse(Event);
			break;
#endif

		case SDL_VIDEORESIZE:
			CRect newSize(Event.resize.w, Event.resize.h);
			g_pVideoDriver->mp_VideoEngine->resizeDisplayScreen(newSize);
			break;
		}
	}
#ifdef MOUSEWRAPPER
	// Handle mouse emulation layer
	processMouse();
#endif

	for(unsigned int i = 0; i < KEYTABLE_SIZE; ++i)
		firsttime_immediate_keytable[i]
		= !last_immediate_keytable[i] && immediate_keytable[i];

	for(int i=0 ; i<MAX_COMMANDS ; i++)
		for(int j=0 ; j<NUM_INPUTS ; j++)
			InputCommand[j][i].firsttimeactive
			= !InputCommand[j][i].lastactive && InputCommand[j][i].active;

#ifndef MOUSEWRAPPER

	// TODO: I'm not sure, if that should go here...
	// Check, if LALT+ENTER was pressed
	if((getHoldedKey(KALT)) && getPressedKey(KENTER))
	{
		bool value;
		value = g_pVideoDriver->getFullscreen();
		value = !value;
		g_pLogFile->textOut(GREEN,"Fullscreen mode triggered by user!<br>");
		g_pVideoDriver->isFullscreen(value);

		// initialize/activate all drivers
		g_pVideoDriver->stop();
		g_pLogFile->ftextOut("Restarting graphics driver...<br>");
		if ( g_pVideoDriver->applyMode() && g_pVideoDriver->start() )
		{
			g_pLogFile->ftextOut(PURPLE, "Toggled Fullscreen quick shortcut...<br>");
		}
		else
		{
			value = !value;
			g_pLogFile->ftextOut(PURPLE, "Couldn't change the resolution, Rolling back...<br>");
			g_pVideoDriver->applyMode();
			g_pVideoDriver->start();
		}

		if(value) g_pVideoDriver->AddConsoleMsg("Fullscreen enabled");
		else g_pVideoDriver->AddConsoleMsg("Fullscreen disabled");

		g_pInput->flushAll();
	}

	// Check, if LALT+Q or LALT+F4 was pressed
	if(getHoldedKey(KALT) && (getPressedKey(KF4) || getPressedKey(KQ)) )
	{
		g_pLogFile->textOut("User exit request!");
		m_exit = true;
	}
#endif

#if defined(WIZ) || defined(GP2X)
	WIZ_AdjustVolume( volume_direction );
#endif

    // Fix up settings if everything gets messed up
	if (g_pInput->getHoldedKey(KF) &&
		g_pInput->getHoldedKey(KI) &&
		g_pInput->getHoldedKey(KX))
	{
		g_pSettings->loadDefaultGraphicsCfg();
		g_pSettings->saveDrvCfg();
		g_pVideoDriver->stop();
		g_pVideoDriver->start();
	}
}
Exemplo n.º 17
0
//main loop
int main(int argc,char* argv[])
{

    // allow ctrl-c to kill program
    signal(SIGINT, signal_handler);

    //establishing connection with the quadcopter
    heli = new CHeli();

    //initializing GUI 
    gui = new CGui(320,240);

    //this class holds the image from the drone	
    image = new CRawImage(320,240);
    //this class can segment the image	
    recognition = new CRecognition();
    image->getSaveNumber();

    while (stop == false){
        //prints the drone telemetric data, helidata struct contains drone angles, speeds and battery status 
        fprintf(stdout,"Angles %.2lf %.2lf %.2lf ",helidata.phi,helidata.psi,helidata.theta);
        fprintf(stdout,"Speeds %.2lf %.2lf %.2lf ",helidata.vx,helidata.vy,helidata.vz);
        fprintf(stdout,"Battery %.0lf ",helidata.battery);
        fprintf(stdout,"Largest blob %i %i\n",pos.x,pos.y);

        //image is captured
        heli->renewImage(image);


        //finding a blob in the image 
        pos = recognition->findSegment(image);

        //turns the drone towards the colored blob 
        //yaw = 100*(pos.x-160); //uncomment to make the drone to turn towards a colored target

        //getting input from the user
        processKeys();

        //setting the drone angles 
        heli->setAngles(pitch,roll,yaw,height);
        pitch=roll=yaw=height=0.0;

        //drawing the image, the cross etc.
        if (move==false || i%1 ==0){
            image->plotLine(pos.x,pos.y);
            image->plotCenter();
            gui->drawImage(image);
            gui->update();	
        }
        i++;
        usleep(20000);
    }


    // cleanup 
    delete recognition;
    delete heli;
    delete image;
    delete gui;
    return 0;
}
Exemplo n.º 18
0
int GeoMapEditor::processEvents()
{
  update_window();
  return processKeys();
}
Exemplo n.º 19
0
/**
 * \brief Decodes the HID mouse report received
 *
 * \param add           USB address used by the transfer
 * \param status        Transfer status
 * \param nb_transfered Number of data transfered
 */
static void uhi_hid_manta_report_reception(
		usb_add_t add,
		usb_ep_t ep,
		uhd_trans_status_t status,
		iram_size_t nb_transfered)
{
	uint8_t i;
	unsigned short val;
	UNUSED(ep);
	
	if ((status == UHD_TRANS_NOTRESPONDING) || (status == UHD_TRANS_TIMEOUT)) {
		uhi_hid_manta_start_trans_report(add);
		return; // HID mouse transfer restart
	}

	if ((status != UHD_TRANS_NOERROR) || (nb_transfered < 64)) {
		return; // HID mouse transfer aborted
	}
	manta_data_lock = 1;
	// Decode hexagon buttons
	for(i=0; i<48; i++)
	{
		butt_states[i] = uhi_hid_manta_dev.report[i+1] + 0x80;	
	}
	//decode sliders
	for(i=0; i<4; i++)
		sliders[i] = uhi_hid_manta_dev.report[i+53] + 0x80;
	//decode function buttons
	for(i=0; i<4; i++)
	{
		func_button_states[i] = uhi_hid_manta_dev.report[i+49] + 0x80;
	}
	manta_data_lock = 0;
	
	if(((sliders[0] != pastsliders[0]) && (sliders[0] != 255)) || ((sliders[1] != pastsliders[1]) && (sliders[1] != 255)))
	{
		val = (sliders[0] + (sliders[1] << 8)) & 0xFFF;
		processSliders(0, val);
	}

	if(((sliders[2] != pastsliders[2]) && (sliders[2] != 255)) || ((sliders[3] != pastsliders[3]) && (sliders[3] != 255)))
	{
		val = (sliders[2] + (sliders[3] << 8)) & 0xFFF;
		processSliders(1, val);
	}
	
	//check if we're in sequencer mode
	if (sequencer_mode == 1)
	{
		processSequencer();
	}
	//if not, we're in keyboard mode
	else
	{
		processKeys();
	}
	
	
		
	blinkersToggle();

	
	manta_send_LED();
	
	uhi_hid_manta_start_trans_report(add);
}
Exemplo n.º 20
0
 void swapBuffers(void) {
     bindAPI(api);
     eglSwapBuffers(eglDisplay, surface);
     processKeys(window);
 }
Exemplo n.º 21
0
int main(int argc,char* argv[])
{
	//initialize logging system, camera and network connection 
	processArgs(argc,argv);
	if (saveLog) initializeLogging();
	if (argc < 2) {
		fprintf(stderr,"usage: %s imageSource num_robots\ne.g. %s /dev/video0 1\n",argv[0],argv[0]);
		return 0;
	}
	camera = new CCamera();
	server = new CPositionServer();
	server->init("6666"); 

	moveOne = moveVal;
	moveOne  = 0;
	//process arguments
	camera->init(argv[1],&imageWidth,&imageHeight,saveVideo);
	camera->loadConfig("../etc/camera.cfg");

	//determine gui size so that it fits the screen
	while (imageHeight/guiScale > screenHeight || imageHeight/guiScale > screenWidth) guiScale = guiScale*2;

	//initialize GUI, image structures, coordinate transformation modules
	if (useGui) gui = new CGui(imageWidth,imageHeight,guiScale);
	image = new CRawImage(imageWidth,imageHeight);
	trans = new CTransformation(imageWidth,imageHeight,circleDiameter,true);
	trans->transformType = TRANSFORM_NONE;		//in our case, 2D is the default

	//initialize the circle detectors - each circle has its own detector instance 
	for (int i = 0;i<MAX_PATTERNS;i++) detectorArray[i] = new CCircleDetect(imageWidth,imageHeight,i);
	image->getSaveNumber();

	//setup timers to assess system performance
	CTimer timer;
	timer.reset();
	timer.start();

	CTimer globalTimer;
	globalTimer.reset();
	globalTimer.start();

	int frameID =0;
	int64_t frameTime = 0;
	while (stop == false)
	{
		if (useGui){
			camera->renewImage(image,moveOne-->0);
		}else{
			if (camera->renewImage(image,moveOne-->0)==-1)stop = true;
		}
		numFound = numStatic = 0;
		timer.reset();
		frameTime = globalTimer.getRealTime();
		//track the robots found in the last attempt 
		for (int i = 0;i<numBots;i++){
			if (currentSegmentArray[i].valid){
				lastSegmentArray[i] = currentSegmentArray[i];
				currentSegmentArray[i] = detectorArray[i]->findSegment(image,lastSegmentArray[i]);
			}
		}

		//search for untracked (not detected in the last frame) robots 
		for (int i = 0;i<numBots;i++){
			if (currentSegmentArray[i].valid == false){
				lastSegmentArray[i].valid = false;
				currentSegmentArray[i] = detectorArray[i]->findSegment(image,lastSegmentArray[i]);
			}
			if (currentSegmentArray[i].valid == false) break;		//does not make sense to search for more patterns if the last one was not found
		}

		//perform transformations from camera to world coordinates
		for (int i = 0;i<numBots;i++){
			if (currentSegmentArray[i].valid){
				objectArray[i] = trans->transform(currentSegmentArray[i],false);
				numFound++;
				if (currentSegmentArray[i].x == lastSegmentArray[i].x) numStatic++;
			}
		}
		printf("Pattern detection time: %i us. Found: %i Static: %i. Clients %i.\n",globalTimer.getTime(),numFound,numStatic,server->numConnections);
		evalTime = timer.getTime();

		//pack up the data for sending to other systems
		server->setNumOfPatterns(numFound,numBots,frameTime);
		for (int i = 0;i<numBots;i++) server->updatePosition(objectArray[i],i,frameTime);
		server->clearToSend();

		//draw stuff on the GUI 
		if (useGui){
			gui->drawImage(image);
			gui->drawTimeStats(evalTime,numBots);
			gui->displayHelp(displayHelp);
			gui->guideCalibration(calibNum,fieldLength,fieldWidth);
		}
		for (int i = 0;i<numBots && useGui && drawCoords;i++){
			if (currentSegmentArray[i].valid) gui->drawStats(currentSegmentArray[i].minx-30,currentSegmentArray[i].maxy,objectArray[i],trans->transformType == TRANSFORM_2D);
		}

		//establishing the coordinate system by manual or autocalibration
		if (autocalibrate && numFound == numBots) autocalibration();
		if (calibNum < 4) manualcalibration();

		
		for (int i = 0;i<numBots;i++){
			//if (currentSegmentArray[i].valid) printf("Object %i %03f %03f %03f %03f %03f\n",i,objectArray[i].x,objectArray[i].y,objectArray[i].z,objectArray[i].error,objectArray[i].esterror);
		}

		if (camera->cameraType == CT_WEBCAM){
			//for real camera, continue with capturing of another frame even if not all robots have been found
			moveOne = moveVal;
			for (int i = 0;i<numBots;i++){
			       	//printf("Frame %i Object %03i %03i %.5f %.5f %.5f \n",frameID,i,currentSegmentArray[i].ID,objectArray[i].x,objectArray[i].y,objectArray[i].yaw);
			       	if (robotPositionLog != NULL) fprintf(robotPositionLog,"Frame %i Time %ld Object %03i %03i %.5f %.5f %.5f \n",frameID,frameTime,i,currentSegmentArray[i].ID,objectArray[i].x,objectArray[i].y,objectArray[i].yaw);
			}
			if (moveVal > 0) frameID++;
		}else{
			//for postprocessing, try to find all robots before loading next frame
			if (numFound ==  numBots)
			{
				//gui->saveScreen(runs++);
				for (int i = 0;i<numBots;i++){
				       		//printf("Frame %i Object %03i %03i %.5f %.5f %.5f \n",frameID,i,currentSegmentArray[i].ID,objectArray[i].x,objectArray[i].y,objectArray[i].yaw);
						if (robotPositionLog != NULL) fprintf(robotPositionLog,"Frame %i Time %ld Object %03i %03i %.5f %.5f %.5f \n",frameID,frameTime,i,currentSegmentArray[i].ID,objectArray[i].x,objectArray[i].y,objectArray[i].yaw);
				}
				moveOne = moveVal; 
				if (moveVal > 0) frameID++;
			}else{
				if (moveOne-- < -100) moveOne = moveVal;
			}
		}

		//gui->saveScreen(runs);
		if (useGui) gui->update();
		if (useGui) processKeys();
	}
	if (robotPositionLog != NULL) fclose(robotPositionLog);
	delete server;
	runs--;
	delete image;
	if (useGui) delete gui;
	for (int i = 0;i<MAX_PATTERNS;i++) delete detectorArray[i];
	camera->saveConfig("../etc/camera.cfg");
	delete camera;
	delete trans;
	return 0;
}
 void EntityLinkTargetIssueGenerator::doGenerate(Entity* entity, IssueList& issues) const {
     processKeys(entity, entity->findMissingLinkTargets(), issues);
     processKeys(entity, entity->findMissingKillTargets(), issues);
 }