From patchwork Sat Mar 30 13:37:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10878483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 946AA1874 for ; Sat, 30 Mar 2019 13:37:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 806BE28727 for ; Sat, 30 Mar 2019 13:37:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74B6B28E44; Sat, 30 Mar 2019 13:37:45 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 DF35628E41 for ; Sat, 30 Mar 2019 13:37:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730837AbfC3Nho (ORCPT ); Sat, 30 Mar 2019 09:37:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37438 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730784AbfC3Nho (ORCPT ); Sat, 30 Mar 2019 09:37:44 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8A77F859FE; Sat, 30 Mar 2019 13:37:43 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-76.ams2.redhat.com [10.36.116.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BCED1001E8A; Sat, 30 Mar 2019 13:37:42 +0000 (UTC) From: Hans de Goede To: Jiri Kosina , Benjamin Tissoires , Dmitry Torokhov Cc: Hans de Goede , Peter Hutterer , linux-input@vger.kernel.org Subject: [RFC 1/6] Input: Rename extra mouse buttons defines to match their actual usage Date: Sat, 30 Mar 2019 14:37:30 +0100 Message-Id: <20190330133735.14681-2-hdegoede@redhat.com> In-Reply-To: <20190330133735.14681-1-hdegoede@redhat.com> References: <20190330133735.14681-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 30 Mar 2019 13:37:43 +0000 (UTC) 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 Almost all modern mice use HID. For buttons 1 - 3 the order of left / right / middle specified in the HUT matches with the BTN_LEFT, BTN_RIGHT and BTN_MIDDLE order of the evdev code defines since the HUT does not specify any meaning for button usages >= 4 the HID input driver simply maps buttons to BTN_LEFT + (number - 1). In practice on most mice which have more then 3 buttons, usage 4 is used for the back(ward) button and usage 5 for the forward button. This means that these buttons generate an input_event code of 0x113 resp. 0x114, which looking at the old defines maps to BTN_SIDE and BTN_EXTRA. Under X these are mapped to buttons 8 resp. 9; and under wayland the input_event code is passed through unmodified. Apps, e.g. Firefox both when running as Wayland client under GNOME3 and when running under Xorg, correctly interpret these as back and forward. So we've back and forward buttons generating BTN_SIDE and BTN_EXTRA, which the apps then interpret as BTN_BACK and BTN_FORWARD, rather then as BTN_SIDE and BTN_EXTRA (which have no clear meaning). I find this all very confusing, this commit tries to remove the confusion by deprecating the old defines and adding new defines which assign labels to the 0x113 - 0x116 input_event codes which match how they are actually used today. Note there are no functional changes here, after this userspace will see the exact same input_event codes as before, this purely about assigning a human-readable label to these codes which matches with how they are actually being used. Signed-off-by: Hans de Goede --- Documentation/input/event-codes.rst | 2 +- drivers/hid/hid-debug.c | 6 +++--- drivers/input/mousedev.c | 8 ++++---- include/uapi/linux/input-event-codes.h | 13 ++++++++++++- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst index b24b5343f5eb..db52b96e7a83 100644 --- a/Documentation/input/event-codes.rst +++ b/Documentation/input/event-codes.rst @@ -422,7 +422,7 @@ should be used to report when the tool is in contact with the tablet. BTN_{STYLUS,STYLUS2} should be used to report buttons on the tool itself. Any button may be used for buttons on the tablet except BTN_{MOUSE,LEFT}. BTN_{0,1,2,etc} are good generic codes for unlabeled buttons. Do not use -meaningful buttons, like BTN_FORWARD, unless the button is labeled for that +meaningful buttons, like BTN_FORWRD, unless the button is labeled for that purpose on the device. For new hardware, both INPUT_PROP_DIRECT and INPUT_PROP_POINTER should be set. diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index ac9fda1b5a72..45b56f933fd1 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c @@ -855,9 +855,9 @@ static const char *keys[KEY_MAX + 1] = { [BTN_6] = "Btn6", [BTN_7] = "Btn7", [BTN_8] = "Btn8", [BTN_9] = "Btn9", [BTN_LEFT] = "LeftBtn", [BTN_RIGHT] = "RightBtn", - [BTN_MIDDLE] = "MiddleBtn", [BTN_SIDE] = "SideBtn", - [BTN_EXTRA] = "ExtraBtn", [BTN_FORWARD] = "ForwardBtn", - [BTN_BACK] = "BackBtn", [BTN_TASK] = "TaskBtn", + [BTN_MIDDLE] = "MiddleBtn", [BTN_BACKWRD] = "BackwardBtn", + [BTN_FORWRD] = "ForwardBtn", [BTN_EXTRA1] = "ExtraBtn1", + [BTN_EXTRA2] = "ExtraBtn2", [BTN_TASK] = "TaskBtn", [BTN_TRIGGER] = "Trigger", [BTN_THUMB] = "ThumbBtn", [BTN_THUMB2] = "ThumbBtn2", [BTN_TOP] = "TopBtn", [BTN_TOP2] = "TopBtn2", [BTN_PINKIE] = "PinkieBtn", diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 412fa71245af..7504e854900f 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c @@ -238,16 +238,16 @@ static void mousedev_key_event(struct mousedev *mousedev, case BTN_RIGHT: index = 1; break; case BTN_2: - case BTN_FORWARD: + case BTN_EXTRA1: case BTN_STYLUS2: case BTN_MIDDLE: index = 2; break; case BTN_3: - case BTN_BACK: - case BTN_SIDE: index = 3; break; + case BTN_EXTRA2: + case BTN_BACKWRD: index = 3; break; case BTN_4: - case BTN_EXTRA: index = 4; break; + case BTN_FORWRD: index = 4; break; default: return; } diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 7f14d4a66c28..f11ce5d2c228 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -355,11 +355,22 @@ #define BTN_LEFT 0x110 #define BTN_RIGHT 0x111 #define BTN_MIDDLE 0x112 +#define BTN_BACKWRD 0x113 +#define BTN_FORWRD 0x114 +#define BTN_EXTRA1 0x115 +#define BTN_EXTRA2 0x116 +#define BTN_TASK 0x117 + +/* + * DEPRECATED: Do not use! + * These old defines are to not break the compilation of user code ONLY. + * Over time they have grown to be incorrect. Almost all modern mice with + * back / forward buttons generate 0x113 for back and 0x114 for forward. + */ #define BTN_SIDE 0x113 #define BTN_EXTRA 0x114 #define BTN_FORWARD 0x115 #define BTN_BACK 0x116 -#define BTN_TASK 0x117 #define BTN_JOYSTICK 0x120 #define BTN_TRIGGER 0x120