Re: [AD] user data for timers

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


On Fri, Sep 11, 2009 at 8:21 PM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
> I'm not very opposed to it, but my concern is that we'll start getting
> requests for userdata for a bunch of other objects, which could get very
> silly.  Why timers and not others?
>
The honest, but unhelpful, response is because timers are the only
objects I've wanted to attach user data to.

Limiting the discussion to event source objects, there are:
* Keyboard, Mice: only one per system, so not useful
* Joystick: al_get_joystick_number(source) already identifies the object.
* Display: 99% of the time I'd only have one, so it's not very likely
I'd need data associated with it.
* User: already can do it.

Alternatively, this more general purpose function would suit me:

void al_register_event_source_with_data(ALLEGRO_EVENT_QUEUE *queue,
  ALLEGRO_EVENT_SOURCE *source, void *data)

where the current rules about a queue / source being unique still
apply. Then it could be accessed via event.any.data.

That would be sufficient for my purposes because I only need a user
data field to quickly identify the object associated with the timer
during event ticks without having to maintain some sort of lookup map.

--
Matthew Leverton




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