示例#1
0
void MickeyThread::run()
{
  sn4_btn_event_t ev;
  ssize_t read;
  finish = false;
  while(1){
    while(fifo <= 1){
      if(finish){
        return;
      }
      fifo = prepareBtnChanel();
      if(fifo <= 0){
        QThread::sleep(1);
      }
    }
    while(fetch_data(fifo, (void*)&ev, sizeof(ev), &read)){
      //std::cout<<"Thread alive!"<<std::endl;
      if(finish){
        return;
      }
      if(read == sizeof(ev)){
        ev.btns ^= 3;
        processClick(ev);
      }
    }
  }
}
示例#2
0
void afterProcess(Userdata *userdata) {
	static int started = 0;
	if (processClick(userdata->click) == -1) { // Released button
		started = 0;
	} else { // Valid button
		//printClick(userdata->click); printf("\n");
		//printDrag(userdata->drag); printf("\n");
		if (started == 0) {
			started = 1;
			userdata->drag.start = userdata->click.origin;
		}
		userdata->drag.end = userdata->click.origin;
		userdata->circle = makeCircleFromDrag(userdata->drag, CV_RGB(255, 255, 255), 2);
	}
	//printCircle(userdata->circle); printf("\n");
	//drawCircle(userdata->input[0], userdata->circle);
	drawSquare(userdata->input[0], userdata->square);
	//printf("\n");

	int width = userdata->size.width;
	int height = userdata->size.height;
	//userdata->square = makeSquare(cvPoint(width * 3 / 4 - 40, height/2 - 40), cvSize(80, 80), CV_RGB(255, 255, 255), 2);
	drawSquare(userdata->input[0], makeSquare(cvPoint(width * 3 / 4 - 40, height-80), cvSize(80, 80), CV_RGB(255, 255, 255), 2));
	
}
示例#3
0
//emulate mouse button press using keyboard
void MickeyThread::on_mouseHotKey_activated(int button, bool pressed)
{
  //std::cout<<(pressed ? "Button pressed!!!" : "Button released!!!")<<std::endl;
  sn4_btn_event_t ev;
  ev.btns = pressed ? button : 0;
  gettimeofday(&(ev.timestamp), NULL);
  processClick(ev);
}
示例#4
0
文件: main.cpp 项目: jpd5367/CMPS415
void mousebuttonhandler(int button, int state, int x, int y)
{
	// when left mouse button is pressed down:
	if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
	{
		processClick(x, y);
	}
	// cause a display event to occur for GLUT:
	glutPostRedisplay();
}
示例#5
0
// _____________________________________________________________________________
void MineSweeperGame::play(size_t numRows, size_t numCols, size_t numMines) {
  _mss.initialize(numRows, numCols, numMines);
  _mss.setMines();
  mousemask(ALL_MOUSE_EVENTS, NULL);
  while (true) {
    _mss.drawField();

    // check whether game is already over and print appropriate output if it is
    if (_mss.status() != MineSweeperState::GameStatus::ONGOING) {
      gameOver();

    // process user input
    } else {
      printf("\x1b[%d;%dH", _mss.yAl() - 3, _mss.xAl() + _mss.numCols());
      printf("\xF0\x9F\x98\x8A");
      if (getmouse(&_me) == OK) {
        processClick();
      }
    }
    int ch = getch();
    if (ch == 'q') break;
    if (ch == 'r') _mss.reset();
  }
}
bool MessageBoxDialog::onClickedNo( const CEGUI::EventArgs& arg )
{
    processClick( MessageBoxDialog::BTN_NO ); 
    return true;
}
bool MessageBoxDialog::onClickedCancel( const CEGUI::EventArgs& arg )
{
    processClick( MessageBoxDialog::BTN_CANCEL ); 
    return true;
}