Ejemplo n.º 1
0
void lmcTransferWindow::lvTransferList_currentRowChanged(int currentRow) {
	if(currentRow < 0) {
		setButtonState(FileView::TS_Max);
		return;
	}

	FileView* pFileView = ui.lvTransferList->item(currentRow);
	setButtonState(pFileView->state);
	pactShowFolder->setEnabled(QFile::exists(pFileView->filePath));
}
Ejemplo n.º 2
0
void WildcardButton::ccTouchMoved(CCTouch* touch, CCEvent* event)
{
  if (containsTouchLocation(touch))
  {      
    setButtonState(GRABBED);
  }
  else
  {
    setButtonState(UNGRABBED);
  }
}
Ejemplo n.º 3
0
void PCWand::deviceThreadMethod(void)
{
    /* Process messages until killed: */
    while(true)
    {
        /* Wait for next message: */
        unsigned char byte=(unsigned char)devicePort.getChar();

        /* Parse message: */
        if(byte>='0'&&byte<='1')
        {
            /* It's a valuator value packet; skip the next byte and read the value: */
            int valuatorIndex=byte-'0';
            devicePort.getChar();
            unsigned char valueByte=(unsigned char)devicePort.getChar();
            float value=(float(valueByte)*2.0f)/255.f-1.0f;
            deviceValuatorStates[valuatorIndex]=value;

            /* Set the valuator value in the device manager: */
            {
                Threads::Mutex::Lock deviceValuesLock(deviceValuesMutex);
                if(reportEvents)
                    setValuatorState(valuatorIndex,value);
            }
        }
        else if(byte>=216&&byte<=218)
        {
            /* It's a button press packet: */
            int buttonIndex=byte-216;
            deviceButtonStates[buttonIndex]=true;

            /* Set the button state in the device manager: */
            {
                Threads::Mutex::Lock deviceValuesLock(deviceValuesMutex);
                if(reportEvents)
                    setButtonState(buttonIndex,true);
            }
        }
        else if(byte>=248&&byte<=250)
        {
            /* It's a button release packet: */
            int buttonIndex=byte-248;
            deviceButtonStates[buttonIndex]=false;

            /* Set the button state in the device manager: */
            {
                Threads::Mutex::Lock deviceValuesLock(deviceValuesMutex);
                if(reportEvents)
                    setButtonState(buttonIndex,false);
            }
        }
    }
}
Ejemplo n.º 4
0
void MicroBitMultiButton::onEvent(MicroBitEvent evt)
{
    int button = evt.source;
    int otherButton = otherSubButton(button);
    
    switch(evt.value)
    {
        case MICROBIT_BUTTON_EVT_DOWN:
            setButtonState(button, 1);
            if(isSubButtonPressed(otherButton))
                MicroBitEvent e(id, MICROBIT_BUTTON_EVT_DOWN);
                
        break;

        case MICROBIT_BUTTON_EVT_HOLD:
            setHoldState(button, 1);
            if(isSubButtonHeld(otherButton))
                MicroBitEvent e(id, MICROBIT_BUTTON_EVT_HOLD);
            
        break;
        
        case MICROBIT_BUTTON_EVT_UP:
            if(isSubButtonPressed(otherButton))
            {
                MicroBitEvent e(id, MICROBIT_BUTTON_EVT_UP);
                
                if (isSubButtonHeld(button) && isSubButtonHeld(otherButton))
                    MicroBitEvent e(id, MICROBIT_BUTTON_EVT_LONG_CLICK);
                else
                    MicroBitEvent e(id, MICROBIT_BUTTON_EVT_CLICK);

                setSupressedState(otherButton, 1);
            }
            else if (!isSubButtonSupressed(button))
            {
                if (isSubButtonHeld(button))
                    MicroBitEvent e(button, MICROBIT_BUTTON_EVT_LONG_CLICK);
                else
                    MicroBitEvent e(button, MICROBIT_BUTTON_EVT_CLICK);
            }

            setButtonState(button, 0);
            setHoldState(button, 0);
            setSupressedState(button, 0);

        break;

    }
}
void DesktopDeviceNavigationTool::buttonCallback(int,int buttonIndex,InputDevice::ButtonCallbackData* cbData)
	{
	if(factory->buttonToggleFlags[buttonIndex])
		{
		/* Check if the toggle state has to be changed: */
		if(!cbData->newButtonState)
			{
			/* Change the button state: */
			toggleButtonStates[buttonIndex]=!toggleButtonStates[buttonIndex];
			setButtonState(buttonIndex,toggleButtonStates[buttonIndex]);
			}
		}
	else
		setButtonState(buttonIndex,cbData->newButtonState);
	}
Ejemplo n.º 6
0
void HIDDevice::handleEvents ( void )
{
	static const AbsoluteTime zeroTime = {0,0} ;
	IOReturn result ;
	IOHIDEventStruct hidEvent;
	bool changed ( false ) ;

	while ( ( result = (*hidQueueInterface) -> getNextEvent ( hidQueueInterface, &hidEvent, zeroTime, 0 ) )
				== kIOReturnSuccess )
	{
		CookieIndexMap::iterator buttonPos ( buttonMap . find ( hidEvent . elementCookie ) ) ;
		if ( buttonPos != buttonMap . end ( ) ) {
			setButtonState ( buttonPos -> second, hidEvent . value ) ;
			changed = true ;
			continue ;
		}
		CookieAxisInfoMap::iterator axisPos ( absAxisMap . find ( hidEvent . elementCookie ) ) ;
		if ( axisPos != absAxisMap . end ( ) ) {
			setValuatorState ( axisPos -> second . index,
			                   axisPos -> second . converter . map ( hidEvent . value ) ) ;
			changed = true ;
			continue ;
		}
	}

	// If events have been processed, mark manager state as complete
	if ( changed ) {
		updateState ( ) ;
		changed = false ;
	}

	if ( result != kIOReturnUnderrun )
		Misc::throwStdErr ( "HIDDevice: event queue error ( 0x%x )", result ) ;
}
Ejemplo n.º 7
0
void HIDDevice::start(void)
{
	if ( ! cfRunLoop )
	{
		// Initialize button and valuator states to the device's current values
		IOHIDEventStruct hidEvent;
		for ( CookieIndexMap::iterator pos ( buttonMap . begin ( ) ) ;
				pos != buttonMap . end ( ) ; ++pos )
		{
			if ( (*hidDeviceInterface) -> getElementValue ( hidDeviceInterface, pos -> first, &hidEvent )
					== kIOReturnSuccess )
			{
				setButtonState ( pos -> second, hidEvent . value ) ;
			}
		}
		for ( CookieAxisInfoMap::iterator pos ( absAxisMap . begin ( ) ) ;
				pos != absAxisMap . end ( ) ; ++pos )
		{
			if ( (*hidDeviceInterface) ->
				 getElementValue ( hidDeviceInterface, pos -> first, &hidEvent ) == kIOReturnSuccess )
			{
				setValuatorState ( pos -> second . index,
				                   pos -> second . converter . map ( hidEvent . value ) ) ;
			}
		}
		updateState ( ) ;
	
		if ( (*hidQueueInterface) -> start ( hidQueueInterface ) != kIOReturnSuccess )
			Misc::throwStdErr ( "HIDDevice: Unable to start HID device event queue" ) ;
	
		startDeviceThread ( ) ;
	}
}
Ejemplo n.º 8
0
void ClutchTool::buttonCallback(int,int deviceButtonIndex,InputDevice::ButtonCallbackData* cbData)
	{
	if(deviceButtonIndex==0) // Clutch button
		{
		bool mustInit=false;
		if(factory->clutchButtonToggleFlag)
			{
			if(!cbData->newButtonState)
				{
				clutchButtonState=!clutchButtonState;
				mustInit=!clutchButtonState;
				}
			}
		else
			{
			clutchButtonState=cbData->newButtonState;
			mustInit=!clutchButtonState;
			}
		
		if(mustInit)
			{
			/* Calculate the new offset transformation: */
			Vector offsetT=transformedDevice->getPosition()-getDevicePosition(0);
			Rotation offsetR=transformedDevice->getTransformation().getRotation()*Geometry::invert(getDeviceTransformation(0).getRotation());
			offset=TrackerState(offsetT,offsetR);
			}
		}
	else // Pass-through button
		{
		if(setButtonState(deviceButtonIndex-1,cbData->newButtonState))
			transformedDevice->setButtonState(deviceButtonIndex-1,buttonStates[deviceButtonIndex-1]);
		}
	}
Ejemplo n.º 9
0
void PmChart::setRecordState(bool record)
{
    liveGroup->newButtonState(liveGroup->pmtimeState(),
				QmcTime::NormalMode, record);
    setButtonState(liveGroup->buttonState());
    enableUi();
}
Ejemplo n.º 10
0
void SnapshotSettings::reflectSettings(void)
{
    digitBox->setValue(TCUserDefaults::longForKey(SAVE_DIGITS_KEY, 1, false));
    widthBox->setValue(TCUserDefaults::longForKey(SAVE_WIDTH_KEY, 1024, false));
    heightBox->setValue(TCUserDefaults::longForKey(SAVE_HEIGHT_KEY, 768, false));
    setButtonState(zoomtofitEnabledButton,
		TCUserDefaults::longForKey(SAVE_ZOOM_TO_FIT_KEY, 1, false));
	seriesEnabledButton->setChecked(
		TCUserDefaults::longForKey(SAVE_SERIES_KEY, 1, false) != 0);
	sizeEnabledButton->setChecked(
		TCUserDefaults::longForKey(SAVE_ACTUAL_SIZE_KEY, 1, false));
	autoCropButton->setChecked(
		TCUserDefaults::boolForKey(AUTO_CROP_KEY, false, false));
	transparentBackgroundButton->setChecked(
		TCUserDefaults::longForKey(SAVE_ALPHA_KEY, 0, false) != 0);
	allStepsBox->setChecked(
		TCUserDefaults::boolForKey(SAVE_STEPS_KEY, false, false));
	suffixEdit->setText(
		TCUserDefaults::stringForKey(SAVE_STEPS_SUFFIX_KEY,
        TCLocalStrings::get("DefaultStepSuffix"), false));
	sameScaleCheck->setChecked(
		TCUserDefaults::boolForKey(SAVE_STEPS_SAME_SCALE_KEY,
        true, false));
	doEnabledSize();
	doEnabledSeries();
    zoomToggled(true);
}
Ejemplo n.º 11
0
void ClutchTool::buttonCallback(int,int deviceButtonIndex,InputDevice::ButtonCallbackData* cbData)
	{
	if(deviceButtonIndex==0) // Clutch button
		{
		bool mustInit=false;
		if(factory->clutchButtonToggleFlag)
			{
			if(!cbData->newButtonState)
				{
				clutchButtonState=!clutchButtonState;
				mustInit=!clutchButtonState;
				}
			}
		else
			{
			clutchButtonState=cbData->newButtonState;
			mustInit=!clutchButtonState;
			}
		
		if(mustInit)
			{
			/* Remember the current input device transformation: */
			last=input.getDevice(0)->getTransformation();
			}
		}
	else // Pass-through button
		{
		if(setButtonState(deviceButtonIndex-1,cbData->newButtonState))
			transformedDevice->setButtonState(deviceButtonIndex-1,buttonStates[deviceButtonIndex-1]);
		}
	}
Ejemplo n.º 12
0
void DesktopDeviceTool::buttonCallback(int,int deviceButtonIndex,InputDevice::ButtonCallbackData* cbData)
	{
	/* Set the new button state and react if it changed: */
	if(setButtonState(deviceButtonIndex,cbData->newButtonState))
		{
		if(deviceButtonIndex==factory->homeButtonIndex)
			{
			if(buttonStates[deviceButtonIndex])
				{
				/* Reset the virtual input device to its home position: */
				transformedDevice->setTransformation(homePosition);
				}
			}
		else if(factory->buttonAxisShiftMasks[deviceButtonIndex]!=0x0)
			{
			/* Update the current axis shift mask: */
			if(buttonStates[deviceButtonIndex])
				axisIndexBase|=factory->buttonAxisShiftMasks[deviceButtonIndex];
			else
				axisIndexBase&=~factory->buttonAxisShiftMasks[deviceButtonIndex];
			}
		else
			{
			/* Pass the button event through to the virtual input device: */
			transformedDevice->setButtonState(deviceButtonIndex,buttonStates[deviceButtonIndex]);
			}
		}
	}
Ejemplo n.º 13
0
void MainWindow::on_treeWidget_clicked(const QModelIndex &index)
{

    setButtonState(false,false);
    int lvl = selected_lvl();
    space * wp = (space*)getRoot();
    if(lvl == 0){
        show_space();

    }else if(lvl == 1){
        int index_s = selected_index(0);
        star * p_star = (star*)wp->sublvl[index_s];
        show_star(p_star);

    }else if(lvl == 2){
        int index_s = selected_index(1);
        star * p_star = (star*)wp->sublvl[index_s];

        int index_p = selected_index(0);
        planet * p_planet = (planet*)p_star->sublvl[index_p];
        show_planet(p_planet);

    }else if(lvl == 3){
        int index_s = selected_index(2);
        star * p_star = (star*)wp->sublvl[index_s];

        int index_p = selected_index(1);
        planet * p_planet = (planet*)p_star->sublvl[index_p];

        int index_sat = selected_index(0);
        satellite * p_sat = (satellite*)p_planet->sublvl[index_sat];
        show_satellite(p_sat);
    }
}
Ejemplo n.º 14
0
void MainWindow::on_pushButton_1_clicked()          //button "Update" - used for update info in tree
{
    setButtonState(false,false);
    int lvl = selected_lvl();
    space * wp = (space*)getRoot();
    if(lvl == 0)
    {
        update_space(ui->lineEdit_space->text());

    }else if(lvl == 1){
        int index_sx = selected_index(0);
        star * p_star = (star*)wp->sublvl[index_sx];
        update_star(p_star,ui->lineEdit_star_name->text(),
                    ui->lineEdit_star_class->text(),
                    ui->lineEdit_star_mass->text().toInt());

    }else if(lvl == 2){
        int index_sx = selected_index(1);
        star * p_star = (star*)wp->sublvl[index_sx];

        int index_px = selected_index(0);
        planet * p_planet = (planet*)p_star->sublvl[index_px];

        update_planet(p_planet,ui->lineEdit_planet_name->text(),
                      ui->lineEdit_dist_to_star->text().toFloat(),
                      ui->lineEdit_planet_mass->text().toFloat());

    }else if(lvl == 3){
        int index_sx = selected_index(2);
        star * p_star = (star*)wp->sublvl[index_sx];

        int index_px = selected_index(1);
        planet * p_planet = (planet*)p_star->sublvl[index_px];

        int index_satx = selected_index(0);
        satellite * p_sat = (satellite*)p_planet->sublvl[index_satx];

        update_satellite(p_sat,ui->lineEdit_sat_name->text(),
                         ui->lineEdit_sat_dist->text().toFloat(),
                         ui->checkBox->isChecked());

    }else{
        setButtonState(true,true);
        return;
    }
    show_tree();
}
Ejemplo n.º 15
0
bool WildcardButton::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
  if (!this->isVisible() || !this->m_isEnabled)
    return false;

  if (containsTouchLocation(touch))
  {      
    setButtonState(GRABBED);
    return true;     
  }
  else
  {
    setButtonState(UNGRABBED);
  }

  return false;
}
Ejemplo n.º 16
0
void MainWindow::on_treeWidget_doubleClicked(const QModelIndex &index)
{
    if(!index.parent().isValid()) {
        setButtonState(false,false);
        ui->treeWidget->collapseAll();
    }else {
        ui->treeWidget->collapse(index.child(1,1));
    }
}
Ejemplo n.º 17
0
void *TCluster::read(ipstream &is) {
   TView::read(is);
   is >> value >> sel >> enableMask >> strings;

   setCursor(2, 0);
   showCursor();
   setButtonState(0, True);
   return this;
}
Ejemplo n.º 18
0
void WildcardButton::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
  if (containsTouchLocation(touch))
  {      
    if(m_pTarget != 0 && m_fnpChangedDelegate != 0)
      (m_pTarget->*m_fnpChangedDelegate)(this);
  }

  setButtonState(UNGRABBED);
}
Ejemplo n.º 19
0
void PolhemusFastrak::processBuffer(int station,const char* recordBuffer)
	{
	Vrui::VRDeviceState::TrackerState ts;
		
	/* Calculate raw position and orientation: */
	typedef PositionOrientation::Vector Vector;
	typedef Vector::Scalar VScalar;
	Vector v;
	v[0]=VScalar(readFloat(recordBuffer+8));
	v[1]=VScalar(readFloat(recordBuffer+12));
	v[2]=VScalar(readFloat(recordBuffer+16));

	typedef PositionOrientation::Rotation Rotation;
	typedef Rotation::Scalar RScalar;
	RScalar angles[3];
	angles[0]=Math::rad(RScalar(readFloat(recordBuffer+20)));
	angles[1]=Math::rad(RScalar(readFloat(recordBuffer+24)));
	angles[2]=Math::rad(RScalar(readFloat(recordBuffer+28)));
	Rotation o=Rotation::identity;
	o*=Rotation::rotateZ(angles[0]);
	o*=Rotation::rotateY(angles[1]);
	o*=Rotation::rotateX(angles[2]);
	
	/* Set new position and orientation: */
	ts.positionOrientation=Vrui::VRDeviceState::TrackerState::PositionOrientation(v,o);
	
	/* Calculate linear and angular velocities: */
	timers[station].elapse();
	if(notFirstMeasurements[station])
		{
		/* Estimate velocities by dividing position/orientation differences by elapsed time since last measurement: */
		double time=timers[station].getTime();
		ts.linearVelocity=(v-oldPositionOrientations[station].getTranslation())/Vrui::VRDeviceState::TrackerState::LinearVelocity::Scalar(time);
		Rotation dO=o*Geometry::invert(oldPositionOrientations[station].getRotation());
		ts.angularVelocity=dO.getScaledAxis()/Vrui::VRDeviceState::TrackerState::AngularVelocity::Scalar(time);
		}
	else
		{
		/* Force initial velocities to zero: */
		ts.linearVelocity=Vrui::VRDeviceState::TrackerState::LinearVelocity::zero;
		ts.angularVelocity=Vrui::VRDeviceState::TrackerState::AngularVelocity::zero;
		notFirstMeasurements[station]=true;
		}
	oldPositionOrientations[station]=ts.positionOrientation;
	
	/* Update button state: */
	if(station==0&&stylusEnabled)
		{
		/* Update stylus button state: */
		setButtonState(0,recordBuffer[33]=='1');
		}

	/* Update tracker state: */
	setTrackerState(station,ts);
	}
Ejemplo n.º 20
0
void DArrowButton::mousePressEvent(QMouseEvent *event)
{
    Q_UNUSED(event)

    emit mousePress();
    m_normalLabel->setVisible(false);
    m_hoverLabel->setVisible(false);
    m_pressLabel->setVisible(true);

    setButtonState(DArrowButton::ArrowStatePress);
}
Ejemplo n.º 21
0
void MainWindow::on_actionEdit_triggered()  //for edit elements
{
    if(ui->treeWidget->selectedItems().count() == 0)
    {
        QErrorMessage error_mes;
        error_mes.showMessage("Node was not selected");
        error_mes.exec();
        return;
    }
    setButtonState(false,true);
}
Ejemplo n.º 22
0
void MouseButtons::start(void)
	{
	/* Set device manager's button states to current button states: */
	{
	Threads::Mutex::Lock buttonStateLock(buttonStateMutex);
	for(int i=0;i<3;++i)
		setButtonState(i,buttonStates[i]);
	
	/* Start reporting events to the device manager: */
	reportEvents=true;
	}
	}
Ejemplo n.º 23
0
void MainWindow::on_pushButton_3_clicked()
{
    setButtonState(false,false);
    int lvl = selected_lvl();
    space * wp = (space*)getRoot();
    if(lvl == 0)
    {
        star * p_star = create_star();
        update_star(p_star,ui->lineEdit_star_name->text(),
                    ui->lineEdit_star_class->text(),
                    ui->lineEdit_star_mass->text().toFloat());

        add_star_sort(wp,p_star);

    }else if(lvl == 1){
        int index_s = selected_index(0);
        star * p_star = (star*)wp->sublvl[index_s];
        planet * p_planet = create_planet();
        update_planet(p_planet,ui->lineEdit_planet_name->text(),
                      ui->lineEdit_dist_to_star->text().toFloat(),
                      ui->lineEdit_planet_mass->text().toFloat());

        add_planet_sort(p_star,p_planet);

    }else if(lvl == 2){
        int index_s = selected_index(1);
        star * p_star = (star*)wp->sublvl[index_s];
        int index_p = selected_index(0);
        planet * p_planet = (planet*)p_star->sublvl[index_p];
        satellite * p_sat = create_satellite();
        update_satellite(p_sat,ui->lineEdit_sat_name->text(),
                         ui->lineEdit_sat_dist->text().toFloat(),
                         ui->checkBox->isChecked());

        add_satellite_sort(p_planet,p_sat);
    }else{
        setButtonState(true,true);
    }
    show_tree();
}
Ejemplo n.º 24
0
void MainWidget::keyPressEvent(QKeyEvent* e)
{
  bool ignore = true;
  if (e->isAutoRepeat() == false) {
    if (setButtonState(e->key(), true)) ignore = false;
    if (mp_glwidget && (e->key() == Qt::Key_Space)) {
      // JUMP!
      mp_glwidget->jump();
      ignore = false;
    }
  }
  if (ignore) e->ignore();
}
Ejemplo n.º 25
0
void FakespacePinchGlove::start(void)
	{
	/* Set device manager's button states to current pinch state: */
	{
	Threads::Mutex::Lock pinchMaskLock(pinchMaskMutex);
	for(int i=0;i<2;++i)
		for(int j=0;j<4;++j)
			setButtonState(i*4+j,pinchMasks[i]&(1<<j));
	
	/* Start reporting events to the device manager: */
	reportEvents=true;
	}
	}
Ejemplo n.º 26
0
void PCWand::start(void)
{
    /* Set device manager's button and valuator values to current device values: */
    {
        Threads::Mutex::Lock deviceValuesLock(deviceValuesMutex);
        for(int i=0; i<numButtons; ++i)
            setButtonState(i,deviceButtonStates[i]);
        for(int i=0; i<numValuators; ++i)
            setValuatorState(i,deviceValuatorStates[i]);

        /* Start reporting events to the device manager: */
        reportEvents=true;
    }
}
Ejemplo n.º 27
0
void HIDDevice::start(void)
	{
	/* Set device manager's button and valuator states to current states: */
	{
	Threads::Mutex::Lock stateLock(stateMutex);
	for(int i=0;i<getNumButtons();++i)
		setButtonState(i,buttonStates[i]);
	for(int i=0;i<getNumValuators();++i)
		setValuatorState(i,valuatorStates[i]);
	
	/* Start reporting events to the device manager: */
	reportEvents=true;
	}
	}
void RazerHydraDevice::start(void)
	{
	/* Set device manager's device states to current device values: */
	Threads::Mutex::Lock deviceValuesLock(deviceValuesMutex);
	for(int i=0;i<7*2;++i)
		setButtonState(i,deviceButtonStates[i]);
	for(int i=0;i<3*2;++i)
		setValuatorState(i,deviceValuatorStates[i]);
	for(int i=0;i<2;++i)
		setTrackerState(i,deviceTrackerStates[i]);
	
	/* Start reporting events to the device manager: */
	reportEvents=true;
	}
Ejemplo n.º 29
0
void WiimoteTracker::wiimoteEventCallbackNoTracker(Misc::CallbackData* cbData)
	{
	if(reportEvents)
		{
		/* Update the VR device state: */
		for(int i=0;i<13;++i)
			setButtonState(i,wiimote->getButtonState(i));
		for(int i=0;i<2;++i)
			setValuatorState(i,wiimote->getJoystickValue(i));
		
		/* Mark manager state as complete: */
		updateState();
		}
	}
Ejemplo n.º 30
0
void lmcTransferWindow::init(void) {
	setWindowIcon(QIcon(IDR_APPICON));

	createToolBar();
	setButtonState(FileView::TS_Max);

	pSettings = new lmcSettings();
	restoreGeometry(pSettings->value(IDS_WINDOWTRANSFERS).toByteArray());
	setUIText();

	ui.lvTransferList->loadData(StdLocation::transferHistory());
	if(ui.lvTransferList->count() > 0)
		ui.lvTransferList->setCurrentRow(0);

	pSoundPlayer = new lmcSoundPlayer();
}