3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 UsbMouseSimulateTouchPad.c
21 #include "UsbMouseSimulateTouchPad.h"
23 #include <Library/DebugLib.h>
24 #include <IndustryStandard/Usb.h>
30 // Driver model protocol interface
34 USBMouseSimulateTouchPadDriverBindingEntryPoint (
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
41 USBMouseSimulateTouchPadDriverBindingSupported (
42 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
43 IN EFI_HANDLE Controller
,
44 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
49 USBMouseSimulateTouchPadDriverBindingStart (
50 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
51 IN EFI_HANDLE Controller
,
52 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
57 USBMouseSimulateTouchPadDriverBindingStop (
58 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
59 IN EFI_HANDLE Controller
,
60 IN UINTN NumberOfChildren
,
61 IN EFI_HANDLE
*ChildHandleBuffer
64 EFI_GUID gEfiUsbMouseSimulateTouchPadDriverGuid
= {
65 0xa579f729, 0xa71d, 0x4b45, { 0xbe, 0xd7, 0xd, 0xb0, 0xa8, 0x7c, 0x3e, 0x8d }
68 EFI_DRIVER_BINDING_PROTOCOL gUsbMouseSimulateTouchPadDriverBinding
= {
69 USBMouseSimulateTouchPadDriverBindingSupported
,
70 USBMouseSimulateTouchPadDriverBindingStart
,
71 USBMouseSimulateTouchPadDriverBindingStop
,
82 IsUsbMouseSimulateTouchPad (
83 IN EFI_USB_IO_PROTOCOL
*UsbIo
88 InitializeUsbMouseSimulateTouchPadDevice (
89 IN USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDev
95 UsbMouseSimulateTouchPadWaitForInput (
101 // Mouse interrupt handler
106 OnMouseSimulateTouchPadInterruptComplete (
114 // Mouse simulate TouchPad, Using AbsolutePointer Protocol
119 GetMouseSimulateTouchPadState (
120 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
121 OUT EFI_ABSOLUTE_POINTER_STATE
*MouseSimulateTouchPadState
127 UsbMouseSimulateTouchPadReset (
128 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
129 IN BOOLEAN ExtendedVerification
137 USBMouseSimulateTouchPadDriverBindingEntryPoint (
138 IN EFI_HANDLE ImageHandle
,
139 IN EFI_SYSTEM_TABLE
*SystemTable
144 Entry point for EFI drivers.
147 ImageHandle - EFI_HANDLE
148 SystemTable - EFI_SYSTEM_TABLE
155 return EfiLibInstallDriverBindingComponentName2 (
158 &gUsbMouseSimulateTouchPadDriverBinding
,
160 &gUsbMouseSimulateTouchPadComponentName
,
161 &gUsbMouseSimulateTouchPadComponentName2
167 Test to see if this driver supports ControllerHandle. Any ControllerHandle
168 that has UsbHcProtocol installed will be supported.
170 @param This Protocol instance pointer.
171 @param Controller Handle of device to test
172 @param RemainingDevicePath Not used
174 @retval EFI_SUCCESS This driver supports this device.
175 @retval EFI_UNSUPPORTED This driver does not support this device.
180 USBMouseSimulateTouchPadDriverBindingSupported (
181 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
182 IN EFI_HANDLE Controller
,
183 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
186 EFI_STATUS OpenStatus
;
187 EFI_USB_IO_PROTOCOL
*UsbIo
;
190 OpenStatus
= gBS
->OpenProtocol (
192 &gEfiUsbIoProtocolGuid
,
194 This
->DriverBindingHandle
,
196 EFI_OPEN_PROTOCOL_BY_DRIVER
198 if (EFI_ERROR (OpenStatus
) && (OpenStatus
!= EFI_ALREADY_STARTED
)) {
199 return EFI_UNSUPPORTED
;
202 if (OpenStatus
== EFI_ALREADY_STARTED
) {
203 return EFI_ALREADY_STARTED
;
207 // Use the USB I/O protocol interface to see the Controller is
208 // the Mouse controller that can be managed by this driver.
210 Status
= EFI_SUCCESS
;
211 if (!IsUsbMouseSimulateTouchPad (UsbIo
)) {
212 Status
= EFI_UNSUPPORTED
;
217 &gEfiUsbIoProtocolGuid
,
218 This
->DriverBindingHandle
,
227 Starting the Usb Bus Driver
229 @param This Protocol instance pointer.
230 @param Controller Handle of device to test
231 @param RemainingDevicePath Not used
233 @retval EFI_SUCCESS This driver supports this device.
234 @retval EFI_UNSUPPORTED This driver does not support this device.
235 @retval EFI_DEVICE_ERROR This driver cannot be started due to device Error
236 EFI_OUT_OF_RESOURCES- Can't allocate memory
238 @retval EFI_ALREADY_STARTED Thios driver has been started
243 USBMouseSimulateTouchPadDriverBindingStart (
244 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
245 IN EFI_HANDLE Controller
,
246 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
250 EFI_USB_IO_PROTOCOL
*UsbIo
;
251 EFI_USB_ENDPOINT_DESCRIPTOR
*EndpointDesc
;
252 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDevice
;
253 UINT8 EndpointNumber
;
256 UINT8 PollingInterval
;
259 UsbMouseSimulateTouchPadDevice
= NULL
;
260 Status
= EFI_SUCCESS
;
262 Status
= gBS
->OpenProtocol (
264 &gEfiUsbIoProtocolGuid
,
266 This
->DriverBindingHandle
,
268 EFI_OPEN_PROTOCOL_BY_DRIVER
270 if (EFI_ERROR (Status
)) {
274 UsbMouseSimulateTouchPadDevice
= AllocateZeroPool (sizeof (USB_MOUSE_SIMULATE_TOUCHPAD_DEV
));
275 if (UsbMouseSimulateTouchPadDevice
== NULL
) {
276 Status
= EFI_OUT_OF_RESOURCES
;
280 UsbMouseSimulateTouchPadDevice
->UsbIo
= UsbIo
;
282 UsbMouseSimulateTouchPadDevice
->Signature
= USB_MOUSE_SIMULATE_TOUCHPAD_DEV_SIGNATURE
;
284 UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
= AllocatePool (sizeof (EFI_USB_INTERFACE_DESCRIPTOR
));
285 if (UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
== NULL
) {
286 Status
= EFI_OUT_OF_RESOURCES
;
290 EndpointDesc
= AllocatePool (sizeof (EFI_USB_ENDPOINT_DESCRIPTOR
));
291 if (EndpointDesc
== NULL
) {
292 Status
= EFI_OUT_OF_RESOURCES
;
296 // Get the Device Path Protocol on Controller's handle
298 Status
= gBS
->OpenProtocol (
300 &gEfiDevicePathProtocolGuid
,
301 (VOID
**) &UsbMouseSimulateTouchPadDevice
->DevicePath
,
302 This
->DriverBindingHandle
,
304 EFI_OPEN_PROTOCOL_GET_PROTOCOL
307 if (EFI_ERROR (Status
)) {
311 // Get interface & endpoint descriptor
313 UsbIo
->UsbGetInterfaceDescriptor (
315 UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
318 EndpointNumber
= UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
->NumEndpoints
;
320 for (Index
= 0; Index
< EndpointNumber
; Index
++) {
321 UsbIo
->UsbGetEndpointDescriptor (
327 if ((EndpointDesc
->Attributes
& 0x03) == 0x03) {
330 // We only care interrupt endpoint here
332 UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
= EndpointDesc
;
336 if (UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
== NULL
) {
338 // No interrupt endpoint, then error
340 Status
= EFI_UNSUPPORTED
;
344 Status
= InitializeUsbMouseSimulateTouchPadDevice (UsbMouseSimulateTouchPadDevice
);
345 if (EFI_ERROR (Status
)) {
346 MouseSimulateTouchPadReportStatusCode (
347 UsbMouseSimulateTouchPadDevice
->DevicePath
,
348 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
349 PcdGet32 (PcdStatusCodeValueMouseInterfaceError
)
355 UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
.GetState
= GetMouseSimulateTouchPadState
;
356 UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
.Reset
= UsbMouseSimulateTouchPadReset
;
357 UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
.Mode
= &UsbMouseSimulateTouchPadDevice
->AbsolutePointerMode
;
359 Status
= gBS
->CreateEvent (
362 UsbMouseSimulateTouchPadWaitForInput
,
363 UsbMouseSimulateTouchPadDevice
,
364 &((UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
).WaitForInput
)
366 if (EFI_ERROR (Status
)) {
370 Status
= gBS
->InstallProtocolInterface (
372 &gEfiAbsolutePointerProtocolGuid
,
373 EFI_NATIVE_INTERFACE
,
374 &UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
377 if (EFI_ERROR (Status
)) {
378 Status
= EFI_DEVICE_ERROR
;
383 // After Enabling Async Interrupt Transfer on this mouse Device
384 // we will be able to get key data from it. Thus this is deemed as
385 // the enable action of the mouse
388 MouseSimulateTouchPadReportStatusCode (
389 UsbMouseSimulateTouchPadDevice
->DevicePath
,
391 PcdGet32 (PcdStatusCodeValueMouseEnable
)
395 // submit async interrupt transfer
397 EndpointAddr
= UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->EndpointAddress
;
398 PollingInterval
= UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->Interval
;
399 PacketSize
= (UINT8
) (UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->MaxPacketSize
);
401 Status
= UsbIo
->UsbAsyncInterruptTransfer (
407 OnMouseSimulateTouchPadInterruptComplete
,
408 UsbMouseSimulateTouchPadDevice
411 if (!EFI_ERROR (Status
)) {
413 UsbMouseSimulateTouchPadDevice
->ControllerNameTable
= NULL
;
416 gUsbMouseSimulateTouchPadComponentName
.SupportedLanguages
,
417 &UsbMouseSimulateTouchPadDevice
->ControllerNameTable
,
418 L
"Generic Usb Mouse Simulate TouchPad",
423 gUsbMouseSimulateTouchPadComponentName2
.SupportedLanguages
,
424 &UsbMouseSimulateTouchPadDevice
->ControllerNameTable
,
425 L
"Generic Usb Mouse Simulate TouchPad2",
433 // If submit error, uninstall that interface
435 Status
= EFI_DEVICE_ERROR
;
437 gBS
->UninstallProtocolInterface (
439 &gEfiAbsolutePointerProtocolGuid
,
440 &UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
444 DEBUG ((EFI_D_ERROR
, __FUNCTION__
" driver start fail\n"));
445 if (EFI_ERROR (Status
)) {
448 &gEfiUsbIoProtocolGuid
,
449 This
->DriverBindingHandle
,
453 if (UsbMouseSimulateTouchPadDevice
!= NULL
) {
454 if (UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
!= NULL
) {
455 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
);
458 if (UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
!= NULL
) {
459 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
);
462 if ((UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
).WaitForInput
!= NULL
) {
463 gBS
->CloseEvent ((UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
).WaitForInput
);
466 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
);
467 UsbMouseSimulateTouchPadDevice
= NULL
;
476 Stop this driver on ControllerHandle. Support stoping any child handles
477 created by this driver.
479 @param This Protocol instance pointer.
480 @param Controller Handle of device to stop driver on
481 @param NumberOfChildren Number of Children in the ChildHandleBuffer
482 @param ChildHandleBuffer List of handles for the children we need to stop.
485 @return EFI_DEVICE_ERROR
491 USBMouseSimulateTouchPadDriverBindingStop (
492 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
493 IN EFI_HANDLE Controller
,
494 IN UINTN NumberOfChildren
,
495 IN EFI_HANDLE
*ChildHandleBuffer
499 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDevice
;
500 EFI_ABSOLUTE_POINTER_PROTOCOL
*AbsolutePointerProtocol
;
501 EFI_USB_IO_PROTOCOL
*UsbIo
;
504 // Get our context back.
506 Status
= gBS
->OpenProtocol (
508 &gEfiAbsolutePointerProtocolGuid
,
509 (VOID
**) &AbsolutePointerProtocol
,
510 This
->DriverBindingHandle
,
512 EFI_OPEN_PROTOCOL_GET_PROTOCOL
515 if (EFI_ERROR (Status
)) {
516 return EFI_UNSUPPORTED
;
518 UsbMouseSimulateTouchPadDevice
= USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol
);
522 &gEfiAbsolutePointerProtocolGuid
,
523 This
->DriverBindingHandle
,
527 UsbIo
= UsbMouseSimulateTouchPadDevice
->UsbIo
;
530 // Uninstall the Asyn Interrupt Transfer from this device
531 // will disable the mouse data input from this device
533 MouseSimulateTouchPadReportStatusCode (
534 UsbMouseSimulateTouchPadDevice
->DevicePath
,
536 PcdGet32 (PcdStatusCodeValueMouseDisable
)
540 // Delete Mouse Async Interrupt Transfer
542 UsbIo
->UsbAsyncInterruptTransfer (
544 UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->EndpointAddress
,
546 UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->Interval
,
552 gBS
->CloseEvent (UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
.WaitForInput
);
554 if (UsbMouseSimulateTouchPadDevice
->DelayedRecoveryEvent
) {
555 gBS
->CloseEvent (UsbMouseSimulateTouchPadDevice
->DelayedRecoveryEvent
);
556 UsbMouseSimulateTouchPadDevice
->DelayedRecoveryEvent
= 0;
559 Status
= gBS
->UninstallProtocolInterface (
561 &gEfiAbsolutePointerProtocolGuid
,
562 &UsbMouseSimulateTouchPadDevice
->AbsolutePointerProtocol
564 if (EFI_ERROR (Status
)) {
570 &gEfiUsbIoProtocolGuid
,
571 This
->DriverBindingHandle
,
575 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
->InterfaceDescriptor
);
576 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
);
578 if (UsbMouseSimulateTouchPadDevice
->ControllerNameTable
) {
579 FreeUnicodeStringTable (UsbMouseSimulateTouchPadDevice
->ControllerNameTable
);
582 gBS
->FreePool (UsbMouseSimulateTouchPadDevice
);
590 Tell if a Usb Controller is a mouse
592 @param UsbIo Protocol instance pointer.
594 @retval TRUE It is a mouse
595 @retval FALSE It is not a mouse
599 IsUsbMouseSimulateTouchPad (
600 IN EFI_USB_IO_PROTOCOL
*UsbIo
604 EFI_USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
;
607 // Get the Default interface descriptor, now we only
608 // suppose it is interface 1
610 Status
= UsbIo
->UsbGetInterfaceDescriptor (
615 if (EFI_ERROR (Status
)) {
619 if ((InterfaceDescriptor
.InterfaceClass
== CLASS_HID
) &&
620 (InterfaceDescriptor
.InterfaceSubClass
== SUBCLASS_BOOT
) &&
621 (InterfaceDescriptor
.InterfaceProtocol
== PROTOCOL_MOUSE
)
632 Initialize the Usb Mouse Simulate TouchPad Device.
634 @param UsbMouseSimulateTouchPadDev Device instance to be initialized
636 @retval EFI_SUCCESS Success
637 @retval EFI_DEVICE_ERROR Init error. EFI_OUT_OF_RESOURCES- Can't allocate
643 InitializeUsbMouseSimulateTouchPadDevice (
644 IN USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDev
647 EFI_USB_IO_PROTOCOL
*UsbIo
;
650 EFI_USB_HID_DESCRIPTOR MouseHidDesc
;
653 UsbIo
= UsbMouseSimulateTouchPadDev
->UsbIo
;
656 // Get HID descriptor
658 Status
= UsbGetHidDescriptor (
660 UsbMouseSimulateTouchPadDev
->InterfaceDescriptor
->InterfaceNumber
,
664 if (EFI_ERROR (Status
)) {
669 // Get Report descriptor
671 if (MouseHidDesc
.HidClassDesc
[0].DescriptorType
!= 0x22) {
672 return EFI_UNSUPPORTED
;
675 ReportDesc
= AllocateZeroPool (MouseHidDesc
.HidClassDesc
[0].DescriptorLength
);
676 if (ReportDesc
== NULL
) {
677 return EFI_OUT_OF_RESOURCES
;
680 Status
= UsbGetReportDescriptor (
682 UsbMouseSimulateTouchPadDev
->InterfaceDescriptor
->InterfaceNumber
,
683 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
,
687 if (EFI_ERROR (Status
)) {
688 gBS
->FreePool (ReportDesc
);
693 // Parse report descriptor
695 Status
= ParseMouseReportDescriptor (
696 UsbMouseSimulateTouchPadDev
,
698 MouseHidDesc
.HidClassDesc
[0].DescriptorLength
701 if (EFI_ERROR (Status
)) {
702 gBS
->FreePool (ReportDesc
);
706 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMaxX
= 1024;
707 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMaxY
= 1024;
708 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMaxZ
= 0;
709 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMinX
= 0;
710 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMinY
= 0;
711 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.AbsoluteMinZ
= 0;
712 UsbMouseSimulateTouchPadDev
->AbsolutePointerMode
.Attributes
= 0x3;
715 // Here we just assume interface 0 is the mouse interface
717 UsbGetProtocolRequest (
723 if (Protocol
!= BOOT_PROTOCOL
) {
724 Status
= UsbSetProtocolRequest (
730 if (EFI_ERROR (Status
)) {
731 gBS
->FreePool (ReportDesc
);
732 return EFI_DEVICE_ERROR
;
737 // Set indefinite Idle rate for USB Mouse
746 gBS
->FreePool (ReportDesc
);
748 if (UsbMouseSimulateTouchPadDev
->DelayedRecoveryEvent
) {
749 gBS
->CloseEvent (UsbMouseSimulateTouchPadDev
->DelayedRecoveryEvent
);
750 UsbMouseSimulateTouchPadDev
->DelayedRecoveryEvent
= 0;
753 Status
= gBS
->CreateEvent (
754 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
756 USBMouseSimulateTouchPadRecoveryHandler
,
757 UsbMouseSimulateTouchPadDev
,
758 &UsbMouseSimulateTouchPadDev
->DelayedRecoveryEvent
766 It is called whenever there is data received from async interrupt
769 @param Data Data received.
770 @param DataLength Length of Data
771 @param Context Passed in context
772 @param Result Async Interrupt Transfer result
775 @return EFI_DEVICE_ERROR
781 OnMouseSimulateTouchPadInterruptComplete (
788 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDevice
;
789 EFI_USB_IO_PROTOCOL
*UsbIo
;
793 UsbMouseSimulateTouchPadDevice
= (USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*) Context
;
794 UsbIo
= UsbMouseSimulateTouchPadDevice
->UsbIo
;
796 if (Result
!= EFI_USB_NOERROR
) {
798 // Some errors happen during the process
800 MouseSimulateTouchPadReportStatusCode (
801 UsbMouseSimulateTouchPadDevice
->DevicePath
,
802 EFI_ERROR_CODE
| EFI_ERROR_MINOR
,
803 PcdGet32 (PcdStatusCodeValueMouseInputError
)
806 if ((Result
& EFI_USB_ERR_STALL
) == EFI_USB_ERR_STALL
) {
807 EndpointAddr
= UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->EndpointAddress
;
809 UsbClearEndpointHalt (
816 UsbIo
->UsbAsyncInterruptTransfer (
818 UsbMouseSimulateTouchPadDevice
->IntEndpointDescriptor
->EndpointAddress
,
827 UsbMouseSimulateTouchPadDevice
->DelayedRecoveryEvent
,
829 EFI_USB_INTERRUPT_DELAY
831 return EFI_DEVICE_ERROR
;
834 if (DataLength
== 0 || Data
== NULL
) {
841 UsbMouseSimulateTouchPadDevice
->AbsolutePointerStateChanged
= TRUE
;
842 UsbMouseSimulateTouchPadDevice
->AbsolutePointerState
.CurrentX
+= *((INT8
*) Data
+ 1);
843 UsbMouseSimulateTouchPadDevice
->AbsolutePointerState
.CurrentY
+= *((INT8
*) Data
+ 2);
844 if (DataLength
> 3) {
845 UsbMouseSimulateTouchPadDevice
->AbsolutePointerState
.CurrentZ
+= *((INT8
*) Data
+ 3);
847 UsbMouseSimulateTouchPadDevice
->AbsolutePointerState
.ActiveButtons
= *(UINT8
*)Data
& 0x3;
853 Get the mouse state, see ABSOLUTE POINTER PROTOCOL.
855 @param This Protocol instance pointer.
856 @param MouseState Current mouse state
859 @return EFI_DEVICE_ERROR
860 @return EFI_NOT_READY
866 GetMouseSimulateTouchPadState (
867 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
868 OUT EFI_ABSOLUTE_POINTER_STATE
*MouseSimulateTouchPadState
871 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*MouseSimulateTouchPadDev
;
873 if (MouseSimulateTouchPadState
== NULL
) {
874 return EFI_DEVICE_ERROR
;
877 MouseSimulateTouchPadDev
= USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (This
);
879 if (!MouseSimulateTouchPadDev
->AbsolutePointerStateChanged
) {
880 return EFI_NOT_READY
;
884 MouseSimulateTouchPadState
,
885 &MouseSimulateTouchPadDev
->AbsolutePointerState
,
886 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
890 // Clear previous move state
892 MouseSimulateTouchPadDev
->AbsolutePointerState
.CurrentX
= 0;
893 MouseSimulateTouchPadDev
->AbsolutePointerState
.CurrentY
= 0;
894 MouseSimulateTouchPadDev
->AbsolutePointerState
.CurrentZ
= 0;
895 MouseSimulateTouchPadDev
->AbsolutePointerState
.ActiveButtons
= 0;
897 MouseSimulateTouchPadDev
->AbsolutePointerStateChanged
= FALSE
;
904 Reset the mouse device, see ABSOLUTE POINTER PROTOCOL.
906 @param This Protocol instance pointer.
907 @param ExtendedVerification Ignored here/
915 UsbMouseSimulateTouchPadReset (
916 IN EFI_ABSOLUTE_POINTER_PROTOCOL
*This
,
917 IN BOOLEAN ExtendedVerification
920 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDevice
;
922 UsbMouseSimulateTouchPadDevice
= USB_MOUSE_SIMULATE_TOUCHPAD_DEV_FROM_MOUSE_PROTOCOL (This
);
924 MouseSimulateTouchPadReportStatusCode (
925 UsbMouseSimulateTouchPadDevice
->DevicePath
,
927 PcdGet32 (PcdStatusCodeValueMouseReset
)
931 &UsbMouseSimulateTouchPadDevice
->AbsolutePointerState
,
932 sizeof (EFI_ABSOLUTE_POINTER_STATE
)
934 UsbMouseSimulateTouchPadDevice
->AbsolutePointerStateChanged
= FALSE
;
940 Event notification function for ABSOLUTE_POINTER.WaitForInput event
941 Signal the event if there is input from mouse
943 @param Event Wait Event
944 @param Context Passed parameter to event handler
951 UsbMouseSimulateTouchPadWaitForInput (
956 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDev
;
958 UsbMouseSimulateTouchPadDev
= (USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*) Context
;
961 // Someone is waiting on the mouse event, if there's
962 // input from mouse, signal the event
964 if (UsbMouseSimulateTouchPadDev
->AbsolutePointerStateChanged
) {
965 gBS
->SignalEvent (Event
);
970 Timer handler for Delayed Recovery timer.
972 @param Event The Delayed Recovery event.
973 @param Context Points to the USB_KB_DEV instance.
979 USBMouseSimulateTouchPadRecoveryHandler (
984 USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*UsbMouseSimulateTouchPadDev
;
985 EFI_USB_IO_PROTOCOL
*UsbIo
;
987 UsbMouseSimulateTouchPadDev
= (USB_MOUSE_SIMULATE_TOUCHPAD_DEV
*) Context
;
989 UsbIo
= UsbMouseSimulateTouchPadDev
->UsbIo
;
991 UsbIo
->UsbAsyncInterruptTransfer (
993 UsbMouseSimulateTouchPadDev
->IntEndpointDescriptor
->EndpointAddress
,
995 UsbMouseSimulateTouchPadDev
->IntEndpointDescriptor
->Interval
,
996 UsbMouseSimulateTouchPadDev
->IntEndpointDescriptor
->MaxPacketSize
,
997 OnMouseSimulateTouchPadInterruptComplete
,
998 UsbMouseSimulateTouchPadDev
1004 Report Status Code in Usb Bot Driver
1006 @param DevicePath Use this to get Device Path
1007 @param CodeType Status Code Type
1008 @param CodeValue Status Code Value
1014 MouseSimulateTouchPadReportStatusCode (
1015 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
1016 IN EFI_STATUS_CODE_TYPE CodeType
,
1017 IN EFI_STATUS_CODE_VALUE Value
1020 REPORT_STATUS_CODE_WITH_DEVICE_PATH (