Fw: Re: [AD] messy allegro 5.0 stuff

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


----- Forwarded message from "David A. Capello" <dacap@xxxxxxxxxx> -----

Date: Sun, 30 Dec 2001 00:01:34 -0300
From: "David A. Capello" <dacap@xxxxxxxxxx>
To: Bob <ohannessian@xxxxxxxxxx>
Subject: Re: [AD] messy allegro 5.0 stuff
User-Agent: Mutt/1.3.24i

On sáb, dic 22, 2001 at 12:40:14 -0500, Bob wrote:
> >>Other thing, maybe this will be useful for a lot of people:
> >>
> >>al_get_input(AL_KEY_LEFT)
> >>al_get_input(AL_MOUSE_LEFT)
> >>al_get_input(AL_JOY_BUTTON_1)
> >>etc.
> >>
> 
> I don't know about this one. Input devices tend to be *very* different from 
> one another. So building a common do-everything API for input is probably a 
> bad idea. Making the API consistent is good, but making everything the same 
> isn't. Some devices are relative, some are absolute, some have digital 
> buttons, some have analogue buttons, some have multiple sticks, some have 
> roulettes, and the keyboard has 100+ keys. If someone invents a new device, 
> there's a good chance that Allegro won't be able to support it nicely with 
> a common API - Unless that API is flexible enough to accomodate just about 
> anything IMHO.

You are right, but we can have two ways to make the input. The original
one (and the fast one), with:

  al_readkey(), al_keypressed(), al_key[AL_KEY_ENTER],
  al_mouse_x, al_mouse_y, al_mouse_b, al_joy etc.

And we can make a common function (al_get_input) that merges all button
input (note just "buttons"): like keyboard keys, mouse buttons, and joystick
buttons, but *not* the mouse movement and joystick movement (if this is
possible will be better).

We only need to make:

#define AL_KEY_...
#define AL_MOUSE_...
#define AL_JOY1_...
#define AL_JOY2_...

int al_get_input(int code)
/* or maybe AL_BOOL al_get_input(AL_INT code) */
{
  if (code >= AL_KEY_... && code <= AL_KEY...)
    return al_key[code];
  else if (code >= AL_MOUSE_... && code <= AL_MOUSE_...) {
    switch (code) {
      case AL_MOUSE_LEFT:   return al_mouse_b & 1;
      case AL_MOUSE_RIGHT:  return al_mouse_b & 2;
      case AL_MOUSE_CENTRE: return al_mouse_b & 4;
      default: return 0;
    }
  }
  else {
    switch (code) {
      case AL_JOY_...
      ...
    }
  }
}

I am thinking, and, not is so hard make the joystick and mouse movement
in the same function. Sure, if we only use digital input (TRUE - FALSE).

----- End forwarded message -----

-- 
David A. Capello
dacap@xxxxxxxxxx
http://www.davidcapello.com.ar



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