Re: [AD] demo of new joystick API

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


Chris wrote:

Robert Ohannessian wrote:

- Type: AL_JOYSTATE

  This is a structure that is used to hold a "snapshot" of a
  joystick's axes and buttons at a particular instant.  It contains
  the following publically readable fields:


Could we get of those, please?


Do you mean get *rid* of? If so, yes I agree, please. It's too close to polling for my liking.


Hmm, I guess this is none too popular. How do you guys want to do it? Do you mean to put the equivalent of AL_JOYSTATE directly into the AL_JOYSTICK structure?

I don't want to give direct access to some array that could be updated at any time by another thread.

  The `stick[s].axis[a].pos' values are always in the range -32767 to
32767.


Could we make it -1.0f to +1.0f? If users need to scale them, they'll
almost certainly have to divide by 32767.0 anyway.


Yes, and we could make the digital input use the same field (1.0f, 0.0f, -1.0f, with no in-betweens if directional pads can be mapped to a joystick).


Hmm, I've never seen an OS-level driver work with floats though, so it's always going to incur some penalty. My thinking was, if we leave the floating point conversion & division to the user, it can be avoided when unnecessary. The background thread is processing joystick axis movements all the time, regardless of whether the user cares about that particular axis. If you guys thinks that's okay, we can go with the floats.

What about making the joystick/joystate structure have dynamicly allocated arrays? I mean, why allocate 5 sticks with 3 axis each and 32 buttons if the "joystick" only has 12 buttons (including a 4-point d-pad).


Currently, it's because of al_get_joystick_state(). If the size is fixed, the user can allocate AL_JOYSTATEs on the stack and use it like this:

   AL_JOYSTATE state;
   al_get_joystick_state(joystick, &state);

Peter




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