Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2372661rdf; Mon, 6 Nov 2023 12:07:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAEuW1MolBUf0HfGvGvCAsIP9LKB5+EK13KaEl5BAJJC1UkM1xBZvOFI+z8OsJqRB87Akn X-Received: by 2002:a05:6871:6008:b0:1f0:8706:4c4a with SMTP id qx8-20020a056871600800b001f087064c4amr755070oab.29.1699301251474; Mon, 06 Nov 2023 12:07:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301251; cv=none; d=google.com; s=arc-20160816; b=Hy8FNSNqcHlUcUGOR41PLiBWz9N3T4NwHCzEI1hGJeUuRxAFvlOgPCfD7Q0xWJV56X P7u13blrd1SkvNScfvBb8Q03srQeMA8DVREVCWVpSjz+1rM27DP+aZYS46NNB+fvjm++ 3Q30qpJdcR1zvDo8A7I8zTufcvvjD2OzHpvbSSzi3Jt7qBagJekj9siu8PEsh7+IBGzD 8cyGqOomnfF0ZyxlEXL63wbkMSiuLF715qYTfZNyMC7g00CWdPGavhR05crWeOoigBXv a0+NPn0V2AJkJEcPQTmyAGE0x4SrzXNWyBej8v5EAFky+gtnRXPEYO4HLxTJ1ElJyBky gX6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=cO/BXULEhmheChvjKlPVxtC1n+rkJk1xKgJu9aRLxOg=; fh=6kHd1tfqk/Q+xNJsatB9BEA6ehbDMJpFz2oig7qLPis=; b=H80bAA0vGZaY3vtb0C2pH7vcV8JXMBuhkkfuKxKL3IbCcQNhJKqnBDFxWbk/nyV1Hg 301YTp0uVsujmY6uECHNyhr4RlS0ZA50TCebSWRC8nj/MAUUCNm+Nlu7G4VVVTfYJ5la rwzJcaxnMSp0X2/0TX5Dwz6fKc66ziM+sG6VlGMeKRMbiJ0s3l0bK9IBzQgiPYpHS85n yP12FFJkWHpp9G4wVMGBOFWPCnyjSWvY2EcAJCXcVgfvLSud2tjgPDtzn3BxavTlAQ/i iAsJ8fE8uV6lAU4koBnbCJnaBt50HTiARh+Wb8z36XmFisBFdENp2p3BupR7Dh+H9uaU Hqyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id cm16-20020a056a020a1000b005b81f21a25csi348718pgb.830.2023.11.06.12.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:07:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D5CB18077997; Mon, 6 Nov 2023 12:07:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232686AbjKFUGp (ORCPT + 99 others); Mon, 6 Nov 2023 15:06:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjKFUGo (ORCPT ); Mon, 6 Nov 2023 15:06:44 -0500 Received: from mailout1n.rrzn.uni-hannover.de (mailout1n.rrzn.uni-hannover.de [130.75.2.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2A62D51; Mon, 6 Nov 2023 12:06:39 -0800 (PST) Received: from [10.23.33.142] (mmsrv.sra.uni-hannover.de [130.75.33.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailout1n.rrzn.uni-hannover.de (Postfix) with ESMTPSA id 2975F10E; Mon, 6 Nov 2023 21:06:37 +0100 (CET) Message-ID: Date: Mon, 6 Nov 2023 21:06:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Requesting your attention and expertise regarding a Tablet/Kernel issue To: Benjamin Tissoires , David Revoy Cc: jkosina@suse.cz, jason.gerecke@wacom.com, jose.exposito89@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, nils@nilsfuhler.de, peter.hutterer@who-t.net, ping.cheng@wacom.com, bagasdotme@gmail.com References: <20231103200524.53930-1-ostapyshyn@sra.uni-hannover.de> Content-Language: en-US From: Illia Ostapyshyn In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.9 at mailout1n X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:07:03 -0800 (PST) On 11/6/23 17:59, Benjamin Tissoires wrote: > If the pen has 2 buttons, and an eraser side, it would be a serious > design flow for XPPEN to report both as eraser. > > Could you please use sudo hid-recorder from hid-tools[1] on any kernel > version and send us the logs here? > I'll be able to replay the events locally, and understand why the > kernel doesn't work properly. > > And if there is a design flaw that can be fixed, we might even be able > to use hid-bpf to change it :) My wild guess is that XP-Pen 16 Artist Pro reports an Eraser usage without Invert for the upper button and Eraser with Invert for the eraser tip. A device-specific driver could work with that, but there seems to be no way to incorporate two different erasers (thus, allowing userspace to map them to different actions arbitrarily) in the generic driver currently. > Generally speaking, relying on X to fix your hardware is going to be a > dead end. When you switch to wayland, you'll lose all of your fixes, > which isn't great. > AFAIU, the kernel now "merges" both buttons, which is a problem. It > seems to be a serious regression. This case is also worrying because I > added regression tests on hid, but I don't have access to all of the > various tablets, so I implemented them from the Microsoft > specification[0]. We need a special case for you here. The issue preventing David from mapping HID_DG_ERASER to BTN_STYLUS2 is that the hidinput_hid_event is not compatible with hidinput_setkeycode. If usage->code is no longer BTN_TOUCH after remapping, it won't be released when Eraser reports 0. A simple fix is: --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1589,7 +1589,7 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct /* value is off, tool is not rubber, ignore */ return; else if (*quirks & HID_QUIRK_NOINVERT && - !test_bit(BTN_TOUCH, input->key)) { + !test_bit(usage->code, input->key)) { /* * There is no invert to release the tool, let hid_input * send BTN_TOUCH with scancode and release the tool after. This change alone fixes David's problem and the right-click mapping in hwdb works again. However, the tool switches to rubber for the remapped eraser (here BTN_STYLUS2) events, both for devices with and without Invert. This does no harm but is not useful either. A cleaner solution for devices without Invert would be to omit the whole tool switching logic in this case: @@ -1577,6 +1577,9 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct switch (usage->hid) { case HID_DG_ERASER: + if (*quirks & HID_QUIRK_NOINVERT && usage->code != BTN_TOUCH) + break; + report->tool_active |= !!value; Remapping Invert does not work anyway as the Invert tool is hardcoded in hidinput_hid_event. Even worse, I guess (not tested) trying to do so would mask BTN_TOOL_RUBBER from dev->keybit and could cause weird behavior similar to one between 87562fcd1342 and 276e14e6c3. This raises the question: should users be able to remap Invert after all?