Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp885013rdb; Wed, 6 Dec 2023 02:47:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9WTQrfFpLTDHE/ZV/o76VjIHyWBhyhza/tk/KtOeP4WHosPssLuQpUYdpqpzELXYM2/nd X-Received: by 2002:a05:6a20:26a8:b0:18f:d12d:c62f with SMTP id h40-20020a056a2026a800b0018fd12dc62fmr326041pze.27.1701859668581; Wed, 06 Dec 2023 02:47:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701859668; cv=none; d=google.com; s=arc-20160816; b=vAK1dbbFzdzTlCH+Bbl3NAIy7O+4XRnX5iCVF2kqRs/sPBaP2WLZqRAOj5BXqD0Yvs lp2ruGGz7CPAdtlGltoIFYhUsMQjgfepcdJci9tM2KWGU7qkDNevmqmZkkfhNSMo18EZ K8ZtNzXlasQhLHTXAIJWXemBDkSCnZm3RP/r6aWnJ1xzYESz6aG2Mozypuc1aLf4NEhO SwcEtCj+YCqbhrRpgcrXCHgHT2+NXfhSyI1HV2gKxPM1tg1JChVEQVZFJAJ7Dw1VS+SU /7ZU1eTIt4958veqwuDzW31aKVVHIjp2BpXrcH3wu36dCj7e22oSEQcMvRKPgA5u5QU3 pBUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=LH2aydkaFOP9WcFc27utmudUlDjgT3vr4vL7uv8ejes=; fh=M/4CRKlsQR53kOvbvsHfGDOrpcvBUt/h3Rh4tB3zkdA=; b=RkAR+agOM7y12GsIkjeyZf0VuU0REM1MZLWW9/ok9rY9gzBpo6OD2p1015uw2D3msM azJbF/dKtTnykxHNVjFwrN9z/cL6ept47zjbtdfsLfUudYbQeUUMICQ9ZWNrAlrpZ1ru urKBxsecjILn27oe3Q1E2CU5VJ9Jf0W3WNvgogv92eE95XeYAH+MPkmP4zgLhG+nETOC 9EVRHJL2KuHjw4BRkWBkuw/hERx+0gELBO1DS0Iv0UlZbSGx36C49TnmbrcRvOdpiI1x BW/LHDv/Z6iicQ8faR44Ygm1doSgHrjcU9liVWaSCcDHC+O9j1yoVznB5c2ffQNzxA/8 TH+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/k8QP7e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id v13-20020a170903238d00b001cfb55da13bsi5106358plh.332.2023.12.06.02.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:47:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Z/k8QP7e"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9B2D980323CB; Wed, 6 Dec 2023 02:47:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377828AbjLFKrX (ORCPT + 99 others); Wed, 6 Dec 2023 05:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377739AbjLFKqs (ORCPT ); Wed, 6 Dec 2023 05:46:48 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00B3719BB for ; Wed, 6 Dec 2023 02:46:31 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECCCAC4339A; Wed, 6 Dec 2023 10:46:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701859591; bh=pOwfO/gTl6S07OObuc/xFJuitivPZGd6txL7TG2VpdI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z/k8QP7ehxdzQ+wMfGwuGeX8E6NC+M7NKGeHf+LeZ2AIQCEGk9p4cyUv5364rTcJY 6EBAVmvirMZuI6P8LWhmjY9o0ZjX27CYnNOetj+qRE4NoYPTrLBTWhsfBwUoU9X/GB kywlgKyHHQD829SGpt4exE28uA9VOsMzAM47hnxX2o244tNDrOT4+8BdqBTYk8qiAO eY4jJ0bxpduwNZ5qu4nqjRVd3xSM0XD0qWvlZUD/ZztYn+VCRUv/ZeEn5Nn3mB0sIE GkNiyui6EiUJSH2BBKurGqMILz67KkUrtCRf8ViKxLdepZam9vMwJ9/v56wPB18W1R CotAg5Y9VFSew== From: Benjamin Tissoires Date: Wed, 06 Dec 2023 11:46:03 +0100 Subject: [PATCH v2 12/15] selftests/hid: tablets: add a secondary barrel switch test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231206-wip-selftests-v2-12-c0350c2f5986@kernel.org> References: <20231206-wip-selftests-v2-0-c0350c2f5986@kernel.org> In-Reply-To: <20231206-wip-selftests-v2-0-c0350c2f5986@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Peter Hutterer Cc: linux-input@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1701859565; l=4659; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=pOwfO/gTl6S07OObuc/xFJuitivPZGd6txL7TG2VpdI=; b=wrlXNzdiguWIptxukcqXa2fnRQeQcKRGiUx1HKABt9ZlVc6LtKjYqva/lT659XLdF+qqJIoyC qt9oypaa+67CswJPbaVhNdtT8xQEXXCis25SzooEX+8ArkOWfOd40L4 X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 06 Dec 2023 02:47:43 -0800 (PST) Some tablets report 2 barrel switches. We better test those too. Use the same transistions description from the primary button tests. Reviewed-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v2 --- tools/testing/selftests/hid/tests/test_tablet.py | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tools/testing/selftests/hid/tests/test_tablet.py b/tools/testing/selftests/hid/tests/test_tablet.py index 20a7a7fdcd9d..a82db66264c5 100644 --- a/tools/testing/selftests/hid/tests/test_tablet.py +++ b/tools/testing/selftests/hid/tests/test_tablet.py @@ -366,6 +366,56 @@ class PenState(Enum): ), } + @staticmethod + def legal_transitions_with_secondary_button() -> Dict[str, Tuple["PenState", ...]]: + """We revisit the Windows Pen Implementation state machine: + we now have a secondary button. + Note: we don't looks for 2 buttons interactions. + """ + return { + "hover-button": (PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON,), + "hover-button -> out-of-range": ( + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_OUT_OF_RANGE, + ), + "in-range -> button-press": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + ), + "in-range -> button-press -> button-release": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_RANGE, + ), + "in-range -> touch -> button-press -> button-release": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_CONTACT, + PenState.PEN_IS_IN_CONTACT_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_CONTACT, + ), + "in-range -> touch -> button-press -> release -> button-release": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_CONTACT, + PenState.PEN_IS_IN_CONTACT_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_RANGE, + ), + "in-range -> button-press -> touch -> release -> button-release": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_CONTACT_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_RANGE, + ), + "in-range -> button-press -> touch -> button-release -> release": ( + PenState.PEN_IS_IN_RANGE, + PenState.PEN_IS_IN_RANGE_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_CONTACT_WITH_SECOND_BUTTON, + PenState.PEN_IS_IN_CONTACT, + PenState.PEN_IS_IN_RANGE, + ), + } + @staticmethod def tolerated_transitions() -> Dict[str, Tuple["PenState", ...]]: """This is not adhering to the Windows Pen Implementation state machine @@ -444,6 +494,7 @@ class Pen(object): self.width = 10 self.height = 10 self.barrelswitch = False + self.secondarybarrelswitch = False self.invert = False self.eraser = False self.xtilt = 1 @@ -736,6 +787,22 @@ class BaseTest: """Rework the transition state machine by adding the primary button.""" self._test_states(state_list, scribble) + @pytest.mark.skip_if_uhdev( + lambda uhdev: "Secondary Barrel Switch" not in uhdev.fields, + "Device not compatible, missing Secondary Barrel Switch usage", + ) + @pytest.mark.parametrize("scribble", [True, False], ids=["scribble", "static"]) + @pytest.mark.parametrize( + "state_list", + [ + pytest.param(v, id=k) + for k, v in PenState.legal_transitions_with_secondary_button().items() + ], + ) + def test_valid_secondary_button_pen_states(self, state_list, scribble): + """Rework the transition state machine by adding the secondary button.""" + self._test_states(state_list, scribble) + @pytest.mark.skip_if_uhdev( lambda uhdev: "Invert" not in uhdev.fields, "Device not compatible, missing Invert usage", -- 2.41.0