From patchwork Tue Jul 21 18:07:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 6837441 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E9B339F358 for ; Tue, 21 Jul 2015 18:07:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B577205CD for ; Tue, 21 Jul 2015 18:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 339BD206B2 for ; Tue, 21 Jul 2015 18:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933356AbbGUSHo (ORCPT ); Tue, 21 Jul 2015 14:07:44 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:36693 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933274AbbGUSHn (ORCPT ); Tue, 21 Jul 2015 14:07:43 -0400 Received: by pachj5 with SMTP id hj5so124200902pac.3 for ; Tue, 21 Jul 2015 11:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ijPxX4JI3MlhTUtCocwDTBfthVYaHC6n5vg5JZaI7Tg=; b=c+IPUzQQRLuGrtIjAMX7/XT47smUOu6BuJTT4twRzP9LWZvWo2RTYk+3AJGe29TsU6 6yRL7KnVp+yvnu+iZUAE/W82XkIcK+IjgJzmi3uFiiswzU3/4moU1z3jHW2G0sHHwk1c QrEwPt3cMinscDnLzpjlroVhGdvFwwTt34m4QPcrBIKivn44099EMzqjweYRyx6n8l9/ opcnTbmXWMo+rMOHJJjVozZr0co/aEues1/6F+p7eR7lZbix1K8ninmisTE2tA0LTZ8G Rz7ZDi7D3i5SYAPvjKNd05A1M1BCRNc/dlslf4iXSMZYlX52lyINMuDuit0AroT/rnmu XzDA== X-Received: by 10.70.8.131 with SMTP id r3mr76109451pda.62.1437502063486; Tue, 21 Jul 2015 11:07:43 -0700 (PDT) Received: from wacom-arch2.localdomain ([67.51.163.2]) by smtp.gmail.com with ESMTPSA id i5sm28872098pat.42.2015.07.21.11.07.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Jul 2015 11:07:42 -0700 (PDT) From: Jason Gerecke To: Jiri Kosina , Ping Cheng , Benjamin Tissoires Cc: Aaron Skomra , linux-input@vger.kernel.org, Jason Gerecke , Jason Gerecke Subject: [PATCH 3/3] HID: wacom: Report touch width/height/orientation for GENERIC devices Date: Tue, 21 Jul 2015 11:07:25 -0700 Message-Id: <1437502045-29927-3-git-send-email-killertofu@gmail.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1437502045-29927-1-git-send-email-killertofu@gmail.com> References: <1437502045-29927-1-git-send-email-killertofu@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The HID_DG_WIDTH and HID_DG_HEIGHT usages report with width and height of contacts. From this information, a crude determination of orientation is also possible. This patch reports all three to userspace if a device reports this usage. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 09fe5d6..280deb2 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -1497,6 +1497,13 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev, wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_POSITION_Y, 4); break; + case HID_DG_WIDTH: + case HID_DG_HEIGHT: + features->last_slot_field = usage->hid; + wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0); + wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0); + input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0); + break; case HID_DG_CONTACTID: features->last_slot_field = usage->hid; break; @@ -1545,6 +1552,13 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, hid_data->x); input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y, hid_data->y); + + if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) { + input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height)); + input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height)); + if (hid_data->width != hid_data->height) + input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1); + } } } @@ -1561,6 +1575,12 @@ static int wacom_wac_finger_event(struct hid_device *hdev, case HID_GD_Y: wacom_wac->hid_data.y = value; break; + case HID_DG_WIDTH: + wacom_wac->hid_data.width = value; + break; + case HID_DG_HEIGHT: + wacom_wac->hid_data.height = value; + break; case HID_DG_CONTACTID: wacom_wac->hid_data.id = value; break;