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>
|
||||
|
||||
Reference in New Issue
Block a user