smcgerty@vax1.tcd.ie (02/09/91)
In article <1991Feb2.000213.11161@athena.mit.edu>, cadill@athena.mit.edu (Christopher J Carrillo) writes: >> >>In article <CADILL.91Jan27182015@e40-008-5.mit.edu> cadill@athena.mit.edu (Christopher J Carrillo) writes: >>>I would like to know how to write a C program which monitors the keyboard and >>>writes a record of every keypress to a file. >> >>There are some examples on the Fish disks. From my brain, there is >>1. Journal, and 2. a pair of programs Report/??? (sorry, forgot the name). > > Do you mean that on Fred Fish disk number 1 there is a program named "Journal" > and on Fred Fish disk number 2 there are two programs in a directory called > "Report" ? > I'm sorry, I just didn't understand what you meant. I havn't a clue about the Fish disks, but if you want to detect what keys are being pressed at any instant, then there is a cheap and dirty way of doing it using the hardware; someone else can work out a way of outputting them to a file... (preferably not using the following...) WARNING: I DON'T KNOW IF THIS WILL WORK ON ALL AMIGAS. (I use an A500) I have discovered that the currently depressed key is held at $bfec01 Just peek this value, XOR it with 255 ($FF) and rotate it left once. The resulting number corresponds with the key value table in the Amiga Hardware Reference Manual: eg F1-F10 = $50-$59 I'll give a quick example in M68000 assembly and not in C, as it look ugly in C! move.b $bfec01,d0 eor.b #$ff,d0 ror.b #1,d0 cmp.b #$50,d0 bne NOT_F1 ; Do F1 stuff NOT_F1 cmp.b .... I dunno if this helps anyone. (It may be ugly, but its a neatish way of checking the keys if you have turned off multitasking.) I haven't actually used this method for anything (I'm an Intui/C type programmer by default) but I have come across a few people who like doing Hardware level programming, but couldn't detect the keyboard, so this looked as good an opening as I was likely to get to tell the world.. REMEMBER: I'm pretty certain this is the sort of thing C= hate to see, so don't come crying to anyone if it doesn't work on your machine. Mail me if you have any thoughts on the good/bad styles of programming the amiga, or if you have any other little 'twiks'... ---------------------------------------------------------------------------- | / T | / Stephen John McGerty | "I could be wrong" Amiga // | | / | |/ smcgerty@vax1.tcd.ie (C.Sci.) | Me. \\// | |__________________________________________|_______________________________|
Jay@deepthot.cary.nc.us (Jay Denebeim) (02/23/91)
In article <1991Feb9.114958.7734@vax1.tcd.ie> smcgerty@vax1.tcd.ie writes: >I havn't a clue about the Fish disks, but if you want to detect what keys are >being pressed at any instant, then there is a cheap and dirty way of doing it >using the hardware; someone else can work out a way of outputting them to a >file... (preferably not using the following...) Would somebody shoot this guy please. There is a simple way of capturing ALL input events, modifying them and basically doing whatever you want with them. In 2.0 there is even a library (comodities) that allows programs to bind into the input chain coopertavely. For previous versions of DOS a good example of this technique is in our PopCLI program. It has always come with source, and is available on our BBS, the fish disks, or by sending mail to filerequest@deepthot.cary.nc.us requesting FILE: popcli4.arc. DON'T GO TO THE HARDWARE. Its not nice. > >---------------------------------------------------------------------------- >| / T | / Stephen John McGerty | "I could be wrong" Amiga // | >| / | |/ smcgerty@vax1.tcd.ie (C.Sci.) | Me. \\// | >|__________________________________________|_______________________________| -- |_o_o|\\ |. o.| || The Jay Denebeim | . | || Software | o | || Distillery | |// Address: UUCP: mcnc.org!deepthot.uucp!jay ====== Internet: jay@deepthot.cary.nc.us BBS:(919)-460-7430 VOICE:(919)-460-6934