示例#1
0
void QShakeSensorGestureRecognizer::create()
{
    accel = new QAccelerometer(this);
    accel->connectToBackend();
    accel->setDataRate(50);

    qoutputrangelist outputranges = accel->outputRanges();

    if (outputranges.count() > 0)
        accelRange = (int)(outputranges.at(0).maximum *2) / 9.8; //approx range in g's
    else
        accelRange = 4; //this should never happen

    connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
    timer->setSingleShot(true);
    timer->setInterval(timerTimeout);
}
示例#2
0
KImageViewer *KView::makeViewer()
{
	KImageViewer *viewer = new KImageViewer;

	if( viewer == 0 )
		return 0;

	KFiltMenuFactory *menu = new KFiltMenuFactory( _filters );
	viewer->setFilterMenu( menu );

	_viewers->append( viewer );
	_filtMenus->insert( viewer, menu );

	connect( viewer, SIGNAL(wantHelp( const char *)),
		this, SLOT(help(const char *)) );
	connect( viewer, SIGNAL(wantNewViewer()),
		this, SLOT(newViewer()) );
	connect( viewer, SIGNAL(wantToDie(KImageViewer *)),
		this, SLOT(closeViewer(KImageViewer *)) );
	connect( viewer, SIGNAL(accelChanged()),
		this, SLOT( updateAllAccels()) );

	return viewer;
}
示例#3
0
bool QtSensorGestureSensorHandler::startSensor(SensorGestureSensors sensor)
{
    bool ok = true;
    switch (sensor) {
    case Accel:
        //accel
        if (accel == 0x0) {
            accel = new QAccelerometer(this);
            ok = accel->connectToBackend();
//            qrangelist rangeList = accel->availableDataRates();

//            QStringList ranges;
//            foreach (const qrange &range, rangeList) {
//                if (range.first == range.second)
//                    ranges << QString("%1 Hz").arg(range.first);
//                else
//                    ranges << QString("%1-%2 Hz").arg(range.first).arg(range.second);
//            }
            accel->setDataRate(100);
            qoutputrangelist outputranges = accel->outputRanges();

            if (outputranges.count() > 0)
                accelRange = (int)(outputranges.at(0).maximum);//39
            else
                accelRange = 39; //this should never happen
            connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
        }
        if (ok && !accel->isActive())
            accel->start();
        break;
    case Orientation:
        //orientation
        if (orientation == 0x0) {
            orientation = new QOrientationSensor(this);
            ok = orientation->connectToBackend();
            orientation->setDataRate(100);
            connect(orientation,SIGNAL(readingChanged()),this,SLOT(orientationChanged()));
        }
        if (ok && !orientation->isActive()) {
            orientation->start();
            QTimer::singleShot(100,this,SLOT(orientationChanged()));
        }
        break;
    case Proximity:
        //proximity
        if (proximity == 0x0) {
            proximity = new QProximitySensor(this);
            ok = proximity->connectToBackend();
            connect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
        }
        if (ok && !proximity->isActive()) {
            proximity->start();
        }
        break;
    case IrProximity:
//        //irproximity
//        if (irProx == 0x0) {
//            irProx = new QIRProximitySensor(this);
//            ok = irProx->connectToBackend();
//            connect(irProx,SIGNAL(readingChanged()),this,SLOT(irProximityChanged()));
//        }
//        if (ok && !irProx->isActive())
//            irProx->start();
//        break;
    case Tap:
//        //dtap
//        if (tapSensor == 0x0) {
//            tapSensor = new QTapSensor(this);
//            ok = tapSensor->connectToBackend();
//            connect(tapSensor,SIGNAL(readingChanged()),this,SLOT(doubletap()));
//        }
//        if (ok && !tapSensor->isActive())
//            tapSensor->start();
        break;
    };
    int val = usedSensorsMap.value(sensor);
    usedSensorsMap.insert(sensor,++val);

    return ok;
}
bool QtSensorGestureSensorHandler::startSensor(SensorGestureSensors sensor)
{
    bool ok = true;
    switch (sensor) {
    case Accel:
        //accel
        if (accel == 0x0) {
            accel = new QAccelerometer(this);
            ok = accel->connectToBackend();
            accel->setDataRate(100);
            qoutputrangelist outputranges = accel->outputRanges();

            if (outputranges.count() > 0)
                accelRange = (int)(outputranges.at(0).maximum);//39
            else
                accelRange = 39; //this should never happen
            connect(accel,SIGNAL(readingChanged()),this,SLOT(accelChanged()));
        }
        if (ok && !accel->isActive())
            accel->start();
        break;
    case Orientation:
        //orientation
        if (orientation == 0x0) {
            orientation = new QOrientationSensor(this);
            ok = orientation->connectToBackend();
            orientation->setDataRate(50);
            connect(orientation,SIGNAL(readingChanged()),this,SLOT(orientationChanged()));
        }
        if (ok && !orientation->isActive())
            orientation->start();
        break;
    case Proximity:
        //proximity
        if (proximity == 0x0) {
            proximity = new QProximitySensor(this);
            ok = proximity->connectToBackend();
            connect(proximity,SIGNAL(readingChanged()),this,SLOT(proximityChanged()));
        }
        if (ok && !proximity->isActive())
            proximity->start();
        break;
    case IrProximity:
        //irproximity
        if (irProx == 0x0) {
            irProx = new QIRProximitySensor(this);
            irProx->setDataRate(50);
            ok = irProx->connectToBackend();
            connect(irProx,SIGNAL(readingChanged()),this,SLOT(irProximityChanged()));
        }
        if (ok && !irProx->isActive())
            irProx->start();
        break;
    case Tap:
        //dtap
        if (tapSensor == 0x0) {
            tapSensor = new QTapSensor(this);
            ok = tapSensor->connectToBackend();
            connect(tapSensor,SIGNAL(readingChanged()),this,SLOT(doubletap()));
        }
        if (ok && !tapSensor->isActive())
            tapSensor->start();
        break;
    };
    int val = usedSensorsMap.value(sensor);
    usedSensorsMap.insert(sensor,++val);

    return ok;
}
示例#5
0
void ChocoboEditor::AccelChanged(int accel)
{
	choco_data.accel = accel;
	emit accelChanged(choco_data.accel);
}