diff --git a/VoodooI2CSynaptics/Info.plist b/VoodooI2CSynaptics/Info.plist
index 66d9b5f..07673d1 100644
--- a/VoodooI2CSynaptics/Info.plist
+++ b/VoodooI2CSynaptics/Info.plist
@@ -18,25 +18,29 @@
1.0
CFBundleVersion
1
- IOKitPersonalities
-
- VoodooI2CHIDDevice
-
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- IOClass
- VoodooI2CSynapticsDevice
- IOProbeScore
- 400
- IOPropertyMatch
-
- name
- SYNA2B33
-
- IOProviderClass
- VoodooI2CDeviceNub
-
-
+ IOKitPersonalities
+
+ VoodooI2CHIDDevice
+
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ IOClass
+ VoodooI2CSynapticsDevice
+ IOProbeScore
+ 400
+ IOPropertyMatch
+
+ name
+ SYNA2B52
+
+ IOProviderClass
+ VoodooI2CDeviceNub
+ RM,deliverNotifications
+
+ QuietTimeAfterTyping
+ 500
+
+
NSHumanReadableCopyright
Copyright © 2017 Alexandre Daoud. All rights reserved.
CFBundleSpokenName
diff --git a/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.cpp b/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.cpp
index 817851f..b969e2e 100644
--- a/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.cpp
+++ b/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.cpp
@@ -209,6 +209,12 @@ bool VoodooI2CSynapticsDevice::start(IOService* api) {
if (!super::start(api))
return false;
+ // Read QuietTimeAfterTyping configuration value (if available)
+ OSNumber* quietTimeAfterTyping = OSDynamicCast(OSNumber, getProperty("QuietTimeAfterTyping"));
+ if (quietTimeAfterTyping != NULL)
+ maxaftertyping = quietTimeAfterTyping->unsigned64BitValue() * 1000000; // Convert to nanoseconds
+
+
reading = true;
work_loop = getWorkLoop();
@@ -253,10 +259,10 @@ bool VoodooI2CSynapticsDevice::start(IOService* api) {
setProperty("VoodooI2CServices Supported", OSBoolean::withBoolean(true));
publish_multitouch_interface();
+ registerService();
reading = false;
-
return true;
exit:
releaseResources();
@@ -1007,6 +1013,15 @@ void VoodooI2CSynapticsDevice::interruptOccured(OSObject* owner, IOInterruptEven
}
void VoodooI2CSynapticsDevice::get_input() {
+ // Ignore input for specified time after keyboard usage
+ AbsoluteTime timestamp;
+ clock_get_uptime(×tamp);
+ uint64_t timestamp_ns;
+ absolutetime_to_nanoseconds(timestamp, ×tamp_ns);
+
+ if (timestamp_ns - keytime < maxaftertyping)
+ return ;
+
reading = true;
uint8_t reg = 0;
@@ -1081,6 +1096,44 @@ void VoodooI2CSynapticsDevice::unpublish_multitouch_interface() {
/* Sasha - impl polling */
void VoodooI2CSynapticsDevice::simulateInterrupt(OSObject* owner, IOTimerEventSource *timer) {
- interruptOccured(owner, NULL, NULL);
+ interruptOccured(owner, 0, 0);
interrupt_simulator->setTimeoutMS(INTERRUPT_SIMULATOR_TIMEOUT);
}
+
+IOReturn VoodooI2CSynapticsDevice::message(UInt32 type, IOService* provider, void* argument) {
+ switch (type) {
+ case kKeyboardGetTouchStatus:
+ {
+#if DEBUG
+ IOLog("%s::getEnabledStatus = %s\n", getName(), ignoreall ? "false" : "true");
+#endif
+ bool* pResult = (bool*)argument;
+ *pResult = !ignoreall;
+ break;
+ }
+ case kKeyboardSetTouchStatus:
+ {
+ bool enable = *((bool*)argument);
+#if DEBUG
+ IOLog("%s::setEnabledStatus = %s\n", getName(), enable ? "true" : "false");
+#endif
+ // ignoreall is true when trackpad has been disabled
+ if (enable == ignoreall) {
+ // save state, and update LED
+ ignoreall = !enable;
+ }
+ break;
+ }
+ case kKeyboardKeyPressTime:
+ {
+ // Remember last time key was pressed
+ keytime = *((uint64_t*)argument);
+#if DEBUG
+ IOLog("%s::keyPressed = %llu\n", getName(), keytime);
+#endif
+ break;
+ }
+ }
+
+ return kIOReturnSuccess;
+}
diff --git a/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.hpp b/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.hpp
index 6c73cb4..ba93d9a 100644
--- a/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.hpp
+++ b/VoodooI2CSynaptics/VoodooI2CSynapticsDevice.hpp
@@ -35,6 +35,14 @@ enum rmi_mode_type {
RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
};
+// 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_t*)
+};
+
struct rmi_function {
unsigned page; /* page of the function */
uint16_t query_base_addr; /* base address for queries */
@@ -103,12 +111,26 @@ class VoodooI2CSynapticsDevice : public IOService
unsigned long device_flags;
unsigned long firmware_id;
+ uint64_t maxaftertyping = 500000000;
+ uint64_t keytime = 0;
+ bool ignoreall;
+
uint8_t f01_ctrl0;
uint8_t interrupt_enable_mask;
bool restore_interrupt_mask;
VoodooI2CMultitouchInterface* mt_interface;
+ /*
+ * 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 kIOSuccess if the message is processed
+ */
+ IOReturn message(UInt32 type, IOService* provider, void* argument) override;
+
protected:
bool awake;
const char* name;
@@ -161,5 +183,4 @@ class VoodooI2CSynapticsDevice : public IOService
void simulateInterrupt(OSObject* owner, IOTimerEventSource* timer); /* Sasha - Implement polling mode */
};
-
#endif /* VoodooI2CSynapticsDevice_hpp */