# MacBook Pro 13 mid 2012 touchpad fine tuning



## Machiaveli (Jun 12, 2020)

Hello folks,

After installing FreeBSD-12.1-RELEASE on a MacBook Pro 13 mid-2012 (MacBookPro9,2 model in Apple's terminology) as the only OS, I've made it working pretty well, thanks to people that make this happens (end of this post to know what's working or not)!
Actually I'm struggling to fine tune the touchpad to make it work as in Mac OS X.

Reading numerous threads on this forum and afaik there's more than one way to configure the touchpad so I'm still confuse as to what I should use to achieve this tuning:

atp(4) (which is what I'm using because it's the driver who gives results close to what I was used to on Mac OS X, except for scrolling)
wsp(4) (which gives the best scrolling with two fingers but couldn't tune it as much as I wanted to)
xorg.conf(5) (a custom InputDevice section on /usr/local/etc/X11/xorg.conf.d/touchpad.conf used in conjunction with `atp(4)`)
synaptics(4) (haven't tried this driver yet)

Configuration of `atp(4)` through `sysctl`:

```
# sysctl hw.usb.atp
hw.usb.atp.stroke_maturity_threshold: 4
hw.usb.atp.slide_min_movement: 1
hw.usb.atp.tap_minimum: 2
hw.usb.atp.small_movement: 40
hw.usb.atp.scale_factor: 20
hw.usb.atp.double_tap_threshold: 200000
hw.usb.atp.touch_timeout: 125000
hw.usb.atp.debug: 1
```

Configuration of `wsp(4)` through `sysctl`:

```
# sysctl hw.usb.wsp
hw.usb.wsp.enable_single_tap_clicks: 1
hw.usb.wsp.scr_hor_threshold: 20
hw.usb.wsp.pressure_tap_threshold: 120
hw.usb.wsp.pressure_untouch_threshold: 10
hw.usb.wsp.pressure_touch_threshold: 50
hw.usb.wsp.z_factor: 5
hw.usb.wsp.scale_factor: 12
hw.usb.wsp.debug: 1
```

Configuration with /usr/local/etc/X11/xorg.conf.d/touchpad.conf:

```
# cat /usr/local/etc/X11/xorg.conf.d/touchpad.conf
Section "InputDevice"
   Identifier  "Mouse0"
   Driver  "mutouch"
   Option    "Protocol" "auto"
   Option    "Device" "/dev/atp0"

   Option  "LeftEdge"  "100"
   Option  "RightEdge"  "1120"
   Option  "TopEdge"  "50"
   Option  "BottomEdge"  "310"
   Option  "FingerLow"  "25"
   Option  "FingerHigh"  "30"
   Option  "MaxTapTime"  "180"
   Option  "MaxTapMove"  "220"
   Option  "MaxDoubleTapTime"  "180"
   Option  "VertScrollDelta"  "20"
   Option  "HorizScrollDelta"  "50"
   Option  "MinSpeed"  "0.79"
   Option  "MaxSpeed"  "0.88"
   Option  "AccelFactor"  "0.0015"
   Option  "SHMConfig"  "on"
EndSection
```

The good things (what's working):

x11/xorg (all is automatically detected \o/ )
backlight and keyboard brightness with /boot/kernel/asmc.ko and sysutils/asmctl (mapped to the corresponding keys in x11-wm/xfce4-wm
suspend/resume (works out of the box)
ambient light sensors
The "bad" things (what isn't working):

Wifi interface (it's a Broadcom BCM4331. It might be supported, thanks to Landon Fuller's great work on bwn(4) and bhnd(4) drivers)
Edit: adding `dmesg`.


----------



## Machiaveli (Jun 21, 2020)

Well after a lot of fiddling, libinput doesn't work at all with the touchpad, no matter what options are used, even the supported one. Might be a bug in how the touchpad is handled by atp(4) or wsp(4) (unloading those and use only libinput lead to no clicks in Xorg).

wsp(4) driver prevents any selection and drag gestures to be made and click detection is fuzzy (with standard sysctl or not through hw.usb.wsp tree). atp(4) provides in this model the most viable option even if scrolling isn't smooth and a real pain to used.

synaptics(4) isn't even recognized by Xorg despite all what's needed is installed.
A mouse is fortunately well supported without any custom settings


----------



## Machiaveli (Jun 24, 2020)

For future reference in case someone else is using this laptop, here are settings making scrolling less painful and fuzzy with the atp driver.

In /etc/sysctl.conf put the following sysctl's MIB:

```
hw.usb.atp.stroke_maturity_threshold: 4
hw.usb.atp.slide_min_movement: 1
hw.usb.atp.tap_minimum: 2
hw.usb.atp.small_movement: 30
hw.usb.atp.scale_factor: 18
hw.usb.atp.double_tap_threshold: 200000
hw.usb.atp.touch_timeout: 125000
```


----------



## TempleBSD (May 19, 2021)

Machiaveli said:


> suspend/resume (works out of the box)


Can't say that about mine sadly. The lid-close event does get detected correctly but nothing happens by default 
Otherwise very similar experience, linking the pr for wsp touchpad driver under 13.0 here too: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252236


----------



## bfm (Jan 15, 2022)

Machiaveli said:


> wsp(4) driver prevents any selection and drag gestures to be made and click detection is fuzzy (with standard sysctl or not through hw.usb.wsp tree). atp(4) provides in this model the most viable option even if scrolling isn't smooth and a real pain to used.


Folks, what's the story with selection and *wsp* driver? I'm trying to make it working on late 2008 Macbook and FreeBSD 12.2-RELEASE and managed to get it as far as two fingers scrolling and decent but not 100% working tap with one and two fingers (sometimes it's refusing to tap first time, I suspect something is in the way and eating the event), but I can't figure out how to select a text. Tried the usual tap and hold one finger while moving the other to select text, but it's either has no effect in terminal and text editors, but it scrolls back and forth in Firefox instead of expected text selection. I'm not sure what am I missing here. Any pointers would be greatly appreciated.

My *xorg.conf* file:

```
Section "ServerFlags"
    Option        "AutoAddDevices"    "False"
EndSection

Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "Screen0" 0 0
    InputDevice    "Touchpad0" "CorePointer"
#    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
    ModulePath   "/usr/local/lib/xorg/modules"
    FontPath     "/usr/local/share/fonts/misc/"
    FontPath     "/usr/local/share/fonts/TTF/"
    FontPath     "/usr/local/share/fonts/OTF/"
    FontPath     "/usr/local/share/fonts/Type1/"
    FontPath     "/usr/local/share/fonts/100dpi/"
    FontPath     "/usr/local/share/fonts/75dpi/"
    FontPath     "catalogue:/usr/local/etc/X11/fontpath.d"
        FontPath "/usr/local/share/fonts/urwfonts/"
EndSection

Section "Module"
    Load  "extmod"
    Load  "glx"
    Load  "freetype"
EndSection

Section "InputDevice"
    Identifier  "Keyboard0"
    Driver      "kbd"
        Option      "XkbRules" "xorg"
        Option      "XkbModel" "macbook79"
    Option      "XkbLayout" "uk"
    Option      "XkbOptions" "terminate:ctrl_alt_bksp,ctrl:nocaps"
EndSection

Section "InputDevice"
   Identifier  "Touchpad0"
   Driver  "mouse"
   Option    "Protocol" "auto"
   Option    "Device" "/dev/wsp0"
EndSection

Section "InputClass"
   Identifier    "Apple Touchpad"
   Driver    "libinput"
   MatchIsTouchpad    "True"
   Option    "Tapping" "on"
   Option    "NaturalScrolling" "on"
    Option  "TappingButtonMap" "lmr"
    Option  "MiddleEmulation" "True"
#   Option    "ClickMethod "clickfinger"
   Option    "Device" "/dev/wsp0"
EndSection

Section "Monitor"
    Identifier   "Monitor0"
    VendorName   "Monitor Vendor"
    ModelName    "Monitor Model"
EndSection

Section "Device"
    Identifier  "Card0"
    Driver      "nvidia"
    BusID       "PCI:2:0:0"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device     "Card0"
    Monitor    "Monitor0"
    DefaultDepth    24
    Option         "AddARGBGLXVisuals" "True"

    SubSection "Display"
        Viewport   0 0
        Depth     1
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     4
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     8
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     15
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Depth     16
    EndSubSection
    SubSection "Display"
        Viewport   0 0
        Modes      "1280x800"
        Depth     24
    EndSubSection
EndSection

Section "Extensions"
    Option         "Composite" "Enable"
EndSection
```


----------



## Machiaveli (Jan 23, 2022)

TempleBSD said:


> Can't say that about mine sadly. The lid-close event does get detected correctly but nothing happens by default
> Otherwise very similar experience, linking the pr for wsp touchpad driver under 13.0 here too: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252236


I've made a wiki entry for my laptop which you can find there settings that make working suspend/resume: https://wiki.freebsd.org/Laptops/Apple_MacBookPro9,2#Suspend.2FResume

bfm: to select text using wsp(4) driver, use 3 fingers to drag (not really convenient due to trackpad's size).


----------

