[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] usb game controllers



On Thu, Jun 23, 2005 at 12:57:46PM -0500, Terry Hancock wrote:
> On Wednesday 22 June 2005 05:33 pm, Bob the Hamster wrote:
> > On Wed, Jun 22, 2005 at 04:17:51PM -0500, Terry Hancock wrote:
> > > Is there any capability to support USB game controllers on 
> > 
> > Pygame supports joysticks nicely. See 
> > http://pygame.org/docs/ref/Joystick.html
> > 
> > Support for USB joysticks on linux in general is quite good, although 
> > some special features like vibration or force-feedback won't be 
> > available.
> 
> So it appears that you are saying that even a device like this one:
> 
> http://www.cdw.com/shop/products/specs.aspx?EDC=313623
> (summary*)
> 
> is still just a joystick as far as PyGame is concerned?  Is there such
> a thing as a hardware compatibility guide for this, or can one
> expect any of them to work?  (standard interface?)

USB joysticks/gamepads are *very* standard. The old ones that connect to 
the sound card are less so... but still not bad.

Looking at the gamepad at that link< expect it would probably show up as 
a six-axis 13 button joystick -- of course, it is possible that the 
directional pad and the left thumb stick are duplicates of each other 
(I have a device like that) and also sometimes some of the buttons will 
be duplicates (but usually not)

> Actually, I see the PyGame mascot is chewing on one of these, so
> maybe I should've guessed.  ;-)
> 
> Now that I look more closely, I can see that PyGame's Joystick
> object appears to support an arbitrary number of buttons and
> other devices.
> 
> What, BTW, is a "directional hat".  The first thing that comes to mind
> is a unit vector which is written with a circumflex or "hat". But maybe
> this is a reference to the shape of a "thumb stick" controller?

That is probably refering to the + shaped directional button. It would 
probably show up as a pair of thresholded analong inputs.

> Sorry if I'm seeming clueless here, I'm not really much of a gamer
> myself, and I definitely am having trouble with jargon conflicts, I
> can see.

Jargon is fun :)
forgive my rambling about "thresholded analog inputs"

What I mean by that is two inputs that represent X and Y position. 
Normally these are zero when the joystick is centered. The Y goes 
negative for up, positive for down, the X goes negative for left, 
positive for right (I think that is the way, I might be turned 
around today)

Anyway, when the inputs are thresholded, as think might be the case for 
the "hat" you were asking about, the X and Y values will not change 
until they go beyond a certain threshold. So while pushing left on a 
regular joystick would cause the X axis to go negative -.01 -.05 -.18 
-.30 ... -.77 -.86 -1 ... as you pushed it harder and harder, but the 
hat on the other hand would not respond at all to a light touch, but 
might jump all the way to -1 when you press hard enough.

> This may have seemed really obvious to the developers' community
> for PyGame, but I don't think the site is explicit enough about this
> kind of support.  To someone like me who's not familiar with the
> subject, it doesn't leap out as obvious that such stuff will be 
> supported.  The "Newbie Guide" for example, doesn't touch on stuff
> like this.   I'm going to have to think about that for a bit, maybe I
> can come up with something useful for the tutorials page.

Does anybody know if there is a pygame wiki out there somewhere where we 
could write up this sort of thing?

> *Summary:
> This is very similar to the controllers on console video games
> (specifically, I think it mimics the Playstation 2's controller, but
> GameCube and  Xbox controllers are very similar).
> 
> The device has more controls than a single joystick:
> 
> 2 "thumb sticks"
> 1 "8-way cross keypad"
> 13 buttons (I see four on the right side, looks like 3 macro buttons
> and probably one "left" and "right" buttons along the top).
> 
> I'm not particularly into this particular one, but there are several
> such devices for sale that have more or less the same interface.

The best thing to do is just buy the thing and play with it.
It'll be fun! :)

---
Bob the Hamster