From: Daniel Bomar <dbdaniel42@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Daniel Bomar <dbdaniel42@gmail.com>
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 [thread overview]
Message-ID: <20220410220713.5303-1-dbdaniel42@gmail.com> (raw)
Signed-off-by: Daniel Bomar <dbdaniel42@gmail.com>
---
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;
--
2.35.1
reply other threads:[~2022-04-10 22:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220410220713.5303-1-dbdaniel42@gmail.com \
--to=dbdaniel42@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox