qtmobility/src/sensors/qtapsensor.cpp
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qtapsensor.h"
       
    43 #include "qtapsensor_p.h"
       
    44 
       
    45 QTM_BEGIN_NAMESPACE
       
    46 
       
    47 IMPLEMENT_READING(QTapReading)
       
    48 
       
    49 /*!
       
    50     \class QTapReading
       
    51     \ingroup sensors_reading
       
    52 
       
    53     \preliminary
       
    54     \brief The QTapReading class represents one reading from the
       
    55            tap sensor.
       
    56 
       
    57     \section2 QTapReading Units
       
    58     The tap sensor registers tap and double tap events in one of the six directions.
       
    59     There are 3 axes that originate from the phone. They are arranged as follows.
       
    60 \code
       
    61              +z
       
    62               |
       
    63               |      +y
       
    64               |     /
       
    65               |----/----
       
    66              /| NOKIA  /|
       
    67             //|--/--- / |
       
    68            // | /   //  /
       
    69           //  |/   //  /
       
    70          //   '--------------- +x
       
    71         //       //  /
       
    72        //       //  /
       
    73       /---------/  /
       
    74      /    O    /  /
       
    75     /         /  /
       
    76     ----------  /
       
    77     |_________!/
       
    78 \endcode
       
    79 */
       
    80 
       
    81 /*!
       
    82     \enum QTapReading::TapDirection
       
    83 
       
    84     The tap direction is reported as one of the six directions (X, Y, Z, positive and negative).
       
    85     There are 3 flags that you can use if you only care about the axis in use.
       
    86 
       
    87     \value Undefined This value means that the direction is unknown.
       
    88     \value X     This flag is set if the tap was along the X axis.
       
    89     \value Y     This flag is set if the tap was along the Y axis.
       
    90     \value Z     This flag is set if the tap was along the Z axis.
       
    91     \value X_Pos This value is returned if the tap was towards the positive X direction.
       
    92     \value Y_Pos This value is returned if the tap was towards the positive Y direction.
       
    93     \value Z_Pos This value is returned if the tap was towards the positive Z direction.
       
    94     \value X_Neg This value is returned if the tap was towards the negative X direction.
       
    95     \value Y_Neg This value is returned if the tap was towards the negative Y direction.
       
    96     \value Z_Neg This value is returned if the tap was towards the negative Z direction.
       
    97 */
       
    98 
       
    99 /*!
       
   100     \property QTapReading::tapDirection
       
   101     \brief the direction of the tap.
       
   102 
       
   103     \sa {QTapReading Units}
       
   104 */
       
   105 
       
   106 QTapReading::TapDirection QTapReading::tapDirection() const
       
   107 {
       
   108     return static_cast<QTapReading::TapDirection>(d->tapDirection);
       
   109 }
       
   110 
       
   111 /*!
       
   112     Sets the tap direction to \a tapDirection.
       
   113 */
       
   114 void QTapReading::setTapDirection(QTapReading::TapDirection tapDirection)
       
   115 {
       
   116     d->tapDirection = tapDirection;
       
   117 }
       
   118 
       
   119 /*!
       
   120     \property QTapReading::doubleTap
       
   121     \brief a value indicating if there was a single or double tap.
       
   122 
       
   123     \list
       
   124     \o true - double tap
       
   125     \o false - single tap
       
   126     \endlist
       
   127     \sa {QTapReading Units}
       
   128 */
       
   129 
       
   130 bool QTapReading::isDoubleTap() const
       
   131 {
       
   132     return d->doubleTap;
       
   133 }
       
   134 
       
   135 /*!
       
   136     Sets the double tap status of the reading to \a doubleTap.
       
   137 */
       
   138 void QTapReading::setDoubleTap(bool doubleTap)
       
   139 {
       
   140     d->doubleTap = doubleTap;
       
   141 }
       
   142 
       
   143 // =====================================================================
       
   144 
       
   145 // begin generated code
       
   146 
       
   147 /*!
       
   148     \class QTapFilter
       
   149     \ingroup sensors_filter
       
   150 
       
   151     \preliminary
       
   152     \brief The QTapFilter class is a convenience wrapper around QSensorFilter.
       
   153 
       
   154     The only difference is that the filter() method features a pointer to QTapReading
       
   155     instead of QSensorReading.
       
   156 */
       
   157 
       
   158 /*!
       
   159     \fn QTapFilter::filter(QTapReading *reading)
       
   160 
       
   161     Called when \a reading changes. Returns false to prevent the reading from propagating.
       
   162 
       
   163     \sa QSensorFilter::filter()
       
   164 */
       
   165 
       
   166 const char *QTapSensor::type("QTapSensor");
       
   167 
       
   168 /*!
       
   169     \class QTapSensor
       
   170     \ingroup sensors_type
       
   171 
       
   172     \preliminary
       
   173     \brief The QTapSensor class is a convenience wrapper around QSensor.
       
   174 
       
   175     The only behavioural difference is that this class sets the type properly.
       
   176 
       
   177     This class also features a reading() function that returns a QTapReading instead of a QSensorReading.
       
   178 
       
   179     For details about how the sensor works, see \l QTapReading.
       
   180 
       
   181     \sa QTapReading
       
   182 */
       
   183 
       
   184 /*!
       
   185     \fn QTapSensor::QTapSensor(QObject *parent)
       
   186 
       
   187     Construct the sensor as a child of \a parent.
       
   188 */
       
   189 
       
   190 /*!
       
   191     \fn QTapSensor::~QTapSensor()
       
   192 
       
   193     Destroy the sensor. Stops the sensor if it has not already been stopped.
       
   194 */
       
   195 
       
   196 /*!
       
   197     \fn QTapSensor::reading() const
       
   198 
       
   199     Returns the reading class for this sensor.
       
   200 
       
   201     \sa QSensor::reading()
       
   202 */
       
   203 // end generated code
       
   204 
       
   205 #include "moc_qtapsensor.cpp"
       
   206 QTM_END_NAMESPACE
       
   207