Skip to content

Commit

Permalink
VoodooInput: new "Update dimensions" message
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Belyaev committed Nov 29, 2019
1 parent e3e381d commit 2a71655
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
10 changes: 8 additions & 2 deletions VoodooInput/VoodooInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ IOReturn VoodooInput::message(UInt32 type, IOService *provider, void *argument)
if (argument && simulator) {
simulator->constructReport(*(VoodooInputEvent*)argument);
}

}

else if (type == kIOMessageVoodooInputUpdateDimensionsMessage && provider == parentProvider) {
if (argument) {
const VoodooInputDimensions& dimensions = *(VoodooInputDimensions*)argument;
logicalMaxX = dimensions.max_x - dimensions.min_x;
logicalMaxY = dimensions.max_y - dimensions.min_y;
}
}

return super::message(type, provider, argument);
}

Expand Down
7 changes: 7 additions & 0 deletions VoodooInput/VoodooInputMultitouch/VoodooInputEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ typedef struct {
VoodooInputTransducer transducers[VOODOO_INPUT_MAX_TRANSDUCERS];
} VoodooInputEvent;

typedef struct {
SInt32 min_x;
SInt32 max_x;
SInt32 min_y;
SInt32 max_y;
} VoodooInputDimensions;

#endif /* VoodooInputEvent_h */
1 change: 1 addition & 0 deletions VoodooInput/VoodooInputMultitouch/VoodooInputMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#define VOODOO_INPUT_MAX_TRANSDUCERS 10
#define kIOMessageVoodooInputMessage 12345
#define kIOMessageVoodooInputUpdateDimensionsMessage 12346

#define kVoodooInputTransducerFingerType 1
#define kVoodooInputTransducerStylusType 2
Expand Down
10 changes: 5 additions & 5 deletions VoodooInput/VoodooInputSimulator/VoodooInputSimulatorDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ UInt16 abs(SInt16 x) {

const unsigned char report_descriptor[] = {0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x85, 0x02, 0x95, 0x03, 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0x95, 0x04, 0x75, 0x08, 0x81, 0x01, 0xc0, 0xc0, 0x05, 0x0d, 0x09, 0x05, 0xa1, 0x01, 0x06, 0x00, 0xff, 0x09, 0x0c, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x10, 0x85, 0x3f, 0x81, 0x22, 0xc0, 0x06, 0x00, 0xff, 0x09, 0x0c, 0xa1, 0x01, 0x06, 0x00, 0xff, 0x09, 0x0c, 0x15, 0x00, 0x26, 0xff, 0x00, 0x85, 0x44, 0x75, 0x08, 0x96, 0x6b, 0x05, 0x81, 0x00, 0xc0};

void VoodooInputSimulatorDevice::constructReport(VoodooInputEvent multitouch_event) {
void VoodooInputSimulatorDevice::constructReport(const VoodooInputEvent& multitouch_event) {
if (!ready_for_reports)
return;

command_gate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooInputSimulatorDevice::constructReportGated), &multitouch_event);
command_gate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &VoodooInputSimulatorDevice::constructReportGated), (void*)&multitouch_event);
}

void VoodooInputSimulatorDevice::constructReportGated(VoodooInputEvent& multitouch_event) {
void VoodooInputSimulatorDevice::constructReportGated(const VoodooInputEvent& multitouch_event) {
if (!ready_for_reports)
return;

Expand All @@ -44,7 +44,7 @@ void VoodooInputSimulatorDevice::constructReportGated(VoodooInputEvent& multitou
input_report.Unused[3] = 0;
input_report.Unused[4] = 0;

VoodooInputTransducer* transducer = &multitouch_event.transducers[0];
const VoodooInputTransducer* transducer = &multitouch_event.transducers[0];

if (!transducer)
return;
Expand Down Expand Up @@ -85,7 +85,7 @@ void VoodooInputSimulatorDevice::constructReportGated(VoodooInputEvent& multitou
bool is_error_input_active = false;

for (int i = 0; i < multitouch_event.contact_count + 1; i++) {
VoodooInputTransducer* transducer = &multitouch_event.transducers[i + stylus_check];
const VoodooInputTransducer* transducer = &multitouch_event.transducers[i + stylus_check];

new_touch_state[i] = touch_state[i];
touch_state[i] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ struct __attribute__((__packed__)) MAGIC_TRACKPAD_INPUT_REPORT {
UInt8 multitouch_report_id;
UInt8 timestamp_buffer[3];

MAGIC_TRACKPAD_INPUT_REPORT_FINGER FINGERS[12]; // May support more fingers
MAGIC_TRACKPAD_INPUT_REPORT_FINGER FINGERS[VOODOO_INPUT_MAX_TRANSDUCERS]; // May support more fingers
};

class EXPORT VoodooInputSimulatorDevice : public IOHIDDevice {
OSDeclareDefaultStructors(VoodooInputSimulatorDevice);

public:
void constructReport(VoodooInputEvent multitouch_event);
void constructReport(const VoodooInputEvent& multitouch_event);

IOReturn setReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) override;

IOReturn getReport(IOMemoryDescriptor* report, IOHIDReportType reportType, IOOptionBits options) override;
Expand Down Expand Up @@ -99,7 +100,7 @@ class EXPORT VoodooInputSimulatorDevice : public IOHIDDevice {
IOCommandGate* command_gate;
MAGIC_TRACKPAD_INPUT_REPORT input_report;

void constructReportGated(VoodooInputEvent& multitouch_event);
void constructReportGated(const VoodooInputEvent& multitouch_event);
};


Expand Down

0 comments on commit 2a71655

Please sign in to comment.