Re: [AD] ex_joystick_hotplugging.c

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On August 22, 2010, Peter Wang wrote:
> On 2010-08-21, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> > On 2010-08-21, at 6:39 PM, Peter Wang wrote:
> > > Hi,
> > > 
> > > I still think it's a bad idea that al_get_num_joysticks can now
> > > invalidate existing ALLEGRO_JOYSTICK structures.
> > 
> > Yeah, I agree.
> > 
> > > curr_joy is invalid at this point.
> > > 
> > > It crashes when I unplug a joystick.  (I will fix it while fixing some
> > > issues with the linux joystick driver)
> > 
> > Alright. I wanted to get it into SVN because I have
> > other commitments that aren't going to leave me much
> > time to tune this how I'd like right now. I think the
> > issues are pretty minor and shouldn't be too hard to
> > fix.
> 
> Ok.  The Linux joystick driver is much improved now.
> The other drivers seem to require similar changes.
> 
> 
> I think we should not require Allegro programs to put in extra effort to
> cope with hotplugging.  Anything that requires the program to remember
> an old id/index/whatever, in addition to ALLEGRO_JOYSTICK handles, is
> too much work.  I have a feeling most programs wouldn't bother.
> 
> Rather, ALLEGRO_JOYSTICK handles should persist after reconfiguration,
> and they should continue to refer to the same physical devices (which
> are still plugged in).  No re-getting of handles required.
> 
> Handles for devices which have been unplugged should *also* persist, so
> nothing will crash.  Inactive handles should be reused when devices are
> plugged in.  That would make this common situation just work:
> if I pull out device A during a game and plug in device B, I probably
> wanted to use device B in place of device A.  Since the old
> ALLEGRO_JOYSTICK handle is valid, a program that doesn't do anything
> special will work as expected.
> 
> We can add a function:
>     bool al_get_joystick_active(ALLEGRO_JOYSTICK *joy);
> to tell if the handle has a physical device associated with it.
> 
> Comments?

Sounds good to me. It would be best if we could somehow detect whether or not 
the device is the same or not, and give a slot back to the same device. But 
when I checked my joystick, it didn't have any kind of unique id. :( so the 
best we could /really/ rely on is the name, and maybe some other hardware 
properties. And try and give the slot back based on that. Failing that, yes, 
just repopulate which ever slot is free.

Does make it easier for the average allegro user.

> Peter
> 
> ---------------------------------------------------------------------------
> --- This SF.net email is sponsored by
> 
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev


-- 
Thomas Fjellstrom
thomas@xxxxxxxxxx

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/