From e7a7a38d91a331c6224ad33ed8cb9cd4dc04b655 Mon Sep 17 00:00:00 2001 From: rogerman Date: Tue, 16 Apr 2013 22:45:40 +0000 Subject: [PATCH] Cocoa Port: - Allow the Rotate Display Left and Rotate Display Right commands to be mapped. --- desmume/src/cocoa/DefaultKeyMappings.plist | 36 ++++++++++++++++++ desmume/src/cocoa/DefaultUserPrefs.plist | Bin 5046 -> 5364 bytes .../userinterface/EmuControllerDelegate.h | 1 + .../userinterface/EmuControllerDelegate.mm | 18 ++++++++- .../src/cocoa/userinterface/InputManager.mm | 15 ++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) diff --git a/desmume/src/cocoa/DefaultKeyMappings.plist b/desmume/src/cocoa/DefaultKeyMappings.plist index f5092b775..762281308 100644 --- a/desmume/src/cocoa/DefaultKeyMappings.plist +++ b/desmume/src/cocoa/DefaultKeyMappings.plist @@ -26,6 +26,8 @@ Load State Slot Save State Slot Copy Screen + Rotate Display Left + Rotate Display Right Set Speed Enable/Disable Speed Limiter Enable/Disable Auto Frame Skip @@ -331,6 +333,40 @@ Copy Screen + Rotate Display Left + + + deviceInfoSummary + Keyboard: [ + deviceCode + NSEventKeyboard + deviceName + Keyboard + elementCode + 33 + elementName + [ + intValue0 + -90 + + + Rotate Display Right + + + deviceInfoSummary + Keyboard: ] + deviceCode + NSEventKeyboard + deviceName + Keyboard + elementCode + 30 + elementName + ] + intValue0 + 90 + + Set Speed diff --git a/desmume/src/cocoa/DefaultUserPrefs.plist b/desmume/src/cocoa/DefaultUserPrefs.plist index 5b432207e652700f4ece5dee11392ab7c5c48f36..990f84687f48a5eed66254e123a9d996a30debaa 100644 GIT binary patch delta 1502 zcmZXSc~F*B6vm%p>buWqe0|YL(eW55P;dDnXi#HYQT z>U8<5?R}iZ$iR3^z(i!?9lVS8@IEHFrdYoEz_fH{|HKg)$)T=%%{MY`&=A3U_USf0 zIo%nPoH=w<;@BjwM~`Dwd{|h*lVJ`f7h?*hVj4ccbbMIz%a4#}1=n!h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JQ3jpnSmZkt(a+u49kx7qdq+sEeF zr|eW)Xy@BycAZ^sH{0#D%I>f`?Jm39R@*&xudT7QcAq_9586Zau=Q;{+T-697Z(lC L!2k09Zo~foo}Oaf diff --git a/desmume/src/cocoa/userinterface/EmuControllerDelegate.h b/desmume/src/cocoa/userinterface/EmuControllerDelegate.h index 4b4edc9bc..003a2e8de 100644 --- a/desmume/src/cocoa/userinterface/EmuControllerDelegate.h +++ b/desmume/src/cocoa/userinterface/EmuControllerDelegate.h @@ -212,6 +212,7 @@ class AudioSampleBlockGenerator; - (void) cmdSaveEmuSaveStateSlot:(NSValue *)cmdAttrValue; - (void) cmdCopyScreen:(NSValue *)cmdAttrValue; +- (void) cmdRotateDisplayRelative:(NSValue *)cmdAttrValue; - (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue; - (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue; diff --git a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm index a094db54f..e42a37a08 100644 --- a/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm +++ b/desmume/src/cocoa/userinterface/EmuControllerDelegate.mm @@ -878,8 +878,7 @@ - (IBAction) changeRotationRelative:(id)sender { - const double angleDegrees = [mainWindow displayRotation] + (double)[CocoaDSUtil getIBActionSenderTag:sender]; - [mainWindow setDisplayRotation:angleDegrees]; + [inputManager dispatchCommandUsingIBAction:_cmd sender:sender]; } - (IBAction) changeDisplayMode:(id)sender @@ -1167,6 +1166,21 @@ [mainWindow copy:nil]; } +- (void) cmdRotateDisplayRelative:(NSValue *)cmdAttrValue +{ + CommandAttributes cmdAttr; + [cmdAttrValue getValue:&cmdAttr]; + + if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF) + { + return; + } + + const double relativeDegrees = (cmdAttr.useInputForSender) ? (double)[CocoaDSUtil getIBActionSenderTag:cmdAttr.input.sender] : (double)cmdAttr.intValue[0]; + const double angleDegrees = [mainWindow displayRotation] + relativeDegrees; + [mainWindow setDisplayRotation:angleDegrees]; +} + - (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue { CommandAttributes cmdAttr; diff --git a/desmume/src/cocoa/userinterface/InputManager.mm b/desmume/src/cocoa/userinterface/InputManager.mm index a39c070cc..02586be11 100644 --- a/desmume/src/cocoa/userinterface/InputManager.mm +++ b/desmume/src/cocoa/userinterface/InputManager.mm @@ -835,6 +835,8 @@ static std::tr1::unordered_map keyboardNameTable; / [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonStart_420x420" ofType:@"png"]] autorelease], @"Start", [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Select", [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Microphone_420x420" ofType:@"png"]] autorelease], @"Microphone", + [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_RotateCCW_420x420" ofType:@"png"]] autorelease], @"Rotate Display Left", + [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_RotateCW_420x420" ofType:@"png"]] autorelease], @"Rotate Display Right", [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ShowHUD_420x420" ofType:@"png"]] autorelease], @"HUD", [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute", [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]] autorelease], @"Pause", @@ -865,6 +867,7 @@ static std::tr1::unordered_map keyboardNameTable; / commandSelector["Load State Slot"] = @selector(cmdLoadEmuSaveStateSlot:); commandSelector["Save State Slot"] = @selector(cmdSaveEmuSaveStateSlot:); commandSelector["Copy Screen"] = @selector(cmdCopyScreen:); + commandSelector["Rotate Display Relative"] = @selector(cmdRotateDisplayRelative:); commandSelector["Set Speed"] = @selector(cmdHoldToggleSpeedScalar:); commandSelector["Enable/Disable Speed Limiter"] = @selector(cmdToggleSpeedLimiter:); commandSelector["Enable/Disable Auto Frame Skip"] = @selector(cmdToggleAutoFrameSkip:); @@ -901,6 +904,15 @@ static std::tr1::unordered_map keyboardNameTable; / CommandAttributes cmdSaveEmuSaveStateSlot = NewCommandAttributesForSelector("Save State Slot", commandSelector["Save State Slot"]); CommandAttributes cmdCopyScreen = NewCommandAttributesForSelector("Copy Screen", commandSelector["Copy Screen"]); + CommandAttributes cmdRotateDisplayRelative = NewCommandAttributesForSelector("Rotate Display Relative", commandSelector["Rotate Display Relative"]); + cmdRotateDisplayRelative.intValue[0] = 90; + + CommandAttributes cmdRotateDisplayLeft = NewCommandAttributesForSelector("Rotate Display Left", commandSelector["Rotate Display Relative"]); + cmdRotateDisplayLeft.intValue[0] = -90; + + CommandAttributes cmdRotateDisplayRight = NewCommandAttributesForSelector("Rotate Display Right", commandSelector["Rotate Display Relative"]); + cmdRotateDisplayRight.intValue[0] = 90; + CommandAttributes cmdToggleSpeed = NewCommandAttributesForSelector("Set Speed", commandSelector["Set Speed"]); cmdToggleSpeed.floatValue[0] = 1.0f; @@ -932,6 +944,8 @@ static std::tr1::unordered_map keyboardNameTable; / defaultCommandAttributes["Load State Slot"] = cmdLoadEmuSaveStateSlot; defaultCommandAttributes["Save State Slot"] = cmdSaveEmuSaveStateSlot; defaultCommandAttributes["Copy Screen"] = cmdCopyScreen; + defaultCommandAttributes["Rotate Display Left"] = cmdRotateDisplayLeft; + defaultCommandAttributes["Rotate Display Right"] = cmdRotateDisplayRight; defaultCommandAttributes["Set Speed"] = cmdToggleSpeed; defaultCommandAttributes["Enable/Disable Speed Limiter"] = cmdToggleSpeedLimiter; defaultCommandAttributes["Enable/Disable Auto Frame Skip"] = cmdToggleAutoFrameSkip; @@ -945,6 +959,7 @@ static std::tr1::unordered_map keyboardNameTable; / [self addMappingForIBAction:@selector(loadEmuSaveStateSlot:) commandAttributes:&cmdLoadEmuSaveStateSlot]; [self addMappingForIBAction:@selector(saveEmuSaveStateSlot:) commandAttributes:&cmdSaveEmuSaveStateSlot]; [self addMappingForIBAction:@selector(copy:) commandAttributes:&cmdCopyScreen]; + [self addMappingForIBAction:@selector(changeRotationRelative:) commandAttributes:&cmdRotateDisplayRelative]; [self addMappingForIBAction:@selector(toggleSpeedLimiter:) commandAttributes:&cmdToggleSpeedLimiter]; [self addMappingForIBAction:@selector(toggleAutoFrameSkip:) commandAttributes:&cmdToggleAutoFrameSkip]; [self addMappingForIBAction:@selector(toggleCheats:) commandAttributes:&cmdToggleCheats];