Betreff: [RFC] hid/sony: add autorepeat for PS3 remotes
Von: David Dillow <dave@thedillows.org>
Datum: 28.06.2013 04:28
An: linux-input@vger.kernel.org
Kopie (CC): Stephan Raue <stephan@openelec.tv>

Some applications using the PS3 remote would like to have autorepeat
from the device. Use the input subsystem's software emulation to provide
this capability, and enable those that don't need it to turn it off.
---
I'm not sure this is the correct approach, or if it is even appropriate
for a remote to do autorepeat. However, the media/rc subsystem does do
it by default, and it's been requested by users, so there is at least
some demand.

This compiled against the hid-sony driver with the PS3 remote changes
merged, but I have done no testing of it. If the approach seems
reasonable, I'll try to test it when the MythTV is idle.

 drivers/hid/hid-sony.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff -Naur linux-3.14/drivers/hid/hid-sony.c linux-3.14.patch/drivers/hid/hid-sony.c
--- linux-3.14/drivers/hid/hid-sony.c	2014-03-31 05:40:15.000000000 +0200
+++ linux-3.14.patch/drivers/hid/hid-sony.c	2014-03-31 11:50:35.755949680 +0200
@@ -546,6 +546,24 @@
 	return 1;
 }
 
+static int ps3remote_setup_repeat(struct hid_device *hdev)
+{
+	struct hid_input *hidinput = list_first_entry(&hdev->inputs,
+						      struct hid_input, list);
+	struct input_dev *input = hidinput->input;
+
+	/*
+	 * Set up autorepeat defaults per the remote control subsystem;
+	 * this must be done after hid_hw_start(), as having these non-zero
+	 * at the time of input_register_device() tells the input system that
+	 * the hardware does the autorepeat, and the PS3 remote does not.
+	 */
+	set_bit(EV_REP, input->evbit);
+	input->rep[REP_DELAY]  = 500;
+	input->rep[REP_PERIOD] = 125;
+
+	return 0;
+}
 
 /* Sony Vaio VGX has wrongly mouse pointer declared as constant */
 static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -1074,6 +1092,8 @@
 	}
 	else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
 		ret = sixaxis_set_operational_bt(hdev);
+	else if (sc->quirks & PS3REMOTE)
+		ret = ps3remote_setup_repeat(hdev);
 	else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
 		/* Report 5 (31 bytes) is used to send data to the controller via USB */
 		ret = sony_set_output_report(sc, 0x05, 248);
