From 198957818e30d28b0fa35339694d1e3b6ddd993c Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 9 May 2019 10:48:51 +0900 Subject: [PATCH] headless-server::input : create a default keyboard device This change creates a default keyboard device when there is no probed device from pepper-evdev. As the focused client will be able to control the output(s) and will get key event(s) by default, at least, we need to create a keyboard when there is no keyboard device detected. Change-Id: I7997e9c5cc2a94e85261f3d56d1975653e6097e9 Signed-off-by: Sung-Jin Park --- src/bin/headless/input.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/bin/headless/input.c b/src/bin/headless/input.c index 0e26be5..494b0a6 100644 --- a/src/bin/headless/input.c +++ b/src/bin/headless/input.c @@ -32,6 +32,7 @@ typedef struct pepper_seat_t *seat; pepper_evdev_t *evdev; pepper_keyboard_t *keyboard; + pepper_input_device_t *default_device; pepper_view_t *focus_view; pepper_view_t *top_view; @@ -193,6 +194,12 @@ headless_input_deinit_event_listeners(headless_input_t *hi) static void headless_input_deinit_input(headless_input_t *hi) { + if (hi->default_device) + { + pepper_input_device_destroy(hi->default_device); + hi->default_device = NULL; + } + pepper_evdev_destroy(hi->evdev); if (hi->seat) @@ -204,10 +211,24 @@ headless_input_deinit_input(headless_input_t *hi) } static pepper_bool_t +headless_input_create_input_device(headless_input_t *hi, uint32_t caps) +{ + pepper_input_device_t *input_device = NULL; + + /* create a default pepper input device */ + input_device = pepper_input_device_create(hi->compositor, caps, NULL, hi); + PEPPER_CHECK(input_device, return PEPPER_FALSE, "Failed to create a keyboard device !\n"); + + hi->default_device = input_device; + return PEPPER_TRUE; +} + +static pepper_bool_t headless_input_init_input(headless_input_t *hi) { uint32_t caps = 0; uint32_t probed = 0; + pepper_bool_t res = PEPPER_FALSE; pepper_evdev_t *evdev = NULL; /* create pepper evdev */ @@ -221,12 +242,19 @@ headless_input_init_input(headless_input_t *hi) probed = pepper_evdev_device_probe(evdev, caps); if (!probed) - PEPPER_TRACE("No evdev devices have been probed.\n"); - else - PEPPER_TRACE("%d evdev device(s) has been probed.\n", probed); + { + PEPPER_TRACE("No evdev device has been probed. A default key device will be created.\n"); + + res = headless_input_create_input_device(hi, caps); + PEPPER_CHECK(res, goto end, "Failed to create any input device(s) !\n"); + + probed++; + } hi->ndevices = probed; + PEPPER_TRACE("%d evdev device(s) has been found.\n", probed); + return PEPPER_TRUE; end: -- 2.7.4