3333// ApplePS2Elan Class Implementation
3434//
3535
36- OSDefineMetaClassAndStructors (ApplePS2Elan, IOHIPointing);
37-
38- UInt32 ApplePS2Elan::deviceType ()
39- { return NX_EVS_DEVICE_TYPE_MOUSE; };
40-
41- UInt32 ApplePS2Elan::interfaceID ()
42- { return NX_EVS_DEVICE_INTERFACE_BUS_ACE; };
36+ OSDefineMetaClassAndStructors (ApplePS2Elan, IOService);
4337
4438bool ApplePS2Elan::init (OSDictionary *dict) {
4539 // Initialize this object's minimal state. This is invoked right after this
@@ -239,18 +233,6 @@ bool ApplePS2Elan::start(IOService *provider) {
239233 }
240234#endif
241235
242- // Advertise the current state of the tapping feature.
243- //
244- // Must add this property to let our superclass know that it should handle
245- // trackpad acceleration settings from user space. Without this, tracking
246- // speed adjustments from the mouse prefs panel have no effect.
247- setProperty (kIOHIDPointerAccelerationTypeKey , kIOHIDTrackpadAccelerationType );
248- setProperty (kIOHIDScrollAccelerationTypeKey , kIOHIDTrackpadScrollAccelerationKey );
249- setProperty (kIOHIDScrollResolutionKey , _scrollresolution << 16 , 32 );
250- // added for Sierra precise scrolling (credit @usr-sse2)
251- setProperty (" HIDScrollResolutionX" , _scrollresolution << 16 , 32 );
252- setProperty (" HIDScrollResolutionY" , _scrollresolution << 16 , 32 );
253-
254236 // Setup workloop with command gate for thread syncronization...
255237 IOWorkLoop *pWorkLoop = getWorkLoop ();
256238 _cmdGate = IOCommandGate::commandGate (this );
@@ -340,11 +322,15 @@ void ApplePS2Elan::setParamPropertiesGated(OSDictionary *config) {
340322
341323 const struct {const char *name; int *var;} int32vars[] = {
342324 {" WakeDelay" , &wakedelay},
343- {" ScrollResolution " , &_scrollresolution },
325+ {" TrackpointDeadzone " , &_trackpointDeadzone },
344326 {" TrackpointMultiplierX" , &_trackpointMultiplierX},
345327 {" TrackpointMultiplierY" , &_trackpointMultiplierY},
346328 {" TrackpointDividerX" , &_trackpointDividerX},
347329 {" TrackpointDividerY" , &_trackpointDividerY},
330+ {" TrackpointScrollMultiplierX" , &_trackpointScrollMultiplierX},
331+ {" TrackpointScrollMultiplierY" , &_trackpointScrollMultiplierY},
332+ {" TrackpointScrollDividerY" , &_trackpointScrollDividerX},
333+ {" TrackpointScrollDividerY" , &_trackpointScrollDividerY},
348334 {" MouseResolution" , &_mouseResolution},
349335 {" MouseSampleRate" , &_mouseSampleRate},
350336 {" ForceTouchMode" , (int *)&_forceTouchMode},
@@ -412,16 +398,8 @@ void ApplePS2Elan::setParamPropertiesGated(OSDictionary *config) {
412398 if (attachedHIDPointerDevices && attachedHIDPointerDevices->getCount () > 0 ) {
413399 ignoreall = usb_mouse_stops_trackpad;
414400 }
415- }
416-
417- IOReturn ApplePS2Elan::setParamProperties (OSDictionary *dict) {
418- if (_cmdGate) {
419- // syncronize through workloop...
420- // _cmdGate->runAction(OSMemberFunctionCast(IOCommandGate::Action, this, &ApplePS2Elan::setParamPropertiesGated), dict);
421- setParamPropertiesGated (dict);
422- }
423-
424- return super::setParamProperties (dict);
401+
402+ setTrackpointProperties ();
425403}
426404
427405IOReturn ApplePS2Elan::setProperties (OSObject *props) {
@@ -434,6 +412,28 @@ IOReturn ApplePS2Elan::setProperties(OSObject *props) {
434412 return super::setProperties (props);
435413}
436414
415+ void ApplePS2Elan::setTrackpointProperties ()
416+ {
417+ // Trackpoint information for VoodooInput
418+ OSDictionary *trackpoint = OSDictionary::withCapacity (10 );
419+ if (trackpoint == nullptr )
420+ return ;
421+
422+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_DEADZONE, _trackpointDeadzone);
423+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_BTN_CNT, 3 );
424+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_MOUSE_MULT_X, _trackpointMultiplierX);
425+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_MOUSE_MULT_Y, _trackpointMultiplierY);
426+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_MOUSE_DIV_X, _trackpointDividerX);
427+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_MOUSE_DIV_Y, _trackpointDividerY);
428+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_SCROLL_MULT_X, _trackpointScrollMultiplierX);
429+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_SCROLL_MULT_Y, _trackpointScrollMultiplierY);
430+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_SCROLL_DIV_X, _trackpointScrollDividerX);
431+ PS2DictSetNumber (trackpoint, VOODOO_TRACKPOINT_SCROLL_DIV_Y, _trackpointScrollDividerY);
432+
433+ setProperty (VOODOO_TRACKPOINT_KEY, trackpoint);
434+ OSSafeReleaseNULL (trackpoint);
435+ }
436+
437437IOReturn ApplePS2Elan::message (UInt32 type, IOService* provider, void * argument) {
438438 // Here is where we receive messages from the keyboard driver
439439 //
@@ -1870,19 +1870,6 @@ void ApplePS2Elan::elantechReportTrackpoint() {
18701870 int dx = packet[4 ] - (int )((packet[1 ] ^ 0x80 ) << 1 );
18711871 int dy = (int )((packet[2 ] ^ 0x80 ) << 1 ) - packet[5 ];
18721872
1873- dx = dx * _trackpointMultiplierX / _trackpointDividerX;
1874- dy = dy * _trackpointMultiplierY / _trackpointDividerY;
1875-
1876- // enable trackpoint scroll mode when middle button was pressed and the trackpoint moved
1877- if (trackpointMiddleButton == 4 && (dx != 0 || dy != 0 )) {
1878- trackpointScrolling = true ;
1879- }
1880-
1881- // disable trackpoint scrolling mode when middle button is released
1882- if (trackpointScrolling && trackpointMiddleButton == 0 ) {
1883- trackpointScrolling = false ;
1884- }
1885-
18861873 AbsoluteTime timestamp;
18871874 clock_get_uptime (×tamp);
18881875
@@ -1891,12 +1878,13 @@ void ApplePS2Elan::elantechReportTrackpoint() {
18911878 uint64_t timestamp_ns;
18921879 absolutetime_to_nanoseconds (timestamp, ×tamp_ns);
18931880 keytime = timestamp_ns;
1894-
1895- if (trackpointScrolling) {
1896- dispatchScrollWheelEvent (dy, dx, 0 , timestamp);
1897- } else {
1898- dispatchRelativePointerEvent (dx, dy, trackpointRightButton | trackpointLeftButton | trackpointMiddleButton, timestamp);
1899- }
1881+
1882+ trackpointReport.timestamp = timestamp;
1883+ trackpointReport.buttons = trackpointLeftButton | trackpointMiddleButton | trackpointRightButton;
1884+ trackpointReport.dx = dx;
1885+ trackpointReport.dy = dy;
1886+ super::messageClient (kIOMessageVoodooTrackpointMessage , voodooInputInstance,
1887+ &trackpointReport, sizeof (trackpointReport));
19001888}
19011889
19021890void ApplePS2Elan::processPacketStatusV4 () {
@@ -2108,8 +2096,11 @@ void ApplePS2Elan::sendTouchData() {
21082096
21092097 if (!info.is_buttonpad ) {
21102098 if (transducers_count == 0 ) {
2111- UInt32 buttons = leftButton | rightButton;
2112- dispatchRelativePointerEvent (0 , 0 , buttons, timestamp);
2099+ trackpointReport.timestamp = timestamp;
2100+ trackpointReport.buttons = leftButton | rightButton;
2101+ trackpointReport.dx = trackpointReport.dy = 0 ;
2102+ super::messageClient (kIOMessageVoodooTrackpointMessage , voodooInputInstance,
2103+ &trackpointReport, sizeof (trackpointReport));
21132104 } else {
21142105 UInt32 buttons = 0 ;
21152106 bool send = false ;
@@ -2122,7 +2113,11 @@ void ApplePS2Elan::sendTouchData() {
21222113 send = true ;
21232114 }
21242115 if (send) {
2125- dispatchRelativePointerEvent (0 , 0 , buttons, timestamp);
2116+ trackpointReport.timestamp = timestamp;
2117+ trackpointReport.buttons = buttons;
2118+ trackpointReport.dx = trackpointReport.dy = 0 ;
2119+ super::messageClient (kIOMessageVoodooTrackpointMessage , voodooInputInstance,
2120+ &trackpointReport, sizeof (trackpointReport));
21262121 }
21272122 }
21282123
0 commit comments