From ad2cd4b3282c2f52eaf82f0b7bcf18b7ef471b41 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 11 Jul 2014 18:08:59 +0400 Subject: [PATCH] dde_linux: HID multitouch support Fixes #1209 --- repos/dde_linux/files.list | 2 + repos/dde_linux/lib/mk/usb.inc | 4 +- repos/dde_linux/ports/dde_linux.hash | 2 +- repos/dde_linux/src/lib/usb/dummies.c | 8 +--- repos/dde_linux/src/lib/usb/include/lx_emul.h | 1 + repos/dde_linux/src/lib/usb/input/evdev.c | 39 ++++++++++++++++--- repos/dde_linux/src/lib/usb/main.cc | 8 +++- 7 files changed, 47 insertions(+), 17 deletions(-) diff --git a/repos/dde_linux/files.list b/repos/dde_linux/files.list index 4c1ab1f6b..f01a66792 100644 --- a/repos/dde_linux/files.list +++ b/repos/dde_linux/files.list @@ -38,6 +38,7 @@ linux-3.9/arch/arm/plat-samsung/include/plat/usb-phy.h linux-3.9/drivers/hid/hid-cherry.c linux-3.9/drivers/hid/hid-core.c linux-3.9/drivers/hid/hid-generic.c +linux-3.9/drivers/hid/hid-multitouch.c linux-3.9/drivers/hid/hid-ids.h linux-3.9/drivers/hid/hid-input.c linux-3.9/drivers/hid/usbhid/hid-core.c @@ -51,6 +52,7 @@ linux-3.9/drivers/hid/usbhid/usbkbd.c linux-3.9/drivers/hid/usbhid/usbmouse.c linux-3.9/drivers/input/evdev.c linux-3.9/drivers/input/input.c +linux-3.9/drivers/input/input-mt.c linux-3.9/drivers/input/input-compat.h linux-3.9/drivers/net/usb/asix_common.c linux-3.9/drivers/net/usb/asix_devices.c diff --git a/repos/dde_linux/lib/mk/usb.inc b/repos/dde_linux/lib/mk/usb.inc index 53b53405f..b24ae81d8 100644 --- a/repos/dde_linux/lib/mk/usb.inc +++ b/repos/dde_linux/lib/mk/usb.inc @@ -43,8 +43,8 @@ SRC_C += $(addprefix usb/host/, ehci-hcd.c) # USB hid SRC_C += $(addprefix hid/usbhid/, hid-core.c hid-quirks.c) -SRC_C += $(addprefix hid/, hid-core.c hid-generic.c hid-input.c hid-cherry.c) -SRC_C += $(addprefix input/, evdev.c input.c) +SRC_C += $(addprefix hid/, hid-core.c hid-generic.c hid-input.c hid-cherry.c hid-multitouch.c) +SRC_C += $(addprefix input/, evdev.c input.c input-mt.c) # USB storage SRC_C += $(addprefix usb/storage/,scsiglue.c protocol.c transport.c usb.c \ diff --git a/repos/dde_linux/ports/dde_linux.hash b/repos/dde_linux/ports/dde_linux.hash index 722ce2124..0adf59b86 100644 --- a/repos/dde_linux/ports/dde_linux.hash +++ b/repos/dde_linux/ports/dde_linux.hash @@ -1 +1 @@ -b396829fbc0af030d9ad632d79ad3f53389d43f2 +e407a48e201bda19915373eef0d114933c1e4223 diff --git a/repos/dde_linux/src/lib/usb/dummies.c b/repos/dde_linux/src/lib/usb/dummies.c index 1ee3bf033..2abc26297 100644 --- a/repos/dde_linux/src/lib/usb/dummies.c +++ b/repos/dde_linux/src/lib/usb/dummies.c @@ -6,6 +6,7 @@ */ /* + * Copyright (C) 2014 Ksys Labs LLC * Copyright (C) 2011-2013 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed @@ -56,6 +57,7 @@ long PTR_ERR(const void *ptr) { TRACE; return 0; } void might_sleep() { SKIP; } char *kasprintf(gfp_t gfp, const char *fmt, ...) { TRACE; return NULL; } int kstrtouint(const char *s, unsigned int base, unsigned int *res) { TRACE; return 0; } +int kstrtoul(const char *s, unsigned int base, unsigned long *res) { TRACE; return 0; } int sprintf(char *buf, const char *fmt, ...) { TRACE; return 0; } int sscanf(const char *b, const char *s, ...) { TRACE; return 0; } int scnprintf(char *buf, size_t size, const char *fmt, ...); @@ -751,12 +753,6 @@ int input_event_from_user(const char __user *buffer, struct input_event *event) int input_event_to_user(char __user *buffer, const struct input_event *event) { TRACE; return 0; } int input_ff_effect_from_user(const char __user *buffer, size_t size, struct ff_effect *effect) { TRACE; return 0;} -/**************** - ** linux/mt.h ** - ****************/ - -void input_mt_destroy_slots(struct input_dev *dev) { TRACE; } - /********************* ** linux/vmalloc.h ** diff --git a/repos/dde_linux/src/lib/usb/include/lx_emul.h b/repos/dde_linux/src/lib/usb/include/lx_emul.h index 84bb0e1ce..614fea3c4 100644 --- a/repos/dde_linux/src/lib/usb/include/lx_emul.h +++ b/repos/dde_linux/src/lib/usb/include/lx_emul.h @@ -587,6 +587,7 @@ void might_sleep(); char *kasprintf(gfp_t gfp, const char *fmt, ...); int kstrtouint(const char *s, unsigned int base, unsigned int *res); +int kstrtoul(const char *s, unsigned int base, unsigned long *res); #define clamp(val, min, max) ({ \ typeof(val) __val = (val); \ diff --git a/repos/dde_linux/src/lib/usb/input/evdev.c b/repos/dde_linux/src/lib/usb/input/evdev.c index 2c7fcd0b0..a0f38ced3 100644 --- a/repos/dde_linux/src/lib/usb/input/evdev.c +++ b/repos/dde_linux/src/lib/usb/input/evdev.c @@ -1,8 +1,9 @@ /* * \brief Input service and event handler * \author Christian Helmuth - * \author Dirk Vogt - * \author Sebastian Sumpf + * \author Dirk Vogt + * \author Sebastian Sumpf + * \author Christian Menard * \date 2009-04-20 * * The original implementation was in the L4Env from the TUD:OS group @@ -11,7 +12,8 @@ */ /* - * Copyright (C) 2009-2013 Genode Labs GmbH + * Copyright (C) 2009-2014 Genode Labs GmbH + * Copyright (C) 2014 Ksys Labs LLC * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. @@ -33,6 +35,8 @@ void genode_evdev_event(struct input_handle *handle, unsigned int type, static unsigned long count = 0; #endif + static int last_ax = -1; /* store the last absolute x value */ + /* filter sound events */ if (test_bit(EV_SND, handle->dev->evbit)) return; @@ -51,6 +55,11 @@ void genode_evdev_event(struct input_handle *handle, unsigned int type, case EV_KEY: arg_keycode = code; + + /* map BTN_TOUCH events to BTN_LEFT */ + if (code == BTN_TOUCH) + arg_keycode = BTN_LEFT; + switch (value) { case 0: @@ -71,16 +80,34 @@ void genode_evdev_event(struct input_handle *handle, unsigned int type, switch (code) { case ABS_X: - arg_type = EVENT_TYPE_MOTION; - arg_ax = value; - break; + case ABS_MT_POSITION_X: + + /* + * Don't create an input event yet. Store the value and wait for the + * subsequent Y event. + */ + last_ax = value; + return; case ABS_Y: + case ABS_MT_POSITION_Y: + + /* + * Create a unified input event with absolute positions on x and y + * axis. + */ arg_type = EVENT_TYPE_MOTION; arg_ay = value; + arg_ax = last_ax; + last_ax = -1; + if (arg_ax == -1) { + printk("Ignore absolute Y event without a preceeding X event\n"); + return; + } break; case ABS_WHEEL: + /* * XXX I do not know, how to handle this correctly. At least, this * scheme works on Qemu. diff --git a/repos/dde_linux/src/lib/usb/main.cc b/repos/dde_linux/src/lib/usb/main.cc index 10f0425e7..4e0996637 100644 --- a/repos/dde_linux/src/lib/usb/main.cc +++ b/repos/dde_linux/src/lib/usb/main.cc @@ -1,12 +1,14 @@ /* * \brief USB driver main program * \author Norman Feske - * \author Sebastian Sumpf + * \author Sebastian Sumpf + * \author Christian Menard * \date 2012-01-29 */ /* - * Copyright (C) 2012-2013 Genode Labs GmbH + * Copyright (C) 2012-2014 Genode Labs GmbH + * Copyright (C) 2014 Ksys Labs LLC * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU General Public License version 2. @@ -38,6 +40,7 @@ extern "C" void module_hid_init_core(); extern "C" void module_hid_generic_init(); extern "C" void module_usb_stor_init(); extern "C" void module_ch_driver_init(); +extern "C" void module_mt_driver_init(); extern "C" void start_input_service(void *ep); @@ -67,6 +70,7 @@ static void init(Services *services) module_hid_init(); module_hid_generic_init(); module_ch_driver_init(); + module_mt_driver_init(); } /* host controller */