osx: update swift code

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2016-12-30 16:35:08 +02:00
parent aca9cb6919
commit fd4d600d3f
7 changed files with 33 additions and 22 deletions

View File

@ -14,12 +14,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(aNotification: NSNotification) {
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
emu_main();
}
func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}

View File

@ -14,8 +14,8 @@ class EmuGLView: NSOpenGLView {
return true;
}
override func drawRect(dirtyRect: NSRect) {
super.drawRect(dirtyRect)
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
// Drawing code here.
// screen_width = view.drawableWidth;
@ -26,16 +26,16 @@ class EmuGLView: NSOpenGLView {
openGLContext!.makeCurrentContext()
while !emu_single_frame(Int32(dirtyRect.width), Int32(dirtyRect.height)) { }
while 0==emu_single_frame(Int32(dirtyRect.width), Int32(dirtyRect.height)) { }
openGLContext!.flushBuffer()
}
override func awakeFromNib() {
var renderTimer = NSTimer.scheduledTimerWithTimeInterval(0.001, target: self, selector: Selector("timerTick"), userInfo: nil, repeats: true)
var renderTimer = Timer.scheduledTimer(timeInterval: 0.001, target: self, selector: #selector(EmuGLView.timerTick), userInfo: nil, repeats: true)
NSRunLoop.currentRunLoop().addTimer(renderTimer, forMode: NSDefaultRunLoopMode);
NSRunLoop.currentRunLoop().addTimer(renderTimer, forMode: NSEventTrackingRunLoopMode);
RunLoop.current.add(renderTimer, forMode: RunLoopMode.defaultRunLoopMode);
RunLoop.current.add(renderTimer, forMode: RunLoopMode.eventTrackingRunLoopMode);
let attrs:[NSOpenGLPixelFormatAttribute] =
[
@ -49,7 +49,7 @@ class EmuGLView: NSOpenGLView {
let pf = NSOpenGLPixelFormat(attributes:attrs)
let context = NSOpenGLContext(format: pf!, shareContext: nil);
let context = NSOpenGLContext(format: pf!, share: nil);
self.pixelFormat = pf;
self.openGLContext = context;
@ -63,11 +63,11 @@ class EmuGLView: NSOpenGLView {
self.needsDisplay = true;
}
override func keyDown(e: NSEvent) {
override func keyDown(with e: NSEvent) {
emu_key_input(e.characters!, 1);
}
override func keyUp(e: NSEvent) {
override func keyUp(with e: NSEvent) {
emu_key_input(e.characters!, 0);
}

View File

@ -10,7 +10,7 @@
#define emulator_osx_osx_main_Bridging_Header_h
void emu_main();
bool emu_single_frame(int w, int h);
int emu_single_frame(int w, int h);
void emu_gles_init();
void emu_key_input(const char* key, int state);
#endif

View File

@ -127,7 +127,7 @@ extern int screen_width,screen_height;
bool rend_single_frame();
bool gles_init();
extern "C" bool emu_single_frame(int w, int h) {
extern "C" int emu_single_frame(int w, int h) {
if (!has_init)
return true;
screen_width = w;
@ -194,4 +194,4 @@ extern "C" void emu_key_input(char* keyt, int state) {
case 'i': handle_key(DPad_Up, state); break;
case 0xa: handle_key(Btn_Start, state); break;
}
}
}

View File

@ -28,7 +28,7 @@ class emulator_osxTests: XCTestCase {
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
self.measure() {
// Put the code you want to measure the time of here.
}
}

View File

@ -192,7 +192,7 @@
84B7BF7F1B72720200F9733F /* stdclass.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BEA71B72720200F9733F /* stdclass.cpp */; };
84B7BF831B727AD700F9733F /* osx-main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BF821B727AD700F9733F /* osx-main.mm */; };
84B7BF861B72871600F9733F /* EmuGLView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BF851B72871600F9733F /* EmuGLView.swift */; };
EBDF374F1BB96581001191B5 /* audiobackend_coreaudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBDF374D1BB96581001191B5 /* audiobackend_coreaudio.cpp */; settings = {ASSET_TAGS = (); }; };
EBDF374F1BB96581001191B5 /* audiobackend_coreaudio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBDF374D1BB96581001191B5 /* audiobackend_coreaudio.cpp */; };
EBDF37511BB969EE001191B5 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBDF37501BB969EE001191B5 /* CoreAudio.framework */; };
EBDF37531BB969F8001191B5 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EBDF37521BB969F8001191B5 /* AudioUnit.framework */; };
/* End PBXBuildFile section */
@ -1338,9 +1338,11 @@
TargetAttributes = {
84A388B21B1CDD3E000166C0 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0820;
};
84A388C21B1CDD3F000166C0 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0820;
TestTargetID = 84A388B21B1CDD3E000166C0;
};
};
@ -1706,6 +1708,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "reicast-osx";
SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Debug;
};
@ -1734,6 +1737,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "reicast-osx";
SWIFT_OBJC_BRIDGING_HEADER = "emulator-osx/emulator-osx-Bridging-Header.h";
SWIFT_VERSION = 3.0;
};
name = Release;
};
@ -1753,6 +1757,7 @@
INFOPLIST_FILE = "emulator-osxTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = "reicast-osxTests";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/reicast-osx.app/Contents/MacOS/reicast-osx";
};
name = Debug;
@ -1769,6 +1774,7 @@
INFOPLIST_FILE = "emulator-osxTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_NAME = "reicast-osxTests";
SWIFT_VERSION = 3.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/reicast-osx.app/Contents/MacOS/reicast-osx";
};
name = Release;

View File

@ -51,10 +51,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
@ -76,17 +76,21 @@
ReferencedContainer = "container:emulator-osx/reicast-osx.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84A388B21B1CDD3E000166C0"
@ -99,12 +103,13 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84A388B21B1CDD3E000166C0"