[PATCH v3 1/1] HID: hid-sony: Only allow four LED states to identify controller

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

 



HID: hid-sony: Only allow four LED states to identify controller

The PS3 and PS4 consoles only support four game controllers, while
Linux supports any number of game controller connected to it. The
kernel driver should mirror the original console's behaviour here
and leave the use of additional LED patterns/colours to user space.

Signed-off-by: Hanno Zulla <kontakt@xxxxxxxx>
---
 drivers/hid/hid-sony.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index e475c5073c99..147750b8dea7 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -1798,17 +1798,11 @@ static int dualshock4_get_version_info(struct sony_sc *sc)
 
 static void sixaxis_set_leds_from_id(struct sony_sc *sc)
 {
-	static const u8 sixaxis_leds[10][4] = {
+	static const u8 sixaxis_leds[4][4] = {
 				{ 0x01, 0x00, 0x00, 0x00 },
 				{ 0x00, 0x01, 0x00, 0x00 },
 				{ 0x00, 0x00, 0x01, 0x00 },
-				{ 0x00, 0x00, 0x00, 0x01 },
-				{ 0x01, 0x00, 0x00, 0x01 },
-				{ 0x00, 0x01, 0x00, 0x01 },
-				{ 0x00, 0x00, 0x01, 0x01 },
-				{ 0x01, 0x00, 0x01, 0x01 },
-				{ 0x00, 0x01, 0x01, 0x01 },
-				{ 0x01, 0x01, 0x01, 0x01 }
+				{ 0x00, 0x00, 0x00, 0x01 }
 	};
 
 	int id = sc->device_id;
@@ -1818,21 +1812,18 @@ static void sixaxis_set_leds_from_id(struct sony_sc *sc)
 	if (id < 0)
 		return;
 
-	id %= 10;
+	id %= 4;
 	memcpy(sc->led_state, sixaxis_leds[id], sizeof(sixaxis_leds[id]));
 }
 
 static void dualshock4_set_leds_from_id(struct sony_sc *sc)
 {
-	/* The first 4 color/index entries match what the PS4 assigns */
-	static const u8 color_code[7][3] = {
+	/* The 4 color/index entries match what the PS4 assigns */
+	static const u8 color_code[4][3] = {
 			/* Blue   */	{ 0x00, 0x00, 0x40 },
-			/* Red	  */	{ 0x40, 0x00, 0x00 },
+			/* Red    */	{ 0x40, 0x00, 0x00 },
 			/* Green  */	{ 0x00, 0x40, 0x00 },
-			/* Pink   */	{ 0x20, 0x00, 0x20 },
-			/* Orange */	{ 0x02, 0x01, 0x00 },
-			/* Teal   */	{ 0x00, 0x01, 0x01 },
-			/* White  */	{ 0x01, 0x01, 0x01 }
+			/* Pink   */	{ 0x20, 0x00, 0x20 }
 	};
 
 	int id = sc->device_id;
@@ -1842,7 +1833,7 @@ static void dualshock4_set_leds_from_id(struct sony_sc *sc)
 	if (id < 0)
 		return;
 
-	id %= 7;
+	id %= 4;
 	memcpy(sc->led_state, color_code[id], sizeof(color_code[id]));
 }
 
-- 
2.17.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