Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2514634imu; Thu, 29 Nov 2018 06:16:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/WD4kUTlxehL9m6hyC38u3b7/CJBh7uacakG0idriqs77xiNTU9x3GfQxwSsJGGyUmtpN2c X-Received: by 2002:a63:f201:: with SMTP id v1mr1295393pgh.232.1543500966990; Thu, 29 Nov 2018 06:16:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543500966; cv=none; d=google.com; s=arc-20160816; b=xu4YUg6Nrj1qR1lVAJBtGCfc+3DmgVOmganRc4y64GfL/VIpCeMM+6sioSSM396bAB oB8/w3dZQ3Yo47Ob42KLaZHIRxcw6+cMUs2oBnpu5iDrE+nQI1ihgboeqRYLJoYgZmEY usJ/efq46qk27HgzqE9YfG5t0qspWuq9Wg1CzeyyTdF9Jhd7xWPEJkF31U8LT9HEEGOZ VaqPeLrnxHt+9SiI3uYRwSr25a96Mp9OImLfEGClM5qCEhVAW/Hf92fDdGnUrJ8Ro5zl aQstqI81PeeEU71e0D0Nyd4epDGNjVJbyAX+hJAaLW/9zEKpf/KwIOz6szwR3CJ8aB8m Bkhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u9gZnLCsrtjMuejUwYQ7TOnIpjq1bPOHJXkDE54Re/s=; b=bI6jTptopfVktrVecZRT/2TvksCPx8ld99ZuICRgpf/zf5CAKtcVNBnTPzoJRUkaBF t8VGQAQwNte2jn1pRB4WCt4OE1cf83ZJ3Qy/SawmJvQTknch1SIi4kIvcxzbdEW7fhhY Jl1zs8MOUjWqfDdW4HuCrBElu0yF6f0Ip7PE2rVZezN1v9keEreKXx6r06gT329rr/+i r9sHrqUEld08j53yTS2hwm8BXGCWeHReA16mSU4fQlJeZXNvz+uewqoBdDfXrR3NMBhQ vSPJrIhGhwGzd86MVlPBwyMboJW7C2PxpEFWxrZX/UNuV5Azo2BZxnhiX1McfWrMTnIi 9VAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XHq+VMV4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si2240894pfa.99.2018.11.29.06.15.51; Thu, 29 Nov 2018 06:16:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XHq+VMV4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729199AbeK3BT7 (ORCPT + 99 others); Thu, 29 Nov 2018 20:19:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:40734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729176AbeK3BT7 (ORCPT ); Thu, 29 Nov 2018 20:19:59 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB5A9205C9; Thu, 29 Nov 2018 14:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543500869; bh=UbytQRzln1U3xmF0DZm98P9qOSr8QIOtUKJoFn29eD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XHq+VMV4AqaCH6ftj9SBEOy7BCV+eaTAX/f+6gtd/WPc4uLjbONZA8JdHLqdzIebM /OSA8DDzRoukGxLpGGPpi/8BEGQxGudpSI9ewWP7g0C3RLfQR0xjIlIXmCZfHgoFG7 8g/rCUFS7gOCAR0JE+CXUqCiCff3rXgJRYDECmV4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Rojtberg , Dmitry Torokhov , Sasha Levin Subject: [PATCH 3.18 30/83] Input: xpad - x360w: report dpad as buttons and axes Date: Thu, 29 Nov 2018 15:11:48 +0100 Message-Id: <20181129140139.661352785@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140138.002176596@linuxfoundation.org> References: <20181129140138.002176596@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5ee8bda943de20017636845a5c8d7069a4a283b8 ] as discussed here[0], x360w is the only pad that maps dpad_to_button. This is bad for downstream developers as they have to differ between x360 and x360w which is not intuitive. This patch implements the suggested solution of exposing the dpad both as axes and as buttons. This retains backward compatibility with software already dealing with the difference while makes new software work as expected across x360/ x360w pads. [0] http://www.spinics.net/lists/linux-input/msg34421.html Signed-off-by: Pavel Rojtberg Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/joystick/xpad.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index fc81473b6e35..f6e96741ff0e 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -437,7 +437,16 @@ static void xpad360_process_packet(struct usb_xpad *xpad, input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); - } else { + } + + /* + * This should be a simple else block. However historically + * xbox360w has mapped DPAD to buttons while xbox360 did not. This + * made no sense, but now we can not just switch back and have to + * support both behaviors. + */ + if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || + xpad->xtype == XTYPE_XBOX360W) { input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04)); input_report_abs(dev, ABS_HAT0Y, @@ -1163,7 +1172,16 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { for (i = 0; xpad_btn_pad[i] >= 0; i++) __set_bit(xpad_btn_pad[i], input_dev->keybit); - } else { + } + + /* + * This should be a simple else block. However historically + * xbox360w has mapped DPAD to buttons while xbox360 did not. This + * made no sense, but now we can not just switch back and have to + * support both behaviors. + */ + if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || + xpad->xtype == XTYPE_XBOX360W) { for (i = 0; xpad_abs_pad[i] >= 0; i++) xpad_set_up_abs(input_dev, xpad_abs_pad[i]); } -- 2.17.1