Subject: Re: Missile launchers vs uhid
To: Stephen Borrill <netbsd@precedence.co.uk>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-kern
Date: 01/29/2008 21:46:32
This is a multipart MIME message.

--==_Exmh_87966720977050
Content-Type: text/plain; charset=us-ascii


[coming back to a thread of about a year ago because I just
got such a gadget between by fingers]

netbsd@precedence.co.uk said:
> They both claim the device directly and try to detach the kernel uhid
> driver before writing a very simple usb control message. This seems a
> lot  simpler than messing around with libusbhid, but I can't see how
> to achieve  it on NetBSD. 

I've just tried -- the kernel uhid driver is absolutely not
in the way of supporting this thing. All the detach or
quirk stuff is unnecessary, it just works.
I'll append a minimal proof-of concept program, the magic constants
are taken from the pymissile script.
uhid1 is the one with interface 1, see the kernel messages:

uhidev1 at uhub3 port 1 configuration 1 interface 0
uhidev1: vendor 0x1130 Tenx Nonstandard Devic, rev 1.10/1.00, addr 2, iclass 
3/0
uhid0 at uhidev1: input=0, output=64, feature=8
uhidev2 at uhub3 port 1 configuration 1 interface 1
uhidev2: vendor 0x1130 Tenx Nonstandard Devic, rev 1.10/1.00, addr 2, iclass 
3/0
uhid1 at uhidev2: input=0, output=8, feature=0

Appearently they did abuse a USB keyboard controller...

best regards
Matthias





-------------------------------------------------------------------
-------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Dr. Sebastian M. Schmidt
-------------------------------------------------------------------
-------------------------------------------------------------------

--==_Exmh_87966720977050
Content-Type: text/plain ; name="rtest.c"; charset=us-ascii
Content-Description: rtest.c
Content-Disposition: attachment; filename="rtest.c"

#include <fcntl.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbhid.h>
#include <string.h>
#include <err.h>

int fd;

void
s(const char *d)
{
	struct usb_ctl_report r;
	int res;

	r.ucr_report = UHID_OUTPUT_REPORT;
	memcpy(r.ucr_data, d, 8);

	res = ioctl(fd, USB_SET_REPORT, &r);
	if (res < 0)
		warn("ioctl");
}

const char init1[] = {85, 83, 66, 67,  0,  0,  4,  0};
const char init2[] = {85, 83, 66, 67,  0, 64,  2,  0};
const char left[] = {0,  1,  0,  0,  0,  0, 8, 8};
const char right[] = {0,  0,  1,  0,  0,  0, 8, 8};
const char up[] = {0,  0,  0,  1,  0,  0, 8, 8};
const char down[] = {0,  0,  0,  0,  1,  0, 8, 8};
const char stop[] = {0,  0,  0,  0,  0,  0,  8, 8};
const char fire[] = {0,  0,  0,  0,  0,  1, 8, 8};

int
main()
{

	fd = open("/dev/uhid1", O_RDWR, 0);
	if (fd < 0)
		err(1, "open");

	s(init1);
	s(init2);
	s(right);

	return 0;
}

--==_Exmh_87966720977050--