{"id":15416858,"url":"https://github.com/ussserrr/trackpad-joystick","last_synced_at":"2025-04-26T11:32:06.949Z","repository":{"id":45671972,"uuid":"165754623","full_name":"ussserrr/trackpad-joystick","owner":"ussserrr","description":"Use Mac trackpad as a joystick","archived":false,"fork":false,"pushed_at":"2019-02-03T20:31:39.000Z","size":25145,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-25T20:08:11.731Z","etag":null,"topics":["cocoa","joystick","trackpad"],"latest_commit_sha":null,"homepage":"https://youtu.be/0sfYmIgf8cU","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ussserrr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-15T00:02:50.000Z","updated_at":"2022-07-14T16:49:40.000Z","dependencies_parsed_at":"2022-08-28T16:41:21.796Z","dependency_job_id":null,"html_url":"https://github.com/ussserrr/trackpad-joystick","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ussserrr%2Ftrackpad-joystick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ussserrr%2Ftrackpad-joystick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ussserrr%2Ftrackpad-joystick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ussserrr%2Ftrackpad-joystick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ussserrr","download_url":"https://codeload.github.com/ussserrr/trackpad-joystick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224032184,"owners_count":17244373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoa","joystick","trackpad"],"created_at":"2024-10-01T17:14:02.326Z","updated_at":"2024-11-11T01:15:50.541Z","avatar_url":"https://github.com/ussserrr.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"![title](/title.png)\n\n![demo](/demo.gif)\n\nExample of how to use MacBook's or Apple Magic Trackpad not for a positioning of the cursor but for getting an absolute coordinates of touches - i.e. as a joystick.\n\nThe project ([`TrackpadJoystick.swift`](/trackpad-joystick/TrackpadJoystick.swift)) is combined with a simple example ([`ViewController.swift`](/trackpad-joystick/ViewController.swift)) - sending a coordinates over an UDP socket. See [wifi-car](https://github.com/ussserrr/wifi-car) for the counterpart.\n\n\n## Overview\n\nThe idea behind the application is to use a custom view - subclass of `NSView` - to receive one touch at a time. To emulate a real joystick behavior touches are allowed to begin only from the center of he trackpad - in a circle with `stickStartPositionRadius` radius. Also, after releasing a finger from the panel the stick is automatically returning to the start position.\n\nCoordinates are retrieving in a real time on every request to the `TrackpadJoystick.centeredCoords` member.\n\nTo prevent distractions in cases when the window is losing focus the app is running itself in a fullscreen mode (use Cmd+Q to exit). Currently, I haven't found a simple way to make an `NSView` a fully transparent overlay in a fullscreen mode to place other UI elements behind it and not rely on them in the main `TrackpadJoystick` class. So if you want any additional UI components please put them in this class.\n\n\n## Installation\n\nTrackpadJoystick itself has no dependencies although the example has one - it uses [IBM-Swift/BlueSocket](https://github.com/IBM-Swift/BlueSocket) as a simple socket framework:\n\n - Install IBM-Swift/BlueSocket via Carthage (`carthage update`) and embed them in your build target\n - Turn on network connections (Project settings -\u003e Capabilities -\u003e App Sandbox -\u003e Network)\n - Create and configure your desired UI and outlets in the Interface Builder\n\n\n## Usage\n\nSee ([`ViewController.swift`](/trackpad-joystick/ViewController.swift)) to see a concept of how to instantiate and use the joystick. In two words, you need to:\n\n```swift\n// create one\n@IBOutlet weak var trackpadJoystick: TrackpadJoystick!\n// retrieve coordinates\nlet c = trackpadJoystick.centeredCoords\nprint(\"x = \\(c.x), y = \\(c.y)\")\n```\n\n*Centered* means that the center of the trackpad is considered an origin point `(0.0; 0.0)` and the range for both X and Y axes is `[-1.0; 1.0]`. There are some another initialization and converting methods available through the `CenteredCoords` interface such as `toNormalized()`, `toScreenCoords()`.\n\n\n## TODOs\n\nCheck for TODOs all over the code to get the insight of what would be great to do.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fussserrr%2Ftrackpad-joystick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fussserrr%2Ftrackpad-joystick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fussserrr%2Ftrackpad-joystick/lists"}