Re: [AD] user data for timers |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On 2009-09-11, Matthew Leverton <meffer@xxxxxxxxxx> wrote:
> 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.
That's true.
> 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.
How about?
void al_set_event_source_data(ALLEGRO_EVENT_SOURCE *source, intptr_t data);
intptr_t al_get_event_source_data(ALLEGRO_EVENT_SOURCE *source);
Peter