PATCH hid: Implement mode switching on Logitech gaming wheels accordingly to the documentation
Implement mode switching on Logitech gaming wheels accordingly to the documentation
---
Logitech has recently released technical documentation which describes the protocol used by their force feedback gaming devices. The documentation describes the method by which the driver is supposed to recognize what model of the wheel is connected and switch it to so-called "native" mode.
(https://opensource.logitech.com/opensource/index.php/Technical_Information)
The patch implements this logic and provides an additional module parameter which can force the driver either not perform the switch at all or switch the wheel into an "extended compatibility" mode (not applicable for all wheels). If a wheel does not support the mode enforced by the parameter, it is left in its original mode. Default behavior is to switch all wheels into native mode.
drivers/hid/hid-lg.c | 17 +++- drivers/hid/hid-lg.h | 11 ++- drivers/hid/hid-lg4ff.c | 224 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 188 insertions(+), 64 deletions(-)
drivers/hid/hid-lg.c +16 -1
@@ -334,6 +334,16 @@ static __u8 momo2_rdesc_fixed[] = { };/* +* Certain Logitech wheels provide various compatibililty modes +* for games that cannot handle their advanced features properly. +* This switch forces the wheel into a specific compatibililty +* instead of its native mode +*/ +#ifdef CONFIG_LOGIWHEELS_FF +static int lg4ff_switch_force_mode; +#endif + +/* * Certain Logitech keyboards send in report #3 keys which are far * above the logical maximum described in descriptor. This extends * the original value of 0x28c of logical maximum to 0x104d
@@ -717,7 +727,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)if (drv_data->quirks &LG_FF3 )lg3ff_init (hdev);if (drv_data->quirks &LG_FF4 ) -lg4ff_init (hdev); +lg4ff_init (hdev, lg4ff_switch_force_mode);return 0 ; err_free:
@@ -818,4 +828,9 @@ static struct hid_driver lg_driver = { };module_hid_driver (lg_driver); +#ifdef CONFIG_LOGIWHEELS_FF +module_param_named (lg4ff_switch_force_mode, lg4ff_switch_force_mode, int,S_IRUGO ); +MODULE_PARM_DESC (lg4ff_switch_force_mode,"Force gaming wheel into specific compatibililty mode (only certain devices)" ); +#endif +MODULE_LICENSE ("GPL" );
drivers/hid/hid-lg.h +9 -2
@@ -25,14 +25,21 @@ static inline int lg3ff_init(struct hid_device *hdev) { return -1; }#endif #ifdef CONFIG_LOGIWHEELS_FF +#define LG4FF_MSW_MIN 0 +#define LG4FF_MSW_NATIVE 0/* Switch device to its native mode (if applicable) */ +#define LG4FF_MSW_DONTSWITCH 1/* Leave device in its current mode */ +#define LG4FF_MSW_DFP 2/* Switch device so that it emulates Driving Force Pro (only G25, G27, DFGT) */ +#define LG4FF_MSW_G25 3/* Switch device so that it emulates G25 (only G27) */ +#define LG4FF_MSW_MAX 3 +int lg4ff_adjust_input_event (struct hid_device *hid,struct hid_field *field,struct hid_usage *usage,__s32 value,struct lg_drv_data *drv_data); -int lg4ff_init (struct hid_device *hdev); +int lg4ff_init (struct hid_device *hdev,const int switch_force_mode);int lg4ff_deinit (struct hid_device *hdev);#else static inline int lg4ff_adjust_input_event (struct hid_device *hid,struct hid_field *field,struct hid_usage *usage,__s32 value,struct lg_drv_data *drv_data) {return 0 ; } -static inline int lg4ff_init (struct hid_device *hdev) {return -1 ; } +static inline int lg4ff_init (struct hid_device *hdev,const int switch_force_mode) {return -1 ; }static inline int lg4ff_deinit (struct hid_device *hdev) {return -1 ; }#endif
drivers/hid/hid-lg4ff.c +163 -61
296 lines not on this page · raw message
Signature · 7 lines
2.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Elias Vanderstuyft
Tested-byQuoted 3 lines · Michal Malý
Implement mode switching on Logitech gaming wheels accordingly to the documentation
Signed-off-by Michal Malý <[email protected]>
Tested all lg4ff_switch_force_mode
modes (0, 1, 2, 3, default), on both:
- MOMO (Black) : PID 0xCA03
- Formula Vibration : PID 0xCA04
Behaviour didn't deviate from normal, which is as expected because these devices don't use the native versus compatibility mode, according to the documentation.
So I consider this patch successful for these devices:
Elias
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines
(quoted diff) +2
-0+#define LG4FF_MSW_MIN 0 +#define LG4FF_MSW_NATIVE 0 /* Switch device to its native mode (ifapplicable) */
(quoted diff) +2
-0+#define LG4FF_MSW_DONTSWITCH 1 /* Leave device in its current mode */ +#define LG4FF_MSW_DFP 2 /* Switch device so that it emulates DrivingForce Pro (only G25, G27, DFGT) */
+#defineLG4FF_MSW_G253 /* Switch device so that it emulates G25 (only
G27) */
+#defineLG4FF_MSW_MAX3
Just to let everyone know I am looking at this patch, and have emailed Michal some questions on whether it covers all options for control.
Cheers,
Simon.
Quoted 4 lines · On Thu, 31 Jul 2014, [email protected] wrote:
Quoted 4 lines
(quoted diff) +2
-0+#define LG4FF_MSW_MIN 0 +#define LG4FF_MSW_NATIVE 0 /* Switch device to its native mode (ifapplicable) */
+#defineLG4FF_MSW_DONTSWITCH1 /* Leave device in its current mode */
Quoted 8 lines
Quoted 5 lines
+#define
LG4FF_MSW_DFP2 /* Switch device so that it emulates Driving
Force Pro (only G25, G27, DFGT) */
+#defineLG4FF_MSW_G253 /* Switch device so that it emulates G25 (only
G27) */
+#defineLG4FF_MSW_MAX3Just to let everyone know I am looking at this patch, and have emailed Michal some questions on whether it covers all options for control.
Hi guys,
did you reach any kind of conclusion here?
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 6 lines · On Tuesday 12 of August 2014 15:10:12 Jiri Kosina wrote:
Quoted 5 lines · On Thu, 31 Jul 2014, [email protected] wrote:
Review
Quoted 5 lines
(quoted diff) +2
-0+#define LG4FF_MSW_MIN 0 +#define LG4FF_MSW_NATIVE 0 /* Switch device to its native mode (ifapplicable) */
(quoted diff) +2
-0+#define LG4FF_MSW_DONTSWITCH 1 /* Leave device in its current mode */ +#define LG4FF_MSW_DFP 2 /* Switch device so that it emulates
Driving
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Force Pro (only G25, G27, DFGT) */
+#defineLG4FF_MSW_G253 /* Switch device so that it emulates G25
(only
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
G27) */
+#defineLG4FF_MSW_MAX3Just to let everyone know I am looking at this patch, and have emailed Michal some questions on whether it covers all options for control.
Hi guys,
did you reach any kind of conclusion here?
Hi,
Simon mailed me his revised patchset which has the changes broken out into four separate patches and allows to switch "extended compatibility" modes on the fly through sysfs. I looked them over and I they seem fine to me. I suppose he'll submit them for review very soon.
Michal
Quoted 6 lines
Simon mailed me his revised patchset which has the changes broken out into four separate patches and allows to switch "extended compatibility" modes on
the fly through sysfs. I looked them over and I they seem fine to me. I suppose he'll submit them for review very soon.
Whilst it is my intention to submit them, I might not achieve the 'very soon' part.... earliest I think would be mid next week as they still need a little tweaking.
Simon
Quoted 4 lines
Whilst it is my intention to submit them, I might not achieve the 'very soon' part.... earliest I think would be mid next week as they still need a little tweaking.
I've sent in patches as 'RFC' as I think they still need a little more testing and I'm tied up with work stuff for the next week or so (and won't have access to the hardware).
If people can test/comment that would be great,
Simon