Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp1584881lkv; Wed, 19 May 2021 13:23:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXdbe1ITENUWL7urh//QUxMNzGw6z1UMxzJc0UjXzpBr8D8WFaobWYPK1Y9/ClfLIm3byA X-Received: by 2002:a05:6602:2b0a:: with SMTP id p10mr1349744iov.129.1621455800357; Wed, 19 May 2021 13:23:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621455800; cv=none; d=google.com; s=arc-20160816; b=Gx0AaDzbszXIBOG7mthkTPp3e5ot47I+4XRTwuEPfsYgSgJjbQtF6V0uRPvUU0Bmvm 8dc7uNow7q3OwxpA3/OaqPTPHX37KDmCX0E2gEAz/Qto8CZoOcnDeEiat5sllztfkoOO WnNc9XllmEWzqyfh+0KBgWbxYoMwET/FpJv1jTV4+Cy+P7+BowfmHA4lghaCytXGZCi1 eurlkXA9fXsDW9GvV7naUCYtJbhHgf+u3+tWZA+pLObaE3mguw3DOBmutP6H2x7FeqyG MdKJcc5fcu9t8jQrSiwn/vpQTnOdizF/uDM0NGqat6EQeICSOByx3fcq12O44MZbEyVJ 2KQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=xhvgxIwKXugvxbNq7OeadgSTzvUaMEzWThB+Rg7b80k=; b=pbCWGBVCxoPBWlusNZK/oAxh3/YZEDUNeIubT8hQJTYXu2gilpYFW7TI41xCgwCDxG EQ0X4lr1+srk8LeqzoypTUnm3kABnbeN9vSJEfleJR3las09Ou+BUmHWh5qi23Q9l2ao nPrsQw3hakx0IZKT0yJc152byIpnxUJ2Z53wyP/Ufb0qRFcvhNfl+YCYfqCNlaYYW50v XU1HxMbLJ3HRpLLTttTCPwlhwnWdhuCr6MhCZreeZ62MD1x4d4mNE/IReq+1/erNpiXR UlOUttk4+shLZJXsZJyT3sNrHyCziznTi7IbbWXcFWuT2FZpTzU8/n4vIL6nMmeFjW1p dqxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZZhg4zQK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 15si740994ilz.158.2021.05.19.13.23.05; Wed, 19 May 2021 13:23:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZZhg4zQK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232564AbhESUDT (ORCPT + 99 others); Wed, 19 May 2021 16:03:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49382 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232529AbhESUDS (ORCPT ); Wed, 19 May 2021 16:03:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621454517; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xhvgxIwKXugvxbNq7OeadgSTzvUaMEzWThB+Rg7b80k=; b=ZZhg4zQKRWOGUU0U6GSf98p6srWjVyAw6XYnYhulfqt2NWQAmR81MhXm3XwvSFSdw5sDYb JOv1QFzA8DueThnjAgHvJ51eQcyESQJtu720d1c4H/cOYvgFCUKbSWoOHtmw8tZlt4VB3D cKR9qzm+3LdWCWG0jVgBeEPgU2hCdVg= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-359-ZfmaMgHvOYKHbYxjSQhStw-1; Wed, 19 May 2021 16:01:55 -0400 X-MC-Unique: ZfmaMgHvOYKHbYxjSQhStw-1 Received: by mail-ej1-f71.google.com with SMTP id la2-20020a170906ad82b02903d4bcc8de3bso4150778ejb.4 for ; Wed, 19 May 2021 13:01:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xhvgxIwKXugvxbNq7OeadgSTzvUaMEzWThB+Rg7b80k=; b=PoYUkh3q0K17W1G5iIZbUdi2u/WUEsoo1tqsKydccUAOcvO3eA7qkctuoTuW+CZXQ4 XmhNvbnFisPBUtTD1CVE79ONZQJnAe0T9q5mE4PNw4Yst8eqVMH+/2Mb1lsOzzFr6fqf 0SqOYaz2WFNulNdi0CZ1oW165qB2vkJjsgxAyi4Ze9mTpjYHpjXomWpNxfHdInknVgS5 7QcqdSt0Urdi+6QlWc4mkDE8gX1sxE6Zbirml0bcndrRJo7rUhaeNC43U7G0US+6NqHh 0VsYRvwioviABLThh6jjp6z+A0bTdY+B85/s8HOHldzj7H6qeOiUiWZUxFhX4x1CFISA UG+w== X-Gm-Message-State: AOAM5310Blzzle7OvcYiFSd23pqgKhFy/UUUXVlw1dx6LARfoYXuauit CrOp6hsySeoSqaC4P/fRUt8t6rCTUirk7Hxdj6oEc35a/3K52CWUCsK7Ae+/CAJIJCZ+zJ+XGnv syKzd7AML13dJX8XXPurOe7ANyAF+XDQ02qk46Pn0AGmSFbU6xODxOafwF5PtyEXl/VHvjrdg0N dY X-Received: by 2002:a17:906:9257:: with SMTP id c23mr879393ejx.392.1621454514262; Wed, 19 May 2021 13:01:54 -0700 (PDT) X-Received: by 2002:a17:906:9257:: with SMTP id c23mr879369ejx.392.1621454514011; Wed, 19 May 2021 13:01:54 -0700 (PDT) Received: from x1.localdomain (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id 9sm397858ejv.73.2021.05.19.13.01.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 May 2021 13:01:53 -0700 (PDT) Subject: Re: [PATCH v2] HID: input: Add support for Programmable Buttons To: =?UTF-8?Q?Thomas_Wei=c3=9fschuh?= , linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires Cc: linux-kernel@vger.kernel.org References: <2dc197eb-a222-8af6-f0ab-f722e4f492ca@redhat.com> <20210519174345.614467-1-linux@weissschuh.net> From: Hans de Goede Message-ID: Date: Wed, 19 May 2021 22:01:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210519174345.614467-1-linux@weissschuh.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 5/19/21 7:43 PM, Thomas Weißschuh wrote: > Map them to KEY_MACRO# event codes. > > These buttons are defined by HID as follows: > "The user defines the function of these buttons to control software applications or GUI objects." > > This matches the semantics of the KEY_MACRO# input event codes that Linux supports. > > Signed-off-by: Thomas Weißschuh > --- > > v1 -> v2: Only handle the 30 keys known I'm no expert in this part of HID, so I'm not 100% sure this is correct, with that said this looks good to me: Reviewed-by: Hans de Goede Regards, Hans > > drivers/hid/hid-debug.c | 11 +++++++++++ > drivers/hid/hid-input.c | 6 ++++++ > 2 files changed, 17 insertions(+) > > diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c > index 59f8d716d78f..0e76d9b4530a 100644 > --- a/drivers/hid/hid-debug.c > +++ b/drivers/hid/hid-debug.c > @@ -122,6 +122,7 @@ static const struct hid_usage_entry hid_usage_table[] = { > { 9, 0, "Button" }, > { 10, 0, "Ordinal" }, > { 12, 0, "Consumer" }, > + {0, 0x003, "ProgrammableButtons"}, > {0, 0x238, "HorizontalWheel"}, > { 13, 0, "Digitizers" }, > {0, 0x01, "Digitizer"}, > @@ -939,6 +940,16 @@ static const char *keys[KEY_MAX + 1] = { > [KEY_KBDINPUTASSIST_NEXTGROUP] = "KbdInputAssistNextGroup", > [KEY_KBDINPUTASSIST_ACCEPT] = "KbdInputAssistAccept", > [KEY_KBDINPUTASSIST_CANCEL] = "KbdInputAssistCancel", > + [KEY_MACRO1] = "Macro1", [KEY_MACRO2] = "Macro2", [KEY_MACRO3] = "Macro3", > + [KEY_MACRO4] = "Macro4", [KEY_MACRO5] = "Macro5", [KEY_MACRO6] = "Macro6", > + [KEY_MACRO7] = "Macro7", [KEY_MACRO8] = "Macro8", [KEY_MACRO9] = "Macro9", > + [KEY_MACRO10] = "Macro10", [KEY_MACRO11] = "Macro11", [KEY_MACRO12] = "Macro12", > + [KEY_MACRO13] = "Macro13", [KEY_MACRO14] = "Macro14", [KEY_MACRO15] = "Macro15", > + [KEY_MACRO16] = "Macro16", [KEY_MACRO17] = "Macro17", [KEY_MACRO18] = "Macro18", > + [KEY_MACRO19] = "Macro19", [KEY_MACRO20] = "Macro20", [KEY_MACRO21] = "Macro21", > + [KEY_MACRO22] = "Macro22", [KEY_MACRO23] = "Macro23", [KEY_MACRO24] = "Macro24", > + [KEY_MACRO25] = "Macro25", [KEY_MACRO26] = "Macro26", [KEY_MACRO27] = "Macro27", > + [KEY_MACRO28] = "Macro28", [KEY_MACRO29] = "Macro29", [KEY_MACRO30] = "Macro30", > }; > > static const char *relatives[REL_MAX + 1] = { > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c > index 18f5e28d475c..32962772cb42 100644 > --- a/drivers/hid/hid-input.c > +++ b/drivers/hid/hid-input.c > @@ -632,6 +632,12 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel > else > code += BTN_TRIGGER_HAPPY - 0x10; > break; > + case HID_CP_CONSUMER_CONTROL: > + if (code <= 29) > + code += KEY_MACRO1; > + else > + code += BTN_TRIGGER_HAPPY - 30; > + break; > default: > switch (field->physical) { > case HID_GD_MOUSE: > > base-commit: efd8929b9eec1cde120abb36d76dd00ff6711023 >