2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 #ifndef __TIZEN_UIX_GESTURE_H__
18 #define __TIZEN_UIX_GESTURE_H__
20 #include <gesture_common.h>
28 * @brief This file contains hand gesture's APIs.
32 * @addtogroup CAPI_UIX_GESTURE_MODULE
37 * @brief The hand gesture handle.
38 * @since_tizen @if WEARABLE 6.0 @endif
40 typedef struct hand_gesture_s *hand_gesture_h;
43 * @brief Called when a gesture is detected.
44 * @details Following error codes can be delivered: \n
45 * #HAND_GESTURE_ERROR_NONE, \n
46 * #HAND_GESTURE_ERROR_NOT_SUPPORTED, \n
47 * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n
48 * #HAND_GESTURE_ERROR_OPERATION_FAILED
50 * @since_tizen @if WEARABLE 6.0 @endif
51 * @remarks The @a handle is managed by the platform and will be released when hand_gesture_destroy() is called.
53 * @param[in] handle A gesture handle
54 * @param[in] gesture A gesture type detected
55 * @param[in] timestamp The time when the gesture is detected. Epoch time in seconds.
56 * @param[in] error An error value. It can be one of the following error values: \n
57 * #HAND_GESTURE_ERROR_NONE, if the operation succeeded.\n
58 * #HAND_GESTURE_ERROR_NOT_SUPPORTED, if the gesture is not supported on the device.\n
59 * #HAND_GESTURE_ERROR_INVALID_PARAMETER, if the parameter is invalid. \n
60 * #HAND_GESTURE_ERROR_OPERATION_FAILED, if the operation failed because of a system error.
61 * @param[in] user_data The user data is passed to hand_gesture_start_recognition()
63 * @see hand_gesture_start_recognition()
65 typedef void(* hand_gesture_recognition_cb)(hand_gesture_h handle, hand_gesture_type_e gesture, double timestamp, hand_gesture_error_e error, void *user_data);
68 * @brief Called when an error is occurred.
69 * @details Following error codes can be delivered: \n
70 * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n
71 * #HAND_GESTURE_ERROR_INVALID_OPERATION, \n
72 * #HAND_GESTURE_ERROR_OUT_OF_MEMORY, \n
73 * #HAND_GESTURE_ERROR_OPERATION_FAILED
75 * @since_tizen @if WEARABLE 6.0 @endif
76 * @remarks The @a handle is the same object for which the callback was set.
77 * The @a handle is available until hand_gesture_destroy() is called.
78 * The @a msg is managed by the platform and will be released when invoking this callback function is finished.
80 * @param[in] handle A gesture handle
81 * @param[in] error An error value. It can be one of the following error values: \n
82 * #HAND_GESTURE_ERROR_INVALID_PARAMETER, \n
83 * #HAND_GESTURE_ERROR_INVALID_OPERATION, \n
84 * #HAND_GESTURE_ERROR_OUT_OF_MEMORY, \n
85 * #HAND_GESTURE_ERROR_OPERATION_FAILED
86 * @param[in] msg An error message from gesture engine service
87 * @param[in] user_data The user data is passed to hand_gesture_set_error_cb()
89 * @see hand_gesture_set_error_cb()
90 * @see hand_gesture_unset_error_cb()
92 typedef void(* hand_gesture_error_cb)(hand_gesture_h handle, hand_gesture_error_e error, const char* msg, void *user_data);
95 * @brief Checks whether a gesture is supported or not.
96 * @details Check if the given gesture type is supported on the device.
98 * @since_tizen @if WEARABLE 6.0 @endif
100 * @param[in] handle A gesture handle
101 * @param[in] gesture A gesture type to be checked
102 * @param[out] supported @c true if the gesture is recognizable on the device,\n
105 * @return @c 0 if the @c gesture is supported, otherwise a negative error value
106 * @retval #HAND_GESTURE_ERROR_NONE Supported
107 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED The @c gesture is not supported
108 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
109 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
111 int hand_gesture_is_supported_type(hand_gesture_h handle, hand_gesture_type_e gesture, bool* supported);
114 * @brief Creates a gesture handle.
116 * @since_tizen @if WEARABLE 6.0 @endif
118 * @privilege %http://tizen.org/privilege/appmanager.launch
119 * @remarks If the function succeeds, @a handle must be released with hand_gesture_destroy().
121 * @param[out] handle A gesture handle
123 * @return 0 on success, otherwise a negative error value
124 * @retval #HAND_GESTURE_ERROR_NONE Successful
125 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Not supported
126 * @retval #HAND_GESTURE_ERROR_PERMISSION_DENIED Permission denied
127 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter
128 * @retval #HAND_GESTURE_ERROR_OUT_OF_MEMORY Out of memory
129 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed
131 * @see hand_gesture_destroy()
133 int hand_gesture_create(hand_gesture_h *handle);
136 * @brief Destroys a gesture handle.
138 * @since_tizen @if WEARABLE 6.0 @endif
140 * @param[in] handle A gesture handle
142 * @return 0 on success, otherwise a negative error value
143 * @retval #HAND_GESTURE_ERROR_NONE Successful
144 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Not supported
145 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter
146 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed
148 * @see hand_gesture_create()
150 int hand_gesture_destroy(hand_gesture_h handle);
153 * @brief Sets an option for gesture recognition.
155 * @since_tizen @if WEARABLE 6.0 @endif
156 * @remarks If you would like to set a gesture option, you should call this function before hand_gesture_start_recognition() is invoked. \n
157 * If you do not call this function, #HAND_GESTURE_OPTION_DEFAULT will be set as the default option.
159 * @param[in] handle A gesture handle used to control the gesture event
160 * @param[in] option An option for detecting gestures
162 * @return @c 0 on success, otherwise a negative error value
163 * @retval #HAND_GESTURE_ERROR_NONE Successful
164 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
165 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
166 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
168 * @see hand_gesture_start_recognition()
170 int hand_gesture_set_option(hand_gesture_h handle, hand_gesture_option_e option);
173 * @brief Starts to recognize a gesture.
174 * @details Sets a callback function to be invoked when the gesture is detected, and starts to monitor occurrences of the gesture.
176 * @since_tizen @if WEARABLE 6.0 @endif
178 * @privilege %http://tizen.org/privilege/appmanager.launch
180 * @param[in] handle A gesture handle used to control the gesture event
181 * @param[in] gesture A gesture type to be monitored
182 * @param[in] callback A callback function to receive gesture events
183 * @param[in] user_data A user data to be passed to the callback function
185 * @return @c 0 on success, otherwise a negative error value
186 * @retval #HAND_GESTURE_ERROR_NONE Successful
187 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
188 * @retval #HAND_GESTURE_ERROR_PERMISSION_DENIED Permission denied
189 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
190 * @retval #HAND_GESTURE_ERROR_ALREADY_STARTED The @c handle is being used already
191 * @retval #HAND_GESTURE_ERROR_OUT_OF_MEMORY Out of memory
192 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
194 * @pre hand_gesture_create()
195 * @pre hand_gesture_set_option()
196 * @post hand_gesture_recognition_cb()
197 * @see hand_gesture_stop_recognition()
199 int hand_gesture_start_recognition(hand_gesture_h handle, hand_gesture_type_e gesture, hand_gesture_recognition_cb callback, void *user_data);
202 * @brief Stops recognizing the gesture registered to the gesture handle.
204 * @since_tizen @if WEARABLE 6.0 @endif
206 * @param[in] handle A gesture handle
208 * @return @c 0 on success, otherwise a negative error value
209 * @retval #HAND_GESTURE_ERROR_NONE Successful
210 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
211 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
212 * @retval #HAND_GESTURE_ERROR_NOT_STARTED Nothing is started using the @c handle
213 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
215 int hand_gesture_stop_recognition(hand_gesture_h handle);
218 * @brief Gets a gesture engine information.
220 * @since_tizen @if WEARABLE 6.0 @endif
221 * @remarks The @a engine_app_id and the @a engine_name should be released using free().
223 * @param[in] handle A gesture handle
224 * @param[out] engine_app_id A gesture engine app ID
225 * @param[out] engine_name A gesture engine name
227 * @return @c 0 on success, otherwise a negative error value
228 * @retval #HAND_GESTURE_ERROR_NONE Successful
229 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
230 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
231 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
233 int hand_gesture_get_engine_info(hand_gesture_h handle, char** engine_app_id, char** engine_name);
236 * @brief Sets a callback function to be invoked when an error is occurred.
238 * @since_tizen @if WEARABLE 6.0 @endif
240 * @param[in] handle A gesture handle
241 * @param[in] callback A callback function invoked when an error is occurred
242 * @param[in] user_data A user data to be passed to the callback function
244 * @return @c 0 on success, otherwise a negative error value
245 * @retval #HAND_GESTURE_ERROR_NONE Successful
246 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
247 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
248 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
250 * @see hand_gesture_error_cb()
251 * @see hand_gesture_unset_error_cb()
253 int hand_gesture_set_error_cb(hand_gesture_h handle, hand_gesture_error_cb callback, void *user_data);
256 * @brief Unsets a callback function to be invoked when an error is occurred.
258 * @since_tizen @if WEARABLE 6.0 @endif
260 * @param[in] handle A gesture handle
262 * @return @c 0 on success, otherwise a negative error value
263 * @retval #HAND_GESTURE_ERROR_NONE Successful
264 * @retval #HAND_GESTURE_ERROR_NOT_SUPPORTED Gesture recognition is not supported
265 * @retval #HAND_GESTURE_ERROR_INVALID_PARAMETER Invalid parameter used
266 * @retval #HAND_GESTURE_ERROR_OPERATION_FAILED Operation failed because of a system error
268 * @see hand_gesture_set_error_cb()
270 int hand_gesture_unset_error_cb(hand_gesture_h handle);
281 #endif /* __TIZEN_UIX_GESTURE_H__ */