61 lines
2.0 KiB
Objective-C
Executable File
61 lines
2.0 KiB
Objective-C
Executable File
//
|
|
// WTSonarPenDriver.h
|
|
//
|
|
// Created by Water Lou on 8/7/14.
|
|
// Copyright (c) 2014 First Water Tech Ltd. All rights reserved.
|
|
//
|
|
|
|
#import <UIKit/UIKit.h>
|
|
#import <AVFoundation/AVFoundation.h>
|
|
|
|
extern NSString *const _Nonnull WTSonarPenDriverStateChangedNotification;
|
|
|
|
typedef NS_ENUM(NSInteger, WTAudioPenDriverState) {
|
|
WTSonarPenDriverStateInit = 0, // wait for pen attach
|
|
WTSonarPenDriverStateCalibrating = 1, // calc min value (when audio source just switched
|
|
WTSonarPenDriverStateRunning = 2, // running
|
|
WTSonarPenDriverStateCalibratingMax = 3, // calibrating max value
|
|
WTSonarPenDriverStateNotSonarPen = 4, // headphone plugged but no a sonarpen, audio sound disabled
|
|
WTSonarPenDriverStateWaitingForPermission = 5, // starting, wait for user permission for microphone
|
|
WTSonarPenDriverStateNoMicrophonePermission = 6, // no started, no microphone permission
|
|
};
|
|
|
|
@class WTSonarPenDriver;
|
|
|
|
@protocol WTSonarPenDriverDelegate<NSObject>
|
|
@optional
|
|
- (void)sonarPenButtonPressed:(WTSonarPenDriver* _Nonnull)driver;
|
|
@end
|
|
|
|
|
|
|
|
@interface WTSonarPenDriver : NSObject
|
|
|
|
- (instancetype _Nonnull)init NS_UNAVAILABLE; // please call initWithApplication instead
|
|
- (instancetype _Nonnull) initWithApplication: (UIApplication * _Nullable)application NS_DESIGNATED_INITIALIZER;
|
|
|
|
- (void) start;
|
|
- (void) stop;
|
|
|
|
- (BOOL) isPenDown; // is pen touched
|
|
- (CGFloat) pressure; // current pressure
|
|
- (BOOL) isPenAttached;
|
|
- (WTAudioPenDriverState) state; // pen drive state
|
|
|
|
/// If button on the pen is pressed
|
|
- (BOOL) isButtonDown;
|
|
|
|
// set to YES, the driver will use current pressure as idle state value
|
|
// developer can set this to YES will no touch is detected, and NO with touch
|
|
@property (nonatomic) BOOL calibratingIdleValue;
|
|
@property (nonatomic) BOOL shouldCheckPenOnStart; // detect pen when plug
|
|
|
|
@property (nonatomic, weak, nullable) id <WTSonarPenDriverDelegate> delegate;
|
|
|
|
//- (void)startFullCalibration;
|
|
|
|
@end
|
|
|
|
BOOL isHeadphoneplugged(AVAudioSessionRouteDescription * _Nonnull route);
|
|
|