delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/17/05:28:25

Message-Id: <3.0.16.19971017112235.34df9b96@hem1.passagen.se>
Date: Fri, 17 Oct 1997 11:23:23 -0400
To: "Ingo Ruhnke" <ruhnke AT owl-online DOT de>
From: Peter Palotas <blizzar AT hem1 DOT passagen DOT se>
Subject: Re: problem with readkey()
Cc: djgpp AT delorie DOT com
Mime-Version: 1.0

At 19.21 1997-10-16 GMT, you wrote:
>I got here some simple code which dosen't run as I expect it to work:
>
>#include <stdio.h>
>#include <allegro.h>
>
>void main()
>{
> allegro_init();
> install_keyboard();
>
> if (readkey() == 'a') {
>   printf ("a was pressed");
> } else {
>   printf ("a wasn't pressed");
> }
>}
Well, the "problem" here is that readkey() returns an integer with
information in the lower 16-bits. The high byte of this contains the
scancode, i.e. ESC = 1 and so on. The low byte contains the Ascii
character, so converting this to a char is neccessary if you just want the
character. This is covered in the docs too AFAIK, read them! :)

-- Peter Palotas alias Blizzar -- blizzar AT hem1 DOT passagen DOT se --

*****************************************************
* A brief description of DJGPP:                     *
* NEVER BEFORE HAS SO FEW DONE SO MUCH FOR SO MANY! *
*****************************************************

- Raw text -


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