2 * Copyright (c) 2019 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_REMOTE_INPUT_H__
18 #define __TIZEN_UIX_REMOTE_INPUT_H__
22 * @file remote_input.h
23 * @brief This file contains remote input APIs and related enumeration.
27 #include <Ecore_IMF.h>
34 * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE
41 * @brief Enumeration for remote input function error.
45 REMOTE_INPUT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
46 REMOTE_INPUT_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
47 REMOTE_INPUT_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
48 REMOTE_INPUT_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
49 REMOTE_INPUT_OPERATION_FAILED, /**< Operation failed */
50 } remote_input_error_e;
54 * @brief Enumeration for key types.
56 * @see remote_input_send_key_event()
59 REMOTE_INPUT_KEY_ENTER = 0, /**< Enter key */
60 REMOTE_INPUT_KEY_SPACE, /**< Space key */
61 REMOTE_INPUT_KEY_BACKSPACE, /**< Backspace key */
62 REMOTE_INPUT_KEY_ESC, /**< Escape key */
63 REMOTE_INPUT_KEY_UP, /**< Up key */
64 REMOTE_INPUT_KEY_DOWN, /**< Down key */
65 REMOTE_INPUT_KEY_LEFT, /**< LEFT key */
66 REMOTE_INPUT_KEY_RIGHT, /**< Right key */
67 REMOTE_INPUT_KEY_PAGE_UP, /**< Page up key */
68 REMOTE_INPUT_KEY_PAGE_DOWN, /**< Page down key */
69 REMOTE_INPUT_KEY_SELECT, /**< Select key */
70 REMOTE_INPUT_KEY_CANCEL, /**< Cancel key */
71 } remote_input_key_type_e;
75 * @brief Enumeration for input resources.
77 * @see remote_input_resource_changed_cb()
80 REMOTE_INPUT_RESOURCE_LOCAL = 0, /**< Input event from IME, H/W keyboard */
81 REMOTE_INPUT_RESOURCE_REMOTE, /**< Input event from remote input API */
82 } remote_input_resource_e;
86 * @brief Handle of the remote input.
89 typedef struct remote_input_s *remote_input_h;
93 * @brief Called when an associated text field has focus.
95 * @param[in] user_data User data to be passed to the callback function
96 * @pre The callback can be registered using remote_input_focus_in_callback_set() function.
97 * @see remote_input_focus_in_callback_set()
98 * @see remote_input_focus_in_callback_unset()
100 typedef void (*remote_input_focus_in_cb)(void *user_data);
104 * @brief Called when an associated text field loses focus.
106 * @param[in] user_data User data to be passed to the callback function
107 * @pre The callback can be registered using remote_input_focus_out_callback_set() function.
108 * @see remote_input_focus_out_callback_set()
109 * @see remote_input_focus_out_callback_unset()
111 typedef void (*remote_input_focus_out_cb)(void *user_data);
115 * @brief Called when an associated text field requests the input panel to set its attributes.
117 * @remarks This callback will be called after remote_input_focus_in_cb().
118 * It can be called again when the associated text field's attributes are changed.
119 * Remote IME application should configure its input panel with various attributes.
120 * @param[in] user_data User data to be passed to the callback function
121 * @pre The callback can be registered using remote_input_metadata_updated_callback_set() function.
122 * @see remote_input_metadata_updated_callback_set()
123 * @see remote_input_metadata_updated_callback_unset()
124 * @see remote_input_get_input_hint()
125 * @see remote_input_get_layout()
126 * @see remote_input_get_layout_variation()
127 * @see remote_input_get_autocapital_type()
128 * @see remote_input_get_return_key_state()
129 * @see remote_input_get_return_key_type()
131 typedef void (*remote_input_metadata_updated_cb)(void *user_data);
135 * @brief Called when an associated text field responds to a request with the surrounding text.
137 * @remarks This callback will be called after remote_input_metadata_updated_cb().
138 * It can be called again when the text or the cursor position in the associated text field is changed.
139 * @a text can be used only in the callback. To use outside, make a copy.
140 * @param[in] text The UTF-8 string requested
141 * @param[in] cursor_pos The cursor position
142 * @param[in] user_data User data to be passed to the callback function
143 * @pre The callback can be registered using remote_input_text_updated_callback_set() function.
144 * @see remote_input_text_updated_callback_set()
145 * @see remote_input_text_updated_callback_unset()
147 typedef void (*remote_input_text_updated_cb)(const char *text, int cursor_pos, void *user_data);
151 * @brief Called when the input resource is changed.
153 * @param[in] resource The input resource
154 * @param[in] user_data User data to be passed to the callback function
155 * @pre The callback can be registered using remote_input_resource_changed_callback_set() function.
156 * @see remote_input_resource_changed_callback_set()
157 * @see remote_input_resource_changed_callback_unset()
159 typedef void (*remote_input_resource_changed_cb)(remote_input_resource_e resource, void *user_data);
163 * @brief Creates a remote input handle.
165 * @privlevel platform
166 * @privilege %http://tizen.org/privilege/internal/default/platform
167 * @remarks If the function succeeds, @a remote_handle must be released with remote_input_destroy().
168 * @param[out] remote_handle The remote input handle
169 * @return 0 on success, otherwise a negative error value
170 * @retval #REMOTE_INPUT_ERROR_NONE Successful
171 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
172 * @retval #REMOTE_INPUT_PERMISSION_DENIED Permission denied
173 * @retval #REMOTE_INPUT_OUT_OF_MEMORY Out of memory
174 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure
175 * @see remote_input_destroy()
177 int remote_input_create(remote_input_h *remote_handle);
181 * @brief Destroys a remote input handle.
183 * @param[in] remote_handle The remote input handle
184 * @return 0 on success, otherwise a negative error value
185 * @retval #REMOTE_INPUT_ERROR_NONE Successful
186 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
187 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failed
188 * @see remote_input_create()
190 int remote_input_destroy(remote_input_h remote_handle);
194 * @brief Sets a callback function to be called when an associated text field has focus.
196 * @param[in] remote_handle The remote input handle
197 * @param[in] callback The callback function to register
198 * @param[in] user_data User data to be passed to the callback function
199 * @return 0 on success, otherwise a negative error value
200 * @retval #REMOTE_INPUT_ERROR_NONE Successful
201 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
202 * @see remote_input_focus_in_callback_unset()
204 int remote_input_focus_in_callback_set(remote_input_h remote_handle, remote_input_focus_in_cb callback, void *user_data);
208 * @brief Unsets the callback function.
210 * @param[in] remote_handle The remote input handle
211 * @return 0 on success, otherwise a negative error value
212 * @retval #REMOTE_INPUT_ERROR_NONE Successful
213 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
214 * @see remote_input_focus_in_callback_set()
216 int remote_input_focus_in_callback_unset(remote_input_h remote_handle);
220 * @brief Sets a callback function to be called when an associated text field loses focus.
222 * @param[in] remote_handle The remote input handle
223 * @param[in] callback The callback function to register
224 * @param[in] user_data User data to be passed to the callback function
225 * @return 0 on success, otherwise a negative error value
226 * @retval #REMOTE_INPUT_ERROR_NONE Successful
227 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
228 * @see remote_input_focus_out_callback_unset()
230 int remote_input_focus_out_callback_set(remote_input_h remote_handle, remote_input_focus_out_cb callback, void *user_data);
234 * @brief Unsets the callback function.
236 * @param[in] remote_handle The remote input handle
237 * @return 0 on success, otherwise a negative error value
238 * @retval #REMOTE_INPUT_ERROR_NONE Successful
239 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
240 * @see remote_input_focus_out_callback_set()
242 int remote_input_focus_out_callback_unset(remote_input_h remote_handle);
246 * @brief Sets a callback function to be called when an associated text field requests the input panel to set its attributes.
248 * @param[in] remote_handle The remote input handle
249 * @param[in] callback The callback function to register
250 * @param[in] user_data User data to be passed to the callback function
251 * @return 0 on success, otherwise a negative error value
252 * @retval #REMOTE_INPUT_ERROR_NONE Successful
253 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
254 * @see remote_input_metadata_updated_callback_unset()
256 int remote_input_metadata_updated_callback_set(remote_input_h remote_handle, remote_input_metadata_updated_cb callback, void *user_data);
260 * @brief Unsets the callback function.
262 * @param[in] remote_handle The remote input handle
263 * @return 0 on success, otherwise a negative error value
264 * @retval #REMOTE_INPUT_ERROR_NONE Successful
265 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
266 * @see remote_input_metadata_updated_callback_set()
268 int remote_input_metadata_updated_callback_unset(remote_input_h remote_handle);
272 * @brief Sets a callback function to be called when an associated text field responds to a request with the surrounding text.
274 * @param[in] remote_handle The remote input handle
275 * @param[in] callback The callback function to register
276 * @param[in] user_data User data to be passed to the callback function
277 * @return 0 on success, otherwise a negative error value
278 * @retval #REMOTE_INPUT_ERROR_NONE Successful
279 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
280 * @see remote_input_text_updated_callback_unset()
282 int remote_input_text_updated_callback_set(remote_input_h remote_handle, remote_input_text_updated_cb callback, void *user_data);
286 * @brief Unsets the callback function.
288 * @param[in] remote_handle The remote input handle
289 * @return 0 on success, otherwise a negative error value
290 * @retval #REMOTE_INPUT_ERROR_NONE Successful
291 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
292 * @see remote_input_text_updated_callback_set()
294 int remote_input_text_updated_callback_unset(remote_input_h remote_handle);
298 * @brief Sets a callback function to be called when the input resource is changed.
300 * @param[in] remote_handle The remote input handle
301 * @param[in] callback The callback function to register
302 * @param[in] user_data User data to be passed to the callback function
303 * @return 0 on success, otherwise a negative error value
304 * @retval #REMOTE_INPUT_ERROR_NONE Successful
305 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
306 * @see remote_input_resource_changed_callback_unset()
308 int remote_input_resource_changed_callback_set(remote_input_h remote_handle, remote_input_resource_changed_cb callback, void *user_data);
312 * @brief Unsets the callback function.
314 * @param[in] remote_handle The remote input handle
315 * @return 0 on success, otherwise a negative error value
316 * @retval #REMOTE_INPUT_ERROR_NONE Successful
317 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
318 * @see remote_input_resource_changed_callback_set()
320 int remote_input_resource_changed_callback_unset(remote_input_h remote_handle);
324 * @brief Gets the input hint information.
325 * @details Each edit field has various attributes for input panel.
326 * This function can be called to get the input hint information in remote_input_metadata_updated_cb() callback function.
328 * @remarks @a input_hint is a bit-wise value which recommends the input panel provide an auto completion and so on
329 * if it is capable of supporting such features.
330 * @param[in] remote_handle The remote input handle
331 * @param[out] input_hint Input hint information
332 * @return 0 on success, otherwise a negative error value
333 * @retval #REMOTE_INPUT_ERROR_NONE Successful
334 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
335 * @post Remote input panel UI should be drawn or operated by this information accordingly.
336 * @see remote_input_metadata_updated_cb()
338 int remote_input_get_input_hint(remote_input_h remote_handle, Ecore_IMF_Input_Hints *input_hint);
342 * @brief Gets the layout information.
343 * @details Each edit field has various attributes for input panel.
344 * This function can be called to get the layout information in remote_input_metadata_updated_cb() callback function.
346 * @param[in] remote_handle The remote input handle
347 * @param[out] layout Layout information
348 * @return 0 on success, otherwise a negative error value
349 * @retval #REMOTE_INPUT_ERROR_NONE Successful
350 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
351 * @post Remote input panel UI should be drawn or operated by this information accordingly.
352 * @see remote_input_metadata_updated_cb()
354 int remote_input_get_layout(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Layout *layout);
358 * @brief Gets the layout variation information.
359 * @details Each edit field has various attributes for input panel.
360 * This function can be called to get the layout variation information in remote_input_metadata_updated_cb() callback function.
362 * @param[in] remote_handle The remote input handle
363 * @param[out] variation The layout variation
364 * @return 0 on success, otherwise a negative error value
365 * @retval #REMOTE_INPUT_ERROR_NONE Successful
366 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
367 * @post Remote input panel UI should be drawn or operated by this information accordingly.
368 * @see remote_input_metadata_updated_cb()
370 int remote_input_get_layout_variation(remote_input_h remote_handle, int *variation);
374 * @brief Gets the autocapital type information.
375 * @details Each edit field has various attributes for input panel.
376 * This function can be called to get the autocapital type information in remote_input_metadata_updated_cb() callback function.
378 * @param[in] remote_handle The remote input handle
379 * @param[out] autocapital_type autocapital_type Autocapital type information
380 * @return 0 on success, otherwise a negative error value
381 * @retval #REMOTE_INPUT_ERROR_NONE Successful
382 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
383 * @post Remote input panel UI should be drawn or operated by this information accordingly.
384 * @see remote_input_metadata_updated_cb()
386 int remote_input_get_autocapital_type(remote_input_h remote_handle, Ecore_IMF_Autocapital_Type *autocapital_type);
390 * @brief Gets the return key state information.
391 * @details Each edit field has various attributes for input panel.
392 * This function can be called to get the return key state information in remote_input_metadata_updated_cb() callback function.
394 * @param[in] remote_handle The remote input handle
395 * @param[out] return_key_state The return key state information \n @c true to enable return key button, @c false to disable return key button
396 * @return 0 on success, otherwise a negative error value
397 * @retval #REMOTE_INPUT_ERROR_NONE Successful
398 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
399 * @post Remote input panel UI should be drawn or operated by this information accordingly.
400 * @see remote_input_metadata_updated_cb()
402 int remote_input_get_return_key_state(remote_input_h remote_handle, bool *return_key_state);
406 * @brief Gets the return key label type information.
407 * @details Each edit field has various attributes for input panel.
408 * This function can be called to get the return key label type information in remote_input_metadata_updated_cb() callback function.
410 * @param[in] remote_handle The remote input handle
411 * @param[out] return_key_type The return key label type information
412 * @return 0 on success, otherwise a negative error value
413 * @retval #REMOTE_INPUT_ERROR_NONE Successful
414 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
415 * @post Remote input panel UI should be drawn or operated by this information accordingly.
416 * @see remote_input_metadata_updated_cb()
418 int remote_input_get_return_key_type(remote_input_h remote_handle, Ecore_IMF_Input_Panel_Return_Key_Type *return_key_type);
422 * @brief Sends a key event to the associated text field.
424 * @remarks This function must be used if an associated text field has focus.
425 * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned.
426 * @param[in] remote_handle The remote input handle
427 * @param[in] key The key type
428 * @return 0 on success, otherwise a negative error value
429 * @retval #REMOTE_INPUT_ERROR_NONE Successful
430 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
431 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure
433 int remote_input_send_key_event(remote_input_h remote_handle, remote_input_key_type_e key);
437 * @brief Sends a commit string to the associated text field.
439 * @remarks This function must be used if an associated text field has focus.
440 * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned.
441 * @param[in] remote_handle The remote input handle
442 * @param[in] text The UTF-8 string to be committed
443 * @return 0 on success, otherwise a negative error value
444 * @retval #REMOTE_INPUT_ERROR_NONE Successful
445 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
446 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure
448 int remote_input_send_commit_string(remote_input_h remote_handle, const char *text);
452 * @brief Updates a preedit string to the associated text field.
454 * @remarks This function must be used if an associated text field has focus.
455 * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned.
456 * @param[in] remote_handle The remote input handle
457 * @param[in] text The UTF-8 string to be committed
458 * @param[in] cursor_pos The cursor position; -1 means at the end of line
459 * @return 0 on success, otherwise a negative error value
460 * @retval #REMOTE_INPUT_ERROR_NONE Successful
461 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
462 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure
464 int remote_input_update_preedit_string(remote_input_h remote_handle, const char *text, int cursor_pos);
468 * @brief Requests to delete surrounding text.
470 * @remarks This function must be used if an associated text field has focus.
471 * Otherwise, #REMOTE_INPUT_OPERATION_FAILED will be returned.
472 * @param[in] remote_handle The remote input handle
473 * @param[in] offset The offset value from the cursor position
474 * @param[in] len The length of the text to delete
475 * @return 0 on success, otherwise a negative error value
476 * @retval #REMOTE_INPUT_ERROR_NONE Successful
477 * @retval #REMOTE_INPUT_INVALID_PARAMETER Invalid parameter
478 * @retval #REMOTE_INPUT_OPERATION_FAILED Operation failure
480 int remote_input_delete_surrounding_text(remote_input_h remote_handle, int offset, int len);
491 #endif /* __TIZEN_UIX_REMOTE_INPUT_H__ */