From 28b273dd575b18fa52403cdabe013605b0be1b90 Mon Sep 17 00:00:00 2001 From: XavierXia <1750546761@qq.com> Date: Tue, 7 Feb 2023 15:49:24 +0100 Subject: [PATCH] update project config & minor code updates & separate HID code into a dedicate kext --- .gitmodules | 3 + .../BigSurface.xcodeproj/project.pbxproj | 394 ++----- .../xcschemes/BigSurface.xcscheme | 2 +- BigSurface/BigSurface/Info.plist | 529 +-------- .../SurfaceBattery/SurfaceBatteryDriver.cpp | 7 +- .../VoodooI2CHIDTransducerWrapper.cpp | 38 - .../VoodooI2CHIDTransducerWrapper.hpp | 33 - .../VoodooI2CMultitouchHIDEventDriver.cpp | 967 ---------------- .../VoodooI2CMultitouchHIDEventDriver.hpp | 316 ----- ...odooI2CPrecisionTouchpadHIDEventDriver.cpp | 54 - ...odooI2CPrecisionTouchpadHIDEventDriver.hpp | 50 - .../VoodooI2CTouchscreenHIDEventDriver.cpp | 244 ---- .../VoodooI2CTouchscreenHIDEventDriver.hpp | 98 -- .../SurfaceHID/SurfaceHIDDevice.cpp | 148 --- .../SurfaceHID/SurfaceHIDDevice.hpp | 52 - .../SurfaceHID/SurfaceHIDDriver.cpp | 211 ---- .../SurfaceHID/SurfaceHIDDriver.hpp | 69 -- .../SurfaceHID/SurfaceTouchScreenDevice.cpp | 89 -- .../SurfaceHID/SurfaceTouchScreenDevice.hpp | 51 - .../SurfaceTouchScreenReportDescriptor.h | 364 ------ .../SurfaceHID/VoodooI2CHIDDevice.cpp | 663 ----------- .../SurfaceHID/VoodooI2CHIDDevice.hpp | 324 ------ .../MEIProtocol.h | 0 .../SurfaceManagementEngineClient.cpp | 35 +- .../SurfaceManagementEngineClient.hpp | 8 +- .../SurfaceManagementEngineDriver.cpp | 21 +- .../SurfaceManagementEngineDriver.hpp | 0 .../CSGesture/AverageClasses.h | 129 --- .../CSGesture/VoodooCSGestureHIDWrapper.cpp | 79 -- .../CSGesture/VoodooCSGestureHIDWrapper.h | 47 - .../VoodooCSGestureHIPointingWrapper.cpp | 201 ---- .../VoodooCSGestureHIPointingWrapper.hpp | 49 - .../CSGesture/VoodooI2CCSGestureEngine.cpp | 1014 ----------------- .../CSGesture/VoodooI2CCSGestureEngine.hpp | 90 -- .../CSGesture/csgesture-softc.h | 90 -- .../CSGesture/csgesturescroll.cpp | 317 ------ .../CSGesture/csgesturescroll.h | 80 -- .../SurfaceMultitouch/MultitouchHelpers.hpp | 29 - .../Native/VoodooI2CNativeEngine.cpp | 187 --- .../Native/VoodooI2CNativeEngine.hpp | 48 - .../VoodooI2CDigitiserStylus.cpp | 30 - .../VoodooI2CDigitiserStylus.hpp | 34 - .../VoodooI2CDigitiserTransducer.cpp | 46 - .../VoodooI2CDigitiserTransducer.hpp | 141 --- .../VoodooI2CMultitouchEngine.cpp | 63 - .../VoodooI2CMultitouchEngine.hpp | 60 - .../VoodooI2CMultitouchInterface.cpp | 94 -- .../VoodooI2CMultitouchInterface.hpp | 114 -- .../SurfaceSerialHubDriver.cpp | 4 +- .../SurfaceBatteryNub.cpp | 27 +- .../SurfaceBatteryNub.hpp | 4 - .../SurfaceSerialHubDevices/SurfaceHIDNub.cpp | 71 +- .../SurfaceSerialHubDevices/SurfaceHIDNub.hpp | 5 +- .../SurfaceTouchScreen/IPTSKenerlUserShared.h | 252 ---- .../SurfaceTouchScreen/IPTSProtocol.h | 355 ------ .../IntelPreciseTouchStylusDriver.cpp | 600 ---------- .../IntelPreciseTouchStylusDriver.hpp | 115 -- .../IntelPreciseTouchStylusUserClient.cpp | 127 --- .../IntelPreciseTouchStylusUserClient.hpp | 46 - .../SurfaceTypeCoverDriver.cpp | 278 ----- .../SurfaceTypeCoverDriver.hpp | 68 -- Dependencies/BigSurfaceHIDDriver | 1 + Dependencies/VoodooGPIO | 2 +- .../project.pbxproj | 364 ------ .../contents.xcworkspacedata | 7 - .../xcschemes/VoodooI2CServices.xcscheme | 76 -- .../VoodooI2CServices/Info.plist | 60 - .../VoodooI2CServices/VoodooI2CLogger.cpp | 42 - .../VoodooI2CServices/VoodooI2CLogger.hpp | 33 - .../VoodooI2CServices/VoodooI2CServices.cpp | 69 -- .../VoodooI2CServices/VoodooI2CServices.hpp | 72 -- Dependencies/VoodooInput | 2 +- Dependencies/VoodooSerial | 2 +- MacKernelSDK | 2 +- 74 files changed, 151 insertions(+), 10245 deletions(-) delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.hpp delete mode 100755 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.cpp delete mode 100755 BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.hpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenReportDescriptor.h delete mode 100644 BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.cpp delete mode 100644 BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.hpp rename BigSurface/BigSurface/{SurfaceTouchScreen => SurfaceManagementEngine}/MEIProtocol.h (100%) rename BigSurface/BigSurface/{SurfaceTouchScreen => SurfaceManagementEngine}/SurfaceManagementEngineClient.cpp (88%) rename BigSurface/BigSurface/{SurfaceTouchScreen => SurfaceManagementEngine}/SurfaceManagementEngineClient.hpp (90%) rename BigSurface/BigSurface/{SurfaceTouchScreen => SurfaceManagementEngine}/SurfaceManagementEngineDriver.cpp (99%) rename BigSurface/BigSurface/{SurfaceTouchScreen => SurfaceManagementEngine}/SurfaceManagementEngineDriver.hpp (100%) delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/AverageClasses.h delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.h delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesture-softc.h delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.h delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/MultitouchHelpers.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.hpp delete mode 100755 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.hpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.cpp delete mode 100644 BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IPTSKenerlUserShared.h delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IPTSProtocol.h delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.cpp delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.hpp delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.cpp delete mode 100644 BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.hpp delete mode 100644 BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.cpp delete mode 100644 BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.hpp create mode 160000 Dependencies/BigSurfaceHIDDriver delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.pbxproj delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/xcshareddata/xcschemes/VoodooI2CServices.xcscheme delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices/Info.plist delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.cpp delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.hpp delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.cpp delete mode 100644 Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.hpp diff --git a/.gitmodules b/.gitmodules index d9378c0..8411b42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "Dependencies/VoodooInput"] path = Dependencies/VoodooInput url = https://github.com/Xiashangning/VoodooInput.git +[submodule "Dependencies/BigSurfaceHIDDriver"] + path = Dependencies/BigSurfaceHIDDriver + url = https://github.com/Xiashangning/BigSurfaceHIDDriver.git diff --git a/BigSurface/BigSurface.xcodeproj/project.pbxproj b/BigSurface/BigSurface.xcodeproj/project.pbxproj index 2883833..f952af6 100644 --- a/BigSurface/BigSurface.xcodeproj/project.pbxproj +++ b/BigSurface/BigSurface.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -29,76 +29,23 @@ 2597318C2738B2BA00A7F7C1 /* SurfaceSMBusController.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2597318A2738B2BA00A7F7C1 /* SurfaceSMBusController.hpp */; }; 2597318D2738B2BA00A7F7C1 /* SurfaceSMBusController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2597318B2738B2BA00A7F7C1 /* SurfaceSMBusController.cpp */; }; 25B97D89260B950E00657C76 /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7BE66D8F258AC5DC003CA4AD /* libkmod.a */; }; - 25B97E1A260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25B97E14260B9F1000657C76 /* VoodooI2CMultitouchHIDEventDriver.cpp */; }; - 25B97E1B260B9F1100657C76 /* SurfaceTypeCoverDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25B97E15260B9F1100657C76 /* SurfaceTypeCoverDriver.cpp */; }; - 25B97E1C260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25B97E16260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.hpp */; }; - 25B97E1E260B9F1100657C76 /* SurfaceTypeCoverDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25B97E18260B9F1100657C76 /* SurfaceTypeCoverDriver.hpp */; }; - 25B97E2B260BA12100657C76 /* VoodooI2CHIDTransducerWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25B97E2A260BA12100657C76 /* VoodooI2CHIDTransducerWrapper.cpp */; }; - 25B97E2E260BA13A00657C76 /* VoodooI2CHIDTransducerWrapper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25B97E2D260BA13A00657C76 /* VoodooI2CHIDTransducerWrapper.hpp */; }; 25C8D7EB27359FCD00F58956 /* SerialProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 25C8D7E827359FCD00F58956 /* SerialProtocol.h */; }; 25C8D7EC27359FCD00F58956 /* SurfaceSerialHubDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25C8D7E927359FCD00F58956 /* SurfaceSerialHubDriver.cpp */; }; 25C8D7ED27359FCD00F58956 /* SurfaceSerialHubDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25C8D7EA27359FCD00F58956 /* SurfaceSerialHubDriver.hpp */; }; - 25CDE609285F27A7003FB4C4 /* SurfaceManagementEngineClient.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE5F9285F27A7003FB4C4 /* SurfaceManagementEngineClient.hpp */; }; - 25CDE60A285F27A7003FB4C4 /* SurfaceTouchScreenDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE5FA285F27A7003FB4C4 /* SurfaceTouchScreenDevice.cpp */; }; - 25CDE60B285F27A7003FB4C4 /* SurfaceManagementEngineDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE5FB285F27A7003FB4C4 /* SurfaceManagementEngineDriver.cpp */; }; - 25CDE60C285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE5FC285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.cpp */; }; - 25CDE60D285F27A7003FB4C4 /* IPTSKenerlUserShared.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE5FD285F27A7003FB4C4 /* IPTSKenerlUserShared.h */; }; - 25CDE60E285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE5FE285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.cpp */; }; - 25CDE60F285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE5FF285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.hpp */; }; - 25CDE610285F27A7003FB4C4 /* SurfaceManagementEngineDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE600285F27A7003FB4C4 /* SurfaceManagementEngineDriver.hpp */; }; - 25CDE611285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE601285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.hpp */; }; - 25CDE612285F27A7003FB4C4 /* MEIProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE602285F27A7003FB4C4 /* MEIProtocol.h */; }; - 25CDE613285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE603285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.hpp */; }; - 25CDE614285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE604285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.cpp */; }; - 25CDE615285F27A7003FB4C4 /* SurfaceManagementEngineClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25CDE605285F27A7003FB4C4 /* SurfaceManagementEngineClient.cpp */; }; - 25CDE616285F27A7003FB4C4 /* SurfaceTouchScreenReportDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE606285F27A7003FB4C4 /* SurfaceTouchScreenReportDescriptor.h */; }; - 25CDE617285F27A7003FB4C4 /* SurfaceTouchScreenDevice.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE607285F27A7003FB4C4 /* SurfaceTouchScreenDevice.hpp */; }; - 25CDE618285F27A7003FB4C4 /* IPTSProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 25CDE608285F27A7003FB4C4 /* IPTSProtocol.h */; }; 25D907292736E2B2006D799F /* AmbientLightValue.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25D907272736E2B2006D799F /* AmbientLightValue.hpp */; }; 25D9072A2736E2B2006D799F /* AmbientLightValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25D907282736E2B2006D799F /* AmbientLightValue.cpp */; }; 25DBA9742836A77700459629 /* SurfaceHIDNub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DBA9722836A77700459629 /* SurfaceHIDNub.cpp */; }; 25DBA9752836A77700459629 /* SurfaceHIDNub.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DBA9732836A77700459629 /* SurfaceHIDNub.hpp */; }; - 25DE0A69283738EC002DA176 /* SurfaceHIDDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DE0A65283738EC002DA176 /* SurfaceHIDDriver.hpp */; }; - 25DE0A6A283738EC002DA176 /* SurfaceHIDDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DE0A66283738EC002DA176 /* SurfaceHIDDriver.cpp */; }; - 25DE0A8D28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DE0A8B28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.cpp */; }; - 25DE0A8E28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DE0A8C28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.hpp */; }; - 25DE0A912837BC4C002DA176 /* SurfaceHIDDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DE0A8F2837BC4C002DA176 /* SurfaceHIDDevice.cpp */; }; - 25DE0A922837BC4C002DA176 /* SurfaceHIDDevice.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DE0A902837BC4C002DA176 /* SurfaceHIDDevice.hpp */; }; - 25DFC00F2877EF8B00EA6990 /* VoodooI2CMultitouchInterface.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFF82877EF8B00EA6990 /* VoodooI2CMultitouchInterface.hpp */; }; - 25DFC0102877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFF92877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.hpp */; }; - 25DFC0112877EF8B00EA6990 /* VoodooI2CMultitouchEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFFA2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.hpp */; }; - 25DFC0122877EF8B00EA6990 /* VoodooI2CDigitiserStylus.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFFB2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.hpp */; }; - 25DFC0132877EF8B00EA6990 /* VoodooI2CNativeEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFBFFD2877EF8B00EA6990 /* VoodooI2CNativeEngine.cpp */; }; - 25DFC0142877EF8B00EA6990 /* VoodooI2CNativeEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFFE2877EF8B00EA6990 /* VoodooI2CNativeEngine.hpp */; }; - 25DFC0152877EF8B00EA6990 /* MultitouchHelpers.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFBFFF2877EF8B00EA6990 /* MultitouchHelpers.hpp */; }; - 25DFC0162877EF8B00EA6990 /* VoodooI2CCSGestureEngine.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0012877EF8B00EA6990 /* VoodooI2CCSGestureEngine.hpp */; }; - 25DFC0172877EF8B00EA6990 /* AverageClasses.h in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0022877EF8B00EA6990 /* AverageClasses.h */; }; - 25DFC0182877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC0032877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.cpp */; }; - 25DFC0192877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0042877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.h */; }; - 25DFC01A2877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC0052877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.cpp */; }; - 25DFC01B2877EF8B00EA6990 /* csgesturescroll.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC0062877EF8B00EA6990 /* csgesturescroll.cpp */; }; - 25DFC01C2877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0072877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.hpp */; }; - 25DFC01D2877EF8B00EA6990 /* VoodooI2CCSGestureEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC0082877EF8B00EA6990 /* VoodooI2CCSGestureEngine.cpp */; }; - 25DFC01E2877EF8C00EA6990 /* csgesturescroll.h in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0092877EF8B00EA6990 /* csgesturescroll.h */; }; - 25DFC01F2877EF8C00EA6990 /* csgesture-softc.h in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC00A2877EF8B00EA6990 /* csgesture-softc.h */; }; - 25DFC0202877EF8C00EA6990 /* VoodooI2CDigitiserTransducer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC00B2877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.cpp */; }; - 25DFC0212877EF8C00EA6990 /* VoodooI2CMultitouchInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC00C2877EF8B00EA6990 /* VoodooI2CMultitouchInterface.cpp */; }; - 25DFC0222877EF8C00EA6990 /* VoodooI2CMultitouchEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC00D2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.cpp */; }; - 25DFC0232877EF8C00EA6990 /* VoodooI2CDigitiserStylus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC00E2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.cpp */; }; - 25DFC0432877F2F200EA6990 /* VoodooI2CHIDDevice.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25DFC0412877F2F200EA6990 /* VoodooI2CHIDDevice.hpp */; }; - 25DFC0442877F2F200EA6990 /* VoodooI2CHIDDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25DFC0422877F2F200EA6990 /* VoodooI2CHIDDevice.cpp */; }; + 25E5B4CB2991ACE7007F21D4 /* SurfaceManagementEngineClient.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25E5B4C62991ACE7007F21D4 /* SurfaceManagementEngineClient.hpp */; }; + 25E5B4CC2991ACE7007F21D4 /* SurfaceManagementEngineDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25E5B4C72991ACE7007F21D4 /* SurfaceManagementEngineDriver.cpp */; }; + 25E5B4CD2991ACE7007F21D4 /* SurfaceManagementEngineDriver.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25E5B4C82991ACE7007F21D4 /* SurfaceManagementEngineDriver.hpp */; }; + 25E5B4CE2991ACE7007F21D4 /* MEIProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 25E5B4C92991ACE7007F21D4 /* MEIProtocol.h */; }; + 25E5B4CF2991ACE7007F21D4 /* SurfaceManagementEngineClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25E5B4CA2991ACE7007F21D4 /* SurfaceManagementEngineClient.cpp */; }; 25EA2A7E2836412B00525325 /* SurfaceBatteryNub.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 25EA2A7C2836412B00525325 /* SurfaceBatteryNub.cpp */; }; 25EA2A7F2836412B00525325 /* SurfaceBatteryNub.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 25EA2A7D2836412B00525325 /* SurfaceBatteryNub.hpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 25CBB35A2733D4B8009B568B /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25B97DBF260B972000657C76 /* VoodooI2CServices.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = AC2DC71C1F7F0D450071CDCA; - remoteInfo = VoodooI2CServices; - }; 25CBB35F2733D4C1009B568B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */; @@ -134,13 +81,6 @@ remoteGlobalIDString = 7BBAB1F822E3A2F800B2941A; remoteInfo = VoodooInput; }; - 25D49D8C2854EE8E008CAAA5 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 25B97DBF260B972000657C76 /* VoodooI2CServices.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = AC2DC71B1F7F0D450071CDCA; - remoteInfo = VoodooI2CServices; - }; 25D49D8E2854EE92008CAAA5 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */; @@ -148,6 +88,20 @@ remoteGlobalIDString = F1F172C41F42263A00AD98FA; remoteInfo = VoodooGPIO; }; + 25E5B47929919DCC007F21D4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 25E5B47529919DCB007F21D4 /* BigSurfaceHIDDriver.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 25E5B46829919DCB007F21D4; + remoteInfo = BigSurfaceHIDDriver; + }; + 25E5B47E29919F2C007F21D4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 25E5B47529919DCB007F21D4 /* BigSurfaceHIDDriver.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 25E5B46729919DCB007F21D4; + remoteInfo = BigSurfaceHIDDriver; + }; AC94C83C2119E50400D26081 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = AC94C8382119E50400D26081 /* VoodooI2CSynaptics.xcodeproj */; @@ -182,33 +136,10 @@ 2597318B2738B2BA00A7F7C1 /* SurfaceSMBusController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceSMBusController.cpp; sourceTree = ""; }; 25B97DA5260B950E00657C76 /* BigSurface.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BigSurface.kext; sourceTree = BUILT_PRODUCTS_DIR; }; 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VoodooGPIO.xcodeproj; path = VoodooGPIO/VoodooGPIO.xcodeproj; sourceTree = ""; }; - 25B97DBF260B972000657C76 /* VoodooI2CServices.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VoodooI2CServices.xcodeproj; path = VoodooI2CServices/VoodooI2CServices.xcodeproj; sourceTree = ""; }; - 25B97E14260B9F1000657C76 /* VoodooI2CMultitouchHIDEventDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CMultitouchHIDEventDriver.cpp; sourceTree = ""; }; - 25B97E15260B9F1100657C76 /* SurfaceTypeCoverDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceTypeCoverDriver.cpp; sourceTree = ""; }; - 25B97E16260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CMultitouchHIDEventDriver.hpp; sourceTree = ""; }; - 25B97E18260B9F1100657C76 /* SurfaceTypeCoverDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceTypeCoverDriver.hpp; sourceTree = ""; }; - 25B97E2A260BA12100657C76 /* VoodooI2CHIDTransducerWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CHIDTransducerWrapper.cpp; sourceTree = ""; }; - 25B97E2D260BA13A00657C76 /* VoodooI2CHIDTransducerWrapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CHIDTransducerWrapper.hpp; sourceTree = ""; }; - 25B97E43260BA33B00657C76 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BigSurface/Info.plist; sourceTree = ""; }; + 25B97E43260BA33B00657C76 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 25C8D7E827359FCD00F58956 /* SerialProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerialProtocol.h; sourceTree = ""; }; 25C8D7E927359FCD00F58956 /* SurfaceSerialHubDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceSerialHubDriver.cpp; sourceTree = ""; }; 25C8D7EA27359FCD00F58956 /* SurfaceSerialHubDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceSerialHubDriver.hpp; sourceTree = ""; }; - 25CDE5F9285F27A7003FB4C4 /* SurfaceManagementEngineClient.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceManagementEngineClient.hpp; sourceTree = ""; }; - 25CDE5FA285F27A7003FB4C4 /* SurfaceTouchScreenDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceTouchScreenDevice.cpp; sourceTree = ""; }; - 25CDE5FB285F27A7003FB4C4 /* SurfaceManagementEngineDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceManagementEngineDriver.cpp; sourceTree = ""; }; - 25CDE5FC285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntelPreciseTouchStylusUserClient.cpp; sourceTree = ""; }; - 25CDE5FD285F27A7003FB4C4 /* IPTSKenerlUserShared.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPTSKenerlUserShared.h; sourceTree = ""; }; - 25CDE5FE285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CTouchscreenHIDEventDriver.cpp; sourceTree = ""; }; - 25CDE5FF285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IntelPreciseTouchStylusDriver.hpp; sourceTree = ""; }; - 25CDE600285F27A7003FB4C4 /* SurfaceManagementEngineDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceManagementEngineDriver.hpp; sourceTree = ""; }; - 25CDE601285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IntelPreciseTouchStylusUserClient.hpp; sourceTree = ""; }; - 25CDE602285F27A7003FB4C4 /* MEIProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MEIProtocol.h; sourceTree = ""; }; - 25CDE603285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CTouchscreenHIDEventDriver.hpp; sourceTree = ""; }; - 25CDE604285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IntelPreciseTouchStylusDriver.cpp; sourceTree = ""; }; - 25CDE605285F27A7003FB4C4 /* SurfaceManagementEngineClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceManagementEngineClient.cpp; sourceTree = ""; }; - 25CDE606285F27A7003FB4C4 /* SurfaceTouchScreenReportDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurfaceTouchScreenReportDescriptor.h; sourceTree = ""; }; - 25CDE607285F27A7003FB4C4 /* SurfaceTouchScreenDevice.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceTouchScreenDevice.hpp; sourceTree = ""; }; - 25CDE608285F27A7003FB4C4 /* IPTSProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IPTSProtocol.h; sourceTree = ""; }; 25CDE619285F291D003FB4C4 /* VoodooInput.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VoodooInput.xcodeproj; path = VoodooInput/VoodooInput.xcodeproj; sourceTree = ""; }; 25D9064A2736DB7F006D799F /* kern_smcinfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_smcinfo.hpp; sourceTree = ""; }; 25D9064B2736DB7F006D799F /* kern_vsmcapi.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kern_vsmcapi.hpp; sourceTree = ""; }; @@ -258,35 +189,12 @@ 25D907282736E2B2006D799F /* AmbientLightValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AmbientLightValue.cpp; sourceTree = ""; }; 25DBA9722836A77700459629 /* SurfaceHIDNub.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceHIDNub.cpp; sourceTree = ""; }; 25DBA9732836A77700459629 /* SurfaceHIDNub.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SurfaceHIDNub.hpp; sourceTree = ""; }; - 25DE0A65283738EC002DA176 /* SurfaceHIDDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceHIDDriver.hpp; sourceTree = ""; }; - 25DE0A66283738EC002DA176 /* SurfaceHIDDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceHIDDriver.cpp; sourceTree = ""; }; - 25DE0A8B28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CPrecisionTouchpadHIDEventDriver.cpp; sourceTree = ""; }; - 25DE0A8C28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CPrecisionTouchpadHIDEventDriver.hpp; sourceTree = ""; }; - 25DE0A8F2837BC4C002DA176 /* SurfaceHIDDevice.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceHIDDevice.cpp; sourceTree = ""; }; - 25DE0A902837BC4C002DA176 /* SurfaceHIDDevice.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SurfaceHIDDevice.hpp; sourceTree = ""; }; - 25DFBFF82877EF8B00EA6990 /* VoodooI2CMultitouchInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CMultitouchInterface.hpp; sourceTree = ""; }; - 25DFBFF92877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CDigitiserTransducer.hpp; sourceTree = ""; }; - 25DFBFFA2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CMultitouchEngine.hpp; sourceTree = ""; }; - 25DFBFFB2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CDigitiserStylus.hpp; sourceTree = ""; }; - 25DFBFFD2877EF8B00EA6990 /* VoodooI2CNativeEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CNativeEngine.cpp; sourceTree = ""; }; - 25DFBFFE2877EF8B00EA6990 /* VoodooI2CNativeEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CNativeEngine.hpp; sourceTree = ""; }; - 25DFBFFF2877EF8B00EA6990 /* MultitouchHelpers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MultitouchHelpers.hpp; sourceTree = ""; }; - 25DFC0012877EF8B00EA6990 /* VoodooI2CCSGestureEngine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CCSGestureEngine.hpp; sourceTree = ""; }; - 25DFC0022877EF8B00EA6990 /* AverageClasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AverageClasses.h; sourceTree = ""; }; - 25DFC0032877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooCSGestureHIDWrapper.cpp; sourceTree = ""; }; - 25DFC0042877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VoodooCSGestureHIDWrapper.h; sourceTree = ""; }; - 25DFC0052877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooCSGestureHIPointingWrapper.cpp; sourceTree = ""; }; - 25DFC0062877EF8B00EA6990 /* csgesturescroll.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = csgesturescroll.cpp; sourceTree = ""; }; - 25DFC0072877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooCSGestureHIPointingWrapper.hpp; sourceTree = ""; }; - 25DFC0082877EF8B00EA6990 /* VoodooI2CCSGestureEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CCSGestureEngine.cpp; sourceTree = ""; }; - 25DFC0092877EF8B00EA6990 /* csgesturescroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = csgesturescroll.h; sourceTree = ""; }; - 25DFC00A2877EF8B00EA6990 /* csgesture-softc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "csgesture-softc.h"; sourceTree = ""; }; - 25DFC00B2877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CDigitiserTransducer.cpp; sourceTree = ""; }; - 25DFC00C2877EF8B00EA6990 /* VoodooI2CMultitouchInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CMultitouchInterface.cpp; sourceTree = ""; }; - 25DFC00D2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CMultitouchEngine.cpp; sourceTree = ""; }; - 25DFC00E2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CDigitiserStylus.cpp; sourceTree = ""; }; - 25DFC0412877F2F200EA6990 /* VoodooI2CHIDDevice.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CHIDDevice.hpp; sourceTree = ""; }; - 25DFC0422877F2F200EA6990 /* VoodooI2CHIDDevice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CHIDDevice.cpp; sourceTree = ""; }; + 25E5B47529919DCB007F21D4 /* BigSurfaceHIDDriver.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BigSurfaceHIDDriver.xcodeproj; path = BigSurfaceHIDDriver/BigSurfaceHIDDriver.xcodeproj; sourceTree = ""; }; + 25E5B4C62991ACE7007F21D4 /* SurfaceManagementEngineClient.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceManagementEngineClient.hpp; sourceTree = ""; }; + 25E5B4C72991ACE7007F21D4 /* SurfaceManagementEngineDriver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceManagementEngineDriver.cpp; sourceTree = ""; }; + 25E5B4C82991ACE7007F21D4 /* SurfaceManagementEngineDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SurfaceManagementEngineDriver.hpp; sourceTree = ""; }; + 25E5B4C92991ACE7007F21D4 /* MEIProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MEIProtocol.h; sourceTree = ""; }; + 25E5B4CA2991ACE7007F21D4 /* SurfaceManagementEngineClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceManagementEngineClient.cpp; sourceTree = ""; }; 25EA2A7C2836412B00525325 /* SurfaceBatteryNub.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SurfaceBatteryNub.cpp; sourceTree = ""; }; 25EA2A7D2836412B00525325 /* SurfaceBatteryNub.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SurfaceBatteryNub.hpp; sourceTree = ""; }; 7BE66D8F258AC5DC003CA4AD /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = ../MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = ""; }; @@ -353,28 +261,17 @@ isa = PBXGroup; children = ( AC0955711F4ED49E0052E343 /* Dependencies */, - 25DFBFF72877EF8B00EA6990 /* SurfaceMultitouch */, - 25B97DAF260B95B600657C76 /* SurfaceTypeCover */, 2524C0A326F3233A00CAAF12 /* SurfaceButton */, 2518A2F22734F6AA00B0D631 /* SurfaceAmbientLightSensor */, 25C8D7E727359FCD00F58956 /* SurfaceSerialHub */, 25DBA9762836A78900459629 /* SurfaceSerialHubDevices */, 2597316F2738B01F00A7F7C1 /* SurfaceBattery */, - 25DE0A63283738EC002DA176 /* SurfaceHID */, - 25CDE5F8285F27A7003FB4C4 /* SurfaceTouchScreen */, + 25E5B4C52991ACE7007F21D4 /* SurfaceManagementEngine */, + 25B97E43260BA33B00657C76 /* Info.plist */, ); path = BigSurface; sourceTree = ""; }; - 25B97DAF260B95B600657C76 /* SurfaceTypeCover */ = { - isa = PBXGroup; - children = ( - 25B97E15260B9F1100657C76 /* SurfaceTypeCoverDriver.cpp */, - 25B97E18260B9F1100657C76 /* SurfaceTypeCoverDriver.hpp */, - ); - path = SurfaceTypeCover; - sourceTree = ""; - }; 25C8D7E727359FCD00F58956 /* SurfaceSerialHub */ = { isa = PBXGroup; children = ( @@ -385,14 +282,6 @@ path = SurfaceSerialHub; sourceTree = ""; }; - 25CBB3572733D4B8009B568B /* Products */ = { - isa = PBXGroup; - children = ( - 25CBB35B2733D4B8009B568B /* VoodooI2CServices.kext */, - ); - name = Products; - sourceTree = ""; - }; 25CBB35C2733D4C1009B568B /* Products */ = { isa = PBXGroup; children = ( @@ -409,24 +298,6 @@ name = Products; sourceTree = ""; }; - 25CDE5F8285F27A7003FB4C4 /* SurfaceTouchScreen */ = { - isa = PBXGroup; - children = ( - 25CDE602285F27A7003FB4C4 /* MEIProtocol.h */, - 25CDE5FB285F27A7003FB4C4 /* SurfaceManagementEngineDriver.cpp */, - 25CDE600285F27A7003FB4C4 /* SurfaceManagementEngineDriver.hpp */, - 25CDE605285F27A7003FB4C4 /* SurfaceManagementEngineClient.cpp */, - 25CDE5F9285F27A7003FB4C4 /* SurfaceManagementEngineClient.hpp */, - 25CDE608285F27A7003FB4C4 /* IPTSProtocol.h */, - 25CDE604285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.cpp */, - 25CDE5FF285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.hpp */, - 25CDE5FC285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.cpp */, - 25CDE601285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.hpp */, - 25CDE5FD285F27A7003FB4C4 /* IPTSKenerlUserShared.h */, - ); - path = SurfaceTouchScreen; - sourceTree = ""; - }; 25CDE61A285F291D003FB4C4 /* Products */ = { isa = PBXGroup; children = ( @@ -539,80 +410,24 @@ path = SurfaceSerialHubDevices; sourceTree = ""; }; - 25DE0A63283738EC002DA176 /* SurfaceHID */ = { - isa = PBXGroup; - children = ( - 25DFC0242877F03E00EA6990 /* HIDEventDriver */, - 25DE0A66283738EC002DA176 /* SurfaceHIDDriver.cpp */, - 25DE0A65283738EC002DA176 /* SurfaceHIDDriver.hpp */, - 25DE0A8F2837BC4C002DA176 /* SurfaceHIDDevice.cpp */, - 25DE0A902837BC4C002DA176 /* SurfaceHIDDevice.hpp */, - 25CDE5FA285F27A7003FB4C4 /* SurfaceTouchScreenDevice.cpp */, - 25CDE607285F27A7003FB4C4 /* SurfaceTouchScreenDevice.hpp */, - 25CDE606285F27A7003FB4C4 /* SurfaceTouchScreenReportDescriptor.h */, - 25DFC0422877F2F200EA6990 /* VoodooI2CHIDDevice.cpp */, - 25DFC0412877F2F200EA6990 /* VoodooI2CHIDDevice.hpp */, - ); - path = SurfaceHID; - sourceTree = ""; - }; - 25DFBFF72877EF8B00EA6990 /* SurfaceMultitouch */ = { + 25E5B47629919DCB007F21D4 /* Products */ = { isa = PBXGroup; children = ( - 25DFC0002877EF8B00EA6990 /* CSGesture */, - 25DFBFFC2877EF8B00EA6990 /* Native */, - 25DFC00C2877EF8B00EA6990 /* VoodooI2CMultitouchInterface.cpp */, - 25DFBFF82877EF8B00EA6990 /* VoodooI2CMultitouchInterface.hpp */, - 25DFC00B2877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.cpp */, - 25DFBFF92877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.hpp */, - 25DFC00D2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.cpp */, - 25DFBFFA2877EF8B00EA6990 /* VoodooI2CMultitouchEngine.hpp */, - 25DFC00E2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.cpp */, - 25DFBFFB2877EF8B00EA6990 /* VoodooI2CDigitiserStylus.hpp */, - 25DFBFFF2877EF8B00EA6990 /* MultitouchHelpers.hpp */, + 25E5B47A29919DCC007F21D4 /* BigSurfaceHIDDriver.kext */, ); - path = SurfaceMultitouch; - sourceTree = ""; - }; - 25DFBFFC2877EF8B00EA6990 /* Native */ = { - isa = PBXGroup; - children = ( - 25DFBFFD2877EF8B00EA6990 /* VoodooI2CNativeEngine.cpp */, - 25DFBFFE2877EF8B00EA6990 /* VoodooI2CNativeEngine.hpp */, - ); - path = Native; - sourceTree = ""; - }; - 25DFC0002877EF8B00EA6990 /* CSGesture */ = { - isa = PBXGroup; - children = ( - 25DFC0012877EF8B00EA6990 /* VoodooI2CCSGestureEngine.hpp */, - 25DFC0022877EF8B00EA6990 /* AverageClasses.h */, - 25DFC0032877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.cpp */, - 25DFC0042877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.h */, - 25DFC0052877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.cpp */, - 25DFC0062877EF8B00EA6990 /* csgesturescroll.cpp */, - 25DFC0072877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.hpp */, - 25DFC0082877EF8B00EA6990 /* VoodooI2CCSGestureEngine.cpp */, - 25DFC0092877EF8B00EA6990 /* csgesturescroll.h */, - 25DFC00A2877EF8B00EA6990 /* csgesture-softc.h */, - ); - path = CSGesture; + name = Products; sourceTree = ""; }; - 25DFC0242877F03E00EA6990 /* HIDEventDriver */ = { + 25E5B4C52991ACE7007F21D4 /* SurfaceManagementEngine */ = { isa = PBXGroup; children = ( - 25B97E2A260BA12100657C76 /* VoodooI2CHIDTransducerWrapper.cpp */, - 25B97E2D260BA13A00657C76 /* VoodooI2CHIDTransducerWrapper.hpp */, - 25B97E14260B9F1000657C76 /* VoodooI2CMultitouchHIDEventDriver.cpp */, - 25B97E16260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.hpp */, - 25DE0A8B28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.cpp */, - 25DE0A8C28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.hpp */, - 25CDE5FE285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.cpp */, - 25CDE603285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.hpp */, + 25E5B4C92991ACE7007F21D4 /* MEIProtocol.h */, + 25E5B4CA2991ACE7007F21D4 /* SurfaceManagementEngineClient.cpp */, + 25E5B4C62991ACE7007F21D4 /* SurfaceManagementEngineClient.hpp */, + 25E5B4C72991ACE7007F21D4 /* SurfaceManagementEngineDriver.cpp */, + 25E5B4C82991ACE7007F21D4 /* SurfaceManagementEngineDriver.hpp */, ); - path = HIDEventDriver; + path = SurfaceManagementEngine; sourceTree = ""; }; 7BE66D8E258AC5DC003CA4AD /* Frameworks */ = { @@ -629,9 +444,9 @@ 25D906A72736DC1A006D799F /* LiluSDK */, 25D906492736DB7F006D799F /* VirtualSMCSDK */, 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */, - 25CDE619285F291D003FB4C4 /* VoodooInput.xcodeproj */, - 25B97DBF260B972000657C76 /* VoodooI2CServices.xcodeproj */, 25813612272D6A2800EED5C9 /* VoodooSerial.xcodeproj */, + 25CDE619285F291D003FB4C4 /* VoodooInput.xcodeproj */, + 25E5B47529919DCB007F21D4 /* BigSurfaceHIDDriver.xcodeproj */, ); name = Dependencies; path = ../../Dependencies; @@ -641,7 +456,6 @@ isa = PBXGroup; children = ( 25B97D6E260B943E00657C76 /* BigSurface */, - 25B97E43260BA33B00657C76 /* Info.plist */, AC2603B11F2F294000CF238F /* Products */, 7BE66D8E258AC5DC003CA4AD /* Frameworks */, ); @@ -670,52 +484,26 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 25CDE617285F27A7003FB4C4 /* SurfaceTouchScreenDevice.hpp in Headers */, 259731842738B01F00A7F7C1 /* BatteryManagerState.hpp in Headers */, 2518A2F62734F6AA00B0D631 /* SurfaceAmbientLightSensorDriver.hpp in Headers */, 259731892738B01F00A7F7C1 /* BatteryManager.hpp in Headers */, - 25CDE618285F27A7003FB4C4 /* IPTSProtocol.h in Headers */, - 25CDE60F285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.hpp in Headers */, 2597317F2738B01F00A7F7C1 /* SurfaceBatteryDriver.hpp in Headers */, - 25DFC01E2877EF8C00EA6990 /* csgesturescroll.h in Headers */, - 25DFC0122877EF8B00EA6990 /* VoodooI2CDigitiserStylus.hpp in Headers */, - 25B97E2E260BA13A00657C76 /* VoodooI2CHIDTransducerWrapper.hpp in Headers */, 259731832738B01F00A7F7C1 /* SurfaceBattery.hpp in Headers */, - 25CDE616285F27A7003FB4C4 /* SurfaceTouchScreenReportDescriptor.h in Headers */, - 25DFC0102877EF8B00EA6990 /* VoodooI2CDigitiserTransducer.hpp in Headers */, 25EA2A7F2836412B00525325 /* SurfaceBatteryNub.hpp in Headers */, 25D907292736E2B2006D799F /* AmbientLightValue.hpp in Headers */, 2597318C2738B2BA00A7F7C1 /* SurfaceSMBusController.hpp in Headers */, - 25B97E1C260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.hpp in Headers */, - 25DFC01F2877EF8C00EA6990 /* csgesture-softc.h in Headers */, 2518A2F82734F6AA00B0D631 /* APDS9960Constants.h in Headers */, - 25DFC0162877EF8B00EA6990 /* VoodooI2CCSGestureEngine.hpp in Headers */, - 25DE0A922837BC4C002DA176 /* SurfaceHIDDevice.hpp in Headers */, - 25DFC0152877EF8B00EA6990 /* MultitouchHelpers.hpp in Headers */, 2524C0A726F3233A00CAAF12 /* SurfaceButtonDriver.hpp in Headers */, 259731862738B01F00A7F7C1 /* SurfaceACAdapter.hpp in Headers */, - 25CDE610285F27A7003FB4C4 /* SurfaceManagementEngineDriver.hpp in Headers */, - 25DFC01C2877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.hpp in Headers */, - 25CDE60D285F27A7003FB4C4 /* IPTSKenerlUserShared.h in Headers */, 2597317D2738B01F00A7F7C1 /* KeyImplementations.hpp in Headers */, 25C8D7EB27359FCD00F58956 /* SerialProtocol.h in Headers */, - 25CDE609285F27A7003FB4C4 /* SurfaceManagementEngineClient.hpp in Headers */, - 25CDE613285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.hpp in Headers */, - 25DFC00F2877EF8B00EA6990 /* VoodooI2CMultitouchInterface.hpp in Headers */, + 25E5B4CE2991ACE7007F21D4 /* MEIProtocol.h in Headers */, 25C8D7ED27359FCD00F58956 /* SurfaceSerialHubDriver.hpp in Headers */, - 25DFC0192877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.h in Headers */, 25DBA9752836A77700459629 /* SurfaceHIDNub.hpp in Headers */, - 25CDE612285F27A7003FB4C4 /* MEIProtocol.h in Headers */, 259040EC26FC0BB200D605D0 /* HIDReport.hpp in Headers */, - 25DE0A69283738EC002DA176 /* SurfaceHIDDriver.hpp in Headers */, - 25DFC0142877EF8B00EA6990 /* VoodooI2CNativeEngine.hpp in Headers */, - 25DFC0432877F2F200EA6990 /* VoodooI2CHIDDevice.hpp in Headers */, - 25DFC0112877EF8B00EA6990 /* VoodooI2CMultitouchEngine.hpp in Headers */, - 25DFC0172877EF8B00EA6990 /* AverageClasses.h in Headers */, - 25DE0A8E28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.hpp in Headers */, - 25CDE611285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.hpp in Headers */, + 25E5B4CB2991ACE7007F21D4 /* SurfaceManagementEngineClient.hpp in Headers */, 259040EA26FC065400D605D0 /* SurfaceButtonDevice.hpp in Headers */, - 25B97E1E260B9F1100657C76 /* SurfaceTypeCoverDriver.hpp in Headers */, + 25E5B4CD2991ACE7007F21D4 /* SurfaceManagementEngineDriver.hpp in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -736,9 +524,9 @@ ); dependencies = ( 25D49D8F2854EE92008CAAA5 /* PBXTargetDependency */, - 25CDE626285F2972003FB4C4 /* PBXTargetDependency */, - 25D49D8D2854EE8E008CAAA5 /* PBXTargetDependency */, 25CBB36B2733D50A009B568B /* PBXTargetDependency */, + 25CDE626285F2972003FB4C4 /* PBXTargetDependency */, + 25E5B47F29919F2C007F21D4 /* PBXTargetDependency */, ); name = BigSurface; productName = VoodooI2C; @@ -751,7 +539,7 @@ AC2603A71F2F294000CF238F /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1250; + LastUpgradeCheck = 1410; ORGANIZATIONNAME = "Xia Shangning"; TargetAttributes = { 25B97D6F260B950E00657C76 = { @@ -773,12 +561,12 @@ projectDirPath = ""; projectReferences = ( { - ProductGroup = 25CBB35C2733D4C1009B568B /* Products */; - ProjectRef = 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */; + ProductGroup = 25E5B47629919DCB007F21D4 /* Products */; + ProjectRef = 25E5B47529919DCB007F21D4 /* BigSurfaceHIDDriver.xcodeproj */; }, { - ProductGroup = 25CBB3572733D4B8009B568B /* Products */; - ProjectRef = 25B97DBF260B972000657C76 /* VoodooI2CServices.xcodeproj */; + ProductGroup = 25CBB35C2733D4C1009B568B /* Products */; + ProjectRef = 25B97DB8260B971000657C76 /* VoodooGPIO.xcodeproj */; }, { ProductGroup = AC94C8392119E50400D26081 /* Products */; @@ -801,13 +589,6 @@ /* End PBXProject section */ /* Begin PBXReferenceProxy section */ - 25CBB35B2733D4B8009B568B /* VoodooI2CServices.kext */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = VoodooI2CServices.kext; - remoteRef = 25CBB35A2733D4B8009B568B /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; 25CBB3602733D4C1009B568B /* VoodooGPIO.kext */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; @@ -829,6 +610,13 @@ remoteRef = 25CDE61D285F291D003FB4C4 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 25E5B47A29919DCC007F21D4 /* BigSurfaceHIDDriver.kext */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = BigSurfaceHIDDriver.kext; + remoteRef = 25E5B47929919DCC007F21D4 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; AC94C83D2119E50400D26081 /* VoodooI2CSynaptics.kext */ = { isa = PBXReferenceProxy; fileType = wrapper.cfbundle; @@ -851,6 +639,7 @@ /* Begin PBXShellScriptBuildPhase section */ 25B97DA1260B950E00657C76 /* Add Plugins */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -861,7 +650,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "mkdir -p \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooGPIO.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooGPIO.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooInput.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooInput.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooI2CServices.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooI2CServices.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooSerial.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooSerial.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n"; + shellScript = "mkdir -p \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooGPIO.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooGPIO.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooSerial.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooSerial.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/VoodooInput.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/VoodooInput.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n\nrm -rf \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns/BigSurfaceHIDDriver.kext\"\nmv \"${BUILT_PRODUCTS_DIR}/BigSurfaceHIDDriver.kext\" \"${BUILT_PRODUCTS_DIR}/BigSurface.kext/Contents/PlugIns\"\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -872,39 +661,19 @@ buildActionMask = 2147483647; files = ( 25DBA9742836A77700459629 /* SurfaceHIDNub.cpp in Sources */, - 25B97E1A260B9F1100657C76 /* VoodooI2CMultitouchHIDEventDriver.cpp in Sources */, - 25B97E2B260BA12100657C76 /* VoodooI2CHIDTransducerWrapper.cpp in Sources */, 259731812738B01F00A7F7C1 /* BatteryManager.cpp in Sources */, 25C8D7EC27359FCD00F58956 /* SurfaceSerialHubDriver.cpp in Sources */, - 25DFC0232877EF8C00EA6990 /* VoodooI2CDigitiserStylus.cpp in Sources */, 25D9072A2736E2B2006D799F /* AmbientLightValue.cpp in Sources */, - 25DFC0202877EF8C00EA6990 /* VoodooI2CDigitiserTransducer.cpp in Sources */, - 25DFC0222877EF8C00EA6990 /* VoodooI2CMultitouchEngine.cpp in Sources */, - 25DFC01A2877EF8B00EA6990 /* VoodooCSGestureHIPointingWrapper.cpp in Sources */, - 25DFC0212877EF8C00EA6990 /* VoodooI2CMultitouchInterface.cpp in Sources */, 259040E926FC065400D605D0 /* SurfaceButtonDevice.cpp in Sources */, 2518A2F72734F6AA00B0D631 /* SurfaceAmbientLightSensorDriver.cpp in Sources */, - 25DFC01B2877EF8B00EA6990 /* csgesturescroll.cpp in Sources */, 259731822738B01F00A7F7C1 /* SurfaceBattery.cpp in Sources */, - 25CDE615285F27A7003FB4C4 /* SurfaceManagementEngineClient.cpp in Sources */, - 25DFC01D2877EF8B00EA6990 /* VoodooI2CCSGestureEngine.cpp in Sources */, - 25CDE60E285F27A7003FB4C4 /* VoodooI2CTouchscreenHIDEventDriver.cpp in Sources */, + 25E5B4CC2991ACE7007F21D4 /* SurfaceManagementEngineDriver.cpp in Sources */, 259731882738B01F00A7F7C1 /* SurfaceBatteryDriver.cpp in Sources */, - 25DFC0182877EF8B00EA6990 /* VoodooCSGestureHIDWrapper.cpp in Sources */, - 25DE0A6A283738EC002DA176 /* SurfaceHIDDriver.cpp in Sources */, 25EA2A7E2836412B00525325 /* SurfaceBatteryNub.cpp in Sources */, 259731852738B01F00A7F7C1 /* KeyImplementations.cpp in Sources */, - 25CDE614285F27A7003FB4C4 /* IntelPreciseTouchStylusDriver.cpp in Sources */, 2597318D2738B2BA00A7F7C1 /* SurfaceSMBusController.cpp in Sources */, - 25DE0A8D28379886002DA176 /* VoodooI2CPrecisionTouchpadHIDEventDriver.cpp in Sources */, - 25B97E1B260B9F1100657C76 /* SurfaceTypeCoverDriver.cpp in Sources */, - 25CDE60C285F27A7003FB4C4 /* IntelPreciseTouchStylusUserClient.cpp in Sources */, - 25CDE60B285F27A7003FB4C4 /* SurfaceManagementEngineDriver.cpp in Sources */, - 25DFC0442877F2F200EA6990 /* VoodooI2CHIDDevice.cpp in Sources */, + 25E5B4CF2991ACE7007F21D4 /* SurfaceManagementEngineClient.cpp in Sources */, 2597317E2738B01F00A7F7C1 /* SurfaceACAdapter.cpp in Sources */, - 25CDE60A285F27A7003FB4C4 /* SurfaceTouchScreenDevice.cpp in Sources */, - 25DFC0132877EF8B00EA6990 /* VoodooI2CNativeEngine.cpp in Sources */, - 25DE0A912837BC4C002DA176 /* SurfaceHIDDevice.cpp in Sources */, 2524C0A626F3233A00CAAF12 /* SurfaceButtonDriver.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -922,16 +691,16 @@ name = VoodooInput; targetProxy = 25CDE625285F2972003FB4C4 /* PBXContainerItemProxy */; }; - 25D49D8D2854EE8E008CAAA5 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = VoodooI2CServices; - targetProxy = 25D49D8C2854EE8E008CAAA5 /* PBXContainerItemProxy */; - }; 25D49D8F2854EE92008CAAA5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = VoodooGPIO; targetProxy = 25D49D8E2854EE92008CAAA5 /* PBXContainerItemProxy */; }; + 25E5B47F29919F2C007F21D4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = BigSurfaceHIDDriver; + targetProxy = 25E5B47E29919F2C007F21D4 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -939,16 +708,18 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_DEADCODE_DEADSTORES = NO; + CLANG_ANALYZER_DEADCODE_DEADSTORES = YES; CLANG_ANALYZER_DIVIDE_BY_ZERO = NO; CLANG_ANALYZER_NULL_DEREFERENCE = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1.1.0; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = K8RXBXZGN4; GCC_OPTIMIZATION_LEVEL = 0; HEADER_SEARCH_PATHS = ( @@ -958,15 +729,16 @@ "$(PROJECT_DIR)/../Dependencies/Lilu.kext/Contents/Resources/", ); INFOPLIST_FILE = BigSurface/Info.plist; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2021 Xia Shangning. All rights reserved."; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/../MacKernelSDK/Library/x86_64", ); + MACOSX_DEPLOYMENT_TARGET = 10.12; MARKETING_VERSION = 1.1.0; MODULE_NAME = com.xavier.BigSurface; MODULE_VERSION = 1.0.6; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - "OTHER_CPLUSPLUSFLAGS[arch=*]" = "-Wno-inconsistent-missing-override"; PRODUCT_BUNDLE_IDENTIFIER = com.xavier.BigSurface; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -979,13 +751,16 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_DEADCODE_DEADSTORES = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO; CODE_SIGN_IDENTITY = "-"; CODE_SIGN_INJECT_BASE_ENTITLEMENTS = YES; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1.1.0; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = K8RXBXZGN4; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; GCC_OPTIMIZATION_LEVEL = fast; @@ -996,15 +771,16 @@ "$(PROJECT_DIR)/../Dependencies/Lilu.kext/Contents/Resources/", ); INFOPLIST_FILE = BigSurface/Info.plist; + INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2021 Xia Shangning. All rights reserved."; LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/../MacKernelSDK/Library/x86_64", ); + MACOSX_DEPLOYMENT_TARGET = 10.12; MARKETING_VERSION = 1.1.0; MODULE_NAME = com.xavier.BigSurface; MODULE_VERSION = 1.0.6; ONLY_ACTIVE_ARCH = YES; - "OTHER_CPLUSPLUSFLAGS[arch=*]" = "-Wno-inconsistent-missing-override"; PRODUCT_BUNDLE_IDENTIFIER = com.xavier.BigSurface; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1019,7 +795,6 @@ ARCHS = x86_64; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -1041,11 +816,11 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1065,10 +840,12 @@ GCC_WARN_UNUSED_VARIABLE = YES; KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../MacKernelSDK/Headers"; KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/../MacKernelSDK/Headers"; - MACOSX_DEPLOYMENT_TARGET = 10.15; - MTL_ENABLE_DEBUG_INFO = YES; + MACOSX_DEPLOYMENT_TARGET = 10.12; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; + WARNING_CFLAGS = ""; }; name = Debug; }; @@ -1079,7 +856,6 @@ ARCHS = x86_64; CLANG_ANALYZER_NONNULL = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; @@ -1101,11 +877,11 @@ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -1120,9 +896,11 @@ GCC_WARN_UNUSED_VARIABLE = YES; KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../MacKernelSDK/Headers"; KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/../MacKernelSDK/Headers"; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 10.12; MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; SDKROOT = macosx; + WARNING_CFLAGS = ""; }; name = Release; }; diff --git a/BigSurface/BigSurface.xcodeproj/xcshareddata/xcschemes/BigSurface.xcscheme b/BigSurface/BigSurface.xcodeproj/xcshareddata/xcschemes/BigSurface.xcscheme index 8a70347..953542f 100644 --- a/BigSurface/BigSurface.xcodeproj/xcshareddata/xcschemes/BigSurface.xcscheme +++ b/BigSurface/BigSurface.xcodeproj/xcshareddata/xcschemes/BigSurface.xcscheme @@ -1,6 +1,6 @@ CFBundleDevelopmentRegion - en + $(DEVELOPMENT_LANGUAGE) CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier @@ -13,432 +13,13 @@ CFBundleName $(PRODUCT_NAME) CFBundlePackageType - KEXT + $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) IOKitPersonalities - Custom MT2 Personality - - ApplePreferenceCapability - 2 - ApplePreferenceIdentifier - com.apple.AppleMultitouchTrackpad - ApplePreferencesDefaultPreferences - - ActuateDetents - 0 - Clicking - 1 - DragLock - 0 - Dragging - 0 - FirstClickThreshold - 1 - ForceSuppressed - - SecondClickThreshold - 1 - TrackpadCornerSecondaryClick - 0 - TrackpadFiveFingerPinchGesture - 2 - TrackpadFourFingerHorizSwipeGesture - 2 - TrackpadFourFingerPinchGesture - 2 - TrackpadFourFingerVertSwipeGesture - 2 - TrackpadHorizScroll - 1 - TrackpadMomentumScroll - - TrackpadPinch - 1 - TrackpadRightClick - - TrackpadRotate - 1 - TrackpadScroll - - TrackpadThreeFingerDrag - - TrackpadThreeFingerHorizSwipeGesture - 2 - TrackpadThreeFingerVertSwipeGesture - 2 - - CFBundleIdentifier - com.apple.driver.AppleTopCaseHIDEventDriver - DefaultMultitouchProperties - - ActuationSupported - - ExtractAndPostDeviceButtonState - - ForceSupported - - HIDServiceSupport - - IOCFPlugInTypes - - 0516B563-B15B-11DA-96EB-0014519758EF - AppleMultitouchDriver.kext/Contents/PlugIns/MultitouchHID.plugin - - MT Built-In - - MTHIDDevice - - MTPowerStatsDisable - - SupportsGestureScrolling - - TrackpadFourFingerGestures - - TrackpadMomentumScroll - - TrackpadSecondaryClickCorners - - TrackpadThreeFingerDrag - - parser-options - 39 - parser-type - 1000 - - DeviceUsagePairs - - - DeviceUsage - 2 - DeviceUsagePage - 1 - - - DoReportIntervalHack - - HIDAccelCurves - - - HIDAccelGainLinear - 65536 - HIDAccelIndex - 0 - HIDAccelTangentSpeedLinear - 484966 - HIDAccelTangentSpeedParabolicRoot - 1376256 - - - HIDAccelGainCubic - 5243 - HIDAccelGainLinear - 64881 - HIDAccelGainParabolic - 32768 - HIDAccelIndex - 8192 - HIDAccelTangentSpeedLinear - 478413 - HIDAccelTangentSpeedParabolicRoot - 1310720 - - - HIDAccelGainCubic - 6554 - HIDAccelGainLinear - 64225 - HIDAccelGainParabolic - 43254 - HIDAccelIndex - 32768 - HIDAccelTangentSpeedLinear - 471859 - HIDAccelTangentSpeedParabolicRoot - 1245184 - - - HIDAccelGainCubic - 7864 - HIDAccelGainLinear - 62915 - HIDAccelGainParabolic - 54395 - HIDAccelIndex - 45056 - HIDAccelTangentSpeedLinear - 465306 - HIDAccelTangentSpeedParabolicRoot - 1179648 - - - HIDAccelGainCubic - 9830 - HIDAccelGainLinear - 61604 - HIDAccelGainParabolic - 65536 - HIDAccelIndex - 57344 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 1114112 - - - HIDAccelGainCubic - 11796 - HIDAccelGainLinear - 60293 - HIDAccelGainParabolic - 75366 - HIDAccelIndex - 65536 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 1048576 - - - HIDAccelGainCubic - 13763 - HIDAccelGainLinear - 58327 - HIDAccelGainParabolic - 85197 - HIDAccelIndex - 98304 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 983040 - - - HIDAccelGainCubic - 15729 - HIDAccelGainLinear - 56361 - HIDAccelGainParabolic - 95027 - HIDAccelIndex - 131072 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 917504 - - - HIDAccelGainCubic - 18350 - HIDAccelGainLinear - 54395 - HIDAccelGainParabolic - 108790 - HIDAccelIndex - 163840 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 851968 - - - HIDAccelGainCubic - 23593 - HIDAccelGainLinear - 65536 - HIDAccelGainParabolic - 123208 - HIDAccelIndex - 196608 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDDisallowRemappingOfPrimaryClick - - HIDPointerAccelerationTable - AACAAFVTQioABwAAAAAAAgAEAAAABAAAABAAAAAQAAAAACAAAA0AAIAAAACAAAABQAAAAYAAAAIAAAAC4AAAAwAAAATgAAAEAAAAB0AAAAUAAAAKAAAABgAAAA1AAAAIAAAAFgAAAArAAAAjAAAADQAAAC8AAAAOwAAAOMAAABBAAABBAAAAEcAAAEjAAAAAUAAADwAAgAAAAIAAAAEAAAABQAAAAYAAAAJAAAACAAAAA4AAAAKAAAAE4AAAAwAAAAZgAAAEAAAACgAAAAUAAAAOQAAABgAAABNAAAAIAAAAHsAAAArAAAAuwAAADQAAADyAAAAOwAAARwAAABBAAABPwAAAEcAAAFiAAAAAgAAADwAAgAAAAIAAAAEAAAABYAAAAYAAAAKgAAACAAAABEAAAAKAAAAGAAAAAwAAAAgAAAAEAAAADQAAAAUAAAASwAAABgAAABkAAAAIAAAAKAAAAArAAAA7wAAADQAAAEuAAAAOwAAAV0AAABBAAABgQAAAEcAAAGkAAAAAsAAADwAAgAAAAIAAAAEAAAABoAAAAYAAAAMAAAACAAAABQAAAAKAAAAHQAAAAwAAAAnAAAAEAAAAEEAAAAUAAAAXgAAABgAAAB/AAAAIAAAAMgAAAArAAABKAAAADQAAAFyAAAAOwAAAaQAAABBAAABywAAAEcAAAHrAAAAA4AAADwAAgAAAAKAAAAEAAAABwAAAAYAAAANgAAACAAAABeAAAAKAAAAIoAAAAwAAAAvAAAAEAAAAE8AAAAUAAAAdQAAABgAAACfAAAAIAAAAPcAAAArAAABZAAAADQAAAG3AAAAOwAAAe0AAABBAAACFQAAAEcAAAIxAAAABAAAADwAAgAAAAMAAAAEAAAACAAAAAYAAAAPgAAACAAAABsAAAAKAAAAKQAAAAwAAAA5gAAAEAAAAGMAAAAUAAAAkwAAABgAAADLAAAAIAAAATUAAAArAAABugAAADQAAAIMAAAAOwAAAj0AAABBAAACXAAAAEcAAAJxA - HIDPointerAccelerationType - HIDTrackpadAcceleration - HIDScrollAccelCurves - - - HIDAccelGainLinear - 65536 - HIDAccelIndex - 0 - HIDAccelTangentSpeedLinear - 393216 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 62259 - HIDAccelGainParabolic - 39322 - HIDAccelIndex - 8192 - HIDAccelTangentSpeedLinear - 406323 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 58982 - HIDAccelGainParabolic - 58982 - HIDAccelIndex - 32768 - HIDAccelTangentSpeedLinear - 419430 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 55706 - HIDAccelGainParabolic - 78643 - HIDAccelIndex - 45056 - HIDAccelTangentSpeedLinear - 432538 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 52429 - HIDAccelGainParabolic - 91750 - HIDAccelIndex - 57344 - HIDAccelTangentSpeedLinear - 445645 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 49152 - HIDAccelGainParabolic - 104858 - HIDAccelIndex - 65536 - HIDAccelTangentSpeedLinear - 458752 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 45875 - HIDAccelGainParabolic - 117965 - HIDAccelIndex - 98304 - HIDAccelTangentSpeedLinear - 471859 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 42598 - HIDAccelGainParabolic - 131072 - HIDAccelIndex - 131072 - HIDAccelTangentSpeedLinear - 484966 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 39322 - HIDAccelGainParabolic - 144179 - HIDAccelIndex - 163840 - HIDAccelTangentSpeedLinear - 498074 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDAccelGainLinear - 36045 - HIDAccelGainParabolic - 157286 - HIDAccelIndex - 196608 - HIDAccelTangentSpeedLinear - 511181 - HIDAccelTangentSpeedParabolicRoot - 786432 - - - HIDScrollAccelerationTable - AACAAFVTQioABwAAAAAAAQABAAAAAQAAAAAgAAAQAABxOwAATOMAAwAAAAdgAAAEwAAADoAAAAbxSgAX6V4ACVeCACMQWgALZ6EALBF7AA2N1AA03ToAD36aADvQuAASWKAARl01ABUAAABO2dgAF8AAAFXK7QAas+UAW2FQAB2QAABe0qoAIL75AGEgywAkLXsAYnXvACewAABjRl8AAIAAABMAAHE7AABWfwABAAAAAuAAAAIAAAAJYAAAAwAAABIAAAAEwAAAIMAAAAaAAAAwgAAACGp5AEH9tgAK7bUAV4ZuAA0B2ABrPTkADv1/AIEEcAAQy5gAkdRWABJouQCe3VAAE+c/AKikCgAXAucAtn2SABot3ADARE4AHVjQAMX4OgAg35IAytuYACQ4bgDO7mUAJ6CXANIwowAAsAAAFAAAcTsAAGFOAADAAAABwAAAAQAAAANgAAACAAAADCAAAAMAAAAW4AAABMAAACnAAAAGQAAAOsAAAAfOggBP7OcACgWAAGo8rgAL658AhMCkAA2RCwCfR+EADzjIALWDbwAQ/k8AxqbEABLNUQDUeCMAFepmAOTKxwAZoVYA8qFmAB1CvwD7fXwAIQuCAQFpdAAkS20BBVKIACegAAEIK4wAAOAAABQAAHE7AABtdwAAwAAAAeAAAAEAAAAD4AAAAgAAAA6AAAADAAAAHEAAAATAAAA0AAAABgAAAEdAAAAHN4wAXL7hAAkAAACAwAAACoAAAKGAAAALz7IAvU7UAA01yQDadikADvtPAPKF4gARLu4BCSWiABUlDwEfV8QAGT9oASzRKgAdChkBNQrGACDz5QE6cR4AJEARAT3XdgAnn1YBQMHWAABQAAATAABxOwAAS7AAAQAAAAJgAAACAAAABuAAAAMAAAAMYAAABMAAABcAAAAGwAAAJAAAAAkAAAAyAAAACz1uAEFngAANcE8AUMGhAA+sTQBgSTMAEagdAG5NTAATT9YAd9WQABTQfgB+26MAF3odAIbYXQAagocAjp+lAB2J6QCTvnkAIN/yAJdcWwAkO0IAmYu9ACegOACacdcAAQAAABUAAHE7AABWfwAAwAAAAiAAAAEAAAAEgAAAAYAAAAqAAAACAAAAEaAAAAMAAAAhgAAABMAAAD6AAAAFwAAAVEAAAAbAAABrAAAACAAAAIxAAAAJAAAAqYAAAApAAADKwAAAC8AAAPTAAAANwAABJAAAABAAAAFEn9IAFEAAAV49zAAZAAABbrsYABzQAAFz78AAIOAAAXhvwAAkIAABem/AACegAAF8JGg= - HIDScrollAccelerationType - HIDTrackpadScrollAcceleration - HIDScrollResolution - 26214400 - IOCFPlugInTypes - - 0516B563-B15B-11DA-96EB-0014519758EF - AppleMultitouchDriver.kext/Contents/PlugIns/MultitouchHID.plugin - - IOClass - AppleMultitouchTrackpadHIDEventDriver - IOProbeScore - 9999 - IOProviderClass - IOHIDInterface - MTEventSource - - ProductIDArray - - 628 - - TrackpadEmbedded - - VendorID - 1452 - - Intel Precise Touch & Stylus Driver - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - IntelPreciseTouchStylusDriver - IOPropertyMatch - - MEIClientUUID - 3e8d0870-271a-4208-8eb5-9acb9402ae04 - - IOProviderClass - SurfaceManagementEngineClient - IOUserClientClass - IntelPreciseTouchStylusUserClient - - Native Multitouch Engine - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - VoodooI2CNativeEngine - IOProviderClass - VoodooI2CMultitouchInterface - Surface Ambient Light Sensor CFBundleIdentifier @@ -490,15 +71,6 @@ IOProviderClass IOACPIPlatformDevice - Surface HID - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - SurfaceHIDDriver - IOProviderClass - SurfaceHIDNub - Surface Management Engine CFBundleIdentifier @@ -525,102 +97,9 @@ IOProviderClass IOACPIPlatformDevice - Surface Touchpad HID Event Driver - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - DeviceUsagePairs - - - DeviceUsage - 5 - DeviceUsagePage - 13 - - - IOClass - VoodooI2CPrecisionTouchpadHIDEventDriver - IOProbeScore - 400 - IOProviderClass - IOHIDInterface - ProcessBluetoothMouseStopsTrackpad - - ProcessUSBMouseStopsTrackpad - - QuietTimeAfterTyping - 400 - - Surface Touchscreen HID Event Driver - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - DeviceUsagePairs - - - DeviceUsage - 4 - DeviceUsagePage - 13 - - - IOClass - VoodooI2CTouchscreenHIDEventDriver - IOProbeScore - 400 - IOProviderClass - IOHIDInterface - - Surface Type Cover - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - DeviceUsagePairs - - - DeviceUsage - 5 - DeviceUsagePage - 13 - - - IOClass - SurfaceTypeCoverDriver - IOProbeScore - 500 - IOPropertyMatch - - Transport - USB - - IOProviderClass - IOHIDInterface - ProcessBluetoothMouseStopsTrackpad - - ProcessUSBMouseStopsTrackpad - - QuietTimeAfterTyping - 400 - - VoodooI2CHIDDevice - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - VoodooI2CHIDDevice - IOProbeScore - 100 - IOPropertyMatch - - compatible - PNP0C50 - - IOProviderClass - VoodooI2CDeviceNub - NSHumanReadableCopyright - Copyright © 2021 Xavier Xia. All rights reserved. + Copyright © 2021 Xia Shangning. All rights reserved. OSBundleCompatibleVersion 1.0.0 OSBundleLibraries @@ -629,8 +108,6 @@ 1.2.0 as.vit9696.VirtualSMC 1.2.0 - com.alexandred.VoodooI2CServices - 1.0 com.apple.iokit.IOACPIFamily 1.4 com.apple.iokit.IOHIDFamily diff --git a/BigSurface/BigSurface/SurfaceBattery/SurfaceBatteryDriver.cpp b/BigSurface/BigSurface/SurfaceBattery/SurfaceBatteryDriver.cpp index 362844e..5e0454d 100644 --- a/BigSurface/BigSurface/SurfaceBattery/SurfaceBatteryDriver.cpp +++ b/BigSurface/BigSurface/SurfaceBattery/SurfaceBatteryDriver.cpp @@ -339,9 +339,10 @@ bool SurfaceBatteryDriver::vsmcNotificationHandler(void *sensors, void *refCon, } void SurfaceBatteryDriver::stop(IOService *provider) { - PMstop(); - releaseResources(); - super::stop(provider); +// PMstop(); +// releaseResources(); +// super::stop(provider); + PANIC("SurfaceBatteryDriver", "called stop!!!"); } void SurfaceBatteryDriver::releaseResources() { diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.cpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.cpp deleted file mode 100644 index 1322f8a..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// -// VoodooI2CHIDTransducerWrapper.cpp -// VoodooI2CHID -// -// Created by Alexandre on 02/01/2018. -// Copyright © 2018 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CHIDTransducerWrapper.hpp" - -#define super OSObject -OSDefineMetaClassAndStructors(VoodooI2CHIDTransducerWrapper, OSObject); - -bool VoodooI2CHIDTransducerWrapper::init() { - if (!super::init()) - return false; - - transducers = OSArray::withCapacity(4); - if (!transducers) - return false; - - return true; -} - -void VoodooI2CHIDTransducerWrapper::free() { - OSSafeReleaseNULL(transducers); - - super::free(); -} - -VoodooI2CHIDTransducerWrapper* VoodooI2CHIDTransducerWrapper::wrapper() { - VoodooI2CHIDTransducerWrapper* wrapper = OSTypeAlloc(VoodooI2CHIDTransducerWrapper); - - if (!wrapper || !wrapper->init()) - OSSafeReleaseNULL(wrapper); - - return wrapper; -} diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.hpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.hpp deleted file mode 100644 index 08b60ae..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CHIDTransducerWrapper.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// VoodooI2CHIDTransducerWrapper.hpp -// VoodooI2CHID -// -// Created by Alexandre on 02/01/2018. -// Copyright © 2018 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CHIDTransducerWrapper_hpp -#define VoodooI2CHIDTransducerWrapper_hpp - -#include -#include -#include - -#include - -#include "../../SurfaceMultitouch/VoodooI2CDigitiserTransducer.hpp" - -class EXPORT VoodooI2CHIDTransducerWrapper : public OSObject { - OSDeclareDefaultStructors(VoodooI2CHIDTransducerWrapper); - - public: - OSArray* transducers; - - bool init() override; - void free() override; - - static VoodooI2CHIDTransducerWrapper* wrapper(); -}; - - -#endif /* VoodooI2CHIDTransducerWrapper_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.cpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.cpp deleted file mode 100644 index 5b1f97d..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.cpp +++ /dev/null @@ -1,967 +0,0 @@ -// -// VoodooI2CMultitouchHIDEventDriver.cpp -// VoodooI2CHID -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CMultitouchHIDEventDriver.hpp" -#include -#include -#include -#include -#include - -#define GetReportType(type) \ -((type <= kIOHIDElementTypeInput_ScanCodes) ? kIOHIDReportTypeInput : \ -(type <= kIOHIDElementTypeOutput) ? kIOHIDReportTypeOutput : \ -(type <= kIOHIDElementTypeFeature) ? kIOHIDReportTypeFeature : -1) - -#define super IOHIDEventService -OSDefineMetaClassAndStructors(VoodooI2CMultitouchHIDEventDriver, IOHIDEventService); - -AbsoluteTime last_multi_touch_event = 0; - -static int scientific_pow(UInt32 significand, UInt32 base, SInt32 exponent) { - UInt32 ret = significand; - while (exponent > 0) { - ret *= base; - exponent--; - } - - while (exponent < 0) { - ret /= base; - exponent++; - } - - return ret; -} - -void VoodooI2CMultitouchHIDEventDriver::calibrateJustifiedPreferredStateElement(IOHIDElement* element, SInt32 removal_percentage) { - UInt32 sat_min = element->getLogicalMin(); - UInt32 sat_max = element->getLogicalMax(); - UInt32 diff = ((sat_max - sat_min) * removal_percentage) / 200; - sat_min += diff; - sat_max -= diff; - - element->setCalibration(0, 1, sat_min, sat_max); -} - -bool VoodooI2CMultitouchHIDEventDriver::didTerminate(IOService* provider, IOOptionBits options, bool* defer) { - if (hid_interface) - hid_interface->close(this); - hid_interface = NULL; - - return super::didTerminate(provider, options, defer); -} - -void VoodooI2CMultitouchHIDEventDriver::forwardReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - if (multitouch_interface) - multitouch_interface->handleInterruptReport(event, timestamp); -} - -UInt32 VoodooI2CMultitouchHIDEventDriver::getElementValue(IOHIDElement* element) { - IOHIDElementCookie cookie = element->getCookie(); - - if (!cookie) - return 0; - - hid_device->updateElementValues(&cookie); - - return element->getValue(); -} - -const char* VoodooI2CMultitouchHIDEventDriver::getProductName() { - if (OSString* name = getProduct()) - return name->getCStringNoCopy(); - - return "Multitouch HID Device"; -} - -void VoodooI2CMultitouchHIDEventDriver::handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor* report, IOHIDReportType report_type, UInt32 report_id) { - // Touchpad is disabled through ApplePS2Keyboard request - if (ignore_all) - return; - - UInt64 now_abs; - clock_get_uptime(&now_abs); - UInt64 now_ns; - absolutetime_to_nanoseconds(now_abs, &now_ns); - - if (report_type == kIOHIDReportTypeInput && readyForReports()) - clock_get_uptime(&last_multi_touch_event); - - // Ignore touchpad interaction(s) shortly after typing - if (now_ns - key_time < max_after_typing) - return; - - if (!readyForReports() || report_type != kIOHIDReportTypeInput) - return; - - if (digitiser.contact_count && digitiser.contact_count->getValue()) { - digitiser.current_contact_count = digitiser.contact_count->getValue(); - - UInt8 finger_count = digitiser.fingers->getCount(); - - // Round up the result of division by finger_count - // This is equivalent to ceil(1.0f * digitiser.current_contact_count / finger_count) - digitiser.report_count = (digitiser.current_contact_count + finger_count - 1) / finger_count; - digitiser.current_report = 1; - } - - handleDigitizerReport(timestamp, report_id); - - if (digitiser.current_report == digitiser.report_count) { - VoodooI2CMultitouchEvent event; - event.contact_count = digitiser.current_contact_count; - event.transducers = digitiser.transducers; - - forwardReport(event, timestamp); - - digitiser.report_count = 1; - digitiser.current_report = 1; - } else { - digitiser.current_report++; - } -} - -void VoodooI2CMultitouchHIDEventDriver::handleDigitizerReport(AbsoluteTime timestamp, UInt32 report_id) { - if (!digitiser.transducers) - return; - - VoodooI2CHIDTransducerWrapper* wrapper; - - wrapper = OSDynamicCast(VoodooI2CHIDTransducerWrapper, digitiser.wrappers->getObject(digitiser.current_report - 1)); - - if (!wrapper) - return; - - for (int i = 0; i < wrapper->transducers->getCount(); i++) { - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, wrapper->transducers->getObject(i)); - if (transducer) { - handleDigitizerTransducerReport(transducer, timestamp, report_id); - } - } - - // Now handle button report - if (digitiser.primaryButton) { // there can't be secondary button without primary - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, digitiser.transducers->getObject(0)); - if (transducer) { - setButtonState(&transducer->physical_button, 0, digitiser.primaryButton->getValue(), timestamp); - if (digitiser.secondaryButton) { - setButtonState(&transducer->physical_button, 1, digitiser.secondaryButton->getValue(), timestamp); - } - } - } - - if (digitiser.styluses->getCount() > 0) { - // The stylus wrapper is the last one - wrapper = OSDynamicCast(VoodooI2CHIDTransducerWrapper, digitiser.wrappers->getLastObject()); - if (!wrapper) { - return; - } - - VoodooI2CDigitiserStylus* stylus = OSDynamicCast(VoodooI2CDigitiserStylus, wrapper->transducers->getObject(0)); - if (!stylus) { - return; - } - - IOHIDElement* element = OSDynamicCast(IOHIDElement, stylus->collection->getChildElements()->getObject(0)); - if (element && report_id == element->getReportID()) { - handleDigitizerTransducerReport(stylus, timestamp, report_id); - } - } -} - -void VoodooI2CMultitouchHIDEventDriver::handleDigitizerTransducerReport(VoodooI2CDigitiserTransducer* transducer, AbsoluteTime timestamp, UInt32 report_id) { - bool handled = false; - bool has_confidence = false; - UInt32 element_index = 0; - UInt32 element_count = 0; - - if (!transducer->collection) - return; - - OSArray* child_elements = transducer->collection->getChildElements(); - - if (!child_elements) - return; - - for (element_index=0, element_count=child_elements->getCount(); element_index < element_count; element_index++) { - IOHIDElement* element; - AbsoluteTime element_timestamp; - bool element_is_current; - UInt32 usage_page; - UInt32 usage; - UInt32 value; - - VoodooI2CDigitiserStylus* stylus = (VoodooI2CDigitiserStylus*)transducer; - - element = OSDynamicCast(IOHIDElement, child_elements->getObject(element_index)); - if (!element) - continue; - - element_timestamp = element->getTimeStamp(); - element_is_current = (element->getReportID() == report_id) && (CMP_ABSOLUTETIME(×tamp, &element_timestamp) == 0); - - transducer->id = report_id; - transducer->timestamp = element_timestamp; - - usage_page = element->getUsagePage(); - usage = element->getUsage(); - value = element->getValue(); - - switch (usage_page) { - case kHIDPage_GenericDesktop: - switch (usage) { - case kHIDUsage_GD_X: - { - transducer->coordinates.x.update(value, timestamp); - transducer->logical_max_x = element->getLogicalMax(); - handled |= element_is_current; - break; - } - case kHIDUsage_GD_Y: - { - transducer->coordinates.y.update(value, timestamp); - transducer->logical_max_y = element->getLogicalMax(); - handled |= element_is_current; - break; - } - case kHIDUsage_GD_Z: - { - transducer->coordinates.z.update(value, timestamp); - transducer->logical_max_z = element->getLogicalMax(); - handled |= element_is_current; - break; - } - } - break; - case kHIDPage_Button: - setButtonState(&transducer->physical_button, (usage - 1), value, timestamp); - handled |= element_is_current; - break; - case kHIDPage_Digitizer: - switch (usage) { - case kHIDUsage_Dig_TransducerIndex: - case kHIDUsage_Dig_ContactIdentifier: - transducer->secondary_id = value; - handled |= element_is_current; - break; - case kHIDUsage_Dig_Touch: - case kHIDUsage_Dig_TipSwitch: - setButtonState(&transducer->tip_switch, 0, value, timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_InRange: - transducer->in_range = value != 0; - handled |= element_is_current; - break; - case kHIDUsage_Dig_TipPressure: - case kHIDUsage_Dig_SecondaryTipSwitch: - { - transducer->tip_pressure.update(element->getValue(), timestamp); - transducer->pressure_physical_max = element->getPhysicalMax(); - handled |= element_is_current; - break; - } - case kHIDUsage_Dig_XTilt: - transducer->tilt_orientation.x_tilt.update(element->getScaledFixedValue(kIOHIDValueScaleTypePhysical), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_YTilt: - transducer->tilt_orientation.y_tilt.update(element->getScaledFixedValue(kIOHIDValueScaleTypePhysical), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_Azimuth: - transducer->azi_alti_orientation.azimuth.update(element->getValue(), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_Altitude: - transducer->azi_alti_orientation.altitude.update(element->getValue(), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_Twist: - transducer->azi_alti_orientation.twist.update(element->getScaledFixedValue(kIOHIDValueScaleTypePhysical), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_Width: - transducer->dimensions.width.update(element->getValue(), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_Height: - transducer->dimensions.height.update(element->getValue(), timestamp); - handled |= element_is_current; - break; - case kHIDUsage_Dig_DataValid: - case kHIDUsage_Dig_TouchValid: - case kHIDUsage_Dig_Quality: - if (value) - transducer->is_valid = true; - else - transducer->is_valid = false; - has_confidence = true; - handled |= element_is_current; - break; - case kHIDUsage_Dig_BarrelPressure: - if (stylus) { - stylus->barrel_pressure.update(element->getScaledFixedValue(kIOHIDValueScaleTypeCalibrated), timestamp); - handled |= element_is_current; - } - break; - case kHIDUsage_Dig_BarrelSwitch: - if (stylus) { - setButtonState(&stylus->barrel_switch, 1, value, timestamp); - handled |= element_is_current; - } - break; - case kHIDUsage_Dig_BatteryStrength: - if (stylus) { - stylus->battery_strength = element->getValue(); - handled |= element_is_current; - } - break; - case kHIDUsage_Dig_Eraser: - if (stylus) { - setButtonState(&stylus->eraser, 2, value, timestamp); - stylus->invert = value != 0; - handled |= element_is_current; - } - break; - case kHIDUsage_Dig_Invert: - if (stylus) { - stylus->invert = value != 0; - handled |= element_is_current; - } - break; - default: - break; - } - break; - } - } - - if (!has_confidence) - transducer->is_valid = true; - - if (!handled) - return; -} - -bool VoodooI2CMultitouchHIDEventDriver::handleStart(IOService* provider) { - if(!super::handleStart(provider)) { - return false; - } - - hid_interface = OSDynamicCast(IOHIDInterface, provider); - - if (!hid_interface) - return false; - - OSString* transport = hid_interface->getTransport(); - if (!transport) - return false; - - if (strncmp(transport->getCStringNoCopy(), kIOHIDTransportUSBValue, sizeof(kIOHIDTransportUSBValue)) != 0) - hid_interface->setProperty("VoodooI2CServices Supported", kOSBooleanTrue); - - hid_device = OSDynamicCast(IOHIDDevice, hid_interface->getParentEntry(gIOServicePlane)); - - if (!hid_device) - return false; - - name = getProductName(); - - OSObject* object = copyProperty(kIOHIDAbsoluteAxisBoundsRemovalPercentage, gIOServicePlane); - - OSNumber* number = OSDynamicCast(OSNumber, object); - - if (number) { - absolute_axis_removal_percentage = number->unsigned32BitValue(); - } - - OSSafeReleaseNULL(object); - - if (should_have_interface) - publishMultitouchInterface(); - - digitiser.fingers = OSArray::withCapacity(1); - - if (!digitiser.fingers) - return false; - - digitiser.styluses = OSArray::withCapacity(1); - - if (!digitiser.styluses) - return false; - - digitiser.transducers = OSArray::withCapacity(1); - - if (!digitiser.transducers) - return false; - - if (parseElements() != kIOReturnSuccess) { - IOLog("%s::%s Could not parse multitouch elements\n", getName(), name); - return false; - } - - if (!hid_interface->open(this, 0, OSMemberFunctionCast(IOHIDInterface::InterruptReportAction, this, &VoodooI2CMultitouchHIDEventDriver::handleInterruptReport), NULL)) - return false; - - setDigitizerProperties(); - - PMinit(); - hid_interface->joinPMtree(this); - registerPowerDriver(this, myIOPMPowerStates, kIOPMNumberPowerStates); - - return true; -} - -void VoodooI2CMultitouchHIDEventDriver::handleStop(IOService* provider) { - OSSafeReleaseNULL(digitiser.transducers); - OSSafeReleaseNULL(digitiser.wrappers); - OSSafeReleaseNULL(digitiser.styluses); - OSSafeReleaseNULL(digitiser.fingers); - - unregisterHIDPointerNotifications(); - OSSafeReleaseNULL(attached_hid_pointer_devices); - - if (multitouch_interface) { - multitouch_interface->stop(this); - multitouch_interface->detach(this); - OSSafeReleaseNULL(multitouch_interface); - } - - if (command_gate) { - work_loop->removeEventSource(command_gate); - OSSafeReleaseNULL(command_gate); - } - - OSSafeReleaseNULL(work_loop); - - PMstop(); - super::handleStop(provider); -} - -UInt32 VoodooI2CMultitouchHIDEventDriver::parseElementPhysicalMax(IOHIDElement* element) { - UInt32 physical_max = element->getPhysicalMax(); - - UInt8 raw_unit_exponent = element->getUnitExponent(); - if (raw_unit_exponent >> 3) { - raw_unit_exponent = raw_unit_exponent | 0xf0; // Raise the 4-bit int to an 8-bit int - } - SInt8 unit_exponent = *reinterpret_cast(&raw_unit_exponent); - - // Scale to 0.01 mm units - UInt32 unit = element->getUnit(); - if (unit == kHIDUsage_LengthUnitCentimeter) { - unit_exponent += 3; - } else if (unit == kHIDUsage_LengthUnitInch) { - physical_max *= 254; - unit_exponent += 1; - } - - physical_max = scientific_pow(physical_max, 10, unit_exponent); - return physical_max; -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::parseDigitizerElement(IOHIDElement* digitiser_element) { - OSArray* children = digitiser_element->getChildElements(); - - if (!children) - return kIOReturnNotFound; - - // Let's parse the configuration page first - if (digitiser_element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_DeviceConfiguration)) { - for (int i = 0; i < children->getCount(); i++) { - IOHIDElement* element = OSDynamicCast(IOHIDElement, children->getObject(i)); - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_Finger)) { - OSArray* sub_array = element->getChildElements(); - - for (int j = 0; j < sub_array->getCount(); j++) { - IOHIDElement* sub_element = OSDynamicCast(IOHIDElement, sub_array->getObject(j)); - - if (sub_element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_DeviceMode)) - digitiser.input_mode = sub_element; - } - } - } - - return kIOReturnSuccess; - } - - for (int i = 0; i < children->getCount(); i++) { - IOHIDElement* element = OSDynamicCast(IOHIDElement, children->getObject(i)); - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_Stylus)) { - digitiser.styluses->setObject(element); - setProperty("SupportsInk", 1, 32); - continue; - } - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_Finger)) { - digitiser.fingers->setObject(element); - - // Let's grab the logical and physical min/max while we are here - // also the contact identifier - - OSArray* sub_array = element->getChildElements(); - - for (int j = 0; j < sub_array->getCount(); j++) { - IOHIDElement* sub_element = OSDynamicCast(IOHIDElement, sub_array->getObject(j)); - - if (sub_element->conformsTo(kHIDPage_GenericDesktop, kHIDUsage_GD_X)) { - if (multitouch_interface && !multitouch_interface->logical_max_x) { - multitouch_interface->logical_max_x = sub_element->getLogicalMax(); - multitouch_interface->physical_max_x = parseElementPhysicalMax(sub_element); - } - } else if (sub_element->conformsTo(kHIDPage_GenericDesktop, kHIDUsage_GD_Y)) { - if (multitouch_interface && !multitouch_interface->logical_max_y) { - multitouch_interface->logical_max_y = sub_element->getLogicalMax(); - multitouch_interface->physical_max_y = parseElementPhysicalMax(sub_element); - } - } - } - - continue; - } - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_ContactCount)) { - digitiser.contact_count = element; - continue; - } - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_DeviceMode)) { - digitiser.input_mode = element; - continue; - } - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_ContactCountMaximum)) { - digitiser.contact_count_maximum = element; - continue; - } - - // On some machines (Namely Dell Latitude 7390 2-in-1) the primary button has kHIDUsage_Button_2, and the secondary button has kHIDUsage_Button_3 - // Address cases involving kHIDUsage_Button_3 - if (element->conformsTo(kHIDPage_Button) && element->getUsage() <= kHIDUsage_Button_3) { - if (digitiser.primaryButton == nullptr) { - digitiser.primaryButton = element; - } - else if (element->getUsage() > digitiser.primaryButton->getUsage()) { - // Candidate for a secondary button - if (digitiser.secondaryButton == nullptr || element->getUsage() < digitiser.secondaryButton->getUsage()) { - digitiser.secondaryButton = element; - } - } - else if (element->getUsage() < digitiser.primaryButton->getUsage()) { - // This is the new primary button. Old primary becomes secondary. - digitiser.secondaryButton = digitiser.primaryButton; - digitiser.primaryButton = element; - } - } - } - - return kIOReturnSuccess; -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::parseElements() { - int index, count; - - OSArray* supported_elements = OSDynamicCast(OSArray, hid_device->getProperty(kIOHIDElementKey)); - - if (!supported_elements) - return kIOReturnNotFound; - - for (index=0, count = supported_elements->getCount(); index < count; index++) { - IOHIDElement* element = NULL; - - element = OSDynamicCast(IOHIDElement, supported_elements->getObject(index)); - if (!element) - continue; - - if (element->getUsage() == 0) - continue; - - if (element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_Pen) - || element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_TouchScreen) - || element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_TouchPad) - || element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_DeviceConfiguration) - ) - parseDigitizerElement(element); - - if (multitouch_interface && element->conformsTo(kHIDPage_Digitizer, kHIDUsage_Dig_TouchScreen)) - multitouch_interface->setProperty(kIOHIDDisplayIntegratedKey, kOSBooleanTrue); - } - - if (digitiser.styluses->getCount() == 0 && digitiser.fingers->getCount() == 0) - return kIOReturnError; - - digitiser.wrappers = OSArray::withCapacity(1); - - if (digitiser.contact_count_maximum) { - UInt8 contact_count_maximum = getElementValue(digitiser.contact_count_maximum); - - // Check if maximum contact count divides by digitiser finger count - if (contact_count_maximum % digitiser.fingers->getCount() != 0) { - IOLog("%s::%s Unknown digitiser type: got %d finger collections and a %d maximum contact count, ignoring extra fingers\n", getName(), name, digitiser.fingers->getCount(), contact_count_maximum); - - // Remove extra fingers from digitiser's finger array if necessary - if (contact_count_maximum < digitiser.fingers->getCount()) { - while (contact_count_maximum % digitiser.fingers->getCount() != 0) - digitiser.fingers->removeObject(digitiser.fingers->getCount() - 1); - } - } - - int wrapper_count = contact_count_maximum / digitiser.fingers->getCount(); - - for (int i = 0; i < wrapper_count; i++) { - VoodooI2CHIDTransducerWrapper* wrapper = VoodooI2CHIDTransducerWrapper::wrapper(); - if(!digitiser.wrappers->setObject(wrapper)) { - IOLog("%s::%s Failed to add Transducer Wrapper to transducer array\n", getName(), name); - OSSafeReleaseNULL(wrapper); - return kIOReturnNoResources; - } - - for (int j = 0; j < digitiser.fingers->getCount(); j++) { - IOHIDElement* finger = OSDynamicCast(IOHIDElement, digitiser.fingers->getObject(j)); - - VoodooI2CDigitiserTransducer* transducer = VoodooI2CDigitiserTransducer::transducer(kDigitiserTransducerFinger, finger); - - wrapper->transducers->setObject(transducer); - transducer->release(); - digitiser.transducers->setObject(transducer); - } - - wrapper->release(); - } - } - - // Add stylus as the final wrapper - if (digitiser.styluses->getCount()) { - VoodooI2CHIDTransducerWrapper* stylus_wrapper = VoodooI2CHIDTransducerWrapper::wrapper(); - digitiser.wrappers->setObject(stylus_wrapper); - - IOHIDElement* stylus = OSDynamicCast(IOHIDElement, digitiser.styluses->getObject(0)); - VoodooI2CDigitiserStylus* transducer = VoodooI2CDigitiserStylus::stylus(kDigitiserTransducerStylus, stylus); - - stylus_wrapper->transducers->setObject(transducer); - transducer->release(); - digitiser.transducers->setObject(0, transducer); - stylus_wrapper->release(); - } - - return kIOReturnSuccess; -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::publishMultitouchInterface() { - multitouch_interface = OSTypeAlloc(VoodooI2CMultitouchInterface); - - if (!multitouch_interface || - !multitouch_interface->init(NULL) || - !multitouch_interface->attach(this)) - goto exit; - - if (!multitouch_interface->start(this)) { - multitouch_interface->detach(this); - goto exit; - } - - multitouch_interface->setProperty(kIOHIDVendorIDKey, getVendorID(), 32); - multitouch_interface->setProperty(kIOHIDProductIDKey, getProductID(), 32); - - multitouch_interface->setProperty(kIOHIDDisplayIntegratedKey, kOSBooleanFalse); - - multitouch_interface->registerService(); - - return kIOReturnSuccess; - -exit: - OSSafeReleaseNULL(multitouch_interface); - return kIOReturnError; -} - -inline void VoodooI2CMultitouchHIDEventDriver::setButtonState(DigitiserTransducerButtonState* state, UInt32 bit, UInt32 value, AbsoluteTime timestamp) { - UInt32 button_mask = 1 << bit; - UInt16 new_value = state->value(); - if (value != 0) - new_value |= button_mask; - else - new_value &= ~button_mask; - state->update(new_value, timestamp); -} - -void VoodooI2CMultitouchHIDEventDriver::setDigitizerProperties() { - if (!digitiser.transducers) - return; - - OSDictionary* properties = OSDictionary::withCapacity(5); - if (!properties) - return; - - properties->setObject("Contact Count Element", digitiser.contact_count); - properties->setObject("Input Mode Element", digitiser.input_mode); - properties->setObject("Contact Count Maximum Element", digitiser.contact_count_maximum); - properties->setObject("Primary Button Element", digitiser.primaryButton); - properties->setObject("Secondary Button Element", digitiser.secondaryButton); - setOSDictionaryNumber(properties, "Transducer Count", digitiser.transducers->getCount()); - - setProperty("Digitizer", properties); - - OSSafeReleaseNULL(properties); -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::setPowerState(unsigned long whichState, IOService* whatDevice) { - return kIOPMAckImplied; -} - -bool VoodooI2CMultitouchHIDEventDriver::start(IOService* provider) { - if (!super::start(provider)) - return false; - - work_loop = getWorkLoop(); - - if (!work_loop) - return false; - - work_loop->retain(); - - command_gate = IOCommandGate::commandGate(this); - if (!command_gate) { - return false; - } - work_loop->addEventSource(command_gate); - - attached_hid_pointer_devices = OSSet::withCapacity(1); - registerHIDPointerNotifications(); - - // Read QuietTimeAfterTyping configuration value (if available) - OSNumber* quietTimeAfterTyping = OSDynamicCast(OSNumber, getProperty("QuietTimeAfterTyping")); - - if (quietTimeAfterTyping != NULL) - max_after_typing = quietTimeAfterTyping->unsigned64BitValue() * 1000000; - - setProperty("VoodooI2CServices Supported", kOSBooleanTrue); - - return true; -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::message(UInt32 type, IOService* provider, void* argument) { - switch (type) { - case kKeyboardGetTouchStatus: - { -#if DEBUG - IOLog("%s::getEnabledStatus = %s\n", getName(), ignore_all ? "false" : "true"); -#endif - bool* pResult = (bool*)argument; - *pResult = !ignore_all; - break; - } - case kKeyboardSetTouchStatus: - { - bool enable = *((bool*)argument); -#if DEBUG - IOLog("%s::setEnabledStatus = %s\n", getName(), enable ? "true" : "false"); -#endif - // ignore_all is true when trackpad has been disabled - if (enable == ignore_all) { - // save state, and update LED - ignore_all = !enable; - } - break; - } - case kKeyboardKeyPressTime: - { - // Remember last time key was pressed - key_time = *((UInt64*)argument); -#if DEBUG - IOLog("%s::keyPressed = %llu\n", getName(), key_time); -#endif - break; - } - } - - return kIOReturnSuccess; -} - -IOReturn VoodooI2CMultitouchHIDEventDriver::setProperties(OSObject * properties) { - // Listen for property changes we are interested in (instead of reading these during frequent IO events) - OSDictionary* dict = OSDynamicCast(OSDictionary, properties); - - if (dict != NULL) { - if (OSCollectionIterator* i = OSCollectionIterator::withCollection(dict)) { - while (OSSymbol* key = OSDynamicCast(OSSymbol, i->getNextObject())) { - // System -> Preferences -> Accessibility -> Mouse & Trackpad -> Ignore built-in trackpad when mouse or wireless trackpad is present - // USBMouseStopsTrackpad - if (key->isEqualTo("USBMouseStopsTrackpad")) { - OSNumber* value = OSDynamicCast(OSNumber, dict->getObject(key)); - - if (value != NULL) { - IOLog("%s::setProperties %s = %d\n", getName(), key->getCStringNoCopy(), value->unsigned32BitValue()); - - ignore_mouse = (value->unsigned32BitValue() > 0); - - // If there are devices connected and automatically switch the current ignore status on/off - if (attached_hid_pointer_devices->getCount() > 0) { - ignore_all = ignore_mouse; - } - } - } - } - - i->release(); - } - } - - return super::setProperties(properties); -} - -void VoodooI2CMultitouchHIDEventDriver::registerHIDPointerNotifications() { - IOServiceMatchingNotificationHandler notificationHandler = OSMemberFunctionCast(IOServiceMatchingNotificationHandler, this, &VoodooI2CMultitouchHIDEventDriver::notificationHIDAttachedHandler); - - // Determine if we should listen for USB mouse attach events as per configuration - OSBoolean* isEnabled = OSDynamicCast(OSBoolean, getProperty("ProcessUSBMouseStopsTrackpad")); - - if (isEnabled && isEnabled->isTrue()) { - // USB mouse HID description as per USB spec: http://www.usb.org/developers/hidpage/HID1_11.pdf - OSDictionary* matchingDictionary = serviceMatching("IOUSBInterface"); - - propertyMatching(OSSymbol::withCString(kUSBInterfaceClass), OSNumber::withNumber(kUSBHIDInterfaceClass, 8), matchingDictionary); - propertyMatching(OSSymbol::withCString(kUSBInterfaceSubClass), OSNumber::withNumber(kUSBHIDBootInterfaceSubClass, 8), matchingDictionary); - propertyMatching(OSSymbol::withCString(kUSBInterfaceProtocol), OSNumber::withNumber(kHIDMouseInterfaceProtocol, 8), matchingDictionary); - - // Register for future services - usb_hid_publish_notify = addMatchingNotification(gIOFirstPublishNotification, matchingDictionary, notificationHandler, this, NULL, 10000); - usb_hid_terminate_notify = addMatchingNotification(gIOTerminatedNotification, matchingDictionary, notificationHandler, this, NULL, 10000); - OSSafeReleaseNULL(matchingDictionary); - } - - // Determine if we should listen for bluetooth mouse attach events as per configuration - isEnabled = OSDynamicCast(OSBoolean, getProperty("ProcessBluetoothMouseStopsTrackpad")); - - if (isEnabled && isEnabled->isTrue()) { - // Bluetooth HID devices - OSDictionary* matchingDictionary = serviceMatching("IOBluetoothHIDDriver"); - propertyMatching(OSSymbol::withCString(kIOHIDVirtualHIDevice), OSBoolean::withBoolean(false), matchingDictionary); - - // Register for future services - bluetooth_hid_publish_notify = addMatchingNotification(gIOFirstPublishNotification, matchingDictionary, notificationHandler, this, NULL, 10000); - bluetooth_hid_terminate_notify = addMatchingNotification(gIOTerminatedNotification, matchingDictionary, notificationHandler, this, NULL, 10000); - OSSafeReleaseNULL(matchingDictionary); - } -} - -void VoodooI2CMultitouchHIDEventDriver::unregisterHIDPointerNotifications() { - // Free device matching notifiers - if (usb_hid_publish_notify) { - usb_hid_publish_notify->remove(); - OSSafeReleaseNULL(usb_hid_publish_notify); - } - - if (usb_hid_terminate_notify) { - usb_hid_terminate_notify->remove(); - OSSafeReleaseNULL(usb_hid_terminate_notify); - } - - if (bluetooth_hid_publish_notify) { - bluetooth_hid_publish_notify->remove(); - OSSafeReleaseNULL(bluetooth_hid_publish_notify); - } - - if (bluetooth_hid_terminate_notify) { - bluetooth_hid_terminate_notify->remove(); - OSSafeReleaseNULL(bluetooth_hid_terminate_notify); - } - - OSSafeReleaseNULL(attached_hid_pointer_devices); -} - -void VoodooI2CMultitouchHIDEventDriver::notificationHIDAttachedHandlerGated(IOService * newService, IONotifier * notifier) { - char path[256]; - int len = 255; - memset(path, 0, len); - newService->getPath(path, &len, gIOServicePlane); - - if (notifier == usb_hid_publish_notify) { - IORegistryEntry* hid_child = OSDynamicCast(IORegistryEntry, newService->getChildEntry(gIOServicePlane)); - - if (!hid_child) - return; - - OSNumber* primary_usage_page = OSDynamicCast(OSNumber, hid_child->getProperty(kIOHIDPrimaryUsagePageKey)); - OSNumber* primary_usage= OSDynamicCast(OSNumber, hid_child->getProperty(kIOHIDPrimaryUsageKey)); - - if (!primary_usage_page || !primary_usage) - return; - - // ignore touchscreens - - if (primary_usage_page->unsigned8BitValue() != kHIDPage_Digitizer && primary_usage->unsigned8BitValue() != kHIDUsage_Dig_TouchScreen) { - attached_hid_pointer_devices->setObject(newService); - IOLog("%s: USB pointer HID device published: %s, # devices: %d\n", getName(), path, attached_hid_pointer_devices->getCount()); - } - } - - if (notifier == usb_hid_terminate_notify) { - attached_hid_pointer_devices->removeObject(newService); - IOLog("%s: USB pointer HID device terminated: %s, # devices: %d\n", getName(), path, attached_hid_pointer_devices->getCount()); - } - - if (notifier == bluetooth_hid_publish_notify) { - // Filter on specific CoD (Class of Device) bluetooth devices only - OSNumber* propDeviceClass = OSDynamicCast(OSNumber, newService->getProperty("ClassOfDevice")); - - if (propDeviceClass != NULL) { - long classOfDevice = propDeviceClass->unsigned32BitValue(); - - long deviceClassMajor = (classOfDevice & 0x1F00) >> 8; - long deviceClassMinor = (classOfDevice & 0xFF) >> 2; - - if (deviceClassMajor == kBluetoothDeviceClassMajorPeripheral) { // Bluetooth peripheral devices - long deviceClassMinor1 = (deviceClassMinor) & 0x30; - long deviceClassMinor2 = (deviceClassMinor) & 0x0F; - - if (deviceClassMinor1 == kBluetoothDeviceClassMinorPeripheral1Pointing || // Seperate pointing device - deviceClassMinor1 == kBluetoothDeviceClassMinorPeripheral1Combo) // Combo bluetooth keyboard/touchpad - { - if (deviceClassMinor2 == kBluetoothDeviceClassMinorPeripheral2Unclassified || // Mouse - deviceClassMinor2 == kBluetoothDeviceClassMinorPeripheral2DigitizerTablet || // Magic Touchpad - deviceClassMinor2 == kBluetoothDeviceClassMinorPeripheral2DigitalPen) // Wacom Tablet - { - attached_hid_pointer_devices->setObject(newService); - IOLog("%s: Bluetooth pointer HID device published: %s, # devices: %d\n", getName(), path, attached_hid_pointer_devices->getCount()); - } - } - } - } - } - - if (notifier == bluetooth_hid_terminate_notify) { - attached_hid_pointer_devices->removeObject(newService); - IOLog("%s: Bluetooth pointer HID device terminated: %s, # devices: %d\n", getName(), path, attached_hid_pointer_devices->getCount()); - } - - if (notifier == usb_hid_publish_notify || notifier == bluetooth_hid_publish_notify) { - if (ignore_mouse && attached_hid_pointer_devices->getCount() > 0) { - // One or more USB or Bluetooth pointer devices attached, disable trackpad - ignore_all = true; - } - } - - if (notifier == usb_hid_terminate_notify || notifier == bluetooth_hid_terminate_notify) { - if (ignore_mouse && attached_hid_pointer_devices->getCount() == 0) { - // No USB or bluetooth pointer devices attached, re-enable trackpad - ignore_all = false; - } - } -} - -bool VoodooI2CMultitouchHIDEventDriver::notificationHIDAttachedHandler(void * refCon, IOService * newService, IONotifier * notifier) { - command_gate->runAction((IOCommandGate::Action)OSMemberFunctionCast( - IOCommandGate::Action, this, - &VoodooI2CMultitouchHIDEventDriver::notificationHIDAttachedHandlerGated), - newService, notifier); - - return true; -} diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.hpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.hpp deleted file mode 100644 index 8de66f5..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CMultitouchHIDEventDriver.hpp +++ /dev/null @@ -1,316 +0,0 @@ -// -// VoodooI2CMultitouchHIDEventDriver.hpp -// VoodooI2CHID -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CMultitouchHIDEventDriver_hpp -#define VoodooI2CMultitouchHIDEventDriver_hpp - -// hack to prevent IOHIDEventDriver from loading when -// we include IOHIDEventService - -#define _IOKIT_HID_IOHIDEVENTDRIVER_H - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "VoodooI2CHIDTransducerWrapper.hpp" - -#include "../../SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp" -#include "../../SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp" -#include "../../SurfaceMultitouch/MultitouchHelpers.hpp" - -#include "../../Dependencies/VoodooSerial/VoodooSerial/utils/helpers.hpp" - -#define kHIDUsage_Dig_Confidence kHIDUsage_Dig_TouchValid - -#define kHIDUsage_LengthUnitCentimeter 0x11 -#define kHIDUsage_LengthUnitInch 0x13 - -// Message types defined by ApplePS2Keyboard -enum { - // from keyboard to mouse/touchpad - kKeyboardSetTouchStatus = iokit_vendor_specific_msg(100), // set disable/enable touchpad (data is bool*) - kKeyboardGetTouchStatus = iokit_vendor_specific_msg(101), // get disable/enable touchpad (data is bool*) - kKeyboardKeyPressTime = iokit_vendor_specific_msg(110) // notify of timestamp a non-modifier key was pressed (data is UInt64*) -}; - -/* Implements an HID Event Driver for HID devices that expose a digitiser usage page. - * - * The members of this class are responsible for parsing, processing and interpreting digitiser-related HID objects. - */ - -class EXPORT VoodooI2CMultitouchHIDEventDriver : public IOHIDEventService { - OSDeclareDefaultStructors(VoodooI2CMultitouchHIDEventDriver); - - public: - struct { - OSArray* fingers = NULL; - OSArray* styluses = NULL; - - OSArray* wrappers = NULL; - OSArray* transducers = NULL; - - // report level elements - - IOHIDElement* contact_count = NULL; - IOHIDElement* input_mode = NULL; - IOHIDElement* primaryButton = NULL; - IOHIDElement* secondaryButton = NULL; - - // collection level elements - - IOHIDElement* contact_count_maximum = NULL; - - - UInt8 current_contact_count = 1; - UInt8 report_count = 1; - UInt8 current_report = 1; - } digitiser; - - /* Calibrates an HID element - * @element The element to be calibrated - * @removalPercentage The percentage by which the element is calibrated - */ - - void calibrateJustifiedPreferredStateElement(IOHIDElement * element, SInt32 removalPercentage); - - /* Notification that a provider has been terminated, sent after recursing up the stack, in leaf-to-root order. - * @options The terminated provider of this object. - * @defer If there is pending I/O that requires this object to persist, and the provider is not opened by this object set defer to true and call the IOService::didTerminate() implementation when the I/O completes. Otherwise, leave defer set to its default value of false. - * - * @return *true* - */ - - bool didTerminate(IOService* provider, IOOptionBits options, bool* defer) override; - - /*Gets the latest value of an element by issuing a getReport request to the - * device. Necessary due to changes between 10.11 and 10.12. - * @element The element whose vaue is to be updated - * - * @return The new value of the element - */ - - UInt32 getElementValue(IOHIDElement* element); - - const char* getProductName(); - - /* Called during the interrupt routine to interate over transducers - * @timestamp The timestamp of the interrupt report - * @report_id The report ID of the interrupt report - */ - - void handleDigitizerReport(AbsoluteTime timestamp, UInt32 report_id); - - /* Called during the interrupt routine to set transducer values - * @transducer The transducer to be updated - * @timestamp The timestamp of the interrupt report - * @report_id The report ID of the interrupt report - */ - - void handleDigitizerTransducerReport(VoodooI2CDigitiserTransducer* transducer, AbsoluteTime timestamp, UInt32 report_id); - - /* Called during the interrupt routine to handle an interrupt report - * @timestamp The timestamp of the interrupt report - * @report A buffer containing the report data - * @report_type The type of HID report - * @report_id The report ID of the interrupt report - */ - - virtual void handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor* report, IOHIDReportType report_type, UInt32 report_id); - - /* Called during the start routine to set up the HID Event Driver - * @provider The object which we have matched against. - * - * This function is reponsible for opening a client connection with the provider and for publishing - * a multitouch interface into the IOService plane. - * - * @return *true* on successful start, *false* otherwise - */ - - bool handleStart(IOService* provider) override; - - /* Parses physical max HID element. - * @element The element to parse. - * - * This function factors reported dimensions with units and exponent. - * - * @return Physical max dimension in 0.01 mm units. - */ - - static UInt32 parseElementPhysicalMax(IOHIDElement* element); - - /* Parses a digitiser usage page element - * @element The element to parse - * - * This function is reponsible for examining the child elements of a digitser elements to determine the - * capabilities of the digitiser. - * - * @return *kIOReturnSuccess* on successful parse, *kIOReturnNotFound* if the digitizer element is not supported - */ - - IOReturn parseDigitizerElement(IOHIDElement* element); - - /* Parses a digitiser transducer element - * @element The element to parse - * @parent The parent digitiser - * - * This function is reponsible for examining the transducers of a digitiser to determine the capabilities of the transducer. - * - * @return *kIOReturnSuccess* on successful parse, *kIOReturnDeviceError*, *kIOReturnError* or *kIOReturnNoDevice* if the transducer element is not supported - */ - - IOReturn parseDigitizerTransducerElement(IOHIDElement* element, IOHIDElement* parent); - - - /* Parses all matched elements - * - * @return *kIOReturnSuccess* on successful parse, *kIOReturnNotFound* if the matched elements are not supported, *kIOReturnError* otherwise - */ - - virtual IOReturn parseElements(); - - /* Postprocessing of digitizer elements - * - * This function is mostly copied from Apple's own HID Event Driver code. It is responsible for cleaning up malformed report descriptors as well as setting some miscellaneous properties. - */ - - void processDigitizerElements(); - - /* Publishes a into the IOService plane - * - * @return *kIOReturnSuccess* on successful publish, *kIOReturnError* otherwise. - */ - - IOReturn publishMultitouchInterface(); - - /* Sets a button state to the given value - * @state The button state to be set - * @bit The bit in which to write the value - * @value The value to be written - * @timestamp The timestamp pertaining to the value - */ - - static inline void setButtonState(DigitiserTransducerButtonState* state, UInt32 bit, UInt32 value, AbsoluteTime timestamp); - - /* Publishes some miscellaneous properties to the IOService plane - */ - - void setDigitizerProperties(); - - /* Called by the OS in order to notify the driver that the device should change power state - * @whichState The power state the device is expected to enter represented by either - * *kIOPMPowerOn* or *kIOPMPowerOff* - * @whatDevice The power management policy maker - * - * This function exists to be overriden by inherited classes should they need it. - * - * @return *kIOPMAckImplied* on succesful state change, *kIOReturnError* otherwise - */ - - IOReturn setPowerState(unsigned long whichState, IOService* whatDevice) override; - - /* Called during the stop routine to terminate the HID Event Driver - * @provider The object which we have matched against. - * - * This function is reponsible for releasing the resources allocated in - */ - - void handleStop(IOService* provider) override; - - /* Implemented to set a certain property - * @provider The object which we have matched against. - */ - - bool start(IOService* provider) override; - - /* - * Called by ApplePS2Controller to notify of keyboard interactions - * @type Custom message type in iokit_vendor_specific_msg range - * @provider Calling IOService - * @argument Optional argument as defined by message type - * - * @return kIOReturnSuccess if the message is processed - */ - IOReturn message(UInt32 type, IOService* provider, void* argument) override; - - /* - * Used to pass user preferences from user mode to the driver - * @properties OSDictionary of configured properties - * - * @return kIOReturnSuccess if the properties are received successfully, otherwise kIOUnsupported - */ - IOReturn setProperties(OSObject * properties) override; - - protected: - const char* name; - bool awake = true; - IOHIDInterface* hid_interface; - IOHIDDevice* hid_device; - VoodooI2CMultitouchInterface* multitouch_interface; - bool should_have_interface = true; - - virtual void forwardReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp); - - private: - SInt32 absolute_axis_removal_percentage = 15; - - bool ignore_all; - bool ignore_mouse = false; - - UInt64 max_after_typing = 500000000; - UInt64 key_time = 0; - - IOWorkLoop* work_loop; - IOCommandGate* command_gate; - - OSSet* attached_hid_pointer_devices; - - IONotifier* usb_hid_publish_notify; // Notification when an USB mouse HID device is connected - IONotifier* usb_hid_terminate_notify; // Notification when an USB mouse HID device is disconnected - - IONotifier* bluetooth_hid_publish_notify; // Notification when a bluetooth HID device is connected - IONotifier* bluetooth_hid_terminate_notify; // Notification when a bluetooth HID device is disconnected - - /* - * Register for notifications of attached HID pointer devices (both USB and bluetooth) - */ - void registerHIDPointerNotifications(); - - /* - * Unregister for notifications of attached HID pointer devices (both USB and bluetooth) - */ - void unregisterHIDPointerNotifications(); - - /* - * IOServiceMatchingNotificationHandler (gated) to receive notification of addMatchingNotification registrations - * @newService IOService object matching the criteria for the addMatchingNotification registration - * @notifier IONotifier object for the notification registration - */ - void notificationHIDAttachedHandlerGated(IOService * newService, IONotifier * notifier); - - /* - * IOServiceMatchingNotificationHandler to receive notification of addMatchingNotification registrations - * @refCon reference set when registering - * @newService IOService object matching the criteria for the addMatchingNotification registration - * @notifier IONotifier object for the notification registration - */ - bool notificationHIDAttachedHandler(void * refCon, IOService * newService, IONotifier * notifier); -}; - - -#endif /* VoodooI2CMultitouchHIDEventDriver_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.cpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.cpp deleted file mode 100644 index 7456c7b..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -// VoodooI2CPrecisionTouchpadHIDEventDriver.cpp -// VoodooI2CHID -// -// Created by Alexandre on 21/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CPrecisionTouchpadHIDEventDriver.hpp" - -#define super VoodooI2CMultitouchHIDEventDriver -OSDefineMetaClassAndStructors(VoodooI2CPrecisionTouchpadHIDEventDriver, VoodooI2CMultitouchHIDEventDriver); - -void VoodooI2CPrecisionTouchpadHIDEventDriver::enterPrecisionTouchpadMode() { - digitiser.input_mode->setValue(INPUT_MODE_TOUCHPAD); - - ready = true; -} - -void VoodooI2CPrecisionTouchpadHIDEventDriver::handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor *report, IOHIDReportType report_type, UInt32 report_id) { - if (!ready) - return; - - super::handleInterruptReport(timestamp, report, report_type, report_id); -} - -bool VoodooI2CPrecisionTouchpadHIDEventDriver::handleStart(IOService* provider) { - if (!super::handleStart(provider)) - return false; - - if (!digitiser.input_mode) - return false; - - IOLog("%s::%s Putting device into Precision Touchpad Mode\n", getName(), name); - enterPrecisionTouchpadMode(); - - return true; -} - -IOReturn VoodooI2CPrecisionTouchpadHIDEventDriver::setPowerState(unsigned long whichState, IOService* whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (!whichState) { - if (awake) - awake = false; - } else { - if (!awake) { - IOSleep(10); - enterPrecisionTouchpadMode(); - awake = true; - } - } - return kIOPMAckImplied; -} diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.hpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.hpp deleted file mode 100644 index d902e3f..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CPrecisionTouchpadHIDEventDriver.hpp +++ /dev/null @@ -1,50 +0,0 @@ -// -// VoodooI2CPrecisionTouchpadHIDEventDriver.hpp -// VoodooI2CHID -// -// Created by Alexandre on 21/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CPrecisionTouchpadHIDEventDriver_hpp -#define VoodooI2CPrecisionTouchpadHIDEventDriver_hpp - -#include -#include -#include - -#include "VoodooI2CMultitouchHIDEventDriver.hpp" - -#define INPUT_MODE_MOUSE 0x00 -#define INPUT_MODE_TOUCHPAD 0x03 - -/* Implements an HID Event Driver for Precision Touchpad devices as specified by Microsoft's protocol in the following document: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/precision-touchpad-devices - * - * The members of this class are responsible for instructing a Precision Touchpad device to enter Touchpad mode. - */ - -class EXPORT VoodooI2CPrecisionTouchpadHIDEventDriver : public VoodooI2CMultitouchHIDEventDriver { - OSDeclareDefaultStructors(VoodooI2CPrecisionTouchpadHIDEventDriver); - - public: - /* @inherit */ - - void handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor *report, IOHIDReportType report_type, UInt32 report_id) override; - - /* @inherit */ - - bool handleStart(IOService* provider) override; - - /* @inherit */ - IOReturn setPowerState(unsigned long whichState, IOService* whatDevice) override; - - protected: - bool ready = false; - - private: - /* Sends a report to the device to instruct it to enter Touchpad mode */ - void enterPrecisionTouchpadMode(); -}; - - -#endif /* VoodooI2CPrecisionTouchpadHIDEventDriver_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.cpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.cpp deleted file mode 100755 index 779b16a..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.cpp +++ /dev/null @@ -1,244 +0,0 @@ -// -// VoodooI2CTouchscreenHIDEventDriver.cpp -// VoodooI2CHID -// -// Created by blankmac on 9/30/17. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CTouchscreenHIDEventDriver.hpp" - -#define super VoodooI2CMultitouchHIDEventDriver -OSDefineMetaClassAndStructors(VoodooI2CTouchscreenHIDEventDriver, VoodooI2CMultitouchHIDEventDriver); - -// Override of VoodooI2CMultitouchHIDEventDriver -bool VoodooI2CTouchscreenHIDEventDriver::checkFingerTouch(AbsoluteTime timestamp, VoodooI2CMultitouchEvent event) { - bool got_transducer = false; - - for (int index = 0; index < event.transducers->getCount(); index++) { - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, event.transducers->getObject(index)); - if (!transducer) - return false; - - if (transducer->type == kDigitiserTransducerFinger) { - UInt16 value = transducer->tip_switch.value(); - UInt16 last_value = transducer->tip_switch.last.value; - if (value || last_value) { - got_transducer = true; - - // Convert logical coordinates to IOFixed and Scaled; - IOFixed x = ((transducer->coordinates.x.value() * 1.0f) / transducer->logical_max_x) * 65535; - IOFixed y = ((transducer->coordinates.y.value() * 1.0f) / transducer->logical_max_y) * 65535; - - checkRotation(&x, &y); - - // Double click routine - if (!last_value) // touch starts - clock_get_uptime(&click_start); - if (!value) { // touch ends - AbsoluteTime click_end; - UInt64 nsecs; - clock_get_uptime(&click_end); - SUB_ABSOLUTETIME(&click_end, &click_start); - absolutetime_to_nanoseconds(click_end, &nsecs); - if (nsecs < 100000000) { // < 100ms a quick click - clock_get_uptime(&click_end); - SUB_ABSOLUTETIME(&click_end, &last_click); - absolutetime_to_nanoseconds(click_end, &nsecs); - if (nsecs < 200000000) { // < 200ms between two quick clicks - - dispatchDigitizerEventWithTiltOrientation(timestamp, transducer->secondary_id, transducer->type, 0x1, 0x00, x, y); - - // double click event - dispatchDigitizerEventWithTiltOrientation(timestamp, transducer->secondary_id, transducer->type, 0x1, 0x01, x, y); - IOSleep(10); - dispatchDigitizerEventWithTiltOrientation(timestamp, transducer->secondary_id, transducer->type, 0x1, 0x00, x, y); - - IOSleep(50); - - dispatchDigitizerEventWithTiltOrientation(timestamp, transducer->secondary_id, transducer->type, 0x1, 0x01, x, y); - IOSleep(10); - // The second lift event will be executed below - - last_click = 0; - } else - clock_get_uptime(&last_click); - } - } - - // Begin long press -> right click routine. - // Increasing long_press_counter check will lengthen the time until execution. - bool right_click = false; - UInt16 temp_x = x; - UInt16 temp_y = y; - if (!click_mask && value) { - SInt16 diff_x = compare_input_x - temp_x; - SInt16 diff_y = compare_input_y - temp_y; - if (long_press_timeout - && abs(diff_x) < RIGHT_CLICK_PRESS_RANGE - && abs(diff_y) < RIGHT_CLICK_PRESS_RANGE) { - AbsoluteTime cur_time; - clock_get_uptime(&cur_time); - if (cur_time > long_press_timeout) { - click_mask = true; - right_click = true; - - compare_input_x = 0; - compare_input_y = 0; - } - } else { - AbsoluteTime timeout; - nanoseconds_to_absolutetime(1000000000, &timeout); // 1s - clock_get_uptime(&long_press_timeout); - ADD_ABSOLUTETIME(&long_press_timeout, &timeout); - - compare_input_x = temp_x; - compare_input_y = temp_y; - } - } - // End long press -> right click routine. - - /* We need the first couple of single touch events to be in hover mode. - * In modes such as Mission Control, this allows us to select and drag - * windows vs just select and exit. - * We are mimicking a cursor being moved into position prior to executing a drag movement. - * There is little noticeable affect in other circumstances. */ - UInt32 buttons; - if (!last_value) - buttons = 0x00; - else if (right_click) - buttons = 0x02; - else if (click_mask) - buttons = 0x00; - else - buttons = value; - - dispatchDigitizerEventWithTiltOrientation(timestamp, transducer->secondary_id, transducer->type, 0x1, buttons, x, y); - - // Finger lifted - if (!value) { - click_mask = false; - long_press_timeout = 0; - } - } - } - } - return got_transducer; -} - -void VoodooI2CTouchscreenHIDEventDriver::checkRotation(IOFixed* x, IOFixed* y) { - if (active_framebuffer) { - if (current_rotation & kIOFBSwapAxes) { - IOFixed old_x = *x; - *x = *y; - *y = old_x; - } - if (current_rotation & kIOFBInvertX) - *x = 65535 - *x; - if (current_rotation & kIOFBInvertY) - *y = 65535 - *y; - } -} - -bool VoodooI2CTouchscreenHIDEventDriver::checkStylus(AbsoluteTime timestamp, VoodooI2CMultitouchEvent event) { - // Check the current transducers for stylus operation, dispatch the pointer events and return true. - // At this time, Apple has removed all methods of handling additional information from the event driver. Only x, y, buttonstate, and - // inrange are valid for macOS Sierra +. 10.11 still makes use of extended functions. - for (int index = 0, count = event.transducers->getCount(); index < count; index++) { - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, event.transducers->getObject(index)); - - if (transducer->type == kDigitiserTransducerStylus && transducer->in_range) { - VoodooI2CDigitiserStylus* stylus = (VoodooI2CDigitiserStylus*)transducer; - IOFixed x = ((stylus->coordinates.x.value() * 1.0f) / stylus->logical_max_x) * 65535; - IOFixed y = ((stylus->coordinates.y.value() * 1.0f) / stylus->logical_max_y) * 65535; - IOFixed z = ((stylus->coordinates.z.value() * 1.0f) / stylus->logical_max_z) * 65535; - IOFixed stylus_pressure = ((stylus->tip_pressure.value() * 1.0f) /stylus->pressure_physical_max) * 65535; - - checkRotation(&x, &y); - - if (stylus->barrel_switch.value() != 0x0 && stylus->barrel_switch.value() !=0x2 && (stylus->barrel_switch.value()-barrel_switch_offset) != 0x2) - barrel_switch_offset = stylus->barrel_switch.value(); - if (stylus->eraser.value() != 0x0 && stylus->eraser.value() !=0x2 && (stylus->eraser.value()-eraser_switch_offset) != 0x4) - eraser_switch_offset = stylus->eraser.value(); - - stylus_buttons = stylus->tip_switch.value(); - - if (stylus->barrel_switch.value() == 0x2 || (stylus->barrel_switch.value() - barrel_switch_offset) == 0x2) { - stylus_buttons = 0x2; - } - - if (stylus->eraser.value() == 0x4 || (stylus->eraser.value() - eraser_switch_offset) == 0x4) { - stylus_buttons = 0x4; - } - - dispatchDigitizerEventWithTiltOrientation(timestamp, stylus->secondary_id, stylus->type, stylus->in_range, stylus_buttons, x, y, z, stylus_pressure, stylus->barrel_pressure.value(), stylus->azi_alti_orientation.twist.value(), stylus->tilt_orientation.x_tilt.value(), stylus->tilt_orientation.y_tilt.value()); - - return true; - } - } - - return false; -} - -IOFramebuffer* VoodooI2CTouchscreenHIDEventDriver::getFramebuffer() { - IORegistryEntry* display = NULL; - IOFramebuffer* framebuffer = NULL; - - OSDictionary *match = serviceMatching("IODisplay"); - OSIterator *iterator = getMatchingServices(match); - - if (iterator) { - display = OSDynamicCast(IORegistryEntry, iterator->getNextObject()); - - if (display) { - IOLog("%s::Got active display\n", getName()); - IORegistryEntry *entry = display->getParentEntry(gIOServicePlane)->getParentEntry(gIOServicePlane); - if (entry) - framebuffer = reinterpret_cast(entry->metaCast("IOFramebuffer")); - if (framebuffer) - IOLog("%s::Got active framebuffer\n", getName()); - } - - iterator->release(); - } - - OSSafeReleaseNULL(match); - return framebuffer; -} - -void VoodooI2CTouchscreenHIDEventDriver::forwardReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - if (!active_framebuffer) - active_framebuffer = getFramebuffer(); - - if (active_framebuffer) { - OSNumber* number = OSDynamicCast(OSNumber, active_framebuffer->getProperty(kIOFBTransformKey)); - current_rotation = number->unsigned8BitValue() / 0x10; - multitouch_interface->setProperty(kIOFBTransformKey, current_rotation, 8); - } - - if (event.contact_count) { - // Send multitouch information to the multitouch interface - if (event.contact_count >= 2) { - multitouch_interface->handleInterruptReport(event, timestamp); - } else { - // Process single touch data - if (!checkStylus(timestamp, event)) { - if (!checkFingerTouch(timestamp, event)) - multitouch_interface->handleInterruptReport(event, timestamp); - } - } - } -} - -bool VoodooI2CTouchscreenHIDEventDriver::handleStart(IOService* provider) { - if (!super::handleStart(provider)) - return false; - - active_framebuffer = getFramebuffer(); - - return true; -} - -void VoodooI2CTouchscreenHIDEventDriver::handleStop(IOService* provider) { - super::handleStop(provider); -} diff --git a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.hpp b/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.hpp deleted file mode 100755 index 9818e19..0000000 --- a/BigSurface/BigSurface/SurfaceHID/HIDEventDriver/VoodooI2CTouchscreenHIDEventDriver.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// VoodooI2CTouchscreenHIDEventDriver.hpp -// VoodooI2CHID -// -// Created by blankmac on 9/30/17. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CTouchscreenHIDEventDriver_hpp -#define VoodooI2CTouchscreenHIDEventDriver_hpp - -#include -#include -#include -#include -#include -#include -#include - -#include "../../SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp" -#include "../../SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp" -#include "../../SurfaceMultitouch/MultitouchHelpers.hpp" - -#include "VoodooI2CMultitouchHIDEventDriver.hpp" - -#define RIGHT_CLICK_PRESS_RANGE 100 // in which range is considered a long press right click event - -/* Implements an HID Event Driver for touchscreen devices as well as stylus input. - */ -class EXPORT VoodooI2CTouchscreenHIDEventDriver : public VoodooI2CMultitouchHIDEventDriver { - OSDeclareDefaultStructors(VoodooI2CTouchscreenHIDEventDriver); - - public: - /* Checks the event contact count and if finger touches >= 2 are detected, the event is immediately dispatched - * to the multitouch engine interface. The 'else' convention used vs 'elseif' is intentional and results in - * smoother gesture recognition and execution. If single touch is detected, first the transducer is checked for stylus operation - * and if false, the transducer is checked for finger touch. - * - * @inherit - */ - void forwardReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) override; - - /* @inherit */ - bool handleStart(IOService* provider) override; - - /* @inherit */ - void handleStop(IOService* provider) override; - - protected: - /* The transducer is checked for stylus operation and pointer event dispatched. x,y,z & pressure information is - * obtained in a logical format and converted to IOFixed variables. - * - * @timestamp The timestamp of the current event being processed - * - * @event The current event - */ - bool checkStylus(AbsoluteTime timestamp, VoodooI2CMultitouchEvent event); - - private: - IOFramebuffer* active_framebuffer; - UInt8 current_rotation; - - UInt32 stylus_buttons = 0; - UInt32 barrel_switch_offset = 0; - UInt32 eraser_switch_offset = 0; - - bool click_mask = false; - - UInt16 compare_input_x = 0; - UInt16 compare_input_y = 0; - AbsoluteTime long_press_timeout = 0; - - AbsoluteTime click_start = 0; - AbsoluteTime last_click = 0; - - /* The transducer is checked for singletouch finger based operation and the pointer event dispatched. This function - * also handles a long-press, right-click function. - * - * @timestamp The timestamp of the current event being processed - * - * @event The current event - * @return `true` if we got a finger touch event, `false` otherwise - */ - bool checkFingerTouch(AbsoluteTime timestamp, VoodooI2CMultitouchEvent event); - - /* Checks to see if the x and y coordinates need to be modified - * to account for a rotation - * - * @x A pointer to the x coordinate - * @y A pointer to the y coordinate - * - */ - - void checkRotation(IOFixed* x, IOFixed* y); - - IOFramebuffer* getFramebuffer(); -}; -#endif /* VoodooI2CTouchscreenHIDEventDriver_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.cpp b/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.cpp deleted file mode 100644 index 03f85b0..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// -// SurfaceHIDDevice.cpp -// SurfaceHID -// -// Created by Xavier on 2022/5/20. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#include "SurfaceHIDDevice.hpp" - -#define LOG(str, ...) IOLog("%s::%s " str "\n", "SurfaceHIDDevice", device_name, ##__VA_ARGS__) - -#define super IOHIDDevice -OSDefineMetaClassAndStructors(SurfaceHIDDevice, IOHIDDevice); - -bool SurfaceHIDDevice::attach(IOService* provider) { - if (!super::attach(provider)) - return false; - - api = OSDynamicCast(SurfaceHIDDriver, provider); - if (!api) - return false; - - if (api->getHIDDescriptor(device, &descriptor) != kIOReturnSuccess) { - LOG("Failed to get HID descriptor!"); - return false; - } - if (descriptor.desc_len != sizeof(SurfaceHIDDescriptor)) { - LOG("Unexpected HID descriptor length: got %u, expected %lu", descriptor.desc_len, sizeof(SurfaceHIDDescriptor)); - return false; - } - if (descriptor.desc_type != kIOUSBDecriptorTypeHID) { - LOG("Unexpected HID descriptor type: got %#04x, expected %#04x", descriptor.desc_type, kIOUSBDecriptorTypeHID); - return false; - } - if (descriptor.num_descriptors != 1) { - LOG("Unexpected number of descriptors: got %u, expected 1", descriptor.num_descriptors); - return false; - } - if (descriptor.report_desc_type != kIOUSBDecriptorTypeReport) { - LOG("Unexpected report descriptor type: got %#04x, expected %#04x", descriptor.report_desc_type, kIOUSBDecriptorTypeReport); - return false; - } - - if (api->getHIDAttributes(device, &attributes) != kIOReturnSuccess) { - LOG("Failed to get HID attributes!"); - return false; - } - if (attributes.length != sizeof(SurfaceHIDAttributes)) { - LOG("Unexpected attribute length: got %u, expected %lu\n", attributes.length, sizeof(SurfaceHIDAttributes)); - return false; - } - - return true; -} - -void SurfaceHIDDevice::detach(IOService* provider) { - api = nullptr; - super::detach(provider); -} - -bool SurfaceHIDDevice::handleStart(IOService *provider) { - if (!super::handleStart(provider)) - return false; - - setName(device_name); - - setProperty("AppleVendorSupported", kOSBooleanTrue); - setProperty("Built-In", kOSBooleanTrue); - setProperty("HIDDefaultBehavior", kOSBooleanTrue); - - return true; -} - -IOReturn SurfaceHIDDevice::getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType == kIOHIDReportTypeFeature) { - UInt8 report_id = options & 0xff; - UInt16 buffer_len = report->getLength(); - UInt8 *buffer = new UInt8[buffer_len]; - if (api->getRawReport(device, report_id, buffer, buffer_len) != kIOReturnSuccess) { - LOG("Get feature report failed"); - delete[] buffer; - return kIOReturnError; - } - report->writeBytes(0, buffer, buffer_len); - delete[] buffer; - } - return kIOReturnSuccess; -} - -IOReturn SurfaceHIDDevice::setReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType == kIOHIDReportTypeFeature || reportType == kIOHIDReportTypeOutput) { - UInt8 report_id = options & 0xff; - UInt16 buffer_len = report->getLength(); - UInt8 *buffer = new UInt8[buffer_len]; - report->readBytes(0, buffer, buffer_len); - api->setRawReport(device, report_id, reportType == kIOHIDReportTypeFeature, buffer, buffer_len); - delete[] buffer; - } - return kIOReturnSuccess; -} - -IOReturn SurfaceHIDDevice::newReportDescriptor(IOMemoryDescriptor **reportDescriptor) const { - UInt8 *desc = new UInt8[descriptor.report_desc_len]; - for (int trial = 0; trial < 10; trial++) { - if (api->getReportDescriptor(device, desc, descriptor.report_desc_len) == kIOReturnSuccess) - goto success; - } - LOG("Failed to get report descriptor!"); - delete[] desc; - return kIOReturnError; -success: - *reportDescriptor = IOBufferMemoryDescriptor::withBytes(desc, descriptor.report_desc_len, kIODirectionNone); - delete[] desc; - return kIOReturnSuccess; -} - -OSString* SurfaceHIDDevice::newTransportString() const { - return OSString::withCString("Surface Serial Hub"); -} - -OSString *SurfaceHIDDevice::newManufacturerString() const { - return OSString::withCString("Microsoft Inc."); -} - -OSNumber *SurfaceHIDDevice::newVendorIDNumber() const { - return OSNumber::withNumber(attributes.vendor, 32); -} - -OSNumber *SurfaceHIDDevice::newProductIDNumber() const { - return OSNumber::withNumber(attributes.product, 32); -} - -OSNumber *SurfaceHIDDevice::newLocationIDNumber() const { - return OSNumber::withNumber(0x1000000, 32); -} - -OSNumber *SurfaceHIDDevice::newCountryCodeNumber() const { - return OSNumber::withNumber(descriptor.country_code, 32); -} - -OSNumber *SurfaceHIDDevice::newVersionNumber() const { - return OSNumber::withNumber(attributes.version, 32); -} - -OSString *SurfaceHIDDevice::newProductString() const { - return OSString::withCString(device_name); -} diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.hpp b/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.hpp deleted file mode 100644 index 0dee4ee..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDevice.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// -// SurfaceHIDDevice.hpp -// SurfaceHID -// -// Created by Xavier on 2022/5/20. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef SurfaceHIDDevice_hpp -#define SurfaceHIDDevice_hpp - -#include -#include - -#include "SurfaceHIDDriver.hpp" - -class EXPORT SurfaceHIDDevice : public IOHIDDevice { - OSDeclareDefaultStructors(SurfaceHIDDevice); - - friend class SurfaceHIDDriver; - -public: - bool attach(IOService *provider) override; - - void detach(IOService* provider) override; - - bool handleStart(IOService *provider) override; - - IOReturn getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) override; - - IOReturn setReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options=0) override; - - IOReturn newReportDescriptor(IOMemoryDescriptor **descriptor) const override; - - OSString *newTransportString() const override; - OSString *newManufacturerString() const override; - OSNumber *newVendorIDNumber() const override; - OSNumber *newProductIDNumber() const override; - OSNumber *newLocationIDNumber() const override; - OSNumber *newCountryCodeNumber() const override; - OSNumber *newVersionNumber() const override; - OSString *newProductString() const override; - -private: - SurfaceHIDDriver* api {nullptr}; - SurfaceHIDDescriptor descriptor; - SurfaceHIDAttributes attributes; - SurfaceHIDDeviceType device; - const char* device_name; -}; - -#endif /* SurfaceHIDDevice_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.cpp b/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.cpp deleted file mode 100644 index d42e4b8..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// -// SurfaceHIDDriver.cpp -// SurfaceHID -// -// Created by Xavier on 2022/5/16. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#include "SurfaceHIDDriver.hpp" -#include "SurfaceHIDDevice.hpp" - -#define LOG(str, ...) IOLog("%s::" str "\n", "SurfaceHIDDriver", ##__VA_ARGS__) - -#define super IOService -OSDefineMetaClassAndStructors(SurfaceHIDDriver, IOService) - -void SurfaceHIDDriver::eventReceived(SurfaceHIDNub *sender, SurfaceHIDDeviceType device, UInt8 *buffer, UInt16 len) { - if (!ready) - return; - - switch (device) { - case SurfaceLegacyKeyboardDevice: - case SurfaceKeyboardDevice: - memcpy(kbd_report, buffer, len); - kbd_report_len = len; - kbd_interrupt->interruptOccurred(nullptr, this, 0); - break; - case SurfaceTouchpadDevice: - if (tpd_interrupt) { - memcpy(tpd_report, buffer, len); - tpd_report_len = len; - tpd_interrupt->interruptOccurred(nullptr, this, 0); - } - break; - default: - LOG("WTF? Unknown event type"); - break; - } -} - -void SurfaceHIDDriver::keyboardInputReceived(IOInterruptEventSource *sender, int count) { - IOBufferMemoryDescriptor *report = IOBufferMemoryDescriptor::withBytes(kbd_report, kbd_report_len, kIODirectionNone); - if (keyboard->handleReport(report) != kIOReturnSuccess) - LOG("Handle keyboard report error!"); - - OSSafeReleaseNULL(report); -} - -void SurfaceHIDDriver::touchpadInputReceived(IOInterruptEventSource *sender, int count) { - IOBufferMemoryDescriptor *report = IOBufferMemoryDescriptor::withBytes(tpd_report, tpd_report_len, kIODirectionNone); - if (touchpad->handleReport(report) != kIOReturnSuccess) - LOG("Handle touchpad report error!"); - - OSSafeReleaseNULL(report); -} - -bool SurfaceHIDDriver::init(OSDictionary *properties) { - if (!super::init(properties)) - return false; - - memset(kbd_report, 0, sizeof(kbd_report)); - memset(tpd_report, 0, sizeof(tpd_report)); - return true; -} - -IOService *SurfaceHIDDriver::probe(IOService *provider, SInt32 *score) { - if (!super::probe(provider, score)) - return nullptr; - - nub = OSDynamicCast(SurfaceHIDNub, provider); - if (!nub) - return nullptr; - - OSBoolean *type = OSRequiredCast(OSBoolean, nub->getProperty(SURFACE_LEGACY_HID_STRING)); - legacy = type->getValue(); - - return this; -} - -bool SurfaceHIDDriver::start(IOService *provider) { - if (!super::start(provider)) - return false; - - work_loop = IOWorkLoop::workLoop(); - if (!work_loop) { - LOG("Could not create work loop!"); - goto exit; - } - - if (nub->registerHIDEvent(this, OSMemberFunctionCast(SurfaceHIDNub::EventHandler, this, &SurfaceHIDDriver::eventReceived)) != kIOReturnSuccess) { - LOG("HID event registration failed!"); - goto exit; - } - - // create keyboard & touchpad devices - keyboard = OSTypeAlloc(SurfaceHIDDevice); - if (!keyboard) { - LOG("Could not create keyboard device"); - goto exit; - } - if (legacy) { - keyboard->device = SurfaceLegacyKeyboardDevice; - keyboard->device_name = "Surface Legacy Keyboard"; - } else { - keyboard->device = SurfaceKeyboardDevice; - keyboard->device_name = "Surface Keyboard"; - } - if (!keyboard->init() || !keyboard->attach(this)) { - LOG("Could not init keyboard device"); - goto exit; - } - if (!keyboard->start(this)) { - keyboard->detach(this); - LOG("Could not start keyboard device"); - goto exit; - } - kbd_interrupt = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &SurfaceHIDDriver::keyboardInputReceived)); - if (!kbd_interrupt) { - LOG("Could not create keyboard interrupt event!"); - goto exit; - } - work_loop->addEventSource(kbd_interrupt); - kbd_interrupt->enable(); - - if (!legacy) { - touchpad = OSTypeAlloc(SurfaceHIDDevice); - if (!touchpad) { - LOG("Could not create touchpad device"); - goto exit; - } - touchpad->device = SurfaceTouchpadDevice; - touchpad->device_name = "Surface Touchpad"; - if (!touchpad->init() || !touchpad->attach(this)) { - LOG("Could not init Surface touchpad device"); - goto exit; - } - if (!touchpad->start(this)) { - touchpad->detach(this); - LOG("Could not start Surface touchpad device"); - goto exit; - } - tpd_interrupt = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &SurfaceHIDDriver::touchpadInputReceived)); - if (!tpd_interrupt) { - LOG("Could not create touchpad interrupt event!"); - goto exit; - } - work_loop->addEventSource(tpd_interrupt); - tpd_interrupt->enable(); - } - ready = true; - - return true; -exit: - releaseResources(); - return false; -} - -void SurfaceHIDDriver::stop(IOService *provider) { - releaseResources(); - super::stop(provider); -} - -void SurfaceHIDDriver::free() { - super::free(); -} - -void SurfaceHIDDriver::releaseResources() { - nub->unregisterHIDEvent(this); - if (kbd_interrupt) { - kbd_interrupt->disable(); - work_loop->removeEventSource(kbd_interrupt); - OSSafeReleaseNULL(kbd_interrupt); - } - if (tpd_interrupt) { - tpd_interrupt->disable(); - work_loop->removeEventSource(tpd_interrupt); - OSSafeReleaseNULL(tpd_interrupt); - } - OSSafeReleaseNULL(work_loop); - - if (keyboard) { - keyboard->stop(this); - keyboard->detach(this); - OSSafeReleaseNULL(keyboard); - } - if (touchpad) { - touchpad->stop(this); - touchpad->detach(this); - OSSafeReleaseNULL(touchpad); - } -} - -IOReturn SurfaceHIDDriver::getHIDDescriptor(SurfaceHIDDeviceType device, SurfaceHIDDescriptor *desc) { - return nub->getHIDDescriptor(device, desc); -} - -IOReturn SurfaceHIDDriver::getHIDAttributes(SurfaceHIDDeviceType device, SurfaceHIDAttributes *attr) { - return nub->getHIDAttributes(device, attr); -} - -IOReturn SurfaceHIDDriver::getReportDescriptor(SurfaceHIDDeviceType device, UInt8 *buffer, UInt16 len) { - return nub->getReportDescriptor(device, buffer, len); -} - -IOReturn SurfaceHIDDriver::getRawReport(SurfaceHIDDeviceType device, UInt8 report_id, UInt8 *buffer, UInt16 len) { - return nub->getHIDRawReport(device, report_id, buffer, len); -} - -void SurfaceHIDDriver::setRawReport(SurfaceHIDDeviceType device, UInt8 report_id, bool feature, UInt8 *buffer, UInt16 len) { - nub->setHIDRawReport(device, report_id, feature, buffer, len); -} diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.hpp b/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.hpp deleted file mode 100644 index 8c980d9..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceHIDDriver.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// SurfaceHIDDriver.hpp -// SurfaceHID -// -// Created by Xavier on 2022/5/16. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef SurfaceHIDDriver_hpp -#define SurfaceHIDDriver_hpp - -#include -#include -#include - -#include "../SurfaceSerialHubDevices/SurfaceHIDNub.hpp" - -class SurfaceHIDDevice; - -class EXPORT SurfaceHIDDriver : public IOService { - OSDeclareDefaultStructors(SurfaceHIDDriver) - -public: - bool init(OSDictionary *properties) override; - - IOService *probe(IOService *provider, SInt32 *score) override; - - bool start(IOService *provider) override; - - void stop(IOService *provider) override; - - void free() override; - - IOReturn getHIDDescriptor(SurfaceHIDDeviceType device, SurfaceHIDDescriptor *desc); - - IOReturn getHIDAttributes(SurfaceHIDDeviceType device, SurfaceHIDAttributes *attr); - - IOReturn getReportDescriptor(SurfaceHIDDeviceType device, UInt8 *buffer, UInt16 len); - - IOReturn getRawReport(SurfaceHIDDeviceType device, UInt8 report_id, UInt8 *buffer, UInt16 len); - - void setRawReport(SurfaceHIDDeviceType device, UInt8 report_id, bool feature, UInt8 *buffer, UInt16 len); - -private: - SurfaceHIDNub* nub {nullptr}; - IOWorkLoop* work_loop {nullptr}; - IOInterruptEventSource* kbd_interrupt {nullptr}; - IOInterruptEventSource* tpd_interrupt {nullptr}; - SurfaceHIDDevice* keyboard {nullptr}; - SurfaceHIDDevice* touchpad {nullptr}; - - bool awake {true}; - bool legacy {false}; - bool ready {false}; - UInt8 kbd_report[32]; - UInt16 kbd_report_len {0}; - UInt8 tpd_report[32]; - UInt16 tpd_report_len {0}; - - void eventReceived(SurfaceHIDNub *sender, SurfaceHIDDeviceType device, UInt8 *buffer, UInt16 len); - - void keyboardInputReceived(IOInterruptEventSource *sender, int count); - - void touchpadInputReceived(IOInterruptEventSource *sender, int count); - - void releaseResources(); -}; - -#endif /* SurfaceHIDDriver_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.cpp b/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.cpp deleted file mode 100644 index 837d35f..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -// SurfaceTouchScreenDevice.cpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/8. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#include "SurfaceTouchScreenDevice.hpp" -#include "SurfaceTouchScreenReportDescriptor.h" - -#define LOG(str, ...) IOLog("%s::" str "\n", "SurfaceTouchScreenDevice", ##__VA_ARGS__) - -#define super IOHIDDevice -OSDefineMetaClassAndStructors(SurfaceTouchScreenDevice, IOHIDDevice); - -bool SurfaceTouchScreenDevice::attach(IOService* provider) { - if (!super::attach(provider)) - return false; - - api = OSDynamicCast(IntelPreciseTouchStylusDriver, provider); - if (!api) - return false; - - return true; -} - -void SurfaceTouchScreenDevice::detach(IOService* provider) { - api = nullptr; - super::detach(provider); -} - -bool SurfaceTouchScreenDevice::handleStart(IOService *provider) { - if (!super::handleStart(provider)) - return false; - - setProperty("MaxContactCount", max_contacts, 32); - - setProperty("Built-In", kOSBooleanTrue); - setProperty("HIDDefaultBehavior", kOSBooleanTrue); - - return true; -} - -IOReturn SurfaceTouchScreenDevice::newReportDescriptor(IOMemoryDescriptor **reportDescriptor) const { - IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::withBytes(virt_reportDescriptor, sizeof(virt_reportDescriptor), kIODirectionNone); - *reportDescriptor = buffer; - return kIOReturnSuccess; -} - -IOReturn SurfaceTouchScreenDevice::getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType == kIOHIDReportTypeFeature) { - UInt8 report_id = options & 0xff; - if (report_id == 0x40) { - UInt8 buffer[] = {0x40, max_contacts}; - report->writeBytes(0, buffer, sizeof(buffer)); - return kIOReturnSuccess; - } - } - return kIOReturnUnsupported; -} - -IOReturn SurfaceTouchScreenDevice::setReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - return kIOReturnUnsupported; -} - -OSString* SurfaceTouchScreenDevice::newTransportString() const { - return OSString::withCString("MEI"); -} - -OSString *SurfaceTouchScreenDevice::newManufacturerString() const { - return OSString::withCString("Microsoft Inc."); -} - -OSString *SurfaceTouchScreenDevice::newProductString() const { - return OSString::withCString("Surface Touch Screen"); -} - -OSNumber *SurfaceTouchScreenDevice::newVendorIDNumber() const { - return OSNumber::withNumber(vendor_id, 32); -} - -OSNumber *SurfaceTouchScreenDevice::newProductIDNumber() const { - return OSNumber::withNumber(device_id, 32); -} - -OSNumber *SurfaceTouchScreenDevice::newVersionNumber() const { - return OSNumber::withNumber(version, 32); -} diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.hpp b/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.hpp deleted file mode 100644 index 99a3c45..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenDevice.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// SurfaceTouchScreenDevice.hpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/8. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef SurfaceTouchScreenDevice_hpp -#define SurfaceTouchScreenDevice_hpp - -#include -#include - -#include "IntelPreciseTouchStylusDriver.hpp" - -class EXPORT SurfaceTouchScreenDevice : public IOHIDDevice { - OSDeclareDefaultStructors(SurfaceTouchScreenDevice); - - friend class IntelPreciseTouchStylusDriver; - -public: - bool attach(IOService *provider) override; - - void detach(IOService* provider) override; - - bool handleStart(IOService *provider) override; - - IOReturn newReportDescriptor(IOMemoryDescriptor **descriptor) const override; - - IOReturn getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) override; - - IOReturn setReport(IOMemoryDescriptor * report, IOHIDReportType reportType, IOOptionBits options=0) override; - - OSString *newTransportString() const override; - OSString *newManufacturerString() const override; - OSString *newProductString() const override; - OSNumber *newVendorIDNumber() const override; - OSNumber *newProductIDNumber() const override; - OSNumber *newVersionNumber() const override; - -private: - IntelPreciseTouchStylusDriver* api {nullptr}; - - UInt16 vendor_id {0}; - UInt16 device_id {0}; - UInt32 version {0}; - UInt8 max_contacts {1}; -}; - -#endif /* SurfaceTouchScreenDevice_hpp */ diff --git a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenReportDescriptor.h b/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenReportDescriptor.h deleted file mode 100644 index fcc9bc0..0000000 --- a/BigSurface/BigSurface/SurfaceHID/SurfaceTouchScreenReportDescriptor.h +++ /dev/null @@ -1,364 +0,0 @@ -// -// SurfaceTouchScreenReportDescriptor.h -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/10. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef SurfaceTouchScreenReportDescriptor_h -#define SurfaceTouchScreenReportDescriptor_h - -const UInt8 virt_reportDescriptor[] = { - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x04, // Usage (Touch Screen) - 0xA1, 0x01, // Collection (Application) - 0x85, 0x40, // Report ID (64) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x22, // Usage (Finger) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x42, // Usage (Tip Switch) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x01, // Report Count (1) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x51, // Usage (Contact Identifier) - 0x25, 0x09, // Logical Maximum (9) - 0x75, 0x07, // Report Size (7) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x76, 0x0B, // Physical Maximum (2934) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0x74, 0x06, // Physical Maximum (1652) - 0x26, 0xFF, 0x7F, // Logical Maximum (32767) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x54, // Usage (Contact Count) - 0x25, 0x0F, // Logical Maximum (15) - 0x75, 0x08, // Report Size (8) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x55, // Usage (Contact Count Maximum) - 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile) - 0xC0, // End Collection - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x02, // Usage (Pen) - 0xA1, 0x01, // Collection (Application) - 0x85, 0x01, // Report ID (1) - 0x09, 0x20, // Usage (Stylus) - 0x35, 0x00, // Physical Minimum (0) - 0xA1, 0x00, // Collection (Physical) - 0x09, 0x32, // Usage (In Range) - 0x09, 0x42, // Usage (Tip Switch) - 0x09, 0x44, // Usage (Barrel Switch) - 0x09, 0x3C, // Usage (Invert) - 0x09, 0x45, // Usage (Eraser) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x05, // Report Count (5) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x95, 0x03, // Report Count (3) - 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x30, // Usage (X) - 0x75, 0x10, // Report Size (16) - 0x95, 0x01, // Report Count (1) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x11, // Unit (System: SI Linear, Length: Centimeter) - 0x46, 0x26, 0x0A, // Physical Maximum (2598) - 0x26, 0x80, 0x25, // Logical Maximum (9600) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x31, // Usage (Y) - 0x46, 0xC4, 0x06, // Physical Maximum (1732) - 0x26, 0x20, 0x1C, // Logical Maximum (7200) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0x05, 0x0D, // Usage Page (Digitizer) - 0x09, 0x30, // Usage (Tip Pressure) - 0x26, 0x00, 0x10, // Logical Maximum (4096) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xA4, // Push - 0x55, 0x0E, // Unit Exponent (-2) - 0x65, 0x14, // Unit (System: English Rotation, Length: Centimeter) - 0x36, 0xD8, 0xDC, // Physical Minimum (-9000) - 0x46, 0x28, 0x23, // Physical Maximum (9000) - 0x26, 0x50, 0x46, // Logical Maximum (18000) - 0x09, 0x3D, // Usage (X Tilt) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x09, 0x3E, // Usage (Y Tilt) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x55, 0x0C, // Unit Exponent (-4) - 0x66, 0x01, 0x10, // Unit (System: SI Linear, Time: Seconds) - 0x35, 0x00, // Physical Minimum (0) - 0x47, 0xFF, 0xFF, 0x00, 0x00, // Physical Maximum (65534) - 0x27, 0xFF, 0xFF, 0x00, 0x00, // Logical Maximum (65534) - 0x09, 0x56, // Usage (Scan Time) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xB4, // Pop - 0xC0, // End Collection - 0xC0, // End Collection -}; - -#endif /* SurfaceTouchScreenReportDescriptor_h */ diff --git a/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.cpp b/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.cpp deleted file mode 100644 index 5f2fdf6..0000000 --- a/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.cpp +++ /dev/null @@ -1,663 +0,0 @@ -// -// VoodooI2CHIDDevice.cpp -// VoodooI2CHID -// -// Created by Alexandre on 25/08/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include -#include -#include "VoodooI2CHIDDevice.hpp" -#include "../../../Dependencies/VoodooSerial/VoodooSerial/VoodooI2C/VoodooI2CDevice/VoodooI2CDeviceNub.hpp" - -#define super IOHIDDevice -OSDefineMetaClassAndStructors(VoodooI2CHIDDevice, IOHIDDevice); - -extern volatile AbsoluteTime last_multi_touch_event; - -bool VoodooI2CHIDDevice::init(OSDictionary* properties) { - if (!super::init(properties)) - return false; - awake = true; - bool temp = false; - reset_event = &temp; - memset(&hid_descriptor, 0, sizeof(VoodooI2CHIDDeviceHIDDescriptor)); - acpi_device = NULL; - api = NULL; - command_gate = NULL; - interrupt_simulator = NULL; - interrupt_source = NULL; - ready_for_input = false; - - client_lock = IOLockAlloc(); - - clients = OSArray::withCapacity(1); - - if (!client_lock || !clients) { - OSSafeReleaseNULL(clients); - return false; - } - - return true; -} - -void VoodooI2CHIDDevice::free() { - if (client_lock) - IOLockFree(client_lock); - - super::free(); -} - -IOReturn VoodooI2CHIDDevice::getHIDDescriptor() { - VoodooI2CHIDDeviceCommand command; - command.c.reg = hid_descriptor_register; - - if (api->writeReadI2C(command.data, 2, (UInt8*)&hid_descriptor, (UInt16)sizeof(VoodooI2CHIDDeviceHIDDescriptor)) != kIOReturnSuccess) { - IOLog("%s::%s Request for HID descriptor failed\n", getName(), name); - return kIOReturnIOError; - } - - return parseHIDDescriptor(); -} - -IOReturn VoodooI2CHIDDevice::parseHIDDescriptor() { - if (hid_descriptor.bcdVersion != 0x0100) { - IOLog("%s::%s Incorrect BCD version %d\n", getName(), name, hid_descriptor.bcdVersion); - return kIOReturnInvalid; - } - - if (hid_descriptor.wHIDDescLength != sizeof(VoodooI2CHIDDeviceHIDDescriptor)) { - IOLog("%s::%s Unexpected size of HID descriptor\n", getName(), name); - return kIOReturnInvalid; - } - - OSDictionary* property_array = OSDictionary::withCapacity(1); - if (!property_array) - return kIOReturnNoMemory; - - setOSDictionaryNumber(property_array, "HIDDescLength", hid_descriptor.wHIDDescLength); - setOSDictionaryNumber(property_array, "BCDVersion", hid_descriptor.bcdVersion); - setOSDictionaryNumber(property_array, "ReportDescLength", hid_descriptor.wReportDescLength); - setOSDictionaryNumber(property_array, "ReportDescRegister", hid_descriptor.wReportDescRegister); - setOSDictionaryNumber(property_array, "MaxInputLength", hid_descriptor.wMaxInputLength); - setOSDictionaryNumber(property_array, "InputRegister", hid_descriptor.wInputRegister); - setOSDictionaryNumber(property_array, "MaxOutputLength", hid_descriptor.wMaxOutputLength); - setOSDictionaryNumber(property_array, "OutputRegister", hid_descriptor.wOutputRegister); - setOSDictionaryNumber(property_array, "CommandRegister", hid_descriptor.wCommandRegister); - setOSDictionaryNumber(property_array, "DataRegister", hid_descriptor.wDataRegister); - setOSDictionaryNumber(property_array, "VendorID", hid_descriptor.wVendorID); - setOSDictionaryNumber(property_array, "ProductID", hid_descriptor.wProductID); - setOSDictionaryNumber(property_array, "VersionID", hid_descriptor.wVersionID); - - setProperty("HIDDescriptor", property_array); - - OSSafeReleaseNULL(property_array); - - return kIOReturnSuccess; -} - -IOReturn VoodooI2CHIDDevice::getHIDDescriptorAddress() { - IOReturn ret; - OSObject *obj = nullptr; - - ret = api->evaluateDSM(I2C_DSM_HIDG, HIDG_DESC_INDEX, &obj); - if (ret == kIOReturnSuccess) { - OSNumber *number = OSDynamicCast(OSNumber, obj); - if (number != nullptr) { - hid_descriptor_register = number->unsigned16BitValue(); - setProperty("HIDDescriptorAddress", hid_descriptor_register, 16); - } else { - IOLog("%s::%s HID descriptor address invalid\n", getName(), name); - ret = kIOReturnInvalid; - } - } else { - IOLog("%s::%s unable to parse HID descriptor address\n", getName(), name); - ret = kIOReturnNotFound; - } - if (obj) obj->release(); - return ret; -} - -void VoodooI2CHIDDevice::getInputReport() { - IOBufferMemoryDescriptor* buffer; - IOReturn ret; - unsigned char* report = (unsigned char *)IOMalloc(hid_descriptor.wMaxInputLength); - - api->readI2C(report, hid_descriptor.wMaxInputLength); - - int return_size = report[0] | report[1] << 8; - - if (!return_size) { - // IOLog("%s::%s Device sent a 0-length report\n", getName(), name); - command_gate->commandWakeup(&reset_event); - goto exit; - } - - if (!ready_for_input) - goto exit; - - if (return_size > hid_descriptor.wMaxInputLength) { - // IOLog("%s: Incomplete report %d/%d\n", getName(), hid_descriptor.wMaxInputLength, return_size); - goto exit; - } - - buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, return_size); - buffer->writeBytes(0, report + 2, return_size - 2); - - ret = handleReport(buffer, kIOHIDReportTypeInput); - - if (ret != kIOReturnSuccess) - IOLog("%s::%s Error handling input report: 0x%.8x\n", getName(), name, ret); - - OSSafeReleaseNULL(buffer); -exit: - IOFree(report, hid_descriptor.wMaxInputLength); - return; -} - -IOReturn VoodooI2CHIDDevice::getReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType != kIOHIDReportTypeFeature && reportType != kIOHIDReportTypeInput) - return kIOReturnBadArgument; - - UInt8 args[3]; - IOReturn ret; - int args_len = 0; - UInt16 read_register = hid_descriptor.wDataRegister; - UInt8 report_id = options & 0xFF; - UInt8 raw_report_type = (reportType == kIOHIDReportTypeFeature) ? 0x03 : 0x01; - - UInt8* buffer = (UInt8*)IOMalloc(report->getLength()+2); - - - if (report_id >= 0x0F) { - args[args_len++] = report_id; - report_id = 0x0F; - } - - args[args_len++] = read_register & 0xFF; - args[args_len++] = read_register >> 8; - - UInt8 length = 4; - - VoodooI2CHIDDeviceCommand* command = (VoodooI2CHIDDeviceCommand*)IOMalloc(4 + args_len); - memset(command, 0, 4+args_len); - command->c.reg = hid_descriptor.wCommandRegister; - command->c.opcode = 0x02; - command->c.report_type_id = report_id | raw_report_type << 4; - - UInt8* raw_command = (UInt8*)command; - - memcpy(raw_command + length, args, args_len); - length += args_len; - ret = api->writeReadI2C(raw_command, length, buffer, report->getLength()+2); - - report->writeBytes(0, buffer+2, report->getLength()); - - IOFree(buffer, report->getLength()+2); - IOFree(command, 4+args_len); - - return ret; -} - -void VoodooI2CHIDDevice::interruptOccured(OSObject* owner, IOInterruptEventSource* src, int intCount) { - if (!awake) - return; - - command_gate->attemptAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooI2CHIDDevice::getInputReport)); -} - -VoodooI2CHIDDevice* VoodooI2CHIDDevice::probe(IOService* provider, SInt32* score) { - if (!super::probe(provider, score)) - return NULL; - - name = getMatchedName(provider); - - acpi_device = OSDynamicCast(IOACPIPlatformDevice, provider->getProperty("acpi-device")); - //acpi_device->retain(); - - if (!acpi_device) { - IOLog("%s::%s Could not get ACPI device\n", getName(), name); - return NULL; - } - - // Sometimes an I2C HID will have power state methods, lets turn it on in case - - acpi_device->evaluateObject("_PS0"); - - api = OSDynamicCast(VoodooI2CDeviceNub, provider); - //api->retain(); - - if (!api) { - IOLog("%s::%s Could not get VoodooI2C API access\n", getName(), name); - return NULL; - } - - if (getHIDDescriptorAddress() != kIOReturnSuccess) { - IOLog("%s::%s Could not get HID descriptor\n", getName(), name); - return NULL; - } - - if (getHIDDescriptor() != kIOReturnSuccess) { - IOLog("%s::%s Could not get HID descriptor\n", getName(), name); - return NULL; - } - - return this; -} - -void VoodooI2CHIDDevice::releaseResources() { - if (command_gate) { - command_gate->disable(); - work_loop->removeEventSource(command_gate); - OSSafeReleaseNULL(command_gate); - } - - stopInterrupt(); - - if (interrupt_simulator) { - work_loop->removeEventSource(interrupt_simulator); - OSSafeReleaseNULL(interrupt_simulator); - } - - if (interrupt_source) { - work_loop->removeEventSource(interrupt_source); - OSSafeReleaseNULL(interrupt_source); - } - - if (work_loop) { - OSSafeReleaseNULL(work_loop); - } - - if (acpi_device) { - OSSafeReleaseNULL(acpi_device); - } - - if (api) { - if (api->isOpen(this)) - api->close(this); - OSSafeReleaseNULL(api); - } -} - -IOReturn VoodooI2CHIDDevice::resetHIDDevice() { - return command_gate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooI2CHIDDevice::resetHIDDeviceGated)); -} - -IOReturn VoodooI2CHIDDevice::resetHIDDeviceGated() { - setHIDPowerState(kVoodooI2CStateOn); - - VoodooI2CHIDDeviceCommand command; - command.c.reg = hid_descriptor.wCommandRegister; - command.c.opcode = 0x01; - command.c.report_type_id = 0; - - api->writeI2C(command.data, 4); - - if (quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET) { - IOSleep(100); - } else { - // Device is required to complete a host-initiated reset in at most 5 seconds. We give it 12 as Linux quirks don't handle some devices. - - AbsoluteTime absolute_time, deadline; - nanoseconds_to_absolutetime(12000000000, &absolute_time); - clock_absolutetime_interval_to_deadline(absolute_time, &deadline); - - IOReturn sleep = command_gate->commandSleep(&reset_event, deadline, THREAD_UNINT); - - if (sleep == THREAD_TIMED_OUT) { - IOLog("%s::%s Timeout waiting for device to complete host initiated reset\n", getName(), name); - return kIOReturnTimeout; - } else if (sleep == THREAD_AWAKENED) { - IOLog("%s::%s Device initiated reset accomplished\n", getName(), name); - } - } - - return kIOReturnSuccess; -} - -IOReturn VoodooI2CHIDDevice::setHIDPowerState(VoodooI2CState state) { - VoodooI2CHIDDeviceCommand command; - IOReturn ret = kIOReturnSuccess; - int attempts = 5; - do { - command.c.reg = hid_descriptor.wCommandRegister; - command.c.opcode = 0x08; - command.c.report_type_id = state ? I2C_HID_PWR_ON : I2C_HID_PWR_SLEEP; - - ret = api->writeI2C(command.data, 4); - IOSleep(100); - } while (ret != kIOReturnSuccess && --attempts >= 0); - return ret; -} - -IOReturn VoodooI2CHIDDevice::setReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType != kIOHIDReportTypeFeature && reportType != kIOHIDReportTypeOutput) - return kIOReturnBadArgument; - - UInt16 data_register = hid_descriptor.wDataRegister; - UInt8 raw_report_type = (reportType == kIOHIDReportTypeFeature) ? 0x03 : 0x02; - UInt8 idx = 0; - UInt16 size; - UInt16 arguments_length; - UInt8 report_id = options & 0xFF; - UInt16 report_length = report->getLength(); - UInt8* buffer = (UInt8*)IOMalloc(report_length); - UInt8* orig_buffer = buffer; - - report->readBytes(0, buffer, report_length); - if(report_id == buffer[0]){ - buffer++; - report_length--; - } - size = 2 + - (report_id ? 1 : 0) /* reportID */ + - report_length /* buf */; - - arguments_length = (report_id >= 0x0F ? 1 : 0) /* optional third byte */ + - 2 /* dataRegister */ + - size /* args */; - - UInt8* arguments = (UInt8*)IOMalloc(arguments_length); - memset(arguments, 0, arguments_length); - - if (report_id >= 0x0F) { - arguments[idx++] = report_id; - report_id = 0x0F; - } - - arguments[idx++] = data_register & 0xFF; - arguments[idx++] = data_register >> 8; - - arguments[idx++] = size & 0xFF; - arguments[idx++] = size >> 8; - - if (report_id) - arguments[idx++] = report_id; - - memcpy(&arguments[idx], buffer, report_length); - - UInt8 length = 4; - - VoodooI2CHIDDeviceCommand* command = (VoodooI2CHIDDeviceCommand*)IOMalloc(4 + arguments_length); - memset(command, 0, 4+arguments_length); - command->c.reg = hid_descriptor.wCommandRegister; - command->c.opcode = 0x03; - command->c.report_type_id = report_id | raw_report_type << 4; - - UInt8* raw_command = (UInt8*)command; - - memcpy(raw_command + length, arguments, arguments_length); - length += arguments_length; - IOReturn ret = api->writeI2C(raw_command, length); - IOSleep(10); - IOFree(command, 4+arguments_length); - IOFree(arguments, arguments_length); - IOFree(orig_buffer, report->getLength()); - - return ret; -} - -void VoodooI2CHIDDevice::lookupQuirks() { - quirks = 0; - for (size_t n = 0; i2c_hid_quirks[n].idVendor; n++) { - if (i2c_hid_quirks[n].idVendor == hid_descriptor.wVendorID && - (i2c_hid_quirks[n].idProduct == HID_ANY_ID || - i2c_hid_quirks[n].idProduct == hid_descriptor.wProductID)) { - quirks = i2c_hid_quirks[n].quirks; - } - } -} - -IOReturn VoodooI2CHIDDevice::setPowerState(unsigned long whichState, IOService* whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (whichState == 0) { - if (awake) { - setHIDPowerState(kVoodooI2CStateOff); - - stopInterrupt(); - - IOLog("%s::%s Going to sleep\n", getName(), name); - awake = false; - } - } else { - if (!awake) { - awake = true; - - startInterrupt(); - - if (quirks & I2C_HID_QUIRK_RESET_ON_RESUME) { - resetHIDDevice(); - } else { - setHIDPowerState(kVoodooI2CStateOn); - } - - IOLog("%s::%s Woke up\n", getName(), name); - } - } - return kIOPMAckImplied; -} - -bool VoodooI2CHIDDevice::handleStart(IOService* provider) { - if (!IOHIDDevice::handleStart(provider)) { - return false; - } - - work_loop = getWorkLoop(); - - if (!work_loop) { - IOLog("%s::%s Could not get work loop\n", getName(), name); - goto exit; - } - - work_loop->retain(); - - command_gate = IOCommandGate::commandGate(this); - if (!command_gate || (work_loop->addEventSource(command_gate) != kIOReturnSuccess)) { - IOLog("%s::%s Could not open command gate\n", getName(), name); - goto exit; - } - - acpi_device->retain(); - api->retain(); - - if (!api->open(this)) { - IOLog("%s::%s Could not open API\n", getName(), name); - goto exit; - } - - interrupt_source = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &VoodooI2CHIDDevice::interruptOccured), api, 0); - if (interrupt_source) { - work_loop->addEventSource(interrupt_source); - } else { - IOLog("%s::%s Warning: Could not get interrupt event source, using polling instead\n", getName(), name); - interrupt_simulator = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &VoodooI2CHIDDevice::simulateInterrupt)); - - if (!interrupt_simulator) { - IOLog("%s::%s Could not get timer event source\n", getName(), name); - goto exit; - } - - work_loop->addEventSource(interrupt_simulator); - } - startInterrupt(); - - lookupQuirks(); - resetHIDDevice(); - - - PMinit(); - api->joinPMtree(this); - registerPowerDriver(this, myIOPMPowerStates, kIOPMNumberPowerStates); - - // Give the reset a bit of time so that IOHIDDevice doesnt happen to start requesting the report - // descriptor before the driver is ready - - IOSleep(100); - - return true; -exit: - releaseResources(); - return false; -} - -bool VoodooI2CHIDDevice::start(IOService* provider) { - if (!super::start(provider)) - return false; - - ready_for_input = true; - - setProperty("VoodooI2CServices Supported", kOSBooleanTrue); - - return true; -} - -void VoodooI2CHIDDevice::stop(IOService* provider) { - IOLockLock(client_lock); - for(;;) { - if (!clients->getCount()) { - break; - } - - IOLockSleep(client_lock, &client_lock, THREAD_UNINT); - } - IOLockUnlock(client_lock); - - releaseResources(); - OSSafeReleaseNULL(clients); - PMstop(); - super::stop(provider); -} - -IOReturn VoodooI2CHIDDevice::newReportDescriptor(IOMemoryDescriptor** descriptor) const { - if (!hid_descriptor.wReportDescLength) { - IOLog("%s::%s Invalid report descriptor size\n", getName(), name); - return kIOReturnDeviceError; - } - - VoodooI2CHIDDeviceCommand command; - command.c.reg = hid_descriptor.wReportDescRegister; - - UInt8* buffer = reinterpret_cast(IOMalloc(hid_descriptor.wReportDescLength)); - memset(buffer, 0, hid_descriptor.wReportDescLength); - - if (api->writeReadI2C(command.data, 2, buffer, hid_descriptor.wReportDescLength) != kIOReturnSuccess) { - IOLog("%s::%s Could not get report descriptor\n", getName(), name); - IOFree(buffer, hid_descriptor.wReportDescLength); - return kIOReturnIOError; - } - - IOBufferMemoryDescriptor* report_descriptor = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, hid_descriptor.wReportDescLength); - - if (!report_descriptor) { - IOLog("%s::%s Could not allocated buffer for report descriptor\n", getName(), name); - return kIOReturnNoResources; - } - - report_descriptor->writeBytes(0, buffer, hid_descriptor.wReportDescLength); - *descriptor = report_descriptor; - - IOFree(buffer, hid_descriptor.wReportDescLength); - - return kIOReturnSuccess; -} - -OSNumber* VoodooI2CHIDDevice::newVendorIDNumber() const { - return OSNumber::withNumber(hid_descriptor.wVendorID, 16); -} - -OSNumber* VoodooI2CHIDDevice::newProductIDNumber() const { - return OSNumber::withNumber(hid_descriptor.wProductID, 16); -} - -OSNumber* VoodooI2CHIDDevice::newVersionNumber() const { - return OSNumber::withNumber(hid_descriptor.wVersionID, 16); -} - -OSString* VoodooI2CHIDDevice::newTransportString() const { - return OSString::withCString("I2C"); -} - -OSString* VoodooI2CHIDDevice::newManufacturerString() const { - return OSString::withCString("Apple"); -} - -void VoodooI2CHIDDevice::simulateInterrupt(OSObject* owner, IOTimerEventSource* timer) { - AbsoluteTime prev_time = last_multi_touch_event; - if (awake) { - VoodooI2CHIDDevice::getInputReport(); - } - - if (last_multi_touch_event == 0) { - interrupt_simulator->setTimeoutMS(INTERRUPT_SIMULATOR_TIMEOUT); - return; - } - - IOSleep(1); - if (last_multi_touch_event != prev_time) { - interrupt_simulator->setTimeoutMS(INTERRUPT_SIMULATOR_TIMEOUT_BUSY); - return; - } - - uint64_t nsecs; - AbsoluteTime cur_time; - clock_get_uptime(&cur_time); - SUB_ABSOLUTETIME(&cur_time, &last_multi_touch_event); - absolutetime_to_nanoseconds(cur_time, &nsecs); - interrupt_simulator->setTimeoutMS((nsecs > 1500000000) ? INTERRUPT_SIMULATOR_TIMEOUT_IDLE : INTERRUPT_SIMULATOR_TIMEOUT_BUSY); -} - -bool VoodooI2CHIDDevice::open(IOService *forClient, IOOptionBits options, void *arg) { - IOLockLock(client_lock); - clients->setObject(forClient); - IOUnlock(client_lock); - - return super::open(forClient, options, arg); -} - -void VoodooI2CHIDDevice::close(IOService *forClient, IOOptionBits options) { - IOLockLock(client_lock); - - for(int i = 0; i < clients->getCount(); i++) { - OSObject* service = clients->getObject(i); - - if (service == forClient) { - clients->removeObject(i); - break; - } - } - - IOUnlock(client_lock); - - IOLockWakeup(client_lock, &client_lock, true); - - super::close(forClient, options); -} - -void VoodooI2CHIDDevice::startInterrupt() { - if (is_interrupt_started) { - return; - } - - if (interrupt_simulator) { - interrupt_simulator->setTimeoutMS(200); - interrupt_simulator->enable(); - } else if (interrupt_source) { - interrupt_source->enable(); - } - is_interrupt_started = true; -} - -void VoodooI2CHIDDevice::stopInterrupt() { - if (!is_interrupt_started) { - return; - } - - if (interrupt_simulator) { - interrupt_simulator->disable(); - } else if (interrupt_source) { - interrupt_source->disable(); - } - is_interrupt_started = false; -} diff --git a/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.hpp b/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.hpp deleted file mode 100644 index 34a6920..0000000 --- a/BigSurface/BigSurface/SurfaceHID/VoodooI2CHIDDevice.hpp +++ /dev/null @@ -1,324 +0,0 @@ -// -// VoodooI2CHIDDevice.hpp -// VoodooI2CHID -// -// Created by Alexandre on 25/08/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CHIDDevice_hpp -#define VoodooI2CHIDDevice_hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../../../Dependencies/VoodooSerial/VoodooSerial/utils/helpers.hpp" - -#define INTERRUPT_SIMULATOR_TIMEOUT 5 -#define INTERRUPT_SIMULATOR_TIMEOUT_BUSY 2 -#define INTERRUPT_SIMULATOR_TIMEOUT_IDLE 50 - -#define I2C_HID_PWR_ON 0x00 -#define I2C_HID_PWR_SLEEP 0x01 - - -#define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) -#define I2C_HID_QUIRK_RESET_ON_RESUME BIT(5) - -#define HID_ANY_ID 0xFFFF - -#define USB_VENDOR_ID_ALPS_JP 0x044E - -#define I2C_VENDOR_ID_HANTICK 0x0911 -#define I2C_PRODUCT_ID_HANTICK_5288 0x5288 - -#define I2C_VENDOR_ID_RAYDIUM 0x2386 -#define I2C_PRODUCT_ID_RAYDIUM_3118 0x3118 - -#define I2C_VENDOR_ID_SYNAPTICS 0x06cb -#define I2C_PRODUCT_ID_SYNAPTICS_SYNA2393 0x7a13 - - -#define EXPORT __attribute__((visibility("default"))) - -typedef union { - UInt8 data[4]; - struct __attribute__((__packed__)) cmd { - UInt16 reg; - UInt8 report_type_id; - UInt8 opcode; - } c; -} VoodooI2CHIDDeviceCommand; - -typedef struct __attribute__((__packed__)) { - UInt16 wHIDDescLength; - UInt16 bcdVersion; - UInt16 wReportDescLength; - UInt16 wReportDescRegister; - UInt16 wInputRegister; - UInt16 wMaxInputLength; - UInt16 wOutputRegister; - UInt16 wMaxOutputLength; - UInt16 wCommandRegister; - UInt16 wDataRegister; - UInt16 wVendorID; - UInt16 wProductID; - UInt16 wVersionID; - UInt32 reserved; -} VoodooI2CHIDDeviceHIDDescriptor; - -static const struct i2c_hid_quirks { - UInt16 idVendor; - UInt16 idProduct; - UInt32 quirks; -} i2c_hid_quirks[] = { - { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, - { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118, - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, - { USB_VENDOR_ID_ALPS_JP, HID_ANY_ID, - I2C_HID_QUIRK_RESET_ON_RESUME }, - { I2C_VENDOR_ID_SYNAPTICS, I2C_PRODUCT_ID_SYNAPTICS_SYNA2393, - I2C_HID_QUIRK_RESET_ON_RESUME }, - { 0, 0 } -}; - -class VoodooI2CDeviceNub; - -/* Implements an I2C-HID device as specified by Microsoft's protocol in the following document: http://download.microsoft.com/download/7/D/D/7DD44BB7-2A7A-4505-AC1C-7227D3D96D5B/hid-over-i2c-protocol-spec-v1-0.docx - * - * The members of this class are responsible for issuing I2C-HID commands via the device API as well as interacting with OS X's HID stack. - */ - - -class EXPORT VoodooI2CHIDDevice : public IOHIDDevice { - OSDeclareDefaultStructors(VoodooI2CHIDDevice); - - public: - const char* name; - - /* Initialises a object - * @properties Contains the properties of the matched provider - * - * This is the first function called during the load routine and - * allocates the memory needed for a object. - * - * @return *true* upon successful initialisation, *false* otherwise - */ - - bool init(OSDictionary* properties) override; - - /* Frees the object - * - * This is the last function called during the unload routine and - * frees the memory allocated in . - */ - - void free() override; - - /* - * Issues an I2C-HID command to get the HID descriptor from the device. - * - * @return *kIOReturnSuccess* on sucessfully getting the HID descriptor, *kIOReturnIOError* if the request failed, *kIOReturnInvalid* if the descriptor is invalid - */ - virtual IOReturn getHIDDescriptor(); - - /* - * Gets the HID descriptor address by evaluating the device's '_DSM' method in the ACPI tables - * - * @return *kIOReturnSuccess* on sucessfully getting the HID descriptor address, *kIOReturnNotFound* if neither the '_DSM' method nor the '_XDSM' was found, *kIOReturnInvalid* if the address is invalid - */ - - IOReturn getHIDDescriptorAddress(); - - IOReturn getReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) override; - - IOReturn parseHIDDescriptor(); - - /* Probes the candidate I2C-HID device to see if this driver can indeed drive it - * @provider The provider which we have matched against - * @score Probe score as specified in the matched personality - * - * This function is responsible for querying the ACPI tables for the HID descriptor address and then - * requesting the HID descriptor from the device. - * - * @return A pointer to this instance of VoodooI2CHID upon succesful probe, else NULL - */ - - VoodooI2CHIDDevice* probe(IOService* provider, SInt32* score) override; - - /* Run during the routine - * @provider The provider which we have matched against - * - * We override in order to allocate the work loop and resources - * so that code is run synchronously with code. - * - * @return *true* upon successful start, *false* otherwise - */ - - bool handleStart(IOService* provider) override; - - void simulateInterrupt(OSObject* owner, IOTimerEventSource* timer); - - /* Sets a few properties that are needed after finishes starting - * @provider The provider which we have matched against - * - * @return *true* upon successful start, *false* otherwise - */ - - bool start(IOService* provider) override; - - /* Stops the I2C-HID Device - * @provider The provider which we have matched against - * - * This function is called before and is responsible for deallocating the resources - * that were allocated in . - */ - - void stop(IOService* provider) override; - - /* Create and return a new memory descriptor that describes the report descriptor for the HID device - * @descriptor Pointer to the memory descriptor returned. This memory descriptor will be released by the caller. - * - * @return *kIOReturnSuccess* on success, or an error return otherwise. - */ - - IOReturn newReportDescriptor(IOMemoryDescriptor** descriptor) const override; - - /* Returns a number object that describes the vendor ID of the HID device. - * - * @return A number object. The caller must decrement the retain count on the object returned. - */ - - OSNumber* newVendorIDNumber() const override; - - /* Returns a number object that describes the product ID of the HID device. - * - * @return A number object. The caller must decrement the retain count on the object returned. - */ - - OSNumber* newProductIDNumber() const override; - - /* Returns a number object that describes the version number of the HID device. - * - * @return A number object. The caller must decrement the retain count on the object returned. - */ - - OSNumber* newVersionNumber() const override; - - /* Returns a string object that describes the transport layer used by the HID device. - * - * @return A string object. The caller must decrement the retain count on the object returned. - */ - - OSString* newTransportString() const override; - - /* Returns a string object that describes the manufacturer of the HID device. - * - * @return A string object. The caller must decrement the retain count on the object returned. - */ - - OSString* newManufacturerString() const override; - - bool open(IOService *forClient, IOOptionBits options = 0, void *arg = 0) override; - void close(IOService *forClient, IOOptionBits options) override; - - protected: - bool awake; - IOWorkLoop* work_loop; - - IOLock* client_lock; - OSArray* clients; - - VoodooI2CHIDDeviceHIDDescriptor hid_descriptor; - - IOReturn resetHIDDeviceGated(); - - /* Issues an I2C-HID reset command. - * - * @return *kIOReturnSuccess* on successful reset, *kIOReturnTimeout* otherwise - */ - - IOReturn resetHIDDevice(); - - /* Issues an I2C-HID power state command. - * @state The power state that the device should enter - * - * @return *kIOReturnSuccess* on successful power state change, *kIOReturnTimeout* otherwise - */ - - IOReturn setHIDPowerState(VoodooI2CState state); - - /* Called by the OS's power management stack to notify the driver that it should change the power state of the deice - * @whichState The power state the device is expected to enter represented by either - * *kIOPMPowerOn* or *kIOPMPowerOff* - * @whatDevice The power management policy maker - * - * - * @return *kIOPMAckImplied* on succesful state change, *kIOReturnError* otherwise - */ - - IOReturn setPowerState(unsigned long whichState, IOService* whatDevice) override; - - /* Issues an I2C-HID set report command. - * @report The report data to be sent to the device - * @reportType The type of HID report to be sent - * @options Options for the report, the first two bytes are the report ID - * - * @return *kIOReturnSuccess* on successful power state change, *kIOReturnTimeout* otherwise - */ - - IOReturn setReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) override; - - /* - * Lookup and set any quirks associated with the I2C HID device. - */ - - void lookupQuirks(); - - private: - IOACPIPlatformDevice* acpi_device; - VoodooI2CDeviceNub* api; - IOCommandGate* command_gate; - UInt16 hid_descriptor_register; - IOTimerEventSource* interrupt_simulator; - IOInterruptEventSource* interrupt_source; - bool ready_for_input; - bool* reset_event; - bool is_interrupt_started = false; - UInt32 quirks = 0; - - /* Queries the I2C-HID device for an input report - * - * This function is called from the interrupt handler in a new thread. It is thus not called from interrupt context. - */ - - void getInputReport(); - - /* - * This function is called when the I2C-HID device asserts its interrupt line. - */ - - void interruptOccured(OSObject* owner, IOInterruptEventSource* src, int intCount); - - /* Releases resources allocated in - * - * This function is called during a graceful exit from and during - * execution of in order to release resources retained by . - */ - - void releaseResources(); - - void startInterrupt(); - - void stopInterrupt(); -}; - - -#endif /* VoodooI2CHIDDevice_hpp */ diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/MEIProtocol.h b/BigSurface/BigSurface/SurfaceManagementEngine/MEIProtocol.h similarity index 100% rename from BigSurface/BigSurface/SurfaceTouchScreen/MEIProtocol.h rename to BigSurface/BigSurface/SurfaceManagementEngine/MEIProtocol.h diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.cpp b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.cpp similarity index 88% rename from BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.cpp rename to BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.cpp index 07fde27..1446351 100644 --- a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.cpp +++ b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.cpp @@ -67,10 +67,6 @@ bool SurfaceManagementEngineClient::start(IOService *provider) { rx_cache = new UInt8[properties.max_msg_length]; initial = false; - - PMinit(); - api->joinPMtree(this); - registerPowerDriver(this, MyIOPMPowerStates, kIOPMNumberPowerStates); registerService(); return true; @@ -81,7 +77,6 @@ bool SurfaceManagementEngineClient::start(IOService *provider) { void SurfaceManagementEngineClient::stop(IOService *provider) { releaseResources(); - PMstop(); super::stop(provider); } @@ -105,23 +100,6 @@ void SurfaceManagementEngineClient::releaseResources() { IOLockFree(queue_lock); } -IOReturn SurfaceManagementEngineClient::setPowerState(unsigned long whichState, IOService *whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (whichState == 0) { - if (awake) { - awake = false; - LOG("Going to sleep"); - } - } else { - if (!awake) { - awake = true; - LOG("Woke up"); - } - } - return kIOPMAckImplied; -} - IOReturn SurfaceManagementEngineClient::registerMessageHandler(OSObject *owner, MessageHandler _handler) { if (!owner || !_handler) return kIOReturnError; @@ -135,9 +113,14 @@ IOReturn SurfaceManagementEngineClient::registerMessageHandler(OSObject *owner, return kIOReturnSuccess; } +void SurfaceManagementEngineClient::unregisterMessageHandler(OSObject *owner) { + if (target && target == owner) { + target = nullptr; + handler = nullptr; + } +} + IOReturn SurfaceManagementEngineClient::sendMessage(UInt8 *data, UInt16 data_len, bool blocking) { - if (!awake) - return kIOReturnError; if (!active) return kIOReturnNoDevice; @@ -163,10 +146,8 @@ void SurfaceManagementEngineClient::hostRequestReconnect() { } void SurfaceManagementEngineClient::messageComplete() { - if (!awake || !rx_cache_pos) { // rx_cache_pos shouldn't be 0 - rx_cache_pos = 0; + if (!rx_cache_pos) return; - } MEIClientMessage *client_msg = new MEIClientMessage; client_msg->msg = new UInt8[rx_cache_pos]; diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.hpp b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.hpp similarity index 90% rename from BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.hpp rename to BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.hpp index 2ad5867..c34efdf 100644 --- a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineClient.hpp +++ b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineClient.hpp @@ -21,11 +21,10 @@ struct MEIClientMessage { class EXPORT SurfaceManagementEngineClient : public IOService { OSDeclareDefaultStructors(SurfaceManagementEngineClient); - friend class SurfaceManagementEngineDriver; public: - // handle received message, when msg = nullptr, it means d0i3 enter/exit depends on msg_len=1/0 + // handle received message typedef void (*MessageHandler)(OSObject *owner, SurfaceManagementEngineClient *sender, UInt8 *msg, UInt16 msg_len); bool attach(IOService* provider) override; @@ -36,10 +35,10 @@ class EXPORT SurfaceManagementEngineClient : public IOService { void stop(IOService* provider) override; - IOReturn setPowerState(unsigned long whichState, IOService *whatDevice) override; - IOReturn registerMessageHandler(OSObject *owner, MessageHandler _handler); + void unregisterMessageHandler(OSObject *owner); + IOReturn sendMessage(UInt8 *data, UInt16 data_len, bool blocking); private: @@ -56,7 +55,6 @@ class EXPORT SurfaceManagementEngineClient : public IOService { UInt16 rx_cache_pos {0}; UInt8 addr; - bool awake {true}; bool active {false}; bool initial {true}; diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineDriver.cpp b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineDriver.cpp similarity index 99% rename from BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineDriver.cpp rename to BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineDriver.cpp index acee747..6a6d4c6 100644 --- a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineDriver.cpp +++ b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineDriver.cpp @@ -860,15 +860,19 @@ IOReturn SurfaceManagementEngineDriver::sendClientMessageGated(SurfaceManagement MEIClientTransaction *tx = new MEIClientTransaction; tx->client = client; - tx->data = buffer; tx->data_len = *buffer_len; + tx->data = new UInt8[tx->data_len]; + memcpy(tx->data, buffer, tx->data_len); tx->completed = false; tx->blocking = *blocking; IOReturn ret = kIOReturnSuccess; - if (tx->blocking) { - if (!acquireWriteBuffer() || !submitTransaction(tx)) { // not finished - enqueue(&bus.tx_queue, &tx->entry); + if (acquireWriteBuffer() && submitTransaction(tx)) { + delete[] tx->data; + delete tx; + } else { + enqueue(&bus.tx_queue, &tx->entry); + if (tx->blocking) { AbsoluteTime abstime, deadline; nanoseconds_to_absolutetime(MEI_CLIENT_SEND_MSG_TIMEOUT * 1000000ULL, &abstime); clock_absolutetime_interval_to_deadline(abstime, &deadline); @@ -878,13 +882,8 @@ IOReturn SurfaceManagementEngineDriver::sendClientMessageGated(SurfaceManagement ret = kIOReturnTimeout; } remqueue(&tx->entry); - } - delete tx; - } else { - if (!acquireWriteBuffer() || !submitTransaction(tx)) { // not finished - tx->data = new UInt8[tx->data_len]; - memcpy(tx->data, buffer, tx->data_len); - enqueue(&bus.tx_queue, &tx->entry); + delete[] tx->data; + delete tx; } } diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineDriver.hpp b/BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineDriver.hpp similarity index 100% rename from BigSurface/BigSurface/SurfaceTouchScreen/SurfaceManagementEngineDriver.hpp rename to BigSurface/BigSurface/SurfaceManagementEngine/SurfaceManagementEngineDriver.hpp diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/AverageClasses.h b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/AverageClasses.h deleted file mode 100644 index 25d7751..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/AverageClasses.h +++ /dev/null @@ -1,129 +0,0 @@ -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// SimpleAverage Class Declaration -// - -#ifndef SimpleAverage_h -#define SimpleAverage_h - -template -class SimpleAverage -{ -private: - T m_buffer[N]; - int m_count; - int m_sum; - int m_index; - -public: - inline SimpleAverage() { reset(); } - T filter(T data) - { - // add new entry to sum - m_sum += data; - // if full buffer, then we are overwriting, so subtract old from sum - if (m_count == N) - m_sum -= m_buffer[m_index]; - // new entry into buffer - m_buffer[m_index] = data; - // move index to next position with wrap around - if (++m_index >= N) - m_index = 0; - // keep count moving until buffer is full - if (m_count < N) - ++m_count; - // return average of current items - return m_sum / m_count; - } - inline void reset() - { - m_count = 0; - m_sum = 0; - m_index = 0; - } - inline int count() { return m_count; } - inline int sum() { return m_sum; } - T oldest() - { - // undefined if nothing in here, return zero - if (m_count == 0) - return 0; - // if it is not full, oldest is at index 0 - // if full, it is right where the next one goes - if (m_count < N) - return m_buffer[0]; - else - return m_buffer[m_index]; - } - T newest() - { - // undefined if nothing in here, return zero - if (m_count == 0) - return 0; - // newest is index - 1, with wrap - int index = m_index; - if (--index < 0) - index = m_count - 1; - return m_buffer[index]; - } - T average() - { - if (m_count == 0) - return 0; - return m_sum / m_count; - } -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// DecayingAverage Class Declaration -// - -template -class DecayingAverage -{ -private: - T m_last; - bool m_lastvalid; - -public: - inline DecayingAverage() { reset(); } - T filter(T data, int fingers) - { - TT result = data; - TT last = m_last; - if (m_lastvalid) - result = (result * N1) / D + (last * N2) / D; - m_lastvalid = true; - m_last = (T)result; - return m_last; - } - inline void reset() - { - m_lastvalid = false; - } -}; - -template -class UndecayAverage -{ -private: - T m_last; - bool m_lastvalid; - -public: - inline UndecayAverage() { reset(); } - T filter(T data) - { - TT result = data; - TT last = m_last; - if (m_lastvalid) - result = (result * D) / N1 - (last * N2) / N1; - m_lastvalid = true; - m_last = (T)data; - return (T)result; - } - inline void reset() - { - m_lastvalid = false; - } -}; -#endif \ No newline at end of file diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.cpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.cpp deleted file mode 100644 index 1af2d79..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// -// VoodooCSGestureHIDWrapper.cpp -// VoodooI2C -// -// Created by Christopher Luu on 10/7/15. -// Copyright © 2015 Alexandre Daoud. All rights reserved. -// - -#include "VoodooCSGestureHIDWrapper.h" -#include "VoodooI2CCSGestureEngine.hpp" - -OSDefineMetaClassAndStructors(VoodooCSGestureHIDWrapper, IOHIDDevice) - -bool VoodooCSGestureHIDWrapper::start(IOService *provider) { - if (!IOHIDDevice::start(provider)) - return false; - setProperty("HIDDefaultBehavior", "Trackpad"); - return true; -} - -IOReturn VoodooCSGestureHIDWrapper::setProperties(OSObject *properties) { - return kIOReturnUnsupported; -} - -IOReturn VoodooCSGestureHIDWrapper::newReportDescriptor(IOMemoryDescriptor **descriptor) const { IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, gestureEngine->reportDescriptorLength()); - - if (buffer == NULL) return kIOReturnNoResources; - gestureEngine->write_report_descriptor_to_buffer(buffer); - *descriptor = buffer; - return kIOReturnSuccess; -} - -IOReturn VoodooCSGestureHIDWrapper::setReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - return kIOReturnUnsupported; -} - -IOReturn VoodooCSGestureHIDWrapper::getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) { - if (reportType == kIOHIDReportTypeOutput) { - gestureEngine->write_report_to_buffer(report); - return kIOReturnSuccess; - } - return kIOReturnUnsupported; -} - -OSString* VoodooCSGestureHIDWrapper::newManufacturerString() const { - return OSString::withCString("CSGesture"); -} - -OSNumber* VoodooCSGestureHIDWrapper::newPrimaryUsageNumber() const { - return OSNumber::withNumber(kHIDUsage_GD_Mouse, 32); -} - -OSNumber* VoodooCSGestureHIDWrapper::newPrimaryUsagePageNumber() const { - return OSNumber::withNumber(kHIDPage_GenericDesktop, 32); -} - -OSNumber* VoodooCSGestureHIDWrapper::newProductIDNumber() const { - return OSNumber::withNumber(gestureEngine->productID, 32); -} - -OSString* VoodooCSGestureHIDWrapper::newProductString() const { - return OSString::withCString("Trackpad"); -} - -OSString* VoodooCSGestureHIDWrapper::newSerialNumberString() const { - return OSString::withCString("1234"); -} - -OSString* VoodooCSGestureHIDWrapper::newTransportString() const { - return OSString::withCString("I2C"); -} - -OSNumber* VoodooCSGestureHIDWrapper::newVendorIDNumber() const { - return OSNumber::withNumber(gestureEngine->vendorID, 16); -} - -OSNumber* VoodooCSGestureHIDWrapper::newLocationIDNumber() const { - return OSNumber::withNumber(123, 32); -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.h b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.h deleted file mode 100644 index 0f3b3fd..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIDWrapper.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// VoodooCSGestureHIDWrapper.h -// VoodooI2C -// -// Created by Christopher Luu on 10/7/15. -// Copyright © 2015 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2C_VoodooCSGestureHIDWrapper_h -#define VoodooI2C_VoodooCSGestureHIDWrapper_h - -#include - -#ifndef EXPORT -#define EXPORT __attribute__((visibility("default"))) -#endif - -class VoodooI2CCSGestureEngine; - -class EXPORT VoodooCSGestureHIDWrapper : public IOHIDDevice -{ - OSDeclareDefaultStructors(VoodooCSGestureHIDWrapper) -public: - VoodooI2CCSGestureEngine *gestureEngine; - - bool start(IOService *provider) override; - - IOReturn setProperties(OSObject *properties) override; - - IOReturn newReportDescriptor(IOMemoryDescriptor **descriptor) const override; - - IOReturn setReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options=0) override; - IOReturn getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) override; - - OSString* newManufacturerString() const override; - OSNumber* newPrimaryUsageNumber() const override; - OSNumber* newPrimaryUsagePageNumber() const override; - OSNumber* newProductIDNumber() const override; - OSString* newProductString() const override; - OSString* newSerialNumberString() const override; - OSString* newTransportString() const override; - OSNumber* newVendorIDNumber() const override; - - OSNumber* newLocationIDNumber() const override; -}; - -#endif /* VoodooI2C_VoodooCSGestureHIDWrapper_h */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.cpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.cpp deleted file mode 100644 index e22e984..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// -// VoodooCSGestureHIPointingWrapper.cpp -// VoodooI2C -// -// Created by CoolStar on 9/6/16. -// Copyright © 2016 CoolStar. All rights reserved. -// - -#include -#include -#include "VoodooCSGestureHIPointingWrapper.hpp" -#include "VoodooI2CCSGestureEngine.hpp" -#include - - -OSDefineMetaClassAndStructors(VoodooCSGestureHIPointingWrapper, IOHIPointing); - -UInt32 VoodooCSGestureHIPointingWrapper::deviceType() -{ - return NX_EVS_DEVICE_TYPE_MOUSE; -} - -UInt32 VoodooCSGestureHIPointingWrapper::interfaceID() -{ - return NX_EVS_DEVICE_INTERFACE_BUS_ACE; -} - -IOItemCount VoodooCSGestureHIPointingWrapper::buttonCount(){ - return 2; -}; - -IOFixed VoodooCSGestureHIPointingWrapper::resolution(){ - return (300) << 16; -}; - -bool VoodooCSGestureHIPointingWrapper::init() { - if (!super::init()) - return false; - - return true; -} - -bool VoodooCSGestureHIPointingWrapper::start(IOService *provider) { - if (!super::start(provider)) - return false; - - int enabledProperty = 1; - - if (version_major >= 16) { - - setProperty("SupportsGestureScrolling", true); - setProperty("TrackpadFourFingerGestures", false); - setProperty("ApplePreferenceIdentifier", "com.apple.AppleMultitouchTrackpad"); - setProperty("MTHIDDevice", true); - setProperty("MT Built-in", true); - setProperty("ApplePreferenceCapability", true); - setProperty("TrackpadEmbedded", true); - setProperty("TrackpadThreeFingerDrag", false); - } else { - setProperty("TrackpadCornerSecondaryClick", enabledProperty, - sizeof(enabledProperty) * 8); - } - - setProperty("Clicking", enabledProperty, - sizeof(enabledProperty) * 8); - setProperty("TrackpadScroll", enabledProperty, - sizeof(enabledProperty) * 8); - setProperty("TrackpadHorizScroll", enabledProperty, - sizeof(enabledProperty) * 8); - - - - // - // Must add this property to let our superclass know that it should handle - // trackpad acceleration settings from user space. Without this, tracking - // speed adjustments from the mouse prefs panel have no effect. - // - - //int prodID = 0x223; //old settings pane (VoodooPS2) - int prodID = 0x0262; //product id from newer Macbook - setProperty("ProductID", prodID, sizeof(prodID) * 8); - - int vendorID = 0x05ac; - setProperty("VendorID", vendorID, sizeof(vendorID) * 8); - - //Need to fake Vendor and Product ID to pull up the trackpad settings pane - - setProperty(kIOHIDPointerAccelerationTypeKey, kIOHIDTrackpadAccelerationType); - setProperty(kIOHIDScrollAccelerationTypeKey, kIOHIDTrackpadScrollAccelerationKey); - setProperty(kIOHIDScrollResolutionKey, 800 << 16, 32); - - setProperty("HIDScrollResolutionX", 800 << 16, 32); - setProperty("HIDScrollResolutionY", 800 << 16, 32); - - return true; -} - -void VoodooCSGestureHIPointingWrapper::stop(IOService *provider) { - super::stop(provider); -} - -void VoodooCSGestureHIPointingWrapper::updateRelativeMouse(int dx, int dy, int buttons) { - // 0x1 = left button - // 0x2 = right button - // 0x4 = middle button - - UInt64 now_abs; - clock_get_uptime(&now_abs); - dispatchRelativePointerEvent(dx, dy, buttons, now_abs); -} - -void VoodooCSGestureHIPointingWrapper::updateAbsoluteMouse(SInt16 x, SInt16 y, int buttons) { - // 0x1 = left button - // 0x2 = right button - // 0x4 = middle button - - UInt64 now_abs; - clock_get_uptime(&now_abs); - - IOGPoint loc; - loc.x = x; - loc.y = y; - - IOGBounds bounds; - bounds.minx = 0; - bounds.maxx = gesturerec->softc.resx; - bounds.minx = 0; - bounds.maxy = gesturerec->softc.resy; - - //IOLog("%s::Absolute input (%d x %d) max: (%d x %d)\n", getName(), x, y, gesturerec->softc.resx, gesturerec->softc.resy); - - dispatchAbsolutePointerEvent(&loc, &bounds, buttons, false, 0, 0, 0, 90, now_abs); -} - -void VoodooCSGestureHIPointingWrapper::updateScroll(short dy, short dx, short dz) { - UInt64 now_abs; - clock_get_uptime(&now_abs); - if (!horizontalScroll) - dx = 0; - dispatchScrollWheelEvent(dy, dx, dz, now_abs); -} - -IOReturn VoodooCSGestureHIPointingWrapper::setParamProperties(OSDictionary *dict) -{ - - /*Known Keys: - HIDDefaultParameters, HIDClickTime, HIDClickSpace, HIDKeyRepeat, HIDInitialKeyRepeat, HIDPointerAcceleration, HIDScrollAcceleration, HIDPointerButtonMode, HIDF12EjectDelay, EjectDelay, HIDSlowKeysDelay, HIDStickyKeysDisabled, HIDStickyKeysOn, HIDStickyKeysShiftToggles, HIDMouseKeysOptionToggles, HIDFKeyMode, HIDMouseKeysOn, HIDKeyboardModifierMappingPairs, MouseKeysStopsTrackpad, HIDScrollZoomModifierMask, HIDMouseAcceleration, HIDMouseScrollAcceleration, HIDTrackpadAcceleration, HIDTrackpadScrollAcceleration, TrackpadPinch, TrackpadFourFingerVertSwipeGesture, TrackpadRotate, TrackpadHorizScroll, TrackpadFourFingerPinchGesture, TrackpadTwoFingerDoubleTapGesture, TrackpadMomentumScroll, TrackpadThreeFingerTapGesture, TrackpadThreeFingerHorizSwipeGesture, Clicking, TrackpadScroll, DragLock, TrackpadFiveFingerPinchGesture, TrackpadThreeFingerVertSwipeGesture, TrackpadTwoFingerFromRightEdgeSwipeGesture, Dragging, TrackpadRightClick, TrackpadCornerSecondaryClick, TrackpadFourFingerHorizSwipeGesture, TrackpadThreeFingerDrag, JitterNoMove, JitterNoClick, PalmNoAction When Typing, PalmNoAction Permanent, TwofingerNoAction, OutsidezoneNoAction When Typing, Use Panther Settings for W, Trackpad Jitter Milliseconds, USBMouseStopsTrackpad, HIDWaitCursorFrameInterval*/ - - /* - macOS 10.12 (and above) - Sierra fix requires the cast to be changed to OSBoolean - Still need the OSNumber checks as a last resort, DO NOT clean up the check statements below by checking os version - */ - - OSBoolean *clicking = OSDynamicCast(OSBoolean, dict->getObject("Clicking")); - if (clicking) { - gesturerec->softc.settings.tapToClickEnabled = clicking->isTrue(); - } else { - OSNumber *clickingNum = OSDynamicCast(OSNumber, dict->getObject("Clicking")); - if (clickingNum) { - gesturerec->softc.settings.tapToClickEnabled = clickingNum->unsigned32BitValue() & 0x1; - } - } - - OSBoolean *dragging = OSDynamicCast(OSBoolean, dict->getObject("Dragging")); - if (dragging) { - gesturerec->softc.settings.tapDragEnabled = dragging->isTrue(); - } else { - OSNumber *draggingNum = OSDynamicCast(OSNumber, dict->getObject("Dragging")); - if (draggingNum) { - gesturerec->softc.settings.tapDragEnabled = draggingNum->unsigned32BitValue() & 0x1; - } - - } - - OSBoolean *hscroll = OSDynamicCast(OSBoolean, dict->getObject("TrackpadHorizScroll")); - if (hscroll) { - horizontalScroll = hscroll->isTrue(); - } else { - OSNumber *hscrollNum = OSDynamicCast(OSNumber, dict->getObject("TrackpadHorizScroll")); - if (hscrollNum) { - horizontalScroll = hscrollNum->unsigned32BitValue() & 0x1; - } - } - - OSBoolean* right_click = OSDynamicCast(OSBoolean, dict->getObject("TrackpadCornerSecondaryClick")); - if (right_click) { - gesturerec->softc.settings.literal_right_click = right_click->isTrue(); - } else { - - OSNumber *right_click_num = OSDynamicCast(OSNumber, dict->getObject("TrackpadCornerSecondaryClick")); - if (right_click_num) { - gesturerec->softc.settings.literal_right_click = right_click_num->unsigned32BitValue() & 0x1; - } - } - - - gesturerec->softc.settings.multiFingerTap = true; - - return super::setParamProperties(dict); -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.hpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.hpp deleted file mode 100644 index a7ff8aa..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooCSGestureHIPointingWrapper.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// -// VoodooCSGestureHIPointingWrapper.hpp -// VoodooI2C -// -// Created by CoolStar on 9/6/16. -// Copyright © 2016 CoolStar. All rights reserved. -// - -#ifndef VoodooCSGestureHIPointingWrapper_h -#define VoodooCSGestureHIPointingWrapper_h - -#include - -#ifndef EXPORT -#define EXPORT __attribute__((visibility("default"))) -#endif - -class VoodooI2CCSGestureEngine; - -class EXPORT VoodooCSGestureHIPointingWrapper : public IOHIPointing { - typedef IOHIPointing super; - OSDeclareDefaultStructors(VoodooCSGestureHIPointingWrapper); - -private: - bool horizontalScroll; - -protected: - IOItemCount buttonCount() override; - IOFixed resolution() override; - -public: - VoodooI2CCSGestureEngine* gesturerec; - - bool init() override; - - bool start(IOService *provider) override; - void stop(IOService *provider) override; - - UInt32 deviceType() override; - UInt32 interfaceID() override; - - IOReturn setParamProperties(OSDictionary *dict) override; - - void updateRelativeMouse(int dx, int dy, int buttons); - void updateAbsoluteMouse(SInt16 x, SInt16 y, int buttons); - void updateScroll(short dy, short dx, short dz); -}; - -#endif /* VoodooCSGestureHIPointingWrapper_h */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.cpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.cpp deleted file mode 100644 index e7326e0..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.cpp +++ /dev/null @@ -1,1014 +0,0 @@ -// -// VoodooI2CCSGestureEngine.cpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Based on code written by CoolStar -// Copyright © 2017 CoolStar. All rights reserved. -// - -#include "VoodooI2CCSGestureEngine.hpp" -#include "../VoodooI2CMultitouchInterface.hpp" - -#define super VoodooI2CMultitouchEngine -OSDefineMetaClassAndStructors(VoodooI2CCSGestureEngine, VoodooI2CMultitouchEngine); - -#define REPORTID_FEATURE 0x02 -#define REPORTID_RELATIVE_MOUSE 0x04 -#define REPORTID_TOUCHPAD 0x05 -#define REPORTID_KEYBOARD 0x07 - -#define MOUSE_BUTTON_1 0x01 -#define MOUSE_BUTTON_2 0x02 -#define MOUSE_BUTTON_3 0x04 - -#define KBD_LCONTROL_BIT 1 -#define KBD_LGUI_BIT 8 - -#define KBD_KEY_CODES 6 - -#ifndef ABS32 -#define ABS32 -inline SInt32 abs(SInt32 num){ - if (num < 0){ - return num * -1; - } - return num; -} -#endif - -inline int filterNegative(int val) { - if (val > 0) - return val; - return 65535; -} - -typedef unsigned char BYTE; - -unsigned char csgesturedesc[] = { - // - // Keyboard report starts here - // - 0x05, 0x01, // USAGE_PAGE (Generic Desktop) - 0x09, 0x06, // USAGE (Keyboard) - 0xa1, 0x01, // COLLECTION (Application) - 0x85, REPORTID_KEYBOARD, // REPORT_ID (Keyboard) - 0x05, 0x07, // USAGE_PAGE (Keyboard) - 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) - 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x01, // LOGICAL_MAXIMUM (1) - 0x75, 0x01, // REPORT_SIZE (1) - 0x95, 0x08, // REPORT_COUNT (8) - 0x81, 0x02, // INPUT (Data,Var,Abs) - 0x95, 0x01, // REPORT_COUNT (1) - 0x75, 0x08, // REPORT_SIZE (8) - 0x81, 0x03, // INPUT (Cnst,Var,Abs) - 0x95, 0x05, // REPORT_COUNT (5) - 0x75, 0x01, // REPORT_SIZE (1) - 0x05, 0x08, // USAGE_PAGE (LEDs) - 0x19, 0x01, // USAGE_MINIMUM (Num Lock) - 0x29, 0x05, // USAGE_MAXIMUM (Kana) - 0x91, 0x02, // OUTPUT (Data,Var,Abs) - 0x95, 0x01, // REPORT_COUNT (1) - 0x75, 0x03, // REPORT_SIZE (3) - 0x91, 0x03, // OUTPUT (Cnst,Var,Abs) - 0x95, 0x06, // REPORT_COUNT (6) - 0x75, 0x08, // REPORT_SIZE (8) - 0x15, 0x00, // LOGICAL_MINIMUM (0) - 0x25, 0x65, // LOGICAL_MAXIMUM (101) - 0x05, 0x07, // USAGE_PAGE (Keyboard) - 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) - 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) - 0x81, 0x00, // INPUT (Data,Ary,Abs) - 0xc0, // END_COLLECTION -}; - -typedef struct __attribute__((__packed__)) _CSGESTURE_KEYBOARD_REPORT -{ - - BYTE ReportID; - - // Left Control, Left Shift, Left Alt, Left GUI - // Right Control, Right Shift, Right Alt, Right GUI - BYTE ShiftKeyFlags; - - BYTE Reserved; - - // See http://www.usb.org/developers/devclass_docs/Hut1_11.pdf - // for a list of key codes - BYTE KeyCodes[KBD_KEY_CODES]; - -} CSGestureKeyboardReport; - -int VoodooI2CCSGestureEngine::distancesq(int delta_x, int delta_y){ - return (delta_x * delta_x) + (delta_y*delta_y); -} - -MultitouchReturn VoodooI2CCSGestureEngine::handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - int i; - - for (int i = 0;i < event.transducers->getCount(); i++) { - softc.x[i] = -1; - softc.y[i] = -1; - softc.p[i] = -1; - } - - UInt8 transform = 0; - OSNumber* number = OSDynamicCast(OSNumber, interface->getProperty(kIOFBTransformKey)); - - if (number) - transform = number->unsigned8BitValue(); - - for (i=0; i < event.transducers->getCount(); i++) { - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, event.transducers->getObject(i)); - if (!transducer) - continue; - - if (transducer->is_valid) { - if (transducer->tip_switch) { - softc.x[i] = transducer->coordinates.x.value(); - softc.y[i] = transducer->coordinates.y.value(); - - softc.x[i] /= softc.factor_x; - softc.y[i] /= softc.factor_y; - - if (transform) { - if (transform & kIOFBSwapAxes) { - int old_x = softc.x[i]; - softc.x[i] = softc.y[i]; - softc.y[i] = old_x; - } - - if (transform & kIOFBInvertX) - softc.x[i] = (interface->logical_max_x / softc.factor_x) - softc.x[i]; - if (transform & kIOFBInvertY) - softc.y[i] = (interface->logical_max_y / softc.factor_y) - softc.y[i]; - } - - if (transducer->tip_pressure.value()) - softc.p[i] = transducer->tip_pressure.value(); - else - softc.p[i] = 10; - } else { - softc.x[i] = -1; - softc.y[i] = -1; - softc.p[i] = -1; - } - } - - if (i == 0 && (CMP_ABSOLUTETIME(×tamp, &transducer->physical_button.current.timestamp) == 0)) { - softc.buttondown = transducer->physical_button & 0x1; - } - - - } - - return MultitouchReturnContinue; -} - -void VoodooI2CCSGestureEngine::timedProcessGesture() { - ProcessGesture(&softc); - - this->timer_event_source->setTimeoutMS(5); -} - -bool VoodooI2CCSGestureEngine::ProcessMove(csgesture_softc *sc, int abovethreshold, int iToUse[4]) { - int frequmult = 10 / sc->frequency; - - if (abovethreshold == 1 || sc->panningActive) { - int i = iToUse[0]; - if (!sc->panningActive && sc->tick[i] < (5 * frequmult)) - return false; - - if (_scrollHandler){ - _scrollHandler->softc = sc; - _scrollHandler->stopScroll(); - } - - if (sc->panningActive && i == -1) - i = sc->idForPanning; - - int delta_x = sc->x[i] - sc->lastx[i]; - int delta_y = sc->y[i] - sc->lasty[i]; - - if (abs(delta_x) > 75 || abs(delta_y) > 75) { - delta_x = 0; - delta_y = 0; - } - - for (int j = 0;j < MAX_FINGERS;j++) { - if (j != i) { - if (sc->blacklistedids[j] != 1) { - if (sc->y[j] > sc->y[i]) { - if (sc->truetick[j] > sc->truetick[i] + (15 * frequmult)) { - sc->blacklistedids[j] = 1; - } - } - } - } - } - - if (!sc->settings.display_integrated){ - sc->dx = delta_x; - sc->dy = delta_y; - } else { - sc->dx = 0; - sc->dy = 0; - - update_absolute_mouse(sc->buttonmask, sc->x[i], sc->y[i]); - } - - sc->panningActive = true; - sc->idForPanning = i; - return true; - } - return false; -} - -bool VoodooI2CCSGestureEngine::ProcessScroll(csgesture_softc *sc, int abovethreshold, int iToUse[4]) { - int frequmult = 10 / sc->frequency; - - sc->scrollx = 0; - sc->scrolly = 0; - - if (abovethreshold == 2 || sc->scrollingActive) { - int i1 = iToUse[0]; - int i2 = iToUse[1]; - - if (!sc->scrollingActive && !sc->scrollInertiaActive) { - if (sc->truetick[i1] < (8 * frequmult) && sc->truetick[i2] < (8 * frequmult)) - return false; - } - - if (sc->scrollingActive){ - if (i1 == -1) { - if (i2 != sc->idsForScrolling[0]) - i1 = sc->idsForScrolling[0]; - else - i1 = sc->idsForScrolling[1]; - } - if (i2 == -1) { - if (i1 != sc->idsForScrolling[0]) - i2 = sc->idsForScrolling[0]; - else - i2 = sc->idsForScrolling[1]; - } - } - - int delta_x1 = sc->x[i1] - sc->lastx[i1]; - int delta_y1 = sc->y[i1] - sc->lasty[i1]; - - int delta_x2 = sc->x[i2] - sc->lastx[i2]; - int delta_y2 = sc->y[i2] - sc->lasty[i2]; - -#if 0 - if ((abs(delta_y1) + abs(delta_y2)) > (abs(delta_x1) + abs(delta_x2))) { - int avgy = (delta_y1 + delta_y2) / 2; - sc->scrolly = avgy; - } - else { - int avgx = (delta_x1 + delta_x2) / 2; - sc->scrollx = avgx; - } - - if (abs(sc->scrollx) > 100) - sc->scrollx = 0; - if (abs(sc->scrolly) > 100) - sc->scrolly = 0; - if (sc->scrolly > 8) - sc->scrolly = sc->scrolly / 8; - else if (sc->scrolly > 5) - sc->scrolly = 1; - else if (sc->scrolly < -8) - sc->scrolly = sc->scrolly / 8; - else if (sc->scrolly < -5) - sc->scrolly = -1; - else - sc->scrolly = 0; - - if (sc->scrollx > 8) { - sc->scrollx = sc->scrollx / 8; - sc->scrollx = -sc->scrollx; - } - else if (sc->scrollx > 5) - sc->scrollx = -1; - else if (sc->scrollx < -8) { - sc->scrollx = sc->scrollx / 8; - sc->scrollx = -sc->scrollx; - } - else if (sc->scrollx < -5) - sc->scrollx = 1; - else - sc->scrollx = 0; - - sc->scrollx = -sc->scrollx; - sc->scrolly = -sc->scrolly; -#endif - - int scrollx = 0; - int scrolly = 0; - - if ((abs(delta_y1) + abs(delta_y2)) > (abs(delta_x1) + abs(delta_x2))) { - int avgy = (delta_y1 + delta_y2) / 2; - scrolly = avgy; - } - else { - int avgx = (delta_x1 + delta_x2) / 2; - scrollx = avgx; - } - - if (abs(scrollx) < 5 && abs(scrolly) < 5 && !sc->scrollingActive) - return false; - - if (_scrollHandler){ - _scrollHandler->softc = sc; - _scrollHandler->ProcessScroll(filterNegative(sc->x[i1]), - filterNegative(sc->y[i1]), - filterNegative(sc->x[i2]), - filterNegative(sc->y[i2])); - } - //_pointingWrapper->updateScroll(sc->scrolly, sc->scrollx, 0); - - int fngrcount = 0; - int totfingers = 0; - for (int i = 0; i < MAX_FINGERS; i++) { - if (sc->x[i] != -1) { - totfingers++; - if (i == i1 || i == i2) - fngrcount++; - } - } - - if (fngrcount == 2) - sc->ticksSinceScrolling = 0; - else - sc->ticksSinceScrolling++; - if (fngrcount == 2 || sc->ticksSinceScrolling <= (5 * frequmult)) { - sc->scrollingActive = true; - if (abovethreshold == 2){ - sc->idsForScrolling[0] = iToUse[0]; - sc->idsForScrolling[1] = iToUse[1]; - } - } - else { - sc->scrollingActive = false; - sc->idsForScrolling[0] = -1; - sc->idsForScrolling[1] = -1; - } - return true; - } - return false; -} - -bool VoodooI2CCSGestureEngine::ProcessThreeFingerSwipe(csgesture_softc *sc, int abovethreshold, int iToUse[4]) { - if (abovethreshold == 3) { - if (_scrollHandler){ - _scrollHandler->softc = sc; - _scrollHandler->stopScroll(); - } - int i1 = iToUse[0]; - int delta_x1 = sc->x[i1] - sc->lastx[i1]; - int delta_y1 = sc->y[i1] - sc->lasty[i1]; - - int i2 = iToUse[1]; - int delta_x2 = sc->x[i2] - sc->lastx[i2]; - int delta_y2 = sc->y[i2] - sc->lasty[i2]; - - int i3 = iToUse[2]; - int delta_x3 = sc->x[i3] - sc->lastx[i3]; - int delta_y3 = sc->y[i3] - sc->lasty[i3]; - - int avgx = (delta_x1 + delta_x2 + delta_x3) / 3; - int avgy = (delta_y1 + delta_y2 + delta_y3) / 3; - - sc->multitaskingx += avgx; - sc->multitaskingy += avgy; - sc->multitaskinggesturetick++; - - if (sc->multitaskinggesturetick > 5 && !sc->multitaskingdone) { - if ((abs(delta_y1) + abs(delta_y2) + abs(delta_y3)) > (abs(delta_x1) + abs(delta_x2) + abs(delta_x3))) { - if (abs(sc->multitaskingy) > 50) { - UInt8 shiftKeys = KBD_LCONTROL_BIT; - UInt8 keyCodes[KBD_KEY_CODES] = { 0, 0, 0, 0, 0, 0 }; - if (sc->multitaskingy < 0) - keyCodes[0] = 0x52; - else - keyCodes[0] = 0x51; - update_keyboard(shiftKeys, keyCodes); - shiftKeys = 0; - keyCodes[0] = 0x0; - update_keyboard(shiftKeys, keyCodes); - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskingdone = true; - } - } - else { - if (abs(sc->multitaskingx) > 50) { - UInt8 shiftKeys = KBD_LCONTROL_BIT; - UInt8 keyCodes[KBD_KEY_CODES] = { 0, 0, 0, 0, 0, 0 }; - if (sc->multitaskingx > 0) - keyCodes[0] = 0x50; - else - keyCodes[0] = 0x4F; - update_keyboard(shiftKeys, keyCodes); - shiftKeys = 0; - keyCodes[0] = 0x0; - update_keyboard(shiftKeys, keyCodes); - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskingdone = true; - } - } - } - else if (sc->multitaskinggesturetick > 25) { - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskinggesturetick = 0; - sc->multitaskingdone = false; - } - return true; - } - else { - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskinggesturetick = 0; - sc->multitaskingdone = false; - return false; - } -} - -bool VoodooI2CCSGestureEngine::ProcessFourFingerSwipe(csgesture_softc *sc, int abovethreshold, int iToUse[4]) { - if (abovethreshold == 4) { - _scrollHandler->softc = sc; - _scrollHandler->stopScroll(); - - int i1 = iToUse[0]; - int delta_x1 = sc->x[i1] - sc->lastx[i1]; - int delta_y1 = sc->y[i1] - sc->lasty[i1]; - - int i2 = iToUse[1]; - int delta_x2 = sc->x[i2] - sc->lastx[i2]; - int delta_y2 = sc->y[i2] - sc->lasty[i2]; - - int i3 = iToUse[2]; - int delta_x3 = sc->x[i3] - sc->lastx[i3]; - int delta_y3 = sc->y[i3] - sc->lasty[i3]; - - int i4 = iToUse[3]; - int delta_x4 = sc->x[i4] - sc->lastx[i4]; - int delta_y4 = sc->y[i4] - sc->lasty[i4]; - - int avgx = (delta_x1 + delta_x2 + delta_x3 + delta_x4) / 4; - int avgy = (delta_y1 + delta_y2 + delta_y3 + delta_y4) / 4; - - sc->multitaskingx += avgx; - sc->multitaskingy += avgy; - sc->multitaskinggesturetick++; - - if (sc->multitaskinggesturetick > 30 && !sc->multitaskingdone) { - if ((abs(delta_y1) + abs(delta_y2) + abs(delta_y3) + abs(delta_y4)) > (abs(delta_x1) + abs(delta_x2) + abs(delta_x3) + abs(delta_x4))) { - if (abs(sc->multitaskingy) > 50) { - UInt8 shiftKeys = KBD_LCONTROL_BIT; - UInt8 keyCodes[KBD_KEY_CODES] = { 0, 0, 0, 0, 0, 0 }; - if (sc->multitaskingy < 0){ - shiftKeys = KBD_LCONTROL_BIT; - keyCodes[0] = 0x44; - }else{ - shiftKeys = KBD_LGUI_BIT; - keyCodes[0] = 0x1A;} - update_keyboard(shiftKeys, keyCodes); - shiftKeys = 0; - keyCodes[0] = 0x0; - update_keyboard(shiftKeys, keyCodes); - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskingdone = true; - } - } - else { - if (abs(sc->multitaskingx) > 50) { - UInt8 shiftKeys = KBD_LCONTROL_BIT; - UInt8 keyCodes[KBD_KEY_CODES] = { 0, 0, 0, 0, 0, 0 }; - if (sc->multitaskingx > 0){ - shiftKeys = 0; - keyCodes[0] = 0x44; - } else { - shiftKeys = KBD_LGUI_BIT; - keyCodes[0] = 0x14;} - update_keyboard(shiftKeys, keyCodes); - shiftKeys = 0; - keyCodes[0] = 0x0; - update_keyboard(shiftKeys, keyCodes); - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskingdone = true; - } - } - } - else if (sc->multitaskinggesturetick > 70) { - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskinggesturetick = 0; - sc->multitaskingdone = false; - } - return true; - } - else { - sc->multitaskingx = 0; - sc->multitaskingy = 0; - sc->multitaskinggesturetick = 0; - sc->multitaskingdone = false; - return false; - } -} - -void VoodooI2CCSGestureEngine::TapToClickOrDrag(csgesture_softc *sc, int button) { - int freqmult = 10 / sc->frequency; - if (!sc->settings.tapToClickEnabled) - return; - - sc->tickssinceclick++; - if (sc->mouseDownDueToTap && sc->idForMouseDown == -1) { - if (sc->tickssinceclick > (10 * freqmult)) { - sc->mouseDownDueToTap = false; - sc->mousedown = false; - sc->buttonmask = 0; - //Tap Drag Timed out - } - return; - } - if (sc->mousedown) { - sc->tickssinceclick = 0; - return; - } - for (int i = 0; i < MAX_FINGERS; i++){ - if (sc->truetick[i] < 10 && sc->truetick[i] > 0) - button++; - } - - - if (button == 0) - return; - - - if (_scrollHandler){ - if (_scrollHandler->isScrolling()){ - _scrollHandler->stopScroll(); - return; - } - } - - int buttonmask = 0; - - switch (button) { - case 1: - buttonmask = MOUSE_BUTTON_1; - break; - case 2: - if (sc->settings.multiFingerTap) - buttonmask = MOUSE_BUTTON_2; - break; - case 3: - if (sc->settings.multiFingerTap) - buttonmask = MOUSE_BUTTON_3; - break; - } - - if (buttonmask != 0 && sc->tickssinceclick > (10 * freqmult) && sc->ticksincelastrelease == 0) { - sc->idForMouseDown = -1; - sc->mouseDownDueToTap = true; - sc->buttonmask = buttonmask; - sc->mousebutton = button; - sc->mousedown = true; - sc->tickssinceclick = 0; - } -} - -void VoodooI2CCSGestureEngine::ClearTapDrag(csgesture_softc *sc, int i) { - int frequmult = 10 / sc->frequency; - if (i == sc->idForMouseDown && sc->mouseDownDueToTap == true) { - if (sc->tick[i] < (10 * frequmult)) { - //Double Tap - update_relative_mouse(0, 0, 0, 0, 0); - update_relative_mouse(sc->buttonmask, 0, 0, 0, 0); - } - sc->mouseDownDueToTap = false; - sc->mousedown = false; - sc->buttonmask = 0; - sc->idForMouseDown = -1; - //Clear Tap Drag - } -} - -void VoodooI2CCSGestureEngine::ProcessGesture(csgesture_softc *sc) { - int frequmult = 10 / sc->frequency; -#pragma mark reset inputs - sc->dx = 0; - sc->dy = 0; - -#pragma mark process touch thresholds - int avgx[MAX_FINGERS]; - int avgy[MAX_FINGERS]; - - int abovethreshold = 0; - int recentlyadded = 0; - int iToUse[5] = { -1,-1,-1, -1, -1}; - int a = 0; - - int nfingers = 0; - for (int i = 0;i < MAX_FINGERS;i++) { - if (sc->x[i] != -1) - nfingers++; - } - - for (int i = 0;i < MAX_FINGERS;i++) { - if (sc->truetick[i] < (30 * frequmult) && sc->truetick[i] != 0) - recentlyadded++; - if (sc->tick[i] == 0) - continue; - if (sc->blacklistedids[i] == 1) - continue; - avgx[i] = sc->flextotalx[i] / sc->tick[i]; - avgy[i] = sc->flextotaly[i] / sc->tick[i]; - - if (!nfingers || nfingers > 2 || (sc->settings.display_integrated && nfingers == 2)) { - if (distancesq(avgx[i], avgy[i]) > 2) { - abovethreshold++; - iToUse[a] = i; - a++; - } - } else if (a == 1 && !sc->settings.display_integrated && nfingers == 2) { - if ((int)(10*abs(sc->y[iToUse[0]] - sc->y[i])/sc->resy) <= (2 / sc->factor_y)) { - abovethreshold++; - iToUse[a] = i; - a++; - } else { - if (sc->y[iToUse[0]] >= sc->y[i]) - iToUse[0] = i; - } - } else if (nfingers == 1 || (a == 0 && nfingers == 2)) { - abovethreshold++; - iToUse[a] = i; - a++; - } - - } - -#pragma mark process different gestures - bool handled = false; - bool handledByScroll = false; - - if (!handled && abovethreshold==4) - handled = ProcessFourFingerSwipe(sc, abovethreshold, iToUse); - if (!handled) - handled = ProcessThreeFingerSwipe(sc, abovethreshold, iToUse); - if (!handled && !sc->buttondown && !sc->mouseDownDueToTap) - handledByScroll = handled = ProcessScroll(sc, abovethreshold, iToUse); - if (!handled) - ProcessMove(sc, abovethreshold, iToUse); - -#pragma mark process clickpad press state - int buttonmask = 0; - - sc->mousebutton = recentlyadded; - if (sc->mousebutton == 0) - sc->mousebutton = abovethreshold; - - if (sc->mousebutton == 0) { - if (sc->panningActive) - sc->mousebutton = 1; - else - sc->mousebutton = nfingers; - if (sc->mousebutton == 0) - sc->mousebutton = 1; - } - if (sc->mousebutton > 3) - sc->mousebutton = 3; - - if (!sc->mouseDownDueToTap) { - if (sc->buttondown && !sc->mousedown) { - if (_scrollHandler){ - if (_scrollHandler->isScrolling()){ - _scrollHandler->stopScroll(); - } - } - - sc->mousedown = true; - sc->tickssinceclick = 0; - - if (nfingers == 1 && ((int)(10*sc->x[iToUse[0]]/sc->resx) > (5 / sc->factor_x)) && ((int)(10*sc->y[iToUse[0]]/sc->resy) > (7 / sc->factor_y))) - sc->mousebutton = 2; - - switch (sc->mousebutton) { - case 1: - buttonmask = MOUSE_BUTTON_1; - break; - case 2: - buttonmask = MOUSE_BUTTON_2; - break; - case 3: - buttonmask = MOUSE_BUTTON_3; - break; - } - sc->buttonmask = buttonmask; - } - else if (sc->mousedown && !sc->buttondown) { - sc->mousedown = false; - sc->mousebutton = 0; - sc->buttonmask = 0; - } - } - -#pragma mark shift to last - int releasedfingers = 0; - - for (int i = 0;i < MAX_FINGERS;i++) { - if (sc->x[i] != -1) { - if (sc->lastx[i] == -1) { - if (sc->ticksincelastrelease < (10 * frequmult) && sc->mouseDownDueToTap && sc->idForMouseDown == -1) { - if (sc->settings.tapDragEnabled) - sc->idForMouseDown = i; //Associate Tap Drag - } - } - sc->truetick[i]++; - if (sc->tick[i] < (10 * frequmult)) { - if (sc->lastx[i] != -1) { - sc->totalx[i] += abs(sc->x[i] - sc->lastx[i]); - sc->totaly[i] += abs(sc->y[i] - sc->lasty[i]); - sc->totalp[i] += sc->p[i]; - - sc->flextotalx[i] = sc->totalx[i]; - sc->flextotaly[i] = sc->totaly[i]; - - int j = sc->tick[i]; - sc->xhistory[i][j] = abs(sc->x[i] - sc->lastx[i]); - sc->yhistory[i][j] = abs(sc->y[i] - sc->lasty[i]); - } - sc->tick[i]++; - } - else if (sc->lastx[i] != -1) { - int absx = abs(sc->x[i] - sc->lastx[i]); - int absy = abs(sc->y[i] - sc->lasty[i]); - - sc->totalx[i] += absx; - sc->totaly[i] += absy; - - sc->flextotalx[i] -= sc->xhistory[i][0]; - sc->flextotaly[i] -= sc->yhistory[i][0]; - for (int j = 1;j < (10 * frequmult);j++) { - sc->xhistory[i][j - 1] = sc->xhistory[i][j]; - sc->yhistory[i][j - 1] = sc->yhistory[i][j]; - } - sc->flextotalx[i] += absx; - sc->flextotaly[i] += absy; - - int j = 9; - sc->xhistory[i][j] = absx; - sc->yhistory[i][j] = absy; - } - } - if (sc->x[i] == -1) { - ClearTapDrag(sc, i); - if (sc->lastx[i] != -1) - sc->ticksincelastrelease = -1; - for (int j = 0;j < (10 * frequmult);j++) { - sc->xhistory[i][j] = 0; - sc->yhistory[i][j] = 0; - } - if (sc->tick[i] < (10 * frequmult) && sc->tick[i] != 0) { - releasedfingers++; - } - sc->totalx[i] = 0; - sc->totaly[i] = 0; - sc->totalp[i] = 0; - sc->tick[i] = 0; - sc->truetick[i] = 0; - - sc->blacklistedids[i] = 0; - - if (sc->idForPanning == i) { - sc->panningActive = false; - sc->idForPanning = -1; - } - } - sc->lastx[i] = sc->x[i]; - sc->lasty[i] = sc->y[i]; - sc->lastp[i] = sc->p[i]; - } - sc->ticksincelastrelease++; - -#pragma mark process tap to click - if (!handledByScroll) - TapToClickOrDrag(sc, releasedfingers); - -#pragma mark send to system - update_relative_mouse(sc->buttonmask, sc->dx, sc->dy, sc->scrolly, sc->scrollx); -} - -#pragma mark OS Specific functions - -void VoodooI2CCSGestureEngine::prepareToSleep(){ - if (_scrollHandler) - _scrollHandler->prepareToSleep(); - - if (this->timer_event_source){ - this->timer_event_source->cancelTimeout(); - this->timer_event_source->release(); - this->timer_event_source = NULL; - } -} - -void VoodooI2CCSGestureEngine::wakeFromSleep(){ - if (_scrollHandler) - _scrollHandler->wakeFromSleep(); - - if (!this->timer_event_source){ - this->timer_event_source = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &VoodooI2CCSGestureEngine::timedProcessGesture)); - this->work_loop->addEventSource(this->timer_event_source); - this->timer_event_source->setTimeoutMS(10); - } -} - -bool VoodooI2CCSGestureEngine::start(IOService *service) { - if (!super::start(service)) - return false; - - this->work_loop = getWorkLoop(); - if (!this->work_loop){ - IOLog("%s::Unable to get workloop\n", getName()); - stop(service); - return false; - } - - this->work_loop->retain(); - - this->timer_event_source = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &VoodooI2CCSGestureEngine::timedProcessGesture)); - if (!this->timer_event_source) { - IOLog("%s::Unable to get timer source\n", getName()); - stop(service); - return false; - } - this->work_loop->addEventSource(this->timer_event_source); - - _wrapper = NULL; - _pointingWrapper = NULL; - _scrollHandler = NULL; - - _wrapper = new VoodooCSGestureHIDWrapper; - if (_wrapper->init()) { - _wrapper->gestureEngine = this; - _wrapper->attach(service); - _wrapper->start(service); - } - else { - _wrapper->release(); - _wrapper = NULL; - return false; - } - - _pointingWrapper = new VoodooCSGestureHIPointingWrapper; - if (_pointingWrapper->init()){ - _pointingWrapper->gesturerec = this; - _pointingWrapper->attach(service); - _pointingWrapper->start(service); - } else { - _pointingWrapper->release(); - _pointingWrapper = NULL; - return false; - } - - _scrollHandler = new CSGestureScroll; - if (_scrollHandler->init()){ - _scrollHandler->softc = &softc; - _scrollHandler->inertiaScroll = true; - - _scrollHandler->_pointingWrapper = _pointingWrapper; - _scrollHandler->_gestureEngine = this; - - _scrollHandler->attach(service); - _scrollHandler->start(service); - } - - UInt16 max_x = interface->logical_max_x; - UInt16 max_y = interface->logical_max_y; - - softc.resx = max_x; - softc.resy = max_y; - - softc.phyx = interface->physical_max_x; - softc.phyy = interface->physical_max_y; - - softc.factor_x = softc.resx / softc.phyx; - if (!softc.factor_x) - softc.factor_x = 1; - - softc.factor_y = softc.resy / softc.phyy; - if (!softc.factor_y) - softc.factor_y = 1; - - softc.frequency = 5; - - softc.infoSetup = true; - - OSBoolean* display_integrated = OSDynamicCast(OSBoolean, interface->getProperty(kIOHIDDisplayIntegratedKey)); - - if (display_integrated) - softc.settings.display_integrated = display_integrated->getValue(); - - for (int i = 0;i < MAX_FINGERS; i++) { - softc.x[i] = -1; - softc.y[i] = -1; - softc.p[i] = -1; - } - - this->timer_event_source->setTimeoutMS(10); - - return true; -} - -void VoodooI2CCSGestureEngine::stop(IOService* provider) { - if (_scrollHandler != NULL){ - _scrollHandler->stop(); - _scrollHandler->_pointingWrapper = NULL; - _scrollHandler->_gestureEngine = NULL; - _scrollHandler->terminate(kIOServiceRequired | kIOServiceSynchronous); - _scrollHandler->release(); - _scrollHandler = NULL; - } - - if (_wrapper != NULL) { - _wrapper->terminate(kIOServiceRequired | kIOServiceSynchronous); - _wrapper->release(); - _wrapper = NULL; - } - - if (_pointingWrapper != NULL){ - _pointingWrapper->terminate(kIOServiceRequired | kIOServiceSynchronous); - _pointingWrapper->release(); - _pointingWrapper = NULL; - } - - if (this->timer_event_source){ - this->timer_event_source->cancelTimeout(); - this->timer_event_source->release(); - this->timer_event_source = NULL; - } - -} - -void VoodooI2CCSGestureEngine::update_relative_mouse(char button, char x, char y, char wheelPosition, char wheelHPosition){ - if (_pointingWrapper) - _pointingWrapper->updateRelativeMouse(x, y, button); -} - -void VoodooI2CCSGestureEngine::update_absolute_mouse(char button, SInt16 x, SInt16 y){ - if (_pointingWrapper) - _pointingWrapper->updateAbsoluteMouse(x, y, button); -} - -void VoodooI2CCSGestureEngine::update_keyboard(UInt8 shiftKeys, UInt8 keyCodes[KBD_KEY_CODES]) { - _CSGESTURE_KEYBOARD_REPORT report; - report.ReportID = REPORTID_KEYBOARD; - report.ShiftKeyFlags = shiftKeys; - for (int i = 0; i < KBD_KEY_CODES; i++){ - report.KeyCodes[i] = keyCodes[i]; - } - - IOBufferMemoryDescriptor *buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, sizeof(report)); - buffer->writeBytes(0, &report, sizeof(report)); - - if (_wrapper){ - IOReturn err = _wrapper->handleReport(buffer, kIOHIDReportTypeInput); - if (err != kIOReturnSuccess) - IOLog("Error handling report: 0x%.8x\n", err); - } - buffer->release(); - -} - -int VoodooI2CCSGestureEngine::reportDescriptorLength(){ - return sizeof(csgesturedesc); -} - -void VoodooI2CCSGestureEngine::write_report_to_buffer(IOMemoryDescriptor *buffer){ - - _CSGESTURE_KEYBOARD_REPORT report; - report.ReportID = REPORTID_KEYBOARD; - report.ShiftKeyFlags = 0; - for (int i = 0; i < KBD_KEY_CODES; i++){ - report.KeyCodes[i] = 0; - } - - UInt rsize = sizeof(report); - - buffer->writeBytes(0, &report, rsize); -} - -void VoodooI2CCSGestureEngine::write_report_descriptor_to_buffer(IOMemoryDescriptor *buffer){ - - UInt rsize = sizeof(csgesturedesc); - - buffer->writeBytes(0, csgesturedesc, rsize); -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.hpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.hpp deleted file mode 100644 index 0b04eeb..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/VoodooI2CCSGestureEngine.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// -// VoodooI2CCSGestureEngine.hpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CCSGestureEngine_hpp -#define VoodooI2CCSGestureEngine_hpp - -#include - -#include -#include -#include -#include - -#include "../VoodooI2CMultitouchEngine.hpp" -#include "../MultitouchHelpers.hpp" -#include "../VoodooI2CDigitiserStylus.hpp" - -#include -#include "VoodooCSGestureHIDWrapper.h" -#include "VoodooCSGestureHIPointingWrapper.hpp" -#include "csgesture-softc.h" -#include "csgesturescroll.h" - -#define MAX_FINGERS 15 - -class VoodooI2CMultitouchInterface; - -class EXPORT VoodooI2CCSGestureEngine : VoodooI2CMultitouchEngine { - OSDeclareDefaultStructors(VoodooI2CCSGestureEngine); -private: - VoodooCSGestureHIDWrapper *_wrapper; - VoodooCSGestureHIPointingWrapper *_pointingWrapper; - CSGestureScroll *_scrollHandler; - - struct { - UInt8 x; - UInt8 y; - UInt8 buttonMask; - } lastmouse; - - IOWorkLoop* work_loop; - IOTimerEventSource* timer_event_source; - - int distancesq(int delta_x, int delta_y); - - //os callbacks - void update_relative_mouse(char button, - char x, char y, char wheelPosition, char wheelHPosition); - void update_absolute_mouse(char button, SInt16 x, SInt16 y); - void update_keyboard(UInt8 shiftKeys, UInt8 *keyCodes); -public: - csgesture_softc softc; - - //public csgesture functions - bool ProcessMove(csgesture_softc *sc, int abovethreshold, int iToUse[4]); - bool ProcessScroll(csgesture_softc *sc, int abovethreshold, int iToUse[4]); - bool ProcessThreeFingerSwipe(csgesture_softc *sc, int abovethreshold, int iToUse[4]); - bool ProcessFourFingerSwipe(csgesture_softc *sc, int abovethreshold, int iToUse[4]); - - void TapToClickOrDrag(csgesture_softc *sc, int button); - void ClearTapDrag(csgesture_softc *sc, int i); - void ProcessGesture(csgesture_softc *sc); - void timedProcessGesture(); - - //os specific functions - void prepareToSleep(); - void wakeFromSleep(); - - void initialize_wrapper(IOService *service); - void destroy_wrapper(void); - - int vendorID; - int productID; - - int reportDescriptorLength(); - void write_report_to_buffer(IOMemoryDescriptor *buffer); - void write_report_descriptor_to_buffer(IOMemoryDescriptor *buffer); - - MultitouchReturn handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp); - bool start(IOService* service); - void stop(IOService* provider); -}; - - -#endif /* VoodooI2CCSGestureEngine_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesture-softc.h b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesture-softc.h deleted file mode 100644 index c6dde1e..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesture-softc.h +++ /dev/null @@ -1,90 +0,0 @@ -// CSGesture Multitouch Touchpad Library -// © 2016, CoolStar. All Rights Reserved. - -#ifndef csgesture_softc_h -#define csgesture_softc_h - -struct csgesture_settings { //note not all settings were brought over from Windows as we are using Apple's settings panel - //tap settings - bool tapToClickEnabled = true; - bool multiFingerTap; - bool tapDragEnabled; - bool display_integrated = false; - bool literal_right_click = false; -}; - -struct csgesture_softc { - struct csgesture_settings settings; - - //hardware input - int x[15]; - int y[15]; - int p[15]; - - bool buttondown; - - //hardware info - bool infoSetup; - - int resx; - int resy; - int phyx; - int phyy; - - int factor_x; - int factor_y; - - //system output - int dx; - int dy; - - int scrollx; - int scrolly; - - int buttonmask; - - //used internally in driver - int panningActive; - int idForPanning; - - int scrollingActive; - int idsForScrolling[2]; - int ticksSinceScrolling; - - int scrollInertiaActive; - - int blacklistedids[15]; - - bool mouseDownDueToTap; - int idForMouseDown; - bool mousedown; - int mousebutton; - - int lastx[15]; - int lasty[15]; - int lastp[15]; - - int xhistory[15][50]; - int yhistory[15][50]; - - int flextotalx[15]; - int flextotaly[15]; - - int totalx[15]; - int totaly[15]; - int totalp[15]; - - int multitaskingx; - int multitaskingy; - int multitaskinggesturetick; - bool multitaskingdone; - - int tick[15]; - int truetick[15]; - int ticksincelastrelease; - int tickssinceclick; - - int frequency; //maximum 10 ms, minimum 2 ms -}; - -#endif /* csgesture_softc_h */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.cpp b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.cpp deleted file mode 100644 index 832e63a..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.cpp +++ /dev/null @@ -1,317 +0,0 @@ -// CSGesture Multitouch Touchpad Library -// © 2016, CoolStar. All Rights Reserved. - -#include "csgesturescroll.h" -#include -#include "VoodooCSGestureHIPointingWrapper.hpp" -#include - -OSDefineMetaClassAndStructors(CSGestureScroll, IOService); - -#ifndef ABS32 -#define ABS32 -inline SInt32 abs(SInt32 num){ - if (num < 0){ - return num * -1; - } - return num; -} -#endif - -inline bool isSameSign(int n1, int n2) { - if (n1 == 0 || n2 == 0) - return true; - if (n1 > 0 && n2 > 0) - return true; - if (n1 < 0 && n2 < 0) - return true; - return false; -} - -inline bool isPropertyValid(int prop) { - if (prop == 65535) - return false; - return true; -} - -void CSGestureScroll::disableScrollDelayed(){ - if (!cancelDelayScroll){ - softc->scrollInertiaActive = false; - cancelDelayScroll = false; - } - - if (_disableScrollDelayTimer){ - _disableScrollDelayTimer->cancelTimeout(); - _disableScrollDelayTimer->release(); - _disableScrollDelayTimer = NULL; - } -} - -void CSGestureScroll::disableScrollingDelayLaunch(){ - if (softc->scrollInertiaActive) - return; - - cancelDelayScroll = false; - - if (_disableScrollDelayTimer){ - _disableScrollDelayTimer->cancelTimeout(); - _disableScrollDelayTimer->release(); - _disableScrollDelayTimer = NULL; - } - - _disableScrollDelayTimer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &CSGestureScroll::disableScrollDelayed)); - _workLoop->addEventSource(_disableScrollDelayTimer); - _disableScrollDelayTimer->setTimeoutMS(300); -} - -bool CSGestureScroll::isScrolling(){ - if (isTouchActive) - return true; - - if (momentumscrollcurrenty > 0 || momentumscrollrest1y > 0 || momentumscrollrest2y > 0) - return true; - - if (momentumscrollcurrentx > 0 || momentumscrollrest1x > 0 || momentumscrollrest2x > 0) - return true; - - return false; -} - -void CSGestureScroll::stopScroll(){ - momentumscrollcurrentx = 0; - momentumscrollrest1x = 0; - momentumscrollrest2x = 0; - dx_history.reset(); - - momentumscrollcurrenty = 0; - momentumscrollrest1y = 0; - momentumscrollrest2y = 0; - dy_history.reset(); - isTouchActive = false; - - // disableScrollingDelayLaunch(); -} - -void CSGestureScroll::scrollTimer(){ - if (momentumscrollcurrentx) { - int dx = momentumscrollcurrentx / 10 + momentumscrollrest2x; - - if (abs(dx) > 7) { - //dispatch the scroll event - if (inertiaScroll) { - _pointingWrapper->updateScroll(0, (dx / 7), 0); - } - - momentumscrollrest2x = dx % 1; - - momentumscrollcurrentx = momentumscrollcurrentx * momentumscrollmultiplierx + momentumscrollrest1x; - momentumscrollrest1x = momentumscrollcurrentx % momentumscrolldivisorx; - momentumscrollcurrentx /= momentumscrolldivisorx; - } - else { - momentumscrollcurrentx = 0; - } - } - - if (momentumscrollcurrenty) { - int dy = momentumscrollcurrenty / 10 + momentumscrollrest2y; - - if (abs(dy) > 7) { - //dispatch the scroll event - if (inertiaScroll) { - _pointingWrapper->updateScroll((dy / 7), 0, 0); - } - - momentumscrollrest2y = dy % 1; - - momentumscrollcurrenty = momentumscrollcurrenty * momentumscrollmultipliery + momentumscrollrest1y; - momentumscrollrest1y = momentumscrollcurrenty % momentumscrolldivisory; - momentumscrollcurrenty /= momentumscrolldivisory; - } - else { - momentumscrollcurrenty = 0; - } - } - - if (momentumscrollcurrentx != 0 || momentumscrollcurrenty != 0) { - cancelDelayScroll = true; - softc->scrollInertiaActive = true; - } - - _scrollTimer->setTimeoutMS(10); -} - -void CSGestureScroll::ProcessScroll(int x1, int y1, int x2, int y2) { - if (isPropertyValid(x1) && - isPropertyValid(y1) && - isPropertyValid(x2) && - isPropertyValid(y2)){ - - int delta_x1 = x1 - lastx1; - int delta_y1 = y1 - lasty1; - - int delta_x2 = x2 - lastx2; - int delta_y2 = y2 - lasty2; - - bool ignoreScroll = false; - - if (lastx1 == 0 || lasty1 == 0 || lastx2 == 0 || lasty2 == 0) - ignoreScroll = true; - - lastx1 = x1; - lasty1 = y1; - lastx2 = x2; - lasty2 = y2; - - if (ignoreScroll) - return; - - int avgy = (delta_y1 + delta_y2) / 2; - int avgx = (delta_x1 + delta_x2) / 2; - - if (abs(avgx) > 100) - avgx = 0; - if (abs(avgy) > 100) - avgx = 0; - - if (avgx == 0 && avgy == 0) { - noScrollCounter++; - if (noScrollCounter < 3) - return; - } - else { - noScrollCounter = 0; - } - - avgy = -avgy; - avgx = -avgx; - - if (abs(avgy) > abs(avgx)) { - _pointingWrapper->updateScroll(avgy, 0, 0); - - if (!isSameSign(momentumscrollcurrenty, avgy)) { - momentumscrollcurrenty = 0; - momentumscrollrest1y = 0; - momentumscrollrest2y = 0; - dy_history.reset(); - } - - dy_history.filter(avgy); - dx_history.reset(); - } else { - _pointingWrapper->updateScroll(0, avgx, 0); - - if (!isSameSign(momentumscrollcurrentx, avgx)) { - momentumscrollcurrentx = 0; - momentumscrollrest1x = 0; - momentumscrollrest2x = 0; - dx_history.reset(); - } - - dx_history.filter(avgx); - dy_history.reset(); - } - ; - isTouchActive = true; - } else { - if (isTouchActive){ - if (dx_history.count() > momentumscrollsamplesmin) { - int scrollx = dx_history.sum() * 10; - if (isSameSign(momentumscrollcurrentx, scrollx)) - momentumscrollcurrentx += scrollx; - else - momentumscrollcurrentx = scrollx; - momentumscrollrest1x = 0; - momentumscrollrest2x = 0; - } - - if (dy_history.count() > momentumscrollsamplesmin) { - int scrolly = dy_history.sum() * 10; - if (isSameSign(momentumscrollcurrenty, scrolly)) - momentumscrollcurrenty += scrolly; - else - momentumscrollcurrenty = scrolly; - momentumscrollrest1y = 0; - momentumscrollrest2y = 0; - } - - dx_history.reset(); - dy_history.reset(); - isTouchActive = false; - } - - lastx1 = 0; - lasty1 = 0; - lastx2 = 0; - lasty2 = 0; - } -} - -void CSGestureScroll::prepareToSleep(){ - if (_scrollTimer){ - _scrollTimer->cancelTimeout(); - _scrollTimer->release(); - _scrollTimer = NULL; - } - - if (_disableScrollDelayTimer){ - _disableScrollDelayTimer->cancelTimeout(); - _disableScrollDelayTimer->release(); - _disableScrollDelayTimer = NULL; - } -} - -void CSGestureScroll::wakeFromSleep(){ - if (_scrollTimer){ - _scrollTimer->cancelTimeout(); - _scrollTimer->release(); - _scrollTimer = NULL; - } - - _scrollTimer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &CSGestureScroll::scrollTimer)); - _workLoop->addEventSource(_scrollTimer); - _scrollTimer->setTimeoutMS(10); -} - -bool CSGestureScroll::start(IOService *provider){ - if (!super::start(provider)) - return false; - - _workLoop = getWorkLoop(); - if (!_workLoop){ - IOLog("CSGestureScroll: Failed to get workloop!\n"); - return false; - } - - _workLoop->retain(); - - _scrollTimer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &CSGestureScroll::scrollTimer)); - _workLoop->addEventSource(_scrollTimer); - _scrollTimer->setTimeoutMS(10); - if (_scrollTimer) - return true; - return false; -} - -void CSGestureScroll::stop(){ - if (_scrollTimer){ - _scrollTimer->cancelTimeout(); // disable before removal. - if (_workLoop) - _workLoop->removeEventSource(_scrollTimer); - _scrollTimer->release(); - _scrollTimer = NULL; - } - - if (_disableScrollDelayTimer){ - _disableScrollDelayTimer->cancelTimeout(); - if (_workLoop) - _workLoop->removeEventSource(_disableScrollDelayTimer); - _disableScrollDelayTimer->release(); - _disableScrollDelayTimer = NULL; - } - - if (_workLoop) { - _workLoop->release(); - _workLoop = NULL; - } -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.h b/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.h deleted file mode 100644 index 7469de8..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/CSGesture/csgesturescroll.h +++ /dev/null @@ -1,80 +0,0 @@ -// CSGesture Multitouch Touchpad Library -// © 2016, CoolStar. All Rights Reserved. - -#include -#include "AverageClasses.h" -#include "VoodooI2CCSGestureEngine.hpp" - -#ifndef csgesturescroll_h -#define csgesturescroll_h - -class VoodooCSGestureHIPointingWrapper; - -class EXPORT CSGestureScroll : public IOService { - typedef IOService super; - OSDeclareDefaultStructors(CSGestureScroll); - -private: - SimpleAverage dy_history; - SimpleAverage dx_history; - - int lastx1 = 0; - int lasty1 = 0; - int lastx2 = 0; - int lasty2 = 0; - - bool isTouchActive = false; - - int momentumscrollsamplesmin = 1; - - int momentumscrollcurrentx = 0; - int momentumscrollmultiplierx = 98; - int momentumscrolldivisorx = 100; - int momentumscrollrest1x = 0; - int momentumscrollrest2x = 0; - - int momentumscrollcurrenty = 0; - int momentumscrollmultipliery = 98; - int momentumscrolldivisory = 100; - int momentumscrollrest1y = 0; - int momentumscrollrest2y = 0; - - bool cancelDelayScroll = false; - - int noScrollCounter = 0; - - IOTimerEventSource *_disableScrollDelayTimer; - - IOTimerEventSource *_scrollTimer; - - IOWorkLoop *_workLoop; - - void disableScrollDelayed(); - - void disableScrollingDelayLaunch(); - - void scrollTimer(); - -public: - bool inertiaScroll = true; - - VoodooI2CCSGestureEngine *_gestureEngine; - - csgesture_softc *softc; - - VoodooCSGestureHIPointingWrapper *_pointingWrapper; - - void prepareToSleep(); - void wakeFromSleep(); - - bool isScrolling(); - - void stopScroll(); - - bool start(IOService *provider) override; - - void stop(); - - void ProcessScroll(int x1, int y1, int x2, int y2); -}; -#endif /* csgesturescroll_h */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/MultitouchHelpers.hpp b/BigSurface/BigSurface/SurfaceMultitouch/MultitouchHelpers.hpp deleted file mode 100644 index b5b8e2c..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/MultitouchHelpers.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// -// MultitouchHelpers.hpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef MultitouchHelpers_hpp -#define MultitouchHelpers_hpp - -#include -#include - -typedef struct { - UInt8 contact_count; - OSArray* transducers; -} VoodooI2CMultitouchEvent; - -typedef UInt32 MultitouchReturn; - -#define MultitouchReturnContinue 0x0 -#define MultitouchReturnBreak 0x1 - -#ifndef EXPORT -#define EXPORT __attribute__((visibility("default"))) -#endif - -#endif /* MultitouchHelpers_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.cpp b/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.cpp deleted file mode 100644 index c9c451a..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// -// VoodooI2CNativeEngine.cpp -// VoodooI2C -// -// Created by Alexandre on 10/02/2018. -// Copyright © 2018 Alexandre Daoud and Kishor Prins. All rights reserved. -// - -#include "VoodooI2CNativeEngine.hpp" - -#define super VoodooI2CMultitouchEngine -OSDefineMetaClassAndStructors(VoodooI2CNativeEngine, VoodooI2CMultitouchEngine); - -MultitouchReturn VoodooI2CNativeEngine::handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - if (!voodooInputInstance) { - return MultitouchReturnContinue; - } - - message.timestamp = timestamp; - message.contact_count = event.contact_count; - memset(message.transducers, 0, VOODOO_INPUT_MAX_TRANSDUCERS * sizeof(VoodooInputTransducer)); - - VoodooI2CDigitiserTransducer* transducer = (VoodooI2CDigitiserTransducer*) event.transducers->getObject(0); - - if (!transducer) - return MultitouchReturnBreak; - - if (transducer->type == kDigitiserTransducerStylus) - stylus_check = 1; - - int valid_touch_count = 0; - - for (int i = 0; i < event.contact_count; i++) { - VoodooI2CDigitiserTransducer* transducer = (VoodooI2CDigitiserTransducer*) event.transducers->getObject(i+stylus_check); - VoodooInputTransducer* inputTransducer = &message.transducers[i]; - - if (!transducer) { - continue; - } - - inputTransducer->fingerType = (MT2FingerType) (kMT2FingerTypeIndexFinger + (i % 4)); - inputTransducer->secondaryId = transducer->secondary_id; - - inputTransducer->type = (transducer->type == DigitiserTransducerType::kDigitiserTransducerFinger) ? VoodooInputTransducerType::FINGER : VoodooInputTransducerType::STYLUS; - - inputTransducer->isValid = transducer->is_valid; - if (inputTransducer->isValid) { - valid_touch_count++; - } - inputTransducer->isTransducerActive = transducer->tip_switch.value(); - inputTransducer->isPhysicalButtonDown = transducer->physical_button.value(); - - inputTransducer->currentCoordinates.x = transducer->coordinates.x.value(); - inputTransducer->previousCoordinates.x = transducer->coordinates.x.last.value; - - inputTransducer->currentCoordinates.y = transducer->coordinates.y.value(); - inputTransducer->previousCoordinates.y = transducer->coordinates.y.last.value; - inputTransducer->supportsPressure = false; - inputTransducer->timestamp = timestamp; - - // TODO: does VoodooI2C know width(s)? how does it measure pressure? - inputTransducer->currentCoordinates.width = transducer->tip_pressure.value() / 2; - inputTransducer->previousCoordinates.width = transducer->tip_pressure.last.value / 2; - - inputTransducer->currentCoordinates.pressure = transducer->tip_pressure.value(); - inputTransducer->previousCoordinates.pressure = transducer->tip_pressure.last.value; - - // Force Touch emulation - // The button state is saved in the first transducer - if (((VoodooI2CDigitiserTransducer*) event.transducers->getObject(0))->physical_button.value() && isForceClickEnabled()) { - inputTransducer->supportsPressure = true; - inputTransducer->isPhysicalButtonDown = 0x0; - inputTransducer->currentCoordinates.pressure = 0xff; - inputTransducer->currentCoordinates.width = 10; - } - } - - // set the thumb to improve 4F pinch and spread gesture and cross-screen dragging - if (valid_touch_count >= 4 || transducer->physical_button.value()) { - // simple thumb detection: to find the lowest finger touch in the vertical direction. - UInt32 y_max = 0; - int thumb_index = 0; - for (int i = 0; i < event.contact_count; i++) { - VoodooInputTransducer* inputTransducer = &message.transducers[i]; - if (inputTransducer->isValid && inputTransducer->currentCoordinates.y >= y_max) { - y_max = inputTransducer->currentCoordinates.y; - thumb_index = i; - } - } - message.transducers[thumb_index].fingerType = kMT2FingerTypeThumb; - } - - super::messageClient(kIOMessageVoodooInputMessage, voodooInputInstance, &message, sizeof(VoodooInputEvent)); - - return MultitouchReturnBreak; -} - -bool VoodooI2CNativeEngine::start(IOService* provider) { - if (!super::start(provider)) - return false; - - parentProvider = OSDynamicCast(VoodooI2CMultitouchInterface, provider); - - if (!parentProvider) { - return false; - } - - voodooInputInstance = NULL; - - setProperty(VOODOO_INPUT_LOGICAL_MAX_X_KEY, parentProvider->logical_max_x, 32); - setProperty(VOODOO_INPUT_LOGICAL_MAX_Y_KEY, parentProvider->logical_max_y, 32); - - setProperty(VOODOO_INPUT_PHYSICAL_MAX_X_KEY, parentProvider->physical_max_x, 32); - setProperty(VOODOO_INPUT_PHYSICAL_MAX_Y_KEY, parentProvider->physical_max_y, 32); - - setProperty("VoodooInputSupported", kOSBooleanTrue); - - stylus_check = 0; - - return true; -} - -bool VoodooI2CNativeEngine::isForceClickEnabled() { - AbsoluteTime now_abs; - UInt64 diff_ns; - clock_get_uptime(&now_abs); - absolutetime_to_nanoseconds(now_abs - lastForceClickPropertyUpdateTime, &diff_ns); - - if (diff_ns < 1e9) { - lastForceClickPropertyUpdateTime = now_abs; - return lastIsForceClickEnabled; - } - - // Blocking reading here takes about 10 microseconds - OSDictionary* dict = OSDynamicCast(OSDictionary, this->getProperty("MultitouchPreferences", gIOServicePlane, kIORegistryIterateRecursively)); - if (!dict) { - return lastIsForceClickEnabled; - } - if (OSCollectionIterator* i = OSCollectionIterator::withCollection(dict)) { - while (OSSymbol* key = OSDynamicCast(OSSymbol, i->getNextObject())) { - // System -> Preferences -> Trackpad -> Force Click and haptic feedback - // ForceSuppressed - if (key->isEqualTo("ForceSuppressed")) { - OSBoolean* value = OSDynamicCast(OSBoolean, dict->getObject(key)); - - if (value != NULL) { - lastIsForceClickEnabled = !value->getValue(); - } - } - } - - i->release(); - } - - lastForceClickPropertyUpdateTime = now_abs; - return lastIsForceClickEnabled; -} - -void VoodooI2CNativeEngine::onPropertyChange() { - if (voodooInputInstance) { - super::messageClient(kIOMessageVoodooInputUpdatePropertiesNotification, voodooInputInstance); - } -} - -void VoodooI2CNativeEngine::stop(IOService* provider) { - super::stop(provider); -} - -bool VoodooI2CNativeEngine::handleOpen(IOService *forClient, IOOptionBits options, void *arg) { - if (forClient && forClient->getProperty(VOODOO_INPUT_IDENTIFIER)) { - voodooInputInstance = forClient; - voodooInputInstance->retain(); - - return true; - } - return false; -} - -bool VoodooI2CNativeEngine::handleIsOpen(const IOService *forClient) const { - return voodooInputInstance != NULL && forClient == voodooInputInstance; -} - -void VoodooI2CNativeEngine::handleClose(IOService *forClient, IOOptionBits options) { - if (voodooInputInstance && forClient == voodooInputInstance) { - OSSafeReleaseNULL(voodooInputInstance); - } -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.hpp b/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.hpp deleted file mode 100644 index 2ca914a..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/Native/VoodooI2CNativeEngine.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// VoodooI2CNativeEngine.hpp -// VoodooI2C -// -// Created by Alexandre on 10/02/2018. -// Copyright © 2018 Alexandre Daoud and Kishor Prins. All rights reserved. -// - -#ifndef VoodooI2CNativeEngine_hpp -#define VoodooI2CNativeEngine_hpp - -#include -#include -#include - -#include "../VoodooI2CMultitouchInterface.hpp" -#include "../VoodooI2CMultitouchEngine.hpp" - -#include "../../Dependencies/VoodooInput/VoodooInput/VoodooInputMultitouch/VoodooInputTransducer.h" -#include "../../Dependencies/VoodooInput/VoodooInput/VoodooInputMultitouch/VoodooInputMessages.h" - -class EXPORT VoodooI2CNativeEngine : public VoodooI2CMultitouchEngine { - OSDeclareDefaultStructors(VoodooI2CNativeEngine); - - VoodooInputEvent message; - VoodooI2CMultitouchInterface* parentProvider; - IOService* voodooInputInstance; - - bool lastIsForceClickEnabled = true; - AbsoluteTime lastForceClickPropertyUpdateTime; - - bool isForceClickEnabled(); - public: - bool start(IOService* provider) override; - void stop(IOService* provider) override; - - bool handleOpen(IOService *forClient, IOOptionBits options, void *arg) override; - bool handleIsOpen(const IOService *forClient) const override; - void handleClose(IOService *forClient, IOOptionBits options) override; - void onPropertyChange() override; - - MultitouchReturn handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp); - private: - int stylus_check = 0; -}; - - -#endif /* VoodooI2CNativeEngine_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.cpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.cpp deleted file mode 100755 index 736e825..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -// VoodooI2CDigitiserStylus.cpp -// VoodooI2C -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CDigitiserStylus.hpp" - -#define super VoodooI2CDigitiserTransducer -OSDefineMetaClassAndStructors(VoodooI2CDigitiserStylus, VoodooI2CDigitiserTransducer); - -VoodooI2CDigitiserStylus* VoodooI2CDigitiserStylus::stylus(DigitiserTransducerType transducer_type, IOHIDElement* digitizer_collection) { - VoodooI2CDigitiserStylus* transducer = NULL; - - transducer = OSTypeAlloc(VoodooI2CDigitiserStylus); - - if (!transducer || !transducer->init()) { - OSSafeReleaseNULL(transducer); - goto exit; - } - - transducer->type = transducer_type; - transducer->collection = digitizer_collection; - transducer->in_range = false; - -exit: - return transducer; -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp deleted file mode 100644 index 842295d..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserStylus.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// -// VoodooI2CDigitiserStylus.hpp -// VoodooI2C -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CDigitiserStylus_hpp -#define VoodooI2CDigitiserStylus_hpp - -#include -#include -#include - -#include "VoodooI2CDigitiserTransducer.hpp" - - -/* Represents a stylus-type transducer */ - -class EXPORT VoodooI2CDigitiserStylus : public VoodooI2CDigitiserTransducer { - OSDeclareDefaultStructors(VoodooI2CDigitiserStylus); - - public: - UInt16 battery_strength; - DigitiserTransducerButtonState barrel_switch; - TimeTrackedValue barrel_pressure; - DigitiserTransducerButtonState eraser; - bool invert; - - static VoodooI2CDigitiserStylus* stylus(DigitiserTransducerType transducer_type, IOHIDElement* digitizer_collection); -}; - -#endif /* VoodooI2CDigitiserStylus_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.cpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.cpp deleted file mode 100644 index cdc032f..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// VoodooI2CDigitiserTransducer.cpp -// VoodooI2C -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CDigitiserTransducer.hpp" - -#define super OSObject -OSDefineMetaClassAndStructors(VoodooI2CDigitiserTransducer, OSObject); - -bool VoodooI2CDigitiserTransducer::serialize(OSSerialize* serializer) { - OSDictionary* temp_dictionary = OSDictionary::withCapacity(2); - - bool result = false; - - if (temp_dictionary) { - temp_dictionary->setObject(kIOHIDElementParentCollectionKey, collection); - temp_dictionary->serialize(serializer); - temp_dictionary->release(); - - result = true; - } - - return result; -} - -VoodooI2CDigitiserTransducer* VoodooI2CDigitiserTransducer::transducer(DigitiserTransducerType transducer_type, IOHIDElement* digitizer_collection) { - VoodooI2CDigitiserTransducer* transducer = NULL; - - transducer = OSTypeAlloc(VoodooI2CDigitiserTransducer); - - if (!transducer || !transducer->init()) { - OSSafeReleaseNULL(transducer); - goto exit; - } - - transducer->type = transducer_type; - transducer->collection = digitizer_collection; - transducer->in_range = false; - -exit: - return transducer; -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.hpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.hpp deleted file mode 100644 index 96b7df5..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CDigitiserTransducer.hpp +++ /dev/null @@ -1,141 +0,0 @@ -// -// VoodooI2CDigitiserTransducer.hpp -// VoodooI2C -// -// Created by Alexandre on 13/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CDigitiserTransducer_hpp -#define VoodooI2CDigitiserTransducer_hpp - -#include -#include -#include -#include -#include - -#ifndef EXPORT -#define EXPORT __attribute__((visibility("default"))) -#endif - -struct ValueWithTime { - UInt16 value = 0; - AbsoluteTime timestamp = 0; -}; - -/* Tracks a value with the current and last value being accessible with their respective timestamps */ - -class TimeTrackedValue { -public: - ValueWithTime current; - ValueWithTime last; - - operator bool() { - return (bool)current.value; - } - - /* Updates a timetracked value - * @value The new value to be set - * @timestamp The timestamp of the new value - */ - - void update(UInt16 value, AbsoluteTime timestamp) { - last = current; - current.value = value; - current.timestamp = timestamp; - } - - /* Returns the current value */ - - UInt16 value() { - return current.value; - } -}; - -typedef TimeTrackedValue DigitiserTransducerButtonState; - -typedef enum { - kDigitiserTransducerFinger, - kDigitiserTransducerStylus, - kDigitiserTransducerPuck -} DigitiserTransducerType; - -typedef struct { - TimeTrackedValue x; - TimeTrackedValue y; - TimeTrackedValue z; -} DigitiserTransducerCoordinates; - -typedef struct { - TimeTrackedValue width; - TimeTrackedValue height; -} DigitiserTransducerDimensions; - -typedef struct { - TimeTrackedValue azimuth; - TimeTrackedValue altitude; - TimeTrackedValue twist; -} DigitiserTransducerAziAltiOrentation; - -typedef struct { - TimeTrackedValue x_tilt; - TimeTrackedValue y_tilt; -} DigitiserTransducerTiltOrientation; - -/* Represents a transducer of a physical digitiser device */ - -class EXPORT VoodooI2CDigitiserTransducer : public OSObject { - OSDeclareDefaultStructors(VoodooI2CDigitiserTransducer); - -public: - DigitiserTransducerButtonState physical_button; - - DigitiserTransducerCoordinates coordinates; - DigitiserTransducerCoordinates last_coordinates; - - DigitiserTransducerDimensions dimensions; - DigitiserTransducerDimensions last_dimensions; - - DigitiserTransducerAziAltiOrentation azi_alti_orientation; - DigitiserTransducerTiltOrientation tilt_orientation; - - DigitiserTransducerButtonState tip_switch; - TimeTrackedValue tip_pressure; - - TimeTrackedValue touch_major; - TimeTrackedValue touch_minor; - - SInt32 logical_max_x; - SInt32 logical_max_y; - SInt32 logical_max_z; - SInt32 pressure_physical_max; - - UInt16 id; - UInt16 secondary_id; - - bool in_range = false; - bool is_valid = false; - DigitiserTransducerType type; - - IOHIDElement* collection; - - UInt32 event_mask; - AbsoluteTime timestamp; - - bool serialize(OSSerialize* serializer); - - /* Instantiates a new transducer - * @transducer_type The type of transducer to be created - * @digitizer_collection The HID element associated to this transducer. Set to *NULL* if not in an HID context - * - * @return A pointer to an instance of - */ - - static VoodooI2CDigitiserTransducer* transducer(DigitiserTransducerType transducer_type, IOHIDElement* digitizer_collection); -protected: -private: -}; - - -#endif /* VoodooI2CDigitiserTransducer_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.cpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.cpp deleted file mode 100644 index 28be736..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -// VoodooI2CMultitouchEngine.cpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CMultitouchEngine.hpp" -#include "VoodooI2CMultitouchInterface.hpp" - -#define super IOService -OSDefineMetaClassAndStructors(VoodooI2CMultitouchEngine, IOService); - -UInt8 VoodooI2CMultitouchEngine::getScore() { - return 0x0; -} - -MultitouchReturn VoodooI2CMultitouchEngine::handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - if (event.contact_count) - IOLog("Contact Count: %d\n", event.contact_count); - - for (int index = 0, count = event.transducers->getCount(); index < count; index++) { - VoodooI2CDigitiserTransducer* transducer = OSDynamicCast(VoodooI2CDigitiserTransducer, event.transducers->getObject(index)); - - if (!transducer) - continue; - - if (transducer->tip_switch) - IOLog("Transducer ID: %d, X: %d, Y: %d, Z: %d, Pressure: %d\n", transducer->secondary_id, transducer->coordinates.x.value(), transducer->coordinates.y.value(), transducer->coordinates.z.value(), transducer->tip_pressure.value()); - } - - return MultitouchReturnContinue; -} - -bool VoodooI2CMultitouchEngine::willTerminate(IOService* provider, IOOptionBits options) { - if (provider->isOpen(this)) - provider->close(this); - - return super::willTerminate(provider, options); -} - -bool VoodooI2CMultitouchEngine::start(IOService* provider) { - if (!super::start(provider)) - return false; - - interface = OSDynamicCast(VoodooI2CMultitouchInterface, provider); - - if (!interface) - return false; - - interface->open(this); - - setProperty("VoodooI2CServices Supported", kOSBooleanTrue); - - registerService(); - - return true; -} - -void VoodooI2CMultitouchEngine::onPropertyChange() { - return; -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.hpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.hpp deleted file mode 100644 index a467d5b..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchEngine.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// -// VoodooI2CMultitouchEngine.hpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CMultitouchEngine_hpp -#define VoodooI2CMultitouchEngine_hpp - -#include -#include -#include - -#include "MultitouchHelpers.hpp" - -class VoodooI2CMultitouchInterface; - -/* Base class that all mutltitouch engines should inherit from */ - -class EXPORT VoodooI2CMultitouchEngine : public IOService { - OSDeclareDefaultStructors(VoodooI2CMultitouchEngine); - - public: - VoodooI2CMultitouchInterface* interface; - - /* Intended to be overwritten by an inherited class to set the engine's priority - * - * @return The engine's score - */ - - virtual UInt8 getScore(); - - /* Intended to be overwritten by an inherited class to handle a multitouch event - * @event The event to be handled - * @timestamp The event's timestamp - * - * @return *MultitouchContinue* if the next engine in line should also be allowed to process the event, *MultitouchBreak* if this is the last engine that should be allowed to process the event - */ - - virtual MultitouchReturn handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp); - - bool willTerminate(IOService* provider, IOOptionBits options) override; - - /* Sets up the multitouch engine - * @provider The that we have matched against - * - * This function is intended to be overwritten by an inherited class but should still be called at the beginning of the overwritten - * function. - * @return *true* upon successful start, *false* otherwise - */ - - virtual bool start(IOService* provider); - - virtual void onPropertyChange(); -}; - - -#endif /* VoodooI2CMultitouchEngine_hpp */ diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.cpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.cpp deleted file mode 100644 index 371a275..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// -// VoodooI2CMultitouchInterface.cpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CMultitouchInterface.hpp" -#include "VoodooI2CMultitouchEngine.hpp" - -#define super IOService -OSDefineMetaClassAndStructors(VoodooI2CMultitouchInterface, IOService); - -void VoodooI2CMultitouchInterface::handleInterruptReport(VoodooI2CMultitouchEvent event, AbsoluteTime timestamp) { - int i, count; - VoodooI2CMultitouchEngine* engine; - - for (i = 0, count = engines->getCount(); i < count; i++) { - engine = OSDynamicCast(VoodooI2CMultitouchEngine, engines->getObject(i)); - if (!engine) - continue; - - if (engine->handleInterruptReport(event, timestamp) == MultitouchReturnBreak) - break; - } -} - -bool VoodooI2CMultitouchInterface::handleOpen(IOService* forClient, IOOptionBits options, void* arg) { - VoodooI2CMultitouchEngine* engine = OSDynamicCast(VoodooI2CMultitouchEngine, forClient); - - if (!engine) - return false; - - engines->setObject(engine); - - return true; -} - -void VoodooI2CMultitouchInterface::handleClose(IOService* forClient, IOOptionBits options) { - VoodooI2CMultitouchEngine* engine = OSDynamicCast(VoodooI2CMultitouchEngine, forClient); - - if (engine) - engines->removeObject(engine); -} - -bool VoodooI2CMultitouchInterface::handleIsOpen(const IOService *forClient ) const { - VoodooI2CMultitouchEngine* engine = OSDynamicCast(VoodooI2CMultitouchEngine, forClient); - - if (engine) { - return engines->containsObject(engine); - } - - return false; -} - -bool VoodooI2CMultitouchInterface::setProperty(const OSSymbol* key, OSObject* object) { - if (!super::setProperty(key, object)) { - return false; - } - for (int i = 0; i < engines->getCount(); i++) { - if (VoodooI2CMultitouchEngine* engine = OSDynamicCast(VoodooI2CMultitouchEngine, engines->getObject(i))) { - engine->onPropertyChange(); - } - } - return true; -} - -SInt8 VoodooI2CMultitouchInterface::orderEngines(VoodooI2CMultitouchEngine* a, VoodooI2CMultitouchEngine* b) { - if (a->getScore() > b->getScore()) - return 1; - else if (a->getScore() < b->getScore()) - return -1; - else - return 0; -} - -bool VoodooI2CMultitouchInterface::start(IOService* provider) { - if (!super::start(provider)) - return false; - - engines = OSOrderedSet::withCapacity(1, (OSOrderedSet::OSOrderFunction)VoodooI2CMultitouchInterface::orderEngines); - - setProperty(kIOFBTransformKey, 0ull, 32); - setProperty("VoodooI2CServices Supported", kOSBooleanTrue); - - return true; -} - -void VoodooI2CMultitouchInterface::stop(IOService* provider) { - OSSafeReleaseNULL(engines); - - super::stop(provider); -} diff --git a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp b/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp deleted file mode 100644 index 60e3135..0000000 --- a/BigSurface/BigSurface/SurfaceMultitouch/VoodooI2CMultitouchInterface.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// -// VoodooI2CMultitouchInterface.hpp -// VoodooI2C -// -// Created by Alexandre on 22/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CMultitouchInterface_hpp -#define VoodooI2CMultitouchInterface_hpp - -#include -#include -#include - -#include "MultitouchHelpers.hpp" -#include "VoodooI2CDigitiserStylus.hpp" - -#define kIOFBTransformKey "IOFBTransform" - -enum { - // transforms - kIOFBRotateFlags = 0x0000000f, - - kIOFBSwapAxes = 0x00000001, - kIOFBInvertX = 0x00000002, - kIOFBInvertY = 0x00000004, - - kIOFBRotate0 = 0x00000000, - kIOFBRotate90 = kIOFBSwapAxes | kIOFBInvertX, - kIOFBRotate180 = kIOFBInvertX | kIOFBInvertY, - kIOFBRotate270 = kIOFBSwapAxes | kIOFBInvertY -}; - -class VoodooI2CMultitouchEngine; - -/* Acts as a middleman between multitouch capable device drivers such as and a - * - * This class is designed to allow multiple (or inherited classes thereof) to attach and receive interrupt reports. - * This allows for situations in which different multitouch engines handle different gestures. - */ - -class EXPORT VoodooI2CMultitouchInterface : public IOService { - OSDeclareDefaultStructors(VoodooI2CMultitouchInterface); - - public: - UInt32 logical_max_x = 0; - UInt32 logical_max_y = 0; - UInt32 physical_max_x = 0; - UInt32 physical_max_y = 0; - - /* Forwards a multitouch event to the attached multitouch engines - * @event The event to forward - * @timestamp The timestamp of the event - * - * Multitouch engines with a higher - * @forClient An instance of that wishes to be a client - * @options Options avaliable for the open - * - * @return *true* upon successful opening, *false* otherwise - */ - - bool handleOpen(IOService* forClient, IOOptionBits options, void* arg) override; - - /* Controls the close behavior of - * @forClient An instance of that wishes to close the connection - * @options Options avaliable for the close - */ - - void handleClose(IOService* client, IOOptionBits options) override; - - - /* Provides a check if the calling IOService instance has called open - * @forClient An instance of that wishes to check if it has called open - */ - bool handleIsOpen(const IOService *forClient ) const override; - - using IORegistryEntry::setProperty; - bool setProperty(const OSSymbol* key, OSObject* object) override; - - /* Orders engines according to - * @a The first engine in the comparison - * @b The second engine in the comparison - * - * @return 1 if is to have higher priority than , -1 if is to have higher priority than , 0 if they have the same priority - */ - - static SInt8 orderEngines(VoodooI2CMultitouchEngine* a, VoodooI2CMultitouchEngine* b); - - /* Sets up the multitouch interface - * @provider The driver which has created us - * - * @return *true* on successful start, *false* otherwise - */ - - bool start(IOService* provider) override; - - /* Stops up the multitouch interface - * @provider The driver which has created us - */ - - void stop(IOService* provider) override; - - private: - OSOrderedSet* engines; -}; - - -#endif /* VoodooI2CMultitouchInterface_hpp */ diff --git a/BigSurface/BigSurface/SurfaceSerialHub/SurfaceSerialHubDriver.cpp b/BigSurface/BigSurface/SurfaceSerialHub/SurfaceSerialHubDriver.cpp index 83b4c4d..519475c 100644 --- a/BigSurface/BigSurface/SurfaceSerialHub/SurfaceSerialHubDriver.cpp +++ b/BigSurface/BigSurface/SurfaceSerialHub/SurfaceSerialHubDriver.cpp @@ -555,8 +555,8 @@ bool SurfaceSerialHubDriver::start(IOService *provider) { goto exit; } work_loop->addEventSource(publish_timer); - // publishing nubs after 30s - publish_timer->setTimeoutMS(30 * 1000); + // publishing nubs after 20s + publish_timer->setTimeoutMS(20 * 1000); uart_interrupt = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &SurfaceSerialHubDriver::processReceivedBuffer)); if (!uart_interrupt) { diff --git a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.cpp b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.cpp index c72176f..1702faa 100644 --- a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.cpp +++ b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.cpp @@ -32,10 +32,6 @@ void SurfaceBatteryNub::detach(IOService* provider) { bool SurfaceBatteryNub::start(IOService *provider) { if (!super::start(provider)) return false; - - PMinit(); - ssh->joinPMtree(this); - registerPowerDriver(this, myIOPMPowerStates, kIOPMNumberPowerStates); registerService(); return true; @@ -43,27 +39,9 @@ bool SurfaceBatteryNub::start(IOService *provider) { void SurfaceBatteryNub::stop(IOService *provider) { unregisterBatteryEvent(target); - PMstop(); super::stop(provider); } -IOReturn SurfaceBatteryNub::setPowerState(unsigned long whichState, IOService *whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (whichState == 0) { - if (awake) { - awake = false; - LOG("Going to sleep"); - } - } else { - if (!awake) { - awake = true; - LOG("Woke up"); - } - } - return kIOPMAckImplied; -} - IOReturn SurfaceBatteryNub::registerBatteryEvent(OSObject* owner, EventHandler _handler) { if (!owner || !_handler) return kIOReturnError; @@ -93,9 +71,6 @@ void SurfaceBatteryNub::unregisterBatteryEvent(OSObject* owner) { } void SurfaceBatteryNub::eventReceived(UInt8 tc, UInt8 tid, UInt8 iid, UInt8 cid, UInt8 *data_buffer, UInt16 length) { - if (!awake) - return; - // iid corresponds to battery/adaptor index, starts with 1 SurfaceBatteryEventType type; switch (cid) { @@ -109,7 +84,7 @@ void SurfaceBatteryNub::eventReceived(UInt8 tc, UInt8 tid, UInt8 iid, UInt8 cid, type = SurfaceAdaptorStatusChanged; break; default: -// LOG("Unknown battery event! tid: %d, iid: %d, cid: %x, data_len: %d", tid, iid, cid, length); + LOG("Unknown battery event! tid: %d, iid: %d, cid: %x, data_len: %d", tid, iid, cid, length); return; } if (handler) diff --git a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.hpp b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.hpp index bddc78e..8d9883d 100644 --- a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.hpp +++ b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceBatteryNub.hpp @@ -37,8 +37,6 @@ class EXPORT SurfaceBatteryNub : public SurfaceSerialHubClient { void stop(IOService* provider) override; - IOReturn setPowerState(unsigned long whichState, IOService *whatDevice) override; - IOReturn registerBatteryEvent(OSObject* owner, EventHandler _handler); void unregisterBatteryEvent(OSObject* owner); @@ -69,8 +67,6 @@ class EXPORT SurfaceBatteryNub : public SurfaceSerialHubClient { SurfaceSerialHubDriver* ssh {nullptr}; OSObject* target {nullptr}; EventHandler handler {nullptr}; - - bool awake {true}; }; #endif /* SurfaceBatteryNub_hpp */ diff --git a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.cpp b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.cpp index e5027a9..04fdfdc 100644 --- a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.cpp +++ b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.cpp @@ -43,10 +43,6 @@ bool SurfaceHIDNub::start(IOService *provider) { } LOG("HID version %d", !legacy+1); setProperty(SURFACE_LEGACY_HID_STRING, legacy); - - PMinit(); - ssh->joinPMtree(this); - registerPowerDriver(this, myIOPMPowerStates, kIOPMNumberPowerStates); registerService(); return true; @@ -54,27 +50,9 @@ bool SurfaceHIDNub::start(IOService *provider) { void SurfaceHIDNub::stop(IOService *provider) { unregisterHIDEvent(target); - PMstop(); super::stop(provider); } -IOReturn SurfaceHIDNub::setPowerState(unsigned long whichState, IOService *whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (whichState == 0) { - if (awake) { - awake = false; - LOG("Going to sleep"); - } - } else { - if (!awake) { - awake = true; - LOG("Woke up"); - } - } - return kIOPMAckImplied; -} - IOReturn SurfaceHIDNub::registerHIDEvent(OSObject* owner, EventHandler _handler) { if (!owner || !_handler) return kIOReturnError; @@ -248,31 +226,30 @@ void SurfaceHIDNub::setHIDRawReport(SurfaceHIDDeviceType device, UInt8 report_id if (feature) LOG("Warning, set feature report is not supported for legacy keyboard device!"); else { - LOG("caps lock report"); -// IOService *client = getClient(); -// if (!client) -// return; -// IOHIDDevice *kbd = OSDynamicCast(IOHIDDevice, client->getClient()); -// if (!kbd) -// return; -// OSArray* elements = OSDynamicCast(OSArray, kbd->getProperty(kIOHIDElementKey)); -// if (!elements) -// return; -// -// IOHIDElement* e = nullptr; -// for (int index=0; index < elements->getCount(); index++) { -// e = OSDynamicCast(IOHIDElement, elements->getObject(index)); -// if (!e) -// continue; -// if (e->getUsage() == 0) -// continue; -// -// if (e->conformsTo(kHIDPage_LEDs, kHIDUsage_LED_CapsLock)) { -// UInt8 value = e->getValue(); -// LOG("caps lock value %d", value); -// ssh->sendCommand(SSH_TC_KBD, SSH_TID_SECONDARY, 0, SSH_CID_KBD_SET_CAPS_LED, &value, 1, true); -// } -// } + IOService *client = getClient(); + if (!client) + return; + IOHIDDevice *kbd = OSDynamicCast(IOHIDDevice, client->getClient()); + if (!kbd) + return; + OSArray* elements = OSDynamicCast(OSArray, kbd->getProperty(kIOHIDElementKey)); + if (!elements) + return; + + IOHIDElement* e = nullptr; + for (int index=0; index < elements->getCount(); index++) { + e = OSDynamicCast(IOHIDElement, elements->getObject(index)); + if (!e) + continue; + if (e->getUsage() == 0) + continue; + + if (e->conformsTo(kHIDPage_LEDs, kHIDUsage_LED_CapsLock)) { + UInt8 value = e->getValue(); + LOG("caps lock value %d", value); + ssh->sendCommand(SSH_TC_KBD, SSH_TID_SECONDARY, 0, SSH_CID_KBD_SET_CAPS_LED, &value, 1, true); + } + } } } else { UInt8 cid = feature ? SSH_CID_HID_SET_FEAT_REPORT : SSH_CID_HID_OUT_REPORT; diff --git a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.hpp b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.hpp index fff02da..cc636ce 100644 --- a/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.hpp +++ b/BigSurface/BigSurface/SurfaceSerialHubDevices/SurfaceHIDNub.hpp @@ -72,8 +72,6 @@ class EXPORT SurfaceHIDNub : public SurfaceSerialHubClient { void stop(IOService* provider) override; - IOReturn setPowerState(unsigned long whichState, IOService *whatDevice) override; - IOReturn registerHIDEvent(OSObject* owner, EventHandler _handler); void unregisterHIDEvent(OSObject* owner); @@ -94,8 +92,7 @@ class EXPORT SurfaceHIDNub : public SurfaceSerialHubClient { SurfaceSerialHubDriver* ssh {nullptr}; OSObject* target {nullptr}; EventHandler handler {nullptr}; - - bool awake {true}; + bool legacy {true}; IOReturn getDescriptorData(SurfaceHIDDeviceType device, SurfaceHIDDescriptorEntryType entry, UInt8 *buffer, UInt16 buffer_len); diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IPTSKenerlUserShared.h b/BigSurface/BigSurface/SurfaceTouchScreen/IPTSKenerlUserShared.h deleted file mode 100644 index cd503af..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IPTSKenerlUserShared.h +++ /dev/null @@ -1,252 +0,0 @@ -// -// IPTSKenerlUserShared.h -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/11. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef IPTSKenerlUserShared_h -#define IPTSKenerlUserShared_h - -#include - -#ifndef PACKED -#define PACKED __attribute__((packed)) -#endif - -/* - * The amount of buffers that is used for IPTS - */ -#define IPTS_BUFFER_NUM 16 - -#define IPTS_DATA_TYPE_PAYLOAD 0x0 -#define IPTS_DATA_TYPE_ERROR 0x1 -#define IPTS_DATA_TYPE_VENDOR_DATA 0x2 -#define IPTS_DATA_TYPE_HID_REPORT 0x3 -#define IPTS_DATA_TYPE_GET_FEATURES 0x4 - -#define IPTS_PAYLOAD_FRAME_TYPE_STYLUS 0x6 -#define IPTS_PAYLOAD_FRAME_TYPE_HEATMAP 0x8 - -#define IPTS_REPORT_TYPE_START 0 -#define IPTS_REPORT_TYPE_END 0xff - -#define IPTS_CONTAINER_TYPE_ROOT 0x00 -#define IPTS_CONTAINER_TYPE_HEATMAP 0x01 -#define IPTS_CONTAINER_TYPE_REPORT 0xff - -#define IPTS_REPORT_TYPE_HEATMAP_DIM 0x03 -#define IPTS_REPORT_TYPE_HEATMAP 0x25 -#define IPTS_REPORT_TYPE_STYLUS_V1 0x10 -#define IPTS_REPORT_TYPE_STYLUS_V2 0x60 - -#define IPTS_REPORT_TYPE_FREQUENCY_NOISE 0x04 -#define IPTS_REPORT_TYPE_PEN_GENERAL 0x57 -#define IPTS_REPORT_TYPE_PEN_JNR_OUTPUT 0x58 -#define IPTS_REPORT_TYPE_PEN_NOISE_METRICS_OUTPUT 0x59 -#define IPTS_REPORT_TYPE_PEN_DATA_SELECTION 0x5a -#define IPTS_REPORT_TYPE_PEN_MAGNITUDE 0x5b -#define IPTS_REPORT_TYPE_PEN_DFT_WINDOW 0x5c -#define IPTS_REPORT_TYPE_PEN_MULTIPLE_REGION 0x5d -#define IPTS_REPORT_TYPE_PEN_TOUCHED_ANTENNAS 0x5e -#define IPTS_REPORT_TYPE_PEN_METADATA 0x5f -#define IPTS_REPORT_TYPE_PEN_DETECTION 0x62 -#define IPTS_REPORT_TYPE_PEN_LIFT 0x63 - -#define IPTS_STYLUS_REPORT_MODE_BIT_PROXIMITY 0 -#define IPTS_STYLUS_REPORT_MODE_BIT_CONTACT 1 -#define IPTS_STYLUS_REPORT_MODE_BIT_BUTTON 2 -#define IPTS_STYLUS_REPORT_MODE_BIT_RUBBER 3 - -//FIXME: should get these report IDs by parsing report descriptor and looking for digitizer usage 0x61 -#define IPTS_HID_REPORT_IS_CONTAINER(x) (x==7 || x==8 || x==10 || x==11 || x==12 || x==13 || x==26 || x==28) - -#define IPTS_HID_REPORT_SINGLETOUCH 0x40 -#define IPTS_SINGLETOUCH_MAX_VALUE (1 << 15) - -#define IPTS_MAX_X 9600 -#define IPTS_MAX_Y 7200 -#define IPTS_DIAGONAL 12000 -#define IPTS_MAX_PRESSURE 4096 - -#define IPTS_DFT_NUM_COMPONENTS 9 -#define IPTS_DFT_MAX_ROWS 16 -#define IPTS_DFT_PRESSURE_ROWS 6 - -#define IPTS_DFT_ID_POSITION 6 -#define IPTS_DFT_ID_BUTTON 9 -#define IPTS_DFT_ID_PRESSURE 11 - -struct PACKED IPTSDataHeader { - UInt32 type; - UInt32 size; - UInt32 buffer; - UInt8 reserved[52]; -}; - -struct PACKED IPTSPayloadHeader { - UInt32 counter; - UInt32 frames; - UInt8 reserved[4]; -}; - -struct PACKED IPTSPayloadFrame { - UInt16 index; - UInt16 type; - UInt32 size; - UInt8 reserved[8]; -}; - -struct PACKED IPTSReportHeader { - UInt8 type; - UInt8 flags; - UInt16 size; -}; - -struct PACKED IPTSStylusReportHeader { - UInt8 elements; - UInt8 reserved[3]; - UInt32 serial; -}; - -struct PACKED IPTSStylusReportV1 { - UInt8 reserved[4]; - UInt8 mode; - UInt16 x; - UInt16 y; - UInt16 pressure; - UInt8 reserved2; -}; - -struct PACKED IPTSStylusReportV2 { - UInt16 timestamp; - UInt16 mode; - UInt16 x; - UInt16 y; - UInt16 pressure; - UInt16 altitude; - UInt16 azimuth; - UInt8 reserved[2]; -}; - -struct PACKED IPTSStylusHIDReport { - UInt8 in_range:1; - UInt8 touch:1; - UInt8 side_button:1; - UInt8 inverted:1; - UInt8 eraser:1; - UInt8 reserved:3; - UInt16 x; - UInt16 y; - UInt16 tip_pressure; - UInt16 x_tilt; - UInt16 y_tilt; - UInt16 scan_time; -}; - -#define IPTS_TOUCH_SCREEN_FINGER_CNT 10 - -struct PACKED IPTSFingerReport { - UInt8 touch:1; - UInt8 contact_id:7; - UInt16 x; - UInt16 y; -}; - -struct PACKED IPTSTouchHIDReport { - IPTSFingerReport fingers[IPTS_TOUCH_SCREEN_FINGER_CNT]; - UInt8 contact_num; -}; - -struct PACKED IPTSHeatmapDimension { - UInt8 height; - UInt8 width; - UInt8 y_min; - UInt8 y_max; - UInt8 x_min; - UInt8 x_max; - UInt8 z_min; - UInt8 z_max; -}; - -struct PACKED IPTSReportStart { - UInt8 reserved[2]; - UInt16 count; - UInt32 timestamp; -}; - -struct PACKED IPTSReportContainer { - UInt32 size; - UInt8 zero; // always zero - UInt8 type; - UInt8 unknown; // 1 for heatmap container, 0 for other containers -}; - -struct PACKED IPTSReportHeatmap { - UInt8 unknown1; // always 8 - UInt32 unknown2; // always 0 - UInt32 size; -}; - -struct PACKED IPTSStylusMagnitudeData { - UInt8 unknown1[2]; // always zero - UInt8 unknown2[2]; // 0 if pen not near screen, 1 or 2 if pen is near screen - UInt8 flags; // 0, 1 or 8 (bitflags?) - UInt8 unknown3[3]; // always 0xff (padding?) - UInt32 x[64]; - UInt32 y[44]; -}; - -struct PACKED IPTSStylusDFTWindow { - UInt32 timestamp; // counting at approx 8MHz - UInt8 num_rows; - UInt8 seq_num; - UInt8 unknown1; // usually 1, can be 0 if there are simultaneous touch events - UInt8 unknown2; // usually 1, can be 0 if there are simultaneous touch events - UInt8 unknown3; // usually 1, but can be higher (2,3,4) for the first few packets of a pen interaction - UInt8 data_type; - UInt16 unknown4; // always 0xffff (padding?) -}; - -struct PACKED IPTSStylusDFTWindowRow { - UInt32 frequency; - UInt32 magnitude; - SInt16 real[IPTS_DFT_NUM_COMPONENTS]; - SInt16 imag[IPTS_DFT_NUM_COMPONENTS]; - SInt8 first; - SInt8 last; - SInt8 mid; - SInt8 zero; -}; - -#define IPTS_TOUCH_REPORT_ID 0x40 -#define IPTS_STYLUS_REPORT_ID 0x01 - -struct PACKED IPTSHIDReport { - UInt8 report_id; - union { - IPTSTouchHIDReport touch; - IPTSStylusHIDReport stylus; - } data; -}; - -struct PACKED IPTSDeviceInfo { - UInt16 vendor_id; - UInt16 product_id; - UInt8 max_contacts; -}; - -enum { - kMethodGetDeviceInfo, - kMethodReceiveInput, - kMethodSendHIDReport, - - kNumberOfMethods -}; - -enum { - kIPTSNumberOfMemoryType = IPTS_BUFFER_NUM, -}; - -#endif /* IPTSKenerlUserShared_h */ diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IPTSProtocol.h b/BigSurface/BigSurface/SurfaceTouchScreen/IPTSProtocol.h deleted file mode 100644 index 90b47a7..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IPTSProtocol.h +++ /dev/null @@ -1,355 +0,0 @@ -// -// IPTSProtocol.h -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/7. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef IPTSProtocol_h -#define IPTSProtocol_h - -#include "IPTSKenerlUserShared.h" - -/* - * Queries the device for vendor specific information. - * - * The command must not contain any payload. - * The response will contain IPTSGetDeviceInfoResponse as payload. - */ -#define IPTS_CMD_GET_DEVICE_INFO 0x00000001 -#define IPTS_RSP_GET_DEVICE_INFO 0x80000001 - -/* - * Sets the mode that IPTS will operate in. - * - * The command must contain IPTSSetModeCommand as payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_SET_MODE 0x00000002 -#define IPTS_RSP_SET_MODE 0x80000002 - -/* - * Configures the memory buffers that the ME will use - * for passing data to the host. - * - * The command must contain IPTSSetMemoryWindowCommand as payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_SET_MEM_WINDOW 0x00000003 -#define IPTS_RSP_SET_MEM_WINDOW 0x80000003 - -/* - * Signals that the host is ready to receive data from the ME. - * - * The command must not contain any payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_READY_FOR_DATA 0x00000005 -#define IPTS_RSP_READY_FOR_DATA 0x80000005 - -/* - * Signals that a buffer can be refilled from the ME. - * - * The command must contain IPTSFeedbackCommand as payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_FEEDBACK 0x00000006 -#define IPTS_RSP_FEEDBACK 0x80000006 - -/* - * Resets the data flow from the ME to the hosts and - * clears the buffers that were set with SET_MEM_WINDOW. - * - * The command must not contain any payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_CLEAR_MEM_WINDOW 0x00000007 -#define IPTS_RSP_CLEAR_MEM_WINDOW 0x80000007 - -/* - * Instructs the ME to reset the touch sensor. - * - * The command must contain struct IPTSResetSensorCommand as payload. - * The response will not contain any payload. - */ -#define IPTS_CMD_RESET_SENSOR 0x0000000B -#define IPTS_RSP_RESET_SENSOR 0x8000000B - -/* - * Get HID report descriptor. - * - * The command must contain struct IPTSGetReportDescriptor. - * The response will contain 8 bytes zeros padding following HID report descriptor. - */ -#define IPTS_CMD_GET_REPORT_DESC 0x0000000F -#define IPTS_RSP_GET_REPORT_DESC 0x8000000F - -/** - * enum IPTSStatus - Possible status codes returned by IPTS commands. - * @IPTSCommandSuccess: Operation completed successfully. - * @IPTSCommandInvalidParams: Command contained a payload with invalid parameters. - * @IPTSCommandAccessDenied: ME could not validate buffer addresses supplied by host. - * @IPTSCommandPayloadSizeError: Command contains an invalid payload. - * @IPTSCommandNotReady: Buffer addresses have not been set. - * @IPTSCommandRequestOutstanding: There is an outstanding command of the same type. - * The host must wait for a response before sending another - * command of the same type. - * @IPTSCommandNoSensorFound: No sensor could be found. Either no sensor is connected, it - * has not been initialized yet, or the system is improperly - * configured. - * @IPTSCommandOutOfMemory: Not enough free memory for requested operation. - * @IPTSCommandUnexpectedError: An unexpected error occurred. - * @IPTSCommandSensorDisabled: The sensor has been disabled and must be reinitialized. - * @IPTSCommandCompatCheckFail: Compatibility revision check between sensor and ME failed. - * The host can ignore this error and attempt to continue. - * @IPTSCommandExpectedReset: The sensor went through a reset initiated by ME or host. - * @IPTSCommandUnexpectedReset: The sensor went through an unexpected reset. - * @IPTSCommandResetFailed: Requested sensor reset failed to complete. - * @IPTSCommandTimeout: The operation timed out. - * @IPTSCommandTestModeFail: Test mode pattern did not match expected values. - * @IPTSCommandSensorFatalFail: The sensor reported a fatal error during reset sequence. - * Further progress is not possible. - * @IPTSCommandSensorFail: The sensor reported a fatal error during reset sequence. - * The host can attempt to continue. - * @IPTSCommandInvalidDeviceCapability: The device reported invalid capabilities. - * @IPTSCommandQuiesceIOInProgress: Command cannot be completed until Quiesce IO is done. - */ -enum IPTSCommandStatus { - IPTSCommandSuccess = 0, - IPTSCommandInvalidParams = 1, - IPTSCommandAccessDenied = 2, - IPTSCommandPayloadSizeError = 3, - IPTSCommandNotReady = 4, - IPTSCommandRequestOutstanding = 5, - IPTSCommandNoSensorFound = 6, - IPTSCommandOutOfMemory = 7, - IPTSCommandUnexpectedError = 8, - IPTSCommandSensorDisabled = 9, - IPTSCommandCompatCheckFail = 10, - IPTSCommandExpectedReset = 11, - IPTSCommandUnexpectedReset = 12, - IPTSCommandResetFailed = 13, - IPTSCommandTimeout = 14, - IPTSCommandTestModeFail = 15, - IPTSCommandSensorFatalFail = 16, - IPTSCommandSensorFail = 17, - IPTSCommandInvalidDeviceCapability = 18, - IPTSCommandQuiesceIOInProgress = 19, -}; - - - -/* - * The special buffer ID that is used for direct host2me feedback. - */ -#define IPTS_HOST2ME_BUFFER IPTS_BUFFER_NUM - -/** - * enum ipts_mode - Operation mode for IPTS hardware - * @IPTSSingletouch: Fallback that supports only one finger and no stylus. - * The data is received as a HID report with ID 64. - * @IPTSMultitouch: The "proper" operation mode for IPTS. It will return - * stylus data as well as capacitive heatmap touch data. - * This data needs to be processed in userspace. - */ -enum IPTSTouchMode { - IPTSSingletouch = 0, - IPTSMultitouch = 1, -}; - -/** - * struct IPTSSetModeCommand - Payload for the SET_MODE command. - * @mode: The mode that IPTS should operate in. - */ -struct PACKED IPTSSetModeCommand { - IPTSTouchMode mode; - UInt8 reserved[12]; -}; - -#define IPTS_WORKQUEUE_SIZE 8192 -#define IPTS_WORKQUEUE_ITEM_SIZE 16 - -/** - * struct IPTSSetMemoryWindowCommand - Payload for the SET_MEM_WINDOW command. - * @data_buffer_addr_lower: Lower 32 bits of the data buffer addresses. - * @data_buffer_addr_upper: Upper 32 bits of the data buffer addresses. - * @workqueue_addr_lower: Lower 32 bits of the workqueue buffer address. - * @workqueue_addr_upper: Upper 32 bits of the workqueue buffer address. - * @doorbell_addr_lower: Lower 32 bits of the doorbell buffer address. - * @doorbell_addr_upper: Upper 32 bits of the doorbell buffer address. - * @feedback_buffer_addr_lower: Lower 32 bits of the feedback buffer addresses. - * @feedback_buffer_addr_upper: Upper 32 bits of the feedback buffer addresses. - * @host2me_addr_lower: Lower 32 bits of the host2me buffer address. - * @host2me_addr_upper: Upper 32 bits of the host2me buffer address. - * @workqueue_item_size: Magic value. (IPTS_WORKQUEUE_ITEM_SIZE) - * @workqueue_size: Magic value. (IPTS_WORKQUEUE_SIZE) - * - * The data buffers are buffers that get filled with touch data by the ME. - * The doorbell buffer is a UInt32 that gets incremented by the ME once a data - * buffer has been filled with new data. - * - * The other buffers are required for using GuC submission with binary - * firmware. Since support for GuC submission has been dropped from i915, - * they are not used anymore, but they need to be allocated and passed, - * otherwise the hardware will refuse to start. - */ -struct PACKED IPTSSetMemoryWindowCommand { - UInt32 data_buffer_addr_lower[IPTS_BUFFER_NUM]; - UInt32 data_buffer_addr_upper[IPTS_BUFFER_NUM]; - UInt32 workqueue_addr_lower; - UInt32 workqueue_addr_upper; - UInt32 doorbell_addr_lower; - UInt32 doorbell_addr_upper; - UInt32 feedback_buffer_addr_lower[IPTS_BUFFER_NUM]; - UInt32 feedback_buffer_addr_upper[IPTS_BUFFER_NUM]; - UInt32 host2me_addr_lower; - UInt32 host2me_addr_upper; - UInt32 host2me_size; - UInt8 reserved1; - UInt8 workqueue_item_size; - UInt16 workqueue_size; - UInt8 reserved[32]; -}; - -/** - * struct ipts_feedback_cmd - Payload for the FEEDBACK command. - * @buffer: The buffer that the ME should refill. - */ -struct PACKED IPTSFeedbackCommand { - UInt32 buffer; - UInt8 reserved[12]; -}; - -/** - * enum IPTSFeedbackCommandType - Commands that can be executed on the sensor through feedback. - */ -enum IPTSFeedbackCommandType { - IPTSFeedbackCommandTypeNone = 0, - IPTSFeedbackCommandTypeSoftReset = 1, - IPTSFeedbackCommandTypeGotoArmed = 2, - IPTSFeedbackCommandTypeGotoSensing = 3, - IPTSFeedbackCommandTypeGotoSleep = 4, - IPTSFeedbackCommandTypeGotoDoze = 5, - IPTSFeedbackCommandTypeHardReset = 6, -}; - -/** - * enum IPTSFeedbackDataType - Describes the data that a feedback buffer contains. - * @IPTSFeedbackDataTypeVendor: The buffer contains vendor specific feedback. - * @IPTSFeedbackDataTypeSetFeatures: The buffer contains a HID set features command. - * @IPTSFeedbackDataTypeGetFeatures: The buffer contains a HID get features command. - * @IPTSFeedbackDataTypeOutputReport: The buffer contains a HID output report. - * @IPTSFeedbackDataTypeStoreData: The buffer contains calibration data for the sensor. - */ -enum IPTSFeedbackDataType { - IPTSFeedbackDataTypeVendor = 0, - IPTSFeedbackDataTypeSetFeatures = 1, - IPTSFeedbackDataTypeGetFeatures = 2, - IPTSFeedbackDataTypeOutputReport = 3, - IPTSFeedbackDataTypeStoreData = 4, -}; - -/** - * struct IPTSFeedbackBuffer - The contents of an IPTS feedback buffer. - * @cmd_type: A command that should be executed on the sensor. - * @size: The size of the payload to be written. - * @buffer: The ID of the buffer that contains this feedback data. - * @protocol: The protocol version of the EDS. - * @data_type: The type of payload that the buffer contains. - * @spi_offset: The offset at which to write the payload data. - * @payload: Payload for the feedback command, or 0 if no payload is sent. - */ -struct PACKED IPTSFeedbackBuffer { - IPTSFeedbackCommandType cmd_type; - UInt32 size; - UInt32 buffer; - UInt32 protocol; - IPTSFeedbackDataType data_type; - UInt32 spi_offset; - UInt8 reserved[40]; - UInt8 payload[]; -}; - -/** - * enum IPTSResetType - Possible ways of resetting the touch sensor - * @IPTSResetTypeHard: Perform hardware reset using GPIO pin. - * @IPTSResetTypeSoft: Perform software reset using SPI interface. - */ -enum IPTSResetType { - IPTSResetTypeHard = 0, - IPTSResetTypeSoft = 1, -}; - -/** - * struct IPTSResetSensorCommand - Payload for the RESET_SENSOR command. - * @type: What type of reset should be performed. - */ -struct PACKED IPTSResetSensorCommand { - IPTSResetType type; - UInt8 reserved[4]; -}; - -#define IPTS_REPORT_DESC_PADDING 8 - -struct PACKED IPTSGetReportDescriptor { - UInt32 addr_lower; - UInt32 addr_upper; - UInt32 padding_len; // MUST be IPTS_REPORT_DESC_PADDING=8 - UInt8 reserved[12]; -}; - -/** - * struct IPTSCommand - A message sent from the host to the ME. - * @code: The message code describing the command. (see IPTS_CMD_*) - * @payload: Payload for the command, or 0 if no payload is required. - */ -struct PACKED IPTSCommand { - UInt32 code; - UInt8 payload[320]; -}; - -/** - * struct IPTSGetDeviceInfoResponse - Payload for the GET_DEVICE_INFO response. - * @vendor_id: Vendor ID of the touch sensor. - * @device_id: Device ID of the touch sensor. - * @hw_rev: Hardware revision of the touch sensor. - * @fw_rev: Firmware revision of the touch sensor. - * @data_size: Required size of one data buffer. - * @feedback_size: Required size of one feedback buffer. - * @mode: Current operation mode of IPTS. - * @max_contacts: The amount of concurrent touches supported by the sensor. - */ -struct PACKED IPTSGetDeviceInfoResponse { - UInt16 vendor_id; - UInt16 device_id; - UInt32 hw_rev; - UInt32 fw_rev; - UInt32 data_size; - UInt32 feedback_size; - IPTSTouchMode mode; - UInt8 max_contacts; - UInt8 reserved[19]; -}; - -/** - * struct IPTSFeedbackResponse - Payload for the FEEDBACK response. - * @buffer: The buffer that has received feedback. - */ -struct PACKED IPTSFeedbackResponse { - UInt32 buffer; -}; - -/** - * struct IPTSResponse - A message sent from the ME to the host. - * @code: The message code describing the response. (see IPTS_RSP_*) - * @status: The status code returned by the command. - * @payload: Payload returned by the command. - */ -struct PACKED IPTSResponse { - UInt32 code; - IPTSCommandStatus status; - UInt8 payload[80]; -}; - -#endif /* IPTSProtocol_h */ diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.cpp b/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.cpp deleted file mode 100644 index 3e057b8..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.cpp +++ /dev/null @@ -1,600 +0,0 @@ -// -// IntelPreciseTouchStylusDriver.cpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/5. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#include "IntelPreciseTouchStylusDriver.hpp" -#include "SurfaceTouchScreenDevice.hpp" - -#define LOG(str, ...) IOLog("%s::" str "\n", "IntelPreciseTouchStylusDriver", ##__VA_ARGS__) - -#define super IOService -OSDefineMetaClassAndStructors(IntelPreciseTouchStylusDriver, IOService) - -void hex_dump(const char *name, UInt8 *buffer, UInt16 len) { - if (len == 0) - return; - IOLog("%s::msg dump: length: %d\n", name, len); - int row = (len-1)/16 + 1; - for (int r=0; raddEventSource(command_gate); - wait_input = OSMemberFunctionCast(IOCommandGate::Action, this, &IntelPreciseTouchStylusDriver::getCurrentInputBufferGated); - interrupt_source = IOInterruptEventSource::interruptEventSource(this, OSMemberFunctionCast(IOInterruptEventAction, this, &IntelPreciseTouchStylusDriver::handleHIDReportGated)); - if (!interrupt_source) { - LOG("Failed to create interrupt source!"); - goto exit; - } - work_loop->addEventSource(interrupt_source); - timer = IOTimerEventSource::timerEventSource(this, OSMemberFunctionCast(IOTimerEventSource::Action, this, &IntelPreciseTouchStylusDriver::pollTouchData)); - if (!timer) { - LOG("Failed to create timer"); - goto exit; - } - work_loop->addEventSource(timer); - - // Publishing touch screen device - touch_screen = OSTypeAlloc(SurfaceTouchScreenDevice); - if (!touch_screen || !touch_screen->init() || !touch_screen->attach(this)) { - LOG("Could not init Surface Touch Screen device"); - goto exit; - } - if (api->registerMessageHandler(this, OSMemberFunctionCast(SurfaceManagementEngineClient::MessageHandler, this, &IntelPreciseTouchStylusDriver::handleMessage)) != kIOReturnSuccess) { - LOG("Failed to register receive handler"); - goto exit; - } - if (startDevice() != kIOReturnSuccess) { - LOG("Failed to start IPTS device!"); - goto exit; - } - - PMinit(); - api->joinPMtree(this); - registerPowerDriver(this, MyIOPMPowerStates, kIOPMNumberPowerStates); - - registerService(); - return true; -exit: - releaseResources(); - return false; -} - -void IntelPreciseTouchStylusDriver::stop(IOService *provider) { - stopDevice(); - // Wait at most 500ms for device to stop - for (int i = 0; i < 20; i++) { - if (state == IPTSDeviceStateStopped) - break; - IOSleep(25); - } - releaseResources(); - super::stop(provider); -} - -IOReturn IntelPreciseTouchStylusDriver::setPowerState(unsigned long whichState, IOService *whatDevice) { - if (whatDevice != this) - return kIOReturnInvalid; - if (whichState == 0) { - if (awake) { - awake = false; - stopDevice(); - // Wait at most 500ms for device to stop - for (int i = 0; i < 20; i++) { - if (state == IPTSDeviceStateStopped) - break; - IOSleep(25); - } - current_doorbell = 0; - LOG("Going to sleep"); - } - } else { - if (!awake) { - command_gate->commandWakeup(&wait); - IOReturn ret = kIOReturnSuccess; - for (int i = 0; i < 3; i++) { - IOSleep(100); - ret = startDevice(); - if (ret != kIOReturnNoDevice || i == 2) - break; - IOSleep(400); - } - if (ret != kIOReturnSuccess) - LOG("Failed to restart IPTS device from sleep!"); - awake = true; - LOG("Woke up"); - } - } - return kIOPMAckImplied; -} - -void IntelPreciseTouchStylusDriver::releaseResources() { - if (timer) { - timer->cancelTimeout(); - timer->disable(); - work_loop->removeEventSource(timer); - OSSafeReleaseNULL(timer); - } - if (interrupt_source) { - interrupt_source->disable(); - work_loop->removeEventSource(interrupt_source); - OSSafeReleaseNULL(interrupt_source); - } - if (command_gate) { - command_gate->disable(); - work_loop->removeEventSource(command_gate); - OSSafeReleaseNULL(command_gate); - } - OSSafeReleaseNULL(work_loop); - - if (touch_screen) { - touch_screen->stop(this); - touch_screen->detach(this); - OSSafeReleaseNULL(touch_screen); - } -} - -IOBufferMemoryDescriptor *IntelPreciseTouchStylusDriver::getReceiveBufferForIndex(int idx) { - if (idx < 0 || idx >= IPTS_BUFFER_NUM) - return nullptr; - - rx_buffer[idx].buffer->retain(); - return rx_buffer[idx].buffer; -} - -UInt16 IntelPreciseTouchStylusDriver::getVendorID() { - return touch_screen->vendor_id; -} - -UInt16 IntelPreciseTouchStylusDriver::getDeviceID() { - return touch_screen->device_id; -} - -UInt8 IntelPreciseTouchStylusDriver::getMaxContacts() { - return touch_screen->max_contacts; -} - -IOReturn IntelPreciseTouchStylusDriver::getCurrentInputBuffer(UInt8 *buffer_idx) { - return command_gate->runAction(wait_input, buffer_idx); -} - -IOReturn IntelPreciseTouchStylusDriver::getCurrentInputBufferGated(UInt8 *buffer_idx) { - IOReturn ret = command_gate->commandSleep(&wait); - - if (ret != THREAD_AWAKENED) - return kIOReturnError; - - if (!awake) - *buffer_idx = IPTS_BUFFER_NUM; // Special index indicating reconnect needed - else - *buffer_idx = (current_doorbell - 1) % IPTS_BUFFER_NUM; - return kIOReturnSuccess; -} - -void IntelPreciseTouchStylusDriver::handleHIDReportGated(IOInterruptEventSource *sender, int count) { - if (sent) - return; - - IOBufferMemoryDescriptor *buffer; - switch (report_to_send.report_id) { - case IPTS_TOUCH_REPORT_ID: - buffer = IOBufferMemoryDescriptor::withBytes(&report_to_send, sizeof(IPTSTouchHIDReport)+1, kIODirectionNone); - break; - case IPTS_STYLUS_REPORT_ID: - buffer = IOBufferMemoryDescriptor::withBytes(&report_to_send, sizeof(IPTSStylusHIDReport)+1, kIODirectionNone); - break; - default: - return; - } - touch_screen->handleReport(buffer); - OSSafeReleaseNULL(buffer); - sent = true; -} - -void IntelPreciseTouchStylusDriver::handleHIDReport(const IPTSHIDReport *report) { - report_to_send = *report; - sent = false; - interrupt_source->interruptOccurred(nullptr, this, 0); -} - -void IntelPreciseTouchStylusDriver::pollTouchData(IOTimerEventSource *sender) { - UInt32 doorbell; - memcpy(&doorbell, doorbell_buffer.vaddr, sizeof(UInt32)); - - if (doorbell == current_doorbell) { - if (!busy) { - timer->setTimeoutMS(IPTS_IDLE_TIMEOUT); - return; - } - AbsoluteTime cur_time; - UInt64 nsecs; - clock_get_uptime(&cur_time); - SUB_ABSOLUTETIME(&cur_time, &last_activate); - absolutetime_to_nanoseconds(cur_time, &nsecs); - if (nsecs < 500000000) // < 500ms - timer->setTimeoutMS(IPTS_BUSY_TIMEOUT); - else if (nsecs < 1500000000) // < 1.5s - timer->setTimeoutMS(IPTS_ACTIVE_TIMEOUT); - else { - busy = false; - timer->setTimeoutMS(IPTS_IDLE_TIMEOUT); - } - } else if (doorbell < current_doorbell) { // MEI device has been reset - LOG("MEI device has reset! Flushing buffers..."); - for (int i = 0; i < IPTS_BUFFER_NUM; i++) - sendFeedback(i); - current_doorbell = doorbell; - timer->setTimeoutMS(IPTS_BUSY_TIMEOUT); - } else { - command_gate->commandWakeup(&wait); - - sendFeedback(current_doorbell % IPTS_BUFFER_NUM, false); // non blocking feedback - current_doorbell++; - busy = true; - clock_get_uptime(&last_activate); - timer->setTimeoutMS(IPTS_BUSY_TIMEOUT); - } -} - -IOReturn IntelPreciseTouchStylusDriver::sendIPTSCommand(UInt32 code, UInt8 *data, UInt16 data_len, bool blocking) { - IPTSCommand cmd; - - memset(&cmd, 0, sizeof(IPTSCommand)); - cmd.code = code; - - if (data && data_len > 0) - memcpy(&cmd.payload, data, data_len); - - IOReturn ret = api->sendMessage(reinterpret_cast(&cmd), sizeof(cmd.code) + data_len, blocking); - if (ret != kIOReturnSuccess && (ret != kIOReturnNoDevice || state != IPTSDeviceStateStopping)) - LOG("Error while sending: 0x%X:%d", code, ret); - - return ret; -} - -IOReturn IntelPreciseTouchStylusDriver::sendFeedback(UInt32 buffer, bool blocking) -{ - IPTSFeedbackCommand cmd; - - memset(&cmd, 0, sizeof(IPTSFeedbackCommand)); - cmd.buffer = buffer; - - return sendIPTSCommand(IPTS_CMD_FEEDBACK, reinterpret_cast(&cmd), sizeof(IPTSFeedbackCommand), blocking); -} - -IOReturn IntelPreciseTouchStylusDriver::sendSetFeatureReport(UInt8 report_id, UInt8 value) -{ - IPTSFeedbackBuffer *feedback; - - memset(tx_buffer.vaddr, 0, feedback_buffer_size); - feedback = reinterpret_cast(tx_buffer.vaddr); - - feedback->cmd_type = IPTSFeedbackCommandTypeNone; - feedback->data_type = IPTSFeedbackDataTypeSetFeatures; - feedback->buffer = IPTS_HOST2ME_BUFFER; - feedback->size = 2; - feedback->payload[0] = report_id; - feedback->payload[1] = value; - - return sendFeedback(IPTS_HOST2ME_BUFFER); -} - -IOReturn IntelPreciseTouchStylusDriver::startDevice() -{ - if (state != IPTSDeviceStateStopped) - return kIOReturnBusy; - - state = IPTSDeviceStateStarting; - restart = false; - - return sendIPTSCommand(IPTS_CMD_GET_DEVICE_INFO, nullptr, 0); -} - -IOReturn IntelPreciseTouchStylusDriver::stopDevice() -{ - if (state == IPTSDeviceStateStopping || state == IPTSDeviceStateStopped) - return kIOReturnBusy; - - state = IPTSDeviceStateStopping; - - timer->cancelTimeout(); - timer->disable(); - - freeDMAResources(); - IOReturn ret = sendFeedback(0); - if (ret == kIOReturnNoDevice) - state = IPTSDeviceStateStopped; - - return ret; -} - -IOReturn IntelPreciseTouchStylusDriver::restartDevice() -{ - if (restart) - return kIOReturnBusy; - restart = true; - - return stopDevice(); -} - -void IntelPreciseTouchStylusDriver::handleMessage(SurfaceManagementEngineClient *sender, UInt8 *msg, UInt16 msg_len) { - IPTSResponse *rsp = reinterpret_cast(msg); - if (isResponseError(rsp)) - return; - - IOReturn ret = kIOReturnSuccess; - switch (rsp->code) { - case IPTS_RSP_GET_DEVICE_INFO: { - IPTSGetDeviceInfoResponse device_info; - memcpy(&device_info, rsp->payload, sizeof(IPTSGetDeviceInfoResponse)); - touch_screen->vendor_id = device_info.vendor_id; - touch_screen->device_id = device_info.device_id; - touch_screen->version = device_info.hw_rev; - touch_screen->max_contacts = device_info.max_contacts; - data_buffer_size = device_info.data_size; - feedback_buffer_size = device_info.feedback_size; - mode = device_info.mode; - - if (allocateDMAResources() != kIOReturnSuccess) { - LOG("Failed to allocate resources"); - ret = kIOReturnNoMemory; - break; - } - -// IPTSGetReportDescriptor get_desc; -// memset(&get_desc, 0, sizeof(IPTSGetReportDescriptor)); -// memset(report_desc_buffer.vaddr, 0, IPTS_REPORT_DESC_BUFFER_SIZE); -// get_desc.addr_lower = report_desc_buffer.paddr & 0xffffffff; -// get_desc.addr_upper = report_desc_buffer.paddr >> 32; -// get_desc.padding_len = IPTS_REPORT_DESC_PADDING; -// ret = sendIPTSCommand(IPTS_CMD_GET_REPORT_DESC, reinterpret_cast(&get_desc), sizeof(IPTSGetReportDescriptor)); -// break; -// } -// case IPTS_RSP_GET_REPORT_DESC: { -// IPTSDataHeader header; -// memcpy(&header, report_desc_buffer.vaddr, sizeof(IPTSDataHeader)); -// UInt16 desc_len = header.size - IPTS_REPORT_DESC_PADDING; -// touch_screen->hid_desc = IOBufferMemoryDescriptor::withBytes((UInt8 *)report_desc_buffer.vaddr + sizeof(IPTSDataHeader) + IPTS_REPORT_DESC_PADDING, desc_len, kIODirectionNone); - - IPTSSetModeCommand set_mode_cmd; - memset(&set_mode_cmd, 0, sizeof(IPTSSetModeCommand)); - set_mode_cmd.mode = IPTSMultitouch; - ret = sendIPTSCommand(IPTS_CMD_SET_MODE, reinterpret_cast(&set_mode_cmd), sizeof(IPTSSetModeCommand)); - break; - } - case IPTS_RSP_SET_MODE: { - mode = IPTSMultitouch; - - IPTSSetMemoryWindowCommand set_mem_cmd; - memset(&set_mem_cmd, 0, sizeof(IPTSSetMemoryWindowCommand)); - for (int i = 0; i < IPTS_BUFFER_NUM; i++) { - set_mem_cmd.data_buffer_addr_lower[i] = rx_buffer[i].paddr & 0xffffffff; - set_mem_cmd.data_buffer_addr_upper[i] = rx_buffer[i].paddr >> 32; - - set_mem_cmd.feedback_buffer_addr_lower[i] = feedback_buffer[i].paddr & 0xffffffff; - set_mem_cmd.feedback_buffer_addr_upper[i] = feedback_buffer[i].paddr >> 32; - } - set_mem_cmd.workqueue_addr_lower = workqueue_buffer.paddr & 0xffffffff; - set_mem_cmd.workqueue_addr_upper = workqueue_buffer.paddr >> 32; - - set_mem_cmd.doorbell_addr_lower = doorbell_buffer.paddr & 0xffffffff; - set_mem_cmd.doorbell_addr_upper = doorbell_buffer.paddr >> 32; - - set_mem_cmd.host2me_addr_lower = tx_buffer.paddr & 0xffffffff; - set_mem_cmd.host2me_addr_upper = tx_buffer.paddr >> 32; - - set_mem_cmd.workqueue_size = IPTS_WORKQUEUE_SIZE; - set_mem_cmd.workqueue_item_size = IPTS_WORKQUEUE_ITEM_SIZE; - - ret = sendIPTSCommand(IPTS_CMD_SET_MEM_WINDOW, reinterpret_cast(&set_mem_cmd), sizeof(IPTSSetMemoryWindowCommand)); - break; - } - case IPTS_RSP_SET_MEM_WINDOW: - if (!touch_screen_started) { - if (!touch_screen->start(this)) { - touch_screen->detach(this); - LOG("Could not start Surface Touch Screen device"); - ret = kIOReturnError; - break; - } - touch_screen_started = true; - } - - LOG("IPTS Device is ready"); - state = IPTSDeviceStateStarted; - - ret = sendIPTSCommand(IPTS_CMD_READY_FOR_DATA, nullptr, 0); - if (ret != kIOReturnSuccess) - break; - if (touch_screen->vendor_id == 0x045e && touch_screen->device_id & 0x0100) - ret = sendSetFeatureReport(0x5, 0x1); // magic command to enable multitouch on newer devices - if (ret != kIOReturnSuccess) - LOG("Failed to enable multitouch on SP7 and newer devices!"); - - timer->enable(); - timer->setTimeoutMS(IPTS_IDLE_TIMEOUT); - - break; - case IPTS_RSP_FEEDBACK: { - if (state != IPTSDeviceStateStopping) - break; - - IPTSFeedbackResponse feedback; - memcpy(&feedback, rsp->payload, sizeof(IPTSFeedbackResponse)); - if (feedback.buffer < IPTS_BUFFER_NUM - 1) { - ret = sendFeedback(feedback.buffer + 1); - break; - } - ret = sendIPTSCommand(IPTS_CMD_CLEAR_MEM_WINDOW, nullptr, 0); - break; - } - case IPTS_RSP_CLEAR_MEM_WINDOW: - state = IPTSDeviceStateStopped; - if (restart) - ret = startDevice(); - break; - default: - break; - } - if (ret != kIOReturnSuccess) { - LOG("Error while handling response 0x%08x", rsp->code); - stopDevice(); - } -} - -bool IntelPreciseTouchStylusDriver::isResponseError(IPTSResponse *rsp) { - bool error; - switch (rsp->status) { - case IPTSCommandSuccess: - case IPTSCommandCompatCheckFail: - error = false; - break; - case IPTSCommandInvalidParams: - error = rsp->code != IPTS_RSP_FEEDBACK; - break; - case IPTSCommandSensorDisabled: - error = state != IPTSDeviceStateStopping; - break; - default: - error = true; - break; - } - if (!error) - return false; - - LOG("Command 0x%08x failed: %d", rsp->code, rsp->status); - if (rsp->status == IPTSCommandExpectedReset || rsp->status == IPTSCommandUnexpectedReset) { - LOG("Sensor was reset"); - if (restartDevice()) - LOG("Failed to restart IPTS"); - } - return true; -} - -IOReturn IntelPreciseTouchStylusDriver::allocateDMAMemory(IPTSBufferInfo *info, UInt32 size) { - IOBufferMemoryDescriptor *buf = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(kernel_task, kIODirectionInOut | kIOMemoryPhysicallyContiguous | kIOMemoryKernelUserShared | kIOMapInhibitCache, size, DMA_BIT_MASK(64)); - if (!buf) - return kIOReturnNoMemory; - buf->prepare(); - - IODMACommand *cmd = IODMACommand::withSpecification(kIODMACommandOutputHost64, 64, 0, IODMACommand::kMapped, 0, 4); - if (!cmd) { - buf->complete(); - OSSafeReleaseNULL(buf); - return kIOReturnNoMemory; - } - cmd->setMemoryDescriptor(buf); - - IODMACommand::Segment64 seg; - UInt64 offset = 0; - UInt32 seg_num = 1; - if (cmd->gen64IOVMSegments(&offset, &seg, &seg_num) != kIOReturnSuccess) { - OSSafeReleaseNULL(cmd); - buf->complete(); - OSSafeReleaseNULL(buf); - return kIOReturnNoMemory; - } - info->paddr = seg.fIOVMAddr; - info->vaddr = buf->getBytesNoCopy(); - info->buffer = buf; - info->dma_cmd = cmd; - - return kIOReturnSuccess; -} - -IOReturn IntelPreciseTouchStylusDriver::allocateDMAResources() -{ - IPTSBufferInfo *buffers = rx_buffer; - for (int i = 0; i < IPTS_BUFFER_NUM; i++) { - if (allocateDMAMemory(buffers+i, data_buffer_size) != kIOReturnSuccess) - goto release_resources; - } - - buffers = feedback_buffer; - for (int i = 0; i < IPTS_BUFFER_NUM; i++) { - if (allocateDMAMemory(buffers+i, feedback_buffer_size) != kIOReturnSuccess) - goto release_resources; - } - - if (allocateDMAMemory(&doorbell_buffer, sizeof(UInt32)) != kIOReturnSuccess || - allocateDMAMemory(&workqueue_buffer, sizeof(UInt32)) != kIOReturnSuccess || - allocateDMAMemory(&tx_buffer, feedback_buffer_size) != kIOReturnSuccess || - allocateDMAMemory(&report_desc_buffer, IPTS_REPORT_DESC_BUFFER_SIZE) != kIOReturnSuccess) - goto release_resources; - - return kIOReturnSuccess; -release_resources: - freeDMAResources(); - return kIOReturnNoMemory; -} - -void IntelPreciseTouchStylusDriver::freeDMAMemory(IPTSBufferInfo *info, bool keep_ref) { - info->dma_cmd->clearMemoryDescriptor(); - OSSafeReleaseNULL(info->dma_cmd); - info->buffer->complete(); - if (keep_ref) - info->buffer->release(); // maybe still hold by client, so needed when client wants to release them - else - OSSafeReleaseNULL(info->buffer); - info->vaddr = nullptr; - info->paddr = 0; -} - -void IntelPreciseTouchStylusDriver::freeDMAResources() -{ - IPTSBufferInfo *buffers = rx_buffer; - for (int i = 0; i < IPTS_BUFFER_NUM; i++) { - if (!buffers[i].vaddr) - continue; - freeDMAMemory(buffers+i, true); - } - buffers = feedback_buffer; - for (int i = 0; i < IPTS_BUFFER_NUM; i++) { - if (!buffers[i].vaddr) - continue; - freeDMAMemory(buffers+i); - } - - if (doorbell_buffer.vaddr) - freeDMAMemory(&doorbell_buffer); - if (workqueue_buffer.vaddr) - freeDMAMemory(&workqueue_buffer); - if (tx_buffer.vaddr) - freeDMAMemory(&tx_buffer); - if (report_desc_buffer.vaddr) - freeDMAMemory(&report_desc_buffer); -} diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.hpp b/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.hpp deleted file mode 100644 index 9056b6c..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusDriver.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// -// IntelPreciseTouchStylusDriver.hpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/5. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef IntelPreciseTouchStylusDriver_hpp -#define IntelPreciseTouchStylusDriver_hpp - -#include "SurfaceManagementEngineClient.hpp" -#include "IPTSProtocol.h" - -#define IPTS_BUSY_TIMEOUT 2 -#define IPTS_ACTIVE_TIMEOUT 5 -#define IPTS_IDLE_TIMEOUT 50 - -#define IPTS_REPORT_DESC_BUFFER_SIZE 0x460 - -enum IPTSDeviceState { - IPTSDeviceStateStarting, - IPTSDeviceStateStarted, - IPTSDeviceStateStopping, - IPTSDeviceStateStopped, -}; - -struct IPTSBufferInfo { - IOBufferMemoryDescriptor *buffer; - IODMACommand *dma_cmd; - void *vaddr; - IOPhysicalAddress paddr; -}; - -class SurfaceTouchScreenDevice; - -class EXPORT IntelPreciseTouchStylusDriver : public IOService { - OSDeclareDefaultStructors(IntelPreciseTouchStylusDriver); - -public: - IOService* probe(IOService* provider, SInt32* score) override; - - bool start(IOService* provider) override; - - void stop(IOService* provider) override; - - IOReturn setPowerState(unsigned long whichState, IOService *whatDevice) override; - - IOBufferMemoryDescriptor *getReceiveBufferForIndex(int idx); - - UInt16 getVendorID(); - UInt16 getDeviceID(); - UInt8 getMaxContacts(); - - IOReturn getCurrentInputBuffer(UInt8 *buffer_idx); - - void handleHIDReport(const IPTSHIDReport *report); - -private: - SurfaceManagementEngineClient* api {nullptr}; - - IOWorkLoop* work_loop {nullptr}; - IOCommandGate* command_gate {nullptr}; - IOCommandGate::Action wait_input {nullptr}; - IOInterruptEventSource* interrupt_source {nullptr}; - IOTimerEventSource* timer {nullptr}; - SurfaceTouchScreenDevice* touch_screen {nullptr}; - - IPTSDeviceState state {IPTSDeviceStateStopped}; - bool awake {true}; - bool touch_screen_started {false}; - bool busy {false}; - bool restart {false}; - bool wait {false}; - UInt32 current_doorbell {0}; - AbsoluteTime last_activate; - - UInt32 data_buffer_size {0}; - UInt32 feedback_buffer_size {0}; - IPTSTouchMode mode {IPTSMultitouch}; - IPTSHIDReport report_to_send; - bool sent {true}; - - IPTSBufferInfo rx_buffer[IPTS_BUFFER_NUM]; - IPTSBufferInfo feedback_buffer[IPTS_BUFFER_NUM]; - IPTSBufferInfo doorbell_buffer; - IPTSBufferInfo workqueue_buffer; - IPTSBufferInfo tx_buffer; - IPTSBufferInfo report_desc_buffer; - - void releaseResources(); - - void pollTouchData(IOTimerEventSource* sender); - - IOReturn startDevice(); - IOReturn restartDevice(); - IOReturn stopDevice(); - - IOReturn sendIPTSCommand(UInt32 code, UInt8 *data, UInt16 data_len, bool blocking = true); - IOReturn sendFeedback(UInt32 buffer, bool blocking = true); - IOReturn sendSetFeatureReport(UInt8 report_id, UInt8 value); - - IOReturn allocateDMAMemory(IPTSBufferInfo *info, UInt32 size); - IOReturn allocateDMAResources(); - void freeDMAMemory(IPTSBufferInfo *info, bool keep_ref = false); - void freeDMAResources(); - - void handleMessage(SurfaceManagementEngineClient *sender, UInt8 *msg, UInt16 msg_len); - bool isResponseError(IPTSResponse *rsp); - - IOReturn getCurrentInputBufferGated(UInt8 *buffer_idx); - void handleHIDReportGated(IOInterruptEventSource *sender, int count); -}; - -#endif /* IntelPreciseTouchStylusDriver_hpp */ diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.cpp b/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.cpp deleted file mode 100644 index 680cdb3..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.cpp +++ /dev/null @@ -1,127 +0,0 @@ -// -// IntelPreciseTouchStylusUserClient.cpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/11. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#include "IntelPreciseTouchStylusUserClient.hpp" - -#define super IOUserClient -OSDefineMetaClassAndStructors(IntelPreciseTouchStylusUserClient, IOUserClient); - -const IOExternalMethodDispatch IntelPreciseTouchStylusUserClient::methods[kNumberOfMethods] = { - [kMethodGetDeviceInfo] = { - .function = (IOExternalMethodAction)&IntelPreciseTouchStylusUserClient::sMethodGetDeviceInfo, - .checkScalarInputCount = 0, - .checkStructureInputSize = 0, - .checkScalarOutputCount = 0, - .checkStructureOutputSize = sizeof(IPTSDeviceInfo), - }, - [kMethodReceiveInput] = { - .function = (IOExternalMethodAction)&IntelPreciseTouchStylusUserClient::sMethodReceiveInput, - .checkScalarInputCount = 0, - .checkStructureInputSize = 0, - .checkScalarOutputCount = 1, // rx buffer index - .checkStructureOutputSize = 0, - }, - [kMethodSendHIDReport] = { - .function = (IOExternalMethodAction)&IntelPreciseTouchStylusUserClient::sMethodSendHIDReport, - .checkScalarInputCount = 0, - .checkStructureInputSize = sizeof(IPTSHIDReport), - .checkScalarOutputCount = 0, - .checkStructureOutputSize = 0, - }, -}; - -IOReturn IntelPreciseTouchStylusUserClient::externalMethod(uint32_t selector, IOExternalMethodArguments *arguments, IOExternalMethodDispatch *dispatch, OSObject *target, void *reference) { - if (selector < kNumberOfMethods) { - dispatch = const_cast(&methods[selector]); - if (!target) - target = this; - } - return super::externalMethod(selector, arguments, dispatch, target, reference); -} - -IOReturn IntelPreciseTouchStylusUserClient::clientMemoryForType(UInt32 type, IOOptionBits *options, IOMemoryDescriptor **memory) { - if (type >= IPTS_BUFFER_NUM) - return kIOReturnBadArgument; - - *memory = driver->getReceiveBufferForIndex(type); - *options |= kIOMapReadOnly; - return kIOReturnSuccess; -} - -bool IntelPreciseTouchStylusUserClient::initWithTask(task_t owningTask, void *securityToken, UInt32 type, OSDictionary *properties) { - if (!owningTask) - return false; - if (!super::initWithTask(owningTask, securityToken, type)) - return false; - - task = owningTask; - return true; -} - -bool IntelPreciseTouchStylusUserClient::start(IOService *provider) { - if (!super::start(provider)) - return false; - - driver = OSDynamicCast(IntelPreciseTouchStylusDriver, provider); - if (!driver) - return false; - - return true; -} - -void IntelPreciseTouchStylusUserClient::stop(IOService* provider) { - super::stop(provider); -} - -IOReturn IntelPreciseTouchStylusUserClient::clientClose(void) { - if (!isInactive()) - terminate(); - return kIOReturnSuccess; -} - -IOReturn IntelPreciseTouchStylusUserClient::sMethodGetDeviceInfo(OSObject *target, void *ref, IOExternalMethodArguments *args) { - IntelPreciseTouchStylusUserClient *that = OSDynamicCast(IntelPreciseTouchStylusUserClient, target); - if (!that) - return kIOReturnError; - return that->getDeviceInfo(ref, args); -} - -IOReturn IntelPreciseTouchStylusUserClient::getDeviceInfo(void *ref, IOExternalMethodArguments *args) { - IPTSDeviceInfo *info = reinterpret_cast(args->structureOutput); - info->vendor_id = driver->getVendorID(); - info->product_id = driver->getDeviceID(); - info->max_contacts = driver->getMaxContacts(); - return kIOReturnSuccess; -} - -IOReturn IntelPreciseTouchStylusUserClient::sMethodReceiveInput(OSObject *target, void *ref, IOExternalMethodArguments *args) { - IntelPreciseTouchStylusUserClient *that = OSDynamicCast(IntelPreciseTouchStylusUserClient, target); - if (!that) - return kIOReturnError; - return that->receiveInput(ref, args); -} - -IOReturn IntelPreciseTouchStylusUserClient::receiveInput(void *ref, IOExternalMethodArguments *args) { - UInt8 buffer_idx; - if (driver->getCurrentInputBuffer(&buffer_idx) != kIOReturnSuccess) - return kIOReturnError; - args->scalarOutput[0] = buffer_idx; - return kIOReturnSuccess; -} - -IOReturn IntelPreciseTouchStylusUserClient::sMethodSendHIDReport(OSObject *target, void *ref, IOExternalMethodArguments *args) { - IntelPreciseTouchStylusUserClient *that = OSDynamicCast(IntelPreciseTouchStylusUserClient, target); - if (!that) - return kIOReturnError; - return that->sendHIDReport(ref, args); -} - -IOReturn IntelPreciseTouchStylusUserClient::sendHIDReport(void *ref, IOExternalMethodArguments *args) { - driver->handleHIDReport(reinterpret_cast(args->structureInput)); - return kIOReturnSuccess; -} diff --git a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.hpp b/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.hpp deleted file mode 100644 index 5f839cf..0000000 --- a/BigSurface/BigSurface/SurfaceTouchScreen/IntelPreciseTouchStylusUserClient.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// -// IntelPreciseTouchStylusUserClient.hpp -// SurfaceTouchScreen -// -// Created by Xavier on 2022/6/11. -// Copyright © 2022 Xia Shangning. All rights reserved. -// - -#ifndef IntelPreciseTouchStylusUserClient_hpp -#define IntelPreciseTouchStylusUserClient_hpp - -#include -#include - -#include "IntelPreciseTouchStylusDriver.hpp" - -class EXPORT IntelPreciseTouchStylusUserClient : public IOUserClient { - OSDeclareDefaultStructors(IntelPreciseTouchStylusUserClient); - -public: - void stop(IOService* provider) override; - bool start(IOService* provider) override; - - bool initWithTask(task_t owningTask, void* securityToken, UInt32 type, OSDictionary* properties) override; - - IOReturn clientClose(void) override; - - IOReturn externalMethod(uint32_t selector, IOExternalMethodArguments* arguments, IOExternalMethodDispatch* dispatch, OSObject* target, void* reference) override; - - IOReturn clientMemoryForType(UInt32 type, IOOptionBits* options, IOMemoryDescriptor** memory) override; - -private: - static const IOExternalMethodDispatch methods[kNumberOfMethods]; - IntelPreciseTouchStylusDriver* driver {nullptr}; - task_t task {nullptr}; - - static IOReturn sMethodGetDeviceInfo(OSObject *target, void *ref, IOExternalMethodArguments *args); - static IOReturn sMethodReceiveInput(OSObject *target, void *ref, IOExternalMethodArguments *args); - static IOReturn sMethodSendHIDReport(OSObject *target, void *ref, IOExternalMethodArguments *args); - - IOReturn getDeviceInfo(void *ref, IOExternalMethodArguments* args); - IOReturn receiveInput(void *ref, IOExternalMethodArguments* args); - IOReturn sendHIDReport(void *ref, IOExternalMethodArguments* args); -}; - -#endif /* IntelPreciseTouchStylusUserClient_hpp */ diff --git a/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.cpp b/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.cpp deleted file mode 100644 index aa29c76..0000000 --- a/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.cpp +++ /dev/null @@ -1,278 +0,0 @@ -// -// SurfaceTypeCoverDriver.hpp -// SurfaceTypeCover -// -// Created by Xavier on 21/04/2021. -// Copyright © 2021 Xia Shangning. All rights reserved. -// - -#include "SurfaceTypeCoverDriver.hpp" - -#include - -// constants for processing the special key input event -#define kHIDIncrVolume 0x01 -#define kHIDDecrVolume 0x02 -#define kHIDMute 0x04 - -#define super VoodooI2CPrecisionTouchpadHIDEventDriver -OSDefineMetaClassAndStructors(SurfaceTypeCoverDriver, VoodooI2CPrecisionTouchpadHIDEventDriver); - -void SurfaceTypeCoverDriver::handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor *report, IOHIDReportType report_type, UInt32 report_id) { - if (!ready) - return; - - super::handleInterruptReport(timestamp, report, report_type, report_id); - - handleKeyboardReport(timestamp, report_id); -} - -void SurfaceTypeCoverDriver::handleKeyboardReport(AbsoluteTime timeStamp, UInt32 reportID) { - UInt32 volumeHandled = 0; - UInt32 volumeState = 0; - UInt32 index, count; - - if(!keyboard.elements) - return; - - for (index=0, count=keyboard.elements->getCount(); indexgetObject(index)); - if (!element) - continue; - - if (element->getReportID() != reportID) - continue; - - elementTimeStamp = element->getTimeStamp(); - if (CMP_ABSOLUTETIME(&timeStamp, &elementTimeStamp) != 0) - continue; - - preValue = element->getValue(kIOHIDValueOptionsFlagPrevious) != 0; - value = element->getValue() != 0; - - if (value == preValue) - continue; - - usagePage = element->getUsagePage(); - usage = element->getUsage(); - - if (usagePage == kHIDPage_Consumer) { - bool suppress = true; - switch (usage) { - case kHIDUsage_Csmr_VolumeIncrement: - volumeHandled |= kHIDIncrVolume; - volumeState |= (value) ? kHIDIncrVolume:0; - break; - case kHIDUsage_Csmr_VolumeDecrement: - volumeHandled |= kHIDDecrVolume; - volumeState |= (value) ? kHIDDecrVolume:0; - break; - case kHIDUsage_Csmr_Mute: - volumeHandled |= kHIDMute; - volumeState |= (value) ? kHIDMute:0; - break; - default: - suppress = false; - break; - } - - if (suppress) - continue; - } - - dispatchKeyboardEvent(timeStamp, usagePage, usage, value); - } - - // RY: Handle the case where Vol Increment, Decrement, and Mute are all down - // If such an event occurs, it is likely that the device is defective, - // and should be ignored. - if ((volumeState != (kHIDIncrVolume|kHIDDecrVolume|kHIDMute)) && - (volumeHandled != (kHIDIncrVolume|kHIDDecrVolume|kHIDMute))) { - // Volume Increment - if (volumeHandled & kHIDIncrVolume) - dispatchKeyboardEvent(timeStamp, kHIDPage_Consumer, kHIDUsage_Csmr_VolumeIncrement, ((volumeState & kHIDIncrVolume) != 0)); - // Volume Decrement - if (volumeHandled & kHIDDecrVolume) - dispatchKeyboardEvent(timeStamp, kHIDPage_Consumer, kHIDUsage_Csmr_VolumeDecrement, ((volumeState & kHIDDecrVolume) != 0)); - // Volume Mute - if (volumeHandled & kHIDMute) - dispatchKeyboardEvent(timeStamp, kHIDPage_Consumer, kHIDUsage_Csmr_Mute, ((volumeState & kHIDMute) != 0)); - } -} - -bool SurfaceTypeCoverDriver::handleStart(IOService* provider) { - if (!super::handleStart(provider)) - return false; - - setKeyboardProperties(); - - return true; -} - -IOReturn SurfaceTypeCoverDriver::parseElements() { - IOReturn ret = super::parseElements(); - - if(ret != kIOReturnSuccess) - return ret; - - //Keyboard : Loop through all createMatchingElements() and parse KeyboardElements - OSArray *elementArray = hid_interface->createMatchingElements(); - keyboard.appleVendorSupported = getProperty(kIOHIDAppleVendorSupported, gIOServicePlane); - if (elementArray) { - for (int i=0, count=elementArray->getCount(); igetObject(i)); - if (!element) - continue; - - if (element->getType() == kIOHIDElementTypeCollection) - continue; - - if (element->getUsage() == 0) - continue; - - if (parseKeyboardElement(element)) - continue; - } - } - OSSafeReleaseNULL(elementArray); - - return kIOReturnSuccess; -} - -bool SurfaceTypeCoverDriver::parseKeyboardElement(IOHIDElement * element) { - UInt32 usagePage = element->getUsagePage(); - UInt32 usage = element->getUsage(); - bool store = false; - - if (!keyboard.elements) { - keyboard.elements = OSArray::withCapacity(4); - if(!keyboard.elements) - goto exit; - } - - switch (usagePage) { - case kHIDPage_GenericDesktop: - switch (usage) { - case kHIDUsage_GD_Start: - case kHIDUsage_GD_Select: - case kHIDUsage_GD_SystemPowerDown: - case kHIDUsage_GD_SystemSleep: - case kHIDUsage_GD_SystemWakeUp: - case kHIDUsage_GD_SystemContextMenu: - case kHIDUsage_GD_SystemMainMenu: - case kHIDUsage_GD_SystemAppMenu: - case kHIDUsage_GD_SystemMenuHelp: - case kHIDUsage_GD_SystemMenuExit: - case kHIDUsage_GD_SystemMenuSelect: - case kHIDUsage_GD_SystemMenuRight: - case kHIDUsage_GD_SystemMenuLeft: - case kHIDUsage_GD_SystemMenuUp: - case kHIDUsage_GD_SystemMenuDown: - case kHIDUsage_GD_DPadUp: - case kHIDUsage_GD_DPadDown: - case kHIDUsage_GD_DPadRight: - case kHIDUsage_GD_DPadLeft: - store = true; - break; - } - break; - case kHIDPage_KeyboardOrKeypad: - if ((usage < kHIDUsage_KeyboardA) || (usage > kHIDUsage_KeyboardRightGUI)) - break; - - // This usage is used to let the OS know if a keyboard is in an enabled state where - // user input is possible - - if (usage == kHIDUsage_KeyboardPower) { - OSDictionary* kbEnableEventProps = NULL; - UInt32 value = 0; - - // To avoid problems with un-intentional clearing of the flag - // we require this report to be a feature report so that the current - // state can be polled if necessary - - if (element->getType() == kIOHIDElementTypeFeature) { - value = element->getValue(kIOHIDValueOptionsUpdateElementValues); - - kbEnableEventProps = OSDictionary::withCapacity(3); - if (!kbEnableEventProps) - break; - OSSafeReleaseNULL(kbEnableEventProps); - } - - store = true; - break; - } - case kHIDPage_Consumer: - if (usage == kHIDUsage_Csmr_ACKeyboardLayoutSelect) - setProperty(kIOHIDSupportsGlobeKeyKey, kOSBooleanTrue); - case kHIDPage_Telephony: - store = true; - break; - case kHIDPage_AppleVendorTopCase: - if (keyboard.appleVendorSupported) { - switch (usage) { - case kHIDUsage_AV_TopCase_BrightnessDown: - case kHIDUsage_AV_TopCase_BrightnessUp: - case kHIDUsage_AV_TopCase_IlluminationDown: - case kHIDUsage_AV_TopCase_IlluminationUp: - case kHIDUsage_AV_TopCase_KeyboardFn: - store = true; - break; - } - } - break; - case kHIDPage_AppleVendorKeyboard: - if (keyboard.appleVendorSupported) { - switch (usage) { - case kHIDUsage_AppleVendorKeyboard_Spotlight: - case kHIDUsage_AppleVendorKeyboard_Dashboard: - case kHIDUsage_AppleVendorKeyboard_Function: - case kHIDUsage_AppleVendorKeyboard_Launchpad: - case kHIDUsage_AppleVendorKeyboard_Reserved: - case kHIDUsage_AppleVendorKeyboard_CapsLockDelayEnable: - case kHIDUsage_AppleVendorKeyboard_PowerState: - case kHIDUsage_AppleVendorKeyboard_Expose_All: - case kHIDUsage_AppleVendorKeyboard_Expose_Desktop: - case kHIDUsage_AppleVendorKeyboard_Brightness_Up: - case kHIDUsage_AppleVendorKeyboard_Brightness_Down: - case kHIDUsage_AppleVendorKeyboard_Language: - store = true; - break; - } - } - break; - } - - if(!store) - goto exit; - - keyboard.elements->setObject(element); - -exit: - return store; -} - -void SurfaceTypeCoverDriver::setKeyboardProperties() -{ - OSDictionary *properties = OSDictionary::withCapacity(4); - - if (!properties) - return; - - if (!keyboard.elements) { - OSSafeReleaseNULL(properties); - return; - } - - properties->setObject(kIOHIDElementKey, keyboard.elements); - setProperty("Keyboard", properties); - - OSSafeReleaseNULL(properties); -} diff --git a/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.hpp b/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.hpp deleted file mode 100644 index eaddaf6..0000000 --- a/BigSurface/BigSurface/SurfaceTypeCover/SurfaceTypeCoverDriver.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// -// SurfaceTypeCoverDriver.hpp -// SurfaceTypeCover -// -// Created by Xavier on 21/04/2021. -// Copyright © 2021 Xia Shangning. All rights reserved. -// - -#ifndef SurfaceTypeCoverDriver_hpp -#define SurfaceTypeCoverDriver_hpp - -#include -#include -#include -#include - -#include "VoodooI2CPrecisionTouchpadHIDEventDriver.hpp" - -/* - * Merged code for Surface Type Cover - * Support keyboard & touchpad at the same time - */ - -class EXPORT SurfaceTypeCoverDriver : public VoodooI2CPrecisionTouchpadHIDEventDriver { - OSDeclareDefaultStructors(SurfaceTypeCoverDriver); - - public: - struct { - OSArray * elements; - UInt8 bootMouseData[4]; - bool appleVendorSupported; - } keyboard; - - /* @inherit */ - - void handleInterruptReport(AbsoluteTime timestamp, IOMemoryDescriptor *report, IOHIDReportType report_type, UInt32 report_id) override; - - /* @inherit */ - - bool handleStart(IOService* provider) override; - - /* @inherit */ - - IOReturn parseElements() override; - - /* Called during the interrupt routine to interate over keyboard events - * @timestamp The timestamp of the interrupt report - * @report_id The report ID of the interrupt report - */ - - void handleKeyboardReport(AbsoluteTime timeStamp, UInt32 reportID); - - /* Parses a keyboard usage page element - * @element The element to parse - * - * This function is reponsible for examining the child elements of a digitser elements to determine the - * capabilities of the keyboard. - * - * @return *true* on successful parse, *false* otherwise - */ - - bool parseKeyboardElement(IOHIDElement* element); - - void setKeyboardProperties(); -}; - - -#endif /* SurfaceTypeCoverDriver_hpp */ diff --git a/Dependencies/BigSurfaceHIDDriver b/Dependencies/BigSurfaceHIDDriver new file mode 160000 index 0000000..8ddbf76 --- /dev/null +++ b/Dependencies/BigSurfaceHIDDriver @@ -0,0 +1 @@ +Subproject commit 8ddbf760a75965c81dc64d46b1fa5a684b117f82 diff --git a/Dependencies/VoodooGPIO b/Dependencies/VoodooGPIO index 64688fb..d9bf9fd 160000 --- a/Dependencies/VoodooGPIO +++ b/Dependencies/VoodooGPIO @@ -1 +1 @@ -Subproject commit 64688fb821fd58d23f1bddf45179d1f54e813597 +Subproject commit d9bf9fdd15c32004c21df6090cc58e868b279dab diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.pbxproj b/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.pbxproj deleted file mode 100644 index 18e12cc..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.pbxproj +++ /dev/null @@ -1,364 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 0F96EB85258D41AF0062E8FD /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F96EB81258D3F8F0062E8FD /* libkmod.a */; }; - AC2049841F8AE9DA00BEC53C /* VoodooI2CLogger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC2049821F8AE9DA00BEC53C /* VoodooI2CLogger.cpp */; }; - AC2049851F8AE9DA00BEC53C /* VoodooI2CLogger.hpp in Headers */ = {isa = PBXBuildFile; fileRef = AC2049831F8AE9DA00BEC53C /* VoodooI2CLogger.hpp */; }; - AC2DC73B1F7F0E7A0071CDCA /* VoodooI2CServices.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC2DC7391F7F0E7A0071CDCA /* VoodooI2CServices.cpp */; }; - AC2DC73C1F7F0E7A0071CDCA /* VoodooI2CServices.hpp in Headers */ = {isa = PBXBuildFile; fileRef = AC2DC73A1F7F0E7A0071CDCA /* VoodooI2CServices.hpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 0F96EB81258D3F8F0062E8FD /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = ../../MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = ""; }; - AC2049821F8AE9DA00BEC53C /* VoodooI2CLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CLogger.cpp; sourceTree = ""; }; - AC2049831F8AE9DA00BEC53C /* VoodooI2CLogger.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CLogger.hpp; sourceTree = ""; }; - AC2DC71C1F7F0D450071CDCA /* VoodooI2CServices.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoodooI2CServices.kext; sourceTree = BUILT_PRODUCTS_DIR; }; - AC2DC7231F7F0D450071CDCA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - AC2DC7391F7F0E7A0071CDCA /* VoodooI2CServices.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoodooI2CServices.cpp; sourceTree = ""; }; - AC2DC73A1F7F0E7A0071CDCA /* VoodooI2CServices.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoodooI2CServices.hpp; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - AC2DC7181F7F0D450071CDCA /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 0F96EB85258D41AF0062E8FD /* libkmod.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 0F96EB80258D3F8F0062E8FD /* Frameworks */ = { - isa = PBXGroup; - children = ( - 0F96EB81258D3F8F0062E8FD /* libkmod.a */, - ); - name = Frameworks; - sourceTree = ""; - }; - AC2DC7121F7F0D450071CDCA = { - isa = PBXGroup; - children = ( - AC2DC71E1F7F0D450071CDCA /* VoodooI2CServices */, - AC2DC71D1F7F0D450071CDCA /* Products */, - 0F96EB80258D3F8F0062E8FD /* Frameworks */, - ); - sourceTree = ""; - }; - AC2DC71D1F7F0D450071CDCA /* Products */ = { - isa = PBXGroup; - children = ( - AC2DC71C1F7F0D450071CDCA /* VoodooI2CServices.kext */, - ); - name = Products; - sourceTree = ""; - }; - AC2DC71E1F7F0D450071CDCA /* VoodooI2CServices */ = { - isa = PBXGroup; - children = ( - AC2DC7391F7F0E7A0071CDCA /* VoodooI2CServices.cpp */, - AC2DC73A1F7F0E7A0071CDCA /* VoodooI2CServices.hpp */, - AC2049821F8AE9DA00BEC53C /* VoodooI2CLogger.cpp */, - AC2049831F8AE9DA00BEC53C /* VoodooI2CLogger.hpp */, - AC2DC7231F7F0D450071CDCA /* Info.plist */, - ); - path = VoodooI2CServices; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - AC2DC7191F7F0D450071CDCA /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - AC2DC73C1F7F0E7A0071CDCA /* VoodooI2CServices.hpp in Headers */, - AC2049851F8AE9DA00BEC53C /* VoodooI2CLogger.hpp in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - AC2DC71B1F7F0D450071CDCA /* VoodooI2CServices */ = { - isa = PBXNativeTarget; - buildConfigurationList = AC2DC7261F7F0D450071CDCA /* Build configuration list for PBXNativeTarget "VoodooI2CServices" */; - buildPhases = ( - AC2DC7171F7F0D450071CDCA /* Sources */, - AC2DC7181F7F0D450071CDCA /* Frameworks */, - AC2DC7191F7F0D450071CDCA /* Headers */, - AC2DC71A1F7F0D450071CDCA /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = VoodooI2CServices; - productName = VoodooI2CServices; - productReference = AC2DC71C1F7F0D450071CDCA /* VoodooI2CServices.kext */; - productType = "com.apple.product-type.kernel-extension"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - AC2DC7131F7F0D450071CDCA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1250; - ORGANIZATIONNAME = "Alexandre Daoud"; - TargetAttributes = { - AC2DC71B1F7F0D450071CDCA = { - CreatedOnToolsVersion = 8.0; - DevelopmentTeam = K8RXBXZGN4; - ProvisioningStyle = Manual; - }; - }; - }; - buildConfigurationList = AC2DC7161F7F0D450071CDCA /* Build configuration list for PBXProject "VoodooI2CServices" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = AC2DC7121F7F0D450071CDCA; - productRefGroup = AC2DC71D1F7F0D450071CDCA /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - AC2DC71B1F7F0D450071CDCA /* VoodooI2CServices */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - AC2DC71A1F7F0D450071CDCA /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - AC2DC7171F7F0D450071CDCA /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - AC2049841F8AE9DA00BEC53C /* VoodooI2CLogger.cpp in Sources */, - AC2DC73B1F7F0E7A0071CDCA /* VoodooI2CServices.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - AC2DC7241F7F0D450071CDCA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = x86_64; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../../MacKernelSDK/Headers"; - KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/../../MacKernelSDK/Headers"; - MACOSX_DEPLOYMENT_TARGET = 10.15; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - AC2DC7251F7F0D450071CDCA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = x86_64; - CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_SUSPICIOUS_MOVES = YES; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = fast; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../../MacKernelSDK/Headers"; - KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/../../MacKernelSDK/Headers"; - MACOSX_DEPLOYMENT_TARGET = 10.15; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - }; - name = Release; - }; - AC2DC7271F7F0D450071CDCA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_ANALYZER_DEADCODE_DEADSTORES = NO; - CLANG_ANALYZER_DIVIDE_BY_ZERO = NO; - CLANG_ANALYZER_NULL_DEREFERENCE = NO; - CLANG_WARN_DOCUMENTATION_COMMENTS = NO; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Manual; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.0; - DEVELOPMENT_TEAM = K8RXBXZGN4; - ENABLE_HARDENED_RUNTIME = YES; - INFOPLIST_FILE = VoodooI2CServices/Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/../../MacKernelSDK/Library/x86_64", - ); - MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0; - MODULE_NAME = com.alexandred.VoodooI2CServices; - MODULE_VERSION = 1.0; - "OTHER_CPLUSPLUSFLAGS[arch=*]" = "-Wno-inconsistent-missing-override"; - PRODUCT_BUNDLE_IDENTIFIER = com.alexandred.VoodooI2CServices; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - RUN_CLANG_STATIC_ANALYZER = YES; - WRAPPER_EXTENSION = kext; - }; - name = Debug; - }; - AC2DC7281F7F0D450071CDCA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_WARN_DOCUMENTATION_COMMENTS = NO; - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Manual; - COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1.0; - DEVELOPMENT_TEAM = K8RXBXZGN4; - ENABLE_HARDENED_RUNTIME = YES; - INFOPLIST_FILE = VoodooI2CServices/Info.plist; - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/../../MacKernelSDK/Library/x86_64", - ); - MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0; - MODULE_NAME = com.alexandred.VoodooI2CServices; - MODULE_VERSION = 1.0; - "OTHER_CPLUSPLUSFLAGS[arch=*]" = "-Wno-inconsistent-missing-override"; - PRODUCT_BUNDLE_IDENTIFIER = com.alexandred.VoodooI2CServices; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - WRAPPER_EXTENSION = kext; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - AC2DC7161F7F0D450071CDCA /* Build configuration list for PBXProject "VoodooI2CServices" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AC2DC7241F7F0D450071CDCA /* Debug */, - AC2DC7251F7F0D450071CDCA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - AC2DC7261F7F0D450071CDCA /* Build configuration list for PBXNativeTarget "VoodooI2CServices" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - AC2DC7271F7F0D450071CDCA /* Debug */, - AC2DC7281F7F0D450071CDCA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = AC2DC7131F7F0D450071CDCA /* Project object */; -} diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/xcshareddata/xcschemes/VoodooI2CServices.xcscheme b/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/xcshareddata/xcschemes/VoodooI2CServices.xcscheme deleted file mode 100644 index 914eeaf..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices.xcodeproj/xcshareddata/xcschemes/VoodooI2CServices.xcscheme +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices/Info.plist b/Dependencies/VoodooI2CServices/VoodooI2CServices/Info.plist deleted file mode 100644 index 490954d..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices/Info.plist +++ /dev/null @@ -1,60 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - KEXT - CFBundleShortVersionString - $(MARKETING_VERSION) - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - IOKitPersonalities - - VoodooI2CLogger - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - VoodooI2CLogger - IOMatchCategory - VoodooI2CLogger - IOProviderClass - VoodooI2CServices - - VoodooI2CServices - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - IOClass - VoodooI2CServices - IOMatchCategory - VoodooI2CServices - IOProviderClass - IOResources - - - NSHumanReadableCopyright - Copyright © 2017 Alexandre Daoud. All rights reserved. - OSBundleCompatibleVersion - 1.0.0 - OSBundleLibraries - - com.apple.kpi.iokit - 14 - com.apple.kpi.libkern - 14 - - OSBundleRequired - Root - - diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.cpp b/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.cpp deleted file mode 100644 index e28d40e..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -// VoodooI2CLogger.cpp -// VoodooI2CServices -// -// Created by Alexandre on 09/10/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CLogger.hpp" -#include "VoodooI2CServices.hpp" - -#define super IOService -OSDefineMetaClassAndStructors(VoodooI2CLogger, IOService); - -bool VoodooI2CLogger::start(IOService* provider) { - if (!super::start(provider)) - return false; - - UInt8 argument; - - if (PE_parse_boot_argn("voodooi2c-logging-level", &argument, sizeof(argument))) { - if (argument >= 0 && argument <= 2) { - logging_level = argument; - } else { - logging_level = kVoodooI2CNormalLogging; - } - } else { - logging_level = kVoodooI2CNormalLogging; - } - - if (!logging_level) - return false; - - attachToParent(provider, VoodooI2CServices::gVoodooI2CPlane); - - return true; -} - -void VoodooI2CLogger::stop(IOService *provider) { - detachFromChild(provider, VoodooI2CServices::gVoodooI2CPlane); - super::stop(provider); -} diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.hpp b/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.hpp deleted file mode 100644 index cae1803..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CLogger.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// -// VoodooI2CLogger.hpp -// VoodooI2CServices -// -// Created by Alexandre on 09/10/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CLogger_hpp -#define VoodooI2CLogger_hpp - -#include -#include -#include - -#define kVoodooI2CSilentLogging 0 -#define kVoodooI2CNormalLogging 1 -#define kVoodooI2CDebugLogging 2 - -class VoodooI2CLogger : public IOService { - OSDeclareDefaultStructors(VoodooI2CLogger); - - public: - bool start(IOService* provider); - void stop(IOService* provider); - - protected: - private: - UInt8 logging_level = kVoodooI2CNormalLogging; -}; - - -#endif /* VoodooI2CLogger_hpp */ diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.cpp b/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.cpp deleted file mode 100644 index fc450b1..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -// VoodooI2CServices.cpp -// VoodooI2CServices -// -// Created by Alexandre on 30/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#include "VoodooI2CServices.hpp" - -const IORegistryPlane* VoodooI2CServices::gVoodooI2CPlane = NULL; - -#define super IOService -OSDefineMetaClassAndStructors(VoodooI2CServices, IOService); - -bool VoodooI2CServices::attachDevice(void* target, void* ref_con, IOService* new_service, IONotifier* notifier) { - OSBoolean* bool_obj = OSDynamicCast(OSBoolean, new_service->getProperty("isI2CController")); - if (bool_obj && bool_obj->isTrue()) { - new_service->attachToParent(getRegistryRoot(), gVoodooI2CPlane); - } else { - IORegistryEntry* parent = new_service->getParentEntry(gIOServicePlane); - new_service->attachToParent(parent, gVoodooI2CPlane); - } - - return true; -} - -bool VoodooI2CServices::detachDevice(void* target, void* ref_con, IOService* new_service, IONotifier* notifier) { - IORegistryEntry* parent = new_service->getParentEntry(gVoodooI2CPlane); - new_service->detachFromParent(parent, gVoodooI2CPlane); - return true; -} - -bool VoodooI2CServices::start(IOService* provider) { - if (!super::start(provider)) - return false; - - gVoodooI2CPlane = IORegistryEntry::makePlane(kVoodooI2CPlane); - - attachToParent(getRegistryRoot(), gVoodooI2CPlane); - - OSDictionary* property_match = OSDictionary::withCapacity(1); - OSDictionary* service_match = OSDictionary::withCapacity(1); - - service_match->setObject("VoodooI2CServices Supported", kOSBooleanTrue); - property_match->setObject(gIOPropertyMatchKey, service_match); - - device_matcher = addMatchingNotification(gIOMatchedNotification, property_match, VoodooI2CServices::attachDevice, this, NULL, 0); - terminate_matcher = addMatchingNotification(gIOTerminatedNotification, property_match, VoodooI2CServices::detachDevice, this, NULL, 0); - - service_match->release(); - property_match->release(); - - registerService(); - - return true; -} - -void VoodooI2CServices::stop(IOService* provider) { - device_matcher->remove(); - terminate_matcher->remove(); - - OSSafeReleaseNULL(device_matcher); - OSSafeReleaseNULL(terminate_matcher); - - detachFromParent(getRegistryRoot(), gVoodooI2CPlane); - - super::stop(provider); -} diff --git a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.hpp b/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.hpp deleted file mode 100644 index 4fcf45b..0000000 --- a/Dependencies/VoodooI2CServices/VoodooI2CServices/VoodooI2CServices.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// -// VoodooI2CServices.hpp -// VoodooI2CServices -// -// Created by Alexandre on 30/09/2017. -// Copyright © 2017 Alexandre Daoud. All rights reserved. -// - -#ifndef VoodooI2CServices_hpp -#define VoodooI2CServices_hpp - -#include -#include -#include - -#define kVoodooI2CPlane "VoodooI2C" - -/* Provides various services to all VoodooI2C related classes. */ -class VoodooI2CServices : public IOService { - OSDeclareDefaultStructors(VoodooI2CServices); - - public: - static const IORegistryPlane* gVoodooI2CPlane; - - /* Starts the services kext - * @provider IOResources - * - * This function is responsible for initialising the VoodooI2C plane and the logger. - * @return *true* on successful start, *false* otherwise - */ - - bool start(IOService* provider); - - /* Stops the services kext - * @provider IOResources - */ - - void stop(IOService* provider); - - protected: - private: - IONotifier* device_matcher; - IONotifier* terminate_matcher; - - /* Called to attach a VoodooI2C related service into the VoodooI2C plane - * @target The VoodooI2CServices instance - * @ref_con A reference constant - * @new_service The service to be attached - * @notifier The IONotifier listening for matching services - * - * will always be a VoodooI2C class with the "VoodooI2CServices Supported" property set to *true* - * - * @return *true* on successful attach, *false* otherwise - */ - - static bool attachDevice(void* target, void* ref_con, IOService* new_service, IONotifier* notifier); - - /* Called to detach a VoodooI2C related service from the VoodooI2C plane - * @target The VoodooI2CServices instance - * @ref_con A reference constant - * @new_service The service to be detached - * @notifier The IONotifier listening for terminating services - * - * will always be a VoodooI2C class with the "VoodooI2CServices Supported" property set to *true* - * - * @return *true* on successful detach, *false* otherwise - */ - static bool detachDevice(void* target, void* ref_con, IOService* new_service, IONotifier* notifier); -}; - - -#endif /* VoodooI2CServices_hpp */ diff --git a/Dependencies/VoodooInput b/Dependencies/VoodooInput index d6558f8..6ce7ef3 160000 --- a/Dependencies/VoodooInput +++ b/Dependencies/VoodooInput @@ -1 +1 @@ -Subproject commit d6558f80546281e69b9bb02d8ccb642ccf6ff23d +Subproject commit 6ce7ef35b3d2161733552377abcdbe7d84834c27 diff --git a/Dependencies/VoodooSerial b/Dependencies/VoodooSerial index dfbaff1..080475b 160000 --- a/Dependencies/VoodooSerial +++ b/Dependencies/VoodooSerial @@ -1 +1 @@ -Subproject commit dfbaff1874f56bab67fe3fe2319b483dcef7da2f +Subproject commit 080475b163ea758c30642829af6c7a15eba792de diff --git a/MacKernelSDK b/MacKernelSDK index 39336fd..c41d877 160000 --- a/MacKernelSDK +++ b/MacKernelSDK @@ -1 +1 @@ -Subproject commit 39336fd35fc3721733de156e7437b3fd27949a3a +Subproject commit c41d877b64e7fd916bd271390bcdf30f7deb7b7a