Re: [AD] Input routines

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


Some advanced keyboard handling routines rely on checking the entire state of the keyboard to
function, e.g. routines that assign the time each button was held down. Event based keyboard
handling is suboptimal, since if the window loses focus, you may end up with a stuck key if the
key's state changed during the time the window lost focus. And, I am guessing, that it is faster
to get the entire state in one call than to iterate over all buttons using al_key_down.

I think that al_get_*_state functions should stay, and there should be an al_joystick_key_down of
some sort, for consistency.

--- Ryan Dickie <goalieca@xxxxxxxxxx> wrote:

> void al_get_keyboard_state(ALLEGRO_KBDSTATE* ret_state)
> bool al_key_down(const ALLEGRO_KBDSTATE* state, int keycode)
> bool al_set_keyboard_leds( int leds ) //notice, no keyboard or
> keyboard state supplied
> 
> I have a question. What is the purpose (for the end user) for getting
> the keyboard state to check if a key is down?
> Wouldn't it be more straight forward for a user to call 'bool
> al_key_down(int keycode)'
> 
> The same goes for mouse routines
> void al_get_mouse_state(ALLEGRO_MSESTATE* ret_state)
> bool al_mouse_button_down(ALLEGRO_MSESTATE* state, int button)
> 
> With the joysticks you can fetch the state given a joystick.. so I do
> see a point.
> void al_get_joystick_state(ALLEGRO_JOYSTICK* joy, ALLEGRO_JOYSTATE* ret_state)
> but with the joystick there is no button down function etc.
> 
> --ryan



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ




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