Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Nov 2012 23:14:40 +1000
From:      Jan Beich <jbeich@tormail.org>
To:        Hans Petter Selasky <hselasky@c2i.net>
Cc:        freebsd-multimedia@freebsd.org
Subject:   Re: linux joystick
Message-ID:  <1TZLm8-000Osa-0r@internal.tormail.org>
In-Reply-To: <201211161040.39454.hselasky@c2i.net> (Hans Petter Selasky's message of "Fri, 16 Nov 2012 10:40:39 %2B0100")
References:  <1TZ2UN-0007lV-2Q@internal.tormail.org> <201211160844.18798.hselasky@c2i.net> <1TZIDy-000OLa-S8@internal.tormail.org> <201211161040.39454.hselasky@c2i.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Content-Type: text/plain
Content-Disposition: inline

Hans Petter Selasky <hselasky@c2i.net> writes:

> On Friday 16 November 2012 10:29:12 Jan Beich wrote:
>
>> Hans Petter Selasky <hselasky@c2i.net> writes:
>> >> And my patch for do-configure + build fix should follow
>> > 
>> > Hi,
>> > 
>> > I think you need to add:
>> > 
>> > -i media_tree/drivers/input/joystick
>> > 
>> > to the linux_make arguments.
>> 
>> This doesn't affect checksum of the produced binary.
>> 
>> > Because that Makefile is not linked with the parent one I think.
>> > 
>> > Then re-run the commands.
>> 
>> I'm building only
>> 
>>   media_tree/drivers/input/joydev.c
>>   media_tree/drivers/input/joystick/xpad.c
>> 
>> and they're both present in the resulting binary.
>> 
>> I think my gamepad is generic enough to not need any driver from
>> media_tree/drivers/input/joystick/. On linux joydev works with usbhid.
>> So, webcamd probably needs to attach to /dev/uhidN, not /dev/ugenN.M.
>> 
>> > --HPS
>
> Hi,
>
> Can you check that your device is present in the ID-table in xpad.c:
>
> static struct usb_device_id xpad_table [] = {
>
> And add some prints in the probe section in xpad.c?

OK, I've added

  // xpad_table[]
  { USB_DEVICE(0x044f, 0xb315) }, /* Thrustmaster dual analog 3.2 */

  // xpad_device[]
  { 0x044f, 0xb315, "Thrustmaster dual analog 3.2", 0, XTYPE_XBOX360 },

  # without/with xpad_device[] line
  $ ./webcamd -d 3.2
  Attached to ugen3.2[0]
 -@ name="Generic X-Box pad" phys="usb-/dev/usb-/dev/usb/input0"
 +@ name="Thrustmaster dual analog 3.2" phys="usb-/dev/usb-/dev/usb/input0"
  | xpad_set_up_abs(..., xpad_abs[0]=0)
  | xpad_set_up_abs(..., xpad_abs[1]=1)
  | xpad_set_up_abs(..., xpad_abs[2]=3)
  | xpad_set_up_abs(..., xpad_abs[3]=4)
  | __set_bit(xpad_common_btn[0]=304, ...)
  | __set_bit(xpad_common_btn[1]=305, ...)
  | __set_bit(xpad_common_btn[2]=307, ...)
  | __set_bit(xpad_common_btn[3]=308, ...)
  | __set_bit(xpad_common_btn[4]=315, ...)
  | __set_bit(xpad_common_btn[5]=314, ...)
  | __set_bit(xpad_common_btn[6]=317, ...)
  | __set_bit(xpad_common_btn[7]=318, ...)
 -| __set_bit(xpad_btn[0]=306, ...)
 -| __set_bit(xpad_btn[1]=309, ...)
 +| __set_bit(xpad360_btn[0]=310, ...)
 +| __set_bit(xpad360_btn[1]=311, ...)
 +| __set_bit(xpad360_btn[2]=316, ...)
  | xpad_set_up_abs(..., xpad_abs_pad[0]=16)
  | xpad_set_up_abs(..., xpad_abs_pad[1]=17)
  | xpad_set_up_abs(..., xpad_abs_triggers[0]=2)
  | xpad_set_up_abs(..., xpad_abs_triggers[1]=5)
  Creating /dev/input/event0

  $ chown foo:foo /dev/input/event0
  $ (cd /dev/input; ln -s event0 js0)
  $ /b/shank/bin/Shank
  ^C
  $ dmesg | fgrep Shank
  linux: pid 51084 (Shank): ioctl fd=23, cmd=0x4520 ('E',32) is not implemented (EVIOCGBIT)
  linux: pid 51084 (Shank): ioctl fd=23, cmd=0x4521 ('E',33) is not implemented (EVIOCGBIT)
  linux: pid 51084 (Shank): ioctl fd=23, cmd=0x6a11 ('j',17) is not implemented (JSIOCGAXES)
  linux: pid 51084 (Shank): ioctl fd=23, cmd=0x6a12 ('j',18) is not implemented (JSIOCGBUTTONS)
  linux: pid 51084 (Shank): ioctl fd=24, cmd=0x4506 ('E',6) is not implemented  (EVIOCGNAME)
  linux: pid 51084 (Shank): ioctl fd=24, cmd=0x6a13 ('j',19) is not implemented (JSIOCGNAME)

However, xpad isn't the right driver for my gamepad. Trying to press
first 4 buttons yields nothing and setting XBOX360 type doesn't help.

  # freebsd + webcamd
  $ hd /dev/input/js0
  ...
  ^C

  # ubuntu
  $ hd /dev/input/js0
  ...
  000000b0  d8 9a 56 00 00 00 01 02  60 ac 56 00 01 00 01 02  |..V.....`.V.....|
  000000c0  f0 ac 56 00 00 00 01 02  e0 ae 56 00 01 00 01 00  |..V.......V.....|
  000000d0  50 af 56 00 00 00 01 00  48 b1 56 00 01 00 01 03  |P.V.....H.V.....|
  000000e0  d0 b1 56 00 00 00 01 03  c0 b3 56 00 01 00 01 01  |..V.......V.....|
  ^C

Moving D-pad or 2 analog sticks does generate some output, still different.
An example for pressing "down" button on D-pad follows

  # freebsd + webcamd
  $ hd /dev/input/js0
  ...
  000005a0  5c f3 00 00 00 00 00 00  a1 00 08 00 00 00 00 00  |\...............|
  000005b0  01 00 30 01 01 00 00 00  5c f3 00 00 00 00 00 00  |..0.....\.......|
  000005c0  a2 00 08 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  000005d0  5c f3 00 00 00 00 00 00  9e fa 08 00 00 00 00 00  |\...............|
  000005e0  01 00 30 01 00 00 00 00  5c f3 00 00 00 00 00 00  |..0.....\.......|
  000005f0  a0 fa 08 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  ^C

  # ubuntu
  $ hd /dev/input/js0
  ...
  00000090  10 8c 69 00 00 00 02 03  98 99 69 00 ff 7f 02 01  |..i.......i.....|
  ^C

Anything else to test e.g., wine built with linux/joystick.h support?

>
> Also, sometimes you need to specify the interface number to webcamd.
>
> It should not matter if uhid is attached or not.
>
> --HPS

--
a patch with printfs should follow

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=printfs.diff

--- media_tree/drivers/input/joystick/xpad.c~
+++ media_tree/drivers/input/joystick/xpad.c
@@ -124,6 +124,7 @@ static const struct xpad_device {
 	{ 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
 	{ 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX },
 	{ 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
+	{ 0x044f, 0xb315, "Thrustmaster dual analog 3.2", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
 	{ 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
@@ -237,6 +238,7 @@ static const signed short xpad_abs_trigg
 
 static struct usb_device_id xpad_table [] = {
 	{ USB_INTERFACE_INFO('X', 'B', 0) },	/* X-Box USB-IF not approved class */
+	{ USB_DEVICE(0x044f, 0xb315) },		/* Thrustmaster dual analog 3.2 */
 	XPAD_XBOX360_VENDOR(0x045e),		/* Microsoft X-Box 360 controllers */
 	XPAD_XBOX360_VENDOR(0x046d),		/* Logitech X-Box 360 style controllers */
 	XPAD_XBOX360_VENDOR(0x0738),		/* Mad Catz X-Box 360 controllers */
@@ -891,6 +893,7 @@ static int xpad_probe(struct usb_interfa
 	input_dev->dev.parent = &intf->dev;
 
 	input_set_drvdata(input_dev, xpad);
+	printf("@ name=\"%s\" phys=\"%s\"\n", input_dev->name, input_dev->phys);
 
 	input_dev->open = xpad_open;
 	input_dev->close = xpad_close;
@@ -900,37 +903,54 @@ static int xpad_probe(struct usb_interfa
 	if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
 		input_dev->evbit[0] |= BIT_MASK(EV_ABS);
 		/* set up axes */
-		for (i = 0; xpad_abs[i] >= 0; i++)
+		for (i = 0; xpad_abs[i] >= 0; i++) {
 			xpad_set_up_abs(input_dev, xpad_abs[i]);
+			printf("| xpad_set_up_abs(..., xpad_abs[%d]=%d)\n",
+			       i, xpad_abs[i]);
+		}
 	}
 
 	/* set up standard buttons */
-	for (i = 0; xpad_common_btn[i] >= 0; i++)
+	for (i = 0; xpad_common_btn[i] >= 0; i++) {
 		__set_bit(xpad_common_btn[i], input_dev->keybit);
+		printf("| __set_bit(xpad_common_btn[%d]=%d, ...)\n", i, xpad_common_btn[i]);
+	}
 
 	/* set up model-specific ones */
 	if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
-		for (i = 0; xpad360_btn[i] >= 0; i++)
+		for (i = 0; xpad360_btn[i] >= 0; i++) {
 			__set_bit(xpad360_btn[i], input_dev->keybit);
+			printf("| __set_bit(xpad360_btn[%d]=%d, ...)\n", i, xpad360_btn[i]);
+		}
 	} else {
-		for (i = 0; xpad_btn[i] >= 0; i++)
+		for (i = 0; xpad_btn[i] >= 0; i++) {
 			__set_bit(xpad_btn[i], input_dev->keybit);
+			printf("| __set_bit(xpad_btn[%d]=%d, ...)\n", i, xpad_btn[i]);
+		}
 	}
 
 	if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
-		for (i = 0; xpad_btn_pad[i] >= 0; i++)
+		for (i = 0; xpad_btn_pad[i] >= 0; i++) {
 			__set_bit(xpad_btn_pad[i], input_dev->keybit);
+			printf("| __set_bit(xpad_btn_pad[%d]=%d, ...)\n", i, xpad_btn_pad[i]);
+		}
 	} else {
-		for (i = 0; xpad_abs_pad[i] >= 0; i++)
+		for (i = 0; xpad_abs_pad[i] >= 0; i++) {
 		    xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
+			printf("| xpad_set_up_abs(..., xpad_abs_pad[%d]=%d)\n", i, xpad_abs_pad[i]);
+		}
 	}
 
 	if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
-		for (i = 0; xpad_btn_triggers[i] >= 0; i++)
+		for (i = 0; xpad_btn_triggers[i] >= 0; i++) {
 			__set_bit(xpad_btn_triggers[i], input_dev->keybit);
+			printf("| __set_bit(xpad_btn_triggers[%d]=%d, ...)\n", i, xpad_btn_triggers[i]);
+		}
 	} else {
-		for (i = 0; xpad_abs_triggers[i] >= 0; i++)
+		for (i = 0; xpad_abs_triggers[i] >= 0; i++) {
 			xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
+			printf("| xpad_set_up_abs(..., xpad_abs_triggers[%d]=%d)\n", i, xpad_abs_triggers[i]);
+		}
 	}
 
 	error = xpad_init_output(intf, xpad);

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1TZLm8-000Osa-0r>