aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/hid/hid-wiimote-core.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index cac3589b1ed5..84e2fbec5fbb 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -769,7 +769,7 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
769 769
770 /* 770 /*
771 * Basic IR data is encoded into 3 bytes. The first two bytes are the 771 * Basic IR data is encoded into 3 bytes. The first two bytes are the
772 * upper 8 bit of the X/Y data, the 3rd byte contains the lower 2 bits 772 * lower 8 bit of the X/Y data, the 3rd byte contains the upper 2 bits
773 * of both. 773 * of both.
774 * If data is packed, then the 3rd byte is put first and slightly 774 * If data is packed, then the 3rd byte is put first and slightly
775 * reordered. This allows to interleave packed and non-packed data to 775 * reordered. This allows to interleave packed and non-packed data to
@@ -778,17 +778,11 @@ static void __ir_to_input(struct wiimote_data *wdata, const __u8 *ir,
778 */ 778 */
779 779
780 if (packed) { 780 if (packed) {
781 x = ir[1] << 2; 781 x = ir[1] | ((ir[0] & 0x03) << 8);
782 y = ir[2] << 2; 782 y = ir[2] | ((ir[0] & 0x0c) << 6);
783
784 x |= ir[0] & 0x3;
785 y |= (ir[0] >> 2) & 0x3;
786 } else { 783 } else {
787 x = ir[0] << 2; 784 x = ir[0] | ((ir[2] & 0x30) << 4);
788 y = ir[1] << 2; 785 y = ir[1] | ((ir[2] & 0xc0) << 2);
789
790 x |= (ir[2] >> 4) & 0x3;
791 y |= (ir[2] >> 6) & 0x3;
792 } 786 }
793 787
794 input_report_abs(wdata->ir, xid, x); 788 input_report_abs(wdata->ir, xid, x);