Skip to content

ofWorks/ofxMacTrackpadPressure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

ofxMacTrackpadPressure

macOS trackpad pressure / Force Touch support for openFrameworks.

Files

ofxMacTrackpadPressure/
├── addon_config.mk
├── src/
│   ├── ofxMacTrackpadPressure.h      // C++ header (clean, no Obj-C)
│   └── ofxMacTrackpadPressure.mm     // Objective-C++ implementation
└── example-pressure-drawing/
    └── src/
        ├── main.cpp
        ├── ofApp.h
        └── ofApp.cpp

Installation

  1. Copy ofxMacTrackpadPressure/ to your openFrameworks/addons/ folder
  2. Generate your project with Project Generator, include this addon
  3. Or manually add the .h and .mm files to your Xcode project

Usage

#include "ofxMacTrackpadPressure.h"

ofxMacTrackpadPressure pressure;

void ofApp::setup() {
    pressure.setup();
    pressure.setEnabled(true);
    ofAddListener(pressure.pressureChanged, this, &ofApp::onPressureChanged);
}

void ofApp::onPressureChanged(ofxTrackpadPressureEventArgs& args) {
    float p = args.pressure;  // 1.0 = normal click, up to ~5.0 deep press
}

Key Points

  • macOS only — uses NSEvent pressure API
  • Force Touch required for variable pressure; normal trackpads return 1.0
  • Events fire alongside standard OF mouseDragged — both work simultaneously
  • Pressure is accumulated delta from baseline 1.0, not absolute

Controls (example)

  • C — clear canvas
  • Space — toggle pressure tracking on/off
  • Click-and-drag — draw with pressure-sensitive width
  • Deep press (Force Touch) — wider strokes

About

pressure sensitive touchpad in macOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors