implement SonarPen
This commit is contained in:
60
libs/libSonarPen/include/WTSonarPenDriver.h
Executable file
60
libs/libSonarPen/include/WTSonarPenDriver.h
Executable file
@@ -0,0 +1,60 @@
|
||||
//
|
||||
// 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);
|
||||
|
||||
28
libs/libSonarPen/include/WTSonarPenTouchesHandler.h
Executable file
28
libs/libSonarPen/include/WTSonarPenTouchesHandler.h
Executable file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// WTSonarPenTouchesHandler.h
|
||||
//
|
||||
// Created by Water Lou on 3/7/15.
|
||||
// Copyright (c) 2015 First Water Tech Ltd. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface WTSonarPenTouchesHandler : NSObject
|
||||
|
||||
- (void)handleTouches:(UIEvent * _Nullable)event
|
||||
view:(UIView * _Nonnull)view
|
||||
penDown:(BOOL)penDownStatus;
|
||||
|
||||
// check if pen is down
|
||||
- (BOOL)isPenDown;
|
||||
// check if touch with large size touch
|
||||
- (BOOL)isPalmTouchedBySize;
|
||||
|
||||
// get pen location if pen is down
|
||||
- (CGPoint)penLocation;
|
||||
// touch object that detect as pen
|
||||
@property(readonly, nullable) UITouch *penTouch;
|
||||
|
||||
- (NSInteger)numberOfTouches;
|
||||
|
||||
@end
|
||||
BIN
libs/libSonarPen/libSonarPenUniversal.a
Executable file
BIN
libs/libSonarPen/libSonarPenUniversal.a
Executable file
Binary file not shown.
Reference in New Issue
Block a user