Skip to content

Instantly share code, notes, and snippets.

#import <AudioToolbox/AudioToolbox.h>
void AudioServicesPlaySystemSoundWithVibration(SystemSoundID inSystemSoundID,id arg,NSDictionary* vibratePattern);
let vibe: NSArray = [true, 1000, false, 250, true, 1200]
let dict = [
"Intensity": 0.7,
"VibePattern": vibe
] as [String : Any]
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dict)
import CoreHaptics
func playHapticsFile() {
guard let url = Bundle.main.url(forResource: "myfile", withExtension: "ahap") else {
print("could not load file")
return
}
do {
@nthState
nthState / PlayPattern.swift
Created June 25, 2021 09:18
Play Haptics with Syncing to Haptrix macOS App
import CoreHaptics
import HaptrixSync
func playHapticsFile() {
guard let url = Bundle.main.url(forResource: "myfile", withExtension: "ahap") else {
print("could not load file")
return
}
@nthState
nthState / PlayStation5DualSenseCoreHaptics.swift
Created July 2, 2021 19:55
Run Core Haptics on PS5 Dual Sense
import Foundation
import GameController
import CoreHaptics
/**
Ensure the controller supports Haptics, then play
*/
class PlayStationHaptics {
var engine: CHHapticEngine?
@nthState
nthState / combineVSAsyncAwait
Last active August 15, 2022 12:17
CombineVsAsyncAwait
struct Product: Decodable {
let title: String
}
class MyCombine {
func getWithCombine() -> AnyPublisher<Product, Error> {
let url = URL(string: "https://dummyjson.com/products/1")!