Re: [AD] mouse_api branch

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


On 2006-09-01, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
> On 8/30/06, Peter Wang <tjaden@xxxxxxxxxx> wrote:
> > On 2006-08-29, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
> > > On 8/27/06, Peter Wang <tjaden@xxxxxxxxxx> wrote:
> > > > If you click outside, wouldn't that focus another window?
> > > Oh, yes I see what you mean now.
> > >
> > > In the new API, I don't think there are methods to:
> > > Determine the number of axes on the mouse
> > > Get the value on the fourth axis
> >
> > Add them :-)
> Sorry, I actually meant 'set the value on the fourth axis' - I already
> added the axis to the mouse event and mouse state structure.

You can add a setter function, and a function to get the number of axes...

> Anyway, I'm wondering whether the number of buttons and axes should be
> part of the AL_MOUSE structure.

... and the number of buttons.  (see below)

> I'm assuming there will be something
> analagous in the AL_JOYSTICK structure. Of course, having >1 joystick
> is not unusual, whereas >1 mouse would be extremely unusual*, but it
> would be nice to have the APIs looking 'aligned'.

Sure.  The only problem is that I'd rather refer to the x and y axes by
name (in the AL_MSESTATE) instead of state.axis[0], state.axis[1].  What
about we arrange AL_MSESTATE like this:

    typedef struct AL_MSESTATE
    {
       int buttons;
       int x;
       int y;
       int z;
       int w;
       int more_axes[N];
    } AL_MSESTATE;

Then provide a macro/function to refer to axes by number:

    int al_mouse_state_axis(AL_MSESTATE *state, int axis_num);

where
    x-axis = axis 0
    y-axis = axis 1
    z-axis = axis 2
    w-axis = axis 3

We can add enums for readability, but it's probably too tedious writing
x = al_mouse_state_axis(state, AL_MOUSE_AXIS_X);


Now, to determine the number of buttons/axes:

    int al_mouse_num_buttons(void);
    int al_mouse_num_axes(void);

To set the axes:

    bool al_mouse_set_axis(int axis_num, int value);

How's that?


Peter





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