Example #1
0
void mouse_event_handler(unsigned char packet[3]) {
	//Middle mouse button pressed/released

	if (!(packet[0] & MOUSE_MB_PRESSED) && mouse_info.mmb_pressed) {
		mouse_info.mmb_pressed = 0;
		mmb_released();
	} else if ((packet[0] & MOUSE_MB_PRESSED) && !mouse_info.mmb_pressed) {
		mouse_info.mmb_pressed = 1;
		mmb_pressed();
	}

	//Right mouse button pressed/released

	if (!(packet[0] & MOUSE_RB_PRESSED) && mouse_info.rmb_pressed) {
		mouse_info.rmb_pressed = 0;
		rmb_released();
	} else if ((packet[0] & MOUSE_RB_PRESSED) && !mouse_info.rmb_pressed) {
		mouse_info.rmb_pressed = 1;
		rmb_pressed();
	}

	//Left mouse button pressed/released

	if (!(packet[0] & MOUSE_LB_PRESSED) && mouse_info.lmb_pressed) {
		mouse_info.lmb_pressed = 0;
		lmb_released();
	} else if ((packet[0] & MOUSE_LB_PRESSED) && !mouse_info.lmb_pressed) {
		mouse_info.lmb_pressed = 1;
		lmb_pressed();
	}

	//Update mouse x position

	if (packet[0] & MOUSE_X_SIGNED) {
		short xdelta = 0xFF00 | packet[1];
		mouse_info.x += xdelta;
		if (mouse_info.x < 0)
			mouse_info.x = 0;
	} else {
		mouse_info.x += packet[1];
		if (mouse_info.x > get_h_res())
			mouse_info.x = get_h_res();
	}

	//Update mouse y position

	if (packet[0] & MOUSE_Y_SIGNED) {
		short ydelta = 0xFF00 | packet[2];
		mouse_info.y -= ydelta;
		if (mouse_info.y > get_v_res())
			mouse_info.y = get_v_res();
	} else {
		mouse_info.y -= packet[2];
		if (mouse_info.y < 0)
			mouse_info.y = 0;
	}
}
Example #2
0
PageTimers::PageTimers (QWidget *parent)
    : Background (parent), edit_mode (false)
{
    QGridLayout *layout = new QGridLayout (this);
    layout->setMargin (0);
    layout->setSpacing (0);

    {
	digital_timer = new DigitalTimer (this);
	connect (digital_timer, SIGNAL (enterEditModeRequested ()), this, SLOT (enterEditModeDigitalTimerPressed ()));
	connect (digital_timer, SIGNAL (leaveEditModeRequested ()), this, SLOT (leaveEditMode ()));
	layout->addWidget (digital_timer, 1, 1);
    }

    {
	analog_timer = new AnalogTimer (this);
	connect (analog_timer, SIGNAL (clearAlarms ()), this, SLOT (clearCurrentAlarms ()));
	connect (analog_timer, SIGNAL (enterEditModeRequested ()), this, SLOT (enterEditModeAnalogTimerPressed ()));
	connect (analog_timer, SIGNAL (leaveEditModeRequested ()), this, SLOT (leaveEditMode ()));
	connect (analog_timer, SIGNAL (pressed ()), this, SIGNAL (analogTimerPressed ()));
	connect (analog_timer, SIGNAL (released ()), this, SIGNAL (analogTimerReleased ()));
	connect (analog_timer, SIGNAL (slide ()), this, SIGNAL (analogTimerSlide ()));
	connect (analog_timer, SIGNAL (zeroTimeReached ()), this, SIGNAL (zeroTimeReached ()));
	layout->addWidget (analog_timer, 2, 1);
    }

    layout->setColumnStretch (0, 15);
    layout->setColumnStretch (1, 50);
    layout->setColumnStretch (2, 15);

    layout->setRowStretch (0, 2);
    layout->setRowStretch (1, 40);
    layout->setRowStretch (2, 40);
    layout->setRowStretch (3, 10);
    layout->setRowStretch (4, 2);
    
#if 0 // Link with Reference
    {
	QHBoxLayout *hlayout = new QHBoxLayout ();
	hlayout->addStretch (1);
	QPushButton *add_timer_button = new QPushButton ("Add timer", this);
	connect (add_timer_button, SIGNAL (clicked ()), this, SIGNAL (switchToPageDishSelect ()));
	hlayout->addWidget (add_timer_button);
	hlayout->addStretch (1);
	layout->addLayout (hlayout);
	add_timer_button->hide ();
    }
#endif
    
    connect (this, SIGNAL (pressed ()), this, SLOT (leaveEditMode ()));

    updateContent ();

    update_timer.setInterval (100);
    update_timer.setSingleShot (false);
    update_timer.start ();

    leave_edit_mode_timer.setSingleShot (false);
    connect (&leave_edit_mode_timer, SIGNAL (timeout ()), this, SLOT (leaveEditMode ()));

    connect (analog_timer, SIGNAL (lmb_pressed ()), &leave_edit_mode_timer, SLOT (stop ()));
    connect (digital_timer, SIGNAL (lmb_pressed ()), &leave_edit_mode_timer, SLOT (stop ()));
    connect (analog_timer, SIGNAL (userIsAlive ()), this, SLOT (restartTirednessTimer ()));
    connect (digital_timer, SIGNAL (userIsAlive ()), this, SLOT (restartTirednessTimer ()));
    connect (analog_timer, SIGNAL (lmb_released ()), this, SLOT (startTirednessTimer ()));
    connect (digital_timer, SIGNAL (lmb_released ()), this, SLOT (startTirednessTimer ()));
}