Previous input dbus interface was initialized by input plugin part.
Thus, input dbus interface initialization part is moved to core input module.
Change-Id: Ie786e15b49b20d30e35719e5f5f26dd0a492a4e8
Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
#include "shared/device-notifier.h"
#include "shared/log.h"
#include "shared/event.h"
+#include "input/input-interface.h"
#include "input-config.h"
#include "input-dbus.h"
}
}
-void input_handler_process_key(int keycode, int keyvalue)
+static void input_handler_process_key(int keycode, int keyvalue)
{
struct input_config *ic;
return 0;
}
+static struct input_ops input_handler_ops = {
+ .input_handler_process_key = input_handler_process_key,
+};
+
static void input_handler_init(void *data)
{
init_input_config();
- init_input_dbus();
+ *(struct input_ops**)data = &input_handler_ops;
}
static const struct device_ops input_handler_device_ops = {
void input_handler_process_key(int keycode, int keyvalue);
-#endif //__INPUT_HANDLER_H__
+#endif //__INPUT_HANDLER_H__
\ No newline at end of file
#include "core/log.h"
#include "shared/common.h"
+#include "input.h"
#include "input-dbus.h"
+#include "input-interface.h"
/* FIXME: input.keyboard feature check should be added and return DEVICE_ERROR_NOT_SUPPORTED */
static GVariant *dbus_inputseteventstate(GDBusConnection *conn,
return g_variant_new("(i)", ret);
}
+static GVariant *dbus_emulate_key(GDBusConnection *conn,
+ const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+ GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+ int keycode, keyvalue;
+
+ g_variant_get(param, "(ii)", &keycode, &keyvalue);
+
+ input_handler_process_key(keycode, keyvalue);
+
+ return gdbus_new_g_variant_tuple();
+}
+
static const dbus_method_s dbus_methods[] = {
{"InputSetEventState", "ii", "i", dbus_inputseteventstate},
{"InputGetEventState", "i", "i", dbus_inputgeteventstate},
+ {"EmulateKey", "ii", NULL, dbus_emulate_key},
/* Add methods here */
};
int input_dbus_init(void);
-#endif //__INPUT_DBUS_H__
+#endif //__INPUT_DBUS_H__
\ No newline at end of file
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file input-interface.h
+ * @brief input interface module header
+ */
+#ifndef __INPUT_INTERFACE_H__
+#define __INPUT_INTERFACE_H__
+
+struct input_ops {
+ void (*input_handler_process_key)(int keycode, int keyvalue);
+};
+
+#endif /* __INPUT_INTERFACE_H__ */
\ No newline at end of file
#include "shared/devices.h"
#include "shared/log.h"
+#include "input.h"
#include "input-dbus.h"
+#include "input-interface.h"
#define SEAT_NAME "seat0"
static struct udev *udev;
static struct libinput *li;
+static struct input_ops *input_plugin_ops;
static guint efd;
static const struct device_ops *input_handler;
.close_restricted = close_restricted,
};
+void input_handler_process_key(int keycode, int keyvalue)
+{
+ if (input_plugin_ops && input_plugin_ops->input_handler_process_key)
+ input_plugin_ops->input_handler_process_key(keycode, keyvalue);
+}
+
static void input_init(void *data)
{
int ret;
int fd;
- ret = input_dbus_init();
- if(ret < 0)
- _E("Failed to init input device dbus interface(%d)", ret);
-
/* load plugin input handler */
input_handler = find_device("input-handler");
if (check_default(input_handler) || input_handler->execute == NULL) {
}
if (input_handler->init)
- input_handler->init(NULL);
+ input_handler->init(&input_plugin_ops);
+
+ if (input_plugin_ops == NULL)
+ _E("Failed to init input_ops");
+
+ ret = input_dbus_init();
+ if (ret < 0)
+ _E("Failed to init input device dbus interface(%d)", ret);
udev = udev_new();
if (!udev) {
--- /dev/null
+/*
+ * deviced
+ *
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file input.h
+ * @brief input module header
+ */
+#ifndef __INPUT_H__
+#define __INPUT_H__
+
+void input_handler_process_key(int keycode, int keyvalue);
+
+#endif /* __INPUT_H__ */
\ No newline at end of file