Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/CoreHaptics/Enums.cs b/src/CoreHaptics/Enums.cs
- new file mode 100644
- index 000000000..ad79f9bb2
- --- /dev/null
- +++ b/src/CoreHaptics/Enums.cs
- @@ -0,0 +1,144 @@
- +//
- +// CoreHaptics C# bindings
- +//
- +// Authors:
- +// Manuel de la Pena Saenz <mandel@microsoft.com>
- +//
- +// Copyright 2019 Microsoft Corporation All rights reserved.
- +//
- +using System;
- +using Foundation;
- +using ObjCRuntime;
- +
- +namespace CoreHaptics {
- +
- + [Mac (10, 15), iOS (13, 0)]
- + public enum CHHapticEventParameterId {
- + [Field ("CHHapticEventParameterIDHapticIntensity")]
- + HapticIntensity,
- +
- + [Field ("CHHapticEventParameterIDHapticSharpness")]
- + HapticSharpness,
- +
- + [Field ("CHHapticEventParameterIDAttackTime")]
- + AttackTime,
- +
- + [Field ("CHHapticEventParameterIDDecayTime")]
- + DecayTime,
- +
- + [Field ("CHHapticEventParameterIDReleaseTime")]
- + ReleaseTime,
- +
- + [Field ("CHHapticEventParameterIDSustained")]
- + Sustained,
- +
- + [Field ("CHHapticEventParameterIDAudioVolume")]
- + AudioVolume,
- +
- + [Field ("CHHapticEventParameterIDAudioPitch")]
- + AudioPitch,
- +
- + [Field ("CHHapticEventParameterIDAudioPan")]
- + AudioPan,
- +
- + [Field ("CHHapticEventParameterIDAudioBrightness")]
- + AudioBrightness,
- + }
- +
- + [Mac (10, 15), iOS (13, 0)]
- + public enum CHHapticDynamicParameterId {
- + [Field ("CHHapticDynamicParameterIDHapticIntensityControl")]
- + HapticDynamicParameterIDHapticIntensityControl,
- +
- + [Field ("CHHapticDynamicParameterIDHapticSharpnessControl")]
- + HapticSharpnessControl,
- +
- + [Field ("CHHapticDynamicParameterIDHapticAttackTimeControl")]
- + HapticAttackTimeControl,
- +
- + [Field ("CHHapticDynamicParameterIDHapticDecayTimeControl")]
- + HapticDecayTimeControl,
- +
- + [Field ("CHHapticDynamicParameterIDHapticReleaseTimeControl")]
- + HapticReleaseTimeControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioVolumeControl")]
- + AudioVolumeControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioPanControl")]
- + AudioPanControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioBrightnessControl")]
- + AudioBrightnessControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioPitchControl")]
- + AudioPitchControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioAttackTimeControl")]
- + AudioAttackTimeControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioDecayTimeControl")]
- + AudioDecayTimeControl,
- +
- + [Field ("CHHapticDynamicParameterIDAudioReleaseTimeControl")]
- + AudioReleaseTimeControl,
- + }
- +
- + [Mac (10, 15), iOS (13, 0)]
- + public enum CHHapticEventType {
- + [Field ("CHHapticEventTypeHapticTransient")]
- + HapticTransient,
- +
- + [Field ("CHHapticEventTypeHapticContinuous")]
- + HapticContinuous,
- +
- + [Field ("CHHapticEventTypeAudioContinuous")]
- + AudioContinuous,
- +
- + [Field ("CHHapticEventTypeAudioCustom")]
- + AudioCustom,
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [Native]
- + public enum CHHapticErrorCode : long {
- + EngineNotRunning = -4805,
- + OperationNotPermitted = -4806,
- + EngineStartTimeout = -4808,
- + NotSupported = -4809,
- + ServerInitFailed = -4810,
- + ServerInterrupted = -4811,
- + InvalidPatternPlayer = -4812,
- + InvalidPatternData = -4813,
- + InvalidPatternDictionary = -4814,
- + InvalidAudioSession = -4815,
- + InvalidParameterType = -4820,
- + InvalidEventType = -4821,
- + InvalidEventTime = -4822,
- + InvalidEventDuration = -4823,
- + InvalidAudioResource = -4824,
- + ResourceNotAvailable = -4825,
- + BadEventEntry = -4830,
- + BadParameterEntry = -4831,
- + InvalidTime = -4840,
- + UnknownError = -4898,
- + MemoryError = -4899,
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [Native]
- + public enum CHHapticEngineFinishedAction : long {
- + StopEngine = 1,
- + LeaveEngineRunning = 2
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [Native]
- + public enum CHHapticEngineStoppedReason : long {
- + AudioSessionInterrupt = 1,
- + ApplicationSuspended = 2,
- + IdleTimeout = 3,
- + NotifyWhenFinished = 4,
- + SystemError = -1,
- + }
- +}
- \ No newline at end of file
- diff --git a/src/corehaptics.cs b/src/corehaptics.cs
- new file mode 100644
- index 000000000..cc250153a
- --- /dev/null
- +++ b/src/corehaptics.cs
- @@ -0,0 +1,393 @@
- +//
- +// CoreHaptics C# bindings
- +//
- +// Authors:
- +// Manuel de la Pena Saenz <mandel@microsoft.com>
- +//
- +// Copyright 2019 Microsoft Corporation All rights reserved.
- +//
- +
- +using System;
- +
- +#if !MONOMAC
- +using AVFoundation;
- +#endif
- +using CoreFoundation;
- +using Foundation;
- +using ObjCRuntime;
- +
- +namespace CoreHaptics {
- +
- +#if MONOMAC
- + interface AVAudioSession {}
- +#endif
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticEventParameter {
- + [BindAs (typeof (CHHapticEventParameterId))]
- + [Export ("parameterID")]
- + NSString ParameterId { get; }
- +
- + [Export ("value")]
- + float Value { get; set; }
- +
- + [Export ("initWithParameterID:value:")]
- + [DesignatedInitializer]
- + IntPtr Constructor ([BindAs (typeof (CHHapticEventParameterId))] NSString parameterId, float value);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticDynamicParameter {
- + [BindAs (typeof (CHHapticDynamicParameterId))]
- + [Export ("parameterID")]
- + NSString ParameterId { get; }
- +
- + [Export ("value")]
- + float Value { get; set; }
- +
- + [Export ("relativeTime")]
- + double RelativeTime { get; set; }
- +
- + [Export ("initWithParameterID:value:relativeTime:")]
- + [DesignatedInitializer]
- + IntPtr Constructor ([BindAs (typeof (CHHapticDynamicParameterId))] NSString parameterId, float value, double time);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticParameterCurveControlPoint {
- + [Export ("relativeTime")]
- + double RelativeTime { get; set; }
- +
- + [Export ("value")]
- + float Value { get; set; }
- +
- + [Export ("initWithRelativeTime:value:")]
- + [DesignatedInitializer]
- + IntPtr Constructor (double time, float value);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticParameterCurve {
- + [BindAs (typeof (CHHapticDynamicParameterId))]
- + [Export ("parameterID")]
- + NSString ParameterId { get; }
- +
- + [Export ("relativeTime")]
- + double RelativeTime { get; set; }
- +
- + [Export ("controlPoints")]
- + CHHapticParameterCurveControlPoint[] ControlPoints { get; }
- +
- + [Export ("initWithParameterID:controlPoints:relativeTime:")]
- + [DesignatedInitializer]
- + IntPtr Constructor ([BindAs (typeof (CHHapticDynamicParameterId))]NSString parameterID, CHHapticParameterCurveControlPoint[] controlPoints, double relativeTime);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticEvent {
- + [BindAs (typeof (CHHapticEventType))]
- + [Export ("type")]
- + NSString Type { get; }
- +
- + [Export ("eventParameters")]
- + CHHapticEventParameter[] EventParameters { get; }
- +
- + [Export ("relativeTime")]
- + double RelativeTime { get; set; }
- +
- + [Export ("duration")]
- + double Duration { get; set; }
- +
- + [Export ("initWithEventType:parameters:relativeTime:")]
- + IntPtr Constructor ([BindAs (typeof (CHHapticEventType))] NSString type, CHHapticEventParameter[] eventParams, double time);
- +
- + [Export ("initWithEventType:parameters:relativeTime:duration:")]
- + IntPtr Constructor ([BindAs (typeof (CHHapticEventType))] NSString type, CHHapticEventParameter[] eventParams, double time, double duration);
- +
- + [Export ("initWithAudioResourceID:parameters:relativeTime:")]
- + IntPtr Constructor (nuint resourceId, CHHapticEventParameter[] eventParams, double time);
- +
- + [Export ("initWithAudioResourceID:parameters:relativeTime:duration:")]
- + IntPtr Constructor (nuint resourceId, CHHapticEventParameter[] eventParams, double time, double duration);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [Protocol]
- + [BaseType (typeof(NSObject))]
- + interface CHHapticParameterAttributes {
- + [Abstract]
- + [Export ("minValue")]
- + float MinValue { get; }
- +
- + [Abstract]
- + [Export ("maxValue")]
- + float MaxValue { get; }
- +
- + [Abstract]
- + [Export ("defaultValue")]
- + float DefaultValue { get; }
- + }
- +
- + interface ICHHapticDeviceCapability { }
- +
- + [iOS (13,0)]
- + [Protocol]
- + interface CHHapticDeviceCapability {
- + [Abstract]
- + [Export ("supportsHaptics")]
- + bool SupportsHaptics { get; }
- +
- + [Abstract]
- + [Export ("supportsAudio")]
- + bool SupportsAudio { get; }
- +
- + // Protocols do not like BindAs yet we know is the enum CHHapticEventType
- + [Abstract]
- + [Export ("attributesForEventParameter:eventType:error:")]
- + [return: NullAllowed]
- + CHHapticParameterAttributes GetAttributes (string eventParameter, string type, [NullAllowed] out NSError outError);
- +
- + // Protocols do not like BindAs yet we know is the enum CHHapticEventType
- + [Abstract]
- + [Export ("attributesForDynamicParameter:error:")]
- + [return: NullAllowed]
- + CHHapticParameterAttributes GetAttributes (string eventParameter, [NullAllowed] out NSError outError);
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [Protocol]
- + [BaseType (typeof(NSObject))]
- + interface CHHapticPatternPlayer {
- + [Abstract]
- + [Export ("startAtTime:error:")]
- + bool StartAtTime (double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("stopAtTime:error:")]
- + bool StopAtTime (double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("sendParameters:atTime:error:")]
- + bool Send (CHHapticDynamicParameter[] parameters, double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("scheduleParameterCurve:atTime:error:")]
- + bool Schedule (CHHapticParameterCurve parameterCurve, double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("cancelAndReturnError:")]
- + bool Cancel ([NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("isMuted")]
- + bool IsMuted { get; set; }
- + }
- +
- + interface ICHHapticAdvancedPatternPlayer {}
- +
- + [Mac (10,15), iOS (13,0)]
- + [Protocol]
- + interface CHHapticAdvancedPatternPlayer : CHHapticPatternPlayer {
- + [Abstract]
- + [Export ("pauseAtTime:error:")]
- + bool Pause (double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("resumeAtTime:error:")]
- + bool Resume (double time, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("seekToOffset:error:")]
- + bool Seek (double offsetTime, [NullAllowed] out NSError outError);
- +
- + [Abstract]
- + [Export ("loopEnabled")]
- + bool LoopEnabled { get; set; }
- +
- + [Abstract]
- + [Export ("loopEnd")]
- + double LoopEnd { get; set; }
- +
- + [Abstract]
- + [Export ("playbackRate")]
- + float PlaybackRate { get; set; }
- +
- + [Abstract]
- + [Export ("completionHandler", ArgumentSemantic.Assign)]
- + Action<NSError> CompletionHandler { get; set; }
- + }
- +
- + [NoMac, iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticEngine
- + {
- + [Static]
- + [Export ("capabilitiesForHardware")]
- + ICHHapticDeviceCapability CapabilitiesForHardware { get; }
- +
- + [Export ("currentTime")]
- + double CurrentTime { get; }
- +
- + [Export ("stoppedHandler", ArgumentSemantic.Assign)]
- + Action<CHHapticEngineStoppedReason> StoppedHandler { get; set; }
- +
- + [Export ("resetHandler", ArgumentSemantic.Assign)]
- + Action ResetHandler { get; set; }
- +
- + [Export ("playsHapticsOnly")]
- + bool PlaysHapticsOnly { get; set; }
- +
- + [Export ("isMutedForAudio")]
- + bool IsMutedForAudio { get; set; }
- +
- + [Export ("isMutedForHaptics")]
- + bool IsMutedForHaptics { get; set; }
- +
- + [Export ("autoShutdownEnabled")]
- + bool AutoShutdownEnabled { [Bind ("isAutoShutdownEnabled")] get; set; }
- +
- + [Export ("initAndReturnError:")]
- + [DesignatedInitializer]
- + IntPtr Constructor ([NullAllowed] out NSError error);
- +/*
- + [Export ("initWithAudioSession:error:")]
- + [DesignatedInitializer]
- + IntPtr Constructor ([NullAllowed] AVAudioSession audioSession, [NullAllowed] out NSError error);
- +*/
- +
- + [Export ("startWithCompletionHandler:")]
- + void Start ([NullAllowed] Action<NSError> completionHandler);
- +
- + [Export ("startAndReturnError:")]
- + bool Start ([NullAllowed] out NSError outError);
- +
- + [Export ("stopWithCompletionHandler:")]
- + void Stop ([NullAllowed] Action<NSError> completionHandler);
- +
- + [Export ("notifyWhenPlayersFinished:")]
- + void NotifyWhenPlayersFinished (Action<NSError> finishedHandler);
- +
- + [Export ("createPlayerWithPattern:error:")]
- + [return: NullAllowed]
- + CHHapticPatternPlayer CreatePlayer (CHHapticPattern pattern, [NullAllowed] out NSError outError);
- +
- + [Export ("createAdvancedPlayerWithPattern:error:")]
- + [return: NullAllowed]
- + ICHHapticAdvancedPatternPlayer CreateAdvancedPlayer (CHHapticPattern pattern, [NullAllowed] out NSError outError);
- +
- + [Export ("registerAudioResource:options:error:")]
- + nuint RegisterAudioResource (NSUrl resourceUrl, NSDictionary options, [NullAllowed] out NSError outError);
- +
- + [Export ("unregisterAudioResource:error:")]
- + bool UnregisterAudioResource (nuint resourceId, [NullAllowed] out NSError outError);
- +
- + [Export ("playPatternFromURL:error:")]
- + bool PlayPattern (NSUrl fileUrl, [NullAllowed] out NSError outError);
- +
- + [Export ("playPatternFromData:error:")]
- + bool PlayPattern (NSData data, [NullAllowed] out NSError outError);
- + }
- +
- + [Static]
- + [Internal]
- + [Mac (10,15), iOS (13,0)]
- + partial interface CHHapticPatternDefinitionKeys {
- + [Field ("CHHapticPatternKeyVersion")]
- + NSString VersionKey { get; }
- +
- + [Field ("CHHapticPatternKeyPattern")]
- + NSString PatternKey { get; }
- +
- + [Field ("CHHapticPatternKeyEvent")]
- + NSString EventKey { get; }
- +
- + [Field ("CHHapticPatternKeyEventType")]
- + NSString EventTypeKey { get; }
- +
- + [Field ("CHHapticPatternKeyTime")]
- + NSString TimeKey { get; }
- +
- + [Field ("CHHapticPatternKeyEventDuration")]
- + NSString EventDurationKey { get; }
- +
- + [Field ("CHHapticPatternKeyEventWaveformPath")]
- + NSString EventWaveformPathKey { get; }
- +
- + [Field ("CHHapticPatternKeyEventParameters")]
- + NSString EventParametersKey { get; }
- +
- + [Field ("CHHapticPatternKeyParameter")]
- + NSString ParameterKey { get; }
- +
- + [Field ("CHHapticPatternKeyParameterID")]
- + NSString ParameterIdKey { get; }
- +
- + [Field ("CHHapticPatternKeyParameterValue")]
- + NSString ParameterValueKey { get; }
- +
- + [Field ("CHHapticPatternKeyParameterCurve")]
- + NSString ParameterCurveKey { get; }
- +
- + [Field ("CHHapticPatternKeyParameterCurveControlPoints")]
- + NSString ParameterCurveControlPointsKey { get; }
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [StrongDictionary ("CHHapticPatternDefinitionKeys")]
- + partial interface CHHapticPatternDefinition {
- + double Version { get; set; }
- + NSArray Pattern { get; set; }
- + NSDictionary Event { get; set; }
- + CHHapticEventType EventType { get; set; }
- + double Time { get; set; }
- + double EventDuration { get; set; }
- + NSString EventWaveformPath { get; set; }
- + NSArray EventParameters { get; set; }
- + NSDictionary Parameter { get; set; }
- + // we need to do a NSString because it can be a CHHapticEventParameterID or a CHHapticDynamicParameterID
- + // which are two different enums. User will have to do the conversion
- + NSString ParameterId { get; set; }
- + double ParameterValue { get; set; }
- + // we do not have docs or header information about the exact type
- + NSObject ParameterCurve { get; set; }
- + NSObject ParameterCurveControlPoints { get; set; }
- + }
- +
- + [Mac (10,15), iOS (13,0)]
- + [BaseType (typeof(NSObject))]
- + [DisableDefaultCtor]
- + interface CHHapticPattern {
- + [Export ("duration")]
- + double Duration { get; }
- +
- + [Export ("initWithEvents:parameters:error:")]
- + IntPtr Constructor (CHHapticEvent[] events, CHHapticDynamicParameter[] parameters, [NullAllowed] out NSError outError);
- +
- + [Export ("initWithEvents:parameterCurves:error:")]
- + IntPtr Constructor (CHHapticEvent[] events, CHHapticParameterCurve[] parameterCurves, [NullAllowed] out NSError outError);
- +
- + [Export ("initWithDictionary:error:")]
- + IntPtr Constructor (NSDictionary patternDict, [NullAllowed] out NSError outError);
- +
- + [Wrap ("this (patternDefinition?.Dictionary, out outError)")]
- + IntPtr Constructor (CHHapticPatternDefinition patternDefinition, [NullAllowed] out NSError outError);
- +
- + [Export ("exportDictionaryAndReturnError:")]
- + [return: NullAllowed]
- + NSDictionary<NSString, NSObject> _ExportDictionary ([NullAllowed] out NSError outError);
- +
- + [Wrap ("new CHHapticPatternDefinition (_ExportDictionary (out outError))")]
- + CHHapticPatternDefinition ExportDictionary ([NullAllowed] out NSError outError);
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement