Re: [AD] demo of new joystick API |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
Peter Wang wrote:
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?
That would be an idea. The joystick state is updated asyncronously in a seperate thread, and the functions that you had taking AL_JOYSTATE take AL_JOYSTICK instead. After all, there aren't too many direct uses for having more than one joystick state per 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.
I don't think floating point math is that much slower.. it's not going to be done in the main thread so it won't be interrupting the main program anyway. Besides, it's either integer multiple+divide, or convert to float+multiply ((float)axis * (1.0f/(float)driver_constant)). Hopefully the driver constant can be worked out at compile time. If not, then it's a divide.
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);
You could have al_get_joystick_state allocate it for you. Though then you'd need al_clear_joystick_state.
- Kitty Cat
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |