Moves vibration logic to DeltaCore; adds taptic engine support
This commit is contained in:
parent
89da120b46
commit
93b9e979cf
@ -1 +1 @@
|
||||
Subproject commit 35d634fdeec4f89da7dfecacb90188d688caa177
|
||||
Subproject commit 54697b08bf8c029d92b97e1acb2be7c21ff45a57
|
||||
@ -26,7 +26,6 @@
|
||||
BF0418141D01E93400E85BCF /* GBADeltaCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF0418131D01E93400E85BCF /* GBADeltaCore.framework */; };
|
||||
BF0418151D01E93400E85BCF /* GBADeltaCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BF0418131D01E93400E85BCF /* GBADeltaCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
BF04E6FF1DB8625C000F35D3 /* ControllerSkinsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF04E6FE1DB8625C000F35D3 /* ControllerSkinsViewController.swift */; };
|
||||
BF090CF41B490D8300DCAB45 /* UIDevice+Vibration.m in Sources */ = {isa = PBXBuildFile; fileRef = BF090CF31B490D8300DCAB45 /* UIDevice+Vibration.m */; };
|
||||
BF0CDDAD1C8155D200640168 /* LoadImageOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0CDDAC1C8155D200640168 /* LoadImageOperation.swift */; };
|
||||
BF0D057F1DDD9A96002A71A7 /* GamesDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF0D057E1DDD9A96002A71A7 /* GamesDatabase.swift */; };
|
||||
BF107EC41BF413F000E0C32C /* GamesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF107EC31BF413F000E0C32C /* GamesViewController.swift */; };
|
||||
@ -129,8 +128,6 @@
|
||||
BF0418131D01E93400E85BCF /* GBADeltaCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = GBADeltaCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
BF04E6FE1DB8625C000F35D3 /* ControllerSkinsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ControllerSkinsViewController.swift; path = "Controller Skins/ControllerSkinsViewController.swift"; sourceTree = "<group>"; };
|
||||
BF090CF11B490D8300DCAB45 /* Delta-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Delta-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
BF090CF21B490D8300DCAB45 /* UIDevice+Vibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+Vibration.h"; sourceTree = "<group>"; };
|
||||
BF090CF31B490D8300DCAB45 /* UIDevice+Vibration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice+Vibration.m"; sourceTree = "<group>"; };
|
||||
BF0A81C41DC915C800443EF0 /* ControllerSkinConfigurations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ControllerSkinConfigurations.h; path = Misc/ControllerSkinConfigurations.h; sourceTree = "<group>"; };
|
||||
BF0CDDAC1C8155D200640168 /* LoadImageOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoadImageOperation.swift; path = Components/LoadImageOperation.swift; sourceTree = "<group>"; };
|
||||
BF0D057E1DDD9A96002A71A7 /* GamesDatabase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GamesDatabase.swift; sourceTree = "<group>"; };
|
||||
@ -227,8 +224,6 @@
|
||||
BF090CEE1B490C1A00DCAB45 /* Extensions */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF090CF21B490D8300DCAB45 /* UIDevice+Vibration.h */,
|
||||
BF090CF31B490D8300DCAB45 /* UIDevice+Vibration.m */,
|
||||
BF797A2C1C2D339F00F1A000 /* UILabel+FontSize.swift */,
|
||||
BF7AE8091C2E8C7600B1B5BC /* UIColor+Delta.swift */,
|
||||
BFCEA67D1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift */,
|
||||
@ -740,7 +735,6 @@
|
||||
BF353FFF1C5DA3C500C1184C /* PausePresentationController.swift in Sources */,
|
||||
BFFC464C1D5998D600AF2CC6 /* CheatTableViewCell.swift in Sources */,
|
||||
BF7AE80A1C2E8C7600B1B5BC /* UIColor+Delta.swift in Sources */,
|
||||
BF090CF41B490D8300DCAB45 /* UIDevice+Vibration.m in Sources */,
|
||||
BFACD5FD1DC3D2CE002D6DDC /* LoadControllerSkinImageOperation.swift in Sources */,
|
||||
BF797A2D1C2D339F00F1A000 /* UILabel+FontSize.swift in Sources */,
|
||||
BFD097211D3A01B8005A44C2 /* SaveStatesViewController.swift in Sources */,
|
||||
@ -952,6 +946,7 @@
|
||||
BF14D8961DE7A512002CA1BE /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
BFFA71D21AAC406100EE9DD1 /* Build configuration list for PBXProject "Delta" */ = {
|
||||
isa = XCConfigurationList;
|
||||
|
||||
@ -125,11 +125,6 @@ class GameViewController: DeltaCore.GameViewController
|
||||
{
|
||||
super.gameController(gameController, didActivate: input)
|
||||
|
||||
if gameController is ControllerView && UIDevice.current.isVibrationSupported
|
||||
{
|
||||
UIDevice.current.vibrate()
|
||||
}
|
||||
|
||||
guard (input as? ControllerInput) != .menu else { return }
|
||||
|
||||
if self.selectingSustainedButtons
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
//
|
||||
// UIDevice+Vibration.h
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 7/5/15.
|
||||
// Copyright © 2015 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
@import UIKit;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface UIDevice (Vibration)
|
||||
|
||||
@property (nonatomic, readonly, getter=isVibrationSupported) BOOL supportsVibration;
|
||||
|
||||
- (void)vibrate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@ -1,78 +0,0 @@
|
||||
//
|
||||
// UIDevice+Vibration.m
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 7/5/15.
|
||||
// Copyright © 2015 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UIDevice+Vibration.h"
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
@import AudioToolbox;
|
||||
|
||||
// Private vibration API declarations
|
||||
#if !APP_STORE_BUILD
|
||||
void AudioServicesStopSystemSound(int);
|
||||
void AudioServicesPlaySystemSoundWithVibration(int, id, NSDictionary *);
|
||||
#endif
|
||||
|
||||
@implementation UIDevice (Vibration)
|
||||
|
||||
#pragma mark - Vibration -
|
||||
|
||||
- (void)vibrate
|
||||
{
|
||||
#if !APP_STORE_BUILD
|
||||
AudioServicesStopSystemSound(kSystemSoundID_Vibrate);
|
||||
|
||||
int64_t vibrationLength = 30;
|
||||
|
||||
if ([[self modelGeneration] hasPrefix:@"iPhone6"])
|
||||
{
|
||||
// iPhone 5S has a weaker vibration motor, so we vibrate for 10ms longer to compensate
|
||||
vibrationLength = 40;
|
||||
}
|
||||
|
||||
NSArray *pattern = @[@NO, @0, @YES, @(vibrationLength)];
|
||||
|
||||
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||
dictionary[@"VibePattern"] = pattern;
|
||||
dictionary[@"Intensity"] = @1;
|
||||
|
||||
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dictionary);
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma mark - Device Info -
|
||||
|
||||
- (NSString *)modelGeneration
|
||||
{
|
||||
char *type = "hw.machine";
|
||||
|
||||
size_t size;
|
||||
sysctlbyname(type, NULL, &size, NULL, 0);
|
||||
|
||||
char *name = malloc(size);
|
||||
sysctlbyname(type, name, &size, NULL, 0);
|
||||
|
||||
NSString *modelName = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
|
||||
free(name);
|
||||
|
||||
return modelName;
|
||||
}
|
||||
|
||||
#pragma mark - Getters/Setters -
|
||||
|
||||
- (BOOL)isVibrationSupported
|
||||
{
|
||||
#if APP_STORE_BUILD || TARGET_IPHONE_SIMULATOR
|
||||
return NO;
|
||||
#else
|
||||
// No way to detect if hardware supports vibration, so we assume if it's not an iPhone, it doesn't have a vibration motor
|
||||
return [self.model hasPrefix:@"iPhone"];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
@ -2,6 +2,5 @@
|
||||
// Use this file to import your target's public headers that you would like to expose to Swift.
|
||||
//
|
||||
|
||||
#import "UIDevice+Vibration.h"
|
||||
#import "NSFetchedResultsController+Conveniences.h"
|
||||
#import "ControllerSkinConfigurations.h"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user