Giter VIP home page Giter VIP logo

unihaptic's Introduction

UniHaptic: Unified API for Haptic Feedback & Vibration

iOS 7+ Swift 5.1 Swift Package Manager License: MIT

Unified API for CHHapticEngine /UIFeedbackGenerator haptic feedback and AudioToolbox vibration. Supports from iOS 13 all the way down to iOS 7.

Installation

Use Swift Package Manager though Xcode 11. Simply go to File -> Swift Packages -> Add Package Dependency... and paste the URL of this repo.

Usage

The API is meant to be as simple as possible. First do your import:

import UniHaptic

and then simply call it:

UniHaptic().vibrate()

You can have more control by initializing the UniHaptic class with a specific style of vibration like this (UniHaptic(style: .impact). The available options are:

  • selection
  • impact
  • notification
  • custom

If you don't provide any option the default will be .selection.

You also have the option to provice specific intensity and sharpness to vibrate:

UniHaptic().vibrate(intensity: 0.7, sharpness: 0.7)

Sharpness is only used if UniHaptic was initialized with .custom style.

Minimize Latency

The above example while being simple it does not provide the lowest possible latency. To get minimal latency initialize Unihaptic in a separate call and store its instance:

class MyClass {
    var unihaptic = UniHaptic()

    func myFunction() {
        unihaptic.vibrate()
    }
}

Then when you call vibrate() the latency will be the lowest possible as the Haptic Engine is prepared. For more information read here.

Project Status

The project is in its early steps. It is perfectly usable as it is but the API might change.

unihaptic's People

Contributors

fotidim avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

hoangdinhtho

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.