home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
521.lha
/
ProMouse_v1.20
/
ProMouse.mod
< prev
next >
Wrap
Text File
|
1991-06-09
|
4KB
|
142 lines
MODULE ProMouse;
(******************************************************************************
Program name: ProMouse
Version : 1.20
Created : Sept. 17, 1989
Author : Robert Kozak
Description : A Proportional Mouse accellerator. From what I hear most mouse
accellerators speed up the mouse by a constant value. This one is
proportional to the individual mouse movements. You may set a sensitivity
value (1-10) from the command line like this :
Promouse 3
Also as you'll notice this program doesn't do anything fancy like display
memory or system time. This just does what it claims.
Status : This program is copyrighted and freely redistributable as long
as it isn't sold for profit. You may use the routines within for whatever you
wish.
******************************************************************************)
FROM SYSTEM IMPORT ADR, ADDRESS, TSIZE, SETREG, SAVEREGS, LOADREGS,
REGISTER, BYTE, STRPTR;
FROM RunTime IMPORT CurrentProcess;
FROM Ports IMPORT MsgPortPtr;
FROM Tasks IMPORT Wait, SignalSet;
FROM Interrupts IMPORT Interrupt;
FROM Devices IMPORT OpenDevice, CloseDevice;
FROM IO IMPORT IOStdReq, DoIO;
FROM InputEvents IMPORT InputEventPtr, IEClass, IEQualifiers, IEQualifierSet;
FROM InputDevice IMPORT INDAddHandler, INDRemHandler;
FROM PortUtils IMPORT CreatePort, DeletePort;
FROM DOS IMPORT SIGBreakC;
FROM ConsoleDevice IMPORT RawKeyConvert, ConsoleName, ConsoleBase;
FROM CmdLineUtils IMPORT argc, argv;
FROM TermOut IMPORT WriteString, WriteLn, WriteInt;
FROM ExtConversions IMPORT ConvStrToInt;
VAR
ioreq : IOStdReq; (* for input handler *)
iostdreq : IOStdReq; (* for console device *)
int : Interrupt;
port : MsgPortPtr;
x : INTEGER;
CONST
threshold = 11; (* Used so that sensitivity can be from (1-10)
instead of (10-1) *)
PROCEDURE InputHandler(): LONGCARD;
VAR
event : InputEventPtr;
S : INTEGER;
BEGIN
SAVEREGS({2..7,10,11,14});
S := threshold - x; (* set up the sensitivity *)
event:=ADDRESS(REGISTER(8));
WITH event^ DO (* Do the calc on the Mouse values for x and y *)
IF ieClass=IEClassRawMouse THEN
IF (ABS(ieX) < 15) AND (ABS(ieX) > S) THEN
ieX := (ieX * ABS(ieX)) DIV S;
END;
IF (ABS(ieY) < 15) AND (ABS(ieY) > S) THEN
ieY := (ieY * ABS(ieY)) DIV S;
END;
END;
END;
LOADREGS({2..7,10,11,14});
RETURN LONGCARD(event);
END InputHandler;
PROCEDURE AddInputHandler();
VAR
x : LONGINT;
BEGIN
port:=CreatePort(NIL,0);
IF port # NIL THEN
ioreq.ioMessage.mnReplyPort:=port;
WITH int DO
isNode.lnPri:=BYTE(75);
isCode:=InputHandler;
END;
IF OpenDevice(ADR("input.device"),0,ADR(ioreq),LONGBITSET{})=0 THEN
ioreq.ioCommand:=INDAddHandler;
ioreq.ioData:=ADR(int);
x:=DoIO(ADR(ioreq));
END;
END;
END AddInputHandler;
PROCEDURE RemInputHandler;
VAR
x : LONGINT;
BEGIN
ioreq.ioCommand:=INDRemHandler;
ioreq.ioData:=ADR(int);
x:=DoIO(ADR(ioreq));
CloseDevice(ADR(ioreq));
DeletePort(port);
END RemInputHandler;
PROCEDURE Control;
VAR
wakeup : SignalSet;
BEGIN
AddInputHandler();
(* No busy waiting here. NO LOITERING! *)
wakeup:=Wait(SignalSet{SIGBreakC});
IF SIGBreakC IN wakeup THEN
WriteString("ProMouse ... Disabled\n");
END;
RemInputHandler();
END Control;
PROCEDURE GetArgs;
VAR
done : BOOLEAN;
BEGIN
IF argc >= 1 THEN done := ConvStrToInt(argv[1]^,x);
IF (x < 1) OR (x > 10) THEN x := 5; END;
WriteString("Sensitivity value set at "); WriteInt(x,0); WriteLn;
END;
END GetArgs;
BEGIN
WriteString("ProMouse Version 1.20 (C) 1989 by Robert Kozak\n");
GetArgs();
IF OpenDevice(ADR(ConsoleName),-1,ADR(iostdreq),LONGBITSET{})=0 THEN
ConsoleBase:=iostdreq.ioDevice;
Control;
CloseDevice(ADR(iostdreq));
END;
END ProMouse.