Re: [AD] key scan codes have changed?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On May 2, 2005 04:10 am, AJ wrote:
> > What it's supposed to return is what is in the documentation:
> >
> >           val = readkey();
> >           if ((val & 0xff) == 'd')     /* by ASCII code */
> >              allegro_message("You pressed 'd'\n");
> >
> >           if ((val >> 8) == KEY_SPACE) /* by scancode */
> >              allegro_message("You pressed Space\n");
> >
> >           if ((val & 0xff) == 3)       /* ctrl+letter */
> >              allegro_message("You pressed Control+C\n");
> >
> >           if (val == (KEY_X << 8))     /* alt+letter */
> >              allegro_message("You pressed Alt+X\n");
> >
[snip]
> if i want to test for alt-c  do i go  if ( readkey() == 0xfc7e )   or do
> i go   if (( (readkey()&0xff) == 7e ) && ( keyshifts & ALT_FLAG ))   ??????

You did read the documentation there right? Where did it ever say you could 
test directly against the returned integer? In all cases, it says to pull the 
words apart and then test.

IMO, Never directly use the values of the KEY_ defines, or directly test 
against readkey's return value. the KEY_ defines have and will change. Thats 
why we have #defines for them in the first place.

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/