From patchwork Tue Sep 27 18:41:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adi Ratiu X-Patchwork-Id: 9352637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A5656077B for ; Tue, 27 Sep 2016 18:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C66E28682 for ; Tue, 27 Sep 2016 18:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C86E291EF; Tue, 27 Sep 2016 18:42:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A795F28682 for ; Tue, 27 Sep 2016 18:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755928AbcI0SmF (ORCPT ); Tue, 27 Sep 2016 14:42:05 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34175 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445AbcI0Slr (ORCPT ); Tue, 27 Sep 2016 14:41:47 -0400 Received: by mail-wm0-f65.google.com with SMTP id l132so2451994wmf.1 for ; Tue, 27 Sep 2016 11:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adirat-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ubUd9oZWoouKNV/7fYeU1ZcVI1wbLHuO78WwVZhF6y4=; b=1I9FHgtSaYSSr5s59kCNoOxuhRIkvzZjAT4Pupx/OyevaE0DmUCfKaQounQQbPc7mv durvZvCxoVXmxJ5i66g/WVCLHQl3s7xFBLLv93+yQrqWfecPUCmt0uY30SNg1bV8LXtf Is78A9Mvcf+YyO0eCcGCObSpy4C0UVCVD2n2zoV+KZk6WK4ZFwzn6Zrb8f+jqMNPGLzH lhJ0pjUieqhw5j5s7fHD2hmbZcRXd0EpfahRjV5z3IrpwSh4qCTOw5ho5dBc2WjCHtXy MGPXz/65ZOdhck1RT6hCu0T44QfrBGbJlhnNIOhAaicEW9QggCsZ6kL7R6EBZ1Sgl94f 8uBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ubUd9oZWoouKNV/7fYeU1ZcVI1wbLHuO78WwVZhF6y4=; b=fcssYepjk1U0MIPlLotQMwNWf2b/53MPErJG1Zc2u5bUj5fiGu907bjnJGUFJpw8Bg +Ihb9gdn7vVIzNUNbu1Vh8qDn6ZIMJtpjcLUW0ANg9HtwEwPc364tnNEzh7+ozjytaVE JXLF0kP44ur6KOwpA50svFQIwjXreH9nWeeCEATJaecn7d7cC99Fy0IQq0Oen9yr1Hir 8tQaM91YPMxzyPhLJUXLAIUjmysn8+W+IjsMbgx3iHA9AY2WlBrdi52D+eil2y3RGEVG F40BAcT5QBiL2XAZrpkvHF1WFXmZPp+QYMv8S78LfjXwhR23ncLod5u7NDrfsEFqghhy jyHQ== X-Gm-Message-State: AA6/9Rl4gGmKXEk5l1XabRmgd1NY32WiDZlnrvgJ+aFX/JESNgm784McnexAuyjKwpMOGQ== X-Received: by 10.28.37.4 with SMTP id l4mr2388386wml.86.1475001706214; Tue, 27 Sep 2016 11:41:46 -0700 (PDT) Received: from adiPC.lan ([188.24.78.211]) by smtp.gmail.com with ESMTPSA id 74sm4488410wmi.7.2016.09.27.11.41.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Sep 2016 11:41:45 -0700 (PDT) From: Ioan-Adrian Ratiu To: benjamin.tissoires@redhat.com, jikos@kernel.org Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, spbnick@gmail.com Subject: [PATCH v2 2/2] hid: hid-dr: add input mapping for axis selection Date: Tue, 27 Sep 2016 21:41:38 +0300 Message-Id: <20160927184138.3009-2-adi@adirat.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160927184138.3009-1-adi@adirat.com> References: <20160927184138.3009-1-adi@adirat.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 79346d620e9d ("HID: input: force generic axis to be mapped to their user space axis") made mapping generic axes to their userspace equivalents mandatory and some lower end gamepads which were depending on the previous behaviour suffered severe regressions because they were reusing axes and expecting hid-input to multiplex their map to the respective userspace axis by always searching for and using the next available axis. One solution is to add a hid quirk for this type of "previous" behaviour in hid-input to bypass the new axes policy in favour of the old one, but since only one hardware vendor seems to be affected negatively we're better off making and exception and mapping in the driver for now; if more vendors or drivers turn out to experience the problem we should reconsider the quirk solution. Signed-off-by: Ioan-Adrian Ratiu --- drivers/hid/hid-dr.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/hid/hid-dr.c b/drivers/hid/hid-dr.c index 2523f8a..818ea7d9 100644 --- a/drivers/hid/hid-dr.c +++ b/drivers/hid/hid-dr.c @@ -248,6 +248,30 @@ static __u8 *dr_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } +#define map_abs(c) hid_map_usage(hi, usage, bit, max, EV_ABS, (c)) +#define map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c)) + +static int dr_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + switch (usage->hid) { + /* + * revert to the old hid-input behavior where axes + * can be randomly assigned when hid->usage is reused. + */ + case HID_GD_X: case HID_GD_Y: case HID_GD_Z: + case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: + if (field->flags & HID_MAIN_ITEM_RELATIVE) + map_rel(usage->hid & 0xf); + else + map_abs(usage->hid & 0xf); + return 1; + } + + return 0; +} + static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) { int ret; @@ -294,6 +318,7 @@ static struct hid_driver dr_driver = { .id_table = dr_devices, .report_fixup = dr_report_fixup, .probe = dr_probe, + .input_mapping = dr_input_mapping, }; module_hid_driver(dr_driver);