2 * Copyright (c) 2016-2021 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_INPUTMETHOD_DEVICE_EVENT_H__
18 #define __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__
21 * @file inputmethod_device_event.h
22 * @brief This file contains definitions for unconventional input device events.
30 * @addtogroup CAPI_UIX_INPUTMETHOD_MODULE
35 * @brief The handle to retrieve unconventional input device specific event data.
37 * @since_tizen @if WEARABLE 3.0 @endif
39 * @see ime_event_set_process_input_device_event_cb()
41 typedef void *ime_input_device_event_h;
44 * @brief Enumeration of unconventional input devices.
46 * @since_tizen @if WEARABLE 3.0 @endif
48 * @see ime_event_set_process_input_device_event_cb()
51 IME_INPUT_DEVICE_TYPE_UNKNOWN, /**< Undefined unconventional input device */
52 IME_INPUT_DEVICE_TYPE_ROTARY, /**< A rotary input device such as bezel that can be found on a wearable device */
53 } ime_input_device_type_e;
56 * @brief Enumeration of directions for rotary input device's rotation event.
58 * @since_tizen @if WEARABLE 3.0 @endif
60 * @see ime_input_device_rotary_get_direction()
64 IME_INPUT_DEVICE_ROTARY_DIRECTION_CLOCKWISE, /**< Rotary is rotated clockwise direction */
65 IME_INPUT_DEVICE_ROTARY_DIRECTION_COUNTER_CLOCKWISE /**< Rotary is rotated counter clockwise direction */
66 } ime_input_device_rotary_direction_e;
69 * @brief Called when the input event is received from an unconventional input device that does not generate key events.
71 * @details This function processes the input event before an associated text input UI control does.
73 * @since_tizen @if WEARABLE 3.0 @endif
75 * @remarks @a device_type contains the information what kind of unconventional input device generated the given event,
76 * and the handle @a device_event is used for obtaining device-specific input device event data.
77 * @a device_event should not be released.
79 * @param[in] device_type The unconventional input device type
80 * @param[in] device_event The handle for device_type specific input device event
81 * @param[in] user_data User data to be passed to the callback function
83 * @pre The callback can be registered using ime_event_set_input_device_event_cb() function.
85 * @see ime_event_set_process_input_device_event_cb()
87 typedef void(*ime_process_input_device_event_cb)(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data);
90 * @brief Sets @c process_input_device_event event callback function.
92 * @since_tizen @if WEARABLE 3.0 @endif
96 * @privilege %http://tizen.org/privilege/ime
98 * @remarks The ime_process_input_device_event_cb() callback function is called when the event
99 * is received from unconventional input devices that needs to be handled by IMEs.
101 * @param[in] callback_func @c inputmethod_process_input_device_event_cb callback function
102 * @param[in] user_data User data to be passed to the callback function
104 * @return 0 on success, otherwise a negative error value
105 * @retval #IME_ERROR_NONE No error
106 * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
107 * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
108 * @retval #IME_ERROR_OPERATION_FAILED Operation failed
110 * @post The ime_run() function should be called to start to run IME application's main loop.
112 * @see ime_process_input_device_event_cb()
113 * @see ime_event_unset_process_input_device_event_cb()
117 static void inputmethod_create_cb(void *user_data);
118 static void inputmethod_terminate_cb(void *user_data);
119 static void inputmethod_show_cb(int context_id, ime_context_h context, void *user_data);
120 static void inputmethod_hide_cb(int context_id, void *user_data);
122 static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event, void *user_data)
124 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
125 dlog_print(DLOG_INFO, "INPUTMETHOD", "Input device type is rotary\n");
129 void ime_app_main(int argc, char **argv)
131 ime_callback_s basic_callback = {
132 inputmethod_create_cb,
133 inputmethod_terminate_cb,
138 ime_event_set_process_input_device_event_cb(inputmethod_process_input_device_event_cb, NULL);
140 ime_run(&basic_callback, NULL);
145 int ime_event_set_process_input_device_event_cb(ime_process_input_device_event_cb callback_func, void *user_data);
148 * @brief Unsets @c process_input_device_event event callback function.
150 * @since_tizen @if WEARABLE 3.0 @endif
154 * @privilege %http://tizen.org/privilege/ime
156 * @remarks The ime_process_input_device_event_cb() callback function is called when the event
157 * is received from unconventional input devices that needs to be handled by IMEs.
159 * @return 0 on success, otherwise a negative error value
160 * @retval #IME_ERROR_NONE No error
161 * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
162 * @retval #IME_ERROR_OPERATION_FAILED Operation failed
164 * @see ime_process_input_device_event_cb()
165 * @see ime_event_set_process_input_device_event_cb()
167 int ime_event_unset_process_input_device_event_cb(void);
170 * @brief Gets the direction of the rotary input device event
172 * If the device_type parameter of the ime_process_input_device_event_cb() function indicates
173 * the current input device type is #IME_INPUT_DEVICE_TYPE_ROTARY, then the device_event parameter
174 * can be used to retrieve rotary device specific parameters, such as direction, as shown in the sample code.
176 * @since_tizen @if WEARABLE 3.0 @endif
180 * @privilege %http://tizen.org/privilege/ime
182 * @param[in] event_handle The input device event handle
183 * @param[out] direction The direction that the rotary input device was rotated to
185 * @return 0 on success, otherwise a negative error value
186 * @retval #IME_ERROR_NONE No error
187 * @retval #IME_ERROR_PERMISSION_DENIED The application does not have the privilege to call this function
188 * @retval #IME_ERROR_INVALID_PARAMETER Invalid parameter
189 * @retval #IME_ERROR_NOT_RUNNING IME main loop isn't started yet
191 * @see ime_input_device_rotary_direction_e
192 * @see ime_process_input_device_event_cb()
195 static void inputmethod_process_input_device_event_cb(ime_input_device_type_e device_type, ime_input_device_event_h device_event)
197 if (device_type == IME_INPUT_DEVICE_TYPE_ROTARY) {
198 ime_input_device_rotary_direction_e direction;
199 if (IME_ERROR_NONE == ime_input_device_rotary_get_direction(device_event, &direction)) {
200 dlog_print(DLOG_INFO, "INPUTMETHOD", "Direction : %d", direction);
206 int ime_input_device_rotary_get_direction(ime_input_device_event_h event_handle, ime_input_device_rotary_direction_e *direction);
216 #endif /* __TIZEN_UIX_INPUTMETHOD_DEVICE_EVENT_H__ */