2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FSysVibrator.h
19 * @brief This is the header file for the %Vibrator class.
21 * This header file contains the declarations of the %Vibrator class.
24 #ifndef _FSYS_VIBRATOR_H_
25 #define _FSYS_VIBRATOR_H_
27 #include <FBaseObject.h>
29 namespace Tizen { namespace System
34 * @brief This class handles the vibration functionality of the device.
38 * The %Vibrator class handles the vibration functionality of a device. It allows the management of the device's vibrator parameters, such as the vibration count and level.
40 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/system/vibrator_mgmt.htm">Vibrator Management</a>.
42 * The following example demonstrates how to use the %Vibrator class.
47 * #include <FSystem.h>
49 * using namespace Tizen::Base;
50 * using namespace Tizen::System;
52 * class MyVibratorClass
55 * result VibratorExample(void);
61 * MyVibratorClass::VibratorExample(void)
63 * result r = vibrator.Construct();
69 * // Initializes the vibration pattern
70 * IntensityDurationVibrationPattern patterns[4] = {{2000, 50}, {1000, 0}, {500, -1}, {1000, 80}};
71 * int length = sizeof(patterns);
73 * // Vibrates with a given pattern and repeats count
74 * vibrator.Start(patterns, length, 3);
79 * // Do some exception handling
86 * @struct IntensityDurationVibrationPattern
87 * @brief This struct represents the specified duration and vibration intensity level.
89 * The %IntensityDurationVibrationPattern struct represents the specified duration and vibration intensity level. This struct can be used with Vibrator::Start(IntensityDurationVibrationPattern[] patterns, int length, int repeatCount) as a custom pattern.
93 struct _OSP_EXPORT_ IntensityDurationVibrationPattern
95 int duration; /**< The duration in milliseconds when the vibrator is on @n
96 * The @c duration does not allow a negative value.
98 int intensity; /**< The vibration intensity [@c -1~ @c 100]: @n
99 * @li The system default vibration intensity (-1)
100 * @li The silent vibration intensity (0)
101 * @li The minimum vibration intensity (1)
102 * @li The maximum vibration intensity (100)
107 class _OSP_EXPORT_ Vibrator
108 : public Tizen::Base::Object
113 * This is the default constructor for this class. @n
114 * The object is not fully constructed after this constructor is called.
115 * For full construction, the Construct() method must be called right after calling this constructor.
122 * This is the destructor for this class. @n
123 * This destructor overrides Tizen::Base::Object::~Object().
127 * @remarks If the instance is destroyed before the vibration stops, the vibration is stopped forcefully.
129 virtual ~Vibrator(void);
132 * Initializes this instance of %Vibrator.
136 * @return An error code
137 * @exception E_SUCCESS The method is successful.
138 * @exception E_SYSTEM An unknown operating system error has occurred.
141 result Construct(void);
145 * Vibrates the device with a specified array pattern that has a vibration intensity and duration. @n
146 * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs. @n
147 * If this method is called again before the previous vibration stops, the previous vibration is cancelled and the new vibration starts immediately. @n
148 * If a new vibrator instance triggers the vibration, the vibrator merges the previous vibration pattern with the new one in the overlapped time. @n
149 * If a system alert occurs such as a ring vibration or a system event notification, the vibration can be interrupted. @n
150 * If the application is terminated, the vibration is cancelled.
154 * @privilege %http://tizen.org/privilege/vibrator
156 * @return An error code
158 * @param[in] patterns The array of @c IntensityDurationVibrationPattern
159 * @param[in] length The length of @c patterns
160 * @param[in] repeatCount The number of times the pattern repeats @n
161 * This value must be between @c 1 to @c 100.
162 * @exception E_SUCCESS The method is successful.
163 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
164 * @exception E_INVALID_ARG A specified input parameter is invalid.
165 * @exception E_OPERATION_FAILED The device operation has failed.
166 * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting the vibration.
167 * @see IntensityDurationVibrationPattern
169 result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount = 1);
172 * Vibrates the device with the specified pattern and level. @n
173 * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
174 * If this method is called again before the previous vibration stops, the previous vibration is cancelled and the new vibration starts immediately.
176 * @brief <i>[Deprecated]</i>
177 * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
180 * @privilege %http://tizen.org/privilege/vibrator
182 * @return An error code
183 * @param[in] onPeriod The period in milliseconds when the vibrator is on @n
184 * It should be greater than @c 0.
185 * @param[in] offPeriod The period in milliseconds when the vibrator is off @n
186 * It should be equal to or greater than @c 0.
187 * @param[in] count The number of times to execute the given pattern @n
188 * It should be greater than @c 0.
189 * @param[in] level The vibration level @n
190 * It ranges from [@c 0~ @c 100], where '@c 0' is a special case indicating the system default level.
191 * @exception E_SUCCESS The method is successful.
192 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
193 * @exception E_INVALID_ARG A specified input parameter is invalid.
194 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
195 * @exception E_DEVICE_FAILED The device operation has failed.
196 * @remarks Various devices may have different vibration capabilities. @n
197 * If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration. @n
198 * If the device supports many levels of vibration, then a level value @c 0 results in the system default vibration,
199 * value @c 1 results in the lowest frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in
200 * intermediate vibration levels. @n
201 * Devices have implementation-specific limits for the total duration of the vibration, and vibration cuts off at that limit even if the duration parameter is
202 * greater than the limit.
205 result Start(long onPeriod, long offPeriod, int count, int level = 0);
208 * Vibrates the device for the specified duration at the specified level. @n
209 * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
210 * If this method is called again before the previous vibration stops, the previous vibration is cancelled and the new vibration starts immediately.
212 * @brief <i>[Deprecated]</i>
213 * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
216 * @privilege %http://tizen.org/privilege/vibrator
218 * @return An error code
219 * @param[in] milliseconds The duration for the vibration in milliseconds @n
220 * It should be greater than @c 0.
221 * @param[in] level The vibration level @n
222 * It ranges from [@c 0~ @c 100], where ' @c 0' is a special case indicating the system default level.
223 * @exception E_SUCCESS The method is successful.
224 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
225 * @exception E_INVALID_ARG A specified input parameter is invalid.
226 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
227 * @exception E_DEVICE_FAILED The device operation has failed.
228 * @remarks Various devices have different vibration capabilities. @n
229 * If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration. @n
230 * If the device supports many levels of vibration, then a level value @c 0 results in the system default vibration, value @c 1 results in the lowest
231 * frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
232 * Devices have implementation-specific limits for the total duration of the vibration, and vibration cuts off at that limit even if the duration parameter is
233 * greater than the limit.
236 result Start(long milliseconds, int level = 0);
239 * Turns the vibrator off.
243 * @privilege %http://tizen.org/privilege/vibrator
245 * @return An error code
246 * @exception E_SUCCESS The method is successful.
247 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
248 * @exception E_DEVICE_FAILED The device operation has failed.
255 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
257 Vibrator(const Vibrator& value);
260 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
262 Vibrator& operator =(const Vibrator& value);
265 friend class _VibratorImpl;
266 class _VibratorImpl* __pVibratorImpl;