Cocoa Port: Change CommandAttributes, now renamed ClientCommandAttributes, to call a C function pointer instead of an Objective-C selector when dispatching its command function.

This commit is contained in:
rogerman 2017-10-16 11:35:49 -07:00
parent 5c9fbdfb06
commit 649587fcb1
6 changed files with 426 additions and 385 deletions

View File

@ -149,6 +149,7 @@ class InternalNoiseGenerator;
class WhiteNoiseGenerator; class WhiteNoiseGenerator;
class SineWaveGenerator; class SineWaveGenerator;
class AudioSampleBlockGenerator; class AudioSampleBlockGenerator;
struct ClientCommandAttributes;
typedef union typedef union
{ {
@ -273,6 +274,8 @@ typedef union
}; };
} NDSInputState; // Each bit represents the Pressed/Released state of a single input. Pressed=0, Released=1 } NDSInputState; // Each bit represents the Pressed/Released state of a single input. Pressed=0, Released=1
typedef void (*ClientCommandDispatcher)(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
struct ClientInputDeviceProperties struct ClientInputDeviceProperties
{ {
char deviceName[INPUT_HANDLER_STRING_LENGTH]; char deviceName[INPUT_HANDLER_STRING_LENGTH];
@ -302,6 +305,25 @@ struct ClientInput
}; };
typedef struct ClientInput ClientInput; typedef struct ClientInput ClientInput;
struct ClientCommandAttributes
{
ClientCommandDispatcher dispatchFunction; // The function to be called when this command is dispatched.
char tag[INPUT_HANDLER_STRING_LENGTH]; // A string identifier for these attributes
int32_t intValue[4]; // Context dependent int values
float floatValue[4]; // Context dependent float values
void *object[4]; // Context dependent objects
bool useInputForIntCoord; // The command will prefer the input device's int coordinate
bool useInputForFloatCoord; // The command will prefer the input device's float coordinate
bool useInputForScalar; // The command will prefer the input device's scalar
bool useInputForObject; // The command will prefer the input device's object
ClientInputDeviceProperties input; // The input device's properties
bool allowAnalogInput; // Flag for allowing a command to accept analog inputs
};
typedef struct ClientCommandAttributes ClientCommandAttributes;
typedef std::map<NDSInputID, size_t> NDSUserInputMap; typedef std::map<NDSInputID, size_t> NDSUserInputMap;
typedef std::map<NDSInputID, NDSInputStateBit> NDSInputStateBitMap; typedef std::map<NDSInputID, NDSInputStateBit> NDSInputStateBitMap;
typedef std::vector<ClientInputDeviceProperties> ClientInputDevicePropertiesList; typedef std::vector<ClientInputDeviceProperties> ClientInputDevicePropertiesList;

View File

@ -30,6 +30,7 @@
@class DisplayWindowController; @class DisplayWindowController;
@class RomInfoPanel; @class RomInfoPanel;
@class MacScreenshotCaptureToolDelegate; @class MacScreenshotCaptureToolDelegate;
struct ClientCommandAttributes;
class AudioSampleBlockGenerator; class AudioSampleBlockGenerator;
@interface EmuControllerDelegate : NSObject <NSUserInterfaceValidations, CocoaDSControllerDelegate> @interface EmuControllerDelegate : NSObject <NSUserInterfaceValidations, CocoaDSControllerDelegate>
@ -238,30 +239,34 @@ class AudioSampleBlockGenerator;
- (IBAction) closeSheet:(id)sender; - (IBAction) closeSheet:(id)sender;
- (void) cmdUpdateDSController:(NSValue *)cmdAttrValue; - (void) cmdUpdateDSController:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdUpdateDSControllerWithTurbo:(NSValue *)cmdAttrValue; - (void) cmdUpdateDSControllerWithTurbo:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdUpdateDSTouch:(NSValue *)cmdAttrValue; - (void) cmdUpdateDSTouch:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdUpdateDSMicrophone:(NSValue *)cmdAttrValue; - (void) cmdUpdateDSMicrophone:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdUpdateDSPaddle:(NSValue *)cmdAttrValue; - (void) cmdUpdateDSPaddle:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdLoadEmuSaveStateSlot:(NSValue *)cmdAttrValue; - (void) cmdAutoholdSet:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdSaveEmuSaveStateSlot:(NSValue *)cmdAttrValue; - (void) cmdAutoholdClear:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdCopyScreen:(NSValue *)cmdAttrValue; - (void) cmdLoadEmuSaveStateSlot:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdRotateDisplayRelative:(NSValue *)cmdAttrValue; - (void) cmdSaveEmuSaveStateSlot:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleAllDisplays:(NSValue *)cmdAttrValue;
- (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue; - (void) cmdCopyScreen:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue; - (void) cmdRotateDisplayRelative:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue; - (void) cmdToggleAllDisplays:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleCheats:(NSValue *)cmdAttrValue;
- (void) cmdToggleExecutePause:(NSValue *)cmdAttrValue; - (void) cmdHoldToggleSpeedScalar:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdCoreExecute:(NSValue *)cmdAttrValue; - (void) cmdToggleSpeedLimiter:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdCorePause:(NSValue *)cmdAttrValue; - (void) cmdToggleAutoFrameSkip:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdFrameAdvance:(NSValue *)cmdAttrValue; - (void) cmdToggleCheats:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdFrameJump:(NSValue *)cmdAttrValue; - (void) cmdToggleExecutePause:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdReset:(NSValue *)cmdAttrValue; - (void) cmdCoreExecute:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleGPUState:(NSValue *)cmdAttrValue; - (void) cmdCorePause:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdFrameAdvance:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdFrameJump:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdReset:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleMute:(const ClientCommandAttributes &)cmdAttr;
- (void) cmdToggleGPUState:(const ClientCommandAttributes &)cmdAttr;
- (BOOL) handleLoadRomByURL:(NSURL *)fileURL; - (BOOL) handleLoadRomByURL:(NSURL *)fileURL;
- (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL; - (BOOL) handleUnloadRom:(NSInteger)reasonID romToLoad:(NSURL *)romURL;

View File

@ -1017,10 +1017,8 @@
#pragma mark Class Methods #pragma mark Class Methods
- (void) cmdUpdateDSController:(NSValue *)cmdAttrValue - (void) cmdUpdateDSController:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO; const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO;
const NSUInteger controlID = cmdAttr.intValue[0]; const NSUInteger controlID = cmdAttr.intValue[0];
@ -1039,10 +1037,8 @@
} }
} }
- (void) cmdUpdateDSControllerWithTurbo:(NSValue *)cmdAttrValue - (void) cmdUpdateDSControllerWithTurbo:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO; const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO;
const NSUInteger controlID = cmdAttr.intValue[0]; const NSUInteger controlID = cmdAttr.intValue[0];
const BOOL isTurboEnabled = (BOOL)cmdAttr.intValue[1]; const BOOL isTurboEnabled = (BOOL)cmdAttr.intValue[1];
@ -1064,10 +1060,8 @@
} }
} }
- (void) cmdUpdateDSTouch:(NSValue *)cmdAttrValue - (void) cmdUpdateDSTouch:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO; const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO;
const NSPoint touchLoc = (cmdAttr.useInputForIntCoord) ? NSMakePoint(cmdAttr.input.intCoordX, cmdAttr.input.intCoordY) : NSMakePoint(cmdAttr.intValue[1], cmdAttr.intValue[2]); const NSPoint touchLoc = (cmdAttr.useInputForIntCoord) ? NSMakePoint(cmdAttr.input.intCoordX, cmdAttr.input.intCoordY) : NSMakePoint(cmdAttr.intValue[1], cmdAttr.intValue[2]);
@ -1089,10 +1083,8 @@
} }
} }
- (void) cmdUpdateDSMicrophone:(NSValue *)cmdAttrValue - (void) cmdUpdateDSMicrophone:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO; const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO;
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
@ -1108,10 +1100,8 @@
[cdsController setSelectedAudioFileGenerator:[inputManager audioFileGeneratorFromFilePath:audioFilePath]]; [cdsController setSelectedAudioFileGenerator:[inputManager audioFileGeneratorFromFilePath:audioFilePath]];
} }
- (void) cmdUpdateDSPaddle:(NSValue *)cmdAttrValue - (void) cmdUpdateDSPaddle:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if (cmdAttr.input.isAnalog) if (cmdAttr.input.isAnalog)
@ -1143,10 +1133,8 @@
} }
} }
- (void) cmdAutoholdSet:(NSValue *)cmdAttrValue - (void) cmdAutoholdSet:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO; const BOOL theState = (cmdAttr.input.state == ClientInputDeviceState_On) ? YES : NO;
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
@ -1154,11 +1142,8 @@
[self setStatusText:(theState) ? NSSTRING_STATUS_AUTOHOLD_SET : NSSTRING_STATUS_AUTOHOLD_SET_RELEASE]; [self setStatusText:(theState) ? NSSTRING_STATUS_AUTOHOLD_SET : NSSTRING_STATUS_AUTOHOLD_SET_RELEASE];
} }
- (void) cmdAutoholdClear:(NSValue *)cmdAttrValue - (void) cmdAutoholdClear:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1170,11 +1155,8 @@
} }
- (void) cmdLoadEmuSaveStateSlot:(NSValue *)cmdAttrValue - (void) cmdLoadEmuSaveStateSlot:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1187,7 +1169,7 @@
return; return;
} }
const NSInteger slotNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : cmdAttr.intValue[0]; const NSInteger slotNumber = (cmdAttr.useInputForObject) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : cmdAttr.intValue[0];
if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS) if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS)
{ {
return; return;
@ -1208,11 +1190,8 @@
[self restoreCoreState]; [self restoreCoreState];
} }
- (void) cmdSaveEmuSaveStateSlot:(NSValue *)cmdAttrValue - (void) cmdSaveEmuSaveStateSlot:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1232,7 +1211,7 @@
return; return;
} }
const NSInteger slotNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : cmdAttr.intValue[0]; const NSInteger slotNumber = (cmdAttr.useInputForObject) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : cmdAttr.intValue[0];
if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS) if (slotNumber < 0 || slotNumber > MAX_SAVESTATE_SLOTS)
{ {
return; return;
@ -1253,31 +1232,25 @@
[self restoreCoreState]; [self restoreCoreState];
} }
- (void) cmdCopyScreen:(NSValue *)cmdAttrValue - (void) cmdCopyScreen:(const ClientCommandAttributes &)cmdAttr
{ {
[mainWindow copy:nil]; [mainWindow copy:nil];
} }
- (void) cmdRotateDisplayRelative:(NSValue *)cmdAttrValue - (void) cmdRotateDisplayRelative:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
} }
const double relativeDegrees = (cmdAttr.useInputForSender) ? (double)[CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : (double)cmdAttr.intValue[0]; const double relativeDegrees = (cmdAttr.useInputForObject) ? (double)[CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : (double)cmdAttr.intValue[0];
const double angleDegrees = [mainWindow displayRotation] + relativeDegrees; const double angleDegrees = [mainWindow displayRotation] + relativeDegrees;
[mainWindow setDisplayRotation:angleDegrees]; [mainWindow setDisplayRotation:angleDegrees];
} }
- (void) cmdToggleAllDisplays:(NSValue *)cmdAttrValue - (void) cmdToggleAllDisplays:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1316,10 +1289,8 @@
} }
} }
- (void) cmdHoldToggleSpeedScalar:(NSValue *)cmdAttrValue - (void) cmdHoldToggleSpeedScalar:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
const float inputSpeedScalar = (cmdAttr.useInputForScalar) ? cmdAttr.input.scalar : cmdAttr.floatValue[0]; const float inputSpeedScalar = (cmdAttr.useInputForScalar) ? cmdAttr.input.scalar : cmdAttr.floatValue[0];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
@ -1327,11 +1298,8 @@
[self setVerticalSyncForNonLayerBackedViews:nil]; [self setVerticalSyncForNonLayerBackedViews:nil];
} }
- (void) cmdToggleSpeedLimiter:(NSValue *)cmdAttrValue - (void) cmdToggleSpeedLimiter:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1355,11 +1323,8 @@
[self setVerticalSyncForNonLayerBackedViews:nil]; [self setVerticalSyncForNonLayerBackedViews:nil];
} }
- (void) cmdToggleAutoFrameSkip:(NSValue *)cmdAttrValue - (void) cmdToggleAutoFrameSkip:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1383,11 +1348,8 @@
[self setVerticalSyncForNonLayerBackedViews:nil]; [self setVerticalSyncForNonLayerBackedViews:nil];
} }
- (void) cmdToggleCheats:(NSValue *)cmdAttrValue - (void) cmdToggleCheats:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1409,11 +1371,8 @@
} }
} }
- (void) cmdToggleExecutePause:(NSValue *)cmdAttrValue - (void) cmdToggleExecutePause:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) ) if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) )
{ {
return; return;
@ -1431,11 +1390,8 @@
} }
} }
- (void) cmdCoreExecute:(NSValue *)cmdAttrValue - (void) cmdCoreExecute:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) ) if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) )
{ {
return; return;
@ -1444,11 +1400,8 @@
[self executeCore]; [self executeCore];
} }
- (void) cmdCorePause:(NSValue *)cmdAttrValue - (void) cmdCorePause:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) ) if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) )
{ {
return; return;
@ -1457,11 +1410,8 @@
[self pauseCore]; [self pauseCore];
} }
- (void) cmdFrameAdvance:(NSValue *)cmdAttrValue - (void) cmdFrameAdvance:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || if ( (cmdAttr.input.state == ClientInputDeviceState_Off) ||
@ -1474,11 +1424,8 @@
[cdsCore setCoreState:ExecutionBehavior_FrameAdvance]; [cdsCore setCoreState:ExecutionBehavior_FrameAdvance];
} }
- (void) cmdFrameJump:(NSValue *)cmdAttrValue - (void) cmdFrameJump:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) ) if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) )
{ {
return; return;
@ -1490,11 +1437,8 @@
[cdsCore setCoreState:ExecutionBehavior_FrameJump]; [cdsCore setCoreState:ExecutionBehavior_FrameJump];
} }
- (void) cmdReset:(NSValue *)cmdAttrValue - (void) cmdReset:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) ) if ( (cmdAttr.input.state == ClientInputDeviceState_Off) || ([self currentRom] == nil) )
{ {
return; return;
@ -1526,11 +1470,8 @@
} }
} }
- (void) cmdToggleMute:(NSValue *)cmdAttrValue - (void) cmdToggleMute:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
@ -1554,18 +1495,15 @@
[[self cdsSpeaker] setVolume:vol]; [[self cdsSpeaker] setVolume:vol];
} }
- (void) cmdToggleGPUState:(NSValue *)cmdAttrValue - (void) cmdToggleGPUState:(const ClientCommandAttributes &)cmdAttr
{ {
CommandAttributes cmdAttr;
[cmdAttrValue getValue:&cmdAttr];
if (cmdAttr.input.state == ClientInputDeviceState_Off) if (cmdAttr.input.state == ClientInputDeviceState_Off)
{ {
return; return;
} }
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content]; CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
const NSInteger bitNumber = (cmdAttr.useInputForSender) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : cmdAttr.intValue[0]; const NSInteger bitNumber = (cmdAttr.useInputForObject) ? [CocoaDSUtil getIBActionSenderTag:(id)cmdAttr.input.object] : 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];

View File

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2013-2015 DeSmuME Team Copyright (C) 2013-2017 DeSmuME Team
This file is free software: you can redistribute it and/or modify This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,6 +33,7 @@
#include "../audiosamplegenerator.h" #include "../audiosamplegenerator.h"
#include "../ClientInputHandler.h" #include "../ClientInputHandler.h"
struct ClientCommandAttributes;
struct ClientInputDeviceProperties; struct ClientInputDeviceProperties;
class MacInputDevicePropertiesEncoder; class MacInputDevicePropertiesEncoder;
@class EmuControllerDelegate; @class EmuControllerDelegate;
@ -46,41 +47,21 @@ class MacInputDevicePropertiesEncoder;
@end @end
typedef struct typedef std::vector<ClientCommandAttributes> CommandAttributesList;
{
char tag[INPUT_HANDLER_STRING_LENGTH]; // A string identifier for these attributes
SEL selector; // The selector that is called on command dispatch
int32_t intValue[4]; // Context dependent int values
float floatValue[4]; // Context dependent float values
void *object[4]; // Context dependent objects
bool useInputForIntCoord; // The command will prefer the input device's int coordinate
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
ClientInputDeviceProperties input; // The input device's properties
bool allowAnalogInput; // Flag for allowing a command to accept analog inputs
} CommandAttributes;
typedef std::vector<CommandAttributes> CommandAttributesList;
#if defined(__ppc__) || defined(__ppc64__) #if defined(__ppc__) || defined(__ppc64__)
typedef std::map<std::string, CommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = CommandAttributes typedef std::map<std::string, ClientCommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = ClientCommandAttributes
typedef std::map<std::string, CommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = CommandAttributes typedef std::map<std::string, ClientCommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = ClientCommandAttributes
typedef std::map<std::string, SEL> CommandSelectorMap; // Key = Command Tag, Value = Obj-C Selector
typedef std::map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator typedef std::map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator
typedef std::map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name typedef std::map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name
#elif !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_6) #elif !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_6)
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, ClientCommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = ClientCommandAttributes
typedef std::tr1::unordered_map<std::string, CommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = CommandAttributes typedef std::tr1::unordered_map<std::string, ClientCommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = ClientCommandAttributes
typedef std::tr1::unordered_map<std::string, SEL> CommandSelectorMap; // Key = Command Tag, Value = Obj-C Selector
typedef std::tr1::unordered_map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator typedef std::tr1::unordered_map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator
typedef std::tr1::unordered_map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name typedef std::tr1::unordered_map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name
#else #else
typedef std::unordered_map<std::string, CommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = CommandAttributes typedef std::unordered_map<std::string, ClientCommandAttributes> InputCommandMap; // Key = Input key in deviceCode:elementCode format, Value = ClientCommandAttributes
typedef std::unordered_map<std::string, CommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = CommandAttributes typedef std::unordered_map<std::string, ClientCommandAttributes> CommandAttributesMap; // Key = Command Tag, Value = ClientCommandAttributes
typedef std::unordered_map<std::string, SEL> CommandSelectorMap; // Key = Command Tag, Value = Obj-C Selector
typedef std::unordered_map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator typedef std::unordered_map<std::string, AudioSampleBlockGenerator> AudioFileSampleGeneratorMap; // Key = File path to audio file, Value = AudioSampleBlockGenerator
typedef std::unordered_map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name typedef std::unordered_map<int32_t, std::string> KeyboardKeyNameMap; // Key = Key code, Value = Key name
#endif #endif
@ -176,7 +157,6 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
InputCommandMap commandMap; InputCommandMap commandMap;
CommandAttributesMap defaultCommandAttributes; CommandAttributesMap defaultCommandAttributes;
CommandSelectorMap commandSelector;
AudioFileSampleGeneratorMap audioFileGenerators; AudioFileSampleGeneratorMap audioFileGenerators;
} }
@ -189,11 +169,11 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@property (readonly) NSDictionary *commandIcon; @property (readonly) NSDictionary *commandIcon;
- (void) setMappingsWithMappings:(NSDictionary *)mappings; - (void) setMappingsWithMappings:(NSDictionary *)mappings;
- (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceDict commandAttributes:(const CommandAttributes *)cmdAttr; - (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceDict commandAttributes:(const ClientCommandAttributes *)cmdAttr;
- (void) addMappingUsingInputAttributes:(const ClientInputDeviceProperties *)inputProperty commandAttributes:(const CommandAttributes *)cmdAttr; - (void) addMappingUsingInputAttributes:(const ClientInputDeviceProperties *)inputProperty commandAttributes:(const ClientCommandAttributes *)cmdAttr;
- (void) addMappingUsingInputList:(const ClientInputDevicePropertiesList *)inputPropertyList commandAttributes:(const CommandAttributes *)cmdAttr; - (void) addMappingUsingInputList:(const ClientInputDevicePropertiesList *)inputPropertyList commandAttributes:(const ClientCommandAttributes *)cmdAttr;
- (void) addMappingForIBAction:(const SEL)theSelector commandAttributes:(const CommandAttributes *)cmdAttr; - (void) addMappingForIBAction:(const SEL)theSelector commandAttributes:(const ClientCommandAttributes *)cmdAttr;
- (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandAttributes:(const CommandAttributes *)cmdAttr; - (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandAttributes:(const ClientCommandAttributes *)cmdAttr;
- (void) removeMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode; - (void) removeMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) removeAllMappingsForCommandTag:(const char *)commandTag; - (void) removeAllMappingsForCommandTag:(const char *)commandTag;
@ -205,11 +185,10 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
- (void) writeDefaultsInputMappings; - (void) writeDefaultsInputMappings;
- (NSString *) commandTagFromInputList:(NSArray *)inputList; - (NSString *) commandTagFromInputList:(NSArray *)inputList;
- (SEL) selectorOfCommandTag:(const char *)commandTag; - (ClientCommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag;
- (CommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag;
- (CommandAttributes) mappedCommandAttributesOfDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode; - (ClientCommandAttributes) mappedCommandAttributesOfDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) setMappedCommandAttributes:(const CommandAttributes *)cmdAttr deviceCode:(const char *)deviceCode elementCode:(const char *)elementCode; - (void) setMappedCommandAttributes:(const ClientCommandAttributes *)cmdAttr deviceCode:(const char *)deviceCode elementCode:(const char *)elementCode;
- (void) updateInputSettingsSummaryInDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo commandTag:(const char *)commandTag; - (void) updateInputSettingsSummaryInDeviceInfoDictionary:(NSMutableDictionary *)deviceInfo commandTag:(const char *)commandTag;
- (OSStatus) loadAudioFileUsingPath:(NSString *)filePath; - (OSStatus) loadAudioFileUsingPath:(NSString *)filePath;
@ -218,17 +197,42 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@end @end
CommandAttributes NewDefaultCommandAttributes(const char *commandTag); ClientCommandAttributes NewDefaultCommandAttributes(const char *commandTag);
CommandAttributes NewCommandAttributesForSelector(const char *commandTag, const SEL theSelector); ClientCommandAttributes NewCommandAttributesWithFunction(const char *commandTag, const ClientCommandDispatcher commandFunc);
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NDSInputID controlID); ClientCommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NDSInputID controlID);
void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr, NSDictionary *deviceInfo); void UpdateCommandAttributesWithDeviceInfoDictionary(ClientCommandAttributes *cmdAttr, NSDictionary *deviceInfo);
NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttributes *cmdAttr, NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const ClientCommandAttributes *cmdAttr,
NSString *deviceCode, NSString *deviceCode,
NSString *deviceName, NSString *deviceName,
NSString *elementCode, NSString *elementCode,
NSString *elementName); NSString *elementName);
void ClientCommandUpdateDSController(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandUpdateDSControllerWithTurbo(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandUpdateDSTouch(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandUpdateDSMicrophone(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandUpdateDSPaddle(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandAutoholdSet(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandAutoholdClear(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandLoadEmuSaveStateSlot(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandSaveEmuSaveStateSlot(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandCopyScreen(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandRotateDisplayRelative(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleAllDisplays(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandHoldToggleSpeedScalar(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleSpeedLimiter(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleAutoFrameSkip(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleCheats(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleExecutePause(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandCoreExecute(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandCorePause(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandFrameAdvance(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandFrameJump(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandReset(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleMute(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
void ClientCommandToggleGPUState(const ClientCommandAttributes &cmdAttr, void *dispatcherObject);
class MacInputDevicePropertiesEncoder : public ClientInputDevicePropertiesEncoder class MacInputDevicePropertiesEncoder : public ClientInputDevicePropertiesEncoder
{ {
private: private:

View File

@ -603,19 +603,19 @@ ClientInputDevicePropertiesList InputListFromHIDValue(IOHIDValueRef hidValueRef,
} }
else else
{ {
CommandAttributes cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:inputProperty.elementCode]; ClientCommandAttributes cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:inputProperty.elementCode];
if (cmdAttr.tag[0] == '\0' || cmdAttr.selector == nil) if (cmdAttr.tag[0] == '\0' || cmdAttr.dispatchFunction == NULL)
{ {
std::string tempElementCode = std::string(inputProperty.elementCode) + "/LowerThreshold"; std::string tempElementCode = std::string(inputProperty.elementCode) + "/LowerThreshold";
cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:tempElementCode.c_str()]; cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:tempElementCode.c_str()];
if (cmdAttr.tag[0] == '\0' || cmdAttr.selector == nil) if (cmdAttr.tag[0] == '\0' || cmdAttr.dispatchFunction == NULL)
{ {
tempElementCode = std::string(inputProperty.elementCode) + "/UpperThreshold"; tempElementCode = std::string(inputProperty.elementCode) + "/UpperThreshold";
cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:tempElementCode.c_str()]; cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:inputProperty.deviceCode elementCode:tempElementCode.c_str()];
} }
} }
const bool useAnalog = (cmdAttr.tag[0] == '\0' || cmdAttr.selector == nil) ? !forceDigitalInput : (!forceDigitalInput && cmdAttr.allowAnalogInput); const bool useAnalog = (cmdAttr.tag[0] == '\0' || cmdAttr.dispatchFunction == NULL) ? !forceDigitalInput : (!forceDigitalInput && cmdAttr.allowAnalogInput);
if (useAnalog) if (useAnalog)
{ {
@ -1046,197 +1046,140 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
[NSImage imageNamed:@"Icon_VolumeMute_16x16"], @"Mute/Unmute", [NSImage imageNamed:@"Icon_VolumeMute_16x16"], @"Mute/Unmute",
nil]; nil];
// Initialize the selectors used for each command tag. (Do this in code rather than in an external file.)
commandSelector["Up"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Down"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Right"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Left"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["A"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["B"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["X"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Y"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["L"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["R"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Start"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Select"] = @selector(cmdUpdateDSControllerWithTurbo:);
commandSelector["Touch"] = @selector(cmdUpdateDSTouch:);
commandSelector["Microphone"] = @selector(cmdUpdateDSMicrophone:);
commandSelector["Debug"] = @selector(cmdUpdateDSController:);
commandSelector["Lid"] = @selector(cmdUpdateDSController:);
commandSelector["Guitar Grip: Green"] = @selector(cmdUpdateDSController:);
commandSelector["Guitar Grip: Red"] = @selector(cmdUpdateDSController:);
commandSelector["Guitar Grip: Yellow"] = @selector(cmdUpdateDSController:);
commandSelector["Guitar Grip: Blue"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: C"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: C#"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: D"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: D#"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: E"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: F"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: F#"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: G"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: G#"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: A"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: A#"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: B"] = @selector(cmdUpdateDSController:);
commandSelector["Piano: High C"] = @selector(cmdUpdateDSController:);
commandSelector["Paddle"] = @selector(cmdUpdateDSPaddle:);
commandSelector["Autohold - Set"] = @selector(cmdAutoholdSet:);
commandSelector["Autohold - Clear"] = @selector(cmdAutoholdClear:);
commandSelector["Load State Slot"] = @selector(cmdLoadEmuSaveStateSlot:);
commandSelector["Save State Slot"] = @selector(cmdSaveEmuSaveStateSlot:);
commandSelector["Copy Screen"] = @selector(cmdCopyScreen:);
commandSelector["Rotate Display Relative"] = @selector(cmdRotateDisplayRelative:);
commandSelector["Toggle All Displays"] = @selector(cmdToggleAllDisplays:);
commandSelector["Set Speed"] = @selector(cmdHoldToggleSpeedScalar:);
commandSelector["Enable/Disable Speed Limiter"] = @selector(cmdToggleSpeedLimiter:);
commandSelector["Enable/Disable Auto Frame Skip"] = @selector(cmdToggleAutoFrameSkip:);
commandSelector["Enable/Disable Cheats"] = @selector(cmdToggleCheats:);
commandSelector["Execute"] = @selector(cmdCoreExecute:);
commandSelector["Pause"] = @selector(cmdCorePause:);
commandSelector["Execute/Pause"] = @selector(cmdToggleExecutePause:);
commandSelector["Frame Advance"] = @selector(cmdFrameAdvance:);
commandSelector["Frame Jump"] = @selector(cmdFrameJump:);
commandSelector["Reset"] = @selector(cmdReset:);
commandSelector["Mute/Unmute"] = @selector(cmdToggleMute:);
commandSelector["Enable/Disable GPU State"] = @selector(cmdToggleGPUState:);
// Generate the default command attributes for each command tag. (Do this in code rather than in an external file.) // Generate the default command attributes for each command tag. (Do this in code rather than in an external file.)
CommandAttributes cmdDSControlRight = NewCommandAttributesForDSControl("Right", NDSInputID_Right); ClientCommandAttributes cmdDSControlRight = NewCommandAttributesForDSControl("Right", NDSInputID_Right);
CommandAttributes cmdDSControlLeft = NewCommandAttributesForDSControl("Left", NDSInputID_Left); ClientCommandAttributes cmdDSControlLeft = NewCommandAttributesForDSControl("Left", NDSInputID_Left);
CommandAttributes cmdDSControlDown = NewCommandAttributesForDSControl("Down", NDSInputID_Down); ClientCommandAttributes cmdDSControlDown = NewCommandAttributesForDSControl("Down", NDSInputID_Down);
CommandAttributes cmdDSControlUp = NewCommandAttributesForDSControl("Up", NDSInputID_Up); ClientCommandAttributes cmdDSControlUp = NewCommandAttributesForDSControl("Up", NDSInputID_Up);
CommandAttributes cmdDSControlSelect = NewCommandAttributesForDSControl("Select", NDSInputID_Select); ClientCommandAttributes cmdDSControlSelect = NewCommandAttributesForDSControl("Select", NDSInputID_Select);
CommandAttributes cmdDSControlStart = NewCommandAttributesForDSControl("Start", NDSInputID_Start); ClientCommandAttributes cmdDSControlStart = NewCommandAttributesForDSControl("Start", NDSInputID_Start);
CommandAttributes cmdDSControlB = NewCommandAttributesForDSControl("B", NDSInputID_B); ClientCommandAttributes cmdDSControlB = NewCommandAttributesForDSControl("B", NDSInputID_B);
CommandAttributes cmdDSControlA = NewCommandAttributesForDSControl("A", NDSInputID_A); ClientCommandAttributes cmdDSControlA = NewCommandAttributesForDSControl("A", NDSInputID_A);
CommandAttributes cmdDSControlY = NewCommandAttributesForDSControl("Y", NDSInputID_Y); ClientCommandAttributes cmdDSControlY = NewCommandAttributesForDSControl("Y", NDSInputID_Y);
CommandAttributes cmdDSControlX = NewCommandAttributesForDSControl("X", NDSInputID_X); ClientCommandAttributes cmdDSControlX = NewCommandAttributesForDSControl("X", NDSInputID_X);
CommandAttributes cmdDSControlL = NewCommandAttributesForDSControl("L", NDSInputID_L); ClientCommandAttributes cmdDSControlL = NewCommandAttributesForDSControl("L", NDSInputID_L);
CommandAttributes cmdDSControlR = NewCommandAttributesForDSControl("R", NDSInputID_R); ClientCommandAttributes cmdDSControlR = NewCommandAttributesForDSControl("R", NDSInputID_R);
CommandAttributes cmdDSControlDebug = NewCommandAttributesForDSControl("Debug", NDSInputID_Debug); ClientCommandAttributes cmdDSControlDebug = NewCommandAttributesForDSControl("Debug", NDSInputID_Debug);
CommandAttributes cmdDSControlLid = NewCommandAttributesForDSControl("Lid", NDSInputID_Lid); ClientCommandAttributes cmdDSControlLid = NewCommandAttributesForDSControl("Lid", NDSInputID_Lid);
CommandAttributes cmdDSControlTouch = NewCommandAttributesForDSControl("Touch", NDSInputID_Touch); ClientCommandAttributes cmdDSControlTouch = NewCommandAttributesForDSControl("Touch", NDSInputID_Touch);
cmdDSControlTouch.useInputForIntCoord = true; cmdDSControlTouch.useInputForIntCoord = true;
CommandAttributes cmdDSControlMic = NewCommandAttributesForDSControl("Microphone", NDSInputID_Microphone); ClientCommandAttributes cmdDSControlMic = NewCommandAttributesForDSControl("Microphone", NDSInputID_Microphone);
cmdDSControlMic.intValue[1] = MicrophoneMode_InternalNoise; cmdDSControlMic.intValue[1] = MicrophoneMode_InternalNoise;
cmdDSControlMic.floatValue[0] = 250.0f; cmdDSControlMic.floatValue[0] = 250.0f;
CommandAttributes cmdGuitarGripGreen = NewCommandAttributesForDSControl("Guitar Grip: Green", NDSInputID_GuitarGrip_Green); ClientCommandAttributes cmdGuitarGripGreen = NewCommandAttributesForDSControl("Guitar Grip: Green", NDSInputID_GuitarGrip_Green);
CommandAttributes cmdGuitarGripRed = NewCommandAttributesForDSControl("Guitar Grip: Red", NDSInputID_GuitarGrip_Red); ClientCommandAttributes cmdGuitarGripRed = NewCommandAttributesForDSControl("Guitar Grip: Red", NDSInputID_GuitarGrip_Red);
CommandAttributes cmdGuitarGripYellow = NewCommandAttributesForDSControl("Guitar Grip: Yellow", NDSInputID_GuitarGrip_Yellow); ClientCommandAttributes cmdGuitarGripYellow = NewCommandAttributesForDSControl("Guitar Grip: Yellow", NDSInputID_GuitarGrip_Yellow);
CommandAttributes cmdGuitarGripBlue = NewCommandAttributesForDSControl("Guitar Grip: Blue", NDSInputID_GuitarGrip_Blue); ClientCommandAttributes cmdGuitarGripBlue = NewCommandAttributesForDSControl("Guitar Grip: Blue", NDSInputID_GuitarGrip_Blue);
CommandAttributes cmdPianoC = NewCommandAttributesForDSControl("Piano: C", NDSInputID_Piano_C); ClientCommandAttributes cmdPianoC = NewCommandAttributesForDSControl("Piano: C", NDSInputID_Piano_C);
CommandAttributes cmdPianoCSharp = NewCommandAttributesForDSControl("Piano: C#", NDSInputID_Piano_CSharp); ClientCommandAttributes cmdPianoCSharp = NewCommandAttributesForDSControl("Piano: C#", NDSInputID_Piano_CSharp);
CommandAttributes cmdPianoD = NewCommandAttributesForDSControl("Piano: D", NDSInputID_Piano_D); ClientCommandAttributes cmdPianoD = NewCommandAttributesForDSControl("Piano: D", NDSInputID_Piano_D);
CommandAttributes cmdPianoDSharp = NewCommandAttributesForDSControl("Piano: D#", NDSInputID_Piano_DSharp); ClientCommandAttributes cmdPianoDSharp = NewCommandAttributesForDSControl("Piano: D#", NDSInputID_Piano_DSharp);
CommandAttributes cmdPianoE = NewCommandAttributesForDSControl("Piano: E", NDSInputID_Piano_E); ClientCommandAttributes cmdPianoE = NewCommandAttributesForDSControl("Piano: E", NDSInputID_Piano_E);
CommandAttributes cmdPianoF = NewCommandAttributesForDSControl("Piano: F", NDSInputID_Piano_F); ClientCommandAttributes cmdPianoF = NewCommandAttributesForDSControl("Piano: F", NDSInputID_Piano_F);
CommandAttributes cmdPianoFSharp = NewCommandAttributesForDSControl("Piano: F#", NDSInputID_Piano_FSharp); ClientCommandAttributes cmdPianoFSharp = NewCommandAttributesForDSControl("Piano: F#", NDSInputID_Piano_FSharp);
CommandAttributes cmdPianoG = NewCommandAttributesForDSControl("Piano: G", NDSInputID_Piano_G); ClientCommandAttributes cmdPianoG = NewCommandAttributesForDSControl("Piano: G", NDSInputID_Piano_G);
CommandAttributes cmdPianoGSharp = NewCommandAttributesForDSControl("Piano: G#", NDSInputID_Piano_GSharp); ClientCommandAttributes cmdPianoGSharp = NewCommandAttributesForDSControl("Piano: G#", NDSInputID_Piano_GSharp);
CommandAttributes cmdPianoA = NewCommandAttributesForDSControl("Piano: A", NDSInputID_Piano_A); ClientCommandAttributes cmdPianoA = NewCommandAttributesForDSControl("Piano: A", NDSInputID_Piano_A);
CommandAttributes cmdPianoASharp = NewCommandAttributesForDSControl("Piano: A#", NDSInputID_Piano_ASharp); ClientCommandAttributes cmdPianoASharp = NewCommandAttributesForDSControl("Piano: A#", NDSInputID_Piano_ASharp);
CommandAttributes cmdPianoB = NewCommandAttributesForDSControl("Piano: B", NDSInputID_Piano_B); ClientCommandAttributes cmdPianoB = NewCommandAttributesForDSControl("Piano: B", NDSInputID_Piano_B);
CommandAttributes cmdPianoHighC = NewCommandAttributesForDSControl("Piano: High C", NDSInputID_Piano_HighC); ClientCommandAttributes cmdPianoHighC = NewCommandAttributesForDSControl("Piano: High C", NDSInputID_Piano_HighC);
CommandAttributes cmdPaddle = NewCommandAttributesForDSControl("Paddle", NDSInputID_Paddle); ClientCommandAttributes cmdPaddle = NewCommandAttributesForDSControl("Paddle", NDSInputID_Paddle);
cmdPaddle.allowAnalogInput = true; cmdPaddle.allowAnalogInput = true;
cmdPaddle.intValue[1] = 0; cmdPaddle.intValue[1] = 0;
cmdPaddle.floatValue[0] = 10.0f; cmdPaddle.floatValue[0] = 10.0f;
CommandAttributes cmdAutoholdSet = NewCommandAttributesForSelector("Autohold - Set", commandSelector["Autohold - Set"]); ClientCommandAttributes cmdAutoholdSet = NewCommandAttributesWithFunction("Autohold - Set", &ClientCommandAutoholdSet);
CommandAttributes cmdAutoholdClear = NewCommandAttributesForSelector("Autohold - Clear", commandSelector["Autohold - Clear"]); ClientCommandAttributes cmdAutoholdClear = NewCommandAttributesWithFunction("Autohold - Clear", &ClientCommandAutoholdClear);
CommandAttributes cmdLoadEmuSaveStateSlot = NewCommandAttributesForSelector("Load State Slot", commandSelector["Load State Slot"]); ClientCommandAttributes cmdLoadEmuSaveStateSlot = NewCommandAttributesWithFunction("Load State Slot", &ClientCommandLoadEmuSaveStateSlot);
CommandAttributes cmdSaveEmuSaveStateSlot = NewCommandAttributesForSelector("Save State Slot", commandSelector["Save State Slot"]); ClientCommandAttributes cmdSaveEmuSaveStateSlot = NewCommandAttributesWithFunction("Save State Slot", &ClientCommandSaveEmuSaveStateSlot);
CommandAttributes cmdCopyScreen = NewCommandAttributesForSelector("Copy Screen", commandSelector["Copy Screen"]); ClientCommandAttributes cmdCopyScreen = NewCommandAttributesWithFunction("Copy Screen", &ClientCommandCopyScreen);
CommandAttributes cmdRotateDisplayRelative = NewCommandAttributesForSelector("Rotate Display Relative", commandSelector["Rotate Display Relative"]); ClientCommandAttributes cmdRotateDisplayRelative = NewCommandAttributesWithFunction("Rotate Display Relative", &ClientCommandRotateDisplayRelative);
cmdRotateDisplayRelative.intValue[0] = 90; cmdRotateDisplayRelative.intValue[0] = 90;
CommandAttributes cmdRotateDisplayLeft = NewCommandAttributesForSelector("Rotate Display Left", commandSelector["Rotate Display Relative"]); ClientCommandAttributes cmdRotateDisplayLeft = NewCommandAttributesWithFunction("Rotate Display Left", &ClientCommandRotateDisplayRelative);
cmdRotateDisplayLeft.intValue[0] = -90; cmdRotateDisplayLeft.intValue[0] = -90;
CommandAttributes cmdRotateDisplayRight = NewCommandAttributesForSelector("Rotate Display Right", commandSelector["Rotate Display Relative"]); ClientCommandAttributes cmdRotateDisplayRight = NewCommandAttributesWithFunction("Rotate Display Right", &ClientCommandRotateDisplayRelative);
cmdRotateDisplayRight.intValue[0] = 90; cmdRotateDisplayRight.intValue[0] = 90;
CommandAttributes cmdToggleAllDisplays = NewCommandAttributesForSelector("Toggle All Displays", commandSelector["Toggle All Displays"]); ClientCommandAttributes cmdToggleAllDisplays = NewCommandAttributesWithFunction("Toggle All Displays", &ClientCommandToggleAllDisplays);
CommandAttributes cmdToggleSpeed = NewCommandAttributesForSelector("Set Speed", commandSelector["Set Speed"]); ClientCommandAttributes cmdToggleSpeed = NewCommandAttributesWithFunction("Set Speed", &ClientCommandHoldToggleSpeedScalar);
cmdToggleSpeed.floatValue[0] = 1.0f; cmdToggleSpeed.floatValue[0] = 1.0f;
CommandAttributes cmdToggleSpeedLimiter = NewCommandAttributesForSelector("Enable/Disable Speed Limiter", commandSelector["Enable/Disable Speed Limiter"]); ClientCommandAttributes cmdToggleSpeedLimiter = NewCommandAttributesWithFunction("Enable/Disable Speed Limiter", &ClientCommandToggleSpeedLimiter);
CommandAttributes cmdToggleAutoFrameSkip = NewCommandAttributesForSelector("Enable/Disable Auto Frame Skip", commandSelector["Enable/Disable Auto Frame Skip"]); ClientCommandAttributes cmdToggleAutoFrameSkip = NewCommandAttributesWithFunction("Enable/Disable Auto Frame Skip", &ClientCommandToggleAutoFrameSkip);
CommandAttributes cmdToggleCheats = NewCommandAttributesForSelector("Enable/Disable Cheats", commandSelector["Enable/Disable Cheats"]); ClientCommandAttributes cmdToggleCheats = NewCommandAttributesWithFunction("Enable/Disable Cheats", &ClientCommandToggleCheats);
CommandAttributes cmdCoreExecute = NewCommandAttributesForSelector("Execute", commandSelector["Execute"]); ClientCommandAttributes cmdCoreExecute = NewCommandAttributesWithFunction("Execute", &ClientCommandCoreExecute);
CommandAttributes cmdCorePause = NewCommandAttributesForSelector("Pause", commandSelector["Pause"]); ClientCommandAttributes cmdCorePause = NewCommandAttributesWithFunction("Pause", &ClientCommandCorePause);
CommandAttributes cmdToggleExecutePause = NewCommandAttributesForSelector("Execute/Pause", commandSelector["Execute/Pause"]); ClientCommandAttributes cmdToggleExecutePause = NewCommandAttributesWithFunction("Execute/Pause", &ClientCommandToggleExecutePause);
CommandAttributes cmdFrameAdvance = NewCommandAttributesForSelector("Frame Advance", commandSelector["Frame Advance"]); ClientCommandAttributes cmdFrameAdvance = NewCommandAttributesWithFunction("Frame Advance", &ClientCommandFrameAdvance);
CommandAttributes cmdFrameJump = NewCommandAttributesForSelector("Frame Jump", commandSelector["Frame Jump"]); ClientCommandAttributes cmdFrameJump = NewCommandAttributesWithFunction("Frame Jump", &ClientCommandFrameJump);
CommandAttributes cmdReset = NewCommandAttributesForSelector("Reset", commandSelector["Reset"]); ClientCommandAttributes cmdReset = NewCommandAttributesWithFunction("Reset", &ClientCommandReset);
CommandAttributes cmdToggleMute = NewCommandAttributesForSelector("Mute/Unmute", commandSelector["Mute/Unmute"]); ClientCommandAttributes cmdToggleMute = NewCommandAttributesWithFunction("Mute/Unmute", &ClientCommandToggleMute);
CommandAttributes cmdToggleGPUState = NewCommandAttributesForSelector("Enable/Disable GPU State", commandSelector["Enable/Disable GPU State"]); ClientCommandAttributes cmdToggleGPUState = NewCommandAttributesWithFunction("Enable/Disable GPU State", &ClientCommandToggleGPUState);
defaultCommandAttributes["Up"] = cmdDSControlUp; defaultCommandAttributes["Up"] = cmdDSControlUp;
defaultCommandAttributes["Down"] = cmdDSControlDown; defaultCommandAttributes["Down"] = cmdDSControlDown;
defaultCommandAttributes["Right"] = cmdDSControlRight; defaultCommandAttributes["Right"] = cmdDSControlRight;
defaultCommandAttributes["Left"] = cmdDSControlLeft; defaultCommandAttributes["Left"] = cmdDSControlLeft;
defaultCommandAttributes["A"] = cmdDSControlA; defaultCommandAttributes["A"] = cmdDSControlA;
defaultCommandAttributes["B"] = cmdDSControlB; defaultCommandAttributes["B"] = cmdDSControlB;
defaultCommandAttributes["X"] = cmdDSControlX; defaultCommandAttributes["X"] = cmdDSControlX;
defaultCommandAttributes["Y"] = cmdDSControlY; defaultCommandAttributes["Y"] = cmdDSControlY;
defaultCommandAttributes["L"] = cmdDSControlL; defaultCommandAttributes["L"] = cmdDSControlL;
defaultCommandAttributes["R"] = cmdDSControlR; defaultCommandAttributes["R"] = cmdDSControlR;
defaultCommandAttributes["Start"] = cmdDSControlStart; defaultCommandAttributes["Start"] = cmdDSControlStart;
defaultCommandAttributes["Select"] = cmdDSControlSelect; defaultCommandAttributes["Select"] = cmdDSControlSelect;
defaultCommandAttributes["Touch"] = cmdDSControlTouch; defaultCommandAttributes["Touch"] = cmdDSControlTouch;
defaultCommandAttributes["Microphone"] = cmdDSControlMic; defaultCommandAttributes["Microphone"] = cmdDSControlMic;
defaultCommandAttributes["Debug"] = cmdDSControlDebug; defaultCommandAttributes["Debug"] = cmdDSControlDebug;
defaultCommandAttributes["Lid"] = cmdDSControlLid; defaultCommandAttributes["Lid"] = cmdDSControlLid;
defaultCommandAttributes["Guitar Grip: Green"] = cmdGuitarGripGreen; defaultCommandAttributes["Guitar Grip: Green"] = cmdGuitarGripGreen;
defaultCommandAttributes["Guitar Grip: Red"] = cmdGuitarGripRed; defaultCommandAttributes["Guitar Grip: Red"] = cmdGuitarGripRed;
defaultCommandAttributes["Guitar Grip: Yellow"] = cmdGuitarGripYellow; defaultCommandAttributes["Guitar Grip: Yellow"] = cmdGuitarGripYellow;
defaultCommandAttributes["Guitar Grip: Blue"] = cmdGuitarGripBlue; defaultCommandAttributes["Guitar Grip: Blue"] = cmdGuitarGripBlue;
defaultCommandAttributes["Piano: C"] = cmdPianoC; defaultCommandAttributes["Piano: C"] = cmdPianoC;
defaultCommandAttributes["Piano: C#"] = cmdPianoCSharp; defaultCommandAttributes["Piano: C#"] = cmdPianoCSharp;
defaultCommandAttributes["Piano: D"] = cmdPianoD; defaultCommandAttributes["Piano: D"] = cmdPianoD;
defaultCommandAttributes["Piano: D#"] = cmdPianoDSharp; defaultCommandAttributes["Piano: D#"] = cmdPianoDSharp;
defaultCommandAttributes["Piano: E"] = cmdPianoE; defaultCommandAttributes["Piano: E"] = cmdPianoE;
defaultCommandAttributes["Piano: F"] = cmdPianoF; defaultCommandAttributes["Piano: F"] = cmdPianoF;
defaultCommandAttributes["Piano: F#"] = cmdPianoFSharp; defaultCommandAttributes["Piano: F#"] = cmdPianoFSharp;
defaultCommandAttributes["Piano: G"] = cmdPianoG; defaultCommandAttributes["Piano: G"] = cmdPianoG;
defaultCommandAttributes["Piano: G#"] = cmdPianoGSharp; defaultCommandAttributes["Piano: G#"] = cmdPianoGSharp;
defaultCommandAttributes["Piano: A"] = cmdPianoA; defaultCommandAttributes["Piano: A"] = cmdPianoA;
defaultCommandAttributes["Piano: A#"] = cmdPianoASharp; defaultCommandAttributes["Piano: A#"] = cmdPianoASharp;
defaultCommandAttributes["Piano: B"] = cmdPianoB; defaultCommandAttributes["Piano: B"] = cmdPianoB;
defaultCommandAttributes["Piano: High C"] = cmdPianoHighC; defaultCommandAttributes["Piano: High C"] = cmdPianoHighC;
defaultCommandAttributes["Paddle"] = cmdPaddle; defaultCommandAttributes["Paddle"] = cmdPaddle;
defaultCommandAttributes["Autohold - Set"] = cmdAutoholdSet; defaultCommandAttributes["Autohold - Set"] = cmdAutoholdSet;
defaultCommandAttributes["Autohold - Clear"] = cmdAutoholdClear; defaultCommandAttributes["Autohold - Clear"] = cmdAutoholdClear;
defaultCommandAttributes["Load State Slot"] = cmdLoadEmuSaveStateSlot; defaultCommandAttributes["Load State Slot"] = cmdLoadEmuSaveStateSlot;
defaultCommandAttributes["Save State Slot"] = cmdSaveEmuSaveStateSlot; defaultCommandAttributes["Save State Slot"] = cmdSaveEmuSaveStateSlot;
defaultCommandAttributes["Copy Screen"] = cmdCopyScreen; defaultCommandAttributes["Copy Screen"] = cmdCopyScreen;
defaultCommandAttributes["Rotate Display Left"] = cmdRotateDisplayLeft; defaultCommandAttributes["Rotate Display Left"] = cmdRotateDisplayLeft;
defaultCommandAttributes["Rotate Display Right"] = cmdRotateDisplayRight; defaultCommandAttributes["Rotate Display Right"] = cmdRotateDisplayRight;
defaultCommandAttributes["Toggle All Displays"] = cmdToggleAllDisplays; defaultCommandAttributes["Toggle All Displays"] = cmdToggleAllDisplays;
defaultCommandAttributes["Set Speed"] = cmdToggleSpeed; defaultCommandAttributes["Set Speed"] = cmdToggleSpeed;
defaultCommandAttributes["Enable/Disable Speed Limiter"] = cmdToggleSpeedLimiter; defaultCommandAttributes["Enable/Disable Speed Limiter"] = cmdToggleSpeedLimiter;
defaultCommandAttributes["Enable/Disable Auto Frame Skip"] = cmdToggleAutoFrameSkip; defaultCommandAttributes["Enable/Disable Auto Frame Skip"] = cmdToggleAutoFrameSkip;
defaultCommandAttributes["Enable/Disable Cheats"] = cmdToggleCheats; defaultCommandAttributes["Enable/Disable Cheats"] = cmdToggleCheats;
defaultCommandAttributes["Execute"] = cmdCoreExecute; defaultCommandAttributes["Execute"] = cmdCoreExecute;
defaultCommandAttributes["Pause"] = cmdCorePause; defaultCommandAttributes["Pause"] = cmdCorePause;
defaultCommandAttributes["Execute/Pause"] = cmdToggleExecutePause; defaultCommandAttributes["Execute/Pause"] = cmdToggleExecutePause;
defaultCommandAttributes["Frame Advance"] = cmdFrameAdvance; defaultCommandAttributes["Frame Advance"] = cmdFrameAdvance;
defaultCommandAttributes["Frame Jump"] = cmdFrameJump; defaultCommandAttributes["Frame Jump"] = cmdFrameJump;
defaultCommandAttributes["Reset"] = cmdReset; defaultCommandAttributes["Reset"] = cmdReset;
defaultCommandAttributes["Mute/Unmute"] = cmdToggleMute; defaultCommandAttributes["Mute/Unmute"] = cmdToggleMute;
defaultCommandAttributes["Enable/Disable GPU State"] = cmdToggleGPUState; defaultCommandAttributes["Enable/Disable GPU State"] = cmdToggleGPUState;
// Map all IBActions (the target object is an EmuControllerDelegate) // Map all IBActions (the target object is an EmuControllerDelegate)
[self addMappingForIBAction:@selector(autoholdSet:) commandAttributes:&cmdAutoholdSet]; [self addMappingForIBAction:@selector(autoholdSet:) commandAttributes:&cmdAutoholdSet];
@ -1310,22 +1253,22 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
for (NSDictionary *deviceInfo in deviceInfoList) for (NSDictionary *deviceInfo in deviceInfoList)
{ {
const char *cmdTag = [commandTag cStringUsingEncoding:NSUTF8StringEncoding]; const char *cmdTag = [commandTag cStringUsingEncoding:NSUTF8StringEncoding];
CommandAttributes cmdAttr = defaultCommandAttributes[cmdTag]; ClientCommandAttributes cmdAttr = defaultCommandAttributes[cmdTag];
UpdateCommandAttributesWithDeviceInfoDictionary(&cmdAttr, deviceInfo); UpdateCommandAttributesWithDeviceInfoDictionary(&cmdAttr, deviceInfo);
// Force DS control commands to use IDs from code instead of from the file. // Force DS control commands to use IDs from code instead of from the file.
// (In other words, we can't trust an external file with this information since // (In other words, we can't trust an external file with this information since
// IDs might desync if the DS Control ID enumeration changes.) // IDs might desync if the DS Control ID enumeration changes.)
if (cmdAttr.selector == @selector(cmdUpdateDSController:) || if (cmdAttr.dispatchFunction == &ClientCommandUpdateDSController ||
cmdAttr.selector == @selector(cmdUpdateDSControllerWithTurbo:) || cmdAttr.dispatchFunction == &ClientCommandUpdateDSControllerWithTurbo ||
cmdAttr.selector == @selector(cmdUpdateDSTouch:) || cmdAttr.dispatchFunction == &ClientCommandUpdateDSTouch ||
cmdAttr.selector == @selector(cmdUpdateDSMicrophone:) || cmdAttr.dispatchFunction == &ClientCommandUpdateDSMicrophone ||
cmdAttr.selector == @selector(cmdUpdateDSPaddle:)) cmdAttr.dispatchFunction == &ClientCommandUpdateDSPaddle)
{ {
cmdAttr.intValue[0] = defaultCommandAttributes[cmdTag].intValue[0]; cmdAttr.intValue[0] = defaultCommandAttributes[cmdTag].intValue[0];
} }
if (cmdAttr.selector == @selector(cmdUpdateDSControllerWithTurbo:)) if (cmdAttr.dispatchFunction == &ClientCommandUpdateDSControllerWithTurbo)
{ {
if ((cmdAttr.intValue[2] == 0) || (cmdAttr.intValue[3] == 0)) if ((cmdAttr.intValue[2] == 0) || (cmdAttr.intValue[3] == 0))
{ {
@ -1348,7 +1291,7 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
[self updateAudioFileGenerators]; [self updateAudioFileGenerators];
} }
- (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceInfo commandAttributes:(const CommandAttributes *)cmdAttr - (void) addMappingUsingDeviceInfoDictionary:(NSDictionary *)deviceInfo commandAttributes:(const ClientCommandAttributes *)cmdAttr
{ {
NSString *deviceCode = (NSString *)[deviceInfo valueForKey:@"deviceCode"]; NSString *deviceCode = (NSString *)[deviceInfo valueForKey:@"deviceCode"];
NSString *elementCode = (NSString *)[deviceInfo valueForKey:@"elementCode"]; NSString *elementCode = (NSString *)[deviceInfo valueForKey:@"elementCode"];
@ -1380,7 +1323,7 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
} }
} }
- (void) addMappingUsingInputAttributes:(const ClientInputDeviceProperties *)inputProperty commandAttributes:(const CommandAttributes *)cmdAttr - (void) addMappingUsingInputAttributes:(const ClientInputDeviceProperties *)inputProperty commandAttributes:(const ClientCommandAttributes *)cmdAttr
{ {
if (inputProperty == NULL) if (inputProperty == NULL)
{ {
@ -1397,7 +1340,7 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
[self addMappingUsingDeviceInfoDictionary:deviceInfo commandAttributes:cmdAttr]; [self addMappingUsingDeviceInfoDictionary:deviceInfo commandAttributes:cmdAttr];
} }
- (void) addMappingUsingInputList:(const ClientInputDevicePropertiesList *)inputPropertyList commandAttributes:(const CommandAttributes *)cmdAttr - (void) addMappingUsingInputList:(const ClientInputDevicePropertiesList *)inputPropertyList commandAttributes:(const ClientCommandAttributes *)cmdAttr
{ {
if (inputPropertyList == NULL) if (inputPropertyList == NULL)
{ {
@ -1418,20 +1361,20 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
} }
} }
- (void) addMappingForIBAction:(const SEL)theSelector commandAttributes:(const CommandAttributes *)cmdAttr - (void) addMappingForIBAction:(const SEL)theSelector commandAttributes:(const ClientCommandAttributes *)cmdAttr
{ {
if (theSelector == nil) if (theSelector == nil)
{ {
return; return;
} }
CommandAttributes IBActionCmdAttr = *cmdAttr; ClientCommandAttributes IBActionCmdAttr = *cmdAttr;
IBActionCmdAttr.useInputForSender = true; IBActionCmdAttr.useInputForObject = true;
[self addMappingUsingDeviceCode:"IBAction" elementCode:sel_getName(theSelector) commandAttributes:&IBActionCmdAttr]; [self addMappingUsingDeviceCode:"IBAction" elementCode:sel_getName(theSelector) commandAttributes:&IBActionCmdAttr];
} }
- (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandAttributes:(const CommandAttributes *)cmdAttr - (void) addMappingUsingDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode commandAttributes:(const ClientCommandAttributes *)cmdAttr
{ {
if (deviceCode == NULL || elementCode == NULL || cmdAttr == NULL) if (deviceCode == NULL || elementCode == NULL || cmdAttr == NULL)
{ {
@ -1517,8 +1460,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
// Look up the command attributes using the input key. // Look up the command attributes using the input key.
const std::string inputKey = std::string(inputProperty.deviceCode) + ":" + std::string(inputProperty.elementCode); const std::string inputKey = std::string(inputProperty.deviceCode) + ":" + std::string(inputProperty.elementCode);
CommandAttributes cmdAttr = commandMap[inputKey]; ClientCommandAttributes cmdAttr = commandMap[inputKey];
if (cmdAttr.tag[0] == '\0' || cmdAttr.selector == nil) if (cmdAttr.tag[0] == '\0' || cmdAttr.dispatchFunction == NULL)
{ {
continue; continue;
} }
@ -1535,14 +1478,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
size_t cmdCount = cmdList->size(); size_t cmdCount = cmdList->size();
for (size_t i = 0; i < cmdCount; i++) for (size_t i = 0; i < cmdCount; i++)
{ {
const CommandAttributes &cmdAttr = (*cmdList)[i]; const ClientCommandAttributes &cmdAttr = (*cmdList)[i];
cmdAttr.dispatchFunction(cmdAttr, emuControl);
if ([emuControl respondsToSelector:cmdAttr.selector])
{
NSValue *cmdObject = [[NSValue alloc] initWithBytes:&cmdAttr objCType:@encode(CommandAttributes)];
[emuControl performSelector:cmdAttr.selector withObject:cmdObject];
[cmdObject release];
}
} }
} }
@ -1559,8 +1496,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
// Look up the command key using the input key. // Look up the command key using the input key.
const std::string inputKey = std::string(inputProperty->deviceCode) + ":" + std::string(inputProperty->elementCode); const std::string inputKey = std::string(inputProperty->deviceCode) + ":" + std::string(inputProperty->elementCode);
CommandAttributes cmdAttr = commandMap[inputKey]; ClientCommandAttributes cmdAttr = commandMap[inputKey];
if (cmdAttr.tag[0] == '\0' || cmdAttr.selector == nil) if (cmdAttr.tag[0] == '\0' || cmdAttr.dispatchFunction == NULL)
{ {
return didCommandDispatch; return didCommandDispatch;
} }
@ -1568,12 +1505,8 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
// Copy the input state to the command attributes. // Copy the input state to the command attributes.
cmdAttr.input = *inputProperty; cmdAttr.input = *inputProperty;
if ([emuControl respondsToSelector:cmdAttr.selector]) // Call this command's dispatch function.
{ cmdAttr.dispatchFunction(cmdAttr, emuControl);
NSValue *cmdObject = [[NSValue alloc] initWithBytes:&cmdAttr objCType:@encode(CommandAttributes)];
[emuControl performSelector:cmdAttr.selector withObject:cmdObject];
[cmdObject release];
}
didCommandDispatch = YES; didCommandDispatch = YES;
return didCommandDispatch; return didCommandDispatch;
@ -1611,23 +1544,18 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
return commandTag; return commandTag;
} }
- (SEL) selectorOfCommandTag:(const char *)commandTag - (ClientCommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag
{
return commandSelector[commandTag];
}
- (CommandAttributes) defaultCommandAttributesForCommandTag:(const char *)commandTag
{ {
return defaultCommandAttributes[commandTag]; return defaultCommandAttributes[commandTag];
} }
- (CommandAttributes) mappedCommandAttributesOfDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode - (ClientCommandAttributes) mappedCommandAttributesOfDeviceCode:(const char *)deviceCode elementCode:(const char *)elementCode
{ {
const std::string inputKey = std::string(deviceCode) + ":" + std::string(elementCode); const std::string inputKey = std::string(deviceCode) + ":" + std::string(elementCode);
return commandMap[inputKey]; return commandMap[inputKey];
} }
- (void) setMappedCommandAttributes:(const CommandAttributes *)cmdAttr deviceCode:(const char *)deviceCode elementCode:(const char *)elementCode - (void) setMappedCommandAttributes:(const ClientCommandAttributes *)cmdAttr deviceCode:(const char *)deviceCode elementCode:(const char *)elementCode
{ {
const std::string inputKey = std::string(deviceCode) + ":" + std::string(elementCode); const std::string inputKey = std::string(deviceCode) + ":" + std::string(elementCode);
commandMap[inputKey] = *cmdAttr; commandMap[inputKey] = *cmdAttr;
@ -1976,12 +1904,12 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
@end @end
CommandAttributes NewDefaultCommandAttributes(const char *commandTag) ClientCommandAttributes NewDefaultCommandAttributes(const char *commandTag)
{ {
CommandAttributes cmdAttr; ClientCommandAttributes cmdAttr;
strncpy(cmdAttr.tag, commandTag, INPUT_HANDLER_STRING_LENGTH); strncpy(cmdAttr.tag, commandTag, INPUT_HANDLER_STRING_LENGTH);
cmdAttr.selector = nil; cmdAttr.dispatchFunction = NULL;
cmdAttr.intValue[0] = 0; cmdAttr.intValue[0] = 0;
cmdAttr.intValue[1] = 0; cmdAttr.intValue[1] = 0;
cmdAttr.intValue[2] = 0; cmdAttr.intValue[2] = 0;
@ -1998,23 +1926,23 @@ CommandAttributes NewDefaultCommandAttributes(const char *commandTag)
cmdAttr.useInputForIntCoord = false; cmdAttr.useInputForIntCoord = false;
cmdAttr.useInputForFloatCoord = false; cmdAttr.useInputForFloatCoord = false;
cmdAttr.useInputForScalar = false; cmdAttr.useInputForScalar = false;
cmdAttr.useInputForSender = false; cmdAttr.useInputForObject = false;
cmdAttr.allowAnalogInput = false; cmdAttr.allowAnalogInput = false;
return cmdAttr; return cmdAttr;
} }
CommandAttributes NewCommandAttributesForSelector(const char *commandTag, const SEL theSelector) ClientCommandAttributes NewCommandAttributesWithFunction(const char *commandTag, const ClientCommandDispatcher commandFunc)
{ {
CommandAttributes cmdAttr = NewDefaultCommandAttributes(commandTag); ClientCommandAttributes cmdAttr = NewDefaultCommandAttributes(commandTag);
cmdAttr.selector = theSelector; cmdAttr.dispatchFunction = commandFunc;
return cmdAttr; return cmdAttr;
} }
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NDSInputID controlID) ClientCommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NDSInputID controlID)
{ {
CommandAttributes cmdAttr = NewCommandAttributesForSelector(commandTag, @selector(cmdUpdateDSController:)); ClientCommandAttributes cmdAttr = NewCommandAttributesWithFunction(commandTag, &ClientCommandUpdateDSController);
switch (controlID) switch (controlID)
{ {
@ -2030,21 +1958,21 @@ CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const
case NDSInputID_X: case NDSInputID_X:
case NDSInputID_L: case NDSInputID_L:
case NDSInputID_R: case NDSInputID_R:
cmdAttr.selector = @selector(cmdUpdateDSControllerWithTurbo:); cmdAttr.dispatchFunction = &ClientCommandUpdateDSControllerWithTurbo;
cmdAttr.intValue[2] = 0x33333333; cmdAttr.intValue[2] = 0x33333333;
cmdAttr.intValue[3] = 4; cmdAttr.intValue[3] = 4;
break; break;
case NDSInputID_Touch: case NDSInputID_Touch:
cmdAttr.selector = @selector(cmdUpdateDSTouch:); cmdAttr.dispatchFunction = &ClientCommandUpdateDSTouch;
break; break;
case NDSInputID_Microphone: case NDSInputID_Microphone:
cmdAttr.selector = @selector(cmdUpdateDSMicrophone:); cmdAttr.dispatchFunction = &ClientCommandUpdateDSMicrophone;
break; break;
case NDSInputID_Paddle: case NDSInputID_Paddle:
cmdAttr.selector = @selector(cmdUpdateDSPaddle:); cmdAttr.dispatchFunction = &ClientCommandUpdateDSPaddle;
break; break;
default: default:
@ -2057,7 +1985,7 @@ CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const
return cmdAttr; return cmdAttr;
} }
void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr, NSDictionary *deviceInfo) void UpdateCommandAttributesWithDeviceInfoDictionary(ClientCommandAttributes *cmdAttr, NSDictionary *deviceInfo)
{ {
if (cmdAttr == NULL || deviceInfo == nil) if (cmdAttr == NULL || deviceInfo == nil)
{ {
@ -2079,7 +2007,7 @@ void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr,
NSNumber *useInputForIntCoord = (NSNumber *)[deviceInfo valueForKey:@"useInputForIntCoord"]; NSNumber *useInputForIntCoord = (NSNumber *)[deviceInfo valueForKey:@"useInputForIntCoord"];
NSNumber *useInputForFloatCoord = (NSNumber *)[deviceInfo valueForKey:@"useInputForFloatCoord"]; NSNumber *useInputForFloatCoord = (NSNumber *)[deviceInfo valueForKey:@"useInputForFloatCoord"];
NSNumber *useInputForScalar = (NSNumber *)[deviceInfo valueForKey:@"useInputForScalar"]; NSNumber *useInputForScalar = (NSNumber *)[deviceInfo valueForKey:@"useInputForScalar"];
NSNumber *useInputForSender = (NSNumber *)[deviceInfo valueForKey:@"useInputForSender"]; NSNumber *useInputForObject = (NSNumber *)[deviceInfo valueForKey:@"useInputForSender"];
NSNumber *isInputAnalog = (NSNumber *)[deviceInfo valueForKey:@"isInputAnalog"]; NSNumber *isInputAnalog = (NSNumber *)[deviceInfo valueForKey:@"isInputAnalog"];
if (intValue0 != nil) cmdAttr->intValue[0] = [intValue0 intValue]; if (intValue0 != nil) cmdAttr->intValue[0] = [intValue0 intValue];
@ -2093,7 +2021,7 @@ void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr,
if (useInputForIntCoord != nil) cmdAttr->useInputForIntCoord = [useInputForIntCoord boolValue]; if (useInputForIntCoord != nil) cmdAttr->useInputForIntCoord = [useInputForIntCoord boolValue];
if (useInputForFloatCoord != nil) cmdAttr->useInputForFloatCoord = [useInputForFloatCoord boolValue]; if (useInputForFloatCoord != nil) cmdAttr->useInputForFloatCoord = [useInputForFloatCoord boolValue];
if (useInputForScalar != nil) cmdAttr->useInputForScalar = [useInputForScalar boolValue]; if (useInputForScalar != nil) cmdAttr->useInputForScalar = [useInputForScalar boolValue];
if (useInputForSender != nil) cmdAttr->useInputForSender = [useInputForSender boolValue]; if (useInputForObject != nil) cmdAttr->useInputForObject = [useInputForObject boolValue];
if (isInputAnalog != nil) cmdAttr->allowAnalogInput = [isInputAnalog boolValue]; if (isInputAnalog != nil) cmdAttr->allowAnalogInput = [isInputAnalog boolValue];
cmdAttr->object[0] = object0; cmdAttr->object[0] = object0;
@ -2102,7 +2030,7 @@ void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr,
cmdAttr->object[3] = object3; cmdAttr->object[3] = object3;
} }
NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttributes *cmdAttr, NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const ClientCommandAttributes *cmdAttr,
NSString *deviceCode, NSString *deviceCode,
NSString *deviceName, NSString *deviceName,
NSString *elementCode, NSString *elementCode,
@ -2138,7 +2066,7 @@ NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttr
[NSNumber numberWithBool:cmdAttr->useInputForIntCoord], @"useInputForIntCoord", [NSNumber numberWithBool:cmdAttr->useInputForIntCoord], @"useInputForIntCoord",
[NSNumber numberWithBool:cmdAttr->useInputForFloatCoord], @"useInputForFloatCoord", [NSNumber numberWithBool:cmdAttr->useInputForFloatCoord], @"useInputForFloatCoord",
[NSNumber numberWithBool:cmdAttr->useInputForScalar], @"useInputForScalar", [NSNumber numberWithBool:cmdAttr->useInputForScalar], @"useInputForScalar",
[NSNumber numberWithBool:cmdAttr->useInputForSender], @"useInputForSender", [NSNumber numberWithBool:cmdAttr->useInputForObject], @"useInputForSender",
nil]; nil];
// Set the object references last since these could be nil. // Set the object references last since these could be nil.
@ -2150,6 +2078,150 @@ NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttr
return newDeviceInfo; return newDeviceInfo;
} }
void ClientCommandUpdateDSController(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdUpdateDSController:cmdAttr];
}
void ClientCommandUpdateDSControllerWithTurbo(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdUpdateDSControllerWithTurbo:cmdAttr];
}
void ClientCommandUpdateDSTouch(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdUpdateDSTouch:cmdAttr];
}
void ClientCommandUpdateDSMicrophone(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdUpdateDSMicrophone:cmdAttr];
}
void ClientCommandUpdateDSPaddle(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdUpdateDSPaddle:cmdAttr];
}
void ClientCommandAutoholdSet(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdAutoholdSet:cmdAttr];
}
void ClientCommandAutoholdClear(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdAutoholdClear:cmdAttr];
}
void ClientCommandLoadEmuSaveStateSlot(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdLoadEmuSaveStateSlot:cmdAttr];
}
void ClientCommandSaveEmuSaveStateSlot(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdSaveEmuSaveStateSlot:cmdAttr];
}
void ClientCommandCopyScreen(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdCopyScreen:cmdAttr];
}
void ClientCommandRotateDisplayRelative(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdRotateDisplayRelative:cmdAttr];
}
void ClientCommandToggleAllDisplays(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleAllDisplays:cmdAttr];
}
void ClientCommandHoldToggleSpeedScalar(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdHoldToggleSpeedScalar:cmdAttr];
}
void ClientCommandToggleSpeedLimiter(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleSpeedLimiter:cmdAttr];
}
void ClientCommandToggleAutoFrameSkip(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleAutoFrameSkip:cmdAttr];
}
void ClientCommandToggleCheats(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleCheats:cmdAttr];
}
void ClientCommandToggleExecutePause(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleExecutePause:cmdAttr];
}
void ClientCommandCoreExecute(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdCoreExecute:cmdAttr];
}
void ClientCommandCorePause(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdCorePause:cmdAttr];
}
void ClientCommandFrameAdvance(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdFrameAdvance:cmdAttr];
}
void ClientCommandFrameJump(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdFrameJump:cmdAttr];
}
void ClientCommandReset(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdReset:cmdAttr];
}
void ClientCommandToggleMute(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleMute:cmdAttr];
}
void ClientCommandToggleGPUState(const ClientCommandAttributes &cmdAttr, void *dispatcherObject)
{
EmuControllerDelegate *emuControl = (EmuControllerDelegate *)dispatcherObject;
[emuControl cmdToggleGPUState:cmdAttr];
}
MacInputDevicePropertiesEncoder::MacInputDevicePropertiesEncoder() MacInputDevicePropertiesEncoder::MacInputDevicePropertiesEncoder()
{ {
NSDictionary *keyboardNameDict = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"KeyNames" ofType:@"plist"]]; NSDictionary *keyboardNameDict = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"KeyNames" ofType:@"plist"]];

View File

@ -305,7 +305,7 @@
} }
// Add the input mapping. // Add the input mapping.
const CommandAttributes cmdAttr = [inputManager defaultCommandAttributesForCommandTag:cmdTag]; const ClientCommandAttributes cmdAttr = [inputManager defaultCommandAttributesForCommandTag:cmdTag];
[inputManager addMappingUsingInputAttributes:inputProperty commandAttributes:&cmdAttr]; [inputManager addMappingUsingInputAttributes:inputProperty commandAttributes:&cmdAttr];
[inputManager writeDefaultsInputMappings]; [inputManager writeDefaultsInputMappings];
@ -352,7 +352,7 @@
const char *devCode = [deviceCode cStringUsingEncoding:NSUTF8StringEncoding]; const char *devCode = [deviceCode cStringUsingEncoding:NSUTF8StringEncoding];
const char *elCode = [elementCode cStringUsingEncoding:NSUTF8StringEncoding]; const char *elCode = [elementCode cStringUsingEncoding:NSUTF8StringEncoding];
CommandAttributes cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:devCode elementCode:elCode]; ClientCommandAttributes cmdAttr = [inputManager mappedCommandAttributesOfDeviceCode:devCode elementCode:elCode];
UpdateCommandAttributesWithDeviceInfoDictionary(&cmdAttr, deviceInfo); UpdateCommandAttributesWithDeviceInfoDictionary(&cmdAttr, deviceInfo);
[inputManager updateInputSettingsSummaryInDeviceInfoDictionary:deviceInfo commandTag:cmdAttr.tag]; [inputManager updateInputSettingsSummaryInDeviceInfoDictionary:deviceInfo commandTag:cmdAttr.tag];
[inputManager setMappedCommandAttributes:&cmdAttr deviceCode:devCode elementCode:elCode]; [inputManager setMappedCommandAttributes:&cmdAttr deviceCode:devCode elementCode:elCode];
@ -450,7 +450,7 @@
return isHandled; return isHandled;
} }
CommandAttributes cmdAttr = [[hidManager inputManager] defaultCommandAttributesForCommandTag:[cmdTagTarget cStringUsingEncoding:NSUTF8StringEncoding]]; ClientCommandAttributes cmdAttr = [[hidManager inputManager] defaultCommandAttributesForCommandTag:[cmdTagTarget cStringUsingEncoding:NSUTF8StringEncoding]];
bool forceDigitalInput = !cmdAttr.allowAnalogInput; bool forceDigitalInput = !cmdAttr.allowAnalogInput;
MacInputDevicePropertiesEncoder *inputEncoder = [[hidManager inputManager] inputEncoder]; MacInputDevicePropertiesEncoder *inputEncoder = [[hidManager inputManager] inputEncoder];