Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!mips!apple!sun-barr!newstop!sun!stpeter!cmcmanis From: cmcmanis@stpeter.Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga.tech Subject: Re: Reading the keyboard without a window. Keywords: keyboard,read,easy? Message-ID: <131583@sun.Eng.Sun.COM> Date: 9 Feb 90 22:44:23 GMT References: <6675@ucdavis.ucdavis.edu> <1990Feb9.150945.29787@santra.uucp> Sender: news@sun.Eng.Sun.COM Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 54 AAAAAAAAAAAAAAAAAAAAARRRRRRRRRRRRRRRRRRRRRGGGGGGGGGGGGGGGGGGGHHHHHHHHHHHH! In article <6675@ucdavis.ucdavis.edu> (Brewski Rogers) wrote: > For a game I am working on, I need to be able to read the keyboard > without having a window open. In article <1990Feb9.150945.29787@santra.uucp> (Juhana R{s{nen) writes: > One (quite brutal) way to do this is to read the keyboard input register > directly. The address is (I belive) $bfec01, and there you'll see the > latest keyboard event (both presses and releases). WRONG!WRONG!WRONG!WRONG!WRONG There are so many *SUPPORTED* ways to do this without some bogus reading of an Address that may or may not be there in a different model that this sort of approach should never ever even be considered except in jest. Then to add insult to injury he continues : >Reading an address constantly to decide whether something has happened or not >is rather a clumsy thing to do, a better way would be to install an >interrupt server that is invoked by PORTS-interrupt, which occurs (at least) >every time a key is pressed or released. The interrupt-routine should >peek into the keyboard register and then, if necessary, send a signal to >the main program that there's a keypress available in a common memory area. >However, this requires assembly programming and a firm knowledge of what >one is doing (to keep the multitasking alive). Which I understand to mean "don't peek until you get an interrupt." Which is still wrong, the correct answer is *DON'T PEEK EVER*. I hate to generalize to "europeans" but this kind of answer seems to constantly originate on your side of the Atlantic, Why? At the very least you can call AddHandler(). This is *easy* to do compared to peeking and polling and all that other stuff you suggested. Just call AddHandler and *poof* keyboard events will be passed to your program via calls to this handler. And you don't even need a "firm knowledge of what one is doing" to keep multitasking alive! And think of all the code space you will save in your program because you are using the routines in the ROMs instead of in RAM, and gee it will work on any Amiga and it is still JUST AS FAST as your code is, cuz it's in assembler too! Don't you guys get the documentation? Don't you read it? European games are looked at derisively here, not because they aren't creative or sexy, but because they always seem to work on only one type of Amiga, whatever type it was that the developer happened to have. Please spread the word that you don't have to reinvent the wheel every time you want to read a key from the keyboard. --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@Eng.Sun.COM These opinions are my own and no one elses, but you knew that didn't you. "If it didn't have bones in it, it wouldn't be crunchy now would it?!"