Skip to content

Commit

Permalink
Add finger width field and patches from VoodooPS2.
Browse files Browse the repository at this point in the history
NOTE: physical dimensions are in 0.01 mm units
  • Loading branch information
Michael Belyaev authored and usr-sse2 committed Aug 13, 2019
1 parent bfbbd5e commit e3e381d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 38 deletions.
13 changes: 11 additions & 2 deletions VoodooInput/VoodooInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ void VoodooInput::free() {

bool VoodooInput::start(IOService *provider) {
if (!super::start(provider)) {
IOLog("Kishor VoodooInput could not super::start!\n");
return false;
}

Expand All @@ -32,6 +33,7 @@ bool VoodooInput::start(IOService *provider) {

if (!transformNumber || !logicalMaxXNumber || !logicalMaxYNumber
|| !physicalMaxXNumber || !physicalMaxYNumber) {
IOLog("Kishor VoodooInput could not get provider properties!\n");
return false;
}

Expand All @@ -46,23 +48,30 @@ bool VoodooInput::start(IOService *provider) {
actuator = OSTypeAlloc(VoodooInputActuatorDevice);

if (!simulator || !actuator) {
IOLog("Kishor VoodooInput could not alloc simulator or actuator!\n");
OSSafeReleaseNULL(simulator);
OSSafeReleaseNULL(actuator);
return false;
}

// Initialize simulator device
if (!simulator->init(NULL) || !simulator->attach(this))
if (!simulator->init(NULL) || !simulator->attach(this)) {
IOLog("Kishor VoodooInput could not attach simulator!\n");
goto exit;
}
else if (!simulator->start(this)) {
IOLog("Kishor VoodooInput could not start simulator!\n");
simulator->detach(this);
goto exit;
}

// Initialize actuator device
if (!actuator->init(NULL) || !actuator->attach(this))
if (!actuator->init(NULL) || !actuator->attach(this)) {
IOLog("Kishor VoodooInput could not init or attach actuator!\n");
goto exit;
}
else if (!actuator->start(this)) {
IOLog("Kishor VoodooInput could not start actuator!\n");
actuator->detach(this);
goto exit;
}
Expand Down
3 changes: 2 additions & 1 deletion VoodooInput/VoodooInputMultitouch/VoodooInputTransducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ enum VoodooInputTransducerType {
struct TouchCoordinates {
UInt32 x;
UInt32 y;
UInt32 pressure;
UInt8 pressure;
UInt8 width;
};

struct VoodooInputTransducer {
Expand Down
58 changes: 23 additions & 35 deletions VoodooInput/VoodooInputSimulator/VoodooInputSimulatorDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,13 @@ void VoodooInputSimulatorDevice::constructReportGated(VoodooInputEvent& multitou
first_unknownbit = newunknown;
}
newunknown = first_unknownbit - (4 * i);

if (new_touch_state[i] > 4) {
finger_data.Size = 10;
finger_data.Pressure = 10;
finger_data.Touch_Minor = 32;
finger_data.Touch_Major = 32;
} else if (new_touch_state[i] == 1) {
newunknown = 0x20;
finger_data.Size = 0;
finger_data.Pressure = 0x0;
finger_data.Touch_Minor = 0x0;
finger_data.Touch_Major = 0x0;
} else if (new_touch_state[i] == 2) {
newunknown = 0x70;
finger_data.Size = 8;
finger_data.Pressure = 10;
finger_data.Touch_Minor = 16;
finger_data.Touch_Major = 16;
} else if (new_touch_state[i] == 3) {
finger_data.Size = 10;
finger_data.Pressure = 10;
finger_data.Touch_Minor = 32;
finger_data.Touch_Major = 32;
} else if (new_touch_state[i] == 4) {
finger_data.Size = 10;
finger_data.Pressure = 10;
finger_data.Touch_Minor = 32;
finger_data.Touch_Major = 32;
}


if (transducer->currentCoordinates.pressure || (input_report.Button)) {

finger_data.Pressure = transducer->currentCoordinates.pressure;
finger_data.Size = transducer->currentCoordinates.width;
finger_data.Touch_Major = transducer->currentCoordinates.width;
finger_data.Touch_Minor = transducer->currentCoordinates.width;

if (input_report.Button) {
finger_data.Pressure = 120;
}

Expand Down Expand Up @@ -426,7 +401,20 @@ IOReturn VoodooInputSimulatorDevice::setReport(IOMemoryDescriptor* report, IOHID
}

if (value == 0xD9) {
unsigned char buffer[] = {0x1, 0xD9, 0x00, 0x10, 0x00};
//Sensor Surface Width = 0x3cf0 (0xf0, 0x3c) = 15.600 cm
//Sensor Surface Height = 0x2b20 (0x20, 0x2b) = 11.040 cm

// It's already in 0.01 mm units
uint32_t rawWidth = engine->getPhysicalMaxX();
uint32_t rawHeight = engine->getPhysicalMaxY();

uint8_t rawWidthLower = rawWidth & 0xff;
uint8_t rawWidthHigher = (rawWidth >> 8) & 0xff;

uint8_t rawHeightLower = rawHeight & 0xff;
uint8_t rawHeightHigher = (rawHeight >> 8) & 0xff;

unsigned char buffer[] = {0xD9, rawWidthLower, rawWidthHigher, 0x00, 0x00, rawHeightLower, rawHeightHigher, 0x00, 0x00, 0x44, 0xE3, 0x52, 0xFF, 0xBD, 0x1E, 0xE4, 0x26}; //Sensor Surface Description
new_get_report_buffer->appendBytes(buffer, sizeof(buffer));
}

Expand Down Expand Up @@ -524,8 +512,8 @@ IOReturn VoodooInputSimulatorDevice::getReport(IOMemoryDescriptor* report, IOHID
}

if (report_id == 0xDB) {
uint32_t rawWidth = engine->getPhysicalMaxX() * 10;
uint32_t rawHeight = engine->getPhysicalMaxY() * 10;
uint32_t rawWidth = engine->getPhysicalMaxX();
uint32_t rawHeight = engine->getPhysicalMaxY();

uint8_t rawWidthLower = rawWidth & 0xff;
uint8_t rawWidthHigher = (rawWidth >> 8) & 0xff;
Expand Down

0 comments on commit e3e381d

Please sign in to comment.