Skip to content

Commit

Permalink
Term cleanup, touch up readme (#57)
Browse files Browse the repository at this point in the history
* Term cleanup, touch up readme

* Couldn't unsee

* Revert unintended replacement

* Ooops
  • Loading branch information
gimdh authored Sep 4, 2020
1 parent 975cbe0 commit cb78e02
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ VoodooInput/
**/*.kext
build
DerivedData
.DS_Store
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ A port for macOS of Synaptic's RMI code from Linux. RMI4 is used for touchscreen

This driver communicates over SMBus or I2C.

## Currently Working
* Force Touch emulation for clickpads (press down clickpad and increase area finger uses)
## Supported Features
* Force Touch emulation for clickpads (press down clickpad and increase touched area)
* Up to four finger gestures (Though it can track up to 5 fingers)
* Buttons
* Trackstick
* Trackpoint
* Power Management
* SMBus Communication
* I2C Communication

## How do I know if my device is compatible?
## Compatibility

**SMBus**

Expand Down Expand Up @@ -47,18 +47,18 @@ Linux:

**SMBus**
* [VoodooSMBus](https://github.com/VoodooSMBus/VoodooSMBus)
* Apple's SMBus **PCI** controller cannot load, as it interfers with VoodooSMBus.
* VoodooPS2
* Apple's SMBus **PCI** controller cannot load, as it interferes with VoodooSMBus.
* [VoodooPS2](https://github.com/acidanthera/VoodooPS2)
* Needed for PS2 reset of the trackpad
* Generally users should only add VoodooPS2Controller and VoodooPS2Keyboard. Trackpad/Mouse will cause VoodooRMI to not attach.
* OpenCore users can just disable Mouse/Trackpad in their config.plist.
* Clover users - go inside the VoodooPS2 kext and remove Mouse/Trackpad from the PlugIns folder.
* Generally users should only add VoodooPS2Controller and VoodooPS2Keyboard. VoodooPS2Trackpad/VoodooPS2Mouse will cause VoodooRMI to not attach.
* OpenCore users can just disable VoodooPS2Trackpad/VoodooPS2Mouse in their `config.plist`.
* Clover users can go inside the VoodooPS2 kext and remove VoodooPS2Trackpad/VoodooPS2Mouse from PlugIns folder.

**I2C**
* [VoodooI2C](https://github.com/VoodooI2C/VoodooI2C)
* Follow their [Documentation](https://voodooi2c.github.io) to identify if you need GPIO pinning.
* Polling mode should just work
* If your device's ACPI name is not included below or marked as unknown, you may try manually add it and consider a PR/issue
* If your device's ACPI name is not included below or marked as unknown, you may add it yourself and create a PR/issue

| Name | Main function |
|---|---|
Expand All @@ -76,7 +76,7 @@ Linux:

## Installation
1) Add the required kexts to your bootloader
2) Disable VoodooPS2Mouse, VoodooPS2Trackpad, and if applicable, VoodooInput from within the PS2 kext.
2) Disable VoodooPS2Trackpad, VoodooPS2Mouse, and if applicable, VoodooInput from within the PS2 kext.
3) For OpenCore users, make sure to add VoodooInput, VoodooTrackpoint and RMISMBus/RMII2C to your Config.plist.
* RMISMBus/RMII2C should be after VoodooRMI
* All dependencies are found under `VoodooRMI.kext/Contents/PlugIns/`
Expand All @@ -90,17 +90,17 @@ There is no support for this kext being loaded into Library/Extensions or System
## Configuration

The values below can be edited under Info.plist within the kext itself - these can be changed without recompiling
**Note** that using non-integer values causes undefined behaviour which may prevent the kext from loading
**Note** that using non-integer value causes undefined behaviour which may prevent the kext from loading

| Value | Default | Description |
| ----- | ------- | ----------- |
| `ForceTouchEmulation` | True | Allows Force Touch emulation on Clickpads |
| `ForceTouchMinPressure` | 90 | Minimum z value to trigger Force touch when clickpad is clicked |
| `DisableWhileTypingTimeout` | 100 | Milliseconds after typing in which to reject touchpad packets |
| `TrackstickMultiplier` | 20 | Multiplier used on trackstick inputs (other than scrolling). This is divided by 20, so the default value of 20 will not change the output value at all |
| `TrackstickScrollMultiplierX` | 20 | Multiplier used on the x access when middle button is held down for scrolling. This is divded by 20. |
| `TrackstickScrollMultiplierY` | 20 | Same as the above, except applied to the Y axis |
| `TrackstickDeadzone` | 1 | Minimum value at which trackstick reports will be accepted. This is subtracted from the input of the trackstick, so setting this extremely high will reduce trackstick resolution |
| `DisableWhileTypingTimeout` | 100 | Milliseconds after typing in which to reject trackpad packets |
| `TrackpointMultiplier` | 20 | Multiplier used on trackpoint inputs (other than scrolling). This is divided by 20, so the default value of 20 will not change the output value at all |
| `TrackpointScrollMultiplierX` | 20 | Multiplier used on the x access when middle button is held down for scrolling. This is divded by 20. |
| `TrackpointScrollMultiplierY` | 20 | Same as the above, except applied to the Y axis |
| `TrackpointDeadzone` | 1 | Minimum value at which trackpoint reports will be accepted. This is subtracted from the input of the trackpoint, so setting this extremely high will reduce trackpoint resolution |
| `MinYDiffThumbDetection` | 200 | Minimum distance between the second lowest and lowest finger in which Minimum Y logic is used to detect the thumb rather than using the z value from the trackpad. Setting this higher means that the thumb must be farther from the other fingers before the y coordinate is used to detect the thumb, rather than using finger area. Keeping this smaller is preferable as finger area logic seems to only be useful when all 4 fingers are grouped together closely, where the thumb is more likely to be pressing down more |

Note that you can use Rehabman's ioio to set properties temporarily (until the next reboot).
Expand Down
14 changes: 7 additions & 7 deletions VoodooRMI/Functions/F03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ void F03::handlePacket(u8 *packet)
if (!voodooTrackpointInstance)
return;

// The highest dx/dy is lowered by subtracting by trackstickDeadzone.
// The highest dx/dy is lowered by subtracting by trackpointDeadzone.
// This however does allows values below the deadzone value to still be sent, preserving control in the lower end

dx -= signum(dx) * min(abs(dx), conf->trackstickDeadzone);
dy -= signum(dy) * min(abs(dy), conf->trackstickDeadzone);
dx -= signum(dx) * min(abs(dx), conf->trackpointDeadzone);
dy -= signum(dy) * min(abs(dy), conf->trackpointDeadzone);

// For middle button, we do not actually tell macOS it's been pressed until it's been released and we didn't scroll
// We first say that it's been pressed internally - but if we scroll at all, then instead we say we scroll
Expand Down Expand Up @@ -201,16 +201,16 @@ void F03::handlePacket(u8 *packet)

// Must multiply first then divide so we don't multiply by zero
if (isScrolling) {
scrollEvent.deltaAxis1 = (SInt32)((SInt64)-dy * conf->trackstickScrollYMult / DEFAULT_MULT);
scrollEvent.deltaAxis2 = (SInt32)((SInt64)-dx * conf->trackstickScrollXMult / DEFAULT_MULT);
scrollEvent.deltaAxis1 = (SInt32)((SInt64)-dy * conf->trackpointScrollYMult / DEFAULT_MULT);
scrollEvent.deltaAxis2 = (SInt32)((SInt64)-dx * conf->trackpointScrollXMult / DEFAULT_MULT);
scrollEvent.deltaAxis3 = 0;
scrollEvent.timestamp = timestamp;

messageClient(kIOMessageVoodooTrackpointScrollWheel, voodooTrackpointInstance, &scrollEvent, sizeof(ScrollWheelEvent));
} else {
relativeEvent.buttons = buttons;
relativeEvent.dx = (SInt32)((SInt64)dx * conf->trackstickMult / DEFAULT_MULT);
relativeEvent.dy = (SInt32)((SInt64)dy * conf->trackstickMult / DEFAULT_MULT);
relativeEvent.dx = (SInt32)((SInt64)dx * conf->trackpointMult / DEFAULT_MULT);
relativeEvent.dy = (SInt32)((SInt64)dy * conf->trackpointMult / DEFAULT_MULT);
relativeEvent.timestamp = timestamp;

messageClient(kIOMessageVoodooTrackpointRelativePointer, voodooTrackpointInstance, &relativeEvent, sizeof(RelativePointerEvent));
Expand Down
32 changes: 16 additions & 16 deletions VoodooRMI/Functions/F30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool F30::start(IOService *provider)
{
if (!super::start(provider))
return false;
// TODO: Either find F03 for trackstick button
// TODO: Either find F03 for trackpoint button
// or just send buttons in attention

int error = rmiBus->blockWrite(fn_descriptor->control_base_addr,
Expand Down Expand Up @@ -210,8 +210,8 @@ int F30::rmi_f30_is_valid_button(int button)
int F30::rmi_f30_map_gpios()
{
unsigned int button = BTN_LEFT;
unsigned int trackstick_button = BTN_LEFT;
int buttonArrLen = min(gpioled_count, TRACKSTICK_RANGE_END);
unsigned int trackpoint_button = BTN_LEFT;
int buttonArrLen = min(gpioled_count, TRACKPOINT_RANGE_END);
setProperty("Button Count", buttonArrLen, 32);

gpioled_key_map = reinterpret_cast<uint16_t *>(IOMalloc(buttonArrLen * sizeof(gpioled_key_map[0])));
Expand All @@ -221,9 +221,9 @@ int F30::rmi_f30_map_gpios()
if (!rmi_f30_is_valid_button(i))
continue;

if (i >= TRACKSTICK_RANGE_START && i < TRACKSTICK_RANGE_END) {
IOLogDebug("F30: Found Trackstick button %d", button);
gpioled_key_map[i] = trackstick_button++;
if (i >= TRACKPOINT_RANGE_START && i < TRACKPOINT_RANGE_END) {
IOLogDebug("F30: Found Trackpoint button %d\n", button);
gpioled_key_map[i] = trackpoint_button++;
} else {
IOLogDebug("F30: Found Button %d", button);
gpioled_key_map[i] = button++;
Expand All @@ -232,10 +232,10 @@ int F30::rmi_f30_map_gpios()
}
}

// Trackstick buttons either come through F03/PS2 passtrough OR they come through F30 interrupts
// Trackpoint buttons either come through F03/PS2 passtrough OR they come through F30 interrupts
// Generally I've found it more common for them to come through PS2
hasTrackstickButtons = trackstick_button != BTN_LEFT;
setProperty("Trackstick Buttons through F30", hasTrackstickButtons);
hasTrackpointButtons = trackpoint_button != BTN_LEFT;
setProperty("Trackpoint Buttons through F30", hasTrackpointButtons);
setProperty("Clickpad", numButtons == 1);

return 0;
Expand Down Expand Up @@ -268,8 +268,8 @@ int F30::rmi_f30_read_control_parameters()

void F30::rmi_f30_report_button()
{
int buttonArrLen = min(gpioled_count, TRACKSTICK_RANGE_END);
unsigned int mask, trackstickBtns = 0, btns = 0;
int buttonArrLen = min(gpioled_count, TRACKPOINT_RANGE_END);
unsigned int mask, trackpointBtns = 0, btns = 0;
unsigned int reg_num, bit_num;
u16 key_code;
bool key_down;
Expand All @@ -295,9 +295,9 @@ void F30::rmi_f30_report_button()

IOLogDebug("Key %u is %s", key_code, key_down ? "Down": "Up");

if (i >= TRACKSTICK_RANGE_START &&
i <= TRACKSTICK_RANGE_END) {
trackstickBtns |= mask;
if (i >= TRACKPOINT_RANGE_START &&
i <= TRACKPOINT_RANGE_END) {
trackpointBtns |= mask;
} else {
btns |= mask;
}
Expand All @@ -314,8 +314,8 @@ void F30::rmi_f30_report_button()
messageClient(kIOMessageVoodooTrackpointRelativePointer, voodooTrackpointInstance, &relativeEvent, sizeof(RelativePointerEvent));
}

if (hasTrackstickButtons)
rmiBus->notify(kHandleRMITrackpointButton, trackstickBtns);
if (hasTrackpointButtons)
rmiBus->notify(kHandleRMITrackpointButton, trackpointBtns);
}

bool F30::handleOpen(IOService *forClient, IOOptionBits options, void *arg)
Expand Down
6 changes: 3 additions & 3 deletions VoodooRMI/Functions/F30.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
+ 1 \
+ 1)

#define TRACKSTICK_RANGE_START 3
#define TRACKSTICK_RANGE_END 6
#define TRACKPOINT_RANGE_START 3
#define TRACKPOINT_RANGE_END 6

struct rmi_f30_ctrl_data {
int address;
Expand Down Expand Up @@ -101,7 +101,7 @@ class F30 : public RMIFunction {

struct input_dev *input;

bool hasTrackstickButtons;
bool hasTrackpointButtons;

int rmi_f30_initialize();
void rmi_f30_set_ctrl_data(rmi_f30_ctrl_data *ctrl,
Expand Down
8 changes: 4 additions & 4 deletions VoodooRMI/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
<integer>100</integer>
<key>DisableWhileTrackpointTimeout </key>
<integer>100</integer>
<key>TrackstickMultiplier</key>
<key>TrackpointMultiplier</key>
<integer>10</integer>
<key>TrackstickScrollMultiplierX</key>
<key>TrackpointScrollMultiplierX</key>
<integer>30</integer>
<key>TrackstickScrollMultiplierY</key>
<key>TrackpointScrollMultiplierY</key>
<integer>30</integer>
<key>TrackstickDeadzone</key>
<key>TrackpointDeadzone</key>
<integer>1</integer>
</dict>
<key>IOProbeScore</key>
Expand Down
10 changes: 5 additions & 5 deletions VoodooRMI/RMIBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ int RMIBus::rmi_register_function(rmi_function *fn) {
break;
// case 0x08: /* self test (aka BIST) */
// case 0x09: /* self test (aka BIST) */
// case 0x17: /* pointing sticks */
// case 0x17: /* trackpoints */
// case 0x19: /* capacitive buttons */
// case 0x1A: /* simple capacitive buttons */
// case 0x21: /* force sensing */
Expand Down Expand Up @@ -361,10 +361,10 @@ void RMIBus::updateConfiguration(OSDictionary* dictionary) {
return;

bool update = false;
update |= Configuration::loadUInt32Configuration(dictionary, "TrackstickMultiplier", &conf.trackstickMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackstickScrollMultiplierX", &conf.trackstickScrollXMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackstickScrollMultiplierY", &conf.trackstickScrollYMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackstickDeadzone", &conf.trackstickDeadzone);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackpointMultiplier", &conf.trackpointMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackpointScrollMultiplierX", &conf.trackpointScrollXMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackpointScrollMultiplierY", &conf.trackpointScrollYMult);
update |= Configuration::loadUInt32Configuration(dictionary, "TrackpointDeadzone", &conf.trackpointDeadzone);
update |= Configuration::loadUInt64Configuration(dictionary, "DisableWhileTypingTimeout", &conf.disableWhileTypingTimeout);
update |= Configuration::loadUInt64Configuration(dictionary, "DisableWhileTrackpointTimeout", &conf.disableWhileTrackpointTimeout);
update |= Configuration::loadUInt32Configuration(dictionary, "ForceTouchMinPressure", &conf.forceTouchMinPressure);
Expand Down
6 changes: 3 additions & 3 deletions VoodooRMI/RMI_2D_Sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ IOReturn RMI2DSensor::message(UInt32 type, IOService *provider, void *argument)
break;
case kKeyboardGetTouchStatus: {
bool *result = (bool *) argument;
*result = touchpadEnable;
*result = trackpadEnable;
break;
}
case kKeyboardSetTouchStatus:
touchpadEnable = *((bool *) argument);
trackpadEnable = *((bool *) argument);
break;
}

Expand All @@ -96,7 +96,7 @@ IOReturn RMI2DSensor::message(UInt32 type, IOService *provider, void *argument)

bool RMI2DSensor::shouldDiscardReport(AbsoluteTime timestamp)
{
return !touchpadEnable
return !trackpadEnable
|| (timestamp - lastKeyboardTS) < conf->disableWhileTypingTimeout * MILLI_TO_NANO
|| (timestamp - lastTrackpointTS) < conf->disableWhileTrackpointTimeout * MILLI_TO_NANO;
}
Expand Down
2 changes: 1 addition & 1 deletion VoodooRMI/RMI_2D_Sensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RMI2DSensor : public IOService {
bool invalidFinger[10];
bool clickpadState {false};
bool pressureLock {false};
bool touchpadEnable {true};
bool trackpadEnable {true};
uint64_t lastKeyboardTS {0}, lastTrackpointTS {0};

MT2FingerType getFingerType();
Expand Down
24 changes: 12 additions & 12 deletions VoodooRMI/rmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

// Message types defined by ApplePS2Keyboard
enum {
// from keyboard to mouse/touchpad
kKeyboardSetTouchStatus = iokit_vendor_specific_msg(100), // set disable/enable touchpad (data is bool*)
kKeyboardGetTouchStatus = iokit_vendor_specific_msg(101), // get disable/enable touchpad (data is bool*)
// from keyboard to mouse/trackpad
kKeyboardSetTouchStatus = iokit_vendor_specific_msg(100), // set disable/enable trackpad (data is bool*)
kKeyboardGetTouchStatus = iokit_vendor_specific_msg(101), // get disable/enable trackpad (data is bool*)
kKeyboardKeyPressTime = iokit_vendor_specific_msg(110) // notify of timestamp a non-modifier key was pressed (data is uint64_t*)
};

Expand Down Expand Up @@ -121,10 +121,10 @@ struct __kfifo {

struct rmi_configuration {
/* F03 */
uint32_t trackstickMult {DEFAULT_MULT};
uint32_t trackstickScrollXMult {DEFAULT_MULT};
uint32_t trackstickScrollYMult {DEFAULT_MULT};
uint32_t trackstickDeadzone {1};
uint32_t trackpointMult {DEFAULT_MULT};
uint32_t trackpointScrollXMult {DEFAULT_MULT};
uint32_t trackpointScrollYMult {DEFAULT_MULT};
uint32_t trackpointDeadzone {1};
/* RMI2DSensor */
bool forceTouchEmulation {true};
uint32_t forceTouchMinPressure {80};
Expand Down Expand Up @@ -215,13 +215,13 @@ struct rmi_2d_axis_alignment {
* available.
* @rmi_f11_sensor_touchscreen - treat the sensor as a touchscreen (direct
* pointing).
* @rmi_f11_sensor_touchpad - thread the sensor as a touchpad (indirect
* @rmi_f11_sensor_trackpad - thread the sensor as a trackpad (indirect
* pointing).
*/
enum rmi_sensor_type {
rmi_sensor_default = 0,
rmi_sensor_touchscreen,
rmi_sensor_touchpad
rmi_sensor_trackpad
};

#define RMI_F11_DISABLE_ABS_REPORT BIT(0)
Expand All @@ -230,16 +230,16 @@ enum rmi_sensor_type {
* struct rmi_2d_sensor_data - overrides defaults for a 2D sensor.
* @axis_align - provides axis alignment overrides (see above).
* @sensor_type - Forces the driver to treat the sensor as an indirect
* pointing device (touchpad) rather than a direct pointing device
* pointing device (trackpad) rather than a direct pointing device
* (touchscreen). This is useful when F11_2D_QUERY14 register is not
* available.
* @disable_report_mask - Force data to not be reported even if it is supported
* by the firware.
* @topbuttonpad - Used with the "5 buttons touchpads" found on the Lenovo 40
* @topbuttonpad - Used with the "5 buttons trackpads" found on the Lenovo 40
* series
* @kernel_tracking - most moderns RMI f11 firmwares implement Multifinger
* Type B protocol. However, there are some corner cases where the user
* triggers some jumps by tapping with two fingers on the touchpad.
* triggers some jumps by tapping with two fingers on the trackpad.
* Use this setting and dmax to filter out these jumps.
* Also, when using an old sensor using MF Type A behavior, set to true to
* report an actual MT protocol B.
Expand Down

0 comments on commit cb78e02

Please sign in to comment.