From 3c8f3ad3fc07f8dee9d948c6de4054e5808ce4af Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 2 Mar 2018 19:37:40 +0200 Subject: [PATCH 1/2] Stop annoying beeps and exceptions --- Cocoa/GBView.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cocoa/GBView.m b/Cocoa/GBView.m index 5e1e31a..4773d38 100644 --- a/Cocoa/GBView.m +++ b/Cocoa/GBView.m @@ -204,7 +204,7 @@ } } - if (!handled) { + if (!handled && [theEvent type] != NSEventTypeFlagsChanged) { [super keyDown:theEvent]; } } @@ -238,7 +238,7 @@ } } - if (!handled) { + if (!handled && [theEvent type] != NSEventTypeFlagsChanged) { [super keyUp:theEvent]; } } From 6e8567eadca6ccdef5d78dd399e4f458e7216777 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 2 Mar 2018 19:42:02 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Silence=20some=20annoying=20Cocoa=20warning?= =?UTF-8?q?s,=20hopefully=20it=20won=E2=80=99t=20affect=20performance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cocoa/Document.m | 4 ++-- Cocoa/GBView.m | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index d4a4288..a7ab0e1 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -174,11 +174,11 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, - (void) vblank { - self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0; [self.view flip]; GB_set_pixels_output(&gb, self.view.pixels); if (self.vramWindow.isVisible) { dispatch_async(dispatch_get_main_queue(), ^{ + self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0; [self reloadVRAMData: nil]; }); } @@ -196,7 +196,6 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, self.audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) { GB_apu_copy_buffer(&gb, buffer, nFrames); } andSampleRate:96000]; - self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0; if (![[NSUserDefaults standardUserDefaults] boolForKey:@"Mute"]) { [self.audioClient start]; } @@ -225,6 +224,7 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, - (void) start { if (running) return; + self.view.mouseHidingEnabled = (self.mainWindow.styleMask & NSFullScreenWindowMask) != 0; [[[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] start]; } diff --git a/Cocoa/GBView.m b/Cocoa/GBView.m index 4773d38..d329328 100644 --- a/Cocoa/GBView.m +++ b/Cocoa/GBView.m @@ -166,7 +166,9 @@ GB_set_clock_multiplier(_gb, clockMultiplier); } current_buffer = (current_buffer + 1) % self.numberOfBuffers; - [self setNeedsDisplay:YES]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self setNeedsDisplay:YES]; + }); } - (uint32_t *) pixels