Index: [thread] [date] [subject] [author]
  From: Andrew Apted <ajapted@netspace.net.au>
  To  : ggi-develop@eskimo.com
  Date: Thu, 2 Jul 1998 02:44:48 +1000

Re: ggiGetc or ggiGetkey?

Steve writes:

>  > 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.)

I reckon ggiGetc() should ignore modifier keys -- seems more in line
with the idea of a simple "wait until keypress" function like ggiGetc is.

The new code would be :

    static inline int ggiKeyRead(ggi_visual_t vis)
    {
            ggi_event ev;
    
	    do {
                /* Block until we get a key */
                ggiEventRead(vis,&ev,emKeyPress | emKeyRepeat);
    
	    while ((KTYP(ev.key.sym) != KT_SHIFT) && 
                   (ev.key.sym != K_VOID));

            return ev.key.sym;
    }
    
>  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[*]?

Lots of useful keys are up there (ENTER, INSERT, F1...) so I'd say allow
those.

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

Yep.

>  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.

I assume SVGAlib gives back MEDIUMRAW keycodes, yeah ?  In that case we
can simply use the KDGKBENT & TIOCLINUX(10) ioctls to convert the
keycodes to keysyms.  Look at display/fbdev/kbd.c which already does
this.

Cheers,
_____________________________________________  ____
                                               \  /
  Andrew Apted   <andrew@ggi-project.org>       \/
  

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