From owner-freebsd-drivers@FreeBSD.ORG Sat Dec 20 09:08:20 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9738A1065670 for ; Sat, 20 Dec 2008 09:08:20 +0000 (UTC) (envelope-from elbarto@arcadebsd.org) Received: from mail.arcadebsd.org (sd-16356.dedibox.fr [88.191.88.233]) by mx1.freebsd.org (Postfix) with ESMTP id 5DA588FC08 for ; Sat, 20 Dec 2008 09:08:20 +0000 (UTC) (envelope-from elbarto@arcadebsd.org) Received: from [192.168.0.1] (home.elbarto.org [82.229.222.193]) (Authenticated sender: elbarto) by mail.arcadebsd.org (Postfix) with ESMTPA id 8FEE9341D0; Sat, 20 Dec 2008 10:08:18 +0100 (CET) Message-ID: <494CB5A8.50509@arcadebsd.org> Date: Sat, 20 Dec 2008 10:06:48 +0100 From: ElBarto User-Agent: Thunderbird 2.0.0.18 (X11/20081129) MIME-Version: 1.0 To: freebsd-drivers@freebsd.org References: <493EE331.8070708@arcadebsd.org> In-Reply-To: <493EE331.8070708@arcadebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: frebsd-usb@freebsd.org Subject: Re: USB Joystick/gamepad driver X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Dec 2008 09:08:20 -0000 ElBarto wrote: > Hello all, > > I've started a driver for usb joystick and gamepad. > The goal of this driver is to have a complete support for HID and > non-HID device. > For now it support HID device and (partially) the Xbox360 gamepad. > > The driver create a ujoy%d device in /dev . > For now the data are like this : > > AXIS_X AXIS_Y AXIS_Z AXIS_RX AXIS_RY AXIS_RZ SLIDER HAT_SWITCH BUTTONS > All coded in one int each. > > I'll next add some ioctl to, for example, find which axis is present > for the joystick etc .... > > There is of course no userland application which support this driver, > I'm planning to re-do the sdl support > for this driver, but before I want to standardize the driver. > > You can download the driver and a small crappy userland application > here : > http://www.arcadebsd.org/~elbarto/ujoy.tgz > > > This has been tested on FreeBSD 7.0 with two different Thrustmaster > gamepad and a Xbox360 one. > > Comments ? Suggestions ? > Hello again, I've updated the driver, it's now more clean. Now it has a struct ujoy to read the data, the struct is like this : struct ujoy_axis { char present; int value; int min; int max; }; struct ujoy { struct ujoy_axis axis[UJOY_MAXAXIS]; unsigned int hat; unsigned int buttons; }; The value of the axis are as they are read at the joystick. Some joystick/gamepad send value from -127->+127 others from 0->255 etc ... But I think it's to the userland application to decide what to do, that's why I give the min and max of each axis. For what I know the max number of axis of an USB joystick/gamepad is 7 (X, Y, Z, RX, RY, RX, SLIDER) but I may but wrong, if you have an usb joystick please try this driver and tell me if all your axis are not recognize. I've tried to get the name of the device to have a ioctl to get it, but all my attempts were unsuccessful. The drivers has been tried on FreeBSD-7.0-RELEASE-p6 with two thrustmaster gamepad, one Xbox360 usb and a gamecube usb adapter. I've CC'ed freebsd-usb too. -- Emmanuel Vadot elbarto@arcadebsd.org