* [PATCH v2 1/3] HID: sony: Add force-feedback support for the Dualshock 4
@ 2014-01-11 20:12 Frank Praznik
2014-01-16 21:46 ` Jiri Kosina
0 siblings, 1 reply; 4+ messages in thread
From: Frank Praznik @ 2014-01-11 20:12 UTC (permalink / raw)
To: linux-input; +Cc: Jiri Kosina
Adds the Dualshock 4 to the HID device list and enables force-feedback.
Adds a Dualshock 4 specific worker function since the Dualshock 4 needs a
different report than the Sixaxis.
The right motor in the Dualshock 4 is variable so the full rumble value
is now passed to the worker function and clamped there if necessary.
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
---
Apply against jikos/hid.git/for-3.14/sony
drivers/hid/hid-core.c | 2 ++
drivers/hid/hid-ids.h | 1 +
drivers/hid/hid-sony.c | 39 ++++++++++++++++++++++++++++++++++++---
3 files changed, 39 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 957d35b..70cc468 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1831,6 +1831,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) },
{ HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 60336f06..ce24459 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -766,6 +766,7 @@
#define USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE 0x0374
#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306
#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268
+#define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4
#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f
#define USB_DEVICE_ID_SONY_BUZZ_CONTROLLER 0x0002
#define USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER 0x1000
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index f57ab5e..8020d10 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -38,6 +38,7 @@
#define SIXAXIS_CONTROLLER_BT BIT(2)
#define BUZZ_CONTROLLER BIT(3)
#define PS3REMOTE BIT(4)
+#define DUALSHOCK4_CONTROLLER BIT(5)
#define SONY_LED_SUPPORT (SIXAXIS_CONTROLLER_USB | BUZZ_CONTROLLER)
@@ -630,7 +631,7 @@ static void sony_state_worker(struct work_struct *work)
};
#ifdef CONFIG_SONY_FF
- buf[3] = sc->right;
+ buf[3] = sc->right ? 1 : 0;
buf[5] = sc->left;
#endif
@@ -640,6 +641,29 @@ static void sony_state_worker(struct work_struct *work)
HID_OUTPUT_REPORT);
}
+static void dualshock4_state_worker(struct work_struct *work)
+{
+ struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
+ unsigned char buf[] = {
+ 0x05,
+ 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00,
+ };
+
+#ifdef CONFIG_SONY_FF
+ buf[4] = sc->right;
+ buf[5] = sc->left;
+#endif
+
+ sc->hdev->hid_output_raw_report(sc->hdev, buf, sizeof(buf),
+ HID_OUTPUT_REPORT);
+}
+
#ifdef CONFIG_SONY_FF
static int sony_play_effect(struct input_dev *dev, void *data,
struct ff_effect *effect)
@@ -651,7 +675,7 @@ static int sony_play_effect(struct input_dev *dev, void *data,
return 0;
sc->left = effect->u.rumble.strong_magnitude / 256;
- sc->right = effect->u.rumble.weak_magnitude ? 1 : 0;
+ sc->right = effect->u.rumble.weak_magnitude / 256;
schedule_work(&sc->state_worker);
return 0;
@@ -728,8 +752,12 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
ret = sixaxis_set_operational_bt(hdev);
- else
+ else if (sc->quirks & DUALSHOCK4_CONTROLLER) {
ret = 0;
+ INIT_WORK(&sc->state_worker, dualshock4_state_worker);
+ } else {
+ ret = 0;
+ }
if (ret < 0)
goto err_stop;
@@ -787,6 +815,11 @@ static const struct hid_device_id sony_devices[] = {
/* Logitech Harmony Adapter for PS3 */
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3),
.driver_data = PS3REMOTE },
+ /* Sony Dualshock 4 controllers for PS4 */
+ { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
+ .driver_data = DUALSHOCK4_CONTROLLER },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
+ .driver_data = DUALSHOCK4_CONTROLLER },
{ }
};
MODULE_DEVICE_TABLE(hid, sony_devices);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] HID: sony: Add force-feedback support for the Dualshock 4
@ 2014-01-12 0:25 simon
0 siblings, 0 replies; 4+ messages in thread
From: simon @ 2014-01-12 0:25 UTC (permalink / raw)
To: Frank Praznik; +Cc: linux-input, Jiri Kosina
> Adds the Dualshock 4 to the HID device list and enables force-feedback.
Adds a Dualshock 4 specific worker function since the Dualshock 4 needs
a
> different report than the Sixaxis.
> The right motor in the Dualshock 4 is variable so the full rumble value
is now passed to the worker function and clamped there if necessary.
Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
I was able to build this and the LED patch against the 3.13rc7 kernel
having first applied this sequence of patches:
https://patchwork.kernel.org/patch/3203761/
I can confirm that FF/LEDs appears to work OK with USB connected
Dualshock4, Dualshock3(SixAxis) and 3rd part wired PS3 controller.
I wasn't able to get Dualshock4 working over BT, but I think that the
problem is with my system - I am yet to figure out getting the HIDP
connection to work properly.
I can use the depricated 'HIDD --connect xxx' to have LEDs are listed in
'/sys/class/leds', but they don't change when instructed. They stay solid
white.
Cheers,
Simon
Tested-by: Simon Wood <simon@mungewell.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] HID: sony: Add force-feedback support for the Dualshock 4
2014-01-11 20:12 Frank Praznik
@ 2014-01-16 21:46 ` Jiri Kosina
2014-01-16 21:53 ` simon
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2014-01-16 21:46 UTC (permalink / raw)
To: Frank Praznik; +Cc: linux-input
On Sat, 11 Jan 2014, Frank Praznik wrote:
> Adds the Dualshock 4 to the HID device list and enables force-feedback.
>
> Adds a Dualshock 4 specific worker function since the Dualshock 4 needs a
> different report than the Sixaxis.
>
> The right motor in the Dualshock 4 is variable so the full rumble value
> is now passed to the worker function and clamped there if necessary.
>
> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
I have now applied the whole series, thanks Frank.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] HID: sony: Add force-feedback support for the Dualshock 4
2014-01-16 21:46 ` Jiri Kosina
@ 2014-01-16 21:53 ` simon
0 siblings, 0 replies; 4+ messages in thread
From: simon @ 2014-01-16 21:53 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Frank Praznik, linux-input
> On Sat, 11 Jan 2014, Frank Praznik wrote:
>
>> Adds the Dualshock 4 to the HID device list and enables force-feedback.
>>
>> Adds a Dualshock 4 specific worker function since the Dualshock 4 needs
>> a
>> different report than the Sixaxis.
>>
>> The right motor in the Dualshock 4 is variable so the full rumble value
>> is now passed to the worker function and clamped there if necessary.
>>
>> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
>
> I have now applied the whole series, thanks Frank.
Thanks.
We are seeing problems with the way that DS4 interacts with Bluez (mostly
importantly how the PC and DS4 'pair'), but I believe that the kernel
stuff is OK.
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-16 21:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-12 0:25 [PATCH v2 1/3] HID: sony: Add force-feedback support for the Dualshock 4 simon
-- strict thread matches above, loose matches on Subject: below --
2014-01-11 20:12 Frank Praznik
2014-01-16 21:46 ` Jiri Kosina
2014-01-16 21:53 ` simon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).