From patchwork Mon Aug 15 23:44:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Brown X-Patchwork-Id: 1069582 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7FNjKCo005386 for ; Mon, 15 Aug 2011 23:45:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752004Ab1HOXpT (ORCPT ); Mon, 15 Aug 2011 19:45:19 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:36553 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807Ab1HOXpT (ORCPT ); Mon, 15 Aug 2011 19:45:19 -0400 Received: by gya6 with SMTP id 6so3477816gya.19 for ; Mon, 15 Aug 2011 16:45:18 -0700 (PDT) Received: by 10.236.178.9 with SMTP id e9mr14723469yhm.186.1313451918371; Mon, 15 Aug 2011 16:45:18 -0700 (PDT) Received: from localhost.localdomain (daedalus.mtv.corp.google.com [172.18.103.24]) by mx.google.com with ESMTPS id w1sm2527687yhi.23.2011.08.15.16.45.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Aug 2011 16:45:17 -0700 (PDT) From: jeffbrown@android.com To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jkosina@suse.cz, rydberg@euromail.se, benjamin.tissoires@enac.fr, chatty@enac.fr, Jeff Brown Subject: [PATCH] hid-multitouch: Filter collections by application usage. Date: Mon, 15 Aug 2011 16:44:28 -0700 Message-Id: <1313451868-79836-1-git-send-email-jeffbrown@android.com> X-Mailer: git-send-email 1.7.0.4 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 15 Aug 2011 23:45:21 +0000 (UTC) From: Jeff Brown This change fixes two problems. First, it ensures that the hid-multitouch driver does not incorrectly map GenericDesktop usages that are intended for other applications, such as a Mouse. Second, it sets the appropriate input properties so that user-space can distinguish TouchScreen devices (INPUT_PROP_DIRECT) from TouchPad devices (INPUT_PROP_POINTER) and configure them accordingly. Signed-off-by: jeffbrown@android.com Acked-By: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 58d0e7a..4ee21ac 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -213,6 +213,16 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct mt_class *cls = td->mtclass; __s32 quirks = cls->quirks; + /* Only map fields from TouchScreen or TouchPad collections. + * We need to ignore fields that belong to other collections + * such as Mouse that might have the same GenericDesktop usages. */ + if (field->application == HID_DG_TOUCHSCREEN) + set_bit(INPUT_PROP_DIRECT, hi->input->propbit); + else if (field->application == HID_DG_TOUCHPAD) + set_bit(INPUT_PROP_POINTER, hi->input->propbit); + else + return 0; + switch (usage->hid & HID_USAGE_PAGE) { case HID_UP_GENDESK: