[Gambas-user] Gambas class to read a joystick

audiossis at ...867... audiossis at ...867...
Tue Mar 4 23:35:15 CET 2008


> ------------------------------
> 
> Message: 9
> Date: Tue, 4 Mar 2008 16:57:18 +0100
> From: Benoit Minisini <gambas at ...1...>
> Subject: Re: [Gambas-user] Gambas class to read a joystick
> To: mailing list for gambas users <gambas-user at lists.sourceforge.net>
> Message-ID: <200803041657.18174.gambas at ...1...>
> Content-Type: text/plain;  charset="iso-8859-1"
> 
> On mardi 4 mars 2008, Audiossis wrote:
> > > ------------------------------
> > >
> > > Message: 3
> > > Date: Mon, 3 Mar 2008 09:56:26 -0500
> > > From: Rob <sourceforge-raindog2 at ...94...>
> > > Subject: Re: [Gambas-user] Gambas class to read a joystick
> > > To: gambas-user at lists.sourceforge.net
> > > Message-ID: <200803030956.26368.sourceforge-raindog2 at ...94...>
> > > Content-Type: text/plain;  charset="iso-8859-1"
> > >
> > > On Monday 03 March 2008 08:29, Benoit Minisini wrote:
> > > > So, in File_Read, you must read the file descriptor by blocks:
> > >
> > > Thanks, I might as well write the joystick component in Gambas then.
> > > How do you think it should be named?
> > >
> > > Rob
> >
> > Rob,
> >     Sorry, it took me a little time to post to your request. I am
> > another Gambas user (not a developer), but I have written a Gambas class
> > file to make use of a C library called libusb. It would seem to me that
> > you may benefit from this class file with your joystick issue if your
> > joystick is not detected in a way that Gambas can otherwise use.
> >
> >     This library will let you write a user mode driver or program that
> > will access almost any type of usb device, although it does have its
> > limits (isochronous tranfers are not supported yet). However, that being
> > said, if you know enough C to program a Gambas module, then you may be
> > able to add isochronous support to this library for your own uses......?
> > You could then build on my class file and get the joystick support you
> > are looking for. Using libusb would allow you to bypass the HID driver
> > altogether.
> >
> > Perhaps you could even base a Gambas module on the libusb library....?
> >
> > Just a suggestion.
> >
> > Ben
> >
> > (PS. Sorry for the double post Benoit, I keep forgetting to change the
> > subject line......)
> 
> I think you shouldn't read usb directly, because the Linux kernel has
> implemented an abstraction layer with devices located in /dev/input.
> Apparently you have /dev/input/event? devices that send input events, and
> specific devices for mice, joystick, and other things I don't know. If the
> joystick/keyboard/mouse is USB or serial is managed by these drivers.
> 
> My 2 cents...
> 
> --
> Benoit Minisini
> 


Hi Benoit,

I understand the point you are trying to make and I agree in part. If the 
kernel has a working driver for that device (eg. evdev) then that driver should 
be used. However that being said, there are circumstances when the kernel mode 
driver is not suitable. The kernel mode driver may be broken or the USB device 
has been incorrectly detected or a kernel mode driver for that device may not 
exist. 

In my case the USB device I have written my program for (a CD/DVD storage 
carousel), was actually detected by the kernel as a HID device, which it is 
not. No kernel mode driver exists for my devices (for linux at any rate). 

Another point I would like to make as well is that libusb interfaces with the 
kernel abstraction layer that you speak of and performs all of it tasks through 
the usbfs subsystem. It also has the ability to detach a kernel driver for the 
selected usb device in order to take exlusive control of the device and drive 
it. In fact even the SANE scanner driver/program is based on libusb.

Accessing the USB device through libusb in Gambas works fine for me. It very 
rarely has any problems. Bear in mind though, I am not trying to use 
isochronous transfers (as I beleive that a joystick would require), only 
interrupt and bulk transfers. You could continuously poll the joystick with 
interrupt transfers, but that would probably consume too much CPU time and it 
would probably make the joystick perform very poorly

Anyway I didn't want to start an argument, so I'll stop rambling now, I just 
wanted to make a suggestion.

Ben



------------------------------------------------------------
This email was sent from Netspace Webmail: http://www.netspace.net.au





More information about the User mailing list