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.

This commit is contained in:
Lior Halphon 2016-06-09 00:37:00 +03:00
parent 94ea44da0c
commit c27ee9d879
1 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#import <OpenGL/gl.h>
#import <Carbon/Carbon.h>
#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;