[AD] New event proposals

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


1) Input events

Quick code:

enum /* input sources */
{
   AL_KEYBOARD,
   AL_MOUSE,
   AL_JOYPAD
};

typedef struct AL_BUTTON
{
   int source;
   int state;
   int key;
} AL_BUTTON;

No way to get actual source (I don't see any need). Source type is provided because you may need to know is it keyboard button (to get text) or something else.

Note that AL_BUTTON can be generated by keyboard, mouse, joypad or something else. Key variable is not real scancode. For example keyboard keys would be from 0-399, mouse 400-499, first joypad 500-999, etc. It could be used as this:

move_left = button.key;       /* we don't care where from key is */
if (button.key == move_left)  /* same */

There should also be function to get name from "fake scancode" and vice versa.

2) Getting events

Quick code:

switch (al_get_next_event_type(queue))
{
   case AL_BUTTON_EVENT:
   {
      AL_BUTTON button;
      al_get_next_event(queue, &button);
   }
}

Could be cleaner or uglier depending how you look at it. Good thing it allows infinite number of user events and no size limit. Just a idea.

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