Re: [AD] num lock dependent scancode conversion

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


stephen.kittelson@xxxxxxxxxx writes:

> On Wed, 13 Sep 2000 19:09:03 +0100 George Foot
> <gfoot@xxxxxxxxxx> writes:
> > I don't think we should mangle the codes used in the key array
> > at all.  Scancodes refer to specific keys, not the functions of
> > those keys.  We don't shuffle up the scancodes in order to
> > support different keyboard layouts, and I don't think we should
> > process numlock at that stage either.
> 
> >From a user's point of view, if they press 'pgdn' (or any other keypad
> key that is dependent on num lock) and num lock is off, I think they want
> the program they are using to recognize 'pgdn', not keypad '3'. Why then,
> should the program recognize keypad '3' if that was not the intention of
> the user?

You are thinking about the GUI, but what about games like doom or
quake, where it only matters which key was pressed/released and not
its meaning (which is configurable by user).

> 
> > In any case, it's
> > relatively trivial to support the numpad arrows through the key
> > array, using this sort of condition:
> > 
> >     (key[KEY_LEFT] || (key[KEY_4_PAD] && key_shifts & 
> > KB_NUMLOCK_FLAG))

It will not affect existing GUI, though.

> 
> > As for readkey, the only effect of numlock should be that with
> > numlock off the ASCII code of numpad keypresses should be set to
> > the current shift state (as with other non-ASCII keys), and with
> > numlock on it should be set to the ASCII code of the number key.
> 
> Without changing the scancode, would that not confuse programs, as they
> would get the ASCII code of something other than anything remotely close
> to the actual key pressed?

Yes, it would not help Allegro GUI, which looks for scancodes and not
ASCII codes.  But if we convert scancodes unconditionally, it would
confuse many games.

BTW, do you want to change functionality of existing programs, without
rewriting them, or do you want this new behaviour only in new
programs?  For example, should the program set some flag to enable
this behaviour, or it should be default behaviour?  If this behaviour
is default, it will break backwards compatibility, if it is not
default (needs some setup from programmer), then it may be done with
small addon package.

Changing scancodes unconditionally is bad, IMHO.  Other alternative is
to have a flag for disabling this conversion.  Or save converted
scancode in key_buffer, together with original scancode, and return
one of them according to some flag.  Or use keyboard_callback as
suggested by Peter Wang.  I like the last one, because we don't need
to change existing keyboard handler, it can be done as addon, it will
not confuse programmers, because they will have to enable it.

-- 
Michael Bukin



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