3 #include "..\..\services\input\include\mouse.h"
8 VOID
MouseGDICallBack(PMOUSE_INPUT_DATA Data
, ULONG InputCount
)
11 LONG mouse_cx
= 0, mouse_cy
= 0;
12 HDC hDC
= RetrieveDisplayHDC();
13 PDC dc
= DC_HandleToPtr(hDC
);
14 PSURFOBJ SurfObj
= AccessUserObject(dc
->Surface
);
15 PSURFGDI SurfGDI
= AccessInternalObject(dc
->Surface
);
18 PDEVICE_OBJECT ClassDeviceObject
= NULL
;
19 PFILE_OBJECT FileObject
= NULL
;
21 UNICODE_STRING ClassName
;
22 IO_STATUS_BLOCK ioStatus
;
26 // Compile the total mouse movement change
27 for (i
=0; i
<InputCount
; i
++)
29 mouse_cx
+= Data
[i
].LastX
;
30 mouse_cy
+= Data
[i
].LastY
;
33 if((mouse_cx
!= 0) || (mouse_cy
!= 0))
38 if(mouse_x
< 0) mouse_x
= 0;
39 if(mouse_y
< 0) mouse_y
= 0;
40 if(mouse_x
> 620) mouse_x
= 620;
41 if(mouse_y
> 460) mouse_y
= 460;
43 SurfGDI
->MovePointer(SurfObj
, mouse_x
, mouse_y
, &MouseRect
);
47 NTSTATUS
ConnectMouseClassDriver()
49 PDEVICE_OBJECT ClassDeviceObject
= NULL
;
50 PFILE_OBJECT FileObject
= NULL
;
52 UNICODE_STRING ClassName
;
53 IO_STATUS_BLOCK ioStatus
;
56 GDI_INFORMATION GDIInformation
;
58 RtlInitUnicodeString(&ClassName
, L
"\\Device\\MouseClass");
60 status
= IoGetDeviceObjectPointer(&ClassName
, FILE_READ_ATTRIBUTES
, &FileObject
, &ClassDeviceObject
);
62 if(status
!= STATUS_SUCCESS
)
64 DbgPrint("Win32k: Could not connect to mouse class driver\n");
68 // Connect our callback to the class driver
70 KeInitializeEvent(&event
, NotificationEvent
, FALSE
);
72 GDIInformation
.CallBack
= MouseGDICallBack
;
74 irp
= IoBuildDeviceIoControlRequest(IOCTL_INTERNAL_MOUSE_CONNECT
,
75 ClassDeviceObject
, &GDIInformation
, sizeof(CLASS_INFORMATION
), NULL
, 0, TRUE
, &event
, &ioStatus
);
77 status
= IoCallDriver(ClassDeviceObject
, irp
);
79 if (status
== STATUS_PENDING
) {
80 KeWaitForSingleObject(&event
, Suspended
, KernelMode
, FALSE
, NULL
);
82 ioStatus
.Status
= status
;
85 return ioStatus
.Status
;
90 HDC hDC
= RetrieveDisplayHDC(RetrieveDisplayHDC());
91 PDC dc
= DC_HandleToPtr(hDC
);
92 PSURFOBJ SurfObj
= AccessUserObject(dc
->Surface
);
93 PSURFGDI SurfGDI
= AccessInternalObject(dc
->Surface
);
103 // Draw a test mouse cursor
104 Brush
.iSolidColor
= 1;
105 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 0, 15, 0, NULL
, 0);
106 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 0, 0, 15, NULL
, 0);
107 EngLineTo(SurfObj
, NULL
, &Brush
, 0, 15, 15, 0, NULL
, 0);
108 Brush
.iSolidColor
= 15;
109 EngLineTo(SurfObj
, NULL
, &Brush
, 1, 1, 13, 1, NULL
, 0);
110 EngLineTo(SurfObj
, NULL
, &Brush
, 1, 1, 1, 13, NULL
, 0);
111 EngLineTo(SurfObj
, NULL
, &Brush
, 1, 13, 13, 1, NULL
, 0);
113 // Create the bitmap for the mouse cursor data
116 hMouseSurf
= EngCreateBitmap(MouseSize
, 16, BMF_4BPP
, 0, NULL
);
117 MouseSurf
= AccessUserObject(hMouseSurf
);
119 // Capture the cursor we drew in the mouse cursor buffer
124 MouseRect
.bottom
= 16;
125 MouseRect
.right
= 16;
126 EngBitBlt(MouseSurf
, SurfObj
, NULL
, NULL
, NULL
, &MouseRect
, &ZeroPoint
, NULL
, NULL
, NULL
, 0);
127 SurfGDI
->SetPointerShape(SurfObj
, MouseSurf
, NULL
, NULL
, 0, 0, 50, 50, &MouseRect
, 0);
129 // Connect the mouse class driver to the GDI
132 ConnectMouseClassDriver();