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.
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 to receive an event about the conceptual states of the device's movement.
44 * @remarks @b Header @b %file: @b \#include @b <FUix.h> @n
45 * @b Library : @b osp-uix
47 * The %Motion class allows an application to know about the movement of the device. The information is given in 2 ways:
48 * the application probes the state or the application registers a listener and receives an event when a movement is observed.
50 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/uix/device_motions.htm">Device Motions</a>.
52 * The following example demonstrates how to use the %Motion class to register a motion event listener and receive motion events.
55 * class MotionExample : public Tizen::Uix::IMotionEventListener
58 * result Initialize();
60 * // IMotionEventListener
61 * void OnDoubleTapDetected(void);
62 * void OnShakeDetected(Tizen::Uix::Sensor::MotionState motionState);
63 * void OnSnapDetected(Tizen::Uix::Sensor::MotionSnapType snapType);
66 * Tizen::Uix::Motion* pMotion;
69 * result MotionExample::Initialize(void)
71 * pMotion = new Motion();
72 * pMotion->Construct(*this);
73 * pMotion->SetEnabled(MOTION_TYPE_DOUBLETAP | MOTION_TYPE_SHAKE);
79 * MotionExample::OnDoubleTapDetected(void)
85 * MotionExample::OnShakeDetected(MotionState motionState)
91 * MotionExample::OnSnapDetected(MotionSnapType snapType)
93 * // In this example, since Snap is not enabled, this listener will not be called.
98 class _OSP_EXPORT_ Motion
99 : public Tizen::Base::Object
104 * This is the default constructor for this class.
111 * This is the destructor for this class.
115 virtual ~Motion(void);
120 * Initializes this instance of %Motion with the specified listener.
124 * @return An error code
125 * @param[in] listener An instance of IMotionEventListener
126 * @exception E_SUCCESS The method is successful.
127 * @exception E_OUT_OF_MEMORY The memory is insufficient.
128 * @exception E_INVALID_STATE This instance is in an invalid state.
129 * @exception E_MAX_EXCEEDED The application has reached the maximum number of motion instances.
130 * @exception E_UNSUPPORTED_OPERATION The motion detection is not supported.
132 result Construct(IMotionEventListener& listener);
135 * Sets the motion event type. @n
136 * If this method is not called, then by default all the motion event types will be captured by the listener.
137 * If the motion events are not be captured, this method can be called with @c type set to @c MOTION_TYPE_NONE.
141 * @param[in] type The type of motions that are captured by a listener @n
142 * Multiple motion types of type Tizen::Uix::Sensor::MotionType can be combined using the logical OR operator.
143 * @exception E_SUCCESS The method is successful.
144 * @exception E_INVALID_STATE This instance has not been constructed as yet.
145 * @exception E_INVALID_ARG A specified input parameter is invalid.
146 * @remarks The specific error code can be accessed using the GetLastResult() method.
148 void SetEnabled(unsigned long type);
151 * Checks whether the specified @c MotionType is supported. @n
152 * @c MOTION_TYPE_NONE and @c MOTION_TYPE_ALL are invalid, and @c false will be returned for these types.
156 * @return @c true if the specified motion type is supported, @n
158 * @param[in] type The type of the motion to query
160 bool IsSupported(MotionType type) const;
163 Motion(const Motion& value);
164 Motion& operator =(const Motion& value);
167 _MotionImpl* __pMotionImpl;
168 friend class _MotionImpl;
172 } } } // Tizen::Uix::Sensor
174 #endif //_FUIX_SENSOR_MOTION_H_