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 you to manage the device's vibrator parameters, such as 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 has the specified duration and a vibration intensity level.
89 * The %IntensityDurationVibrationPattern struct has the specified duration and a vibration intensity level. This 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 is not allowed 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.
117 * @remarks The object is not fully constructed after this constructor is called. 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 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 canceled 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 the system alert occurs such as ring vibration and a system event notification, the vibration can be interrupted. @n
150 * If the application is terminated, the vibration is canceled.
153 * @privilege %http://tizen.org/privilege/vibrator
155 * @return An error code
157 * @param[in] patterns An array of @c IntensityDurationVibrationPattern
158 * @param[in] length The length of @c patterns
159 * @param[in] repeatCount The number of times the pattern repeats @n This value must be between @c 1 to @c 100.
160 * @exception E_SUCCESS The method is successful.
161 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
162 * @exception E_INVALID_ARG A specified input parameter is invalid.
163 * @exception E_OPERATION_FAILED The device operation has failed.
164 * @remarks The vibration intensity does not apply the change, even if the system default vibration intensity is changed after starting vibration.
165 * @see IntensityDurationVibrationPattern
167 result Start(IntensityDurationVibrationPattern* patterns, int length, int repeatCount = 1);
170 * Vibrates the device with the specified pattern and level. @n
171 * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
172 * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
174 * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
177 * @privilege %http://tizen.org/privilege/vibrator
179 * @return An error code
180 * @param[in] onPeriod The period in milliseconds when the vibrator is on @n
181 * It should be greater than @c 0.
182 * @param[in] offPeriod The period in milliseconds when the vibrator is off @n
183 * It should be equal to or greater than @c 0.
184 * @param[in] count The number of times to execute the given pattern @n
185 * It should be greater than @c 0.
186 * @param[in] level The vibration level @n
187 * Ranges from [@c 0~ @c 100], where '@c 0' is a special case indicating the system default level.
188 * @exception E_SUCCESS The method is successful.
189 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
190 * @exception E_INVALID_ARG A specified input parameter is invalid.
191 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
192 * @exception E_DEVICE_FAILED The device operation has failed.
193 * @remarks Various devices may have different vibration capabilities.
194 * If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
195 * 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 frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
196 * 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 greater than the limit.
199 result Start(long onPeriod, long offPeriod, int count, int level = 0);
202 * Vibrates the device for the specified duration at the specified @c level. @n
203 * The %Start() method returns the result immediately so that the vibration occurs simultaneously as the device runs.
204 * If this method is called again before the previous vibration stops, the previous vibration is canceled and the new vibration starts immediately.
206 * @deprecated This method is deprecated. Instead of using this method, use Start(IntensityDurationVibrationPattern*, int, int).
209 * @privilege %http://tizen.org/privilege/vibrator
211 * @return An error code
212 * @param[in] milliseconds The duration for the vibration in milliseconds @n
213 * It should be greater than @c 0.
214 * @param[in] level The vibration level @n
215 * Ranges from [@c 0~ @c 100], where ' @c 0' is a special case indicating the system default level.
216 * @exception E_SUCCESS The method is successful.
217 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
218 * @exception E_INVALID_ARG A specified input parameter is invalid.
219 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
220 * @exception E_DEVICE_FAILED The device operation has failed.
221 * @remarks Various devices have different vibration capabilities. @n
222 * If the device supports only one level of vibration, then a level value between [@c 0~ @c 100] results in the default vibration.
223 * 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 frequency vibration, value @c 100 results in the highest frequency vibration, and intermediate values result in intermediate vibration levels. @n
224 * 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 greater than the limit.
227 result Start(long milliseconds, int level = 0);
230 * Turns the vibrator off.
234 * @privilege %http://tizen.org/privilege/vibrator
236 * @return An error code
237 * @exception E_SUCCESS The method is successful.
238 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
239 * @exception E_DEVICE_FAILED The device operation has failed.
246 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
248 Vibrator(const Vibrator& value);
251 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
253 Vibrator& operator =(const Vibrator& value);
256 friend class _VibratorImpl;
257 class _VibratorImpl* __pVibratorImpl;