Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4318083pxj; Tue, 8 Jun 2021 11:21:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0nP6fXNo46fQuQUX1WgbIdlUCAuAwlEE9gb8ihSzCVdUFmyoNXRcmNeOM0q7Tg8WVqQOz X-Received: by 2002:a17:906:1444:: with SMTP id q4mr25141634ejc.459.1623176498137; Tue, 08 Jun 2021 11:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623176498; cv=none; d=google.com; s=arc-20160816; b=a80ZDKUzMvLSsBTDPTX3MyvLZajTCejE3oV72AHvQeJWFOTt05Bex0qxL5ChJmhuDJ vmrRh35Ea4OXMErkSTVQoccu5El163fm1XkuqXPeyI4YqNLIRa47ShJY0S9UQGTHIjeB GAmd+EMm97GSZp1+dfe0C9XD29aClSinWyoIBcd+z9m9dHuYClGPuaEBD/nOwDLKLhMU tQnIxSeMYZbuWM6PYugexVPtPteYt/drv6o7jTdKCMz7gk23y424D3iPtpX0mt7tgu99 1rRj8yZwc3i7k03YKKwlbdy+LoVHZyaWy1kE2DEuh4kQzx2IBxievqzxRI8+XAQ+oMv0 Wrow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=0qun7NvXodjF9YHPpZb3mdfN8HUr8FYO6a8xPo6DMO8=; b=ZinV4Cdg6m4fkGTMAweno/V0k2pgD38HritpR7z1Fma0BJ4VTBqlAsS0+pIKlpJclo aNaYkux7wNWGLXWrkOTmOU6RxrO6livXgXCRBSaH9v8hksYV0uyfQfEOJq+/36tKzUrm DxVU3D0bKZxyQl1zbpU8IuYBXxwP6/h88hFt2I+tajCDswmrFgOu4RJyJLUjgmdyRImA bWIOx9nQkDbG0N9QJCVCSERC9e6O282DQQwYhOULAap8Af2KZJshayugOrm2d5JiZcga eaR0Vasme5DeQW0JHhP0llxYdYLvKRLUuP+iOiIekyPVf6UyszNhGzr6seHyifDQoAaE JuBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=clilsAGW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si344402eds.204.2021.06.08.11.21.15; Tue, 08 Jun 2021 11:21:38 -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=fail header.i=@weissschuh.net header.s=mail header.b=clilsAGW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233964AbhFHSU4 (ORCPT + 99 others); Tue, 8 Jun 2021 14:20:56 -0400 Received: from todd.t-8ch.de ([159.69.126.157]:35705 "EHLO todd.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbhFHSUy (ORCPT ); Tue, 8 Jun 2021 14:20:54 -0400 Date: Tue, 8 Jun 2021 20:18:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1623176337; bh=SC/iW8tEKG23KFNCOheedAfp54KKN/nyiLVof+f8O10=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=clilsAGWMCoQ2dLL4aqCX4sDgASMV05DVYEBhkh7N9uLURQEpHJ+yKoGww/AIRuwB HYpKmDIldBvQlrOeETDPmgVP8Zx9RI4hz7JMmrD4/W4DcYBPiERzDLxlVJXwqLTKCR +l0hNl0xa4YEIhjy3DWLLvGZdPaENrPbMh3Vaesk= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin Tissoires , Hans de Goede Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] HID: input: Add support for Programmable Buttons Message-ID: References: <20210520084805.685486-1-linux@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210520084805.685486-1-linux@weissschuh.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi everybody, this is a ping requesting a review for my patch. I hope it is not to early send a ping. Link to patch in the archive: https://lore.kernel.org/linux-input/20210520084805.685486-1-linux@weissschuh.net/ Regards, Thomas On Do, 2021-05-20T10:48+0200, Thomas Weißschuh wrote: > Date: Thu, 20 May 2021 10:48:05 +0200 > From: Thomas Weißschuh > To: linux-input@vger.kernel.org, Jiri Kosina , Benjamin > Tissoires , Hans de Goede > > Cc: Thomas Weißschuh , linux-kernel@vger.kernel.org > Subject: [PATCH v3] HID: input: Add support for Programmable Buttons > X-Mailer: git-send-email 2.31.1 > > 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: https://lore.kernel.org/linux-input/20210519160349.609690-1-linux@weissschuh.net/ > > v1 -> v2: Only handle the 30 keys known > > v2: https://lore.kernel.org/linux-input/20210519174345.614467-1-linux@weissschuh.net/ > > v2 -> v3: > * Use hex constants for consistency > * Validate that the button is part of a "Programmable Buttons" Named Array. > Otherwise the condition would also apply to "Function Buttons". > * Ignore non-"Programmable Buttons" buttons. > > drivers/hid/hid-debug.c | 11 +++++++++++ > drivers/hid/hid-input.c | 22 ++++++++++++++++++++++ > include/linux/hid.h | 1 + > 3 files changed, 34 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..791a2baf9ccd 100644 > --- a/drivers/hid/hid-input.c > +++ b/drivers/hid/hid-input.c > @@ -567,6 +567,16 @@ static void hidinput_update_battery(struct hid_device *dev, int value) > } > #endif /* CONFIG_HID_BATTERY_STRENGTH */ > > +static bool hidinput_field_in_collection(struct hid_device *device, struct hid_field *field, > + unsigned int type, unsigned int usage) > +{ > + struct hid_collection *collection; > + > + collection = &device->collection[field->usage->collection_index]; > + > + return collection->type == type && collection->usage == usage; > +} > + > static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_field *field, > struct hid_usage *usage) > { > @@ -632,6 +642,18 @@ 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 (hidinput_field_in_collection(device, field, > + HID_COLLECTION_NAMED_ARRAY, > + HID_CP_PROGRAMMABLEBUTTONS)) { > + if (code <= 0x1d) > + code += KEY_MACRO1; > + else > + code += BTN_TRIGGER_HAPPY - 0x1e; > + } else { > + goto ignore; > + } > + break; > default: > switch (field->physical) { > case HID_GD_MOUSE: > diff --git a/include/linux/hid.h b/include/linux/hid.h > index 271021e20a3f..fb0e4dde6175 100644 > --- a/include/linux/hid.h > +++ b/include/linux/hid.h > @@ -102,6 +102,7 @@ struct hid_item { > #define HID_COLLECTION_PHYSICAL 0 > #define HID_COLLECTION_APPLICATION 1 > #define HID_COLLECTION_LOGICAL 2 > +#define HID_COLLECTION_NAMED_ARRAY 4 > > /* > * HID report descriptor global item tags > > base-commit: efd8929b9eec1cde120abb36d76dd00ff6711023 > -- > 2.31.1 >