void LipstickCompositor::setScreenOrientationFromSensor() { QOrientationReading* reading = m_orientationSensor->reading(); if (debug()) qDebug() << "Screen orientation changed " << reading->orientation(); switch (reading->orientation()) { case QOrientationReading::TopUp: setScreenOrientation(Qt::PortraitOrientation); break; case QOrientationReading::TopDown: setScreenOrientation(Qt::InvertedPortraitOrientation); break; case QOrientationReading::LeftUp: setScreenOrientation(Qt::InvertedLandscapeOrientation); break; case QOrientationReading::RightUp: setScreenOrientation(Qt::LandscapeOrientation); break; case QOrientationReading::Undefined: case QOrientationReading::FaceUp: case QOrientationReading::FaceDown: default: setScreenOrientation(Qt::PrimaryOrientation); break; } }
void Utility::onReadingChanged() { #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN) QOrientationReading* reading = m_sensor->reading(); switch(reading->orientation()) { case QOrientationReading::TopUp: m_state = "Landscape"; emit orientationChanged(); break; case QOrientationReading::TopDown: m_state = "LandscapeInverted"; emit orientationChanged(); break; case QOrientationReading::LeftUp: m_state = "Portrait"; emit orientationChanged(); break; case QOrientationReading::RightUp: m_state = "PortraitInverted"; emit orientationChanged(); default: break; } #endif }
void MyMoveServer::orientationChanged() { QOrientationReading* reading = m_orientation.reading(); if (reading->orientation() == QOrientationReading::TopUp) { m_portrait = true; } else if (reading->orientation() == QOrientationReading::RightUp) { m_portrait = false; } qDebug("MyMoveServer::orientationChanged, portrait %d", m_portrait); }
void OrientationWatcher::changeHappened () { if (!watching) { return; } QOrientationReading * result = reading(); if (result) { QOrientationReading::Orientation nextSetting = result->orientation(); if (lastSetting == nextSetting) { return; } qreal degrees (0); bool portrait (true); bool doSignal (false); bool inverted (false); switch (nextSetting) { case QOrientationReading::TopUp: degrees = -90.0; lastSetting = nextSetting; doSignal = true; break; case QOrientationReading::TopDown: degrees = 90; lastSetting = nextSetting; inverted = true; doSignal = true; break; case QOrientationReading::LeftUp: degrees = 180; lastSetting = nextSetting; doSignal = true; portrait = false; inverted = true; break; case QOrientationReading::RightUp: degrees = 0; lastSetting = nextSetting; doSignal = true; portrait = false; break; default: break; } if (doSignal) { emit rotationChange (degrees, portrait, inverted); } } }
void LipstickCompositor::setScreenOrientationFromSensor() { QOrientationReading* reading = m_orientationSensor->reading(); if (debug()) qDebug() << "Screen orientation changed " << reading->orientation(); Qt::ScreenOrientation sensorOrientation = m_sensorOrientation; switch (reading->orientation()) { case QOrientationReading::TopUp: sensorOrientation = Qt::PortraitOrientation; break; case QOrientationReading::TopDown: sensorOrientation = Qt::InvertedPortraitOrientation; break; case QOrientationReading::LeftUp: sensorOrientation = Qt::InvertedLandscapeOrientation; break; case QOrientationReading::RightUp: sensorOrientation = Qt::LandscapeOrientation; break; case QOrientationReading::FaceUp: case QOrientationReading::FaceDown: /* Keep screen orientation at previous state */ break; case QOrientationReading::Undefined: default: sensorOrientation = Qt::PrimaryOrientation; break; } if (sensorOrientation != m_sensorOrientation) { m_sensorOrientation = sensorOrientation; emit sensorOrientationChanged(); } }
HRESULT readingChanged(ISimpleOrientationSensor *, ISimpleOrientationSensorOrientationChangedEventArgs *args) { SimpleOrientation value; HRESULT hr = args->get_Orientation(&value); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Failed to get orientation value." << qt_error_string(hr); return hr; } DateTime dateTime; hr = args->get_Timestamp(&dateTime); if (FAILED(hr)) { qCWarning(lcWinRtSensors) << "Failed to get compass reading timestamp." << qt_error_string(hr); return hr; } switch (value) { default: reading.setOrientation(QOrientationReading::Undefined); break; case SimpleOrientation_NotRotated: reading.setOrientation(QOrientationReading::TopUp); break; case SimpleOrientation_Rotated90DegreesCounterclockwise: reading.setOrientation(QOrientationReading::RightUp); break; case SimpleOrientation_Rotated180DegreesCounterclockwise: reading.setOrientation(QOrientationReading::TopDown); break; case SimpleOrientation_Rotated270DegreesCounterclockwise: reading.setOrientation(QOrientationReading::LeftUp); break; case SimpleOrientation_Faceup: reading.setOrientation(QOrientationReading::FaceUp); break; case SimpleOrientation_Facedown: reading.setOrientation(QOrientationReading::FaceDown); break; } reading.setTimestamp(dateTimeToMsSinceEpoch(dateTime)); q->newReadingAvailable(); return S_OK; }
MyMoveServer::MyMoveServer(QObject *parent) : QObject(parent), #ifndef ANN_TRAINING m_state(IDLE), #else m_state(COLLECTING_DATA), m_gestureFile(), #endif m_eh(this), m_gesture(), m_gesturesDouble(), m_gesturesTriple(), m_orientation(), m_portrait(true), m_gestureNN2(NULL), m_gestureNN3(NULL), m_featureVector(), m_featureMatrix(), m_diffMatrix(), m_f11(), m_f12(), m_f21(), m_f22() { m_orientation.start(); resetFeatureVector(); QOrientationReading* reading = m_orientation.reading(); if (reading->orientation() == QOrientationReading::TopUp) { m_portrait = true; } else if (reading->orientation() == QOrientationReading::RightUp) { m_portrait = false; } #ifndef ANN_TRAINING qDebug("MyMoveServer, portrait: %d", m_portrait); #else qDebug("Starting in the data collecting mode"); QString fname("/home/user/MyDocs/gesturedata"); fname.append(QVariant(m_gestureNum).toString()); m_gestureFile.setFileName(fname); m_gestureCount = 0; #endif connect(&m_orientation, SIGNAL(readingChanged()), this, SLOT(orientationChanged())); qRegisterMetaType<QPoint>("QPoint"); qRegisterMetaType<QList<QPoint> >("QList<QPoint>"); connect(&m_eh, SIGNAL(touchPress(QList<QPoint>)), this, SLOT(touchPress(QList<QPoint>))); connect(&m_eh, SIGNAL(touchMove(QList<QPoint>)), this, SLOT(touchMove(QList<QPoint>))); connect(&m_eh, SIGNAL(touchRelease(QList<QPoint>)), this, SLOT(touchRelease(QList<QPoint>))); QDBusConnection bus = QDBusConnection::sessionBus(); bus.registerObject("/sandst1/mymoves", this, QDBusConnection::ExportAllSlots); bus.registerService("org.sandst1.mymoves"); m_eh.start(); m_gestureNN2 = fann_create_from_file("/opt/mymoves/mymoves_nn2.net"); m_gestureNN3 = fann_create_from_file("/opt/mymoves/mymoves_nn3.net"); #ifndef ANN_TRAINING observeGestures(); #endif }