Re: [AD] Hotplug joysticks

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


On 2010-08-18, at 9:00 PM, Thomas Fjellstrom <tfjellstrom@xxxxxxxxxx> wrote:
>> 
>> Am I right that al_get_num_joysticks() will mean "max joystick number"
>> or "number of potential joysticks" (which it sort of does already)?
>> If you remove a joystick, the other joysticks ought to retain their
>> numbers, so there will be unused slots between between 0 ..
>> al_get_num_joysticks()-1.
> 
> My original suggestion to trentg involved joysticks having a unique id so a 
> joystick once plugged in never has its number changed. and while you could 
> use a get_num_joysticks, and get_joystick(idx) interface, you wouldn't use 
> those 0-N indexes anywhere else, as they may not match the joystick's actual 
> id.
> 
> Or something I just came up with, a findfirst/next like api for joysticks. 
> Instead of a get_num,get_joystick(id) api. then it doesn't matter how many 
> there are, or what the ids mean. it will only return existing joysticks, and 
> noone has to worry about empty spaces.
> 
> But if you like unused slots, thats an option too.

My idea is kind of a combination of the two ideas. al_get_num_joysticks will return the number of joysticks currently connected to the system, while al_get_joystick will return an id. Events will come from a global joystick object with an id to identify them. Most recently plugged in joysticks will be at the end of the 'list' you get from al_get_joystick. With this api there really isn't a need for a refresh or configure fuction. The user will be expected to store whatever info they need after calling al_get_num_joysticks and should expect calling it to potentially change the layout or order of things in the list. The ids will stay the same between calls if the pad remains plugged in.



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