fix SonarPen for iOS

This commit is contained in:
2019-10-14 12:50:41 +02:00
parent 258f6a6aff
commit 3c99653c09
7 changed files with 60 additions and 15 deletions

View File

@@ -18,6 +18,7 @@
@interface AppDelegate () {
GameViewController* view;
WTSonarPenDriver* sonarpen_driver;
bool sonarpen_started;
}
@end
@@ -35,6 +36,11 @@
[MSCrashes generateTestCrash];
}
- (bool)sonarpen_present
{
return sonarpen_started && [sonarpen_driver isPenAttached];
}
- (float)sonarpen_pressure
{
return [sonarpen_driver isPenAttached] ? [sonarpen_driver pressure] : 1.f;
@@ -46,29 +52,41 @@
case WTSonarPenDriverStateInit:
NSLog(@"Status: Initializing"); break;
case WTSonarPenDriverStateRunning:
NSLog(@"Status: Running"); break;
NSLog(@"Status: Running");
App::I->message_box("SonarPen", "Your SonarPen is now ready. Have fun!");
break;
case WTSonarPenDriverStateCalibrating:
NSLog(@"Status: Calibrating"); break;
case WTSonarPenDriverStateNotSonarPen:
NSLog(@"Status: Not a Sonar Pen"); break;
NSLog(@"Status: Not a Sonar Pen");
App::I->message_box("SonarPen Error", "Couldn't recognize the device attatched to the jack plug as a SonarPen. Please remove it and plug it back in.");
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;
NSLog(@"Status: No Microphone Permission");
App::I->message_box("SonarPen Error", "SonarPen could not be started because you didn't allow the microphone permission. Please go to Settings -> PanoPainter and enable Microphone.");
break;
}
}
- (void)sonarpen_start {
if (sonarpen_started)
return;
sonarpen_driver = [[WTSonarPenDriver alloc] initWithApplication:[UIApplication sharedApplication]];
[sonarpen_driver start];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(penStatusChanged) name:WTSonarPenDriverStateChangedNotification object:nil];
sonarpen_started = true;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"c2dccca196294ecca8fd5d58af2738cf"];
sonarpen_started = false;
[MSAppCenter start:@"c2dccca1-9629-4ecc-a8fd-5d58af2738cf" withServices:@[
[MSAnalytics class],
[MSCrashes class]
]];
// 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;