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 #ifndef __FEEDBACK_H__
20 #define __FEEDBACK_H__
22 #include <tizen_error.h>
23 #include "feedback-ids.h"
31 * @brief This file contains the feedback API
35 * @addtogroup CAPI_SYSTEM_FEEDBACK_MODULE
40 * @brief Enumerations of error codes for the Feedback API.
45 FEEDBACK_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
46 FEEDBACK_ERROR_OPERATION_FAILED = TIZEN_ERROR_NOT_PERMITTED, /**< Operation not permitted */
47 FEEDBACK_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
48 FEEDBACK_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported in this device */
49 FEEDBACK_ERROR_NOT_INITIALIZED = TIZEN_ERROR_SYSTEM_CLASS | 0x52, /**< Has not yet been Initialized */
52 #define FEEDBACK_SUCCEEDED(n) ((n) == FEEDBACK_ERROR_NONE)
53 #define FEEDBACK_FAILED(n) ((n) != FEEDBACK_ERROR_NONE)
56 * @brief Initializes feedback API.
61 * If this function is not called in advance, other function will return #FEEDBACK_ERROR_NOT_INITIALIZED.
63 * @return 0 on success, otherwise a negative error value.
64 * @retval #FEEDBACK_ERROR_NONE Successful
65 * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed
66 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
68 * @see feedback_deinitialize()
70 int feedback_initialize(void);
73 * @brief Deinitializes feedback API.
74 * @details This function must be called when feedback functions are no longer needed.
78 * @return 0 on success, otherwise a negative error value.
79 * @retval #FEEDBACK_ERROR_NONE Successful
80 * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed
81 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
83 * @see feedback_initialize()
85 int feedback_deinitialize(void);
88 * @brief Plays various types of reactions that are pre-defined.
90 * This functon can be used to react to pre-defined actions. \n
91 * It play various types of system pre-defined media or vibration patterns.
96 * Currently, there are two types of reactions: sound and vibration. \n
97 * Depending on the settings, some types cannot operate.
98 * For example, when set to silent mode, the device doesn't produce any sound.
100 * @param[in] pattern The pre-defined pattern
102 * @return 0 on success, otherwise a negative error value.
103 * @retval #FEEDBACK_ERROR_NONE Successful
104 * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
105 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
107 int feedback_play(feedback_pattern_e pattern);
111 * @brief Plays specific type of reactions that are pre-defined.
113 * This function can be used to react to pre-defined actions. \n
114 * It play specific type of system pre-defined pattern.
119 * Currently, there are two types of reactions: sound and vibration.
121 * @param[in] type The pattern type
122 * @param[in] pattern The pre-defined pattern
124 * @return 0 on success, otherwise a negative error value.
125 * @retval #FEEDBACK_ERROR_NONE Successful
126 * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
127 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
129 int feedback_play_type(feedback_type_e type, feedback_pattern_e pattern);
133 * @brief Plays specific type of reactions that are pre-defined.
135 * This function can be used to react to pre-defined actions. \n
136 * It play specific type of system pre-defined pattern.
141 * Currently, there are two types of reactions: sound and vibration.
143 * @param[in] type string The pattern type
144 * @param[in] pattern string The pre-defined pattern
146 * @return 0 on success, otherwise a negative error value.
147 * @retval #FEEDBACK_ERROR_NONE Successful
148 * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
149 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
151 int feedback_play_type_by_name(char *type, char *pattern);
154 * @brief Stop various types of reactions
156 * This functon can be used to stop react to pre-defined actions. \n
157 * It stops various types of system pre-defined media or vibration patterns.
161 * @return 0 on success, otherwise a negative error value.
162 * @retval #FEEDBACK_ERROR_NONE Successful
163 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
165 int feedback_stop(void);
168 * @brief Gets the file path of resource for the given feedback type and pattern.
170 * Depending on the type of each pattern resouorce has a different format. \n
171 * Currently, System supports two pattern types. \n
172 * #FEEDBACK_TYPE_SOUND type uses .wav format. \n
173 * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n
174 * If the given pattern doesn't have a file for the type, @a path will return NULL.
178 * @remarks @a path must be released with free() by you.
180 * @param[in] type The pattern type
181 * @param[in] pattern The pre-defined pattern
182 * @param[out] path The file path of resource for feedback type and pattern
184 * @return 0 on success, otherwise a negative error value.
185 * @retval #FEEDBACK_ERROR_NONE Successful
186 * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
187 * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed
188 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
190 int feedback_get_resource_path(feedback_type_e type, feedback_pattern_e pattern, char **path);
193 * @brief Sets the new file path of resource for the given feedback type and pattern.
195 * Depending on the type of each pattern resouorce has a different format. \n
196 * Currently, System supports two pattern types. \n
197 * #FEEDBACK_TYPE_SOUND type uses .wav format. \n
198 * #FEEDBACK_TYPE_VIBRATION type uses .ivt format. \n
199 * If the given pattern doesn't have a file for the type, @a path will return NULL.
203 * @param[in] type The pattern type
204 * @param[in] pattern The pre-defined pattern
205 * @param[in] path The new file path of resource for feedback type and pattern
207 * @return 0 on success, otherwise a negative error value.
208 * @retval #FEEDBACK_ERROR_NONE Successful
209 * @retval #FEEDBACK_ERROR_INVALID_PARAMETER Invalid parameter
210 * @retval #FEEDBACK_ERROR_OPERATION_FAILED Operation failed
211 * @retval #FEEDBACK_ERROR_NOT_SUPPORTED Not supported device
213 int feedback_set_resource_path(feedback_type_e type, feedback_pattern_e pattern, char *path);
223 #endif //__FEEDBACK_H__