Skip to content

Commit

Permalink
trivial: add an additional transducer for the stylus, related to #14
Browse files Browse the repository at this point in the history
* this likely does nothing, but it seemed like the right thing to do
  • Loading branch information
lazd committed Jan 22, 2020
1 parent 58a280a commit 97f9dcb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
22 changes: 17 additions & 5 deletions VoodooI2CGoodix/VoodooI2CGoodixEventDriver.cpp
Expand Up @@ -33,7 +33,7 @@ void VoodooI2CGoodixEventDriver::dispatchPenEvent(int logicalX, int logicalY, in
checkRotation(&x, &y);

// Dispatch the actual event
dispatchDigitizerEventWithTiltOrientation(timestamp, 0, kDigitiserTransducerStylus, 0x1, clickType, x, y, 65535, tipPressure);
dispatchDigitizerEventWithTiltOrientation(timestamp, stylusTransducerID, kDigitiserTransducerStylus, 0x1, clickType, x, y, 0, tipPressure);

// Store the coordinates so we can lift the finger later
lastEventFixedX = x;
Expand Down Expand Up @@ -395,7 +395,7 @@ IOReturn VoodooI2CGoodixEventDriver::publishMultitouchInterface() {

void VoodooI2CGoodixEventDriver::configureMultitouchInterface(int logicalMaxX, int logicalMaxY, int numTransducers, UInt32 vendorId) {
if (multitouch_interface) {
IOLog("%s::Configuring multitouch interface with dimensions %d,%d and %d transducers\n", getName(), logicalMaxX, logicalMaxY, numTransducers);
IOLog("%s::Configuring multitouch interface with dimensions %d,%d and %d transducers\n", getName(), logicalMaxX, logicalMaxY, numTransducers + 1);

multitouch_interface->physical_max_x = logicalMaxX;
multitouch_interface->physical_max_y = logicalMaxY;
Expand All @@ -408,16 +408,17 @@ void VoodooI2CGoodixEventDriver::configureMultitouchInterface(int logicalMaxX, i
setProperty(kIOHIDVendorIDKey, vendorId, 32);
setProperty(kIOHIDProductIDKey, vendorId, 32);

transducers = OSArray::withCapacity(numTransducers);
transducers = OSArray::withCapacity(numTransducers + 1);
if (!transducers) {
IOLog("%s::No memory to allocate transducers array\n", getName());
return;
}

DigitiserTransducerType type = kDigitiserTransducerFinger;
for (int i = 0; i < numTransducers; i++) {
VoodooI2CDigitiserTransducer* transducer = VoodooI2CDigitiserTransducer::transducer(type, NULL);
transducer->type = kDigitiserTransducerFinger;

transducer->type = kDigitiserTransducerFinger;
transducer->logical_max_x = multitouch_interface->logical_max_x;
transducer->logical_max_y = multitouch_interface->logical_max_y;
transducer->id = i;
Expand All @@ -426,8 +427,19 @@ void VoodooI2CGoodixEventDriver::configureMultitouchInterface(int logicalMaxX, i
transducers->setObject(transducer);
}

OSDictionary* properties = OSDictionary::withCapacity(2);
// Set up an additional transducer as the stylus
stylusTransducerID = numTransducers;
VoodooI2CDigitiserTransducer* transducer = VoodooI2CDigitiserTransducer::transducer(kDigitiserTransducerStylus, NULL);

transducer->type = kDigitiserTransducerStylus;
transducer->logical_max_x = multitouch_interface->logical_max_x;
transducer->logical_max_y = multitouch_interface->logical_max_y;
transducer->id = stylusTransducerID;
transducer->secondary_id = stylusTransducerID;

transducers->setObject(transducer);

OSDictionary* properties = OSDictionary::withCapacity(2);
if (!properties) {
IOLog("%s::No memory to allocate properties dictionary\n", getName());
return;
Expand Down
2 changes: 2 additions & 0 deletions VoodooI2CGoodix/VoodooI2CGoodixEventDriver.hpp
Expand Up @@ -215,6 +215,8 @@ class EXPORT VoodooI2CGoodixEventDriver : public IOHIDEventService {
bool fingerDown = false;
UInt64 fingerDownStart = 0;

UInt8 stylusTransducerID;

bool scrollStarted = false;
};

Expand Down
2 changes: 1 addition & 1 deletion VoodooI2CGoodix/VoodooI2CGoodixTouchDriver.cpp
Expand Up @@ -367,7 +367,7 @@ void VoodooI2CGoodixTouchDriver::goodix_ts_store_touch(UInt8 *coor_data) {
swap(input_x, input_y);
}

#ifndef GOODIX_TOUCH_DRIVER_DEBUG
#ifdef GOODIX_TOUCH_DRIVER_DEBUG
IOLog("%s::%s %d with width %d at %d,%d\n", getName(), type ? "Stylus" : "Touch", id, input_w, input_x, input_y);
#endif

Expand Down

0 comments on commit 97f9dcb

Please sign in to comment.