ReactOS  0.4.14-dev-384-g5b37caa
sermouse.h File Reference
#include <ntddk.h>
#include <ntddser.h>
#include <kbdmou.h>
Include dependency graph for sermouse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SERMOUSE_DRIVER_EXTENSION
 
struct  _SERMOUSE_DEVICE_EXTENSION
 

Macros

#define SERMOUSE_TAG   'uoMS'
 
#define PACKET_BUFFER_SIZE   4
 
#define LEFT_BUTTON_MASK   0x20
 
#define LEFT_BUTTON_SHIFT   5
 
#define RIGHT_BUTTON_MASK   0x10
 
#define RIGHT_BUTTON_SHIFT   3
 
#define MIDDLE_BUTTON_MASK   0x20
 
#define MIDDLE_BUTTON_SHIFT   3
 
#define MOUSE_BUTTON_LEFT   0x01
 
#define MOUSE_BUTTON_RIGHT   0x02
 
#define MOUSE_BUTTON_MIDDLE   0x04
 

Typedefs

typedef struct _SERMOUSE_DRIVER_EXTENSION SERMOUSE_DRIVER_EXTENSION
 
typedef struct _SERMOUSE_DRIVER_EXTENSIONPSERMOUSE_DRIVER_EXTENSION
 
typedef struct _SERMOUSE_DEVICE_EXTENSION SERMOUSE_DEVICE_EXTENSION
 
typedef struct _SERMOUSE_DEVICE_EXTENSIONPSERMOUSE_DEVICE_EXTENSION
 

Enumerations

enum  SERMOUSE_DEVICE_STATE {
  dsStopped, dsStarted, dsPaused, dsRemoved,
  dsSurpriseRemoved
}
 
enum  SERMOUSE_MOUSE_TYPE { mtNone, mtMicrosoft, mtLogitech, mtWheelZ }
 

Functions

SERMOUSE_MOUSE_TYPE SermouseDetectLegacyDevice (IN PDEVICE_OBJECT LowerDevice)
 
NTSTATUS ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI SermouseDeviceWorker (PVOID Context)
 

Variables

DRIVER_DISPATCH SermouseCreate
 
DRIVER_DISPATCH SermouseClose
 
DRIVER_DISPATCH SermouseCleanup
 
DRIVER_ADD_DEVICE SermouseAddDevice
 
DRIVER_DISPATCH SermousePnp
 
DRIVER_DISPATCH SermouseInternalDeviceControl
 

Macro Definition Documentation

◆ LEFT_BUTTON_MASK

#define LEFT_BUTTON_MASK   0x20

Definition at line 31 of file sermouse.h.

◆ LEFT_BUTTON_SHIFT

#define LEFT_BUTTON_SHIFT   5

Definition at line 33 of file sermouse.h.

◆ MIDDLE_BUTTON_MASK

#define MIDDLE_BUTTON_MASK   0x20

Definition at line 39 of file sermouse.h.

◆ MIDDLE_BUTTON_SHIFT

#define MIDDLE_BUTTON_SHIFT   3

Definition at line 41 of file sermouse.h.

◆ MOUSE_BUTTON_LEFT

#define MOUSE_BUTTON_LEFT   0x01

Definition at line 44 of file sermouse.h.

◆ MOUSE_BUTTON_MIDDLE

#define MOUSE_BUTTON_MIDDLE   0x04

Definition at line 48 of file sermouse.h.

◆ MOUSE_BUTTON_RIGHT

#define MOUSE_BUTTON_RIGHT   0x02

Definition at line 46 of file sermouse.h.

◆ PACKET_BUFFER_SIZE

#define PACKET_BUFFER_SIZE   4

Definition at line 28 of file sermouse.h.

◆ RIGHT_BUTTON_MASK

#define RIGHT_BUTTON_MASK   0x10

Definition at line 35 of file sermouse.h.

◆ RIGHT_BUTTON_SHIFT

#define RIGHT_BUTTON_SHIFT   3

Definition at line 37 of file sermouse.h.

◆ SERMOUSE_TAG

#define SERMOUSE_TAG   'uoMS'

Definition at line 8 of file sermouse.h.

Typedef Documentation

◆ PSERMOUSE_DEVICE_EXTENSION

◆ PSERMOUSE_DRIVER_EXTENSION

◆ SERMOUSE_DEVICE_EXTENSION

◆ SERMOUSE_DRIVER_EXTENSION

Enumeration Type Documentation

◆ SERMOUSE_DEVICE_STATE

Enumerator
dsStopped 
dsStarted 
dsPaused 
dsRemoved 
dsSurpriseRemoved 

Definition at line 10 of file sermouse.h.

◆ SERMOUSE_MOUSE_TYPE

Enumerator
mtNone 
mtMicrosoft 
mtLogitech 
mtWheelZ 

Definition at line 19 of file sermouse.h.

20 {
21  mtNone, /* No Mouse */
22  mtMicrosoft, /* Microsoft Mouse with 2 buttons */
23  mtLogitech, /* Logitech Mouse with 3 buttons */
24  mtWheelZ /* Microsoft Wheel Mouse (aka Z Mouse) */
SERMOUSE_MOUSE_TYPE
Definition: sermouse.h:19

Function Documentation

◆ ForwardIrpAndForget()

NTSTATUS NTAPI ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 59 of file misc.c.

62 {
64 
65  ASSERT(LowerDevice);
66 
68  return IoCallDriver(LowerDevice, Irp);
69 }
_In_ PIRP Irp
Definition: csq.h:116
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

◆ ForwardIrpAndWait()

NTSTATUS ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 32 of file fdo.c.

35 {
36  KEVENT Event;
39  ASSERT(LowerDevice);
40 
43 
45 
46  Status = IoCallDriver(LowerDevice, Irp);
47  if (Status == STATUS_PENDING)
48  {
50  if (NT_SUCCESS(Status))
51  Status = Irp->IoStatus.Status;
52  }
53 
54  return Status;
55 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
struct _FDO_DEVICE_EXTENSION * PFDO_DEVICE_EXTENSION
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static IO_COMPLETION_ROUTINE ForwardIrpAndWaitCompletion
Definition: fdo.c:17
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

◆ SermouseDetectLegacyDevice()

SERMOUSE_MOUSE_TYPE SermouseDetectLegacyDevice ( IN PDEVICE_OBJECT  LowerDevice)

Definition at line 117 of file detect.c.

119 {
120  HANDLE Handle;
121  ULONG Fcr, Mcr;
122  ULONG BaudRate;
123  ULONG Command;
124  SERIAL_TIMEOUTS Timeouts;
126  ULONG_PTR i, Count = 0;
127  UCHAR Buffer[16];
128  SERMOUSE_MOUSE_TYPE MouseType = mtNone;
130 
131  TRACE_(SERMOUSE, "SermouseDetectLegacyDevice(LowerDevice %p)\n", LowerDevice);
132 
133  RtlZeroMemory(Buffer, sizeof(Buffer));
134 
135  /* Open port */
137  LowerDevice,
139  NULL,
140  0,
141  NULL,
142  KernelMode,
143  &Handle);
144  if (!NT_SUCCESS(Status)) return mtNone;
145 
146  /* Reset UART */
147  TRACE_(SERMOUSE, "Reset UART\n");
148  Mcr = 0; /* MCR: DTR/RTS/OUT2 off */
150  &Mcr, sizeof(Mcr), NULL, NULL);
151  if (!NT_SUCCESS(Status)) goto ByeBye;
152 
153  /* Set communications parameters */
154  TRACE_(SERMOUSE, "Set communications parameters\n");
155  /* DLAB off */
156  Fcr = 0;
158  &Fcr, sizeof(Fcr), NULL, NULL);
159  if (!NT_SUCCESS(Status)) goto ByeBye;
160  /* Set serial port speed */
161  BaudRate = 1200;
163  &BaudRate, sizeof(BaudRate), NULL, NULL);
164  if (!NT_SUCCESS(Status)) goto ByeBye;
165  /* Set LCR */
166  LCR.WordLength = 7;
167  LCR.Parity = NO_PARITY;
168  LCR.StopBits = STOP_BITS_2;
170  &LCR, sizeof(LCR), NULL, NULL);
171  if (!NT_SUCCESS(Status)) goto ByeBye;
172 
173  /* Flush receive buffer */
174  TRACE_(SERMOUSE, "Flush receive buffer\n");
177  &Command, sizeof(Command), NULL, NULL);
178  if (!NT_SUCCESS(Status)) goto ByeBye;
179  /* Wait 100 ms */
180  Wait(100);
181 
182  /* Enable DTR/RTS */
183  TRACE_(SERMOUSE, "Enable DTR/RTS\n");
185  NULL, 0, NULL, NULL);
186  if (!NT_SUCCESS(Status)) goto ByeBye;
188  NULL, 0, NULL, NULL);
189  if (!NT_SUCCESS(Status)) goto ByeBye;
190 
191  /* Set timeout to 500 microseconds */
192  TRACE_(SERMOUSE, "Set timeout to 500 microseconds\n");
193  Timeouts.ReadIntervalTimeout = 100;
194  Timeouts.ReadTotalTimeoutMultiplier = 0;
195  Timeouts.ReadTotalTimeoutConstant = 500;
198  &Timeouts, sizeof(Timeouts), NULL, NULL);
199  if (!NT_SUCCESS(Status)) goto ByeBye;
200 
201  /* Fill the read buffer */
202  TRACE_(SERMOUSE, "Fill the read buffer\n");
203  Status = ReadBytes(LowerDevice, Buffer, sizeof(Buffer)/sizeof(Buffer[0]), &Count);
204  if (!NT_SUCCESS(Status)) goto ByeBye;
205 
206  for (i = 0; i < Count; i++)
207  {
208  if (Buffer[i] == 'B')
209  {
210  /* Sign for Microsoft Ballpoint */
211  ERR_(SERMOUSE, "Microsoft Ballpoint device detected. THIS DEVICE IS NOT YET SUPPORTED");
212  MouseType = mtNone;
213  goto ByeBye;
214  }
215  else if (Buffer[i] == 'M')
216  {
217  /* Sign for Microsoft Mouse protocol followed by button specifier */
218  if (i == sizeof(Buffer) - 1)
219  {
220  /* Overflow Error */
221  goto ByeBye;
222  }
223  switch (Buffer[i + 1])
224  {
225  case '3':
226  INFO_(SERMOUSE, "Microsoft Mouse with 3-buttons detected\n");
227  MouseType = mtLogitech;
228  break;
229  case 'Z':
230  INFO_(SERMOUSE, "Microsoft Wheel Mouse detected\n");
231  MouseType = mtWheelZ;
232  break;
233  default:
234  INFO_(SERMOUSE, "Microsoft Mouse with 2-buttons detected\n");
235  MouseType = mtMicrosoft;
236  break;
237  }
238  goto ByeBye;
239  }
240  }
241 
242 ByeBye:
243  /* Close port */
244  if (Handle)
245  ZwClose(Handle);
246  return MouseType;
247 }
#define SERIAL_PURGE_RXCLEAR
Definition: serial.c:96
#define INFO_(ch,...)
Definition: debug.h:159
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
ULONG WriteTotalTimeoutConstant
Definition: ntddser.h:307
SERMOUSE_MOUSE_TYPE
Definition: sermouse.h:19
#define IOCTL_SERIAL_SET_FIFO_CONTROL
Definition: ntddser.h:92
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
ULONG ReadTotalTimeoutConstant
Definition: ntddser.h:305
#define ERR_(ch,...)
Definition: debug.h:156
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
Definition: shell.h:41
NTSTATUS NTAPI ObOpenObjectByPointer(IN PVOID Object, IN ULONG HandleAttributes, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PHANDLE Handle)
Definition: obhandle.c:2739
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IOCTL_SERIAL_SET_DTR
Definition: ntddser.h:90
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG ReadTotalTimeoutMultiplier
Definition: ntddser.h:304
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
#define TRACE_(x)
Definition: compat.h:66
_In_ HANDLE Handle
Definition: extypes.h:390
ULONG WriteTotalTimeoutMultiplier
Definition: ntddser.h:306
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct Command Command
ULONG ReadIntervalTimeout
Definition: ntddser.h:303
#define LCR
Definition: serial_port.h:65
#define STOP_BITS_2
Definition: serial.c:87
unsigned char UCHAR
Definition: xmlstorage.h:181
static NTSTATUS DeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN SIZE_T InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PSIZE_T OutputBufferSize)
Definition: detect.c:19
Status
Definition: gdiplustypes.h:24
#define NO_PARITY
Definition: serial.c:89
#define IOCTL_SERIAL_SET_MODEM_CONTROL
Definition: ntddser.h:98
static NTSTATUS Wait(IN ULONG milliseconds)
Definition: detect.c:104
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define IOCTL_SERIAL_SET_RTS
Definition: ntddser.h:102
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104

Referenced by SermouseStartDevice().

◆ SermouseDeviceWorker()

VOID NTAPI SermouseDeviceWorker ( PVOID  Context)

Definition at line 64 of file readmouse.c.

66 {
67  PSERMOUSE_DEVICE_EXTENSION DeviceExtension;
68  PDEVICE_OBJECT LowerDevice;
70  PIRP Irp;
71  IO_STATUS_BLOCK ioStatus;
72  KEVENT event;
73  PUCHAR PacketBuffer;
74  UCHAR ReceivedByte;
75  ULONG Queue;
77  ULONG ButtonsDifference;
78  KIRQL OldIrql;
79  ULONG i;
80  ULONG Fcr;
81  ULONG BaudRate;
82  SERIAL_TIMEOUTS Timeouts;
86 
87  TRACE_(SERMOUSE, "SermouseDeviceWorker() called\n");
88 
89  DeviceExtension = (PSERMOUSE_DEVICE_EXTENSION)((PDEVICE_OBJECT)Context)->DeviceExtension;
90  LowerDevice = DeviceExtension->LowerDevice;
91  Zero.QuadPart = 0;
92  PacketBuffer = DeviceExtension->PacketBuffer;
93 
94  ASSERT(LowerDevice);
95 
96  /* Initialize device extension */
97  DeviceExtension->ActiveQueue = 0;
98  DeviceExtension->PacketBufferPosition = 0;
99  DeviceExtension->PreviousButtons = 0;
100 
101  /* Initialize serial port */
102  Fcr = 0;
104  &Fcr, sizeof(Fcr), NULL, NULL);
106  /* Set serial port speed */
107  BaudRate = DeviceExtension->AttributesInformation.SampleRate * 8;
109  &BaudRate, sizeof(BaudRate), NULL, NULL);
111  /* Set LCR */
112  LCR.WordLength = 7;
113  LCR.Parity = NO_PARITY;
114  LCR.StopBits = STOP_BIT_1;
116  &LCR, sizeof(LCR), NULL, NULL);
118 
119  /* Set timeouts */
121  Timeouts.ReadIntervalTimeout = 100;
124  &Timeouts, sizeof(Timeouts), NULL, NULL);
126 
127  /* main read loop */
129  while (TRUE)
130  {
132  &DeviceExtension->StopWorkerThreadEvent,
133  Executive,
134  KernelMode,
135  TRUE,
136  &Zero);
137  if (Status != STATUS_TIMEOUT)
138  {
139  /* we need to stop the worker thread */
140  KeClearEvent(&DeviceExtension->StopWorkerThreadEvent);
141  break;
142  }
143 
146  IRP_MJ_READ,
147  LowerDevice,
149  &Zero,
150  &event,
151  &ioStatus);
152  if (!Irp)
153  {
154  /* No memory actually, try later */
155  INFO_(SERMOUSE, "No memory actually, trying again\n");
157  continue;
158  }
159 
160  Status = IoCallDriver(LowerDevice, Irp);
161  if (Status == STATUS_PENDING)
162  {
164  Status = ioStatus.Status;
165  }
166 
167  if (!NT_SUCCESS(Status))
168  continue;
169 
170  /* Read all available data and process */
171  for (i = 0; i < ioStatus.Information; i++)
172  {
173  ReceivedByte = Buffer[i];
174  INFO_(SERMOUSE, "ReceivedByte 0x%02x\n", ReceivedByte);
175 
176  /* Synchronize */
177  if ((ReceivedByte & 0x40) == 0x40)
178  DeviceExtension->PacketBufferPosition = 0;
179 
180  PacketBuffer[DeviceExtension->PacketBufferPosition] = ReceivedByte & 0x7f;
181  DeviceExtension->PacketBufferPosition++;
182 
183  /* Process packet if complete */
184  if (DeviceExtension->PacketBufferPosition >= 3)
185  {
186  Queue = DeviceExtension->ActiveQueue % 2;
187 
188  /* Prevent buffer overflow */
189  if (DeviceExtension->InputDataCount[Queue] == 1)
190  continue;
191 
192  Input = &DeviceExtension->MouseInputData[Queue];
193 
194  if (DeviceExtension->PacketBufferPosition == 3)
195  {
196  /* Retrieve change in x and y from packet */
197  Input->LastX = (signed char)(PacketBuffer[1] | ((PacketBuffer[0] & 0x03) << 6));
198  Input->LastY = (signed char)(PacketBuffer[2] | ((PacketBuffer[0] & 0x0c) << 4));
199 
200  /* Determine the current state of the buttons */
201  Input->RawButtons = (DeviceExtension->PreviousButtons & MOUSE_BUTTON_MIDDLE) |
202  ((UCHAR)(PacketBuffer[0] & LEFT_BUTTON_MASK) >> LEFT_BUTTON_SHIFT) |
203  ((UCHAR)(PacketBuffer[0] & RIGHT_BUTTON_MASK) >> RIGHT_BUTTON_SHIFT);
204  }
205  else if (DeviceExtension->PacketBufferPosition == 4)
206  {
207  DeviceExtension->PacketBufferPosition = 0;
208  /* If middle button state changed than report event */
209  if (((UCHAR)(PacketBuffer[3] & MIDDLE_BUTTON_MASK) >> MIDDLE_BUTTON_SHIFT) ^
210  (DeviceExtension->PreviousButtons & MOUSE_BUTTON_MIDDLE))
211  {
212  Input->RawButtons ^= MOUSE_BUTTON_MIDDLE;
213  Input->LastX = 0;
214  Input->LastY = 0;
215  }
216  else
217  {
218  continue;
219  }
220  }
221 
222  /* Determine ButtonFlags */
223  Input->ButtonFlags = 0;
224  ButtonsDifference = DeviceExtension->PreviousButtons ^ Input->RawButtons;
225 
226  if (ButtonsDifference != 0)
227  {
228  if (ButtonsDifference & MOUSE_BUTTON_LEFT
229  && DeviceExtension->AttributesInformation.NumberOfButtons >= 1)
230  {
231  if (Input->RawButtons & MOUSE_BUTTON_LEFT)
232  Input->ButtonFlags |= MOUSE_LEFT_BUTTON_DOWN;
233  else
234  Input->ButtonFlags |= MOUSE_LEFT_BUTTON_UP;
235  }
236 
237  if (ButtonsDifference & MOUSE_BUTTON_RIGHT
238  && DeviceExtension->AttributesInformation.NumberOfButtons >= 2)
239  {
240  if (Input->RawButtons & MOUSE_BUTTON_RIGHT)
241  Input->ButtonFlags |= MOUSE_RIGHT_BUTTON_DOWN;
242  else
243  Input->ButtonFlags |= MOUSE_RIGHT_BUTTON_UP;
244  }
245 
246  if (ButtonsDifference & MOUSE_BUTTON_MIDDLE
247  && DeviceExtension->AttributesInformation.NumberOfButtons >= 3)
248  {
249  if (Input->RawButtons & MOUSE_BUTTON_MIDDLE)
250  Input->ButtonFlags |= MOUSE_MIDDLE_BUTTON_DOWN;
251  else
252  Input->ButtonFlags |= MOUSE_MIDDLE_BUTTON_UP;
253  }
254  }
255 
256  /* Send the Input data to the Mouse Class driver */
257  DeviceExtension->InputDataCount[Queue]++;
258 
260  InterlockedIncrement((PLONG)&DeviceExtension->ActiveQueue);
262  DeviceExtension->ConnectData.ClassDeviceObject,
263  &DeviceExtension->MouseInputData[Queue],
264  &DeviceExtension->MouseInputData[Queue] + 1,
265  &DeviceExtension->InputDataCount[Queue]);
267  DeviceExtension->InputDataCount[Queue] = 0;
268 
269  /* Copy RawButtons to Previous Buttons for Input */
270  DeviceExtension->PreviousButtons = Input->RawButtons;
271  }
272  }
273  }
274 
276 }
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define RIGHT_BUTTON_MASK
Definition: sermouse.h:35
#define MOUSE_MIDDLE_BUTTON_DOWN
Definition: ntddmou.h:50
#define MOUSE_LEFT_BUTTON_DOWN
Definition: ntddmou.h:46
#define STOP_BIT_1
Definition: ntddser.h:215
#define INFO_(ch,...)
Definition: debug.h:159
#define MIDDLE_BUTTON_SHIFT
Definition: sermouse.h:41
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IOCTL_SERIAL_SET_BAUD_RATE
Definition: ntddser.h:82
ULONG WriteTotalTimeoutConstant
Definition: ntddser.h:307
_In_ PIRP Irp
Definition: csq.h:116
#define IOCTL_SERIAL_SET_FIFO_CONTROL
Definition: ntddser.h:92
PDEVICE_OBJECT LowerDevice
Definition: sermouse.h:57
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG ReadTotalTimeoutConstant
Definition: ntddser.h:305
LONG NTSTATUS
Definition: precomp.h:26
Definition: arc.h:84
struct _SERMOUSE_DEVICE_EXTENSION * PSERMOUSE_DEVICE_EXTENSION
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define IOCTL_SERIAL_SET_LINE_CONTROL
Definition: ntddser.h:96
#define LEFT_BUTTON_SHIFT
Definition: sermouse.h:33
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
UCHAR KIRQL
Definition: env_spec_w32.h:591
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
USHORT SampleRate
Definition: ntddmou.h:111
ULONG ReadTotalTimeoutMultiplier
Definition: ntddser.h:304
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:29
Definition: bufpool.h:45
static NTSTATUS SermouseDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG CtlCode, IN PVOID InputBuffer OPTIONAL, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer OPTIONAL, IN OUT PULONG OutputBufferSize)
Definition: readmouse.c:16
#define TRACE_(x)
Definition: compat.h:66
ULONG WriteTotalTimeoutMultiplier
Definition: ntddser.h:306
#define RIGHT_BUTTON_SHIFT
Definition: sermouse.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ULONG ReadIntervalTimeout
Definition: ntddser.h:303
MOUSE_ATTRIBUTES AttributesInformation
Definition: sermouse.h:72
#define MOUSE_LEFT_BUTTON_UP
Definition: ntddmou.h:47
#define MOUSE_MIDDLE_BUTTON_UP
Definition: ntddmou.h:51
#define LCR
Definition: serial_port.h:65
#define MOUSE_RIGHT_BUTTON_DOWN
Definition: ntddmou.h:48
#define PACKET_BUFFER_SIZE
Definition: sermouse.h:28
PVOID ClassService
Definition: kbdmou.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
unsigned char UCHAR
Definition: xmlstorage.h:181
VOID(STDAPICALLTYPE * PSERVICE_CALLBACK_ROUTINE)(IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN OUT PVOID SystemArgument3)
Definition: kbdmou.h:86
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
struct _cl_event * event
Definition: glext.h:7739
UCHAR PacketBuffer[PACKET_BUFFER_SIZE]
Definition: sermouse.h:69
Status
Definition: gdiplustypes.h:24
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define NO_PARITY
Definition: serial.c:89
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
Definition: fatprocs.h:402
#define IRP_MJ_READ
Definition: rdpdr.c:46
MOUSE_INPUT_DATA MouseInputData[2]
Definition: sermouse.h:68
#define MIDDLE_BUTTON_MASK
Definition: sermouse.h:39
struct tagContext Context
Definition: acpixf.h:1030
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define MOUSE_RIGHT_BUTTON_UP
Definition: ntddmou.h:49
#define LEFT_BUTTON_MASK
Definition: sermouse.h:31
CONNECT_DATA ConnectData
Definition: sermouse.h:67
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5
USHORT NumberOfButtons
Definition: ntddmou.h:110
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
#define IOCTL_SERIAL_SET_TIMEOUTS
Definition: ntddser.h:104
PDEVICE_OBJECT ClassDeviceObject
Definition: kbdmou.h:81

Referenced by SermouseStartDevice().

Variable Documentation

◆ SermouseAddDevice

DRIVER_ADD_DEVICE SermouseAddDevice

Definition at line 91 of file sermouse.h.

Referenced by DriverEntry().

◆ SermouseCleanup

DRIVER_DISPATCH SermouseCleanup

Definition at line 81 of file sermouse.h.

Referenced by DriverEntry().

◆ SermouseClose

DRIVER_DISPATCH SermouseClose

Definition at line 79 of file sermouse.h.

Referenced by DriverEntry().

◆ SermouseCreate

DRIVER_DISPATCH SermouseCreate

Definition at line 77 of file sermouse.h.

Referenced by DriverEntry().

◆ SermouseInternalDeviceControl

DRIVER_DISPATCH SermouseInternalDeviceControl

Definition at line 97 of file sermouse.h.

Referenced by DriverEntry().

◆ SermousePnp

DRIVER_DISPATCH SermousePnp

Definition at line 93 of file sermouse.h.

Referenced by DriverEntry().