OpenMultitouchSupport

repository·main·Indexed 42 days ago

https://github.com/kyome22/openmultitouchsupport

A Swift library for observing global multitouch events on the default macOS trackpad by wrapping the private MultitouchSupport.framework. Requires macOS 15.0+, Xcode 26.2+, and the App Sandbox to be disabled. Provides the OMSManager class and OMSTouchData structures to track touch position, pressure, angle, and state.

Tokens
733
Snippets
2
Records
3
Agent score
4%

What's inside OpenMultitouchSupport

  1. Use OpenMultitouchSupport to observe trackpad events

    main

    OpenMultitouchSupport allows you to observe global multitouch events on the default trackpad by providing a wrapper around the private MultitouchSupport.framework.

    Important Requirement: You must disable App Sandbox in your Xcode project settings to use this library, as it observes global events.

    import OpenMultitouchSupport
    
    let manager = OMSManager.shared()
    
    Task { [weak self, manager] in
        for await touchData in manager.touchDataStream {
            // use touchData
        }
    }
    
    manager.startListening()
    manager.stopListening()
  2. Reference the OMSTouchData data structures

    main

    The library provides several Sendable structs and enums to describe touch information. Each OMSTouchData object received from the touchDataStream contains the following properties:

    • id: Unique identifier for the touch.
    • position: An OMSPosition containing x and y (Float).
    • total: Total value of capacitance (Float).
    • pressure: Pressure applied (Float).
    • axis: An OMSAxis containing major and minor (Float).
    • angle: Finger angle (Float).
    • density: Area density of capacitance (Float).
    • state: The current OMSState of the touch.
    • timestamp: A string representing the event time.
    struct OMSPosition: Sendable {
        var x: Float
        var y: Float
    }
    
    struct OMSAxis: Sendable {
        var major: Float
        var minor: Float
    }
    
    enum OMSState: String, Sendable {
        case notTouching
        case starting
        case hovering
        case making
        case touching
        case breaking
        case lingering
        case leaving
    }
    
    struct OMSTouchData: Sendable {
        var id: Int32
        var position: OMSPosition
        var total: Float // total value of capacitance
        var pressure: Float
        var axis: OMSAxis
        var angle: Float // finger angle
        var density: Float // area density of capacitance
        var state: OMSState
        var timestamp: String
    }