All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] input: hid-microsoft: Implement trigger rumble for Xbox One S over bluetooth
@ 2022-04-10 22:07 Daniel Bomar
  0 siblings, 0 replies; only message in thread
From: Daniel Bomar @ 2022-04-10 22:07 UTC (permalink / raw)
  To: Dmitry Torokhov, Jiri Kosina, Benjamin Tissoires
  Cc: linux-input, linux-kernel, Daniel Bomar

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-10 22:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-10 22:07 [PATCH 4/4] input: hid-microsoft: Implement trigger rumble for Xbox One S over bluetooth Daniel Bomar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.