Mail Archives: djgpp/1997/06/27/06:01:51
Michael D. Ryan writes:
>I want to be able to interpret an alt code from the keyboard using
>allegro. I have tried doing it the way it says in the allegro.txt and
>it doesn't work.
>
>EX:
>
>int ch, int key;
That's not valid C, so it can't be the exact program you were testing!
When asking for help about a problem, please make sure you post
something that you've actually run, so you are sure that it does indeed
demonstrate the trouble. Of course it's a good idea to strip the guilty
routine down to an absolute minimum, but if you leave essential things
out or just post a sort-of-similar routine, it's very likely that some
silly typo like this will end up leaving out the one line that actually
contains your problem...
>key = KEY_F;
>ch = readkey();
>if (ch == (key << 8)) do_whatever();
>else didnt_work();
>
>It doesn't seem to recognize the keys. I have tried a whole bunch of
>different combinations and no luck.
Looks fine to me. This almost identical program works correctly on my
machine, so your mistake must be in the bits of code that you didn't
post...
#include <stdio.h>
#include <allegro.h>
int main()
{
int ch, key;
allegro_init();
install_keyboard();
key = KEY_F;
ch = readkey();
if (ch == (key << 8))
printf("alt+F was pressed!\n");
else
printf("Something else was pressed!\n");
return 0;
}
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -