Re: [AD] Hotplug joysticks

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


On August 18, 2010, Peter Wang wrote:
> On 2010-08-18, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> > I've got joystick hotplugging working on Windows right now.
> > This is one feature that maybe should be added to 4.9 now
> > because it changes the semantics of how things work a bit.
> > This is how it works:
> > 
> > The user installs joystick driver and calls al_get_num_joysticks and
> > al_get_joystick(x). Everything behaves as normal until:
> > The (new) system event source (al_get_system_event_source) emits a
> > ALLEGRO_EVENT_JOYSTICK_CONFIGURED event.
> 
> I would prefer a dedicated joystick subsystem event source.  Actually,
> we don't *need* a separate joystick event source per joystick, so maybe
> we should use a single joystick event source for all joysticks.
> In fact, the user doesn't need to see ALLEGRO_JOYSTICK objects at all:
> just use the joystick number.  In many ways this would be more
> convenient.

Thats what I thought too, but a user may want to have a separate thread per 
display, and give the joystick to that thread as well. Unless this joystick 
number can be used to register a given joystick in a separate queue?

> > At this point, the user can ignore the event and proceed as
> > normal, but if they call al_get_num_joysticks, the present "user"
> > configuration of sticks changed to the present "system" view of
> > joysticks (what is actually plugged in and not on the system at that
> > time.) User calls al_get_joystick(x) again for all desired joysticks.
> 
> How about adding al_reinstall_joystick(), or al_reconfigure_joysticks()?
> It would then be obvious that from that point, al_get_num_joysticks may
> change, all old joystick structures become invalid (if that's what we
> want), and they need to be reregistered (unless we switch to a single
> joystick event source).

I think it'd be better to just automatically de-register joysticks on 
removal. In most cases all it means is the joystick events stop coming. if 
you're doing anything clever with the ALLEGRO_JOYSTICK structures you're 
asking for trouble. Though theres no need to free those structures either, 
unless the joystick subsystem stores them in an array for some reason. But 
either way there really isn't a need to do anything special with them.

I guess mostly we agree...

> 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
tfjellstrom@xxxxxxxxxx




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