delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/05/07/11:00:40

From: Uwe DOT Huebner AT gmd DOT de (Uwe Huebner - EDS-CAT)
Subject: Re: getch()
To: WKIM AT vms DOT cis DOT pitt DOT edu (Wonkoo Kim EE U. of Pittsburgh)
Date: Fri, 7 May 1993 16:06:41 +0200 (MET DST)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu

I had a similar problem (was looking for an unbuffered get-character
function. Up to now I'm using getkey() of <pc.h> but
it has the drawback of mapping key combinations to values greater
than 255. So I wrote a wrapper that maps values above 255
to character (<256) combinations:

int getkbd()

{
  static int i_next=-1;
  int i;

  if (i_next != -1)
    {
      i=i_next;
      i_next=-1;
    }
  else
    {
      i=getkey();
      if (i>511)
        {
          i_next=i-512;
          i=27;
        }
      if (i>255)
        {
          i_next=i-256;
          i=0;
        }
    }
  return(i);
}

I'm not as happy with that solution as I should be.
I there a better solution?

Uwe
-- 
-------------------------------------------------------------------
Uwe Huebner                          e-mail: huebner AT borneo DOT gmd DOT de
GMD/SET
P.O.Box 1316                             Phone: (+49) 2241 14-2771
D-5205 Sankt Augustin 1                    Fax: (+49) 2241 14-2342
-------------------------------------------------------------------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019