2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUixSensorMotion.h
20 * @brief This is the header file for the %Motion class.
22 * This header file contains the declarations of the %Motion class.
25 #ifndef _FUIX_SENSOR_MOTION_H_
26 #define _FUIX_SENSOR_MOTION_H_
28 #include <FUixSensorMotionCommon.h>
29 #include <FUixSensorIMotionEventListener.h>
30 #include <FBaseObject.h>
31 #include <FBaseDataType.h>
33 namespace Tizen { namespace Uix { namespace Sensor
40 * @brief This class is used to probe the state or receive an event about the conceptual states of the device's movement.
44 * The %Motion class allows an application to know about the movement of the device. The information is given in 2 ways:
45 * the application probes the state or the application registers a listener and receives an event when a movement is observed.
47 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/device_motions.htm">Device Motions</a>.
49 * The following example demonstrates how to use the %Motion class to register a motion event listener and receive motion events.
52 * class MotionExample : public Tizen::Uix::IMotionEventListener
55 * result Initialize();
57 * // IMotionEventListener
58 * void OnDoubleTapDetected(void);
59 * void OnShakeDetected(Tizen::Uix::Sensor::MotionState motionState);
60 * void OnSnapDetected(Tizen::Uix::Sensor::MotionSnapType snapType);
63 * Tizen::Uix::Sensor::Motion* pMotion;
66 * result MotionExample::Initialize(void)
68 * pMotion = new Motion();
69 * pMotion->Construct(*this);
70 * pMotion->SetEnabled(MOTION_TYPE_DOUBLETAP | MOTION_TYPE_SHAKE);
76 * MotionExample::OnDoubleTapDetected(void)
82 * MotionExample::OnShakeDetected(MotionState motionState)
88 * MotionExample::OnSnapDetected(MotionSnapType snapType)
90 * // In this example, since Snap is not enabled, this listener will not be called.
95 class _OSP_EXPORT_ Motion
96 : public Tizen::Base::Object
101 * This is the default constructor for this class.
108 * This is the destructor for this class.
112 virtual ~Motion(void);
117 * Initializes this instance of %Motion with the specified @c listener.
121 * @return An error code
122 * @param[in] listener An instance of IMotionEventListener
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_OUT_OF_MEMORY The memory is insufficient.
125 * @exception E_INVALID_STATE This instance is in an invalid state.
126 * @exception E_MAX_EXCEEDED The application has reached the maximum number of motion instances.
127 * @exception E_UNSUPPORTED_OPERATION The motion detection is not supported.
129 result Construct(IMotionEventListener& listener);
132 * Sets the motion event type. @n
133 * If the %SetEnabled() method is not called, then by default all the motion event types are captured by the listener.
134 * If the motion events are not to be captured, this method can be called with @c type set to @c MOTION_TYPE_NONE.
138 * @param[in] type The type of motions that are captured by a listener @n
139 * Multiple motion types of type Tizen::Uix::Sensor::MotionType can be combined using the logical OR operator.
140 * @exception E_SUCCESS The method is successful.
141 * @exception E_INVALID_STATE This instance has not been constructed as yet.
142 * @exception E_INVALID_ARG The specified input parameter is invalid.
143 * @remarks The specific error code can be accessed using the GetLastResult() method.
145 void SetEnabled(unsigned long type);
148 * Checks whether the specified @c type is supported. @n
149 * @c MOTION_TYPE_NONE and @c MOTION_TYPE_ALL are unsupported types, and @c false is returned for these types.
153 * @return @c true if the specified motion type is supported, @n
155 * @param[in] type The type of the motion to query
157 bool IsSupported(MotionType type) const;
160 Motion(const Motion& value);
161 Motion& operator =(const Motion& value);
164 _MotionImpl* __pMotionImpl;
165 friend class _MotionImpl;
169 } } } // Tizen::Uix::Sensor
171 #endif //_FUIX_SENSOR_MOTION_H_