linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
@ 2008-08-18  9:17 Сергей Беляшов
  2008-08-18 15:24 ` Dmitry Torokhov
  0 siblings, 1 reply; 8+ messages in thread
From: Сергей Беляшов @ 2008-08-18  9:17 UTC (permalink / raw)
  To: linux-input

Hello.
  Current kernel has no support for autocentering for Logitech wheels.
By default autocentering enabled in wheel and constant effect does not
work properly. Using USB sniffer I found command which change
autocentering settings: 0xFE, 0x0D, 0x0R, 0x0L, 0x80, 0x00, 0x00,
where R - clockwise force, L - counter-clockwise (0x0-0xF, 0xC =
100%). I write patch for my current kernel (2.6.25), but I think git
version also supported, because I do not found any changes in it.
Currently kernel interface has no support for separate autocenter
control and so I do not implement it.
  And some interesting command 0xF3 (or 0xF5 - I do not understand
difference) which makes wheel very easy to rotate (a-la wheel booster
- no any resistance). Effect of that command can be disabled by
setting any (zero too) autocentering strength. I do not found in
kernel interface any standart command for this feature.

===================================================================================

--- linux-source-2.6.24/drivers/hid/usbhid/hid-lgff.c	2008-02-11
08:51:11.000000000 +0300
+++ linux-source-2.6.24.n/drivers/hid/usbhid/hid-lgff.c	2008-08-15
14:00:39.000000000 +0400
@@ -48,6 +48,12 @@
 	-1
 };

+static const signed short ff_momo_wheel[] = {
+	FF_CONSTANT,
+	FF_AUTOCENTER,
+	-1
+};
+
 static const struct dev_type devices[] = {
 	{ 0x046d, 0xc211, ff_rumble },
 	{ 0x046d, 0xc219, ff_rumble },
@@ -55,7 +61,7 @@
 	{ 0x046d, 0xc286, ff_joystick },
 	{ 0x046d, 0xc294, ff_joystick },
 	{ 0x046d, 0xc295, ff_joystick },
-	{ 0x046d, 0xca03, ff_joystick },
+	{ 0x046d, 0xca03, ff_momo_wheel },
 };

 static int hid_lgff_play(struct input_dev *dev, void *data, struct
ff_effect *effect)
@@ -100,6 +106,23 @@
 	return 0;
 }

+static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
+{
+	struct hid_device *hid = input_get_drvdata(dev);
+	struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
+	struct hid_report *report = list_entry(report_list->next, struct
hid_report, list);
+	__s32 *value = report->field[0]->value;
+	magnitude = (magnitude >> 12) & 0xf;
+	*value++ = 0xfe;
+	*value++ = 0x0d;
+	*value++ = magnitude;	/* clockwise strength */
+	*value++ = magnitude;	/* counter-clockwise strength */
+	*value++ = 0x80;
+	*value++ = 0x00;
+	*value++ = 0x00;
+	usbhid_submit_report(hid, report, USB_DIR_OUT);
+}
+
 int hid_lgff_init(struct hid_device* hid)
 {
 	struct hid_input *hidinput = list_entry(hid->inputs.next, struct
hid_input, list);
@@ -110,6 +133,7 @@
 	const signed short *ff_bits = ff_joystick;
 	int error;
 	int i;
+	int autocenter = 0;

 	/* Find the report to use */
 	if (list_empty(report_list)) {
@@ -138,13 +162,19 @@
 		}
 	}

-	for (i = 0; ff_bits[i] >= 0; i++)
+	for (i = 0; ff_bits[i] >= 0; i++) {
 		set_bit(ff_bits[i], dev->ffbit);
+		if (ff_bits[i] == FF_AUTOCENTER)
+		    autocenter = 1;
+	}

 	error = input_ff_create_memless(dev, NULL, hid_lgff_play);
 	if (error)
 		return error;

+	if (autocenter && dev->ff && (!dev->ff->set_autocenter))
+		dev->ff->set_autocenter = hid_lgff_set_autocenter;
+
 	printk(KERN_INFO "Force feedback for Logitech force feedback devices
by Johann Deneux <johann.deneux@it.uu.se>\n");

 	return 0;

========================================================================
Changes in this patch only for MOMO Racing wheels. But some other
wheels (G25, for example) may be also understand this protocol, but I
cannot check it.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-18  9:17 [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback) Сергей Беляшов
@ 2008-08-18 15:24 ` Dmitry Torokhov
       [not found]   ` <bb829a0b0808180916l1d2ca72fj689edcf5b8c156e5@mail.gmail.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2008-08-18 15:24 UTC (permalink / raw)
  To: ???????????? ??????????????; +Cc: linux-input, Jiri Kosina

Hi Sergey,

On Mon, Aug 18, 2008 at 01:17:48PM +0400, ???????????? ?????????????? wrote:
> Hello.
>   Current kernel has no support for autocentering for Logitech wheels.
> By default autocentering enabled in wheel and constant effect does not
> work properly. Using USB sniffer I found command which change
> autocentering settings: 0xFE, 0x0D, 0x0R, 0x0L, 0x80, 0x00, 0x00,
> where R - clockwise force, L - counter-clockwise (0x0-0xF, 0xC =
> 100%). I write patch for my current kernel (2.6.25), but I think git
> version also supported, because I do not found any changes in it.
> Currently kernel interface has no support for separate autocenter
> control and so I do not implement it.
>   And some interesting command 0xF3 (or 0xF5 - I do not understand
> difference) which makes wheel very easy to rotate (a-la wheel booster
> - no any resistance). Effect of that command can be disabled by
> setting any (zero too) autocentering strength. I do not found in
> kernel interface any standart command for this feature.

This could probably implemented via a sysfs device knob...

> 
>  	error = input_ff_create_memless(dev, NULL, hid_lgff_play);
>  	if (error)
>  		return error;
> 
> +	if (autocenter && dev->ff && (!dev->ff->set_autocenter))
> +		dev->ff->set_autocenter = hid_lgff_set_autocenter;
> +

You can just do "if (test_bit(FF_AUTOCENTER, dev->ffbit))" and you
won't need a temp variable. Also why do you need the rest of the check?

-- 
Dmitry

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
       [not found]     ` <20080818131807.ZZRA012@mailhub.coreip.homeip.net>
@ 2008-08-18 18:30       ` Сергей Беляшов
  2008-08-19  0:34         ` D. Ragno
  2008-08-19 12:59         ` Jiri Kosina
  0 siblings, 2 replies; 8+ messages in thread
From: Сергей Беляшов @ 2008-08-18 18:30 UTC (permalink / raw)
  To: linux-input; +Cc: Jiri Kosina

2008/8/18 Dmitry Torokhov <dmitry.torokhov@gmail.com>:
>
>>
>>       error = input_ff_create_memless(dev, NULL, hid_lgff_play);
>>       if (error)
>>               return error;
>>
>> +     if (autocenter && dev->ff && (!dev->ff->set_autocenter))
>> +             dev->ff->set_autocenter = hid_lgff_set_autocenter;
>> +
>
> You can just do "if (test_bit(FF_AUTOCENTER, dev->ffbit))" and you
> won't need a temp variable. Also why do you need the rest of the check?
>
> --
> Dmitry
>
>>
>> Yes. This checks are redundant.
>> Do I need to recreate patch and resend it?
>
> Yes, please. Also send it to Jiri Kosina <jkosina@suse.cz> since the
> patch will go through his HID tree.


=========================================================================
Logitech MOMO Recing Wheel Force Feedback autocenter setting support
(also may be work on G25 etc. but I cann't check):

--- linux-source-2.6.24/drivers/hid/usbhid/hid-lgff.c   2008-02-11
08:51:11.000000000 +0300
+++ linux-source-2.6.24.n/drivers/hid/usbhid/hid-lgff.c 2008-08-18
22:16:04.000000000 +0400
@@ -48,6 +48,12 @@
 	-1
 };

+static const signed short ff_momo_wheel[] = {
+	FF_CONSTANT,
+	FF_AUTOCENTER,
+	-1
+};
+
 static const struct dev_type devices[] = {
 	{ 0x046d, 0xc211, ff_rumble },
 	{ 0x046d, 0xc219, ff_rumble },
@@ -55,7 +61,7 @@
 	{ 0x046d, 0xc286, ff_joystick },
 	{ 0x046d, 0xc294, ff_joystick },
 	{ 0x046d, 0xc295, ff_joystick },
-	{ 0x046d, 0xca03, ff_joystick },
+	{ 0x046d, 0xca03, ff_momo_wheel },
 };

 static int hid_lgff_play(struct input_dev *dev, void *data, struct
ff_effect *effect)
@@ -100,6 +106,23 @@
 	return 0;
 }

+static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
+{
+	struct hid_device *hid = input_get_drvdata(dev);
+	struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
+	struct hid_report *report = list_entry(report_list->next, struct
hid_report, list);
+	__s32 *value = report->field[0]->value;
+	magnitude = (magnitude >> 12) & 0xf;
+	*value++ = 0xfe;
+	*value++ = 0x0d;
+	*value++ = magnitude;   /* clockwise strength */
+	*value++ = magnitude;   /* counter-clockwise strength */
+	*value++ = 0x80;
+	*value++ = 0x00;
+	*value = 0x00;
+	usbhid_submit_report(hid, report, USB_DIR_OUT);
+}
+
 int hid_lgff_init(struct hid_device* hid)
 {
 	struct hid_input *hidinput = list_entry(hid->inputs.next, struct
hid_input, list);
@@ -145,6 +168,9 @@
 	if (error)
 		return error;

+	if ( test_bit(FF_AUTOCENTER, dev->ffbit) )
+		dev->ff->set_autocenter = hid_lgff_set_autocenter;
+
 	printk(KERN_INFO "Force feedback for Logitech force feedback devices
by Johann Deneux <johann.deneux@it.uu.se>\n");

 	return 0;
====================================================================
note: all formating spaces are tabs (if need I can send patch as attachement)

Best regards,
Sergey Belyashov

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-18 18:30       ` Сергей Беляшов
@ 2008-08-19  0:34         ` D. Ragno
  2008-08-19  7:51           ` Сергей Беляшов
  2008-08-19 12:59         ` Jiri Kosina
  1 sibling, 1 reply; 8+ messages in thread
From: D. Ragno @ 2008-08-19  0:34 UTC (permalink / raw)
  To: linux-input

Have you found anything about the MOMO with regards to sending putting
it in native mode, so it will give you two axises for the
throttle/brake? I've attempted to try and snoop this, but my snooping
skills are less than stellar.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-19  0:34         ` D. Ragno
@ 2008-08-19  7:51           ` Сергей Беляшов
  0 siblings, 0 replies; 8+ messages in thread
From: Сергей Беляшов @ 2008-08-19  7:51 UTC (permalink / raw)
  To: D. Ragno; +Cc: linux-input

2008/8/19 D. Ragno <homerj@icculus.org>:
> Have you found anything about the MOMO with regards to sending putting
> it in native mode, so it will give you two axises for the
> throttle/brake? I've attempted to try and snoop this, but my snooping
> skills are less than stellar.

No, I have not. I grab all commands which Windows driver sends to
wheel (on any action in settings and effects tests):
0x11, 0x08, 0xXX, 0x80, 0x00, 0x00, 0x00 - used for effects (all
effects in diagnostic tool done by this command), but I do not
understand what is it and how to use.
0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - reset to defaults (driver
use it with previous command to produce effects)
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - unknown
0x09, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 - unknown
0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 - unknown
0xF3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - disable wheel resistance
(such as autocenter disabling, but more ease to rotate wheel)
0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - same as previous
0xFE, 0x0D, 0x0X, 0x0Y, 0x80, 0x00, 0x00 - autocentering control
I try all of them by modifying kernel driver (usbtool does not work
for me properly). But wheel did not switches to native mode.
Also I try commands from G25 protocol, described in vdrift.net forum.
Reconnect commands does not work for MOMO Racing wheel.

Best regards,
Sergey Belyashov

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-18 18:30       ` Сергей Беляшов
  2008-08-19  0:34         ` D. Ragno
@ 2008-08-19 12:59         ` Jiri Kosina
  2008-08-19 17:46           ` Сергей Беляшов
  1 sibling, 1 reply; 8+ messages in thread
From: Jiri Kosina @ 2008-08-19 12:59 UTC (permalink / raw)
  To: Сергей Беляшов
  Cc: linux-input

On Mon, 18 Aug 2008, ?????? ??????? wrote:

> =========================================================================
> Logitech MOMO Recing Wheel Force Feedback autocenter setting support
> (also may be work on G25 etc. but I cann't check):

Hi Sergey,

sorry for late reply, I have been on vacation.

Could you please send the patch with proper Signed-off-by: line, as 
documented in Documentation/SubmittingPatches, so that I can merge it 
properly?

Thanks!

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-19 12:59         ` Jiri Kosina
@ 2008-08-19 17:46           ` Сергей Беляшов
  2008-09-02 15:11             ` Jiri Kosina
  0 siblings, 1 reply; 8+ messages in thread
From: Сергей Беляшов @ 2008-08-19 17:46 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input

Jiri Kosina пишет:
> On Mon, 18 Aug 2008, Sergey Belyashov wrote:
> 
>> =========================================================================
>> Logitech MOMO Recing Wheel Force Feedback autocenter setting support
>> (also may be work on G25 etc. but I cann't check):
> 
> Hi Sergey,
> 
> sorry for late reply, I have been on vacation.
> 
> Could you please send the patch with proper Signed-off-by: line, as 
> documented in Documentation/SubmittingPatches, so that I can merge it 
> properly?
> 
> Thanks!
> 

  Current kernel has no support for autocentering for Logitech wheels.
By default autocentering enabled in wheel and constant effect does not
work properly. Using USB sniffer I found command which change
autocentering settings: 0xFE, 0x0D, 0x0R, 0x0L, 0x80, 0x00, 0x00,
where R - clockwise force, L - counter-clockwise (0x0-0xF, 0xC =
100%). I write patch for my current kernel (2.6.25), but I think git
version also supported, because I do not found any changes in it.


========================================================================================
--- drivers/hid/usbhid/hid-lgff.c	2008-04-17 06:49:44.000000000 +0400
+++ drivers/hid/usbhid/hid-lgff.c	2008-08-19 20:57:00.000000000 +0400
@@ -48,6 +48,12 @@ static const signed short ff_joystick[] 
 	-1
 };
 
+static const signed short ff_wheel[] = {
+	FF_CONSTANT,
+	FF_AUTOCENTER,
+	-1
+};
+
 static const struct dev_type devices[] = {
 	{ 0x046d, 0xc211, ff_rumble },
 	{ 0x046d, 0xc219, ff_rumble },
@@ -55,7 +61,7 @@ static const struct dev_type devices[] =
 	{ 0x046d, 0xc286, ff_joystick },
 	{ 0x046d, 0xc294, ff_joystick },
 	{ 0x046d, 0xc295, ff_joystick },
-	{ 0x046d, 0xca03, ff_joystick },
+	{ 0x046d, 0xca03, ff_wheel },
 };
 
 static int hid_lgff_play(struct input_dev *dev, void *data, struct ff_effect *effect)
@@ -100,6 +106,23 @@ static int hid_lgff_play(struct input_de
 	return 0;
 }
 
+static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude)
+{
+	struct hid_device *hid = input_get_drvdata(dev);
+	struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list;
+	struct hid_report *report = list_entry(report_list->next, struct hid_report, list);
+	__s32 *value = report->field[0]->value;
+	magnitude = (magnitude >> 12) & 0xf;
+	*value++ = 0xfe;
+	*value++ = 0x0d;
+	*value++ = magnitude;   /* clockwise strength */
+	*value++ = magnitude;   /* counter-clockwise strength */
+	*value++ = 0x80;
+	*value++ = 0x00;
+	*value = 0x00;
+	usbhid_submit_report(hid, report, USB_DIR_OUT);
+}
+
 int hid_lgff_init(struct hid_device* hid)
 {
 	struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);
@@ -145,6 +168,9 @@ int hid_lgff_init(struct hid_device* hid
 	if (error)
 		return error;
 
+	if ( test_bit(FF_AUTOCENTER, dev->ffbit) )
+		dev->ff->set_autocenter = hid_lgff_set_autocenter;
+
 	printk(KERN_INFO "Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n");
 
 	return 0;

========================================================================================
Signed-off-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback)
  2008-08-19 17:46           ` Сергей Беляшов
@ 2008-09-02 15:11             ` Jiri Kosina
  0 siblings, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2008-09-02 15:11 UTC (permalink / raw)
  To: Sergey.Belyashov; +Cc: linux-input

On Tue, 19 Aug 2008, ?????? ??????? wrote:

>   Current kernel has no support for autocentering for Logitech wheels. 
> By default autocentering enabled in wheel and constant effect does not 
> work properly. Using USB sniffer I found command which change 
> autocentering settings: 0xFE, 0x0D, 0x0R, 0x0L, 0x80, 0x00, 0x00, where 
> R - clockwise force, L - counter-clockwise (0x0-0xF, 0xC = 100%). I 
> write patch for my current kernel (2.6.25), but I think git version also 
> supported, because I do not found any changes in it.

Applied, thanks Sergey.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-02 15:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-18  9:17 [PATCH] Autocentering support for Logitech MOMO Racing Wheel (force feedback) Сергей Беляшов
2008-08-18 15:24 ` Dmitry Torokhov
     [not found]   ` <bb829a0b0808180916l1d2ca72fj689edcf5b8c156e5@mail.gmail.com>
     [not found]     ` <20080818131807.ZZRA012@mailhub.coreip.homeip.net>
2008-08-18 18:30       ` Сергей Беляшов
2008-08-19  0:34         ` D. Ragno
2008-08-19  7:51           ` Сергей Беляшов
2008-08-19 12:59         ` Jiri Kosina
2008-08-19 17:46           ` Сергей Беляшов
2008-09-02 15:11             ` Jiri Kosina

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).