Skip to content

Commit a4bfe13

Browse files
dynamix1337Jiri Kosina
authored andcommitted
HID: sony: support for the ghlive ps4 dongles
This commit adds support for the Guitar Hero Live PS4 dongles. These dongles require a "magic" USB control message to be sent every 8 seconds otherwise the dongle will not report events where the strumbar is hit while a fret is being held. Note that the GHL_GUITAR_POKE_INTERVAL is reduced to 8 seconds in order to support PS3, Wii U, and PS4 GHL dongles. Also note that the constant for vendor id 0x1430 has been renamed from Activision to RedOctane as self-declared by the device. Co-developed-by: Pascal Giard <[email protected]> Signed-off-by: Pascal Giard <[email protected]> Signed-off-by: Daniel Nguyen <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent df04fbe commit a4bfe13

File tree

3 files changed

+38
-17
lines changed

3 files changed

+38
-17
lines changed

drivers/hid/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ config HID_SONY
952952
* Buzz controllers
953953
* Sony PS3 Blue-ray Disk Remote Control (Bluetooth)
954954
* Logitech Harmony adapter for Sony Playstation 3 (Bluetooth)
955-
* Guitar Hero Live PS3 and Wii U guitar dongles
955+
* Guitar Hero Live PS3, Wii U and PS4 guitar dongles
956956
* Guitar Hero PS3 and PC guitar dongles
957957

958958
config SONY_FF

drivers/hid/hid-ids.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
#define USB_VENDOR_ID_ACTIONSTAR 0x2101
4242
#define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011
4343

44-
#define USB_VENDOR_ID_ACTIVISION 0x1430
45-
#define USB_DEVICE_ID_ACTIVISION_GUITAR_DONGLE 0x474c
46-
4744
#define USB_VENDOR_ID_ADS_TECH 0x06e1
4845
#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155
4946

@@ -1018,6 +1015,10 @@
10181015
#define USB_VENDOR_ID_REALTEK 0x0bda
10191016
#define USB_DEVICE_ID_REALTEK_READER 0x0152
10201017

1018+
#define USB_VENDOR_ID_REDOCTANE 0x1430
1019+
#define USB_DEVICE_ID_REDOCTANE_GUITAR_DONGLE 0x474c
1020+
#define USB_DEVICE_ID_REDOCTANE_PS4_GHLIVE_DONGLE 0x07bb
1021+
10211022
#define USB_VENDOR_ID_RETROUSB 0xf000
10221023
#define USB_DEVICE_ID_RETROUSB_SNES_RETROPAD 0x0003
10231024
#define USB_DEVICE_ID_RETROUSB_SNES_RETROPORT 0x00f1

drivers/hid/hid-sony.c

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
* Copyright (c) 2013 Colin Leitner <[email protected]>
1212
* Copyright (c) 2014-2016 Frank Praznik <[email protected]>
1313
* Copyright (c) 2018 Todd Kelner
14-
* Copyright (c) 2020 Pascal Giard <[email protected]>
14+
* Copyright (c) 2020-2021 Pascal Giard <[email protected]>
1515
* Copyright (c) 2020 Sanjay Govind <[email protected]>
16+
* Copyright (c) 2021 Daniel Nguyen <[email protected]>
1617
*/
1718

1819
/*
@@ -62,6 +63,7 @@
6263
#define SHANWAN_GAMEPAD BIT(16)
6364
#define GH_GUITAR_CONTROLLER BIT(17)
6465
#define GHL_GUITAR_PS3WIIU BIT(18)
66+
#define GHL_GUITAR_PS4 BIT(19)
6567

6668
#define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
6769
#define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
@@ -85,18 +87,27 @@
8587
#define NSG_MRXU_MAX_X 1667
8688
#define NSG_MRXU_MAX_Y 1868
8789

88-
#define GHL_GUITAR_POKE_INTERVAL 10 /* In seconds */
90+
/* The PS3/Wii U dongles require a poke every 10 seconds, but the PS4
91+
* requires one every 8 seconds. Using 8 seconds for all for simplicity.
92+
*/
93+
#define GHL_GUITAR_POKE_INTERVAL 8 /* In seconds */
8994
#define GUITAR_TILT_USAGE 44
9095

91-
/* Magic value and data taken from GHLtarUtility:
96+
/* Magic data taken from GHLtarUtility:
9297
* https://github.com/ghlre/GHLtarUtility/blob/master/PS3Guitar.cs
9398
* Note: The Wii U and PS3 dongles happen to share the same!
9499
*/
95-
static const u16 ghl_ps3wiiu_magic_value = 0x201;
96100
static const char ghl_ps3wiiu_magic_data[] = {
97101
0x02, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00
98102
};
99103

104+
/* Magic data for the PS4 dongles sniffed with a USB protocol
105+
* analyzer.
106+
*/
107+
static const char ghl_ps4_magic_data[] = {
108+
0x30, 0x02, 0x08, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00
109+
};
110+
100111
/* PS/3 Motion controller */
101112
static u8 motion_rdesc[] = {
102113
0x05, 0x01, /* Usage Page (Desktop), */
@@ -642,14 +653,14 @@ static void ghl_magic_poke(struct timer_list *t)
642653
hid_err(sc->hdev, "usb_submit_urb failed: %d", ret);
643654
}
644655

645-
static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev)
656+
static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev,
657+
const char ghl_magic_data[], u16 poke_size)
646658
{
647659
struct usb_ctrlrequest *cr;
648-
u16 poke_size;
649660
u8 *databuf;
650661
unsigned int pipe;
662+
u16 ghl_magic_value = (((HID_OUTPUT_REPORT + 1) << 8) | ghl_magic_data[0]);
651663

652-
poke_size = ARRAY_SIZE(ghl_ps3wiiu_magic_data);
653664
pipe = usb_sndctrlpipe(usbdev, 0);
654665

655666
cr = devm_kzalloc(&sc->hdev->dev, sizeof(*cr), GFP_ATOMIC);
@@ -663,10 +674,10 @@ static int ghl_init_urb(struct sony_sc *sc, struct usb_device *usbdev)
663674
cr->bRequestType =
664675
USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT;
665676
cr->bRequest = USB_REQ_SET_CONFIGURATION;
666-
cr->wValue = cpu_to_le16(ghl_ps3wiiu_magic_value);
677+
cr->wValue = cpu_to_le16(ghl_magic_value);
667678
cr->wIndex = 0;
668679
cr->wLength = cpu_to_le16(poke_size);
669-
memcpy(databuf, ghl_ps3wiiu_magic_data, poke_size);
680+
memcpy(databuf, ghl_magic_data, poke_size);
670681
usb_fill_control_urb(
671682
sc->ghl_urb, usbdev, pipe,
672683
(unsigned char *) cr, databuf, poke_size,
@@ -3030,11 +3041,17 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
30303041
return -ENODEV;
30313042
}
30323043

3033-
if (sc->quirks & GHL_GUITAR_PS3WIIU) {
3044+
if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
30343045
sc->ghl_urb = usb_alloc_urb(0, GFP_ATOMIC);
30353046
if (!sc->ghl_urb)
30363047
return -ENOMEM;
3037-
ret = ghl_init_urb(sc, usbdev);
3048+
3049+
if (sc->quirks & GHL_GUITAR_PS3WIIU)
3050+
ret = ghl_init_urb(sc, usbdev, ghl_ps3wiiu_magic_data,
3051+
ARRAY_SIZE(ghl_ps3wiiu_magic_data));
3052+
else if (sc->quirks & GHL_GUITAR_PS4)
3053+
ret = ghl_init_urb(sc, usbdev, ghl_ps4_magic_data,
3054+
ARRAY_SIZE(ghl_ps4_magic_data));
30383055
if (ret) {
30393056
hid_err(hdev, "error preparing URB\n");
30403057
return ret;
@@ -3052,7 +3069,7 @@ static void sony_remove(struct hid_device *hdev)
30523069
{
30533070
struct sony_sc *sc = hid_get_drvdata(hdev);
30543071

3055-
if (sc->quirks & GHL_GUITAR_PS3WIIU) {
3072+
if (sc->quirks & (GHL_GUITAR_PS3WIIU | GHL_GUITAR_PS4)) {
30563073
del_timer_sync(&sc->ghl_poke_timer);
30573074
usb_free_urb(sc->ghl_urb);
30583075
}
@@ -3172,11 +3189,14 @@ static const struct hid_device_id sony_devices[] = {
31723189
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY_RHYTHM, USB_DEVICE_ID_SONY_PS3WIIU_GHLIVE_DONGLE),
31733190
.driver_data = GHL_GUITAR_PS3WIIU | GH_GUITAR_CONTROLLER },
31743191
/* Guitar Hero PC Guitar Dongle */
3175-
{ HID_USB_DEVICE(USB_VENDOR_ID_ACTIVISION, USB_DEVICE_ID_ACTIVISION_GUITAR_DONGLE),
3192+
{ HID_USB_DEVICE(USB_VENDOR_ID_REDOCTANE, USB_DEVICE_ID_REDOCTANE_GUITAR_DONGLE),
31763193
.driver_data = GH_GUITAR_CONTROLLER },
31773194
/* Guitar Hero PS3 World Tour Guitar Dongle */
31783195
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY_RHYTHM, USB_DEVICE_ID_SONY_PS3_GUITAR_DONGLE),
31793196
.driver_data = GH_GUITAR_CONTROLLER },
3197+
/* Guitar Hero Live PS4 guitar dongles */
3198+
{ HID_USB_DEVICE(USB_VENDOR_ID_REDOCTANE, USB_DEVICE_ID_REDOCTANE_PS4_GHLIVE_DONGLE),
3199+
.driver_data = GHL_GUITAR_PS4 | GH_GUITAR_CONTROLLER },
31803200
{ }
31813201
};
31823202
MODULE_DEVICE_TABLE(hid, sony_devices);

0 commit comments

Comments
 (0)