Skip to content

Commit

Permalink
Use palm type instead of disabling transducer
Browse files Browse the repository at this point in the history
  • Loading branch information
1Revenger1 committed Jul 29, 2024
1 parent 35d23c5 commit cac437b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 31 deletions.
6 changes: 4 additions & 2 deletions VoodooRMI/Functions/F11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions VoodooRMI/Functions/F12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
44 changes: 21 additions & 23 deletions VoodooRMI/Functions/Input/RMITrackpadFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,41 +154,35 @@ 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;

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;
Expand All @@ -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;
}

Expand All @@ -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
Expand All @@ -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]) {
Expand All @@ -275,14 +267,20 @@ 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;
trans.fingerType = kMT2FingerTypeUndefined;
}
}

inputEvent.contact_count = reportIdx;
inputEvent.transducers[0].isPhysicalButtonDown = clickpadState;
inputEvent.contact_count = validFingerCount;
inputEvent.timestamp = report->timestamp;

sendVoodooInputPacket(kIOMessageVoodooInputMessage, &inputEvent);
Expand Down
6 changes: 4 additions & 2 deletions VoodooRMI/Functions/Input/RMITrackpadFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions VoodooRMI/RMIBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit cac437b

Please sign in to comment.