3 #include "../../drivers/input/include/mouse.h"
6 BOOLEAN SafetySwitch
= FALSE
, SafetySwitch2
= FALSE
, MouseEnabled
= FALSE
;
8 UINT mouse_width
= 0, mouse_height
= 0;
10 INT
MouseSafetyOnDrawStart(PSURFOBJ SurfObj
, PSURFGDI SurfGDI
, LONG HazardX1
, LONG HazardY1
, LONG HazardX2
, LONG HazardY2
)
15 if(SurfObj
== NULL
) return 0;
17 if((SurfObj
->iType
!= STYPE_DEVICE
) || (MouseEnabled
== FALSE
)) return 0;
19 if(HazardX1
> HazardX2
) { tmp
= HazardX2
; HazardX2
= HazardX1
; HazardX1
= tmp
; }
20 if(HazardY1
> HazardY2
) { tmp
= HazardY2
; HazardY2
= HazardY1
; HazardY1
= tmp
; }
22 if( (mouse_x
+ mouse_width
>= HazardX1
) && (mouse_x
<= HazardX2
) &&
23 (mouse_y
+ mouse_height
>= HazardY1
) && (mouse_y
<= HazardY2
) )
25 SurfGDI
->MovePointer(SurfObj
, -1, -1, &MouseRect
);
29 // Mouse is not allowed to move if GDI is busy drawing
35 INT
MouseSafetyOnDrawEnd(PSURFOBJ SurfObj
, PSURFGDI SurfGDI
)
39 if(SurfObj
== NULL
) return 0;
41 if((SurfObj
->iType
!= STYPE_DEVICE
) || (MouseEnabled
== FALSE
)) return 0;
43 if(SafetySwitch
== TRUE
)
45 SurfGDI
->MovePointer(SurfObj
, mouse_x
, mouse_y
, &MouseRect
);
49 SafetySwitch2
= FALSE
;
54 VOID
MouseGDICallBack(PMOUSE_INPUT_DATA Data
, ULONG InputCount
)
57 LONG mouse_cx
= 0, mouse_cy
= 0;
58 HDC hDC
= W32kGetScreenDC();
64 PDEVICE_OBJECT ClassDeviceObject
= NULL
;
65 PFILE_OBJECT FileObject
= NULL
;
67 UNICODE_STRING ClassName
;
68 IO_STATUS_BLOCK ioStatus
;
77 dc
= DC_HandleToPtr(hDC
);
78 SurfObj
= (PSURFOBJ
)AccessUserObject(dc
->Surface
);
79 SurfGDI
= (PSURFGDI
)AccessInternalObject(dc
->Surface
);
81 // Compile the total mouse movement change
82 for (i
=0; i
<InputCount
; i
++)
84 mouse_cx
+= Data
[i
].LastX
;
85 mouse_cy
+= Data
[i
].LastY
;
88 if((mouse_cx
!= 0) || (mouse_cy
!= 0))
93 if(mouse_x
< 0) mouse_x
= 0;
94 if(mouse_y
< 0) mouse_y
= 0;
95 if(mouse_x
> 620) mouse_x
= 620;
96 if(mouse_y
> 460) mouse_y
= 460;
98 if((SafetySwitch
== FALSE
) && (SafetySwitch2
== FALSE
)) ;
99 SurfGDI
->MovePointer(SurfObj
, mouse_x
, mouse_y
, &MouseRect
);
103 VOID
EnableMouse(HDC hDisplayDC
)
105 PDC dc
= DC_HandleToPtr(hDisplayDC
);
106 PSURFOBJ SurfObj
= (PSURFOBJ
)AccessUserObject(dc
->Surface
);
107 PSURFGDI SurfGDI
= (PSURFGDI
)AccessInternalObject(dc
->Surface
);
118 // Draw a test mouse cursor
122 // Draw transparent colored rectangle
123 Brush
.iSolidColor
= 5;
124 for (i
= 0; i
< 17; i
++)
125 EngLineTo(SurfObj
, NULL
, &Brush
, 0, i
, 17, i
, NULL
, 0);
127 // Draw white interior
128 Brush
.iSolidColor
= 15;
129 for (i
= 1; i
< 16; i
++)
130 EngLineTo(SurfObj
, NULL
, &Brush
, 0, i
-1, 16-i
, i
-1, NULL
, 0);
132 // Draw black outline
133 Brush
.iSolidColor
= 0;
134 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 0, 15, 0, NULL
, 0);
135 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 16, 15, 0, NULL
, 0);
136 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 15, 0, 0, NULL
, 0);
138 // Create the bitmap for the mouse cursor data
141 hMouseSurf
= EngCreateBitmap(MouseSize
, 16, BMF_4BPP
, 0, NULL
);
142 MouseSurf
= (PSURFOBJ
)AccessUserObject(hMouseSurf
);
144 // Capture the cursor we drew in the mouse cursor buffer
149 MouseRect
.bottom
= 16;
150 MouseRect
.right
= 16;
151 EngBitBlt(MouseSurf
, SurfObj
, NULL
, NULL
, NULL
, &MouseRect
, &ZeroPoint
, NULL
, NULL
, NULL
, 0);
152 SurfGDI
->SetPointerShape(SurfObj
, MouseSurf
, NULL
, NULL
, 0, 0, 50, 50, &MouseRect
, 0);