diff --git a/VoodooRMI/Functions/F11.cpp b/VoodooRMI/Functions/F11.cpp index dcd29ff..3ffadab 100644 --- a/VoodooRMI/Functions/F11.cpp +++ b/VoodooRMI/Functions/F11.cpp @@ -595,8 +595,10 @@ int F11::rmi_f11_initialize() query_offset += rc; if (sens_query.has_physical_props) { - sensorSize.sizeX = sens_query.x_sensor_size_mm; - sensorSize.sizeY = sens_query.y_sensor_size_mm; + sensorSize.mmSizeX = sens_query.x_sensor_size_mm; + sensorSize.mmSizeY = sens_query.y_sensor_size_mm; + sensorSize.umPerTraceX = sens_query.x_sensor_size_mm * 10 / sens_query.nr_x_electrodes; + sensorSize.umPerTraceY = sens_query.y_sensor_size_mm * 10 / sens_query.nr_y_electrodes; } else { IOLogError("No size data from Device."); return -ENODEV; diff --git a/VoodooRMI/Functions/F12.cpp b/VoodooRMI/Functions/F12.cpp index 58cbbb0..f505130 100644 --- a/VoodooRMI/Functions/F12.cpp +++ b/VoodooRMI/Functions/F12.cpp @@ -260,8 +260,10 @@ int F12::rmi_f12_read_sensor_tuning() if (rmi_register_desc_has_subpacket(item, 4)) offset += 1; - sensorSize.sizeX = (pitch_x * rx_receivers) >> 12; - sensorSize.sizeY = (pitch_y * tx_receivers) >> 12; + sensorSize.mmSizeX = (pitch_x * rx_receivers) >> 12; + sensorSize.mmSizeY = (pitch_y * tx_receivers) >> 12; + sensorSize.umPerTraceX = (pitch_x >> 12) * 10; + sensorSize.umPerTraceY = (pitch_y >> 12) * 10; setData(sensorSize); return 0; diff --git a/VoodooRMI/Functions/Input/RMITrackpadFunction.cpp b/VoodooRMI/Functions/Input/RMITrackpadFunction.cpp index f167477..b2f7294 100644 --- a/VoodooRMI/Functions/Input/RMITrackpadFunction.cpp +++ b/VoodooRMI/Functions/Input/RMITrackpadFunction.cpp @@ -154,32 +154,28 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) ((report->timestamp - lastTrackpointTS) < (conf.disableWhileTrackpointTimeout * MILLI_TO_NANO)); size_t maxIdx = report->fingers > MAX_FINGERS ? MAX_FINGERS : report->fingers; - size_t reportIdx = 0; for (int i = 0; i < maxIdx; i++) { rmi_2d_sensor_abs_object obj = report->objs[i]; bool isValidObj = obj.type == RMI_2D_OBJECT_FINGER || - obj.type == RMI_2D_OBJECT_STYLUS; /*||*/ + obj.type == RMI_2D_OBJECT_STYLUS || // Allow inaccurate objects as they are likely invalid, which we want to track still // This can be a random finger or one which was lifted up slightly -// obj.type == RMI_2D_OBJECT_INACCURATE; + obj.type == RMI_2D_OBJECT_INACCURATE; - auto& transducer = inputEvent.transducers[reportIdx]; + auto& transducer = inputEvent.transducers[i]; transducer.isTransducerActive = isValidObj; transducer.secondaryId = i; // Finger lifted, make finger valid if (!isValidObj) { - if (fingerState[i] != RMI_FINGER_LIFTED) reportIdx++; fingerState[i] = RMI_FINGER_LIFTED; - transducer.isPhysicalButtonDown = false; - transducer.currentCoordinates.pressure = 0; continue; } validFingerCount++; - reportIdx++; + transducer.isTransducerActive = true; transducer.previousCoordinates = transducer.currentCoordinates; transducer.currentCoordinates.width = obj.z / 2.0; transducer.timestamp = report->timestamp; @@ -187,8 +183,6 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) transducer.currentCoordinates.x = obj.x; transducer.currentCoordinates.y = data.maxY - obj.y; - int deltaWidth = abs(obj.wx - obj.wy); - switch (fingerState[i]) { case RMI_FINGER_LIFTED: fingerState[i] = RMI_FINGER_STARTED_IN_ZONE; @@ -198,7 +192,7 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) /* fall through */ case RMI_FINGER_STARTED_IN_ZONE: { size_t zone = checkInZone(transducer); - if (zone == 0) { + if (zone == 0 && obj.z > 20) { fingerState[i] = RMI_FINGER_VALID; } @@ -214,13 +208,13 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) /* fall through */ case RMI_FINGER_VALID: if (obj.z > RMI_2D_MAX_Z || - deltaWidth > conf.fingerMajorMinorMax) { + obj.wx * data.umPerTraceX > 250 || + obj.wy * data.umPerTraceY > 250 || + obj.type == RMI_2D_OBJECT_INACCURATE) { fingerState[i] = RMI_FINGER_INVALID; } - transducer.isPhysicalButtonDown = clickpadState; - // Force touch emulation only works with clickpads (button underneath trackpad) // Lock finger in place and in force touch until lifted // Checks for VALID input before registering as force touch @@ -236,24 +230,22 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) break; } - transducer.isPhysicalButtonDown = false; transducer.currentCoordinates = transducer.previousCoordinates; transducer.currentCoordinates.pressure = RMI_MT2_MAX_PRESSURE; break; case RMI_FINGER_INVALID: - transducer.isTransducerActive = false; - continue; + break; } - transducer.isTransducerActive = fingerState[i] == RMI_FINGER_VALID || fingerState[i] == RMI_FINGER_FORCE_TOUCH; + transducer.isTransducerActive = fingerState[i] != RMI_FINGER_STARTED_IN_ZONE && fingerState[i] != RMI_FINGER_LIFTED; - IOLogDebug("Finger num: %d (%s) (%d, %d) [Z: %u WX: %u WY: %u FingerType: %d Pressure : %d Button: %d]", + IOLogDebug("Finger num: %d (%s) (%d, %d) [Z: %u WX: %u WY: %u FingerType: %d Pressure: %d]", i, - transducer.isTransducerActive ? "valid" : "invalid", + fingerState[i] != RMI_FINGER_INVALID ? "valid" : "invalid", obj.x, obj.y, obj.z, obj.wx, obj.wy, transducer.fingerType, - transducer.currentCoordinates.pressure, - transducer.isPhysicalButtonDown); + transducer.currentCoordinates.pressure + ); } if (validFingerCount >= 4 && freeFingerTypes[kMT2FingerTypeThumb]) { @@ -275,6 +267,11 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) if (trans.fingerType == kMT2FingerTypeUndefined) { trans.fingerType = getFingerType(); } + + if (fingerState[i] == RMI_FINGER_INVALID) { + freeFingerTypes[trans.fingerType] = true; + trans.fingerType = kMT2FingerTypePalm; + } } else { // Free finger freeFingerTypes[trans.fingerType] = true; @@ -282,7 +279,8 @@ void RMITrackpadFunction::handleReport(RMI2DSensorReport *report) } } - inputEvent.contact_count = reportIdx; + inputEvent.transducers[0].isPhysicalButtonDown = clickpadState; + inputEvent.contact_count = validFingerCount; inputEvent.timestamp = report->timestamp; sendVoodooInputPacket(kIOMessageVoodooInputMessage, &inputEvent); diff --git a/VoodooRMI/Functions/Input/RMITrackpadFunction.hpp b/VoodooRMI/Functions/Input/RMITrackpadFunction.hpp index b3939ec..aa6c9db 100644 --- a/VoodooRMI/Functions/Input/RMITrackpadFunction.hpp +++ b/VoodooRMI/Functions/Input/RMITrackpadFunction.hpp @@ -36,10 +36,12 @@ enum finger_state { }; struct Rmi2DSensorData { - UInt16 sizeX; - UInt16 sizeY; + UInt16 mmSizeX; + UInt16 mmSizeY; UInt16 maxX; UInt16 maxY; + UInt32 umPerTraceX; + UInt32 umPerTraceY; }; struct rmi_2d_sensor_abs_object { diff --git a/VoodooRMI/RMIBus.cpp b/VoodooRMI/RMIBus.cpp index b045bb0..194010d 100644 --- a/VoodooRMI/RMIBus.cpp +++ b/VoodooRMI/RMIBus.cpp @@ -303,8 +303,8 @@ void RMIBus::publishVoodooInputProperties() { setProperty(VOODOO_INPUT_LOGICAL_MAX_X_KEY, trackpadData.maxX, 16); setProperty(VOODOO_INPUT_LOGICAL_MAX_Y_KEY, trackpadData.maxY, 16); // Need to be in 0.01mm units - setProperty(VOODOO_INPUT_PHYSICAL_MAX_X_KEY, trackpadData.sizeX * 100, 16); - setProperty(VOODOO_INPUT_PHYSICAL_MAX_Y_KEY, trackpadData.sizeY * 100, 16); + setProperty(VOODOO_INPUT_PHYSICAL_MAX_X_KEY, trackpadData.mmSizeX * 100, 16); + setProperty(VOODOO_INPUT_PHYSICAL_MAX_Y_KEY, trackpadData.mmSizeY * 100, 16); setProperty(VOODOO_INPUT_TRANSFORM_KEY, 0ull, 32); if (trackpointFunction != nullptr) {