Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!pacbell.com!tandem!zorch!amiga0!mykes From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz) Newsgroups: comp.sys.amiga.programmer Subject: Re: Checking for a Keystroke (in C) Message-ID: Date: 30 Jun 91 20:37:41 GMT References: <1991Jun27.013554.11040@cccan.uucp> Organization: Amiga makes it possible Lines: 35 In article hinds@repair.stanford.edu (Alexander Hinds) writes: > Could somebody post some (C) code detailing the above? I've >been wanting to do this for a while, but I can't seem to make sense >of the keyboard/CIA stuff in the hardware manual. Thanks. Call this often (several times per second would be good) to check the CIA keyboard port directly: UBYTE CheckKey() { UBYTE far *cia = 0xbfec01; /* note the "far" kludge */ static UBYTE last = 0; UBYTE retval = 0; retval = *cia; if (retval != last) last = retval; else retval = 0; /* * since 'C' is totally bad about not providing things like ROR.B * you get really bad looking stuff like the following: */ retval = ((retval & 1) << 7) + ((retval>>1)&0x7f); return retval; } To check if it is a keyup/down, look at bit 8. The remaining bits are the hardware scan code. -- **************************************************** * I want games that look like Shadow of the Beast * * but play like Leisure Suit Larry. * ****************************************************