Пример #1
0
MainWindow::MainWindow(QWidget *parent, kitrokopter::API *api) :
	QMainWindow(parent),
	ui(new Ui::MainWindow),
	api(api),
	gamepad(new Gamepad(this)),
	quadcopterModel(new QuadcopterModel(this, api)),
	quadcopterDebugDialog(0),
	trackedFilter(new QuadcopterTrackedFilter(this)),
	untrackedFilter(new QuadcopterTrackedFilter(this)),
	calibrationDialog(0)
{
	ui->setupUi(this);

	setWindowIcon(QIcon(":/icons/images/Logo64.png"));
	ui->mainToolBar->hide();

	initGamepad();

	trackedFilter->setSourceModel(quadcopterModel);
	untrackedFilter->setSourceModel(quadcopterModel);
	trackedFilter->filterTracked();
	untrackedFilter->filterUntracked();
	ui->trackedList->setModel(trackedFilter);
	ui->untrackedList->setModel(untrackedFilter);

	irrlichtWidget = new QIrrlichtWidget(ui->superWidget);
	irrlichtWidget->setMinimumSize(QSize(640, 480));
	QSizePolicy policy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
	policy.setHorizontalStretch(255);
	irrlichtWidget->setSizePolicy(policy);
	ui->superWidget->layout()->addWidget(irrlichtWidget);
	gui3d = new Gui3D(irrlichtWidget, api);

	connect(ui->launchButton, SIGNAL(clicked()), this, SLOT(launch()));
	connect(ui->loadFormationButton, SIGNAL(clicked()), this, SLOT(loadFormation()));
	connect(ui->scanButton, SIGNAL(clicked()), this, SLOT(scanForQuadcopters()));
	connect(ui->actionShutdown_everything, SIGNAL(triggered()), this, SLOT(shutdownEverything()));

	connect(ui->actionQuadcopters, SIGNAL(triggered()), this, SLOT(openQuadcopterDebugDialog()));
	connect(ui->trackedList, SIGNAL(activated(QModelIndex)), this, SLOT(openQuadcopterDetailDialog(QModelIndex)));
	connect(ui->untrackedList, SIGNAL(activated(QModelIndex)), this, SLOT(openQuadcopterDetailDialog(QModelIndex)));

	connect(ui->calibrateCamerasButton, SIGNAL(clicked()), this, SLOT(openCalibrationDialog()));
	connect(ui->startSystemButton, SIGNAL(clicked()), this, SLOT(startSystem()));

	connect(ui->actionGamepad, SIGNAL(triggered()), this, SLOT(openGamepadDebugDialog()));
	connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(openAboutDialog()));
}
Пример #2
0
Файл: beagle.c Проект: dzz/ctt2
int main(int argc, char **argv){ 
    
    int fps                                         = -1;
    double frame_millis                             = -1;
    double init_millis                              = 0;
    double tick_millis                              = 0;
    double frame_overflow                           = 0;
    double spf                                      = 0.0;
    int tick_next                                   = 0;
    unsigned int ctt2_state                         = CTT2_EVT_POLL_EVENTS;
    unsigned int render_test = 0;
        finished = 0;
    initialized_modules = 0;


    print_banner();

    if(argc==5 || argc==6) {
        SCREEN_WIDTH    = atoi( argv[1] );
        SCREEN_HEIGHT   = atoi( argv[2] );
        fullscreen      = atoi( argv[3] );
        fps             = atoi( argv[4] );
        spf = 1.0/(double)fps;
        frame_millis    = (double)1000/(double)fps;
        if(argc==6) {
            beagle_application_path = argv[5]; 
            printf("Application path: `%s`\n", beagle_application_path );
        }
    } else {

        print_usage();
        return;
    }


    loadRuntimeModule( &initLog,        &dropLog,           CTT2_RT_MODULE_LOG );
    loadRuntimeModule( &initCore,       &dropCore,          CTT2_RT_MODULE_CORE );
    loadRuntimeModule( &initDisplay,    &dropDisplay,       CTT2_RT_MODULE_DISPLAY );
    loadRuntimeModule( &initOpenGL,     &dropOpenGL,        CTT2_RT_MODULE_OPENGL );

    loadRuntimeModule( &initAudio,      &dropAudio,         CTT2_RT_MODULE_AUDIO );
    loadRuntimeModule( &initWinMsgs,    &dropWinMsgs,       CTT2_RT_MODULE_WINDOW_MSGS );
    loadRuntimeModule( &initTextInput,  &dropTextInput,     CTT2_RT_MODULE_TEXT_INPUT );
    loadRuntimeModule( &initTimer,      &dropTimer,         CTT2_RT_MODULE_TIMER );
    loadRuntimeModule( &initGamepad,    &dropGamepad,       CTT2_RT_MODULE_GAMEPAD);
    loadRuntimeModule( &initPython,     &dropPython,        CTT2_RT_MODULE_PYTHON);

    int run = 1;
    /** MAIN DISPATCH LOOP **/
    if(run) {
        SDL_Event event;
        double base_millis = timer_get_ms();
        tick_millis = timer_get_ms();


        while(finished != CTT2_RT_TERMINATED ) {
            switch(ctt2_state) {
                    case CTT2_EVT_TICK:
                        if(api_tick() == API_FAILURE) { 
                                finished = 1; 
                            } else {
                                tick_millis += frame_millis;
                                if( (timer_get_ms() - tick_millis) > frame_millis ) {
                                    ctt2_state = CTT2_EVT_TICK;
                                } else {
                                ctt2_state = CTT2_EVT_RENDER;
                                }
                            }
                         break;
                    case CTT2_EVT_RENDER:
                         if(render_test == 0) {
                            api_render();
                         } 
                         if(render_test==1) {
                             hwgfx_render_test();
                         }
                         if(render_test==2) {
                            api_render_test();
                         }
                         ctt2_state = CTT2_EVT_SYNC_GFX;
                         break;
                    case CTT2_EVT_SYNC_GFX:
                        updateViewingSurface();  
                        ctt2_state = CTT2_EVT_POLL_EVENTS;
                        break;
                    case CTT2_EVT_POLL_EVENTS:
                        if( (timer_get_ms() - tick_millis) > frame_millis ) {
                            ctt2_state = CTT2_EVT_TICK;
                         } 
                          break;
            }


            while(SDL_PollEvent(&event)) {
                switch (event.type) {
                    case SDL_CONTROLLERDEVICEADDED:
                        dropGamepad();
                        initGamepad();
                        break;
                    case SDL_CONTROLLERDEVICEREMOVED:
                        dropGamepad();
                        initGamepad();
                        break;
                    case SDL_JOYAXISMOTION:
                        GamepadHandleEvent( &event );
                        break; 
                    case SDL_TEXTINPUT:
                        api_dispatch_text( event.text.text );
                        break;
                    case SDL_QUIT:
                        finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_SYSWMEVENT:
                        #ifdef _WIN32
                            #ifdef WACOM_ENABLED
                                handle_wm_event(event); //used for the wacom tablet module, but currently missing...
                            #endif
                        #endif
                        break;
                    case SDL_KEYDOWN:
                        if( api_dispatch_key(event.key.keysym.sym,1) == API_FAILURE ) finished = CTT2_RT_TERMINATED;
                        if( event.key.keysym.sym == SDLK_F5 && (event.key.keysym.mod & KMOD_CTRL) ) {
                            dropPython();
                            initPython();
                        }
                        if( event.key.keysym.sym == SDLK_F6 && (event.key.keysym.mod & KMOD_CTRL) ) {
                            render_test = (render_test+1)%3;
                        }
                        if( event.key.keysym.sym == SDLK_F4 && (event.key.keysym.mod & KMOD_ALT) ) {
                            finished = CTT2_RT_TERMINATED;
                        }
                        break;
                    case SDL_KEYUP:
                        if( api_dispatch_key(event.key.keysym.sym,0) 
                                == API_FAILURE ) finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_MOUSEBUTTONDOWN:
                        if(api_dispatch_mousedown(
                                    event.button.button, 
                                    event.button.x, 
                                    event.button.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED ;
                        break;
                    case SDL_MOUSEBUTTONUP:
                        if(api_dispatch_mouseup(
                                    event.button.button, 
                                    event.button.x, 
                                    event.button.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED;
                        break;
                    case SDL_MOUSEMOTION:
                        if(api_dispatch_mousemotion(
                                    event.motion.x, 
                                    event.motion.y) == API_FAILURE ) 
                                        finished = CTT2_RT_TERMINATED;
                        break;
                }
            }
        }
    }
    
    sequencer_halt();
    dropRuntimeModules(0);
    return 0;
}
Пример #3
0
void QB64_GameControllerInit(){
initGamepad();
}