Re: [AD] ALLEGRO_KEYBOARD_STATE improvement

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


On 2008-10-12, Ryan Patterson <cgamesplay@xxxxxxxxxx> wrote:
> Without knowing much about the motivations for including it, I move
> that the display member of this structure should be removed. It isn't
> clear what it actually refers to (the foreground window?

The window that was in focus when you called al_get_keyboard_state().

> the window
> that received the most recent event? what if there is no active
> display?)

It should be set to NULL.

> , and none of the drivers use it anyways.

The drivers *should* be setting it for the user (haven't checked it
recently).

> On Sun, Oct 12, 2008 at 10:59 AM, Ryan Patterson
> <cgamesplay@xxxxxxxxxx> wrote:
> > In the Allegro source, there is this construct:
> >
> > typedef struct ALLEGRO_KEYBOARD_STATE
> > {
> >   struct ALLEGRO_DISPLAY *display;  /* public */
> >   unsigned int __key_down__internal__[4]; /* internal */
> >   /* Was using uint32_t, but some machines don't have stdint.h. */
> > #if AL_KEY_MAX >= (32 * 4)
> > # error __key_down__internal__ array not big enough for AL_KEY_MAX
> > #endif
> > } ALLEGRO_KEYBOARD_STATE;
> >
> > Obviously, AL_KEY_MAX isn't the right symbol to use. However, since
> > ALLEGRO_KEY_MAX is no longer a preprocessor symbol at all, that error
> > will never get triggered. I've written a patch that changes the size
> > of the array to be statically calculated using the value of
> > ALLEGRO_KEY_MAX:
> >
> > typedef struct ALLEGRO_KEYBOARD_STATE
> > {
> >   struct ALLEGRO_DISPLAY *display;  /* public */
> >   unsigned int __key_down__internal__[(ALLEGRO_KEY_MAX + 7) / 8 /
> > sizeof(unsigned int)]; /* internal */
> >   /* Was using uint32_t, but some machines don't have stdint.h. */
> > } ALLEGRO_KEYBOARD_STATE;

Thanks.

Peter





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