home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 9
/
FreshFishVol9-CD2.bin
/
bbs
/
util
/
mayflower.lha
/
MayFlower
/
CapsLock
/
docs
/
CapsWarn.post
< prev
Wrap
Text File
|
1993-07-14
|
2KB
|
86 lines
[From ] Rj Schack [REC'D] [SENT] [MSG 4827 OF 4990]
[To ] Jeff Johansen [Reply To 4823] [Has Reply 4843]
[Date ] 19 Jun 92 05:06:10
[Subject ] Caps Lock Question
-> The other day I was thinking of a neat programming idea and was
-> wondering if any one here has seen such a beast or might wish to
-> write one. Here goes... I turn my Amiga on (or reboot it) and
-> press my CapsLock key so the red light comes on. Somewhere in
-> or after Statup-Sequence a program senses I have done this and
-> executes a pre-determined program or script.
---------- [cut here] ----------
/* CapsWarn.c - by Rj Schack - placed in the public domain.
SAS/C 5.10b: lc -O capswarn.c
Blink 5.10b: blink lib:c.o capswarn.o lib lib:lc.lib lib:amiga.lib
define __main=__tinymain sc sd nd
*/
#include <exec/memory.h>
#include <devices/keyboard.h>
int CXBRK(void) { return(0); }
int chkabort(void) { return(0); }
main()
{
struct IOStdReq *KeyIO;
struct MsgPort *KeyMP;
char *KeyMatrix;
char ReturnCode = 0;
if (KeyMP = CreatePort(NULL, NULL))
{
if (KeyIO = CreateExtIO(KeyMP, sizeof(struct IOStdReq)))
{
if (!(OpenDevice("keyboard.device", NULL, KeyIO, NULL)))
{
if (KeyMatrix = AllocMem(20, MEMF_PUBLIC|MEMF_CLEAR))
{
KeyIO->io_Command = KBD_READMATRIX;
KeyIO->io_Data = KeyMatrix;
KeyIO->io_Length = 20;
DoIO(KeyIO);
if (KeyMatrix[12] & (1 << 2))
ReturnCode = 5;
FreeMem(KeyMatrix, 20);
}
CloseDevice(KeyIO);
}
DeleteExtIO(KeyIO);
}
DeletePort(KeyMP);
}
exit(ReturnCode);
}
---------- [end here] ----------
Example script usage:
---------- [cut here] ----------
dev:path/CapsWarn
if warn
echo "CapsLock key is active."
endif
---------- [end here] ----------
Source is sparse with no casting for brevity over nets. You'll
get warnings, but it should compile okay. I would've uuencoded it
(as an executable), but I prefer to deal with source code. If you
can't compile it, I can put the source/executable up on 42. BTW,
it's only tested under v37.
- RjS
--- Star-Net v1.0
* Origin: Phila Amiga Users Group 215-551-1485/6113 (1:273/50.0)