implement SonarPen
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
- (BOOL)application:(UIApplication *)app
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options;
|
||||
- (float)sonarpen_pressure;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#import "AppDelegate.h"
|
||||
#import "GameViewController.h"
|
||||
#include "app.h"
|
||||
#include <WTSonarPenDriver.h>
|
||||
|
||||
void global_exception_handler(NSException* e)
|
||||
{
|
||||
@@ -28,6 +29,7 @@ void global_signal_handler(int e)
|
||||
|
||||
@interface AppDelegate () {
|
||||
GameViewController* view;
|
||||
WTSonarPenDriver* sonarpen_driver;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -40,9 +42,38 @@ void global_signal_handler(int e)
|
||||
return true;
|
||||
}
|
||||
|
||||
- (float)sonarpen_pressure
|
||||
{
|
||||
return [sonarpen_driver isPenAttached] ? [sonarpen_driver pressure] : 1.f;
|
||||
}
|
||||
|
||||
- (void)penStatusChanged
|
||||
{
|
||||
switch (sonarpen_driver.state) {
|
||||
case WTSonarPenDriverStateInit:
|
||||
NSLog(@"Status: Initializing"); break;
|
||||
case WTSonarPenDriverStateRunning:
|
||||
NSLog(@"Status: Running"); break;
|
||||
case WTSonarPenDriverStateCalibrating:
|
||||
NSLog(@"Status: Calibrating"); break;
|
||||
case WTSonarPenDriverStateNotSonarPen:
|
||||
NSLog(@"Status: Not a Sonar Pen"); break;
|
||||
case WTSonarPenDriverStateCalibratingMax:
|
||||
NSLog(@"Status: Calibrating Max Value"); break;
|
||||
case WTSonarPenDriverStateWaitingForPermission:
|
||||
NSLog(@"Status: Wait for Permission"); break;
|
||||
case WTSonarPenDriverStateNoMicrophonePermission:
|
||||
NSLog(@"Status: No Microphone Permission"); break;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
// Override point for customization after application launch.
|
||||
NSSetUncaughtExceptionHandler(&global_exception_handler);
|
||||
sonarpen_driver = [[WTSonarPenDriver alloc] initWithApplication:application];
|
||||
[sonarpen_driver start];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(penStatusChanged) name:WTSonarPenDriverStateChangedNotification object:nil];
|
||||
|
||||
view = (GameViewController*)self.window.rootViewController;
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <GLKit/GLKit.h>
|
||||
#import "AppDelegate.h"
|
||||
|
||||
@interface GameViewController : GLKViewController <UIKeyInput,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
|
||||
{
|
||||
|
||||
@@ -276,6 +276,8 @@ std::set<UITouch*> ignored_touch;
|
||||
UITouch *touch = valid_touches[0];
|
||||
CGPoint touchLocation = [touch locationInView:self.view];
|
||||
float force = touch.type == UITouchType::UITouchTypeStylus ? touch.force : 1.0f;
|
||||
AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
||||
force = [app sonarpen_pressure];
|
||||
if (t_count == 2)
|
||||
{
|
||||
//App::I.gesture_end();
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
<true/>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>Export the panoramic to the gallery</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>Use the audio jack for the SonarPen</string>
|
||||
<key>UIFileSharingEnabled</key>
|
||||
<true/>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
|
||||
@@ -234,6 +234,10 @@
|
||||
ADD7D2AF1EBFA35F00D5A897 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */; };
|
||||
ADD7D2B11EBFA42600D5A897 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2B01EBFA42600D5A897 /* libz.tbd */; };
|
||||
ADD7D2B31EBFA42C00D5A897 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADD7D2B21EBFA42C00D5A897 /* Security.framework */; };
|
||||
ADE0862D212395B600945972 /* libSonarPenUniversal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADE0862C212395B500945972 /* libSonarPenUniversal.a */; };
|
||||
ADE0862F21239C9200945972 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADE0862E21239C9100945972 /* AudioToolbox.framework */; };
|
||||
ADE0863121239CDA00945972 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADE0863021239CD900945972 /* MediaPlayer.framework */; };
|
||||
ADE0863321239D0700945972 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ADE0863221239D0700945972 /* Accelerate.framework */; };
|
||||
ADE22BE5211904AB00D5F44B /* node_panel_grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADE22BE3211904AA00D5F44B /* node_panel_grid.cpp */; };
|
||||
ADE22BE6211904AB00D5F44B /* node_panel_grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADE22BE3211904AA00D5F44B /* node_panel_grid.cpp */; };
|
||||
ADE22BE7211904AB00D5F44B /* node_panel_grid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADE22BE3211904AA00D5F44B /* node_panel_grid.cpp */; };
|
||||
@@ -477,6 +481,10 @@
|
||||
ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = "../../Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS/arm64/libcurl.a"; sourceTree = "<group>"; };
|
||||
ADD7D2B01EBFA42600D5A897 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
|
||||
ADD7D2B21EBFA42C00D5A897 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
|
||||
ADE0862C212395B500945972 /* libSonarPenUniversal.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSonarPenUniversal.a; path = libs/libSonarPen/libSonarPenUniversal.a; sourceTree = "<group>"; };
|
||||
ADE0862E21239C9100945972 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = DEVELOPER_DIR; };
|
||||
ADE0863021239CD900945972 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; };
|
||||
ADE0863221239D0700945972 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/Accelerate.framework; sourceTree = DEVELOPER_DIR; };
|
||||
ADE22BE3211904AA00D5F44B /* node_panel_grid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = node_panel_grid.cpp; sourceTree = "<group>"; };
|
||||
ADE22BE4211904AA00D5F44B /* node_panel_grid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = node_panel_grid.h; sourceTree = "<group>"; };
|
||||
ADE491111F86D09100FB8E92 /* shapes.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = shapes.cc; path = libs/poly2tri/poly2tri/common/shapes.cc; sourceTree = "<group>"; };
|
||||
@@ -537,6 +545,9 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
ADE0863321239D0700945972 /* Accelerate.framework in Frameworks */,
|
||||
ADE0863121239CDA00945972 /* MediaPlayer.framework in Frameworks */,
|
||||
ADE0862F21239C9200945972 /* AudioToolbox.framework in Frameworks */,
|
||||
AD3087C82061D1CD009F9260 /* CoreGraphics.framework in Frameworks */,
|
||||
AD3087C62061D1B4009F9260 /* CoreVideo.framework in Frameworks */,
|
||||
AD3087C2205F016F009F9260 /* AVFoundation.framework in Frameworks */,
|
||||
@@ -544,6 +555,7 @@
|
||||
AD30D8331F8049BD00B6A112 /* Photos.framework in Frameworks */,
|
||||
AD759B691F279B3900211963 /* GLKit.framework in Frameworks */,
|
||||
ADD7D2B31EBFA42C00D5A897 /* Security.framework in Frameworks */,
|
||||
ADE0862D212395B600945972 /* libSonarPenUniversal.a in Frameworks */,
|
||||
ADD7D2B11EBFA42600D5A897 /* libz.tbd in Frameworks */,
|
||||
AD759B681F2796EA00211963 /* OpenGLES.framework in Frameworks */,
|
||||
ADD7D28D1EBF9D6F00D5A897 /* CoreFoundation.framework in Frameworks */,
|
||||
@@ -559,6 +571,9 @@
|
||||
AD06989520CC6C210010825F /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ADE0863221239D0700945972 /* Accelerate.framework */,
|
||||
ADE0863021239CD900945972 /* MediaPlayer.framework */,
|
||||
ADE0862E21239C9100945972 /* AudioToolbox.framework */,
|
||||
AD06989620CC6C350010825F /* ZipArchive.framework */,
|
||||
);
|
||||
name = iOS;
|
||||
@@ -749,6 +764,7 @@
|
||||
AD58E0731E3421CB006ACC15 /* libs */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
ADE0862C212395B500945972 /* libSonarPenUniversal.a */,
|
||||
ADD7D2AE1EBFA35F00D5A897 /* libcurl.a */,
|
||||
ADE491101F86D07900FB8E92 /* p2t */,
|
||||
AD0E11A21ECA61B500CDA6BB /* jpge.cpp */,
|
||||
@@ -1696,11 +1712,15 @@
|
||||
libs/jpeg,
|
||||
libs/poly2tri/poly2tri,
|
||||
libs/base64,
|
||||
libs/libSonarPen/include,
|
||||
);
|
||||
INFOPLIST_FILE = PanoPainter/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS",
|
||||
"$(PROJECT_DIR)/libs/libSonarPen",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.omixlab.panopainter.ios;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
@@ -1730,11 +1750,15 @@
|
||||
libs/jpeg,
|
||||
libs/poly2tri/poly2tri,
|
||||
libs/base64,
|
||||
libs/libSonarPen/include,
|
||||
);
|
||||
INFOPLIST_FILE = PanoPainter/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"/Users/omimac/Downloads/curl-android-ios-master/prebuilt-with-ssl/iOS",
|
||||
"$(PROJECT_DIR)/libs/libSonarPen",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.omixlab.panopainter.ios;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
|
||||
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