/**
* @platform
+ * @brief Called when a key event is occurred.
+ * @since_tizen 6.5
+ * @remarks This callback will be called after remote_input_focus_in_cb().
+ * @param[in] user_data User data to be passed to the callback function
+ * @pre The callback can be registered using remote_input_key_event_callback_set() function.
+ * @see remote_input_key_event_callback_set()
+ * @see remote_input_key_event_callback_unset()
+ */
+typedef void (*remote_input_key_event_cb)(void *user_data);
+
+/**
+ * @platform
* @brief Creates a remote input handle.
* @since_tizen 5.5
* @privlevel platform
*/
int remote_input_delete_surrounding_text(remote_input_h remote_handle, int offset, int len);
+/**
+ * @platform
+ * @brief Gets the key event type.
+ * @details This function can be called to get the key event type in remote_input_key_event_cb() callback function.
+ * @since_tizen 6.5
+ * @param[in] remote_handle The remote input handle
+ * @param[out] key_type The key event type
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_key_event_cb()
+ */
+int remote_input_get_key_type(remote_input_h remote_handle, remote_input_key_type_e *key_type);
+
+/**
+ * @platform
+ * @brief Gets whether the key is pressed.
+ * @details This function can be called to get the key event type in remote_input_key_event_cb() callback function.
+ * @since_tizen 6.5
+ * @param[in] remote_handle The remote input handle
+ * @param[out] pressed Whether the key is pressed or not
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_key_event_cb()
+ */
+int remote_input_get_key_pressed_state(remote_input_h remote_handle, bool *pressed);
+
+/**
+ * @platform
+ * @brief Gets the timestamp when the event occurred.
+ * @details This function can be called to get the key event type in remote_input_key_event_cb() callback function.
+ * @since_tizen 6.5
+ * @param[in] remote_handle The remote input handle
+ * @param[out] key_type The timestamp
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_key_event_cb()
+ */
+int remote_input_get_key_timestamp(remote_input_h remote_handle, int *timestamp);
+
+/**
+ * @platform
+ * @brief Sets a callback function to be called when the key event is occurred.
+ * @since_tizen 6.5
+ * @param[in] remote_handle The remote input handle
+ * @param[in] callback The callback function to register
+ * @param[in] user_data User data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_key_event_callback_unset()
+ */
+int remote_input_key_event_callback_set(remote_input_h remote_handle, remote_input_key_event_cb callback, void *user_data);
+
+/**
+ * @platform
+ * @brief Unsets the callback function.
+ * @since_tizen 6.5
+ * @param[in] remote_handle The remote input handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #REMOTE_INPUT_ERROR_NONE Successful
+ * @retval #REMOTE_INPUT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see remote_input_key_event_callback_set()
+ */
+int remote_input_key_event_callback_unset(remote_input_h remote_handle);
+
/**
* @}
Ecore_IMF_Autocapital_Type autocapital_type;
bool return_key_disabled;
Ecore_IMF_Input_Panel_Return_Key_Type return_key_type;
+ remote_input_key_type_e key_type;
+ bool key_pressed;
+ int timestamp;
remote_input_metadata_updated_cb metadata_updated_cb;
void *metadata_updated_cb_user_data;
remote_input_text_updated_cb text_updated_cb;
void *text_updated_cb_user_data;
remote_input_resource_changed_cb resource_changed_cb;
void *resource_changed_cb_user_data;
+ remote_input_key_event_cb key_event_cb;
+ void *key_event_cb_user_data;
};
#endif /* __TIZEN_UIX_REMOTE_INPUT_PRIVATE_H__ */
remote_handle->resource_changed_cb_user_data);
}
}
+
+static void _key_event_cb(void *user_data, remote_control_key_event_s *data)
+{
+ remote_input_h remote_handle = (remote_input_h)user_data;
+
+ if (remote_handle == NULL) {
+ LOGE("remote handle is not available");
+ return;
+ }
+
+ remote_handle->key_type = (remote_input_key_type_e)data->type;
+ remote_handle->key_pressed = data->pressed ? true : false;
+ remote_handle->timestamp = data->timestamp;
+
+ if (remote_handle->key_event_cb) {
+ remote_handle->key_event_cb(remote_handle->key_event_cb_user_data);
+ }
+}
//LCOV_EXCL_STOP
EXPORT_API int remote_input_create(remote_input_h *remote_handle)
}
return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_get_key_type(remote_input_h remote_handle, remote_input_key_type_e *key_type)
+{
+ if (!remote_handle || !key_type) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ *key_type = remote_handle->key_type;
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_get_key_pressed_state(remote_input_h remote_handle, bool *pressed)
+{
+ if (!remote_handle || !pressed) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ *pressed = remote_handle->key_pressed;
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_get_key_timestamp(remote_input_h remote_handle, int *timestamp)
+{
+ if (!remote_handle || !timestamp) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ *timestamp = remote_handle->timestamp;
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_key_event_callback_set(remote_input_h remote_handle, remote_input_key_event_cb callback, void *user_data)
+{
+ if (!remote_handle || !remote_handle->remote_client || !callback) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ remote_control_key_event_callback_set(remote_handle->remote_client, _key_event_cb, (void *)remote_handle);
+ remote_handle->key_event_cb = callback;
+ remote_handle->key_event_cb_user_data = user_data;
+
+ return REMOTE_INPUT_ERROR_NONE;
+}
+
+EXPORT_API int remote_input_key_event_callback_unset(remote_input_h remote_handle)
+{
+ if (!remote_handle || !remote_handle->remote_client) {
+ LOGE("REMOTE_INPUT_ERROR_INVALID_PARAMETER");
+ return REMOTE_INPUT_ERROR_INVALID_PARAMETER;
+ }
+
+ remote_control_key_event_callback_unset(remote_handle->remote_client);
+ remote_handle->key_event_cb = NULL;
+ remote_handle->key_event_cb_user_data = NULL;
+
+ return REMOTE_INPUT_ERROR_NONE;
}
\ No newline at end of file
EXPECT_EQ(ret, REMOTE_INPUT_ERROR_INVALID_PARAMETER);
}
+TEST_F(RemoteInputTest, utc_remote_input_key_event_callback_set_n)
+{
+ int ret = remote_input_key_event_callback_set(NULL, NULL, NULL);
+ EXPECT_EQ(ret, REMOTE_INPUT_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(RemoteInputTest, utc_remote_input_key_event_callback_unset_n)
+{
+ int ret = remote_input_key_event_callback_unset(NULL);
+ EXPECT_EQ(ret, REMOTE_INPUT_ERROR_INVALID_PARAMETER);
+}
+
TEST_F(RemoteInputTest, utc_remote_input_get_input_hint_n)
{
Ecore_IMF_Input_Hints input_hint;