Cocoa Port:

- Users can now take advantage of the new input handling system with a completely redesigned user interface. Check it out in the input preferences!
- New feature: Touch input can be mapped to any input device. In addition, touch coordinates can now be user-defined.
- New feature: Multiple inputs may be assigned to the same command at the same time.
- Enhancement: It is now possible to remove all input mappings from a command.
- Also, many new commands are available for mapping. They are: Execute/Pause, Reset, Mute/Unmute, Load State Slot, Save State Slot, Copy Screen, Set Speed, Enable/Disable Speed Limiter, Enable/Disable Auto Frame Skip, Enable/Disable Cheats, and Enable/Disable GPU State.
This commit is contained in:
rogerman 2013-03-12 09:13:29 +00:00
parent 4577cc9c92
commit 5cd1cdef80
18 changed files with 7050 additions and 8380 deletions

View File

@ -2,314 +2,343 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>Up</key> <key>CommandTagList</key>
<array> <array>
<dict> <string>Up</string>
<key>deviceCode</key> <string>Down</string>
<string>NSEventKeyboard</string> <string>Left</string>
<key>deviceName</key> <string>Right</string>
<string>Keyboard</string> <string>A</string>
<key>elementCode</key> <string>B</string>
<string>126</string> <string>X</string>
<key>elementName</key> <string>Y</string>
<string>Up Arrow</string> <string>L</string>
</dict> <string>R</string>
</array> <string>Start</string>
<key>Down</key> <string>Select</string>
<array> <string>Touch</string>
<dict> <string>Microphone</string>
<key>deviceCode</key> <string>Lid</string>
<string>NSEventKeyboard</string> <string>Debug</string>
<key>deviceName</key> <string>Execute/Pause</string>
<string>Keyboard</string> <string>Reset</string>
<key>elementCode</key> <string>Mute/Unmute</string>
<string>125</string> <string>Load State Slot</string>
<key>elementName</key> <string>Save State Slot</string>
<string>Down Arrow</string> <string>Copy Screen</string>
</dict> <string>Set Speed</string>
</array> <string>Enable/Disable Speed Limiter</string>
<key>Left</key> <string>Enable/Disable Auto Frame Skip</string>
<array> <string>Enable/Disable Cheats</string>
<dict> <string>Enable/Disable GPU State</string>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>123</string>
<key>elementName</key>
<string>Left Arrow</string>
</dict>
</array>
<key>Right</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>124</string>
<key>elementName</key>
<string>Right Arrow</string>
</dict>
</array>
<key>A</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>7</string>
<key>elementName</key>
<string>X</string>
</dict>
</array>
<key>B</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>6</string>
<key>elementName</key>
<string>Z</string>
</dict>
</array>
<key>X</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>1</string>
<key>elementName</key>
<string>S</string>
</dict>
</array>
<key>Y</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>A</string>
</dict>
</array>
<key>L</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>12</string>
<key>elementName</key>
<string>Q</string>
</dict>
</array>
<key>R</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>13</string>
<key>elementName</key>
<string>W</string>
</dict>
</array>
<key>Start</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>36</string>
<key>elementName</key>
<string>Return</string>
</dict>
</array>
<key>Select</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>48</string>
<key>elementName</key>
<string>Tab</string>
</dict>
</array>
<key>Touch</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventMouse</string>
<key>deviceName</key>
<string>Mouse</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>Primary Button</string>
<key>useDeviceValues</key>
<true/>
<key>pointX</key>
<integer>0</integer>
<key>pointY</key>
<real>0</real>
</dict>
</array>
<key>Microphone</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>50</string>
<key>elementName</key>
<string>`</string>
</dict>
</array>
<key>Debug</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>42</string>
<key>elementName</key>
<string>\</string>
</dict>
</array>
<key>Lid</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>51</string>
<key>elementName</key>
<string>Delete (Backspace)</string>
</dict>
</array>
<key>Speed Half</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>27</string>
<key>elementName</key>
<string>-</string>
<key>floatValue</key>
<string>0.5</string>
</dict>
</array>
<key>Speed Double</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>24</string>
<key>elementName</key>
<string>=</string>
<key>floatValue</key>
<integer>2</integer>
</dict>
</array>
<key>HUD</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>4</string>
<key>elementName</key>
<string>H</string>
</dict>
</array>
<key>Execute</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>117</string>
<key>elementName</key>
<string>Forward Delete</string>
</dict>
</array>
<key>Pause</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>119</string>
<key>elementName</key>
<string>End</string>
</dict>
</array>
<key>Reset</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>121</string>
<key>elementName</key>
<string>Page Down</string>
</dict>
</array>
<key>Mute</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>71</string>
<key>elementName</key>
<string>Numpad Clear</string>
</dict>
</array> </array>
<key>DefaultInputMappings</key>
<dict>
<key>Up</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>126</string>
<key>elementName</key>
<string>Up Arrow</string>
</dict>
</array>
<key>Down</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>125</string>
<key>elementName</key>
<string>Down Arrow</string>
</dict>
</array>
<key>Left</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>123</string>
<key>elementName</key>
<string>Left Arrow</string>
</dict>
</array>
<key>Right</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>124</string>
<key>elementName</key>
<string>Right Arrow</string>
</dict>
</array>
<key>A</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>7</string>
<key>elementName</key>
<string>X</string>
</dict>
</array>
<key>B</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>6</string>
<key>elementName</key>
<string>Z</string>
</dict>
</array>
<key>X</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>1</string>
<key>elementName</key>
<string>S</string>
</dict>
</array>
<key>Y</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>A</string>
</dict>
</array>
<key>L</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>12</string>
<key>elementName</key>
<string>Q</string>
</dict>
</array>
<key>R</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>13</string>
<key>elementName</key>
<string>W</string>
</dict>
</array>
<key>Start</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>36</string>
<key>elementName</key>
<string>Return</string>
</dict>
</array>
<key>Select</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>48</string>
<key>elementName</key>
<string>Tab</string>
</dict>
</array>
<key>Touch</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventMouse</string>
<key>deviceName</key>
<string>Mouse</string>
<key>elementCode</key>
<string>0</string>
<key>elementName</key>
<string>Primary Button</string>
<key>useInputForIntCoord</key>
<true/>
</dict>
</array>
<key>Microphone</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>50</string>
<key>elementName</key>
<string>` (Accent)</string>
<key>intValue1</key>
<string>1</string>
</dict>
</array>
<key>Lid</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>51</string>
<key>elementName</key>
<string>Delete (Backspace)</string>
</dict>
</array>
<key>Debug</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>42</string>
<key>elementName</key>
<string>\</string>
</dict>
</array>
<key>HUD</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>4</string>
<key>elementName</key>
<string>H</string>
</dict>
</array>
<key>Execute/Pause</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>117</string>
<key>elementName</key>
<string>Forward Delete</string>
</dict>
</array>
<key>Reset</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>121</string>
<key>elementName</key>
<string>Page Down</string>
</dict>
</array>
<key>Mute/Unmute</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>71</string>
<key>elementName</key>
<string>Numpad Clear</string>
</dict>
</array>
<key>Load State Slot</key>
<array/>
<key>Save State Slot</key>
<array/>
<key>Copy Screen</key>
<array/>
<key>Set Speed</key>
<array>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>27</string>
<key>elementName</key>
<string>-</string>
<key>floatValue0</key>
<string>0.5</string>
</dict>
<dict>
<key>deviceCode</key>
<string>NSEventKeyboard</string>
<key>deviceName</key>
<string>Keyboard</string>
<key>elementCode</key>
<string>24</string>
<key>elementName</key>
<string>=</string>
<key>floatValue0</key>
<integer>2</integer>
</dict>
</array>
<key>Enable/Disable Speed Limiter</key>
<array/>
<key>Enable/Disable Auto Frame Skip</key>
<array/>
<key>Enable/Disable Cheats</key>
<array/>
<key>Enable/Disable GPU State</key>
<array/>
</dict>
</dict> </dict>
</plist> </plist>

View File

@ -113,7 +113,7 @@
<key>80</key> <key>80</key>
<string>F19</string> <string>F19</string>
<key>50</key> <key>50</key>
<string>`</string> <string>` (Accent)</string>
<key>27</key> <key>27</key>
<string>-</string> <string>-</string>
<key>24</key> <key>24</key>

View File

@ -57,9 +57,9 @@ enum
- (id) initWithMic:(CocoaDSMic *)theMic; - (id) initWithMic:(CocoaDSMic *)theMic;
- (void) setSoundInputMode:(NSInteger)inputMode; - (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID;
- (void) setControllerState:(BOOL)theState controlID:(NSUInteger)controlID; - (void) setTouchState:(BOOL)theState location:(const NSPoint)theLocation;
- (void) setTouchState:(BOOL)theState location:(NSPoint)theLocation; - (void) setMicrophoneState:(BOOL)theState inputMode:(const NSInteger)inputMode;
- (void) flush; - (void) flush;
@end @end

View File

@ -62,14 +62,7 @@
[super dealloc]; [super dealloc];
} }
- (void) setSoundInputMode:(NSInteger)inputMode - (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID
{
OSSpinLockLock(&spinlockControllerState);
self.cdsMic.mode = inputMode;
OSSpinLockUnlock(&spinlockControllerState);
}
- (void) setControllerState:(BOOL)theState controlID:(NSUInteger)controlID
{ {
if (controlID >= DSControllerState_StatesCount) if (controlID >= DSControllerState_StatesCount)
{ {
@ -81,7 +74,7 @@
OSSpinLockUnlock(&spinlockControllerState); OSSpinLockUnlock(&spinlockControllerState);
} }
- (void) setTouchState:(BOOL)theState location:(NSPoint)theLocation - (void) setTouchState:(BOOL)theState location:(const NSPoint)theLocation
{ {
OSSpinLockLock(&spinlockControllerState); OSSpinLockLock(&spinlockControllerState);
controllerState[DSControllerState_Touch] = (theState) ? true : false; controllerState[DSControllerState_Touch] = (theState) ? true : false;
@ -89,6 +82,14 @@
OSSpinLockUnlock(&spinlockControllerState); OSSpinLockUnlock(&spinlockControllerState);
} }
- (void) setMicrophoneState:(BOOL)theState inputMode:(const NSInteger)inputMode
{
OSSpinLockLock(&spinlockControllerState);
controllerState[DSControllerState_Microphone] = (theState) ? true : false;
self.cdsMic.mode = inputMode;
OSSpinLockUnlock(&spinlockControllerState);
}
- (void) flush - (void) flush
{ {
OSSpinLockLock(&spinlockControllerState); OSSpinLockLock(&spinlockControllerState);
@ -140,15 +141,15 @@
{ {
if (micMode == MICMODE_NONE) if (micMode == MICMODE_NONE)
{ {
[self.cdsMic fillWithNullSamples]; [cdsMic fillWithNullSamples];
} }
else if (micMode == MICMODE_INTERNAL_NOISE) else if (micMode == MICMODE_INTERNAL_NOISE)
{ {
[self.cdsMic fillWithInternalNoise]; [cdsMic fillWithInternalNoise];
} }
else if (micMode == MICMODE_WHITE_NOISE) else if (micMode == MICMODE_WHITE_NOISE)
{ {
[self.cdsMic fillWithWhiteNoise]; [cdsMic fillWithWhiteNoise];
} }
else if (micMode == MICMODE_SOUND_FILE) else if (micMode == MICMODE_SOUND_FILE)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -75,6 +75,15 @@ enum OGLVertexAttributeID
OGLVertexAttributeID_TexCoord0 = 8 OGLVertexAttributeID_TexCoord0 = 8
}; };
#ifndef MAC_OS_X_VERSION_10_7
// In Mac OS X, strnlen() is unsupported prior to v10.7, so define it here.
static size_t strnlen(const char *s, size_t n)
{
const char *p = (const char *)memchr(s, 0, n);
return(p ? p-s : n);
}
#endif // MAC_OS_X_VERSION_10_7
@implementation DisplayWindowController @implementation DisplayWindowController
@synthesize emuControl; @synthesize emuControl;
@ -1310,10 +1319,11 @@ enum OGLVertexAttributeID
- (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue - (BOOL) handleHIDQueue:(IOHIDQueueRef)hidQueue
{ {
BOOL isHandled = NO; BOOL isHandled = NO;
std::string inputStr;
DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate]; DisplayWindowController *windowController = (DisplayWindowController *)[[self window] delegate];
InputAttributesList inputList = InputManagerEncodeHIDQueue(hidQueue); InputAttributesList inputList = InputManagerEncodeHIDQueue(hidQueue);
char inputStr[INPUT_HANDLER_STRING_LENGTH*2];
memset(inputStr, '\0', INPUT_HANDLER_STRING_LENGTH*2);
const size_t inputCount = inputList.size(); const size_t inputCount = inputList.size();
@ -1321,16 +1331,18 @@ enum OGLVertexAttributeID
{ {
const InputAttributes &inputAttr = inputList[i]; const InputAttributes &inputAttr = inputList[i];
if (inputAttr.inputState == INPUT_ATTRIBUTE_STATE_ON) if (inputAttr.state == INPUT_ATTRIBUTE_STATE_ON)
{ {
inputStr = inputAttr.deviceName + ":" + inputAttr.elementName; strlcpy(inputStr, inputAttr.deviceName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, ":", INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputAttr.elementName, INPUT_HANDLER_STRING_LENGTH*2);
break; break;
} }
} }
if (!inputStr.empty()) if (strnlen(inputStr, INPUT_HANDLER_STRING_LENGTH*2) != 0)
{ {
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr.c_str() encoding:NSUTF8StringEncoding]]; [[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr encoding:NSUTF8StringEncoding]];
} }
CommandAttributesList cmdList = [inputManager generateCommandListUsingInputList:&inputList]; CommandAttributesList cmdList = [inputManager generateCommandListUsingInputList:&inputList];
@ -1355,8 +1367,12 @@ enum OGLVertexAttributeID
if (keyPressed && [theEvent window] != nil) if (keyPressed && [theEvent window] != nil)
{ {
std::string inputStr = inputAttr.deviceName + ":" + inputAttr.elementName; char inputStr[INPUT_HANDLER_STRING_LENGTH*2];
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr.c_str() encoding:NSUTF8StringEncoding]]; strlcpy(inputStr, inputAttr.deviceName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, ":", INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputAttr.elementName, INPUT_HANDLER_STRING_LENGTH*2);
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr encoding:NSUTF8StringEncoding]];
} }
isHandled = [inputManager dispatchCommandUsingInputAttributes:&inputAttr]; isHandled = [inputManager dispatchCommandUsingInputAttributes:&inputAttr];
@ -1383,10 +1399,15 @@ enum OGLVertexAttributeID
if (buttonPressed && [theEvent window] != nil) if (buttonPressed && [theEvent window] != nil)
{ {
char inputCoordBuf[256] = {0}; char inputCoordBuf[256] = {0};
snprintf(inputCoordBuf, 256, " X:%i Y:%i", (int)inputAttr.floatValue[0], (int)inputAttr.floatValue[1]); snprintf(inputCoordBuf, 256, " X:%i Y:%i", (int)inputAttr.intCoordX, (int)inputAttr.intCoordY);
std::string inputStr = inputAttr.deviceName + ":" + inputAttr.elementName + std::string(inputCoordBuf); char inputStr[INPUT_HANDLER_STRING_LENGTH*2];
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr.c_str() encoding:NSUTF8StringEncoding]]; strlcpy(inputStr, inputAttr.deviceName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, ":", INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputAttr.elementName, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputStr, inputCoordBuf, INPUT_HANDLER_STRING_LENGTH*2);
[[windowController emuControl] setStatusText:[NSString stringWithCString:inputStr encoding:NSUTF8StringEncoding]];
} }
isHandled = [inputManager dispatchCommandUsingInputAttributes:&inputAttr]; isHandled = [inputManager dispatchCommandUsingInputAttributes:&inputAttr];

View File

@ -65,6 +65,10 @@
NSInteger selectedExportRomSaveID; NSInteger selectedExportRomSaveID;
NSInteger selectedRomSaveTypeID; NSInteger selectedRomSaveTypeID;
CGFloat lastSetSpeedScalar;
BOOL isSoundMuted;
float lastSetVolumeValue;
NSImage *iconVolumeFull; NSImage *iconVolumeFull;
NSImage *iconVolumeTwoThird; NSImage *iconVolumeTwoThird;
NSImage *iconVolumeOneThird; NSImage *iconVolumeOneThird;
@ -200,7 +204,7 @@
- (void) cmdCopyScreen:(NSValue *)cmdAttrValue; - (void) cmdCopyScreen:(NSValue *)cmdAttrValue;
- (void) cmdToggleSpeedScalar:(NSValue *)cmdAttrValue; - (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue;
- (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue; - (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue;
- (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue; - (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue;
- (void) cmdToggleCheats:(NSValue *)cmdAttrValue; - (void) cmdToggleCheats:(NSValue *)cmdAttrValue;

View File

@ -118,6 +118,10 @@
selectedRomSaveTypeID = ROMSAVETYPE_AUTOMATIC; selectedRomSaveTypeID = ROMSAVETYPE_AUTOMATIC;
selectedExportRomSaveID = 0; selectedExportRomSaveID = 0;
lastSetSpeedScalar = 1.0f;
isSoundMuted = NO;
lastSetVolumeValue = MAX_VOLUME;
iconExecute = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]]; iconExecute = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]];
iconPause = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]]; iconPause = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]];
iconSpeedNormal = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Speed1x_420x420" ofType:@"png"]]; iconSpeedNormal = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Speed1x_420x420" ofType:@"png"]];
@ -275,14 +279,20 @@
else if (vol > 0.0f && vol <= VOLUME_THRESHOLD_LOW) else if (vol > 0.0f && vol <= VOLUME_THRESHOLD_LOW)
{ {
newImage = iconVolumeOneThird; newImage = iconVolumeOneThird;
isSoundMuted = NO;
lastSetVolumeValue = vol;
} }
else if (vol > VOLUME_THRESHOLD_LOW && vol <= VOLUME_THRESHOLD_HIGH) else if (vol > VOLUME_THRESHOLD_LOW && vol <= VOLUME_THRESHOLD_HIGH)
{ {
newImage = iconVolumeTwoThird; newImage = iconVolumeTwoThird;
isSoundMuted = NO;
lastSetVolumeValue = vol;
} }
else else
{ {
newImage = iconVolumeFull; newImage = iconVolumeFull;
isSoundMuted = NO;
lastSetVolumeValue = vol;
} }
if (newImage != currentImage) if (newImage != currentImage)
@ -639,14 +649,12 @@
- (IBAction) loadEmuSaveStateSlot:(id)sender - (IBAction) loadEmuSaveStateSlot:(id)sender
{ {
const NSInteger slotNumber = [CocoaDSUtil getIBActionSenderTag:sender]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
[inputManager dispatchCommandUsingIBAction:_cmd tag:slotNumber];
} }
- (IBAction) saveEmuSaveStateSlot:(id)sender - (IBAction) saveEmuSaveStateSlot:(id)sender
{ {
const NSInteger slotNumber = [CocoaDSUtil getIBActionSenderTag:sender]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
[inputManager dispatchCommandUsingIBAction:_cmd tag:slotNumber];
} }
- (IBAction) importRomSave:(id)sender - (IBAction) importRomSave:(id)sender
@ -708,22 +716,22 @@
- (IBAction) toggleExecutePause:(id)sender - (IBAction) toggleExecutePause:(id)sender
{ {
[inputManager dispatchCommandUsingIBAction:_cmd tag:0]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
} }
- (IBAction) reset:(id)sender - (IBAction) reset:(id)sender
{ {
[inputManager dispatchCommandUsingIBAction:_cmd tag:0]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
} }
- (IBAction) toggleSpeedLimiter:(id)sender - (IBAction) toggleSpeedLimiter:(id)sender
{ {
[inputManager dispatchCommandUsingIBAction:_cmd tag:0]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
} }
- (IBAction) toggleAutoFrameSkip:(id)sender - (IBAction) toggleAutoFrameSkip:(id)sender
{ {
[inputManager dispatchCommandUsingIBAction:_cmd tag:0]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
} }
- (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender - (IBAction) toggleKeepMinDisplaySizeAtNormal:(id)sender
@ -753,8 +761,7 @@
- (IBAction) toggleGPUState:(id)sender - (IBAction) toggleGPUState:(id)sender
{ {
const NSInteger bitNumber = [CocoaDSUtil getIBActionSenderTag:sender]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
[inputManager dispatchCommandUsingIBAction:_cmd tag:bitNumber];
} }
- (IBAction) changeRomSaveType:(id)sender - (IBAction) changeRomSaveType:(id)sender
@ -768,13 +775,15 @@
- (IBAction) toggleCheats:(id)sender - (IBAction) toggleCheats:(id)sender
{ {
[inputManager dispatchCommandUsingIBAction:_cmd tag:0]; [inputManager dispatchCommandUsingIBAction:_cmd sender:sender];
} }
- (IBAction) changeCoreSpeed:(id)sender - (IBAction) changeCoreSpeed:(id)sender
{ {
CGFloat newSpeedScalar = (CGFloat)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0f;
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setSpeedScalar:(CGFloat)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0f]; [cdsCore setSpeedScalar:newSpeedScalar];
lastSetSpeedScalar = newSpeedScalar;
} }
- (IBAction) changeCoreEmuFlags:(id)sender - (IBAction) changeCoreEmuFlags:(id)sender
@ -985,14 +994,18 @@
[cmdAttrValue getValue:&cmdAttr]; [cmdAttrValue getValue:&cmdAttr];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
NSUInteger controlID = (NSUInteger)cmdAttr.commandID; const NSUInteger controlID = cmdAttr.intValue[0];
BOOL theState = (cmdAttr.inputState == INPUT_ATTRIBUTE_STATE_ON) ? YES : NO; const BOOL theState = (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_ON) ? YES : NO;
if (controlID == DSControllerState_Touch) if (controlID == DSControllerState_Touch)
{ {
NSPoint touchLoc = NSMakePoint(cmdAttr.floatValue[0], cmdAttr.floatValue[1]); const NSPoint touchLoc = (cmdAttr.useInputForIntCoord) ? NSMakePoint(cmdAttr.input.intCoordX, cmdAttr.input.intCoordY) : NSMakePoint(cmdAttr.intValue[1], cmdAttr.intValue[2]);
[[cdsCore cdsController] setTouchState:theState location:touchLoc]; [[cdsCore cdsController] setTouchState:theState location:touchLoc];
} }
else if (controlID == DSControllerState_Microphone)
{
[[cdsCore cdsController] setMicrophoneState:theState inputMode:cmdAttr.intValue[1]];
}
else else
{ {
[[cdsCore cdsController] setControllerState:theState controlID:controlID]; [[cdsCore cdsController] setControllerState:theState controlID:controlID];
@ -1004,6 +1017,11 @@
CommandAttributes cmdAttr; CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr]; [cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
NSString *saveStatePath = [[CocoaDSFile saveStateURL] path]; NSString *saveStatePath = [[CocoaDSFile saveStateURL] path];
if (saveStatePath == nil) if (saveStatePath == nil)
{ {
@ -1011,7 +1029,7 @@
return; return;
} }
const NSInteger slotNumber = cmdAttr.integerValue[0]; const NSInteger slotNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:cmdAttr.input.sender] : cmdAttr.intValue[0];
if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS) if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS)
{ {
return; return;
@ -1037,6 +1055,11 @@
CommandAttributes cmdAttr; CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr]; [cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
NSString *saveStatePath = [[CocoaDSFile saveStateURL] path]; NSString *saveStatePath = [[CocoaDSFile saveStateURL] path];
if (saveStatePath == nil) if (saveStatePath == nil)
{ {
@ -1051,7 +1074,7 @@
return; return;
} }
const NSInteger slotNumber = cmdAttr.integerValue[0]; const NSInteger slotNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:cmdAttr.input.sender] : cmdAttr.intValue[0];
if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS) if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS)
{ {
return; return;
@ -1077,18 +1100,26 @@
[mainWindow copy:nil]; [mainWindow copy:nil];
} }
- (void) cmdToggleSpeedScalar:(NSValue *)cmdAttrValue - (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr; CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr]; [cmdAttrValue getValue:&cmdAttr];
CGFloat speedScalar = cmdAttr.floatValue[0]; const float speedScalar = (cmdAttr.useInputForScalar) ? cmdAttr.input.scalar : cmdAttr.floatValue[0];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setSpeedScalar:speedScalar];
[cdsCore setSpeedScalar:(cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF) ? lastSetSpeedScalar : speedScalar];
} }
- (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue - (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ([cdsCore isSpeedLimitEnabled]) if ([cdsCore isSpeedLimitEnabled])
@ -1105,6 +1136,14 @@
- (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue - (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ([cdsCore isFrameSkipEnabled]) if ([cdsCore isFrameSkipEnabled])
@ -1121,6 +1160,14 @@
- (void) cmdToggleCheats:(NSValue *)cmdAttrValue - (void) cmdToggleCheats:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ([cdsCore isCheatingEnabled]) if ([cdsCore isCheatingEnabled])
@ -1137,14 +1184,19 @@
- (void) cmdToggleExecutePause:(NSValue *)cmdAttrValue - (void) cmdToggleExecutePause:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF || [self currentRom] == nil)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ([cdsCore coreState] == CORESTATE_PAUSE) if ([cdsCore coreState] == CORESTATE_PAUSE)
{ {
if ([self currentRom] != nil) [self executeCore];
{
[self executeCore];
}
} }
else else
{ {
@ -1154,7 +1206,10 @@
- (void) cmdReset:(NSValue *)cmdAttrValue - (void) cmdReset:(NSValue *)cmdAttrValue
{ {
if ([self currentRom] == nil) CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF || [self currentRom] == nil)
{ {
return; return;
} }
@ -1187,13 +1242,46 @@
} }
} }
- (void) cmdToggleMute:(NSValue *)cmdAttrValue
{
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
float vol = 0.0f;
if (isSoundMuted)
{
isSoundMuted = NO;
vol = lastSetVolumeValue;
[self setStatusText:@"Sound unmuted."];
}
else
{
isSoundMuted = YES;
[self setStatusText:@"Sound muted."];
}
[self setCurrentVolumeValue:vol];
[CocoaDSUtil messageSendOneWayWithFloat:[cdsSpeaker receivePort] msgID:MESSAGE_SET_VOLUME floatValue:vol];
}
- (void) cmdToggleGPUState:(NSValue *)cmdAttrValue - (void) cmdToggleGPUState:(NSValue *)cmdAttrValue
{ {
CommandAttributes cmdAttr; CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr]; [cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == INPUT_ATTRIBUTE_STATE_OFF)
{
return;
}
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
const NSInteger bitNumber = cmdAttr.integerValue[0]; const NSInteger bitNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:cmdAttr.input.sender] : cmdAttr.intValue[0];
const UInt32 flagBit = [cdsCore.cdsGPU gpuStateFlags] ^ (1 << bitNumber); const UInt32 flagBit = [cdsCore.cdsGPU gpuStateFlags] ^ (1 << bitNumber);
[cdsCore.cdsGPU setGpuStateFlags:flagBit]; [cdsCore.cdsGPU setGpuStateFlags:flagBit];
@ -1837,13 +1925,9 @@
[(NSMenuItem*)theItem setState:NSOnState]; [(NSMenuItem*)theItem setState:NSOnState];
} }
} }
else if (speedScalar == [theItem tag])
{
[(NSMenuItem*)theItem setState:NSOnState];
}
else else
{ {
[(NSMenuItem*)theItem setState:NSOffState]; [(NSMenuItem*)theItem setState:(speedScalar == [theItem tag]) ? NSOnState : NSOffState];
} }
} }
else if ([(id)theItem isMemberOfClass:[NSToolbarItem class]]) else if ([(id)theItem isMemberOfClass:[NSToolbarItem class]])
@ -1866,56 +1950,28 @@
{ {
if ([(id)theItem isMemberOfClass:[NSMenuItem class]]) if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{ {
if ([cdsCore isSpeedLimitEnabled]) [(NSMenuItem*)theItem setTitle:([cdsCore isSpeedLimitEnabled]) ? NSSTRING_TITLE_DISABLE_SPEED_LIMIT : NSSTRING_TITLE_ENABLE_SPEED_LIMIT];
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_DISABLE_SPEED_LIMIT];
}
else
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_ENABLE_SPEED_LIMIT];
}
} }
} }
else if (theAction == @selector(toggleAutoFrameSkip:)) else if (theAction == @selector(toggleAutoFrameSkip:))
{ {
if ([(id)theItem isMemberOfClass:[NSMenuItem class]]) if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{ {
if ([cdsCore isFrameSkipEnabled]) [(NSMenuItem*)theItem setTitle:([cdsCore isFrameSkipEnabled]) ? NSSTRING_TITLE_DISABLE_AUTO_FRAME_SKIP : NSSTRING_TITLE_ENABLE_AUTO_FRAME_SKIP];
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_DISABLE_AUTO_FRAME_SKIP];
}
else
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_ENABLE_AUTO_FRAME_SKIP];
}
} }
} }
else if (theAction == @selector(cheatsDisable:)) else if (theAction == @selector(toggleCheats:))
{ {
if ([(id)theItem isMemberOfClass:[NSMenuItem class]]) if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{ {
if ([cdsCore isCheatingEnabled]) [(NSMenuItem*)theItem setTitle:([cdsCore isCheatingEnabled]) ? NSSTRING_TITLE_DISABLE_CHEATS : NSSTRING_TITLE_ENABLE_CHEATS];
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_DISABLE_CHEATS];
}
else
{
[(NSMenuItem*)theItem setTitle:NSSTRING_TITLE_ENABLE_CHEATS];
}
} }
} }
else if (theAction == @selector(changeRomSaveType:)) else if (theAction == @selector(changeRomSaveType:))
{ {
if ([(id)theItem isMemberOfClass:[NSMenuItem class]]) if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{ {
if ([self selectedRomSaveTypeID] == [theItem tag]) [(NSMenuItem*)theItem setState:([self selectedRomSaveTypeID] == [theItem tag]) ? NSOnState : NSOffState];
{
[(NSMenuItem*)theItem setState:NSOnState];
}
else
{
[(NSMenuItem*)theItem setState:NSOffState];
}
} }
} }
else if (theAction == @selector(openEmuSaveState:) || else if (theAction == @selector(openEmuSaveState:) ||
@ -1940,14 +1996,7 @@
{ {
if ([(id)theItem isMemberOfClass:[NSMenuItem class]]) if ([(id)theItem isMemberOfClass:[NSMenuItem class]])
{ {
if ([cdsCore.cdsGPU gpuStateByBit:[theItem tag]]) [(NSMenuItem*)theItem setState:([cdsCore.cdsGPU gpuStateByBit:[theItem tag]]) ? NSOnState : NSOffState];
{
[(NSMenuItem*)theItem setState:NSOnState];
}
else
{
[(NSMenuItem*)theItem setState:NSOffState];
}
} }
} }
else if (theAction == @selector(changeScale:)) else if (theAction == @selector(changeScale:))
@ -1979,13 +2028,9 @@
[(NSMenuItem*)theItem setState:NSOnState]; [(NSMenuItem*)theItem setState:NSOnState];
} }
} }
else if (viewRotation == [theItem tag])
{
[(NSMenuItem*)theItem setState:NSOnState];
}
else else
{ {
[(NSMenuItem*)theItem setState:NSOffState]; [(NSMenuItem*)theItem setState:(viewRotation == [theItem tag]) ? NSOnState : NSOffState];
} }
} }
} }

View File

@ -23,9 +23,9 @@
#include <string> #include <string>
#include <vector> #include <vector>
#define INPUT_HANDLER_MAX_ATTRIBUTE_VALUES 4 #define INPUT_HANDLER_STRING_LENGTH 256
enum enum InputAttributeState
{ {
INPUT_ATTRIBUTE_STATE_OFF = 0, INPUT_ATTRIBUTE_STATE_OFF = 0,
INPUT_ATTRIBUTE_STATE_ON, INPUT_ATTRIBUTE_STATE_ON,
@ -46,38 +46,41 @@ enum
typedef struct typedef struct
{ {
std::string deviceName; char deviceName[INPUT_HANDLER_STRING_LENGTH];
std::string deviceCode; char deviceCode[INPUT_HANDLER_STRING_LENGTH];
std::string elementName; char elementName[INPUT_HANDLER_STRING_LENGTH];
std::string elementCode; char elementCode[INPUT_HANDLER_STRING_LENGTH];
NSInteger inputState; InputAttributeState state; // The input state that is sent on command dispatch
int32_t intCoordX; // The X-coordinate as an int for commands that require a location
NSInteger integerValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; int32_t intCoordY; // The Y-coordinate as an int for commands that require a location
CGFloat floatValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; float floatCoordX; // The X-coordinate as a float for commands that require a location
id object[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; float floatCoordY; // The Y-coordinate as a float for commands that require a location
float scalar; // A scalar value for commands that require a scalar
id sender; // An object for commands that require an object
} InputAttributes; } InputAttributes;
typedef struct typedef struct
{ {
SEL selector; char tag[INPUT_HANDLER_STRING_LENGTH]; // A string identifier for these attributes
NSInteger commandID; SEL selector; // The selector that is called on command dispatch
NSInteger inputState; int32_t intValue[4]; // Context dependent int values
float floatValue[4]; // Context dependent float values
id object[4]; // Context dependent objects
NSInteger integerValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; bool useInputForIntCoord; // The command will prefer the input device's int coordinate
BOOL useIntegerInputValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; bool useInputForFloatCoord; // The command will prefer the input device's float coordinate
bool useInputForScalar; // The command will prefer the input device's scalar
bool useInputForSender; // The command will prefer the input device's sender
CGFloat floatValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES]; InputAttributes input; // The input device's attributes
BOOL useFloatInputValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES];
id object[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES];
BOOL useObjectInputValue[INPUT_HANDLER_MAX_ATTRIBUTE_VALUES];
} CommandAttributes; } CommandAttributes;
typedef std::vector<InputAttributes> InputAttributesList; typedef std::vector<InputAttributes> InputAttributesList;
typedef std::vector<CommandAttributes> CommandAttributesList; typedef std::vector<CommandAttributes> CommandAttributesList;
typedef std::tr1::unordered_map<std::string, std::string> CommandTagMap; // Key = Input key in deviceCode:elementCode format, Value = Command Tag typedef std::tr1::unordered_map<std::string, CommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = CommandAttributes
typedef std::tr1::unordered_map<std::string, CommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = CommandAttributes typedef std::tr1::unordered_map<std::string, CommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = CommandAttributes
typedef std::tr1::unordered_map<std::string, SEL> CommandSelectorMap; // Key = Command Tag, Value = Obj-C Selector
#pragma mark - #pragma mark -
@interface InputHIDDevice : NSObject @interface InputHIDDevice : NSObject
@ -141,36 +144,58 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@interface InputManager : NSObject @interface InputManager : NSObject
{ {
EmuControllerDelegate *emuControl; EmuControllerDelegate *emuControl;
NSOutlineView *inputPrefsOutlineView;
id<InputHIDManagerTarget> hidInputTarget; id<InputHIDManagerTarget> hidInputTarget;
InputHIDManager *hidManager; InputHIDManager *hidManager;
NSMutableDictionary *inputMappings;
CommandTagMap commandMap;
CommandAttributesMap commandMasterList; InputCommandMap commandMap;
CommandAttributesMap defaultCommandAttributes;
CommandSelectorMap commandSelector;
} }
@property (assign) IBOutlet EmuControllerDelegate *emuControl; @property (readonly) IBOutlet EmuControllerDelegate *emuControl;
@property (readonly) IBOutlet NSOutlineView *inputPrefsOutlineView;
@property (retain) id<InputHIDManagerTarget> hidInputTarget; @property (retain) id<InputHIDManagerTarget> hidInputTarget;
@property (retain) NSMutableDictionary *inputMappings;
- (void) addMappingsUsingUserDefaults; - (void) addMappingsUsingUserDefaults;
- (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceDict commandTag:(const char *)commandTag; - (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceDict commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandTag:(const char *)commandTag; - (void) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingUsingInputList:(const InputAttributesList *)inputList commandTag:(const char *)commandTag; - (void) addMappingUsingInputList:(const InputAttributesList *)inputList commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingForIBAction:(const SEL)theSelector commandTag:(const char *)commandTag; - (void) addMappingForIBAction:(const SEL)theSelector commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandTag:(const char *)commandTag; - (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandAttributes:(const CommandAttributes *)cmdAttr;
- (void) removeMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode; - (void) removeMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) removeAllMappingsOfCommandTag:(const char *)commandTag; - (void) removeAllMappingsForCommandTag:(const char *)commandTag;
- (CommandAttributesList) generateCommandListUsingInputList:(const InputAttributesList *)inputList; - (CommandAttributesList) generateCommandListUsingInputList:(const InputAttributesList *)inputList;
- (void) dispatchCommandList:(const CommandAttributesList *)cmdList; - (void) dispatchCommandList:(const CommandAttributesList *)cmdList;
- (BOOL) dispatchCommandUsingInputAttributes:(const InputAttributes *)inputAttr; - (BOOL) dispatchCommandUsingInputAttributes:(const InputAttributes *)inputAttr;
- (BOOL) dispatchCommandUsingIBAction:(const SEL)theSelector tag:(const NSInteger)tagValue; - (BOOL) dispatchCommandUsingIBAction:(const SEL)theSelector sender:(id)sender;
- (void) writeUserDefaultsMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandTag:(const char *)commandTag; - (void) writeDefaultsInputMappings;
- (SEL) selectorOfCommandTag:(const char *)commandTag;
- (CommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag;
- (CommandAttributes) mappedCommandAttributesOfDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) setMappedCommandAttributes:(const CommandAttributes *)cmdAttr deviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) updateInputSettingsSummaryInDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo commandTag:(const char *)commandTag;
CommandAttributes NewDefaultCommandAttributes(const char *commandTag);
CommandAttributes NewCommandAttributesForSelector(const char *commandTag, const SEL theSelector);
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NSUInteger controlID);
void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr, NSDictionary *deviceInfo);
NSDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttributes *cmdAttr,
NSString *deviceCode,
NSString *deviceName,
NSString *elementCode,
NSString *elementName);
InputAttributesList InputManagerEncodeHIDQueue(const IOHIDQueueRef hidQueue); InputAttributesList InputManagerEncodeHIDQueue(const IOHIDQueueRef hidQueue);
InputAttributes InputManagerEncodeKeyboardInput(const unsigned short keyCode, BOOL keyPressed); InputAttributes InputManagerEncodeKeyboardInput(const unsigned short keyCode, BOOL keyPressed);
InputAttributes InputManagerEncodeMouseButtonInput(const NSInteger buttonNumber, const NSPoint touchLoc, BOOL buttonPressed); InputAttributes InputManagerEncodeMouseButtonInput(const NSInteger buttonNumber, const NSPoint touchLoc, BOOL buttonPressed);
InputAttributes InputManagerEncodeIBAction(const SEL theSelector, const NSInteger tagValue); InputAttributes InputManagerEncodeIBAction(const SEL theSelector, id sender);
@end @end

File diff suppressed because it is too large Load Diff

View File

@ -105,7 +105,6 @@
- (void) setupSlotMenuItems; - (void) setupSlotMenuItems;
- (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber; - (NSMenuItem *) addSlotMenuItem:(NSMenu *)menu slotNumber:(NSUInteger)slotNumber;
- (void) setupUserDefaults; - (void) setupUserDefaults;
- (void) updateInputDisplayFields;
- (IBAction) showMigrationWindow:(id)sender; - (IBAction) showMigrationWindow:(id)sender;
- (IBAction) handleMigrationWindow:(id)sender; - (IBAction) handleMigrationWindow:(id)sender;
- (void) setRomInfoPanelBoxTitleColors; - (void) setRomInfoPanelBoxTitleColors;

View File

@ -201,6 +201,8 @@
// Setup the applications settings from the user defaults file. // Setup the applications settings from the user defaults file.
[self setupUserDefaults]; [self setupUserDefaults];
[inputPrefsView initSettingsSheets];
} }
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
@ -471,9 +473,6 @@
[prefBindings setValue:[cheatDatabasePath lastPathComponent] forKey:@"R4CheatDatabaseName"]; [prefBindings setValue:[cheatDatabasePath lastPathComponent] forKey:@"R4CheatDatabaseName"];
} }
// Set the sound input mode per user preferences.
[[cdsCore cdsController] setSoundInputMode:[[NSUserDefaults standardUserDefaults] integerForKey:@"Input_AudioInputMode"]];
// Update the SPU Sync controls in the Preferences window. // Update the SPU Sync controls in the Preferences window.
if ([[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMode"] == SPU_SYNC_MODE_DUAL_SYNC_ASYNC) if ([[NSUserDefaults standardUserDefaults] integerForKey:@"SPU_SyncMode"] == SPU_SYNC_MODE_DUAL_SYNC_ASYNC)
{ {
@ -495,9 +494,6 @@
[prefBindings setValue:nil forKey:@"AutoloadRomName"]; [prefBindings setValue:nil forKey:@"AutoloadRomName"];
} }
// Update all of the input display fields.
[self updateInputDisplayFields];
// Set the menu for the display rotation. // Set the menu for the display rotation.
const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"]; const double displayRotation = (double)[[NSUserDefaults standardUserDefaults] floatForKey:@"DisplayView_Rotation"];
[prefWindowDelegate updateDisplayRotationMenu:displayRotation]; [prefWindowDelegate updateDisplayRotationMenu:displayRotation];
@ -506,40 +502,6 @@
[prefWindowDelegate updateVolumeIcon:nil]; [prefWindowDelegate updateVolumeIcon:nil];
[emuControl setupUserDefaults]; [emuControl setupUserDefaults];
[inputManager addMappingsUsingUserDefaults];
}
- (void) updateInputDisplayFields
{
PreferencesWindowDelegate *prefWindowDelegate = [prefWindow delegate];
NSMutableDictionary *prefBindings = [prefWindowDelegate bindings];
if ([[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"] == nil)
{
return;
}
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Up"] forKey:@"Input_Up"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Down"] forKey:@"Input_Down"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Left"] forKey:@"Input_Left"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Right"] forKey:@"Input_Right"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"A"] forKey:@"Input_A"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"B"] forKey:@"Input_B"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"X"] forKey:@"Input_X"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Y"] forKey:@"Input_Y"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"L"] forKey:@"Input_L"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"R"] forKey:@"Input_R"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Start"] forKey:@"Input_Start"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Select"] forKey:@"Input_Select"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Microphone"] forKey:@"Input_Microphone"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Lid"] forKey:@"Input_Lid"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Debug"] forKey:@"Input_Debug"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Speed Half"] forKey:@"Input_SpeedHalf"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Speed Double"] forKey:@"Input_SpeedDouble"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"HUD"] forKey:@"Input_HUD"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Execute"] forKey:@"Input_Execute"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Pause"] forKey:@"Input_Pause"];
[prefBindings setValue:[inputPrefsView parseMappingDisplayString:"Reset"] forKey:@"Input_Reset"];
} }
- (IBAction) showMigrationWindow:(id)sender - (IBAction) showMigrationWindow:(id)sender

View File

@ -21,27 +21,72 @@
@class CocoaDSController; @class CocoaDSController;
@interface InputPrefProperties : NSObject
{
NSString *commandTag;
NSImage *icon;
NSWindow *settingsSheet;
}
@interface InputPrefsView : NSView <InputHIDManagerTarget> @property (retain) NSString *commandTag;
@property (retain) NSImage *icon;
@property (retain) NSWindow *settingsSheet;
- (id) initWithCommandTag:(NSString *)theCommandTag icon:(NSImage *)theIcon sheet:(NSWindow *)theSheet;
@end
#pragma mark -
@interface InputPrefsView : NSView <InputHIDManagerTarget, NSOutlineViewDelegate, NSOutlineViewDataSource>
{ {
NSWindow *prefWindow; NSWindow *prefWindow;
NSOutlineView *inputPrefOutlineView;
NSObjectController *inputSettingsController;
NSWindow *inputSettingsMicrophone;
NSWindow *inputSettingsTouch;
NSWindow *inputSettingsLoadStateSlot;
NSWindow *inputSettingsSaveStateSlot;
NSWindow *inputSettingsSetSpeedLimit;
NSWindow *inputSettingsGPUState;
InputManager *inputManager; InputManager *inputManager;
NSButton *lastConfigButton; NSString *configInputTargetID;
NSInteger configInputTargetID;
NSMutableDictionary *configInputList; NSMutableDictionary *configInputList;
std::tr1::unordered_map<NSInteger, std::string> commandTagMap; // Key = Command ID, Value = Command Tag NSDictionary *inputPrefProperties;
NSDictionary *displayStringBindings; NSDictionary *inputSettingsMappings;
NSArray *commandTagList;
} }
@property (readonly) IBOutlet NSWindow *prefWindow; @property (readonly) IBOutlet NSWindow *prefWindow;
@property (readonly) IBOutlet NSOutlineView *inputPrefOutlineView;
@property (readonly) IBOutlet NSObjectController *inputSettingsController;
@property (readonly) IBOutlet NSWindow *inputSettingsMicrophone;
@property (readonly) IBOutlet NSWindow *inputSettingsTouch;
@property (readonly) IBOutlet NSWindow *inputSettingsLoadStateSlot;
@property (readonly) IBOutlet NSWindow *inputSettingsSaveStateSlot;
@property (readonly) IBOutlet NSWindow *inputSettingsSetSpeedLimit;
@property (readonly) IBOutlet NSWindow *inputSettingsGPUState;
@property (readonly) IBOutlet InputManager *inputManager; @property (readonly) IBOutlet InputManager *inputManager;
@property (assign) NSInteger configInputTargetID; @property (retain) NSString *configInputTargetID;
- (void) initSettingsSheets;
- (NSString *) commandTagFromInputList:(NSArray *)inputList;
- (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed; - (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed;
- (BOOL) handleMouseButtonEvent:(NSEvent *)mouseEvent buttonPressed:(BOOL)buttonPressed; - (BOOL) handleMouseButtonEvent:(NSEvent *)mouseEvent buttonPressed:(BOOL)buttonPressed;
- (NSString *) parseMappingDisplayString:(const char *)commandTag; - (BOOL) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandTag:(NSString *)commandTag;
- (void) setMappingUsingDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo;
- (void) didEndSettingsSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (IBAction) inputButtonSet:(id)sender; - (IBAction) setInputAdd:(id)sender;
- (IBAction) removeInput:(id)sender;
- (IBAction) changeSpeed:(id)sender;
- (IBAction) showSettingsSheet:(id)sender;
- (IBAction) closeSettingsSheet:(id)sender;
@end @end

View File

@ -21,12 +21,61 @@
#import "cocoa_globals.h" #import "cocoa_globals.h"
#import "cocoa_input.h" #import "cocoa_input.h"
#import "cocoa_util.h"
#define INPUT_HOLD_TIME 0.1 // Time in seconds to hold a button in its on state when mapping an input. #define INPUT_HOLD_TIME 0.1 // Time in seconds to hold a button in its on state when mapping an input.
@implementation InputPrefProperties
@synthesize commandTag;
@synthesize icon;
@synthesize settingsSheet;
- (id)init
{
return [self initWithCommandTag:@"" icon:nil sheet:nil];
}
- (id) initWithCommandTag:(NSString *)theCommandTag icon:(NSImage *)theIcon sheet:(NSWindow *)theSheet
{
self = [super init];
if (self == nil)
{
return self;
}
commandTag = [theCommandTag retain];
icon = [theIcon retain];
settingsSheet = [theSheet retain];
return self;
}
- (void)dealloc
{
[self setCommandTag:nil];
[self setIcon:nil];
[self setSettingsSheet:nil];
[super dealloc];
}
@end
#pragma mark -
@implementation InputPrefsView @implementation InputPrefsView
@synthesize prefWindow; @synthesize prefWindow;
@synthesize inputPrefOutlineView;
@synthesize inputSettingsController;
@synthesize inputSettingsMicrophone;
@synthesize inputSettingsTouch;
@synthesize inputSettingsLoadStateSlot;
@synthesize inputSettingsSaveStateSlot;
@synthesize inputSettingsSetSpeedLimit;
@synthesize inputSettingsGPUState;
@synthesize inputManager; @synthesize inputManager;
@dynamic configInputTargetID; @dynamic configInputTargetID;
@ -38,57 +87,34 @@
return self; return self;
} }
lastConfigButton = nil; configInputTargetID = nil;
configInputTargetID = 0; configInputList = [[NSMutableDictionary alloc] initWithCapacity:128];
configInputList = [[NSMutableDictionary alloc] initWithCapacity:32];
displayStringBindings = [[NSDictionary alloc] initWithObjectsAndKeys: inputPrefProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
@"Input_Up", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_UP], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"UNKNOWN COMMAND",
@"Input_Down", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_DOWN], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowUp_420x420" ofType:@"png"]] autorelease], @"Up",
@"Input_Left", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_LEFT], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowDown_420x420" ofType:@"png"]] autorelease], @"Down",
@"Input_Right", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_RIGHT], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowLeft_420x420" ofType:@"png"]] autorelease], @"Left",
@"Input_A", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_A], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ArrowRight_420x420" ofType:@"png"]] autorelease], @"Right",
@"Input_B", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_B], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonA_420x420" ofType:@"png"]] autorelease], @"A",
@"Input_X", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_X], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonB_420x420" ofType:@"png"]] autorelease], @"B",
@"Input_Y", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_Y], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonX_420x420" ofType:@"png"]] autorelease], @"X",
@"Input_L", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_L], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonY_420x420" ofType:@"png"]] autorelease], @"Y",
@"Input_R", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_R], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonL_420x420" ofType:@"png"]] autorelease], @"L",
@"Input_Start", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_START], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonR_420x420" ofType:@"png"]] autorelease], @"R",
@"Input_Select", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_SELECT], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonStart_420x420" ofType:@"png"]] autorelease], @"Start",
@"Input_Microphone", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_SIM_MIC], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Select",
@"Input_Lid", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_LID], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Microphone_420x420" ofType:@"png"]] autorelease], @"Microphone",
@"Input_Debug", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_DEBUG], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_ShowHUD_420x420" ofType:@"png"]] autorelease], @"HUD",
@"Input_SpeedHalf", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_SPEED_HALF], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute",
@"Input_SpeedDouble", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_SPEED_DOUBLE], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Pause_420x420" ofType:@"png"]] autorelease], @"Pause",
@"Input_HUD", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_TOGGLE_HUD], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Execute_420x420" ofType:@"png"]] autorelease], @"Execute/Pause",
@"Input_Execute", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_EXECUTE], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_Reset_420x420" ofType:@"png"]] autorelease], @"Reset",
@"Input_Pause", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_PAUSE], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_DSButtonSelect_420x420" ofType:@"png"]] autorelease], @"Touch",
@"Input_Reset", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_RESET], [[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Icon_VolumeMute_16x16" ofType:@"png"]] autorelease], @"Mute/Unmute",
@"Input_Touch", [NSString stringWithFormat:@"%i", PREF_INPUT_BUTTON_TOUCH], nil];
nil];
commandTagMap[PREF_INPUT_BUTTON_UP] = "Up"; commandTagList = [[[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DefaultKeyMappings" ofType:@"plist"]] valueForKey:@"CommandTagList"] retain];
commandTagMap[PREF_INPUT_BUTTON_DOWN] = "Down";
commandTagMap[PREF_INPUT_BUTTON_LEFT] = "Left";
commandTagMap[PREF_INPUT_BUTTON_RIGHT] = "Right";
commandTagMap[PREF_INPUT_BUTTON_A] = "A";
commandTagMap[PREF_INPUT_BUTTON_B] = "B";
commandTagMap[PREF_INPUT_BUTTON_X] = "X";
commandTagMap[PREF_INPUT_BUTTON_Y] = "Y";
commandTagMap[PREF_INPUT_BUTTON_L] = "L";
commandTagMap[PREF_INPUT_BUTTON_R] = "R";
commandTagMap[PREF_INPUT_BUTTON_START] = "Start";
commandTagMap[PREF_INPUT_BUTTON_SELECT] = "Select";
commandTagMap[PREF_INPUT_BUTTON_SIM_MIC] = "Microphone";
commandTagMap[PREF_INPUT_BUTTON_LID] = "Lid";
commandTagMap[PREF_INPUT_BUTTON_DEBUG] = "Debug";
commandTagMap[PREF_INPUT_BUTTON_SPEED_HALF] = "Speed Half";
commandTagMap[PREF_INPUT_BUTTON_SPEED_DOUBLE] = "Speed Double";
commandTagMap[PREF_INPUT_BUTTON_TOGGLE_HUD] = "HUD";
commandTagMap[PREF_INPUT_BUTTON_EXECUTE] = "Execute";
commandTagMap[PREF_INPUT_BUTTON_PAUSE] = "Pause";
commandTagMap[PREF_INPUT_BUTTON_RESET] = "Reset";
commandTagMap[PREF_INPUT_BUTTON_TOUCH] = "Touch";
return self; return self;
} }
@ -96,102 +122,163 @@
- (void)dealloc - (void)dealloc
{ {
[configInputList release]; [configInputList release];
[displayStringBindings release]; [inputPrefProperties release];
[inputSettingsMappings release];
[commandTagList release];
[super dealloc]; [super dealloc];
} }
#pragma mark Dynamic Properties #pragma mark Dynamic Properties
- (void) setConfigInputTargetID:(NSInteger)targetID - (void) setConfigInputTargetID:(NSString *)targetID
{ {
if (targetID == 0) if (targetID == nil)
{ {
[lastConfigButton setState:NSOffState]; [configInputTargetID release];
lastConfigButton = nil;
} }
configInputTargetID = targetID; configInputTargetID = [targetID retain];
[[self inputManager] setHidInputTarget:(targetID == 0) ? nil : self]; [[self inputManager] setHidInputTarget:(targetID == nil) ? nil : self];
} }
- (NSInteger) configInputTargetID - (NSString *) configInputTargetID
{ {
return configInputTargetID; return configInputTargetID;
} }
#pragma mark Class Methods #pragma mark Class Methods
- (void) initSettingsSheets
{
inputSettingsMappings = [[NSDictionary alloc] initWithObjectsAndKeys:
inputSettingsMicrophone, @"Microphone",
inputSettingsTouch, @"Touch",
inputSettingsLoadStateSlot, @"Load State Slot",
inputSettingsSaveStateSlot, @"Save State Slot",
inputSettingsSetSpeedLimit, @"Set Speed",
inputSettingsGPUState, @"Enable/Disable GPU State",
nil];
}
- (NSString *) commandTagFromInputList:(NSArray *)inputList
{
NSString *commandTag = nil;
if (inputList == nil)
{
return commandTag;
}
NSDictionary *inputMappings = [inputManager inputMappings];
for (NSString *tag in inputMappings)
{
if (inputList == [inputMappings valueForKey:tag])
{
commandTag = tag;
break;
}
}
return commandTag;
}
- (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed - (BOOL) handleKeyboardEvent:(NSEvent *)theEvent keyPressed:(BOOL)keyPressed
{ {
BOOL isHandled = NO; const InputAttributes inputAttr = InputManagerEncodeKeyboardInput([theEvent keyCode], keyPressed);
return [self addMappingUsingInputAttributes:&inputAttr commandTag:[self configInputTargetID]];
if ([self configInputTargetID] == 0)
{
return isHandled;
}
std::string commandTag = commandTagMap[[self configInputTargetID]];
if (commandTag.empty())
{
return isHandled;
}
InputAttributes inputAttr = InputManagerEncodeKeyboardInput([theEvent keyCode], keyPressed);
[inputManager addMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
[inputManager writeUserDefaultsMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
NSMutableDictionary *prefWindowBindings = [(PreferencesWindowDelegate *)[prefWindow delegate] bindings];
NSString *displayBinding = (NSString *)[displayStringBindings valueForKey:[NSString stringWithFormat:@"%i", [self configInputTargetID]]];
[prefWindowBindings setValue:[self parseMappingDisplayString:commandTag.c_str()] forKey:displayBinding];
[self setConfigInputTargetID:0];
isHandled = YES;
return isHandled;
} }
- (BOOL) handleMouseButtonEvent:(NSEvent *)mouseEvent buttonPressed:(BOOL)buttonPressed - (BOOL) handleMouseButtonEvent:(NSEvent *)mouseEvent buttonPressed:(BOOL)buttonPressed
{ {
BOOL isHandled = NO; const InputAttributes inputAttr = InputManagerEncodeMouseButtonInput([mouseEvent buttonNumber], NSMakePoint(0.0f, 0.0f), buttonPressed);
return [self addMappingUsingInputAttributes:&inputAttr commandTag:[self configInputTargetID]];
if ([self configInputTargetID] == 0)
{
return isHandled;
}
std::string commandTag = commandTagMap[[self configInputTargetID]];
if (commandTag.empty())
{
return isHandled;
}
InputAttributes inputAttr = InputManagerEncodeMouseButtonInput([mouseEvent buttonNumber], NSMakePoint(0.0f, 0.0f), buttonPressed);
[inputManager addMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
[inputManager writeUserDefaultsMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
NSMutableDictionary *prefWindowBindings = [(PreferencesWindowDelegate *)[prefWindow delegate] bindings];
NSString *displayBinding = (NSString *)[displayStringBindings valueForKey:[NSString stringWithFormat:@"%i", [self configInputTargetID]]];
[prefWindowBindings setValue:[self parseMappingDisplayString:commandTag.c_str()] forKey:displayBinding];
[self setConfigInputTargetID:0];
isHandled = YES;
return isHandled;
} }
- (NSString *) parseMappingDisplayString:(const char *)commandTag - (BOOL) addMappingUsingInputAttributes:(const InputAttributes *)inputAttr commandTag:(NSString *)commandTag
{ {
NSDictionary *userMappings = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"Input_ControllerMappings"]; BOOL didMap = NO;
NSArray *mappingList = (NSArray *)[userMappings valueForKey:[NSString stringWithCString:commandTag encoding:NSUTF8StringEncoding]];
NSDictionary *mapping = (NSDictionary *)[mappingList objectAtIndex:0];
NSString *deviceName = (NSString *)[mapping valueForKey:@"deviceName"];
NSString *elementName = (NSString *)[mapping valueForKey:@"elementName"];
NSString *displayString = [NSString stringWithString:deviceName]; if (commandTag == nil)
displayString = [displayString stringByAppendingString:@": "]; {
displayString = [displayString stringByAppendingString:elementName]; return didMap;
}
return displayString; const char *cmdTag = [commandTag cStringUsingEncoding:NSUTF8StringEncoding];
if (cmdTag == NULL)
{
return didMap;
}
// Add the input mapping.
const CommandAttributes cmdAttr = [inputManager defaultCommandAttributesForCommandTag:cmdTag];
[inputManager addMappingUsingInputAttributes:inputAttr commandAttributes:&cmdAttr];
[inputManager writeDefaultsInputMappings];
// Deselect the row of the command tag.
NSDictionary *inputMappings = [inputManager inputMappings];
NSArray *mappingList = (NSArray *)[inputMappings valueForKey:[self configInputTargetID]];
const NSInteger rowNumber = [inputPrefOutlineView rowForItem:mappingList];
if (rowNumber != -1)
{
[inputPrefOutlineView deselectRow:rowNumber];
}
// Update all expanded command tags.
for (NSString *tag in inputMappings)
{
NSArray *inputList = (NSArray *)[inputMappings valueForKey:tag];
if ([inputPrefOutlineView isItemExpanded:inputList])
{
[inputPrefOutlineView reloadItem:inputList reloadChildren:YES];
}
}
[self setConfigInputTargetID:nil];
didMap = YES;
return didMap;
}
- (void) setMappingUsingDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo
{
if (deviceInfo == nil)
{
return;
}
NSString *deviceCode = (NSString *)[deviceInfo valueForKey:@"deviceCode"];
NSString *elementCode = (NSString *)[deviceInfo valueForKey:@"elementCode"];
const char *devCode = [deviceCode cStringUsingEncoding:NSUTF8StringEncoding];
const char *elCode = [elementCode cStringUsingEncoding:NSUTF8StringEncoding];
CommandAttributes cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:devCode elementCode:elCode];
UpdateCommandAttributesWithDeviceInfoDictionary(&cmdAttr, deviceInfo);
[inputManager updateInputSettingsSummaryInDeviceInfoDictionary:deviceInfo commandTag:cmdAttr.tag];
[inputManager setMappedCommandAttributes:&cmdAttr deviceCode:devCode elementCode:elCode];
[inputManager writeDefaultsInputMappings];
}
- (void) didEndSettingsSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
NSOutlineView *outlineView = (NSOutlineView *)contextInfo;
NSMutableDictionary *deviceInfo = (NSMutableDictionary *)[inputSettingsController content];
switch (returnCode)
{
case NSCancelButton:
break;
case NSOKButton:
[self setMappingUsingDeviceInfoDictionary:deviceInfo];
[outlineView reloadItem:deviceInfo reloadChildren:NO];
break;
default:
break;
}
[inputSettingsController setContent:nil];
} }
#pragma mark InputHIDManagerTarget Protocol #pragma mark InputHIDManagerTarget Protocol
@ -199,7 +286,7 @@
{ {
BOOL isHandled = NO; BOOL isHandled = NO;
if ([self configInputTargetID] == 0) if ([self configInputTargetID] == nil)
{ {
ClearHIDQueue(hidQueue); ClearHIDQueue(hidQueue);
return isHandled; return isHandled;
@ -211,11 +298,15 @@
for (unsigned int i = 0; i < inputCount; i++) for (unsigned int i = 0; i < inputCount; i++)
{ {
const InputAttributes &inputAttr = inputList[i]; const InputAttributes &inputAttr = inputList[i];
const std::string inputKey = inputAttr.deviceCode + ":" + inputAttr.elementCode; char inputKey[INPUT_HANDLER_STRING_LENGTH*2];
NSString *inputKeyStr = [NSString stringWithCString:inputKey.c_str() encoding:NSUTF8StringEncoding]; strlcpy(inputKey, inputAttr.deviceCode, INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputKey, ":", INPUT_HANDLER_STRING_LENGTH*2);
strlcat(inputKey, inputAttr.elementCode, INPUT_HANDLER_STRING_LENGTH*2);
NSString *inputKeyStr = [NSString stringWithCString:inputKey encoding:NSUTF8StringEncoding];
NSDate *inputOnDate = [configInputList valueForKey:inputKeyStr]; NSDate *inputOnDate = [configInputList valueForKey:inputKeyStr];
if (inputAttr.inputState == INPUT_ATTRIBUTE_STATE_ON) if (inputAttr.state == INPUT_ATTRIBUTE_STATE_ON)
{ {
if (inputOnDate == nil) if (inputOnDate == nil)
{ {
@ -233,21 +324,7 @@
} }
else else
{ {
std::string commandTag = commandTagMap[[self configInputTargetID]]; isHandled = [self addMappingUsingInputAttributes:&inputAttr commandTag:[self configInputTargetID]];
if (commandTag.empty())
{
continue;
}
// Add the input mapping.
[inputManager addMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
[inputManager writeUserDefaultsMappingUsingInputAttributes:&inputAttr commandTag:commandTag.c_str()];
NSMutableDictionary *prefWindowBindings = [(PreferencesWindowDelegate *)[prefWindow delegate] bindings];
NSString *displayBinding = (NSString *)[displayStringBindings valueForKey:[NSString stringWithFormat:@"%i", [self configInputTargetID]]];
[prefWindowBindings setValue:[self parseMappingDisplayString:commandTag.c_str()] forKey:displayBinding];
[self setConfigInputTargetID:0];
break; break;
} }
} }
@ -258,6 +335,199 @@
return isHandled; return isHandled;
} }
#pragma mark NSOutlineViewDelegate Protocol
- (BOOL)selectionShouldChangeInOutlineView:(NSOutlineView *)outlineView
{
return NO;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([(NSString *)[tableColumn identifier] isEqualToString:@"InputCommandTagColumn"] ||
[(NSString *)[tableColumn identifier] isEqualToString:@"InputSettingsColumn"] ||
[(NSString *)[tableColumn identifier] isEqualToString:@"RemoveInputColumn"])
{
return YES;
}
return NO;
}
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
NSCell *outCell = [tableColumn dataCellForRow:[outlineView rowForItem:item]];
if ([columnID isEqualToString:@"InputCommandTagColumn"])
{
if ([item isKindOfClass:[NSArray class]])
{
NSString *commandTag = [self commandTagFromInputList:item];
if (commandTag != nil)
{
NSImage *buttonImage = (NSImage *)[inputPrefProperties valueForKey:commandTag];
if (buttonImage == nil)
{
buttonImage = (NSImage *)[inputPrefProperties valueForKey:@"UNKNOWN COMMAND"];
}
[outCell setTitle:commandTag];
[outCell setImage:buttonImage];
}
else
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
else
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
else if ([columnID isEqualToString:@"InputDeviceColumn"])
{
NSFont *newFont = [[NSFontManager sharedFontManager] fontWithFamily:[[outCell font] familyName]
traits:([item isKindOfClass:[NSArray class]]) ? NSBoldFontMask : 0
weight:0
size:[[outCell font] pointSize]];
[outCell setFont:newFont];
}
else if ([columnID isEqualToString:@"InputSettingsSummaryColumn"])
{
NSFont *newFont = [[NSFontManager sharedFontManager] fontWithFamily:[[outCell font] familyName]
traits:([item isKindOfClass:[NSArray class]]) ? NSBoldFontMask : 0
weight:0
size:[[outCell font] pointSize]];
[outCell setFont:newFont];
}
else if ([columnID isEqualToString:@"InputSettingsColumn"])
{
if ([item isKindOfClass:[NSDictionary class]])
{
NSString *commandTag = [self commandTagFromInputList:[outlineView parentForItem:item]];
NSWindow *theSheet = (NSWindow *)[inputSettingsMappings valueForKey:commandTag];
[outCell setEnabled:(theSheet == nil) ? NO : YES];
}
else
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
else if ([columnID isEqualToString:@"RemoveInputColumn"])
{
if (![item isKindOfClass:[NSDictionary class]])
{
outCell = [[[NSCell alloc] init] autorelease];
}
}
return outCell;
}
#pragma mark NSOutlineViewDataSource Protocol
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (item == nil)
{
NSString *commandTag = [commandTagList objectAtIndex:index];
return [[inputManager inputMappings] valueForKey:commandTag];
}
else if ([item isKindOfClass:[NSArray class]])
{
return [(NSArray *)item objectAtIndex:index];
}
return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
if ([item isKindOfClass:[NSArray class]])
{
return YES;
}
return NO;
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
NSInteger numberChildren = 0;
if (item == nil)
{
numberChildren = [commandTagList count];
}
else if ([item isKindOfClass:[NSArray class]])
{
numberChildren = [(NSArray *)item count];
}
return numberChildren;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString *columnID = (NSString *)[tableColumn identifier];
if ([columnID isEqualToString:@"InputCommandTagColumn"])
{
if ([item isKindOfClass:[NSDictionary class]])
{
return nil;
}
}
else if ([columnID isEqualToString:@"InputDeviceColumn"])
{
if ([item isKindOfClass:[NSArray class]])
{
const unsigned long inputCount = (unsigned long)[(NSArray *)item count];
return [NSString stringWithFormat:(inputCount != 1) ? @"%ld Inputs Mapped" : @"%ld Input Mapped", inputCount];
}
else if ([item isKindOfClass:[NSDictionary class]])
{
return [item valueForKey:@"deviceInfoSummary"];
}
return @"";
}
else if ([columnID isEqualToString:@"InputSettingsSummaryColumn"])
{
NSString *settingsSummary = @"";
if ([item isKindOfClass:[NSDictionary class]])
{
settingsSummary = [item valueForKey:@"inputSettingsSummary"];
}
return settingsSummary;
}
else if ([columnID isEqualToString:@"InputSettingsColumn"])
{
return nil;
}
else if ([columnID isEqualToString:@"RemoveInputColumn"])
{
return nil;
}
return item;
}
- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
{
return [self commandTagFromInputList:item];
}
- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
{
NSString *commandTag = (NSString *)object;
NSArray *inputList = (NSArray *)[[inputManager inputMappings] valueForKey:commandTag];
return inputList;
}
#pragma mark NSResponder Methods #pragma mark NSResponder Methods
- (void)keyDown:(NSEvent *)theEvent - (void)keyDown:(NSEvent *)theEvent
@ -328,25 +598,81 @@
#pragma mark IBAction Methods #pragma mark IBAction Methods
- (IBAction) inputButtonSet:(id)sender - (IBAction) setInputAdd:(id)sender
{ {
NSButton *theButton = (NSButton *)sender; NSOutlineView *outlineView = (NSOutlineView *)sender;
const NSInteger rowNumber = [outlineView clickedRow];
if ([self configInputTargetID] != 0 && lastConfigButton != theButton) [configInputList removeAllObjects];
{
[lastConfigButton setState:NSOffState];
}
if ([theButton state] == NSOnState) if ([outlineView isRowSelected:rowNumber])
{ {
lastConfigButton = theButton; [outlineView deselectRow:rowNumber];
[configInputList removeAllObjects]; [self setConfigInputTargetID:nil];
[self setConfigInputTargetID:[theButton tag]];
} }
else else
{ {
[self setConfigInputTargetID:0]; [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:rowNumber] byExtendingSelection:NO];
NSArray *inputList = (NSArray *)[outlineView itemAtRow:rowNumber];
[self setConfigInputTargetID:[self commandTagFromInputList:inputList]];
[prefWindow makeFirstResponder:self];
} }
} }
- (IBAction) removeInput:(id)sender
{
NSOutlineView *outlineView = (NSOutlineView *)sender;
const NSInteger rowNumber = [outlineView clickedRow];
NSDictionary *deviceInfo = (NSDictionary *)[outlineView itemAtRow:rowNumber];
[inputManager removeMappingUsingDeviceCode:[(NSString *)[deviceInfo valueForKey:@"deviceCode"] cStringUsingEncoding:NSUTF8StringEncoding] elementCode:[(NSString *)[deviceInfo valueForKey:@"elementCode"] cStringUsingEncoding:NSUTF8StringEncoding]];
NSMutableArray *inputList = (NSMutableArray *)[outlineView parentForItem:deviceInfo];
[inputList removeObject:deviceInfo];
[outlineView reloadItem:inputList reloadChildren:YES];
[inputManager writeDefaultsInputMappings];
}
- (IBAction) changeSpeed:(id)sender
{
NSMutableDictionary *deviceInfo = (NSMutableDictionary *)[inputSettingsController content];
if (deviceInfo != nil)
{
const float speedScalar = (float)[CocoaDSUtil getIBActionSenderTag:sender] / 100.0f;
[deviceInfo setObject:[NSNumber numberWithFloat:speedScalar] forKey:@"floatValue0"];
}
}
- (IBAction) showSettingsSheet:(id)sender
{
NSOutlineView *outlineView = (NSOutlineView *)sender;
const NSInteger rowNumber = [outlineView clickedRow];
NSMutableDictionary *item = (NSMutableDictionary *)[outlineView itemAtRow:rowNumber];
NSString *commandTag = [self commandTagFromInputList:[outlineView parentForItem:item]];
NSWindow *theSheet = (NSWindow *)[inputSettingsMappings valueForKey:commandTag];
if (theSheet == nil)
{
return;
}
[inputSettingsController setContent:item];
[NSApp beginSheet:theSheet
modalForWindow:prefWindow
modalDelegate:self
didEndSelector:@selector(didEndSettingsSheet:returnCode:contextInfo:)
contextInfo:outlineView];
}
- (IBAction) closeSettingsSheet:(id)sender
{
NSWindow *sheet = [(NSControl *)sender window];
[sheet makeFirstResponder:nil]; // Force end of editing of any text fields.
[NSApp endSheet:sheet returnCode:[CocoaDSUtil getIBActionSenderTag:sender]];
}
@end @end

View File

@ -97,8 +97,6 @@
- (IBAction) chooseCheatDatabase:(id)sender; - (IBAction) chooseCheatDatabase:(id)sender;
- (void) chooseCheatDatabaseDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; - (void) chooseCheatDatabaseDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
- (IBAction) selectSoundInputMode:(id)sender;
- (IBAction) selectDisplayMode:(id)sender; - (IBAction) selectDisplayMode:(id)sender;
- (IBAction) selectDisplaySize:(id)sender; - (IBAction) selectDisplaySize:(id)sender;
- (IBAction) selectDisplayRotation:(id)sender; - (IBAction) selectDisplayRotation:(id)sender;

View File

@ -377,12 +377,6 @@
} }
} }
- (IBAction) selectSoundInputMode:(id)sender
{
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore.cdsController setSoundInputMode:[[NSUserDefaults standardUserDefaults] integerForKey:@"Input_AudioInputMode"]];
}
- (IBAction) selectDisplayMode:(id)sender - (IBAction) selectDisplayMode:(id)sender
{ {
const NSInteger displayMode = [(NSMenuItem *)sender tag]; const NSInteger displayMode = [(NSMenuItem *)sender tag];
@ -762,7 +756,7 @@
{ {
[prefWindowController setContent:bindings]; [prefWindowController setContent:bindings];
if ([viewInput configInputTargetID] != 0) if ([viewInput configInputTargetID] != nil)
{ {
[[viewInput inputManager] setHidInputTarget:viewInput]; [[viewInput inputManager] setHidInputTarget:viewInput];
} }
@ -770,7 +764,7 @@
- (void)windowWillClose:(NSNotification *)notification - (void)windowWillClose:(NSNotification *)notification
{ {
[viewInput setConfigInputTargetID:0]; [viewInput setConfigInputTargetID:nil];
} }
@end @end