From patchwork Sun Apr 10 22:06:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bomar X-Patchwork-Id: 12808327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A1D7C433EF for ; Sun, 10 Apr 2022 22:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241634AbiDJWIy (ORCPT ); Sun, 10 Apr 2022 18:08:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239481AbiDJWIx (ORCPT ); Sun, 10 Apr 2022 18:08:53 -0400 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772DC25C53; Sun, 10 Apr 2022 15:06:41 -0700 (PDT) Received: by mail-qk1-x736.google.com with SMTP id t207so7918032qke.2; Sun, 10 Apr 2022 15:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lUcJJmfd/iKH5QzT7MteJYXqisZV9mqEGEpy1uMnjR0=; b=kVQ+O2fXRoRP9P2JAJlKbts4usvZAKbC9A/O3T5gjHXO/6JpiRb1h6qayogHtW44If 5A60r1kq+s2pR1DXMjn9fwnkCH3cMvWDGNzBN2WwPXst0mmrtXYDpKWhSiffGFRExtBh crVPvHdRpe03KeA5XzXanuzw+rTqw1YzTcUZ0k0vqJjrIhFqxACEG7FMYiV3PtfJRH9s JmZ/ufHEPlBxMPfmw5/hWVuvHEMjNLCpZ3zoZjuxJcz0rlykdPVOF5+xWhOZrCFS8kZl RwbaAn3c8hSQJnW6JLVKBWiYJB0XMtaG8sPfZpm/plaMlqpSOISur5JbpX6qMBEkAZ/S mjCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lUcJJmfd/iKH5QzT7MteJYXqisZV9mqEGEpy1uMnjR0=; b=pRfMZl/wMBf1truKftRB16q22sNyeI2onu+bFAL/7iu327DOrNKADexH4rG5xkOk30 wzMePaPAPh/qYh8uNjoufeDmL7EHD6sA24ky4Csc4N68wMCELnon9EUuToYRz7B72Aj+ VUtet/g0EtArox3ogaY7/OpyDCyZ2RC8UGGKSXA+DDSjucEz2fH7I77DkOYbri5VpTNx ZaOMebgxMU+0uCTAmV89r+8bHshxey0839KXZXEtzuq9O2S3EVQfdsVxe/VCZWyjcU/O DX9qMi6/FUHLwHEaQs28KY8MqQR9hGmMBcbLQFHT33zewr73B7JoPewzgGE7bTxj8sud d5gA== X-Gm-Message-State: AOAM530W48jZifWNIQ9qqW0TrtIreD2H0kbzV+Q7JRWs0w093CkAhtHY 2rzegD5zlYMjso19uB+aYn/aou20rIOo X-Google-Smtp-Source: ABdhPJzRNctQz8OrVtRyXjs9kyzfCMG4ZVnB90KI8d5kihZ/gf4srvIUDKa1LRx43exU0vdDusibeA== X-Received: by 2002:a37:9b52:0:b0:69a:e26:61aa with SMTP id d79-20020a379b52000000b0069a0e2661aamr11509149qke.159.1649628400671; Sun, 10 Apr 2022 15:06:40 -0700 (PDT) Received: from arch.. ([2607:fb90:966:1288:8e89:a5ff:fe6f:56d3]) by smtp.gmail.com with ESMTPSA id g21-20020ac85815000000b002e06e2623a7sm22688416qtg.0.2022.04.10.15.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 15:06:40 -0700 (PDT) From: Daniel Bomar To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Bomar Subject: [PATCH 1/4] input: uapi: Add trigger_left and trigger_right to ff_rumble_effect struct Date: Sun, 10 Apr 2022 17:06:33 -0500 Message-Id: <20220410220633.5235-1-dbdaniel42@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add 2 variables to the control the trigger motors into the struct that gets passed in from userspace. ff_rumble_effect is part of a union in ff_effect. This does not grow the total size of the union so should be ABI compatible. Signed-off-by: Daniel Bomar --- include/uapi/linux/input.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index ee3127461ee0..d187e00d91a1 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -415,6 +415,8 @@ struct ff_periodic_effect { * struct ff_rumble_effect - defines parameters of a periodic force-feedback effect * @strong_magnitude: magnitude of the heavy motor * @weak_magnitude: magnitude of the light one + * @trigger_left: magnitude of the motor behind the left trigger + * @trigger_right: magnitude of the motor behind the right trigger * * Some rumble pads have two motors of different weight. Strong_magnitude * represents the magnitude of the vibration generated by the heavy one. @@ -422,6 +424,8 @@ struct ff_periodic_effect { struct ff_rumble_effect { __u16 strong_magnitude; __u16 weak_magnitude; + __u16 trigger_left; + __u16 trigger_right; }; /** From patchwork Sun Apr 10 22:06:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bomar X-Patchwork-Id: 12808328 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A9C3C433FE for ; Sun, 10 Apr 2022 22:06:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243016AbiDJWJH (ORCPT ); Sun, 10 Apr 2022 18:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239481AbiDJWJG (ORCPT ); Sun, 10 Apr 2022 18:09:06 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE7453B45; Sun, 10 Apr 2022 15:06:54 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id s6so471818qta.1; Sun, 10 Apr 2022 15:06:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ekLghVlZfgJwOBvVk0WUfBdIri575Qvb/4XkzJn/Y4Q=; b=KojYOOba95CBmF32aU1+Yn/XxtV9YXQvuXlu53ilpVUMqT/Wg/ELWkiE4IRqB25ENg alX4kHDkPTI3CAHSv/iajtLe4IZkaODbc+8vOFaTVyDeTmFGLc51IqeILQAzXh5p40qZ Dicu9tqdy5uOC5Ythd/zjPeOpcvbNCmyp8ih8RIZkmSRMcvpux0jaaPJ3sxZeHqw9tVw z3TDyEvbGnBLtQrZkvijiX4m6jFPZOk6OtqNgdspXOxCzyqFQp3PQEi2uYbSsYtSiaNt x/1E9S14oP2zkaaFGUgwmox1GB8cGbN+a7H6CaVLBVIsealCfIAVqR4aD5r8CTzEb6QA 4vFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ekLghVlZfgJwOBvVk0WUfBdIri575Qvb/4XkzJn/Y4Q=; b=sHRZsnYwy1KMPQy1Y3Mlrl1kQjdRBlQE1q7qRGFTQm8f/IbuXZR0t/0JKeLLWWAMec lG1ArxP1vTcoLh3B9WMEewiRDKc+5/chhovm9Ty/cSfAxD9uzk4W9g3KWLI03PPk4zwy bXY90bjl2I3RWsTdqHImEd+DGt/Ze/DNXSSpVixVvIZo7A1i2DSQsCcO9ljHYtCHyTkD lsK0Yumhkiqknul+cdnti32BMo7ZhfUWsn5yYoTthwjbtUYFVB+rhfF2eoXcCtHO3o/6 S6nbPiNNzegKCwjbiZD+aDqGOa+1JfvhcSCOrwwh5yMjfZIyHHroJ95IE70ijU5+EG5E CXXw== X-Gm-Message-State: AOAM530iOV6p86JidgGrajOFHsP3UwN6ISR9D8/99I7SEblDBFKid9F5 L76e/y3VAmQCPEO1P2HcHQ== X-Google-Smtp-Source: ABdhPJwBvvj2ofTwK3pUAoE58FHs8U7MZkuQFd+lL+72CF/Q7B0LrpYNnNCsSWvjTY4yjNG/4LhQkA== X-Received: by 2002:ac8:7090:0:b0:2ed:ca4:f08c with SMTP id y16-20020ac87090000000b002ed0ca4f08cmr8879694qto.57.1649628413190; Sun, 10 Apr 2022 15:06:53 -0700 (PDT) Received: from arch.. ([2607:fb90:966:1288:8e89:a5ff:fe6f:56d3]) by smtp.gmail.com with ESMTPSA id v67-20020a379346000000b0069bdb3bb132sm5343639qkd.37.2022.04.10.15.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 15:06:52 -0700 (PDT) From: Daniel Bomar To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Bomar Subject: [PATCH 2/4] input: ff-memless: Add trigger left/right in ml_combine_effects Date: Sun, 10 Apr 2022 17:06:49 -0500 Message-Id: <20220410220649.5258-1-dbdaniel42@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Signed-off-by: Daniel Bomar --- drivers/input/ff-memless.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/ff-memless.c b/drivers/input/ff-memless.c index 8229a9006917..7f3a19970608 100644 --- a/drivers/input/ff-memless.c +++ b/drivers/input/ff-memless.c @@ -245,7 +245,7 @@ static void ml_combine_effects(struct ff_effect *effect, int gain) { struct ff_effect *new = state->effect; - unsigned int strong, weak, i; + unsigned int strong, weak, trigger_left, trigger_right, i; int x, y; s16 level; @@ -271,6 +271,8 @@ static void ml_combine_effects(struct ff_effect *effect, case FF_RUMBLE: strong = (u32)new->u.rumble.strong_magnitude * gain / 0xffff; weak = (u32)new->u.rumble.weak_magnitude * gain / 0xffff; + trigger_left = (u32)new->u.rumble.trigger_left * gain / 0xffff; + trigger_right = (u32)new->u.rumble.trigger_right * gain / 0xffff; if (effect->u.rumble.strong_magnitude + strong) effect->direction = ml_calculate_direction( @@ -289,6 +291,10 @@ static void ml_combine_effects(struct ff_effect *effect, 0xffffU); effect->u.rumble.weak_magnitude = min(weak + effect->u.rumble.weak_magnitude, 0xffffU); + effect->u.rumble.trigger_left = + min(trigger_left + effect->u.rumble.trigger_left, 0xffffU); + effect->u.rumble.trigger_right = + min(trigger_right + effect->u.rumble.trigger_right, 0xffffU); break; case FF_PERIODIC: From patchwork Sun Apr 10 22:07:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bomar X-Patchwork-Id: 12808329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB027C433EF for ; Sun, 10 Apr 2022 22:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243047AbiDJWJV (ORCPT ); Sun, 10 Apr 2022 18:09:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243013AbiDJWJU (ORCPT ); Sun, 10 Apr 2022 18:09:20 -0400 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BF504F47D; Sun, 10 Apr 2022 15:07:07 -0700 (PDT) Received: by mail-qv1-xf36.google.com with SMTP id p8so11903180qvv.5; Sun, 10 Apr 2022 15:07:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JR0xVHqHdbQUb+iGPJt6PwEd5Z6tp6DNOoS3GUblF6k=; b=AiFrLw/Wa+EhA+gjW+n0QFsvk8ReDL+AkeKJ+uB/FJhacehCxJqq2ihhm2WYW/9sAu Ivckgdz13+Chxz8JZSIFe9cpbHKL+SSWwvmdH11/O4vGLXIi1lAYv00awDhTznkQgFkt WZE0Cdm0j9mqXaOKo2Ag7/MtjEN40C3+4fiMod9ATzXzxrcXDALlH+kEBUcJqCvrtWy+ saPdsAPlnktGn39icg8RegMPttlu6Chdnf3mMzgUJgkwvXtI9N/i1HnRdd3YNNPhhAnN BTPtoANxPuIsCVPMlFw1w/V4E8TrG4etllPLQ9THin654VT8B0Xjge6maPZig3tUnbqn iDjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JR0xVHqHdbQUb+iGPJt6PwEd5Z6tp6DNOoS3GUblF6k=; b=Eus52jobfytK7yf2TwpccyMxgHmU9RCJ/k6pJp+rKrgsfI+qNF34P90KNynj4iuFxO w9AInSM8rKm5drC61oITsfPuqZCuUUNmQ4FaxviOIrlG5sXXnRrhDrFb21fNT6bhSopQ bbZs3x+4WUEo/L81UO9f2LRJdAVR/BoxJDan33quDfmtUBhYtzh5RzcSy7L5ykDTbLJf zX914aACPaMI70URfEm0zHNYJ87DNLS4S7ApCA6AEufxEfruR5N/ndhHf3/Mlt7gBHGM HtyZMEYMWNp6T6V/lhIMsPSg0INVi1p1n+v5NZ7sh5jvi2Xpw2N0FyBWbDqJKfkEbCe0 i6vg== X-Gm-Message-State: AOAM533D9TbdbrypSse8EMxrHEeS5b9nDByz1BvwYasoFtm4JuFy6vtc NB9h1EQlWz9sv1jlTrd0gA== X-Google-Smtp-Source: ABdhPJxVPMRHq0w4uY7YWfj1Psknqr1kqsC8TIZg/L70IL+CzN1oESbaSW/YnTXu4pqsAlN+8aDmpQ== X-Received: by 2002:a05:6214:1cc4:b0:431:4cbc:1d91 with SMTP id g4-20020a0562141cc400b004314cbc1d91mr24977694qvd.64.1649628426859; Sun, 10 Apr 2022 15:07:06 -0700 (PDT) Received: from arch.. ([2607:fb90:966:1288:8e89:a5ff:fe6f:56d3]) by smtp.gmail.com with ESMTPSA id b40-20020a05620a272800b0069c10f8825asm1844532qkp.130.2022.04.10.15.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 15:07:06 -0700 (PDT) From: Daniel Bomar To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Bomar Subject: [PATCH 3/4] input: xpad: Implement trigger rumble for Xbox One controllers Date: Sun, 10 Apr 2022 17:07:01 -0500 Message-Id: <20220410220701.5279-1-dbdaniel42@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Signed-off-by: Daniel Bomar --- drivers/input/joystick/xpad.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 18190b529bca..0ac59ce03e58 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1251,6 +1251,8 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; __u16 strong; __u16 weak; + __u16 trigger_left; + __u16 trigger_right; int retval; unsigned long flags; @@ -1259,6 +1261,8 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect strong = effect->u.rumble.strong_magnitude; weak = effect->u.rumble.weak_magnitude; + trigger_left = effect->u.rumble.trigger_left; + trigger_right = effect->u.rumble.trigger_right; spin_lock_irqsave(&xpad->odata_lock, flags); @@ -1311,8 +1315,8 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect packet->data[3] = 0x09; packet->data[4] = 0x00; packet->data[5] = 0x0F; - packet->data[6] = 0x00; - packet->data[7] = 0x00; + packet->data[6] = trigger_left / 512; + packet->data[7] = trigger_right / 512; packet->data[8] = strong / 512; /* left actuator */ packet->data[9] = weak / 512; /* right actuator */ packet->data[10] = 0xFF; /* on period */ From patchwork Sun Apr 10 22:07:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Bomar X-Patchwork-Id: 12808330 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7491C433F5 for ; Sun, 10 Apr 2022 22:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243969AbiDJWJc (ORCPT ); Sun, 10 Apr 2022 18:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238297AbiDJWJa (ORCPT ); Sun, 10 Apr 2022 18:09:30 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFCF648E75; Sun, 10 Apr 2022 15:07:18 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id c1so2067788qke.10; Sun, 10 Apr 2022 15:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lLhtRYu7uRpqF6UzH4W4hGNVqeKtsIf+LFdDV1FH9AA=; b=Pf9KD80gKq4lpLTlNHSxm0OpmWpVF+lDJVeJDWonIAresYV4KaG2Je1CxJYc0JNcEn bh3BdAGvY8MOKdlLjpa70kx6Gvbvv6bjfXka5ENV821QkPzRuROyiaYo92j1y4uzksVN TZZP7OzzR/hOZI1sDXEX1MmgW9YU7CLZP3F6Vpjjhc6cFwGsWIyowxwsTQ7KOqDbFqf8 oYFfAkAvx2ZNP5ovdbpsJyx+HS35Ne1zGxfLyr541S+CMSMU8AT5LN4Qo69qGtkFLcYH N0sKb03iMU81yIGNnyWJhs12ip8tQ9+bivtUbyVugwTIAbklNw1GtESqAQ6+VyPxQAo9 d8pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lLhtRYu7uRpqF6UzH4W4hGNVqeKtsIf+LFdDV1FH9AA=; b=W6/0vCwII2K9kjysLCmSwCKeemm1RnUEsIVrJ+UZkEh1u2vHNw/Fsy0RGz/GeE6fn5 9hNXqXFbnjlSvbaIGJc/Vf+zo+iqJww6RduG+vKaIoDIqZGYf9yhGHgDX8P6P0+5yK+R VYiwG5/4FlQjFKZMZxMh2hnJuY2GUM/KSab9zLlg/UKsQcbbX9k5N99PP8maZNeunjVD R3IynR0/sJyS5P4ekqTtCgIL3OUHZ9DrOQXKk6YwGcihSwqjrwRSj7mmW50UeDhuizvH p8eaR4sAtYvsJ2dcsoYgrngFUnQ1KbwFp/C62dHSKFARodeb9wfNeHYuTIaBAZkR+qz5 37Zg== X-Gm-Message-State: AOAM532rIwMOxHVJmzS1diESSw8Wp0gRuSelcg/pYxHB3b2ApHad/Iwh fmYvqmAMkpb89qITEC/lBC3ukzG3Jn2l X-Google-Smtp-Source: ABdhPJyOhDTxUv0dBoQrjbd/G4yGRICic04riEunSWDSyVxTqRkuEDZTp8MvJvrv5pVfpzVKwlkhkg== X-Received: by 2002:a05:620a:214f:b0:69b:f840:f8c3 with SMTP id m15-20020a05620a214f00b0069bf840f8c3mr5388160qkm.600.1649628437348; Sun, 10 Apr 2022 15:07:17 -0700 (PDT) Received: from arch.. ([2607:fb90:966:1288:8e89:a5ff:fe6f:56d3]) by smtp.gmail.com with ESMTPSA id r17-20020a05620a299100b00680b43004bfsm20916357qkp.45.2022.04.10.15.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Apr 2022 15:07:16 -0700 (PDT) From: Daniel Bomar To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Bomar Subject: [PATCH 4/4] input: hid-microsoft: Implement trigger rumble for Xbox One S over bluetooth Date: Sun, 10 Apr 2022 17:07:13 -0500 Message-Id: <20220410220713.5303-1-dbdaniel42@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Signed-off-by: Daniel Bomar --- drivers/hid/hid-microsoft.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index 071fd093a5f4..061275626c42 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c @@ -32,6 +32,8 @@ struct ms_data { unsigned long quirks; struct hid_device *hdev; struct work_struct ff_worker; + __u8 trigger_left; + __u8 trigger_right; __u8 strong; __u8 weak; void *output_report_dmabuf; @@ -40,9 +42,13 @@ struct ms_data { #define XB1S_FF_REPORT 3 #define ENABLE_WEAK BIT(0) #define ENABLE_STRONG BIT(1) +#define ENABLE_RIGHT BIT(2) +#define ENABLE_LEFT BIT(3) enum { - MAGNITUDE_STRONG = 2, + MAGNITUDE_LEFT, + MAGNITUDE_RIGHT, + MAGNITUDE_STRONG, MAGNITUDE_WEAK, MAGNITUDE_NUM }; @@ -288,7 +294,7 @@ static void ms_ff_worker(struct work_struct *work) memset(r, 0, sizeof(*r)); r->report_id = XB1S_FF_REPORT; - r->enable = ENABLE_WEAK | ENABLE_STRONG; + r->enable = ENABLE_WEAK | ENABLE_STRONG | ENABLE_RIGHT | ENABLE_LEFT; /* * Specifying maximum duration and maximum loop count should * cover maximum duration of a single effect, which is 65536 @@ -296,6 +302,8 @@ static void ms_ff_worker(struct work_struct *work) */ r->duration_10ms = U8_MAX; r->loop_count = U8_MAX; + r->magnitude[MAGNITUDE_LEFT] = ms->trigger_left; + r->magnitude[MAGNITUDE_RIGHT] = ms->trigger_right; r->magnitude[MAGNITUDE_STRONG] = ms->strong; /* left actuator */ r->magnitude[MAGNITUDE_WEAK] = ms->weak; /* right actuator */ @@ -316,6 +324,8 @@ static int ms_play_effect(struct input_dev *dev, void *data, /* * Magnitude is 0..100 so scale the 16-bit input here */ + ms->trigger_left = ((u32) effect->u.rumble.trigger_left * 100) / U16_MAX; + ms->trigger_right = ((u32) effect->u.rumble.trigger_right * 100) / U16_MAX; ms->strong = ((u32) effect->u.rumble.strong_magnitude * 100) / U16_MAX; ms->weak = ((u32) effect->u.rumble.weak_magnitude * 100) / U16_MAX;