Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp295469lqj; Wed, 10 Apr 2024 10:35:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9M9Y7EWTSERTqDAnKfzaN7C0eCiGk2P5VmBE4mQqpdn0uRDIi9cZ94TkD9/F1qx9Am/RUbKocvnEnE39nGztHGtv8qV95FDRS2birHQ== X-Google-Smtp-Source: AGHT+IFsB0YqXYY/UXqqFXrT5mHeMZebt7U2bTP3uJ4e1tot7XMHEAGZKZ3t3uXSJuvtrvsNX/RW X-Received: by 2002:a05:6a00:3a13:b0:6ea:df65:ff7d with SMTP id fj19-20020a056a003a1300b006eadf65ff7dmr3484385pfb.10.1712770530981; Wed, 10 Apr 2024 10:35:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712770530; cv=pass; d=google.com; s=arc-20160816; b=uHb+5xLmZvmrrlxZrKxRtn3oadG5QIRELB2gJ4uCr/yOiCFu7p8wV9mqYIVvkCFIqU LcVlr6bVbiOI1x8NvOll6MpcANFycoihuBbyTNMBdbGRY49OxUMqtVfftvF3yBMXMRd3 lgmdFtnXHRl8l8XZvG/Jb6K6moBJIP8BPTdwTz1rQ09rM8vynjQ+eSTMFO5nmHyeX3uu gpahSFYAHDCIaIwuKmyDwgkGOJhwrxe9wcxbWW5l6sa9oo14q/YAVRuuw7wyntD3SoWT 3Oi2lH5iXkQBLaRLuYg+SEY8AlWUoACBfmBHemSa7/+48cBYD2MnYAH6rXIAu4Cc5aEY nUeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=pDdq5APGO+FFT8JZgOSL8KfjCDggyWuYIZGsozr70Wo=; fh=ho438NhVBtcioQVDrg3lHWbSMg2+osFD2590tU+Apuc=; b=tKg9JAaJP/o+f8vs/Zaq75DaozQlMcfExCSsQWh346SJZ3RkcMLNZM4TNdSaaaWnE4 rSfxMbgZja4vCHN6el1+AGPb8ySvjrre6qsmIRRp6rZPXvsU0vN76gAGOublOe0J+hLS FGiYjeoomH76oTiBaV6419J6jsdwYBiUEo5aphGVOv2ND9YRTvPfymIq93qQH7Yk+iHC c64IF48JIWNHxhsUPIN0eZIiFuqgai11T67fTJ3AWe4QtlAHu1m2/sPhlyqupsbXHjJ/ q6GTQXwJMSoNSZxOpSk1ShuAeXKUUgSImYtaH/4+tK8WQfglpIpYjcJS7NOZjHwJtmRl clEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dybj+T4M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139089-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139089-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fm18-20020a056a002f9200b006e7137c1b04si10951631pfb.282.2024.04.10.10.35.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 10:35:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139089-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dybj+T4M; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-139089-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139089-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2C3FE289674 for ; Wed, 10 Apr 2024 17:24:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F304C194C71; Wed, 10 Apr 2024 17:20:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dybj+T4M" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 022D019069E; Wed, 10 Apr 2024 17:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769627; cv=none; b=mWzVhmoLde9+wOBUVaMqmvTn+g5Q+z6/xBLI1i8d5VZWj1LQOxTLx7pWMnJqOfurhtpwzLcsD0RiHb3GHCyCeSe/5HmkRHcZWlmuJN8WnGQqF5ZqF4MhgCyXxSGD3mChVKDyc5TNLIwkuB5CWIkaKuFaAXd2MA8dgK04y/PzgHg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712769627; c=relaxed/simple; bh=cW39rxLL7SNmaGCvHGHkPuHo9w+dGTGLLZl6+MwFSus=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fjbKOnjF/O+jGlsJagm2a+y+4xBwjDYVlrtTXP+r9sKM8LOP/JFJyJzbpkQ8Hp/EOqkkwzKzQcyHRFCWGyzf8gjep0yV4MkGxcKEOA+QxyBVSl2IAdLRSOR4qsS1PIZ6DTGatwArBJSrN9PHyoAQPr0yWeYWufm5kLIRzTohp3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dybj+T4M; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 778BAC433B1; Wed, 10 Apr 2024 17:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712769626; bh=cW39rxLL7SNmaGCvHGHkPuHo9w+dGTGLLZl6+MwFSus=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Dybj+T4MZ+9xXcNecuCD8ZyeFdCL0cI8dfA80X31p9Jtktjy0NTiodPrgm4IPCSZc LR78+QVgM6GkQhy/qSwkuggiO7+XpyWZsUXZoomAFNQvW6E/5dJIDSK8UC9zrA3b9F sDfhkogd6x1cO2oNk2Ue1JUEPXrmURtI6PBOEdHnRcVPIkid9YVURZaN2iewx0fR5q lwgaQyFSNd1MJuLQ5zpB731ZPlPexVeNJ9OdRbgOTPYqW1zRHP/9SUKb6UVdWeHLOn A6DE0zMuOv39xBEvc8N17GZWAsPhbNZcjpiGFmR/Sz+N+SEDL7wrmn3/hQVljvgO+V xOMwQ0Z+QfmDQ== From: Benjamin Tissoires Date: Wed, 10 Apr 2024 19:19:38 +0200 Subject: [PATCH 18/18] selftests/hid: add tests for the Raptor Mach 2 joystick Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240410-bpf_sources-v1-18-a8bf16033ef8@kernel.org> References: <20240410-bpf_sources-v1-0-a8bf16033ef8@kernel.org> In-Reply-To: <20240410-bpf_sources-v1-0-a8bf16033ef8@kernel.org> To: Jiri Kosina , Benjamin Tissoires , Shuah Khan , Peter Hutterer Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712769589; l=3284; i=bentiss@kernel.org; s=20230215; h=from:subject:message-id; bh=cW39rxLL7SNmaGCvHGHkPuHo9w+dGTGLLZl6+MwFSus=; b=ywHPEum0yoe1I9JQLPf4Fgbqf+WbEPJv48/GuUbFojAlXhjBfEQsHpTV0VwwNsJ/4bu42zsuZ hiQSyFEopFgAAYKB5BvwabsLbDizKbJqfaLUdrQXZGlgT+UOvLjhrQj X-Developer-Key: i=bentiss@kernel.org; a=ed25519; pk=7D1DyAVh6ajCkuUTudt/chMuXWIJHlv2qCsRkIizvFw= The only interesting bit is the HAT switch, and we use a BPF program to fix it. So ensure this works correctly. Signed-off-by: Benjamin Tissoires --- tools/testing/selftests/hid/tests/test_gamepad.py | 47 ++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/hid/tests/test_gamepad.py b/tools/testing/selftests/hid/tests/test_gamepad.py index bd30dadbeb7d..8d5b5ffdae49 100644 --- a/tools/testing/selftests/hid/tests/test_gamepad.py +++ b/tools/testing/selftests/hid/tests/test_gamepad.py @@ -10,7 +10,7 @@ from . import base import libevdev import pytest -from .base_gamepad import BaseGamepad, JoystickGamepad +from .base_gamepad import BaseGamepad, JoystickGamepad, AxisMapping from hidtools.util import BusType import logging @@ -609,6 +609,40 @@ class AsusGamepad(BaseGamepad): self.buttons = (1, 2, 4, 5, 7, 8, 14, 15, 13) +class RaptorMach2Joystick(JoystickGamepad): + axes_map = { + "left_stick": { + "x": AxisMapping("x"), + "y": AxisMapping("y"), + }, + "right_stick": { + "x": AxisMapping("z"), + "y": AxisMapping("Rz"), + }, + } + + def __init__( + self, + name, + rdesc=None, + application="Joystick", + input_info=(BusType.USB, 0x11C0, 0x5606), + ): + super().__init__(rdesc, application, name, input_info) + self.buttons = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) + self.hat_switch = 240 # null value is 240 as max is 239 + + def event( + self, *, left=(None, None), right=(None, None), hat_switch=None, buttons=None + ): + if hat_switch is not None: + hat_switch *= 30 + + return super().event( + left=left, right=right, hat_switch=hat_switch, buttons=buttons + ) + + class TestSaitekGamepad(BaseTest.TestGamepad): def create_device(self): return SaitekGamepad() @@ -617,3 +651,14 @@ class TestSaitekGamepad(BaseTest.TestGamepad): class TestAsusGamepad(BaseTest.TestGamepad): def create_device(self): return AsusGamepad() + + +class TestRaptorMach2Joystick(BaseTest.TestGamepad): + hid_bpfs = [("FR-TEC__Raptor-Mach-2.bpf.o", True)] + + def create_device(self): + return RaptorMach2Joystick( + "uhid test Sanmos Group FR-TEC Raptor MACH 2", + rdesc="05 01 09 04 a1 01 05 01 85 01 05 01 09 30 75 10 95 01 15 00 26 ff 07 46 ff 07 81 02 05 01 09 31 75 10 95 01 15 00 26 ff 07 46 ff 07 81 02 05 01 09 33 75 10 95 01 15 00 26 ff 03 46 ff 03 81 02 05 00 09 00 75 10 95 01 15 00 26 ff 03 46 ff 03 81 02 05 01 09 32 75 10 95 01 15 00 26 ff 03 46 ff 03 81 02 05 01 09 35 75 10 95 01 15 00 26 ff 03 46 ff 03 81 02 05 01 09 34 75 10 95 01 15 00 26 ff 07 46 ff 07 81 02 05 01 09 36 75 10 95 01 15 00 26 ff 03 46 ff 03 81 02 05 09 19 01 2a 1d 00 15 00 25 01 75 01 96 80 00 81 02 05 01 09 39 26 ef 00 46 68 01 65 14 75 10 95 01 81 42 05 01 09 00 75 08 95 1d 81 01 15 00 26 ef 00 85 58 26 ff 00 46 ff 00 75 08 95 3f 09 00 91 02 85 59 75 08 95 80 09 00 b1 02 c0", + input_info=(BusType.USB, 0x11C0, 0x5606), + ) -- 2.44.0