Received: by 2002:a05:7412:4e10:b0:e2:908c:2ebd with SMTP id gb16csp57603rdb; Tue, 7 Nov 2023 00:01:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFG/jnTg7ziZ3tiL/Jto5QPyGohqnduAzrTOBhZa/8enGvRS1kV8Kb9+ZTGRlfz/xBJesdO X-Received: by 2002:a05:6358:1905:b0:168:eada:cf98 with SMTP id w5-20020a056358190500b00168eadacf98mr31581161rwm.29.1699344094035; Tue, 07 Nov 2023 00:01:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699344093; cv=none; d=google.com; s=arc-20160816; b=snOXQbFOYeZSm6s+ciE6f31Y3VeqWlm2jlqoDKcKJSWt3+oY5zMF1xh7NsnsfT7xaM EvuWQLal7d+9sFC+Q1ZtBn2nrJoAechY8s7IP7PWG76wfj1ksE0AKbgZ0pO2QIoUNK3W aRgkt29hO+1w1qT93PXbKWON2OeAdf0tseVPztrSkAqfC+eEZKwKXKYg7CDvcO4uFkwg 2EjqyUOirtvYxJ/XlkDB3z0cMqjOHTq4GSfuhyDdLRhlU8p79IXm9qdpSGVKXtxSj//U 6aLRgnDHUqYMNeiqoZ6u23mgXe4XoBdw4Nr97AnwpPUYbNJ2Dkqmqj2MFfrTvIFsbbnL B7XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fS33WX/TP1PBbgnGRlYS4ZqDoFTuXKV4PZ845SjCyEc=; fh=yRSfRh+HJff8OWtOFaGW0l7RKkuo36XGDAoEjIptAag=; b=KBn7WG+49fh4MGORv1Mt4KcSkZbwAnaurWvhTKSnAiW6fbnDPjU399ofduoR8SploT Wx75SI0bc2eH7A09rQWTqmI+kzYweNucxWiCEd9ucuBuDiEpoD+kyOUni+vYtuQCywJ+ IlmVxbfF7Ot8MoqU1TC9y/RWm+hE7SGbGPOmT05EVfzstnCGvw/MCiuZJ4eInVCS8xTn 4btheH51Fl2PZ5Jx3ycWTleQQlwawfKp2fFKvmolCnWpdBUTI7ZMOGkdaYm9PeWt4ti/ YpM9NV86rddyiugEHrYd3bHCc//Fpj8xGB0OvDzrKWgCv2R5RGOVhH7t7xg9kiJetFb/ rtjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YA2lBfx7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ca33-20020a056a0206a100b00578f7063adasi1672847pgb.33.2023.11.07.00.01.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 00:01:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YA2lBfx7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 293798029845; Tue, 7 Nov 2023 00:01:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233590AbjKGIAz (ORCPT + 99 others); Tue, 7 Nov 2023 03:00:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233681AbjKGIAx (ORCPT ); Tue, 7 Nov 2023 03:00:53 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5C9AFD for ; Tue, 7 Nov 2023 00:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699344004; 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=fS33WX/TP1PBbgnGRlYS4ZqDoFTuXKV4PZ845SjCyEc=; b=YA2lBfx7Wrd6i8FuWBzkq4X7pJVh541adBHrnb3yUmUAnW/g3b89YC89YPMa6SKzDzxy0S ILZhK8saSBPDiwXMywkvdWKH/L3aguSIray4rptfuA9laMyQOKFSMjR6PL5nyl91oFqylK SJ+MC9rPfWBK6WfbcFX16iupp/33oP8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-126-1_8S739kOQ6q5yGm9A9SSg-1; Tue, 07 Nov 2023 03:00:03 -0500 X-MC-Unique: 1_8S739kOQ6q5yGm9A9SSg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9dd489c98e7so256513666b.2 for ; Tue, 07 Nov 2023 00:00:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699344002; x=1699948802; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fS33WX/TP1PBbgnGRlYS4ZqDoFTuXKV4PZ845SjCyEc=; b=MP6pXTlEKEm0k967ai5f9TY0kmmJrRYRqcwL2aar89yMFkk63UGlvDJSw9qDaZaAOy /zlTlu7BiesfIS1OeJ565KLFJmMblKQWZJdtZ+Xz9eNEOrw970TVGR+hjHTDwqaO0Q7A mC40xq+80bMFjdwdMmTgqbYQUyL8sS0Jf0wOSo3ycmgyqVhQbs0FxbtHwV/BEbyPjwLK sEjz09zsdSoTp5K96lzElo8LOroO34urADWUHcknTiFma4ciAy9uqcdlNkEm2Qc2XmFi Sl4ykOP6/EHGxfWxC+JRvnnjilur6azhfr3ttNxKPtprCHoOFHgisTqF0YrqatsKd3+D t0Hg== X-Gm-Message-State: AOJu0YzBffoLIWeRmdSLZfA4tjSCF7aVbkz9p7bbG8jN+1fjPU4LDmmb Er6AvMyinSRfz2lWciroU9BVQDcBEvSyAvS0DstQTEMPR69wWsNFPiNnOMJulbO0c0ZgfdmA/l3 3rTd5BjUGgJhI4kfpYnZ6y13OAfS0j5jcuANl1Lef X-Received: by 2002:a17:907:1392:b0:9d6:e1b5:1afa with SMTP id vs18-20020a170907139200b009d6e1b51afamr10270530ejb.46.1699344002158; Tue, 07 Nov 2023 00:00:02 -0800 (PST) X-Received: by 2002:a17:907:1392:b0:9d6:e1b5:1afa with SMTP id vs18-20020a170907139200b009d6e1b51afamr10270509ejb.46.1699344001694; Tue, 07 Nov 2023 00:00:01 -0800 (PST) MIME-Version: 1.0 References: <20231103200524.53930-1-ostapyshyn@sra.uni-hannover.de> In-Reply-To: From: Benjamin Tissoires Date: Tue, 7 Nov 2023 08:59:50 +0100 Message-ID: Subject: Re: Requesting your attention and expertise regarding a Tablet/Kernel issue To: Illia Ostapyshyn Cc: David Revoy , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 07 Nov 2023 00:01:31 -0800 (PST) On Mon, Nov 6, 2023 at 9:06=E2=80=AFPM Illia Ostapyshyn wrote: > > 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. That's exactly why I want to see the exact event flow. We can not do "wild guesses" unfortunately (not meaning any offenses). And I am very suspicious about the fact that the stylus reports 2 identical erasers. Because in the past David seemed to be able to have 2 distincts behaviors for the 2 "buttons" (physical button and eraser tail). > > > > 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: I must confess, being the one who refactored everything, I still don't believe this is as simple as it may seem. I paged out all of the special cases, and now, without seeing the event flow I just can not understand why this would fix the situation. And BTW, if you have a tool affected by 276e14e6c3, I'd be curious to get a hid-recorder sample for it so I can get regression tests for it. > > --- 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)) { I don't want to be rude, but this feels very much like black magic, especially because there is a comment just below and it is not updated. So either the explanation was wrong, or it's not explaining the situation (I also understand that this is not a formal submission, so maybe that's the reason why the comment is not updated). > /* > * There is no invert to release the tool, let hi= d_input > * send BTN_TOUCH with scancode and release the t= ool 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 !=3D BTN_= TOUCH) > + break; > + > report->tool_active |=3D !!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? > The kernel is supposed to transfer what the device is. So if it says this is an eraser, we should not try to change it. Users can then tweak their own device if they wish through hid-bpf or through libinput quirks, but when you install a fresh kernel without tweaks, we should be as accurate as possible. My main concern is that now we have a device which exports 2 different interactions as being the same. So either the firmware is wrong, and we need to quirk it, or the kernel is wrong and merges both, and this needs fixes as well. Once every interaction on the device gets its own behavior, userspace can do whatever they want. It's not the kernel's concern anymore. BTW, David, were you able to do a revert of 276e14e6c3? Cheers, Benjamin