[PATCH 09/13] HID: wiimote: use ABS_ACCEL_* for accelerometer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the new ABS_ACCEL_* bits for accelerometer data _iff_ legacy mode is
not selected. ABS_R? is confusing and ambigiuous. ABS_ACCEL_* was
introduced exactly for accelerometers like the one of the wiimote.

Signed-off-by: David Herrmann <dh.herrmann@xxxxxxxxx>
---
 drivers/hid/hid-wiimote-modules.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c
index f3de94e..777f932 100644
--- a/drivers/hid/hid-wiimote-modules.c
+++ b/drivers/hid/hid-wiimote-modules.c
@@ -477,9 +477,16 @@ static void wiimod_accel_in_accel(struct wiimote_data *wdata,
 	y |= (accel[1] >> 4) & 0x2;
 	z |= (accel[1] >> 5) & 0x2;
 
-	input_report_abs(wdata->accel, ABS_RX, x - 0x200);
-	input_report_abs(wdata->accel, ABS_RY, y - 0x200);
-	input_report_abs(wdata->accel, ABS_RZ, z - 0x200);
+	if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) {
+		input_report_abs(wdata->accel, ABS_RX, x - 0x200);
+		input_report_abs(wdata->accel, ABS_RY, y - 0x200);
+		input_report_abs(wdata->accel, ABS_RZ, z - 0x200);
+	} else {
+		input_report_abs(wdata->accel, ABS_ACCEL_X, x - 0x200);
+		input_report_abs(wdata->accel, ABS_ACCEL_Y, y - 0x200);
+		input_report_abs(wdata->accel, ABS_ACCEL_Z, z - 0x200);
+	}
+
 	input_sync(wdata->accel);
 }
 
@@ -525,12 +532,25 @@ static int wiimod_accel_probe(const struct wiimod_ops *ops,
 	wdata->accel->name = WIIMOTE_NAME " Accelerometer";
 
 	set_bit(EV_ABS, wdata->accel->evbit);
-	set_bit(ABS_RX, wdata->accel->absbit);
-	set_bit(ABS_RY, wdata->accel->absbit);
-	set_bit(ABS_RZ, wdata->accel->absbit);
-	input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4);
-	input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4);
-	input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4);
+
+	if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) {
+		set_bit(ABS_RX, wdata->accel->absbit);
+		set_bit(ABS_RY, wdata->accel->absbit);
+		set_bit(ABS_RZ, wdata->accel->absbit);
+		input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4);
+		input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4);
+		input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4);
+	} else {
+		set_bit(ABS_ACCEL_X, wdata->accel->absbit);
+		set_bit(ABS_ACCEL_Y, wdata->accel->absbit);
+		set_bit(ABS_ACCEL_Z, wdata->accel->absbit);
+		input_set_abs_params(wdata->accel, ABS_ACCEL_X,
+				     -500, 500, 2, 4);
+		input_set_abs_params(wdata->accel, ABS_ACCEL_Y,
+				     -500, 500, 2, 4);
+		input_set_abs_params(wdata->accel, ABS_ACCEL_Z,
+				     -500, 500, 2, 4);
+	}
 
 	ret = input_register_device(wdata->accel);
 	if (ret) {
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux