Mickey::Mickey() : updateTimer(this), btnThread(this), state(STANDBY), 
  calDlg(), aplDlg(), recenterFlag(true), dw(NULL) 
{
  trans = new MickeyTransform();
  //QObject::connect(onOffSwitch, SIGNAL(activated()), this, SLOT(onOffSwitch_activated()));
  //QObject::connect(&lbtnSwitch, SIGNAL(activated()), &btnThread, SLOT(on_key_pressed()));
  QObject::connect(this, SIGNAL(mouseHotKey_activated(int, bool)), 
		   &btnThread, SLOT(on_mouseHotKey_activated(int, bool)));
  QObject::connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateTimer_activated()));
  QObject::connect(&aplDlg, SIGNAL(keep()), this, SLOT(keepSettings()));
  QObject::connect(&aplDlg, SIGNAL(revert()), this, SLOT(revertSettings()));

  QObject::connect(&calDlg, SIGNAL(recenterNow(bool)), this, SLOT(recenterNow(bool)));
  QObject::connect(&calDlg, SIGNAL(startCalibration()), this, SLOT(startCalibration()));
  QObject::connect(&calDlg, SIGNAL(finishCalibration()), this, SLOT(finishCalibration()));
  QObject::connect(&calDlg, SIGNAL(cancelCalibration(bool)), this, SLOT(cancelCalibration(bool)));
  
  if(!mouse.init()){
    exit(1);
  }
  dw = QApplication::desktop();
//  screenBBox = dw->screenGeometry();
  screenBBox = QRect(0, 0, dw->width(), dw->height());
  screenCenter = screenBBox.center();
  updateTimer.setSingleShot(false);
  updateTimer.setInterval(8);
  btnThread.start();
  linuxtrack_init((char *)"Mickey");
  changeState(TRACKING);
}
int main(int argc, char *argv[]) {
  char *section = NULL;//"Default [ \nblablabla";
  float heading, pitch, roll;
  float tx, ty, tz;
  unsigned int counter;
  int retval;
  
  if(argc > 1){
    section = argv[1];
  }
  printf("Section: %s\n", section);
  
  retval = linuxtrack_init(section);
  while(linuxtrack_get_tracking_state() == INITIALIZING){
    ltr_int_usleep(333333);
  }
  if (retval != 0) { 
    printf("Error %d detected! Aborting!\n", retval);
    return retval; 
  };  
  printf("Trying to recenter!\n");
  linuxtrack_recenter();
  pthread_create(&reader, NULL, kbd_reader, NULL);
  unsigned int cntr=-1; 
  while (!quit_flag) {
    retval = linuxtrack_get_pose (&heading,&pitch,&roll,
                                  &tx, &ty, &tz, &counter);
    if(retval < 0){
      printf("Problem reading update!\n");
      break;
    }
    if(cntr != counter){
      cntr = counter;
      printf("hdg:%8.3f pitch:%8.3f roll:%8.3f ", heading, pitch, roll);
      printf("tx:%8.3f y:%8.3f z:%8.3f\n", tx, ty, tz);
    }
    ltr_int_usleep(100000);
  }
  pthread_join(reader, NULL);
  return 0;
}
Exemple #3
0
bool intialise_tracking(void)
{
    linuxtrack_state_type state;
    // Initialize the tracking using Default profile
    state = linuxtrack_init(nullptr);
    if (state < LINUXTRACK_OK){
        printf("%s\n", linuxtrack_explain(state));
        return false;
    }
    int timeout = 0;
    // Wait up to 20 seconds for the tracker initialization
    while (timeout < 200){
        state = linuxtrack_get_tracking_state();
        printf("Status: %s\n", linuxtrack_explain(state));
        if((state == RUNNING) || (state == PAUSED)){
            return true;
        }
        usleep(100000);
        ++timeout;
    }
    printf("Linuxtrack doesn't work right!\n");
    printf("Make sure it is installed and configured correctly.\n");
    return false;
}
/******************************************************************
 *		FTReportName (FREETRACKCLIENT.3)
 *
 *
 */
void __stdcall FREETRACKCLIENT_FTReportName(char * name)
{
    linuxtrack_init(name);
}