diff --git a/Cocoa/CMKeyboardManager.h b/Cocoa/CMKeyboardManager.h index 7037409..613aae3 100644 --- a/Cocoa/CMKeyboardManager.h +++ b/Cocoa/CMKeyboardManager.h @@ -34,13 +34,6 @@ @end @interface CMKeyboardManager : NSObject -{ - IOHIDManagerRef keyboardHidManager; - NSMutableArray *observers; - - @private - NSObject *observerLock; -} + (CMKeyboardManager *)sharedInstance; diff --git a/Cocoa/CMKeyboardManager.m b/Cocoa/CMKeyboardManager.m index 59e52e3..d393fc5 100644 --- a/Cocoa/CMKeyboardManager.m +++ b/Cocoa/CMKeyboardManager.m @@ -36,6 +36,11 @@ - (void)keyStateDidChange:(NSInteger)scanCode @end @implementation CMKeyboardManager +{ + IOHIDManagerRef keyboardHidManager; + NSMutableArray *observers; + NSObject *observerLock; +} + (CMKeyboardManager *)sharedInstance { diff --git a/Cocoa/CMMSXJoystick.h b/Cocoa/CMMSXJoystick.h deleted file mode 100644 index 245d356..0000000 --- a/Cocoa/CMMSXJoystick.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************** - ** - ** CocoaMSX: MSX Emulator for Mac OS X - ** http://www.cocoamsx.com - ** Copyright (C) 2012-2016 Akop Karapetyan - ** - ** This program is free software; you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation; either version 2 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program; if not, write to the Free Software - ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ** - ****************************************************************************** - */ -#import - -enum -{ - CMMSXJoystickUnknown = 0, - CMMSXJoystickTwoButton = 1, -}; - -typedef NSUInteger CMMSXJoystickLayout; - -@interface CMMSXJoystick : NSObject -{ - NSMutableDictionary *virtualCodeToButtonInfoMap; -} - -- (NSString *)presentationLabelForVirtualCode:(NSInteger)keyCode; - -+ (CMMSXJoystick *)joystickWithLayout:(CMMSXJoystickLayout)layout; - -@end diff --git a/Cocoa/CMMSXJoystick.m b/Cocoa/CMMSXJoystick.m deleted file mode 100644 index 7cb001c..0000000 --- a/Cocoa/CMMSXJoystick.m +++ /dev/null @@ -1,135 +0,0 @@ -/***************************************************************************** - ** - ** CocoaMSX: MSX Emulator for Mac OS X - ** http://www.cocoamsx.com - ** Copyright (C) 2012-2016 Akop Karapetyan - ** - ** This program is free software; you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation; either version 2 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program; if not, write to the Free Software - ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - ** - ****************************************************************************** - */ -#import "CMMSXJoystick.h" - -#include "InputEvent.h" - -#pragma mark - CMJoystickButton - -@interface CMJoystickButton : NSObject - -@property (nonatomic, assign) NSInteger portOneVirtualCode; -@property (nonatomic, assign) NSInteger portTwoVirtualCode; -@property (nonatomic, strong) NSString *label; - -- (NSString *)presentationLabel; - -@end - -@implementation CMJoystickButton - -- (NSString *)presentationLabel -{ - return [self label]; -} - -@end - -#pragma mark - CMMSXJoystick - -@interface CMMSXJoystick () - -- (CMJoystickButton *)mapButtonWithPortOneVirtualCode:(NSInteger)portOneVirtualCode - portTwoVirtualCode:(NSInteger)portTwoVirtualCode - label:(NSString *)label; - -+ (CMMSXJoystick *)twoButtonJoystick; - -@end - -static NSDictionary *layoutToJoystickMap; - -@implementation CMMSXJoystick - -+ (void)initialize -{ - layoutToJoystickMap = [[NSDictionary alloc] initWithObjectsAndKeys: - [self twoButtonJoystick], @(CMMSXJoystickTwoButton), - - nil]; -} - -- (id)init -{ - if ((self = [super init])) - { - virtualCodeToButtonInfoMap = [[NSMutableDictionary alloc] init]; - } - - return self; -} - -- (CMJoystickButton *)mapButtonWithPortOneVirtualCode:(NSInteger)portOneVirtualCode - portTwoVirtualCode:(NSInteger)portTwoVirtualCode - label:(NSString *)label -{ - CMJoystickButton *button = [[CMJoystickButton alloc] init]; - - [button setPortOneVirtualCode:portOneVirtualCode]; - [button setPortTwoVirtualCode:portTwoVirtualCode]; - [button setLabel:label]; - - [virtualCodeToButtonInfoMap setObject:button forKey:@(portOneVirtualCode)]; - [virtualCodeToButtonInfoMap setObject:button forKey:@(portTwoVirtualCode)]; - - return button; -} - -- (NSString *)presentationLabelForVirtualCode:(NSInteger)keyCode -{ - return [[virtualCodeToButtonInfoMap objectForKey:@(keyCode)] presentationLabel]; -} - -+ (CMMSXJoystick *)joystickWithLayout:(CMMSXJoystickLayout)layout -{ - return [layoutToJoystickMap objectForKey:@(layout)]; -} - -+ (CMMSXJoystick *)twoButtonJoystick -{ - CMMSXJoystick *joystick = [[CMMSXJoystick alloc] init]; - - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_BUTTON1 - portTwoVirtualCode:EC_JOY2_BUTTON1 - label:CMLoc(@"Button 1", @"Joystick button")]; - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_BUTTON2 - portTwoVirtualCode:EC_JOY2_BUTTON2 - label:CMLoc(@"Button 2", @"Joystick button")]; - - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_UP - portTwoVirtualCode:EC_JOY2_UP - label:CMLoc(@"Up", @"Joystick button")]; - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_DOWN - portTwoVirtualCode:EC_JOY2_DOWN - label:CMLoc(@"Down", @"Joystick button")]; - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_LEFT - portTwoVirtualCode:EC_JOY2_LEFT - label:CMLoc(@"Left", @"Joystick button")]; - [joystick mapButtonWithPortOneVirtualCode:EC_JOY1_RIGHT - portTwoVirtualCode:EC_JOY2_RIGHT - label:CMLoc(@"Right", @"Joystick button")]; - - return joystick; -} - -@end diff --git a/CocoaMSX.xcodeproj/project.pbxproj b/CocoaMSX.xcodeproj/project.pbxproj index 58f317b..1edd53b 100644 --- a/CocoaMSX.xcodeproj/project.pbxproj +++ b/CocoaMSX.xcodeproj/project.pbxproj @@ -356,7 +356,6 @@ FEA4548D1679B65300AAECB7 /* DiskDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = FEA4548C1679B65300AAECB7 /* DiskDocument.icns */; }; FEA454901679BAF700AAECB7 /* CassetteDocument.icns in Resources */ = {isa = PBXBuildFile; fileRef = FEA4548F1679BAF700AAECB7 /* CassetteDocument.icns */; }; FEA6E8A416EB0A2800A580CF /* CMMSXKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = FEA6E8A316EB0A2800A580CF /* CMMSXKeyboard.m */; }; - FEA6E8A716EB223100A580CF /* CMMSXJoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = FEA6E8A616EB223100A580CF /* CMMSXJoystick.m */; }; FEA74EFD16FC14B60033E2DE /* Data in Resources */ = {isa = PBXBuildFile; fileRef = FEA74EFC16FC14B60033E2DE /* Data */; }; FEAAF3EF167283C500D371CD /* CMInputDeviceLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = FEAAF3EE167283C500D371CD /* CMInputDeviceLayout.m */; }; FEAAF3F81672942700D371CD /* CMInputMethod.m in Sources */ = {isa = PBXBuildFile; fileRef = FEAAF3F71672942700D371CD /* CMInputMethod.m */; }; @@ -1113,8 +1112,6 @@ FEA6277A16A0CAD70048C05C /* cbios.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cbios.txt; sourceTree = ""; }; FEA6E8A216EB0A2800A580CF /* CMMSXKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMMSXKeyboard.h; sourceTree = ""; }; FEA6E8A316EB0A2800A580CF /* CMMSXKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMMSXKeyboard.m; sourceTree = ""; }; - FEA6E8A516EB223100A580CF /* CMMSXJoystick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMMSXJoystick.h; sourceTree = ""; }; - FEA6E8A616EB223100A580CF /* CMMSXJoystick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMMSXJoystick.m; sourceTree = ""; }; FEA74EFC16FC14B60033E2DE /* Data */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Data; sourceTree = ""; }; FEA841B0187FCD8000F5CD6D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; FEA841B2187FCD8000F5CD6D /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; @@ -2248,8 +2245,6 @@ FEAAF3EE167283C500D371CD /* CMInputDeviceLayout.m */, 6B1C25AA1672972F004DD618 /* CMKeyboardInput.h */, 6B1C25AB1672972F004DD618 /* CMKeyboardInput.m */, - FEA6E8A516EB223100A580CF /* CMMSXJoystick.h */, - FEA6E8A616EB223100A580CF /* CMMSXJoystick.m */, FEA6E8A216EB0A2800A580CF /* CMMSXKeyboard.h */, FEA6E8A316EB0A2800A580CF /* CMMSXKeyboard.m */, FE2E1961164085A000BCFD53 /* CMPreferences.h */, @@ -2768,7 +2763,6 @@ FE2D857D16E33140003EFB3F /* CMIsZero.m in Sources */, FE2D858016E3480C003EFB3F /* CMAsString.m in Sources */, FEA6E8A416EB0A2800A580CF /* CMMSXKeyboard.m in Sources */, - FEA6E8A716EB223100A580CF /* CMMSXJoystick.m in Sources */, FE81439016F797CC000FABC7 /* CMGamepadManager.m in Sources */, FE81439316F7A191000FABC7 /* CMGamepad.m in Sources */, FE05CAD4176CD21200D6CAC0 /* CMConfigureJoystickController.m in Sources */, diff --git a/Controllers/CMPreferenceController.m b/Controllers/CMPreferenceController.m index 2a05199..588321a 100644 --- a/Controllers/CMPreferenceController.m +++ b/Controllers/CMPreferenceController.m @@ -32,7 +32,6 @@ #import "MGScopeBar.h" -#import "CMMSXJoystick.h" #import "CMKeyboardInput.h" #import "CMMachine.h" #import "CMMixerChannel.h" @@ -1321,7 +1320,7 @@ - (id) outlineView:(NSOutlineView *) outlineView return nil; } else if ([[tableColumn identifier] isEqualToString:@"CMKeyAssignmentColumn"]) { CMKeyboardInput *keyInput = (CMKeyboardInput *)[[theEmulator keyboardLayout] inputMethodForVirtualCode:virtualCode]; - return [CMKeyCaptureView descriptionForKeyCode:@([keyInput keyCode])]; + return [CMKeyCaptureView descriptionForKeyCode:[keyInput keyCode]]; } } diff --git a/Resources/ConfigureJoystick.xib b/Resources/ConfigureJoystick.xib index 736c3ac..95fcca3 100644 --- a/Resources/ConfigureJoystick.xib +++ b/Resources/ConfigureJoystick.xib @@ -17,49 +17,21 @@ - + - + - - - + - + - + @@ -113,7 +85,7 @@ Gw - + @@ -121,6 +93,13 @@ Gw + + + + + + + + + - + diff --git a/Resources/RepositionCassette.xib b/Resources/RepositionCassette.xib index fddb238..2010cbc 100644 --- a/Resources/RepositionCassette.xib +++ b/Resources/RepositionCassette.xib @@ -12,8 +12,8 @@ - - + +