diff mbox

[10/13] HID: wiimote: use ABS_GYRO_* bits for MP

Message ID 1383336984-26601-11-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

David Herrmann Nov. 1, 2013, 8:16 p.m. UTC
Use the new gyroscope bits for motion-plus. The used ABS_R? bits are
ambiguous and should be replaced by proper bits to not confuse generic
user-space.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/hid/hid-wiimote-modules.c | 44 ++++++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c
index 777f932..e51e82b 100644
--- a/drivers/hid/hid-wiimote-modules.c
+++ b/drivers/hid/hid-wiimote-modules.c
@@ -2222,9 +2222,16 @@  static void wiimod_mp_in_mp(struct wiimote_data *wdata, const __u8 *ext)
 	else
 		z *= 9;
 
-	input_report_abs(wdata->mp, ABS_RX, x);
-	input_report_abs(wdata->mp, ABS_RY, y);
-	input_report_abs(wdata->mp, ABS_RZ, z);
+	if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) {
+		input_report_abs(wdata->mp, ABS_RX, x);
+		input_report_abs(wdata->mp, ABS_RY, y);
+		input_report_abs(wdata->mp, ABS_RZ, z);
+	} else {
+		input_report_abs(wdata->mp, ABS_GYRO_X, x);
+		input_report_abs(wdata->mp, ABS_GYRO_Y, y);
+		input_report_abs(wdata->mp, ABS_GYRO_Z, z);
+	}
+
 	input_sync(wdata->mp);
 }
 
@@ -2274,15 +2281,28 @@  static int wiimod_mp_probe(const struct wiimod_ops *ops,
 	wdata->mp->name = WIIMOTE_NAME " Motion Plus";
 
 	set_bit(EV_ABS, wdata->mp->evbit);
-	set_bit(ABS_RX, wdata->mp->absbit);
-	set_bit(ABS_RY, wdata->mp->absbit);
-	set_bit(ABS_RZ, wdata->mp->absbit);
-	input_set_abs_params(wdata->mp,
-			     ABS_RX, -16000, 16000, 4, 8);
-	input_set_abs_params(wdata->mp,
-			     ABS_RY, -16000, 16000, 4, 8);
-	input_set_abs_params(wdata->mp,
-			     ABS_RZ, -16000, 16000, 4, 8);
+
+	if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) {
+		set_bit(ABS_RX, wdata->mp->absbit);
+		set_bit(ABS_RY, wdata->mp->absbit);
+		set_bit(ABS_RZ, wdata->mp->absbit);
+		input_set_abs_params(wdata->mp,
+				     ABS_RX, -16000, 16000, 4, 8);
+		input_set_abs_params(wdata->mp,
+				     ABS_RY, -16000, 16000, 4, 8);
+		input_set_abs_params(wdata->mp,
+				     ABS_RZ, -16000, 16000, 4, 8);
+	} else {
+		set_bit(ABS_GYRO_X, wdata->mp->absbit);
+		set_bit(ABS_GYRO_Y, wdata->mp->absbit);
+		set_bit(ABS_GYRO_Z, wdata->mp->absbit);
+		input_set_abs_params(wdata->mp,
+				     ABS_GYRO_X, -16000, 16000, 4, 8);
+		input_set_abs_params(wdata->mp,
+				     ABS_GYRO_Y, -16000, 16000, 4, 8);
+		input_set_abs_params(wdata->mp,
+				     ABS_GYRO_Z, -16000, 16000, 4, 8);
+	}
 
 	ret = input_register_device(wdata->mp);
 	if (ret)