diff options
| -rw-r--r-- | drivers/hid/hid-sony.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index c6982a29a56d..f405b07d0381 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
| @@ -1099,8 +1099,11 @@ struct sony_sc { | |||
| 1099 | u8 led_delay_on[MAX_LEDS]; | 1099 | u8 led_delay_on[MAX_LEDS]; |
| 1100 | u8 led_delay_off[MAX_LEDS]; | 1100 | u8 led_delay_off[MAX_LEDS]; |
| 1101 | u8 led_count; | 1101 | u8 led_count; |
| 1102 | bool ds4_dongle_connected; | ||
| 1102 | }; | 1103 | }; |
| 1103 | 1104 | ||
| 1105 | static void sony_set_leds(struct sony_sc *sc); | ||
| 1106 | |||
| 1104 | static inline void sony_schedule_work(struct sony_sc *sc) | 1107 | static inline void sony_schedule_work(struct sony_sc *sc) |
| 1105 | { | 1108 | { |
| 1106 | if (!sc->defer_initialization) | 1109 | if (!sc->defer_initialization) |
| @@ -1430,6 +1433,31 @@ static int sony_raw_event(struct hid_device *hdev, struct hid_report *report, | |||
| 1430 | return -EILSEQ; | 1433 | return -EILSEQ; |
| 1431 | } | 1434 | } |
| 1432 | } | 1435 | } |
| 1436 | |||
| 1437 | /* | ||
| 1438 | * In the case of a DS4 USB dongle, bit[2] of byte 31 indicates | ||
| 1439 | * if a DS4 is actually connected (indicated by '0'). | ||
| 1440 | * For non-dongle, this bit is always 0 (connected). | ||
| 1441 | */ | ||
| 1442 | if (sc->hdev->vendor == USB_VENDOR_ID_SONY && | ||
| 1443 | sc->hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) { | ||
| 1444 | bool connected = (rd[31] & 0x04) ? false : true; | ||
| 1445 | |||
| 1446 | if (!sc->ds4_dongle_connected && connected) { | ||
| 1447 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller connected\n"); | ||
| 1448 | sony_set_leds(sc); | ||
| 1449 | sc->ds4_dongle_connected = true; | ||
| 1450 | } else if (sc->ds4_dongle_connected && !connected) { | ||
| 1451 | hid_info(sc->hdev, "DualShock 4 USB dongle: controller disconnected\n"); | ||
| 1452 | sc->ds4_dongle_connected = false; | ||
| 1453 | /* Return 0, so hidraw can get the report. */ | ||
| 1454 | return 0; | ||
| 1455 | } else if (!sc->ds4_dongle_connected) { | ||
| 1456 | /* Return 0, so hidraw can get the report. */ | ||
| 1457 | return 0; | ||
| 1458 | } | ||
| 1459 | } | ||
| 1460 | |||
| 1433 | dualshock4_parse_report(sc, rd, size); | 1461 | dualshock4_parse_report(sc, rd, size); |
| 1434 | } | 1462 | } |
| 1435 | 1463 | ||
