lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220410220713.5303-1-dbdaniel42@gmail.com>
Date:   Sun, 10 Apr 2022 17:07:13 -0500
From:   Daniel Bomar <dbdaniel42@...il.com>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Jiri Kosina <jikos@...nel.org>,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>
Cc:     linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
        Daniel Bomar <dbdaniel42@...il.com>
Subject: [PATCH 4/4] input: hid-microsoft: Implement trigger rumble for Xbox One S over bluetooth

Signed-off-by: Daniel Bomar <dbdaniel42@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ