Re: [AD] nld_readkey()

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


stickman2000@xxxxxxxxxx writes:

> By providing 'nld_readkey' with Allegro, the developer doesn't have to do
> much to support keys depending on num lock's state, all they have to do
> is call nld_readkey instead of readkey. I find it useful, I think other
> developers out there, who use Allegro, would also. Perhaps we could take
> a poll?

Your patch is incorrect.  It should use numlock state at the time of
pressing key on keypad, not numlock state at the time of calling
nld_readkey.

There are several ways to solve it:

1) Keep shift state in buffer together with scancodes.  Then
nld_readkey will act according to numlock state and readkey will
ignore this information.

2) Add new scancodes for keypad keys pressed when numlock is on.  Then
nld_readkey will convert scancodes to usual ones (not keypad
scancodes), and readkey will remove numlock state from scancode.

3) Add new flag (ignore_numlock_flag?).  If it is set, then keyboard
will work as it does now.  If it is not set, then keyboard handler
will convert key codes according to numlock state on insertion.  No
special function is necessary then, and programmers may distinguish
between keys pressed with keypad and main keyboard by using scancode.

IMHO, last one is better than first ones.  Also it is similar to how
keys can be entered with ALT-numpad (look in src/misc/pckeys.c).

-- 
Michael Bukin



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