diff mbox

hid-magicmouse: Correct parsing of large X and Y motions.

Message ID 878w5qaspq.fsf@troilus.org (mailing list archive)
State Accepted
Commit 7d876c05fa6cf82f0274f27276d981ed325697a5
Headers show

Commit Message

Michael Poole July 5, 2010, 2:50 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 0b89c1c..7cdda23 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -267,8 +267,8 @@  static int magicmouse_raw_event(struct hid_device *hdev,
 		 * to have the current touch information before
 		 * generating a click event.
 		 */
-		x = (signed char)data[1];
-		y = (signed char)data[2];
+		x = (int)(((data[3] & 0x0c) << 28) | (data[1] << 22)) >> 22;
+		y = (int)(((data[3] & 0x30) << 26) | (data[2] << 22)) >> 22;
 		clicks = data[3];
 		break;
 	case 0x20: /* Theoretically battery status (0-100), but I have