From c27ee9d879cb6ad1408122ee920a592c7aab301f Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 9 Jun 2016 00:37:00 +0300 Subject: [PATCH] Fixed a bug in the Cocoa port that made SameBoy ignore some input keys when the keyboard layout is set to a non-Latin/ASCII keyboard. This was solved by forcing an ASCII layout. --- Cocoa/GBView.m | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Cocoa/GBView.m b/Cocoa/GBView.m index b0657c1..86adccc 100644 --- a/Cocoa/GBView.m +++ b/Cocoa/GBView.m @@ -1,4 +1,5 @@ #import +#import #import "GBView.h" #import "GBButtons.h" #import "NSString+StringForKey.h" @@ -152,6 +153,27 @@ static GBShader *shader = nil; glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); } +- (BOOL)becomeFirstResponder +{ + /* Non-Roman keyboard layouts breaks user input. */ + TSMDocumentID document = TSMGetActiveDocument(); + + CFArrayRef inpu_sources = TISCreateASCIICapableInputSourceList(); + TSMSetDocumentProperty(document, kTSMDocumentEnabledInputSourcesPropertyTag, + sizeof(CFArrayRef), &inpu_sources); + CFRelease(inpu_sources); + + return [super becomeFirstResponder]; +} + +- (BOOL)resignFirstResponder +{ + TSMDocumentID document = TSMGetActiveDocument(); + TSMRemoveDocumentProperty(document, kTSMDocumentEnabledInputSourcesPropertyTag); + + return [super resignFirstResponder]; +} + - (BOOL)acceptsFirstResponder { return YES;