Index: [thread] [date] [subject] [author]
  From: Steve Cheng <elmert@ipoline.com>
  To  : ggi-develop@eskimo.com
  Date: Wed, 1 Jul 1998 12:03:05 -0400 (EDT)

Re: ggiGetc or ggiGetkey?

On Wed, 1 Jul 1998, Chris Meadors wrote:

> > Hmm - you should get something like the K_VOID key showing that a key was
> > pressed, but it had no significant translation. It could as well return some
> > value from the Unicode reserved pages.
> 
> Okay, I'm happy with Shift, Alt, Ctrl, Caps, et al returning values this
> could be very useful to action game programmers.

> The svgalib target does almost the same thing, but Shift repeats like the
> other keys do if held.  So the output of my program looks like:
> 
> display-svga: Can't open the help-vgagl (sVgALIb) library.  # Anyone want to
> help me with that error?
> 63  # I press 'c'
> F704  # I press 'Shift'
> F704
> F704
> F704  # Still holding it

Strangely as it sounds, I think this is correct behaviour.  This is because
the shift key is actually returning evKeyRepeat, and ggiGetc() returns all
evKeyPress and evKeyRepeat events. (The reason that the shift repeats at all
is because svgalib does it, even in the so-called raw keyboard mode.)

Also notice that currently ggiGetc() is the same as ggiKeyRead().  Maybe we
should change ggiGetc() so that it just discards keys that are in the
reserved unicode pages (e.g. shift keys) and K_VOID[*]?

The "action game programmers" :) should not use ggiKeyRead() anyway. 
They should just use ggiEventPoll directly and get evKeyPresses and
evKeyReleases (and usually not evKeyRepeats).

[*] So which one is it, a special code for each of the 'special' keys, or a
single K_VOID?  I think K_VOID is less useful because you have to check
MODIFIER_DATA and can't get the exact key pressed.

> 63  # I was trying to get a capital 'C'
> 0  # I pushed the 'Windows' key to exit

I already have an idea to fix the problem. (I'm saying this so that everyone
can have input and/or correct me.)  The svgalib target keeps a table of
current keys pressed.  So if we get the 'letter' keys, then check the known
shift keys, then shift and set MODIFIER_DATA in the ggi_key_event.

Stupid question:  how do you know what keys are letters and shifts?  Not
good to hardcode them.

> With the svgalib target the state of the '-lock' keys doesn't change when
> they are pressed, they just return a value.  Entering my program with the
> capslock on the letter keys still return their lowercase values.  When held
> they repeat.

Sidenote: when you press the -lock keys svgalib doesn't change the LEDs
either.  So if we keep the -lock key state in the svgalib target (no big
deal), will it confuse users thinking that -lock keys are not supported? :-)

> Looks like the svgalib target needs fixed also.  :(

Yup, there's a big warning about these bugs in display/svgalib/events.c.

--
Steve Cheng               

email: steve@ggi-project.org   
www: <http://shell.ipoline.com/~elmert/>;

Index: [thread] [date] [subject] [author]