source: branches/bigint/Devices/Mouse.pas

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 
1unit Mouse;
2
3interface
4
5uses
6 Classes, SysUtils, Device, Int;
7
8type
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
24implementation
25
26{ TMouse }
27
28function TMouse.ReadX: TInt;
29var
30 Pos: TPoint;
31begin
32 if Assigned(FOnGetPosition) then begin
33 Pos := FOnGetPosition;
34 Result := Pos.X;
35 end else Result := 0;
36end;
37
38function TMouse.ReadY: TInt;
39var
40 Pos: TPoint;
41begin
42 if Assigned(FOnGetPosition) then begin
43 Pos := FOnGetPosition;
44 Result := Pos.Y;
45 end else Result := 0;
46end;
47
48function TMouse.ReadButtonsState: TInt;
49begin
50
51end;
52
53function TMouse.GetHandlers: THandlers;
54begin
55 Result := THandlers.Create;
56 Result.ReadHandlers.Add(ReadX);
57 Result.ReadHandlers.Add(ReadY);
58 Result.ReadHandlers.Add(ReadButtonsState);
59end;
60
61end.
62
Note: See TracBrowser for help on using the repository browser.