home *** CD-ROM | disk | FTP | other *** search
- OMouse.TPU for TP 5.5
- =====================
-
-
- Thank you for downloading omouse.zip. Omouse stands for
- object mouse. Compile and run omouse.dem with Turbo
- Pascal 5.5 to see omouse in action. When you want to
- use a mouse in your next application simply include
- omouse in the "uses" clause!
-
- For example:
-
- program MyNextApp;
-
- uses omouse;
-
-
-
- begin
- mouse.show;
- while (not mouse.LeftPressed) do;
- writeln('Mouse's left button pressed.')
- end.
-
- All omouse coordinates are expressed in Turbo Pascal's
- physical screen coordinates rather than the mouse's
- virtual coordinates. Be sure to call mouse.reset after
- each video mode change to enable this feature!
-
- For example:
-
- program MyLastApp;
-
- uses graph, omouse;
-
- var driver, mode, error : integer;
-
- begin
- if not mouse.present then begin
- write('Mouse driver not installed ');
- write('or mouse not properly ');
- writeln('connected!');
- writeln('Press "enter" to halt.');
- halt;
- end;
- driver := detect;
- InitGraph(driver,mode,'');
- error := GraphResult;
- if error <> grOk then
- writeln('Graphics error: ',
- GraphErrorMsg(error))
- else begin
- mouse.reset;
- mouse.x := GetMaxX div 2;
- mouse.y := GetMaxY div 2;
- mouse.GotoXY;
- mouse.trap(mouse.x,mouse.y,
- GetMaxX,GetMaxY);
- OutText('Mouse trapped in lower ');
- OutText('right quadrant.')
- end;
- readln
- end.
-
- Omouse has both initialization and exit code so you need
- not worry about any messy details. All of the mouse
- driver functions are included as methods of the mouse
- object. If you look at the MM (Microsoft Mouse) object
- code in the interface section of omouse, you can see the
- data fields and methods. Both are commented with
- { MF?? } which tells you which (M)ouse (F)unction(s) are
- operating on the data or being called.
-
- For example, consider the following code from the
- interface section of omouse.pas :
-
- MM = object { Microsoft Mouse }
-
- { "var mouse : MM;" below must be the only instance! }
-
- { Exit chain procedure pointer; do not modify! }
- ExitSave : pointer;
-
- { MF0, MF33 : Video mode at reset/SoftReset }
- { Call reset after all video mode changes! }
- { Do not modify! }
- vmode : word;
-
- { MF0 : Set by reset }
- Present : boolean;
- Buttons : word;
-
- { MF3, MF5, MF6 : Button Status }
- LeftPressed, RightPressed : boolean;
-
- { MF3, MF4 : Mouse Positon }
- x, y : integer;
- { X & Y are physical, not virtual coordinates! }
- { Text modes upper left corner : 1,1 }
- { Graphics modes upper left corner : 0,0 }
-
- ...
-
- procedure init; { Don't call! }
-
- { Mouse driver function calls: }
-
- procedure reset; { MF0 }
- procedure show; { MF1 }
- procedure hide; { MF2 }
- procedure UpdateStatusInfo; { MF3 }
- procedure GotoXY; { MF4 }
- procedure UpdatePressInfo; { MF5 }
- procedure UpdateReleaseInfo; { MF6 }
- procedure trap { MF7, MF8 }
- (x1,y1,x2,y2 : integer);
-
- ...
-
- end;
-
- var mouse : MM;
-
-
- In this example listing, you should find vmode and
- thus deduce from the associated comments that
- mouse.vmode is modified and/or referenced by mouse
- functions #0 and #33. Now find the "show" method. This
- implements Microsoft Mouse Driver function #1. You may
- be wondering what calling mouse.UpdateStatusInfo does
- other than call mouse function #3. The answer is that
- it updates mouse.LeftPressed, mouse.RightPressed,
- mouse.x, and mouse.y! Can you see this by finding these
- data fields and seeing that their associated comments
- say that they are modified by mouse function #3? I
- should mention now, if you want to do any serious mouse
- programming it would be a good idea to pick up
-
- "Microsoft Mouse Programmer's Reference."
- Bellevue, Washington: Microsoft Press, 1989.
-
- This is the main reference I used in coding omouse.
- Rather than repeat what is in this book or explain what
- the mouse functions do, you should reference this book.
- By using the book and reading the interface of omouse,
- you will soon get the picture of what's going on.
-
- You will soon notice that the mouse methods don't
- typically pass parameters but values are instead stored
- directly in the mouse object's data fields. The reason
- I don't pass parameters is so you don't have to provide
- variables to store them in. Secondly, omouse has a
- special method called AutoEventUpdate which is a
- prewritten mouse event interrupt handler. All you do is
- call mouse.AutoEventUpdate and it updates the mouse's
- data fields whenever a mouse event happens as specified
- by mouse.EventMask (see p. 167 of the book). The mask
- is preconfigured to request an update whenever the mouse
- moves, or a mouse button is pressed or released. This
- should satisfy most of your requirements. If you need
- something more sophisticed, you can use the code of
- AutoEventHandler() to cookbook your interrupt handler!
- But you'll have to register to get that secret.
-
- I tested the omouse unit with Microsoft Mouse driver
- version 7.00 and Microsoft's second generation mouse.
-
- Compile and run omouse.dem with Turbo Pascal 5.5.
- Peruse its source code to get some ideas about using
- omouse. You are going to have to dig alittle but you'll
- get allot from omouse. Play with the mouse.report in
- the demo to see some of the data fields updated by the
- automatic event handler. Hey, this is shareware! I
- haven't found anyone willing to pay for 60 page manuals,
- e.g. crtplus.zip, crtpls.zip, so I stopped writing them.
- If you feel otherwise let me know. Why not let me know
- via email. Remember I need your support to do more!
-
- If you find omouse useful and are using it in your
- applications, a registration fee of $7 is requested.
- Upon registration you will be sent source code and the
- latest examples programs on a DOS formatted 5 1/4" disk.
-
-
- Thanks,
-
- John
-
- CIS id : 73757,2233
-
-
- P.S. Graphtxt is already available as shareware ($7) on
- the BBS's and PolyList will be as soon as polylist.dem
- and polylist.doc are finished, shareware ($7). Be
- sure to look for crtplus, shareware ($20); this is the
- one with the 60 page manual!
-
-
- Omouse.PAS interface section follows.
- =====================================
-
-
- {
-
- omouse.pas
- 2-23-90
- Microsoft mouse interrupt functions
-
- Copyright 1990
- John W. Small
- All rights reserved
-
- PSW / Power SoftWare
- P.O. Box 10072
- McLean, Virginia 22102 8072
- (703) 759-3838
-
-
- Works consulted:
-
- "Microsoft Mouse Programmer's Reference."
- Bellevue, Washington: Microsoft Press, 1989.
-
- "Microsoft Mouse Programmer's Reference Guide."
- Bellevue, Washington: Microsoft Press, 1986.
-
- }
-
- unit omouse;
-
- interface
-
- uses DOS;
-
- const
-
- {
- Mouse Events, for MM.CallMask, MM.AltCallMask,
- MM.EventMask, and MM.EventFlags.
- }
-
- Moved = 1;
- LeftP = 2;
- LeftR = 4;
- RightP = 8;
- RightR = 16;
- Shift = 32;
- Ctrl = 64;
- Alt = 128;
-
- { Mouse Buttons }
-
- LeftB = 1;
- RightB = 2;
-
-
- type
-
- MouseTypes =
- ( Unknown, Bus, Serial, InPort, PS2, HP );
-
- MouseLanguages = ( English, French, Dutch,
- German, Swedish, Finnish, Spanish,
- Portuguese, Italian );
-
- GraphicsCursorType = record
- HorzHotSpot, VertHotSpot : shortint;
- ScreenCursorMask : array[0..31] of word
- end;
-
- MM = object { Microsoft Mouse }
-
- { "var mouse : MM;" below must be the only instance! }
-
- { Exit chain procedure pointer; do not modify! }
- ExitSave : pointer;
-
- { MF0, MF33 : Video mode at reset/SoftReset }
- { Call reset after all video mode changes! }
- { Do not modify! }
- vmode : word;
-
- { MF0 : Set by reset }
- Present : boolean;
- Buttons : word;
-
- { MF3, MF5, MF6 : Button Status }
- LeftPressed, RightPressed : boolean;
-
- { MF3, MF4 : Mouse Positon }
- x, y : integer;
- { X & Y are physical, not virtual coordinates! }
- { Text modes upper left corner : 1,1 }
- { Graphics modes upper left corner : 0,0 }
-
- { User data area! }
- UserX, UserY, UserLeft,
- UserRight, UserCount : integer;
-
- { MF5 : Button Press Information }
- LastLeftPressX, LastLeftPressY,
- LeftPresses : integer;
- LastRightPressX, LastRightPressY,
- RightPresses : integer;
- { X & Y are physical, not virtual coordinates! }
-
- { MF5, MF6 : Button Requested }
- ButtonRequested : word;
-
- { MF6 : Button Release Information }
- LastLeftReleaseX, LastLeftReleaseY,
- LeftReleases : integer;
- LastRightReleaseX, LastRightReleaseY,
- RightReleases : integer;
- { X & Y are physical, not virtual coordinates! }
-
- { MF11 : Mouse motion counters }
- VertMickeys, HorzMickeys : word;
-
- { MF12, MF20 : Set/SwapInterrupt(s) mask/addr }
- IntrProc : pointer; { See AutoEventHandler }
- CallMask : word;
- { Also used by AutoEventUpdate. }
-
- { Set by Mouse Event Handler. }
- EventMask : word;
- EventFlags : word;
- EventCount : word;
- EventMoved : word;
- ClickTimeOut : longint;
- LeftClickTime : longint;
- LeftClicks : word;
- RightClickTime : longint;
- RightClicks : word;
-
- { MF21, MF22, MF23 : Used by save and restore }
- { Do not modify! }
- OrigState, State : pointer;
- StateSize : word;
-
- { MF24, MF25 : Set/GetAltInterrupt mask/addr }
- AltIntrProc : pointer; { See AutoEventHandler }
- AltCallMask : word;
- { MF25 can read those set by MF20! }
-
- { MF26, MF27 : Set/GetSensitivity }
- HorzPercent, VertPercent, DoublePercent : word;
-
- { MF29, MF30 : Set/GetCRTpage }
- CRTpage : word;
-
- { MF31, MF32 : Used by off/on, don't change! }
- MouseIntrVector : pointer;
-
- { MF34, MF35 : Used by Get/SetLanguage }
- language : MouseLanguages;
-
- { MF36 : Set by driver }
- DriverVersion : word;
- IRQ : integer;
- TypeRequired : MouseTypes;
-
-
- procedure init; { Don't call! }
-
- { Mouse driver function calls: }
-
- procedure reset; { MF0 }
- procedure show; { MF1 }
- procedure hide; { MF2 }
- procedure UpdateStatusInfo; { MF3 }
- procedure GotoXY; { MF4 }
- procedure UpdatePressInfo; { MF5 }
- procedure UpdateReleaseInfo; { MF6 }
- procedure trap { MF7, MF8 }
- (x1,y1,x2,y2 : integer);
- procedure GraphicsCursor { MF9 }
- (gc : GraphicsCursorType);
- procedure SoftWareTextCursor { MF10 }
- (scrMask, curMask : word);
- procedure UpdateMotionInfo; { MF11 }
- procedure SetInterrupt; { MF12 }
- procedure LightPenOn; { MF13 }
- procedure LightPenOff; { MF14 }
- procedure speed { MF15 }
- (horz, vert : word);
- procedure OffTrap { MF16 }
- (x1, y1, x2, y2 : integer);
- procedure DoubleSpeedThreshold { MF19 }
- (mickeys : word);
- procedure SwapInterrupts; { MF20 }
- procedure AutoEventUpdate; { N/A }
- procedure save; { MF21, MF22 }
- procedure restore; { MF23 }
- procedure SetAltInterrupt; { MF24 }
- procedure GetAltInterrupt; { MF25 }
- procedure ClrAltInterrupts; { N/A }
- procedure SetSensitivity; { MF26 }
- procedure GetSensitivity; { MF27 }
- procedure SetInterruptRate { MF28 }
- (rate : word);
- procedure SetCRTpage; { MF29 }
- procedure GetCRTpage; { MF30 }
- procedure off; { MF31 }
- procedure on; { MF32 }
- procedure SoftReset; { MF33 }
- procedure SetLanguage; { MF34 }
- procedure GetLanguage; { MF35 }
- procedure driver; { MF36 }
-
- { Added features: }
-
- function VirtualX (XPhysical : integer) : integer;
- function PhysicalX (XVirtual : integer) : integer;
- function VirtualY (YPhysical : integer) : integer;
- function PhysicalY (YVirtual : integer) : integer;
-
- procedure report; { Text mode only! }
-
- end;
-
- var
-
- mouse : MM;
-
- { Do not call! Use to cookbook your own if needed. }
- procedure AutoEventHandler(PseudoFlags,CS,IP,
- ConditionMask,ButtonState,x,y,
- HorzMickeys,VertMickeys,
- DS,ES,BP: word); interrupt;