Last change
on this file was 12, checked in by chronos, 2 weeks ago |
- Added: More CPU instructions.
- Added: Mouse device.
|
File size:
1.1 KB
|
Line | |
---|
1 | unit Mouse;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Device, Int;
|
---|
7 |
|
---|
8 | type
|
---|
9 | TGetPositionEvent = function : TPoint of object;
|
---|
10 |
|
---|
11 | { TMouse }
|
---|
12 |
|
---|
13 | TMouse = class(TDevice)
|
---|
14 | private
|
---|
15 | FOnGetPosition: TGetPositionEvent;
|
---|
16 | function ReadX: TInt;
|
---|
17 | function ReadY: TInt;
|
---|
18 | function ReadButtonsState: TInt;
|
---|
19 | public
|
---|
20 | function GetHandlers: THandlers; override;
|
---|
21 | property OnGetPosition: TGetPositionEvent read FOnGetPosition write FOnGetPosition;
|
---|
22 | end;
|
---|
23 |
|
---|
24 | implementation
|
---|
25 |
|
---|
26 | { TMouse }
|
---|
27 |
|
---|
28 | function TMouse.ReadX: TInt;
|
---|
29 | var
|
---|
30 | Pos: TPoint;
|
---|
31 | begin
|
---|
32 | if Assigned(FOnGetPosition) then begin
|
---|
33 | Pos := FOnGetPosition;
|
---|
34 | Result := Pos.X;
|
---|
35 | end else Result := 0;
|
---|
36 | end;
|
---|
37 |
|
---|
38 | function TMouse.ReadY: TInt;
|
---|
39 | var
|
---|
40 | Pos: TPoint;
|
---|
41 | begin
|
---|
42 | if Assigned(FOnGetPosition) then begin
|
---|
43 | Pos := FOnGetPosition;
|
---|
44 | Result := Pos.Y;
|
---|
45 | end else Result := 0;
|
---|
46 | end;
|
---|
47 |
|
---|
48 | function TMouse.ReadButtonsState: TInt;
|
---|
49 | begin
|
---|
50 |
|
---|
51 | end;
|
---|
52 |
|
---|
53 | function TMouse.GetHandlers: THandlers;
|
---|
54 | begin
|
---|
55 | Result := THandlers.Create;
|
---|
56 | Result.ReadHandlers.Add(ReadX);
|
---|
57 | Result.ReadHandlers.Add(ReadY);
|
---|
58 | Result.ReadHandlers.Add(ReadButtonsState);
|
---|
59 | end;
|
---|
60 |
|
---|
61 | end.
|
---|
62 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.