ReactOS  0.4.15-dev-1636-gf634010
hardware.c File Reference
#include "inport.h"
#include <debug.h>
Include dependency graph for hardware.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define READ_MOUSE(DeviceExtension, Port)   READ_PORT_UCHAR((DeviceExtension)->IoBase + (Port))
 
#define WRITE_MOUSE(DeviceExtension, Port, Data)   WRITE_PORT_UCHAR((DeviceExtension)->IoBase + (Port), (Data))
 
#define NEC_BM_DATA   0x00
 
#define NEC_BM_CONTROL   0x04
 
#define NEC_INT_ENABLE   0x00
 
#define NEC_INT_DISABLE   0x10
 
#define NEC_READ_X_LOW   0x00
 
#define NEC_READ_X_HIGH   0x20
 
#define NEC_READ_Y_LOW   0x40
 
#define NEC_READ_Y_HIGH   0x60
 
#define NEC_INPUT_CAPTURE   0x00
 
#define NEC_INPUT_HOLD   0x80
 
#define NEC_BM_CONFIG   0x06
 
#define NEC_PPI_INT_ENABLE   0x08
 
#define NEC_PPI_INT_DISABLE   0x09
 
#define NEC_PPI_HC_NO_CLEAR   0x0E
 
#define NEC_PPI_HC_CLEAR   0x0F
 
#define NEC_PPI_DEFAULT_MODE   0x93
 
#define NEC_BM_INT_RATE   0x4002
 
#define NEC_RATE_120_HZ   0x00
 
#define NEC_RATE_60_HZ   0x01
 
#define NEC_RATE_30_HZ   0x02
 
#define NEC_RATE_15_HZ   0x03
 
#define NEC_BM_HIRESO_BASE   (PUCHAR)0x61
 
#define NEC_BUTTON_RIGHT   0x20
 
#define NEC_BUTTON_LEFT   0x80
 
#define MS_INPORT_CONTROL   0x00
 
#define INPORT_REG_BTNS   0x00
 
#define INPORT_REG_X   0x01
 
#define INPORT_REG_Y   0x02
 
#define INPORT_REG_MODE   0x07
 
#define INPORT_RESET   0x80
 
#define MS_INPORT_DATA   0x01
 
#define INPORT_MODE_IRQ   0x01
 
#define INPORT_MODE_BASE   0x10
 
#define INPORT_MODE_HOLD   0x20
 
#define MS_INPORT_SIGNATURE   0x02
 
#define MS_BUTTON_MIDDLE   0x01
 
#define MS_BUTTON_LEFT   0x02
 
#define MS_BUTTON_RIGHT   0x04
 
#define LOG_BM_DATA   0x00
 
#define LOG_BM_SIGNATURE   0x01
 
#define LOG_SIGNATURE_BYTE   0xA5
 
#define LOG_BM_CONTROL   0x02
 
#define LOG_ENABLE_IRQ   0x00
 
#define LOG_DISABLE_IRQ   0x10
 
#define LOG_READ_X_LOW   0x80
 
#define LOG_READ_X_HIGH   0xA0
 
#define LOG_READ_Y_LOW   0xC0
 
#define LOG_READ_Y_HIGH   0xE0
 
#define LOG_BM_CONFIG   0x03
 
#define LOG_DEFAULT_MODE   0x90
 
#define LOG_CONFIG_BYTE   0x91
 
#define LOG_BUTTON_RIGHT   0x20
 
#define LOG_BUTTON_MIDDLE   0x40
 
#define LOG_BUTTON_LEFT   0x80
 

Functions

VOID NTAPI InPortDpcForIsr (_In_ PKDPC Dpc, _In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_opt_ PVOID Context)
 
BOOLEAN NTAPI InPortIsr (_In_ PKINTERRUPT Interrupt, _In_ PVOID Context)
 
VOID NTAPI InPortInitializeMouse (_In_ PINPORT_DEVICE_EXTENSION DeviceExtension)
 
BOOLEAN NTAPI InPortStartMouse (_In_ PVOID SynchronizeContext)
 
BOOLEAN NTAPI InPortStopMouse (_In_ PVOID SynchronizeContext)
 

Macro Definition Documentation

◆ INPORT_MODE_BASE

#define INPORT_MODE_BASE   0x10

Definition at line 76 of file hardware.c.

◆ INPORT_MODE_HOLD

#define INPORT_MODE_HOLD   0x20

Definition at line 77 of file hardware.c.

◆ INPORT_MODE_IRQ

#define INPORT_MODE_IRQ   0x01

Definition at line 75 of file hardware.c.

◆ INPORT_REG_BTNS

#define INPORT_REG_BTNS   0x00

Definition at line 68 of file hardware.c.

◆ INPORT_REG_MODE

#define INPORT_REG_MODE   0x07

Definition at line 71 of file hardware.c.

◆ INPORT_REG_X

#define INPORT_REG_X   0x01

Definition at line 69 of file hardware.c.

◆ INPORT_REG_Y

#define INPORT_REG_Y   0x02

Definition at line 70 of file hardware.c.

◆ INPORT_RESET

#define INPORT_RESET   0x80

Definition at line 72 of file hardware.c.

◆ LOG_BM_CONFIG

#define LOG_BM_CONFIG   0x03

Definition at line 102 of file hardware.c.

◆ LOG_BM_CONTROL

#define LOG_BM_CONTROL   0x02

Definition at line 93 of file hardware.c.

◆ LOG_BM_DATA

#define LOG_BM_DATA   0x00

Definition at line 88 of file hardware.c.

◆ LOG_BM_SIGNATURE

#define LOG_BM_SIGNATURE   0x01

Definition at line 90 of file hardware.c.

◆ LOG_BUTTON_LEFT

#define LOG_BUTTON_LEFT   0x80

Definition at line 108 of file hardware.c.

◆ LOG_BUTTON_MIDDLE

#define LOG_BUTTON_MIDDLE   0x40

Definition at line 107 of file hardware.c.

◆ LOG_BUTTON_RIGHT

#define LOG_BUTTON_RIGHT   0x20

Definition at line 106 of file hardware.c.

◆ LOG_CONFIG_BYTE

#define LOG_CONFIG_BYTE   0x91

Definition at line 104 of file hardware.c.

◆ LOG_DEFAULT_MODE

#define LOG_DEFAULT_MODE   0x90

Definition at line 103 of file hardware.c.

◆ LOG_DISABLE_IRQ

#define LOG_DISABLE_IRQ   0x10

Definition at line 95 of file hardware.c.

◆ LOG_ENABLE_IRQ

#define LOG_ENABLE_IRQ   0x00

Definition at line 94 of file hardware.c.

◆ LOG_READ_X_HIGH

#define LOG_READ_X_HIGH   0xA0

Definition at line 98 of file hardware.c.

◆ LOG_READ_X_LOW

#define LOG_READ_X_LOW   0x80

Definition at line 97 of file hardware.c.

◆ LOG_READ_Y_HIGH

#define LOG_READ_Y_HIGH   0xE0

Definition at line 100 of file hardware.c.

◆ LOG_READ_Y_LOW

#define LOG_READ_Y_LOW   0xC0

Definition at line 99 of file hardware.c.

◆ LOG_SIGNATURE_BYTE

#define LOG_SIGNATURE_BYTE   0xA5

Definition at line 91 of file hardware.c.

◆ MS_BUTTON_LEFT

#define MS_BUTTON_LEFT   0x02

Definition at line 82 of file hardware.c.

◆ MS_BUTTON_MIDDLE

#define MS_BUTTON_MIDDLE   0x01

Definition at line 81 of file hardware.c.

◆ MS_BUTTON_RIGHT

#define MS_BUTTON_RIGHT   0x04

Definition at line 83 of file hardware.c.

◆ MS_INPORT_CONTROL

#define MS_INPORT_CONTROL   0x00

Definition at line 67 of file hardware.c.

◆ MS_INPORT_DATA

#define MS_INPORT_DATA   0x01

Definition at line 74 of file hardware.c.

◆ MS_INPORT_SIGNATURE

#define MS_INPORT_SIGNATURE   0x02

Definition at line 79 of file hardware.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file hardware.c.

◆ NEC_BM_CONFIG

#define NEC_BM_CONFIG   0x06

Definition at line 46 of file hardware.c.

◆ NEC_BM_CONTROL

#define NEC_BM_CONTROL   0x04

Definition at line 34 of file hardware.c.

◆ NEC_BM_DATA

#define NEC_BM_DATA   0x00

Definition at line 32 of file hardware.c.

◆ NEC_BM_HIRESO_BASE

#define NEC_BM_HIRESO_BASE   (PUCHAR)0x61

Definition at line 59 of file hardware.c.

◆ NEC_BM_INT_RATE

#define NEC_BM_INT_RATE   0x4002

Definition at line 53 of file hardware.c.

◆ NEC_BUTTON_LEFT

#define NEC_BUTTON_LEFT   0x80

Definition at line 62 of file hardware.c.

◆ NEC_BUTTON_RIGHT

#define NEC_BUTTON_RIGHT   0x20

Definition at line 61 of file hardware.c.

◆ NEC_INPUT_CAPTURE

#define NEC_INPUT_CAPTURE   0x00

Definition at line 43 of file hardware.c.

◆ NEC_INPUT_HOLD

#define NEC_INPUT_HOLD   0x80

Definition at line 44 of file hardware.c.

◆ NEC_INT_DISABLE

#define NEC_INT_DISABLE   0x10

Definition at line 36 of file hardware.c.

◆ NEC_INT_ENABLE

#define NEC_INT_ENABLE   0x00

Definition at line 35 of file hardware.c.

◆ NEC_PPI_DEFAULT_MODE

#define NEC_PPI_DEFAULT_MODE   0x93

Definition at line 51 of file hardware.c.

◆ NEC_PPI_HC_CLEAR

#define NEC_PPI_HC_CLEAR   0x0F

Definition at line 50 of file hardware.c.

◆ NEC_PPI_HC_NO_CLEAR

#define NEC_PPI_HC_NO_CLEAR   0x0E

Definition at line 49 of file hardware.c.

◆ NEC_PPI_INT_DISABLE

#define NEC_PPI_INT_DISABLE   0x09

Definition at line 48 of file hardware.c.

◆ NEC_PPI_INT_ENABLE

#define NEC_PPI_INT_ENABLE   0x08

Definition at line 47 of file hardware.c.

◆ NEC_RATE_120_HZ

#define NEC_RATE_120_HZ   0x00

Definition at line 54 of file hardware.c.

◆ NEC_RATE_15_HZ

#define NEC_RATE_15_HZ   0x03

Definition at line 57 of file hardware.c.

◆ NEC_RATE_30_HZ

#define NEC_RATE_30_HZ   0x02

Definition at line 56 of file hardware.c.

◆ NEC_RATE_60_HZ

#define NEC_RATE_60_HZ   0x01

Definition at line 55 of file hardware.c.

◆ NEC_READ_X_HIGH

#define NEC_READ_X_HIGH   0x20

Definition at line 39 of file hardware.c.

◆ NEC_READ_X_LOW

#define NEC_READ_X_LOW   0x00

Definition at line 38 of file hardware.c.

◆ NEC_READ_Y_HIGH

#define NEC_READ_Y_HIGH   0x60

Definition at line 41 of file hardware.c.

◆ NEC_READ_Y_LOW

#define NEC_READ_Y_LOW   0x40

Definition at line 40 of file hardware.c.

◆ READ_MOUSE

#define READ_MOUSE (   DeviceExtension,
  Port 
)    READ_PORT_UCHAR((DeviceExtension)->IoBase + (Port))

Definition at line 23 of file hardware.c.

◆ WRITE_MOUSE

#define WRITE_MOUSE (   DeviceExtension,
  Port,
  Data 
)    WRITE_PORT_UCHAR((DeviceExtension)->IoBase + (Port), (Data))

Definition at line 26 of file hardware.c.

Function Documentation

◆ InPortDpcForIsr()

VOID NTAPI InPortDpcForIsr ( _In_ PKDPC  Dpc,
_In_ PDEVICE_OBJECT  DeviceObject,
_Inout_ PIRP  Irp,
_In_opt_ PVOID  Context 
)

Definition at line 114 of file hardware.c.

119 {
120  PINPORT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
121  KIRQL OldIrql;
122  ULONG DummyInputDataConsumed;
123  INPORT_RAW_DATA RawData;
124 
128 
129  /* Copy raw data */
131  RawData = DeviceExtension->RawData;
133 
134  /* Fill out fields */
135  DeviceExtension->MouseInputData.LastX = RawData.DeltaX;
136  DeviceExtension->MouseInputData.LastY = RawData.DeltaY;
137  DeviceExtension->MouseInputData.ButtonFlags = 0;
138  if (RawData.ButtonDiff != 0)
139  {
140  switch (DeviceExtension->MouseType)
141  {
142  case NecBusMouse:
143  {
144  if (RawData.ButtonDiff & NEC_BUTTON_LEFT)
145  {
146  if (RawData.Buttons & NEC_BUTTON_LEFT)
147  DeviceExtension->MouseInputData.ButtonFlags |= MOUSE_LEFT_BUTTON_UP;
148  else
150  }
151  if (RawData.ButtonDiff & NEC_BUTTON_RIGHT)
152  {
153  if (RawData.Buttons & NEC_BUTTON_RIGHT)
155  else
157  }
158 
159  break;
160  }
161 
162  case MsInPortMouse:
163  {
164  /* Button flags have to be inverted */
165  if (RawData.ButtonDiff & MS_BUTTON_LEFT)
166  {
167  if (RawData.Buttons & MS_BUTTON_LEFT)
169  else
170  DeviceExtension->MouseInputData.ButtonFlags |= MOUSE_LEFT_BUTTON_UP;
171  }
172  if (RawData.ButtonDiff & MS_BUTTON_RIGHT)
173  {
174  if (RawData.Buttons & MS_BUTTON_RIGHT)
176  else
178  }
179  if (RawData.ButtonDiff & MS_BUTTON_MIDDLE)
180  {
181  if (RawData.Buttons & MS_BUTTON_MIDDLE)
183  else
185  }
186 
187  break;
188  }
189 
190  case LogitechBusMouse:
191  {
192  if (RawData.ButtonDiff & LOG_BUTTON_LEFT)
193  {
194  if (RawData.Buttons & LOG_BUTTON_LEFT)
195  DeviceExtension->MouseInputData.ButtonFlags |= MOUSE_LEFT_BUTTON_UP;
196  else
198  }
199  if (RawData.ButtonDiff & LOG_BUTTON_RIGHT)
200  {
201  if (RawData.Buttons & LOG_BUTTON_RIGHT)
203  else
205  }
206  if (RawData.ButtonDiff & LOG_BUTTON_MIDDLE)
207  {
208  if (RawData.Buttons & LOG_BUTTON_MIDDLE)
210  else
212  }
213 
214  break;
215  }
216  }
217  }
218 
219  /* Send mouse packet */
220  (*(PSERVICE_CALLBACK_ROUTINE)DeviceExtension->ClassService)(
221  DeviceExtension->ClassDeviceObject,
222  &DeviceExtension->MouseInputData,
223  &DeviceExtension->MouseInputData + 1,
224  &DummyInputDataConsumed);
225 }
MOUSE_INPUT_DATA MouseInputData
Definition: inport.h:68
_Must_inspect_result_ _In_ PWDF_DPC_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFDPC * Dpc
Definition: wdfdpc.h:107
#define MOUSE_MIDDLE_BUTTON_DOWN
Definition: ntddmou.h:50
#define MOUSE_LEFT_BUTTON_DOWN
Definition: ntddmou.h:46
PDEVICE_OBJECT ClassDeviceObject
Definition: inport.h:64
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define MS_BUTTON_LEFT
Definition: hardware.c:82
#define MS_BUTTON_RIGHT
Definition: hardware.c:83
UCHAR Buttons
Definition: inport.h:36
INPORT_MOUSE_TYPE MouseType
Definition: inport.h:49
#define MS_BUTTON_MIDDLE
Definition: hardware.c:81
#define NEC_BUTTON_LEFT
Definition: hardware.c:62
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
ULONG ButtonDiff
Definition: inport.h:37
INPORT_RAW_DATA RawData
Definition: inport.h:60
_In_ PIRP Irp
Definition: csq.h:116
#define LOG_BUTTON_LEFT
Definition: hardware.c:108
VOID NTAPI KeReleaseInterruptSpinLock(IN PKINTERRUPT Interrupt, IN KIRQL OldIrql)
Definition: spinlock.c:165
PKINTERRUPT InterruptObject
Definition: inport.h:52
#define MOUSE_LEFT_BUTTON_UP
Definition: ntddmou.h:47
#define MOUSE_MIDDLE_BUTTON_UP
Definition: ntddmou.h:51
#define MOUSE_RIGHT_BUTTON_DOWN
Definition: ntddmou.h:48
KIRQL NTAPI KeAcquireInterruptSpinLock(IN PKINTERRUPT Interrupt)
Definition: spinlock.c:148
VOID(STDAPICALLTYPE * PSERVICE_CALLBACK_ROUTINE)(IN PVOID NormalContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN OUT PVOID SystemArgument3)
Definition: kbdmou.h:86
USHORT ButtonFlags
Definition: ntddmou.h:82
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
#define LOG_BUTTON_MIDDLE
Definition: hardware.c:107
#define NEC_BUTTON_RIGHT
Definition: hardware.c:61
#define LOG_BUTTON_RIGHT
Definition: hardware.c:106
unsigned int ULONG
Definition: retypes.h:1
#define MOUSE_RIGHT_BUTTON_UP
Definition: ntddmou.h:49

◆ InPortInitializeMouse()

VOID NTAPI InPortInitializeMouse ( _In_ PINPORT_DEVICE_EXTENSION  DeviceExtension)

Definition at line 343 of file hardware.c.

345 {
346  PAGED_CODE();
347 
348  /* Initialize mouse and disable interrupts */
349  switch (DeviceExtension->MouseType)
350  {
351  case NecBusMouse:
353 
354  /* Setup interrupt rate (unavailable on hireso machines) */
355  if (DeviceExtension->IoBase != NEC_BM_HIRESO_BASE)
356  WRITE_MOUSE(DeviceExtension, NEC_BM_INT_RATE, NEC_RATE_60_HZ);
357 
358  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_INT_DISABLE);
359  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_NO_CLEAR);
360  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_CLEAR);
361  break;
362 
363  case MsInPortMouse:
364  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_RESET);
365  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
366  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA, INPORT_MODE_BASE);
367  break;
368 
369  case LogitechBusMouse:
370  WRITE_MOUSE(DeviceExtension, LOG_BM_CONFIG, LOG_DEFAULT_MODE);
371  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_DISABLE_IRQ);
372  break;
373  }
374 }
#define NEC_RATE_60_HZ
Definition: hardware.c:55
#define LOG_BM_CONTROL
Definition: hardware.c:93
#define INPORT_MODE_BASE
Definition: hardware.c:76
#define NEC_PPI_HC_CLEAR
Definition: hardware.c:50
#define INPORT_REG_MODE
Definition: hardware.c:71
#define NEC_BM_INT_RATE
Definition: hardware.c:53
#define NEC_BM_HIRESO_BASE
Definition: hardware.c:59
#define NEC_PPI_INT_DISABLE
Definition: hardware.c:48
#define MS_INPORT_DATA
Definition: hardware.c:74
#define LOG_BM_CONFIG
Definition: hardware.c:102
#define NEC_PPI_DEFAULT_MODE
Definition: hardware.c:51
#define LOG_DEFAULT_MODE
Definition: hardware.c:103
#define INPORT_RESET
Definition: hardware.c:72
#define MS_INPORT_CONTROL
Definition: hardware.c:67
#define WRITE_MOUSE(DeviceExtension, Port, Data)
Definition: hardware.c:26
#define NEC_BM_CONFIG
Definition: hardware.c:46
#define LOG_DISABLE_IRQ
Definition: hardware.c:95
#define NEC_PPI_HC_NO_CLEAR
Definition: hardware.c:49
#define PAGED_CODE()

Referenced by InPortStartDevice().

◆ InPortIsr()

BOOLEAN NTAPI InPortIsr ( _In_ PKINTERRUPT  Interrupt,
_In_ PVOID  Context 
)

Definition at line 229 of file hardware.c.

232 {
233  UCHAR Buttons;
234  ULONG ButtonDiff;
235  CHAR DeltaX, DeltaY;
236  PINPORT_DEVICE_EXTENSION DeviceExtension = Context;
237 
239 
240  switch (DeviceExtension->MouseType)
241  {
242  case NecBusMouse:
243  {
244  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
246 
247  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
249  DeltaX = READ_MOUSE(DeviceExtension, NEC_BM_DATA) & 0x0F;
250 
251  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
253  DeltaX |= READ_MOUSE(DeviceExtension, NEC_BM_DATA) << 4;
254 
255  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
257  DeltaY = READ_MOUSE(DeviceExtension, NEC_BM_DATA) & 0x0F;
258 
259  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
261  Buttons = READ_MOUSE(DeviceExtension, NEC_BM_DATA);
262  DeltaY |= Buttons << 4;
264 
265  WRITE_MOUSE(DeviceExtension, NEC_BM_CONTROL,
267 
268  break;
269  }
270 
271  case MsInPortMouse:
272  {
273  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
274  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA,
276 
277  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_X);
278  DeltaX = READ_MOUSE(DeviceExtension, MS_INPORT_DATA);
279 
280  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_Y);
281  DeltaY = READ_MOUSE(DeviceExtension, MS_INPORT_DATA);
282 
283  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_BTNS);
284  Buttons = READ_MOUSE(DeviceExtension, MS_INPORT_DATA);
286 
287  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
288  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA,
290 
291  break;
292  }
293 
294  case LogitechBusMouse:
295  {
296  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_READ_X_LOW);
297  DeltaX = READ_MOUSE(DeviceExtension, LOG_BM_DATA) & 0x0F;
298 
299  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_READ_X_HIGH);
300  DeltaX |= READ_MOUSE(DeviceExtension, LOG_BM_DATA) << 4;
301 
302  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_READ_Y_LOW);
303  DeltaY = READ_MOUSE(DeviceExtension, LOG_BM_DATA) & 0x0F;
304 
305  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_READ_Y_HIGH);
306  Buttons = READ_MOUSE(DeviceExtension, LOG_BM_DATA);
307  DeltaY |= Buttons << 4;
309 
310  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_ENABLE_IRQ);
311 
312  break;
313  }
314  }
315 
316  ButtonDiff = DeviceExtension->MouseButtonState ^ Buttons;
317  DeviceExtension->MouseButtonState = Buttons;
318 
319  /*
320  * Bus mouse devices don't have a status register to check
321  * whether this interrupt is indeed for us.
322  */
323  if ((DeltaX == 0) && (DeltaY == 0) && (ButtonDiff == 0))
324  {
325  /* We just pretend that the interrupt is not ours */
326  return FALSE;
327  }
328  else
329  {
330  DeviceExtension->RawData.DeltaX = DeltaX;
331  DeviceExtension->RawData.DeltaY = DeltaY;
332  DeviceExtension->RawData.Buttons = Buttons;
333  DeviceExtension->RawData.ButtonDiff = ButtonDiff;
334 
335  IoRequestDpc(DeviceExtension->Self, NULL, NULL);
336 
337  return TRUE;
338  }
339 }
#define INPORT_MODE_HOLD
Definition: hardware.c:77
#define INPORT_REG_Y
Definition: hardware.c:70
#define LOG_READ_X_HIGH
Definition: hardware.c:98
#define NEC_INPUT_CAPTURE
Definition: hardware.c:43
#define LOG_BM_CONTROL
Definition: hardware.c:93
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define INPORT_MODE_BASE
Definition: hardware.c:76
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
char CHAR
Definition: xmlstorage.h:175
#define INPORT_REG_X
Definition: hardware.c:69
#define MS_BUTTON_LEFT
Definition: hardware.c:82
#define NEC_READ_X_LOW
Definition: hardware.c:38
#define MS_BUTTON_RIGHT
Definition: hardware.c:83
UCHAR Buttons
Definition: inport.h:36
PDEVICE_OBJECT Self
Definition: inport.h:42
INPORT_MOUSE_TYPE MouseType
Definition: inport.h:49
#define INPORT_REG_MODE
Definition: hardware.c:71
#define MS_BUTTON_MIDDLE
Definition: hardware.c:81
#define NEC_BUTTON_LEFT
Definition: hardware.c:62
#define NEC_INT_ENABLE
Definition: hardware.c:35
#define INPORT_MODE_IRQ
Definition: hardware.c:75
ULONG ButtonDiff
Definition: inport.h:37
INPORT_RAW_DATA RawData
Definition: inport.h:60
#define FALSE
Definition: types.h:117
#define LOG_BUTTON_LEFT
Definition: hardware.c:108
#define NEC_READ_Y_LOW
Definition: hardware.c:40
#define READ_MOUSE(DeviceExtension, Port)
Definition: hardware.c:23
#define MS_INPORT_DATA
Definition: hardware.c:74
static const TBBUTTON Buttons[]
Definition: mplay32.c:41
FORCEINLINE VOID IoRequestDpc(_Inout_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Irp, _In_opt_ __drv_aliasesMem PVOID Context)
Definition: iofuncs.h:2746
#define LOG_READ_Y_HIGH
Definition: hardware.c:100
#define NEC_INT_DISABLE
Definition: hardware.c:36
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NEC_INPUT_HOLD
Definition: hardware.c:44
#define LOG_READ_Y_LOW
Definition: hardware.c:99
#define MS_INPORT_CONTROL
Definition: hardware.c:67
#define NEC_BM_CONTROL
Definition: hardware.c:34
#define NEC_BM_DATA
Definition: hardware.c:32
#define LOG_BUTTON_MIDDLE
Definition: hardware.c:107
#define WRITE_MOUSE(DeviceExtension, Port, Data)
Definition: hardware.c:26
#define INPORT_REG_BTNS
Definition: hardware.c:68
#define NEC_BUTTON_RIGHT
Definition: hardware.c:61
#define NEC_READ_X_HIGH
Definition: hardware.c:39
#define NULL
Definition: types.h:112
#define LOG_BUTTON_RIGHT
Definition: hardware.c:106
struct tagContext Context
Definition: acpixf.h:1034
unsigned int ULONG
Definition: retypes.h:1
#define LOG_BM_DATA
Definition: hardware.c:88
#define LOG_READ_X_LOW
Definition: hardware.c:97
#define NEC_READ_Y_HIGH
Definition: hardware.c:41
#define LOG_ENABLE_IRQ
Definition: hardware.c:94

◆ InPortStartMouse()

BOOLEAN NTAPI InPortStartMouse ( _In_ PVOID  SynchronizeContext)

Definition at line 378 of file hardware.c.

380 {
382 
383  /* Enable interrupts */
384  switch (DeviceExtension->MouseType)
385  {
386  case NecBusMouse:
387  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_INT_ENABLE);
388  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_NO_CLEAR);
389  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_CLEAR);
390  break;
391 
392  case MsInPortMouse:
393  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
394  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA,
396  break;
397 
398  case LogitechBusMouse:
399  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_ENABLE_IRQ);
400  break;
401  }
402 
403  return TRUE;
404 }
#define LOG_BM_CONTROL
Definition: hardware.c:93
#define NEC_PPI_INT_ENABLE
Definition: hardware.c:47
#define TRUE
Definition: types.h:120
#define INPORT_MODE_BASE
Definition: hardware.c:76
#define NEC_PPI_HC_CLEAR
Definition: hardware.c:50
INPORT_MOUSE_TYPE MouseType
Definition: inport.h:49
#define INPORT_REG_MODE
Definition: hardware.c:71
#define INPORT_MODE_IRQ
Definition: hardware.c:75
#define MS_INPORT_DATA
Definition: hardware.c:74
#define MS_INPORT_CONTROL
Definition: hardware.c:67
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
#define WRITE_MOUSE(DeviceExtension, Port, Data)
Definition: hardware.c:26
#define NEC_BM_CONFIG
Definition: hardware.c:46
#define NEC_PPI_HC_NO_CLEAR
Definition: hardware.c:49
#define LOG_ENABLE_IRQ
Definition: hardware.c:94

◆ InPortStopMouse()

BOOLEAN NTAPI InPortStopMouse ( _In_ PVOID  SynchronizeContext)

Definition at line 408 of file hardware.c.

410 {
412 
413  /* Disable interrupts */
414  switch (DeviceExtension->MouseType)
415  {
416  case NecBusMouse:
417  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_INT_DISABLE);
418  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_NO_CLEAR);
419  WRITE_MOUSE(DeviceExtension, NEC_BM_CONFIG, NEC_PPI_HC_CLEAR);
420  break;
421 
422  case MsInPortMouse:
423  WRITE_MOUSE(DeviceExtension, MS_INPORT_CONTROL, INPORT_REG_MODE);
424  WRITE_MOUSE(DeviceExtension, MS_INPORT_DATA, INPORT_MODE_BASE);
425  break;
426 
427  case LogitechBusMouse:
428  WRITE_MOUSE(DeviceExtension, LOG_BM_CONTROL, LOG_DISABLE_IRQ);
429  break;
430  }
431 
432  return TRUE;
433 }
#define LOG_BM_CONTROL
Definition: hardware.c:93
#define TRUE
Definition: types.h:120
#define INPORT_MODE_BASE
Definition: hardware.c:76
#define NEC_PPI_HC_CLEAR
Definition: hardware.c:50
INPORT_MOUSE_TYPE MouseType
Definition: inport.h:49
#define INPORT_REG_MODE
Definition: hardware.c:71
#define NEC_PPI_INT_DISABLE
Definition: hardware.c:48
#define MS_INPORT_DATA
Definition: hardware.c:74
#define MS_INPORT_CONTROL
Definition: hardware.c:67
_In_ PKSYNCHRONIZE_ROUTINE _In_opt_ __drv_aliasesMem PVOID SynchronizeContext
Definition: kefuncs.h:536
#define WRITE_MOUSE(DeviceExtension, Port, Data)
Definition: hardware.c:26
#define NEC_BM_CONFIG
Definition: hardware.c:46
#define LOG_DISABLE_IRQ
Definition: hardware.c:95
#define NEC_PPI_HC_NO_CLEAR
Definition: hardware.c:49