Exemple #1
0
QWidget *CentralWidget::createCmdWidget()
{
    joystick = new JoystickButton;

    connect(joystick, SIGNAL(upButtonPressed()), this,
        SLOT(slotCarDirectCmd()));
    connect(joystick, SIGNAL(upButtonReleased()), this,
        SLOT(slotCarStopCmd()));
    connect(joystick, SIGNAL(downButtonPressed()), this,
        SLOT(slotCarReverseCmd()));
    connect(joystick, SIGNAL(downButtonReleased()), this,
        SLOT(slotCarStopCmd()));
    connect(joystick, SIGNAL(rightButtonPressed()), this,
        SLOT(slotCarRightCmd()));
    connect(joystick, SIGNAL(rightButtonReleased()), this,
        SLOT(slotCarStopCmd()));
    connect(joystick, SIGNAL(leftButtonPressed()), this,
        SLOT(slotCarLeftCmd()));
    connect(joystick, SIGNAL(leftButtonReleased()), this,
        SLOT(slotCarStopCmd()));
    connect(joystick, SIGNAL(centerButtonPressed()), this,
        SLOT(slotCarStopCmd()));

    return joystick;
}
Exemple #2
0
void ClickableImage::mouseReleaseEvent(QMouseEvent *eve )
{
	if ( eve->button() == Qt::LeftButton )
    	emit leftButtonReleased(this);
	else if ( eve->button() == Qt::RightButton )
		emit rightButtonReleased(this);
	else if ( eve->button() == Qt::MidButton )
		emit middleButtonReleased(this);	
}
Exemple #3
0
MyMessageBox::MyMessageBox(QWidget *_widget,QString _title, QString _content):
    MyMessagePanel(_widget),Title(_title),Content(_content)
{
    QRect rect  = _widget->rect();
    this->setGeometry(rect.width()/4,rect.height()/4,rect.width()/2,rect.height()/3);

    titleLabel = new QLabel(Title,this);
    contentLabel = new QLabel(Content,this);

    leftButton = new QPushButton("Retry",this);
    rightButton = new QPushButton("Next",this);

    Initialize();

    connect(leftButton,SIGNAL(clicked(bool)),this,SLOT(leftButtonClicked()));
    connect(rightButton,SIGNAL(clicked(bool)),this,SLOT(rightButtonClicked()));
    connect(leftButton,SIGNAL(pressed()),this,SLOT(leftButtonPressed()));
    connect(rightButton,SIGNAL(pressed()),this,SLOT(rightButtonPressed()));
    connect(leftButton,SIGNAL(released()),this,SLOT(leftButtonReleased()));
    connect(rightButton,SIGNAL(released()),this,SLOT(rightButtonReleased()));

}
void moveMouse() {
	// gesture analysis
	
	barycBufferX[barycBufferIndex] = barycX;
	barycBufferY[barycBufferIndex] = barycY;
	barycBufferZ[barycBufferIndex] = barycZ;
	barycBufferIndex = (barycBufferIndex + 1) % HAND_POS_BUFFER_SIZE;

	
	
	if (isOpenHand) {
		
		int prevBarycBufferIndex = (barycBufferIndex > 0) ? barycBufferIndex-1 : HAND_POS_BUFFER_SIZE-1;
		
		int countX = -round((barycBufferX[barycBufferIndex] - barycBufferX[prevBarycBufferIndex]) * 600);
		int countY = round((barycBufferY[barycBufferIndex] - barycBufferY[prevBarycBufferIndex]) * 600);
		
		verticalScroll(countX, countY);
		
		printf("Scrolling > countX: %d\n", countX);
		return;
	}
	
	
	double meanBarycX = 0;
	double meanBarycY = 0;
	double meanBarycZ = 0;
	
	int i;
	for (i=0; i<HAND_POS_BUFFER_SIZE; i++) {
		meanBarycX += barycBufferX[i] / HAND_POS_BUFFER_SIZE;
		meanBarycY += barycBufferY[i] / HAND_POS_BUFFER_SIZE;
		meanBarycZ += barycBufferZ[i] / HAND_POS_BUFFER_SIZE;
	}
	
	
	mousePosX = round(-meanBarycX * 1280 + 640);
	mousePosY = round(meanBarycY * 1280 + 400);
	

	if (leftButtonState == MOUSE_CLICK_UP && normVecY < -0.45) {
		leftButtonPressed(mousePosX, mousePosY);
		leftButtonState = MOUSE_CLICK_DOWN;
		printf("Mouse click left down\n");
		
	}
	else if (leftButtonState == MOUSE_CLICK_DOWN && normVecY >= -0.45 ) {
		leftButtonReleased(mousePosX, mousePosY);
		leftButtonState = MOUSE_CLICK_UP;
		printf("Mouse click left up\n");
	}
	else if (rightButtonState == MOUSE_CLICK_UP && normVecX < -0.5) {
		rightButtonPressed(mousePosX, mousePosY);
		rightButtonState = MOUSE_CLICK_DOWN;
		printf("Mouse click right down\n");	
	}
	else if (rightButtonState == MOUSE_CLICK_DOWN && normVecX >= -0.5 ) {
		rightButtonReleased(mousePosX, mousePosY);
		rightButtonState = MOUSE_CLICK_UP;	
		printf("Mouse click right up\n");
	}	
	else {
		moveCursor(mousePosX, mousePosY);
	}

	
}