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 <[email protected]>
---
 drivers/hid/hid-wiimote-modules.c | 44 ++++++++++++++++++++++++++++-----------
 1 file changed, 32 insertions(+), 12 deletions(-)

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)
-- 
1.8.4.1

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

Reply via email to