summaryrefslogtreecommitdiff
path: root/ivi-input-api
diff options
context:
space:
mode:
authorEmre Ucan <eucan@de.adit-jv.com>2015-04-10 14:48:22 +0200
committerNobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp>2015-05-13 16:06:26 +0900
commit07cdf1c8c83ad4bef7db912a48d43b04975679d8 (patch)
tree3b6f6a5fe3a5e77067be0dabbc105b1709ac8213 /ivi-input-api
parentca8501e36af8541c912709340731fe5f4e60c892 (diff)
downloadwayland-ivi-extension-07cdf1c8c83ad4bef7db912a48d43b04975679d8.tar.gz
ilmInput: implement ilm_getInputDevices
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Diffstat (limited to 'ivi-input-api')
-rw-r--r--ivi-input-api/ilmInput/src/ilm_input.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/ivi-input-api/ilmInput/src/ilm_input.c b/ivi-input-api/ilmInput/src/ilm_input.c
index eb1fa96..688fe32 100644
--- a/ivi-input-api/ilmInput/src/ilm_input.c
+++ b/ivi-input-api/ilmInput/src/ilm_input.c
@@ -163,7 +163,51 @@ ILM_EXPORT ilmErrorTypes
ilm_getInputDevices(ilmInputDevice bitmask, t_ilm_uint *num_seats,
t_ilm_string **seats)
{
- return ILM_FAILED;
+ ilmErrorTypes returnValue = ILM_FAILED;
+ struct ilm_control_context *ctx;
+ struct seat_context *seat;
+ int max_seats;
+ int seats_added = 0;
+
+ if ((seats == NULL) || (num_seats == NULL)) {
+ fprintf(stderr, "Invalid Argument\n");
+ return ILM_FAILED;
+ }
+
+ ctx = sync_and_acquire_instance();
+ max_seats = wl_list_length(&ctx->wl.list_seat);
+ *seats = calloc(max_seats, sizeof **seats);
+
+ if (*seats == NULL) {
+ fprintf(stderr, "Failed to allocate memory for input device list\n");
+ release_instance();
+ return ILM_FAILED;
+ }
+
+ wl_list_for_each(seat, &ctx->wl.list_seat, link) {
+ returnValue = ILM_SUCCESS;
+
+ if ((seat->capabilities & bitmask) == 0)
+ continue;
+
+ (*seats)[seats_added] = strdup(seat->seat_name);
+ if ((*seats)[seats_added] == NULL) {
+ int j;
+ fprintf(stderr, "Failed to duplicate seat name %s\n",
+ seat->seat_name);
+ for (j = 0; j < seats_added; j++)
+ free((*seats)[j]);
+ free(*seats);
+ *seats = NULL;
+ returnValue = ILM_FAILED;
+ break;
+ }
+
+ seats_added++;
+ }
+ *num_seats = seats_added;
+ release_instance();
+ return returnValue;
}
ILM_EXPORT ilmErrorTypes