Cocoa Port: NEW FEATURE - Add the ability to set up custom frame-by-frame press/release state patterns for turbo.
This commit is contained in:
parent
d1ac719b5c
commit
af22153f5c
|
@ -39,7 +39,7 @@
|
|||
#define FRAME_SKIP_BIAS 0.1 // May be any real number. This value acts as a vector addition to the frame skip.
|
||||
#define MAX_FRAME_SKIP (DS_FRAMES_PER_SECOND / 2.98)
|
||||
|
||||
#define INPUT_STATES_CLEAR_VALUE 0xFFFFFFFF00FF03FFUL
|
||||
#define INPUT_STATES_CLEAR_VALUE 0xFFFFFFFF00FF03FFULL
|
||||
|
||||
enum ExecutionBehavior
|
||||
{
|
||||
|
|
|
@ -81,6 +81,10 @@
|
|||
<string>Up Arrow</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Down</key>
|
||||
|
@ -98,6 +102,10 @@
|
|||
<string>Down Arrow</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Left</key>
|
||||
|
@ -115,6 +123,10 @@
|
|||
<string>Left Arrow</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Right</key>
|
||||
|
@ -132,6 +144,10 @@
|
|||
<string>Right Arrow</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>A</key>
|
||||
|
@ -149,6 +165,10 @@
|
|||
<string>X</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>B</key>
|
||||
|
@ -166,6 +186,10 @@
|
|||
<string>Z</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>X</key>
|
||||
|
@ -183,6 +207,10 @@
|
|||
<string>S</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Y</key>
|
||||
|
@ -200,6 +228,10 @@
|
|||
<string>A</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>L</key>
|
||||
|
@ -217,6 +249,10 @@
|
|||
<string>Q</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>R</key>
|
||||
|
@ -234,6 +270,10 @@
|
|||
<string>W</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Start</key>
|
||||
|
@ -251,6 +291,10 @@
|
|||
<string>Return</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Select</key>
|
||||
|
@ -268,6 +312,10 @@
|
|||
<string>Tab</string>
|
||||
<key>intValue1</key>
|
||||
<false/>
|
||||
<key>intValue2</key>
|
||||
<integer>858993459</integer>
|
||||
<key>intValue3</key>
|
||||
<integer>4</integer>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Touch</key>
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef struct
|
|||
bool autohold;
|
||||
uint32_t turboPattern;
|
||||
uint8_t turboPatternStep;
|
||||
uint8_t turboPatternLength;
|
||||
} ClientInput;
|
||||
|
||||
@protocol CocoaDSControllerDelegate <NSObject>
|
||||
|
@ -107,7 +108,7 @@ typedef struct
|
|||
@property (retain) NSString *hardwareMicSampleRateString;
|
||||
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID;
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled turboPattern:(uint32_t)turboPattern;
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled turboPattern:(uint32_t)turboPattern turboPatternLength:(uint32_t)turboPatternLength;
|
||||
- (void) setTouchState:(BOOL)theState location:(const NSPoint)theLocation;
|
||||
- (void) setSineWaveGeneratorFrequency:(const double)freq;
|
||||
- (void) clearAutohold;
|
||||
|
|
|
@ -72,6 +72,7 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
|||
clientInput[i].turbo = false;
|
||||
clientInput[i].turboPattern = 0;
|
||||
clientInput[i].turboPatternStep = 0;
|
||||
clientInput[i].turboPatternLength = 0;
|
||||
clientInput[i].autohold = false;
|
||||
}
|
||||
|
||||
|
@ -242,10 +243,10 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
|||
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID
|
||||
{
|
||||
[self setControllerState:theState controlID:controlID turbo:NO turboPattern:0];
|
||||
[self setControllerState:theState controlID:controlID turbo:NO turboPattern:0 turboPatternLength:0];
|
||||
}
|
||||
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled turboPattern:(uint32_t)turboPattern
|
||||
- (void) setControllerState:(BOOL)theState controlID:(const NSUInteger)controlID turbo:(const BOOL)isTurboEnabled turboPattern:(uint32_t)turboPattern turboPatternLength:(uint32_t)turboPatternLength
|
||||
{
|
||||
if (controlID >= NDSInputID_InputCount)
|
||||
{
|
||||
|
@ -259,25 +260,27 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
|||
if (theState)
|
||||
{
|
||||
clientInput[controlID].turbo = (isTurboEnabled) ? true : false;
|
||||
clientInput[controlID].turboPattern = (clientInput[controlID].turbo) ? turboPattern : 0;
|
||||
clientInput[controlID].autohold = true;
|
||||
|
||||
if (!clientInput[controlID].turbo)
|
||||
{
|
||||
clientInput[controlID].turboPatternStep = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clientInput[controlID].isPressed = (theState || clientInput[controlID].autohold);
|
||||
clientInput[controlID].turbo = (isTurboEnabled && clientInput[controlID].isPressed);
|
||||
clientInput[controlID].turboPattern = (clientInput[controlID].turbo) ? turboPattern : 0;
|
||||
|
||||
if (!clientInput[controlID].turbo)
|
||||
{
|
||||
clientInput[controlID].turboPatternStep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
clientInput[controlID].turboPattern = (clientInput[controlID].turbo) ? turboPattern : 0;
|
||||
|
||||
if (turboPatternLength > 32)
|
||||
{
|
||||
turboPatternLength = 32;
|
||||
}
|
||||
|
||||
clientInput[controlID].turboPatternLength = (clientInput[controlID].turbo) ? turboPatternLength : 0;
|
||||
|
||||
if (!clientInput[controlID].turbo)
|
||||
{
|
||||
clientInput[controlID].turboPatternStep = 0;
|
||||
}
|
||||
|
||||
OSSpinLockUnlock(&spinlockControllerState);
|
||||
|
@ -326,11 +329,11 @@ SineWaveGenerator sineWaveGenerator(250.0, MIC_SAMPLE_RATE);
|
|||
|
||||
if (clientInput[i].turbo)
|
||||
{
|
||||
const bool turboState = (clientInput[i].turboPattern >> clientInput[i].turboPatternStep) & 0x00000001;
|
||||
flushedStates[i] = (flushedStates[i] && turboState);
|
||||
const bool pressedState = (clientInput[i].turboPattern >> clientInput[i].turboPatternStep) & 0x00000001;
|
||||
flushedStates[i] = (flushedStates[i] && pressedState);
|
||||
|
||||
clientInput[i].turboPatternStep++;
|
||||
if (clientInput[i].turboPatternStep >= 32)
|
||||
if (clientInput[i].turboPatternStep >= clientInput[i].turboPatternLength)
|
||||
{
|
||||
clientInput[i].turboPatternStep = 0;
|
||||
}
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1051,9 +1051,10 @@
|
|||
const NSUInteger controlID = cmdAttr.intValue[0];
|
||||
const BOOL isTurboEnabled = (BOOL)cmdAttr.intValue[1];
|
||||
const uint32_t turboPattern = (uint32_t)cmdAttr.intValue[2];
|
||||
const uint32_t turboPatternLength = (uint32_t)cmdAttr.intValue[3];
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[[cdsCore cdsController] setControllerState:theState controlID:controlID turbo:isTurboEnabled turboPattern:turboPattern];
|
||||
[[cdsCore cdsController] setControllerState:theState controlID:controlID turbo:isTurboEnabled turboPattern:turboPattern turboPatternLength:turboPatternLength];
|
||||
}
|
||||
|
||||
- (void) cmdUpdateDSTouch:(NSValue *)cmdAttrValue
|
||||
|
|
|
@ -237,7 +237,7 @@ void HandleDeviceRemovalCallback(void *inContext, IOReturn inResult, void *inSen
|
|||
|
||||
CommandAttributes NewDefaultCommandAttributes(const char *commandTag);
|
||||
CommandAttributes NewCommandAttributesForSelector(const char *commandTag, const SEL theSelector);
|
||||
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NSUInteger controlID, const bool supportTurbo);
|
||||
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NSUInteger controlID);
|
||||
void UpdateCommandAttributesWithDeviceInfoDictionary(CommandAttributes *cmdAttr, NSDictionary *deviceInfo);
|
||||
|
||||
NSMutableDictionary* DeviceInfoDictionaryWithCommandAttributes(const CommandAttributes *cmdAttr,
|
||||
|
|
|
@ -1122,47 +1122,47 @@ static std::unordered_map<unsigned short, std::string> keyboardNameTable; // Key
|
|||
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.)
|
||||
CommandAttributes cmdDSControlRight = NewCommandAttributesForDSControl("Right", NDSInputID_Right, true);
|
||||
CommandAttributes cmdDSControlLeft = NewCommandAttributesForDSControl("Left", NDSInputID_Left, true);
|
||||
CommandAttributes cmdDSControlDown = NewCommandAttributesForDSControl("Down", NDSInputID_Down, true);
|
||||
CommandAttributes cmdDSControlUp = NewCommandAttributesForDSControl("Up", NDSInputID_Up, true);
|
||||
CommandAttributes cmdDSControlSelect = NewCommandAttributesForDSControl("Select", NDSInputID_Select, true);
|
||||
CommandAttributes cmdDSControlStart = NewCommandAttributesForDSControl("Start", NDSInputID_Start, true);
|
||||
CommandAttributes cmdDSControlB = NewCommandAttributesForDSControl("B", NDSInputID_B, true);
|
||||
CommandAttributes cmdDSControlA = NewCommandAttributesForDSControl("A", NDSInputID_A, true);
|
||||
CommandAttributes cmdDSControlY = NewCommandAttributesForDSControl("Y", NDSInputID_Y, true);
|
||||
CommandAttributes cmdDSControlX = NewCommandAttributesForDSControl("X", NDSInputID_X, true);
|
||||
CommandAttributes cmdDSControlL = NewCommandAttributesForDSControl("L", NDSInputID_L, true);
|
||||
CommandAttributes cmdDSControlR = NewCommandAttributesForDSControl("R", NDSInputID_R, true);
|
||||
CommandAttributes cmdDSControlDebug = NewCommandAttributesForDSControl("Debug", NDSInputID_Debug, false);
|
||||
CommandAttributes cmdDSControlLid = NewCommandAttributesForDSControl("Lid", NDSInputID_Lid, false);
|
||||
CommandAttributes cmdDSControlRight = NewCommandAttributesForDSControl("Right", NDSInputID_Right);
|
||||
CommandAttributes cmdDSControlLeft = NewCommandAttributesForDSControl("Left", NDSInputID_Left);
|
||||
CommandAttributes cmdDSControlDown = NewCommandAttributesForDSControl("Down", NDSInputID_Down);
|
||||
CommandAttributes cmdDSControlUp = NewCommandAttributesForDSControl("Up", NDSInputID_Up);
|
||||
CommandAttributes cmdDSControlSelect = NewCommandAttributesForDSControl("Select", NDSInputID_Select);
|
||||
CommandAttributes cmdDSControlStart = NewCommandAttributesForDSControl("Start", NDSInputID_Start);
|
||||
CommandAttributes cmdDSControlB = NewCommandAttributesForDSControl("B", NDSInputID_B);
|
||||
CommandAttributes cmdDSControlA = NewCommandAttributesForDSControl("A", NDSInputID_A);
|
||||
CommandAttributes cmdDSControlY = NewCommandAttributesForDSControl("Y", NDSInputID_Y);
|
||||
CommandAttributes cmdDSControlX = NewCommandAttributesForDSControl("X", NDSInputID_X);
|
||||
CommandAttributes cmdDSControlL = NewCommandAttributesForDSControl("L", NDSInputID_L);
|
||||
CommandAttributes cmdDSControlR = NewCommandAttributesForDSControl("R", NDSInputID_R);
|
||||
CommandAttributes cmdDSControlDebug = NewCommandAttributesForDSControl("Debug", NDSInputID_Debug);
|
||||
CommandAttributes cmdDSControlLid = NewCommandAttributesForDSControl("Lid", NDSInputID_Lid);
|
||||
|
||||
CommandAttributes cmdDSControlTouch = NewCommandAttributesForDSControl("Touch", NDSInputID_Touch, false);
|
||||
CommandAttributes cmdDSControlTouch = NewCommandAttributesForDSControl("Touch", NDSInputID_Touch);
|
||||
cmdDSControlTouch.useInputForIntCoord = true;
|
||||
|
||||
CommandAttributes cmdDSControlMic = NewCommandAttributesForDSControl("Microphone", NDSInputID_Microphone, false);
|
||||
CommandAttributes cmdDSControlMic = NewCommandAttributesForDSControl("Microphone", NDSInputID_Microphone);
|
||||
cmdDSControlMic.intValue[1] = MICMODE_INTERNAL_NOISE;
|
||||
cmdDSControlMic.floatValue[0] = 250.0f;
|
||||
|
||||
CommandAttributes cmdGuitarGripGreen = NewCommandAttributesForDSControl("Guitar Grip: Green", NDSInputID_GuitarGrip_Green, false);
|
||||
CommandAttributes cmdGuitarGripRed = NewCommandAttributesForDSControl("Guitar Grip: Red", NDSInputID_GuitarGrip_Red, false);
|
||||
CommandAttributes cmdGuitarGripYellow = NewCommandAttributesForDSControl("Guitar Grip: Yellow", NDSInputID_GuitarGrip_Yellow, false);
|
||||
CommandAttributes cmdGuitarGripBlue = NewCommandAttributesForDSControl("Guitar Grip: Blue", NDSInputID_GuitarGrip_Blue, false);
|
||||
CommandAttributes cmdPianoC = NewCommandAttributesForDSControl("Piano: C", NDSInputID_Piano_C, false);
|
||||
CommandAttributes cmdPianoCSharp = NewCommandAttributesForDSControl("Piano: C#", NDSInputID_Piano_CSharp, false);
|
||||
CommandAttributes cmdPianoD = NewCommandAttributesForDSControl("Piano: D", NDSInputID_Piano_D, false);
|
||||
CommandAttributes cmdPianoDSharp = NewCommandAttributesForDSControl("Piano: D#", NDSInputID_Piano_DSharp, false);
|
||||
CommandAttributes cmdPianoE = NewCommandAttributesForDSControl("Piano: E", NDSInputID_Piano_E, false);
|
||||
CommandAttributes cmdPianoF = NewCommandAttributesForDSControl("Piano: F", NDSInputID_Piano_F, false);
|
||||
CommandAttributes cmdPianoFSharp = NewCommandAttributesForDSControl("Piano: F#", NDSInputID_Piano_FSharp, false);
|
||||
CommandAttributes cmdPianoG = NewCommandAttributesForDSControl("Piano: G", NDSInputID_Piano_G, false);
|
||||
CommandAttributes cmdPianoGSharp = NewCommandAttributesForDSControl("Piano: G#", NDSInputID_Piano_GSharp, false);
|
||||
CommandAttributes cmdPianoA = NewCommandAttributesForDSControl("Piano: A", NDSInputID_Piano_A, false);
|
||||
CommandAttributes cmdPianoASharp = NewCommandAttributesForDSControl("Piano: A#", NDSInputID_Piano_ASharp, false);
|
||||
CommandAttributes cmdPianoB = NewCommandAttributesForDSControl("Piano: B", NDSInputID_Piano_B, false);
|
||||
CommandAttributes cmdPianoHighC = NewCommandAttributesForDSControl("Piano: High C", NDSInputID_Piano_HighC, false);
|
||||
CommandAttributes cmdGuitarGripGreen = NewCommandAttributesForDSControl("Guitar Grip: Green", NDSInputID_GuitarGrip_Green);
|
||||
CommandAttributes cmdGuitarGripRed = NewCommandAttributesForDSControl("Guitar Grip: Red", NDSInputID_GuitarGrip_Red);
|
||||
CommandAttributes cmdGuitarGripYellow = NewCommandAttributesForDSControl("Guitar Grip: Yellow", NDSInputID_GuitarGrip_Yellow);
|
||||
CommandAttributes cmdGuitarGripBlue = NewCommandAttributesForDSControl("Guitar Grip: Blue", NDSInputID_GuitarGrip_Blue);
|
||||
CommandAttributes cmdPianoC = NewCommandAttributesForDSControl("Piano: C", NDSInputID_Piano_C);
|
||||
CommandAttributes cmdPianoCSharp = NewCommandAttributesForDSControl("Piano: C#", NDSInputID_Piano_CSharp);
|
||||
CommandAttributes cmdPianoD = NewCommandAttributesForDSControl("Piano: D", NDSInputID_Piano_D);
|
||||
CommandAttributes cmdPianoDSharp = NewCommandAttributesForDSControl("Piano: D#", NDSInputID_Piano_DSharp);
|
||||
CommandAttributes cmdPianoE = NewCommandAttributesForDSControl("Piano: E", NDSInputID_Piano_E);
|
||||
CommandAttributes cmdPianoF = NewCommandAttributesForDSControl("Piano: F", NDSInputID_Piano_F);
|
||||
CommandAttributes cmdPianoFSharp = NewCommandAttributesForDSControl("Piano: F#", NDSInputID_Piano_FSharp);
|
||||
CommandAttributes cmdPianoG = NewCommandAttributesForDSControl("Piano: G", NDSInputID_Piano_G);
|
||||
CommandAttributes cmdPianoGSharp = NewCommandAttributesForDSControl("Piano: G#", NDSInputID_Piano_GSharp);
|
||||
CommandAttributes cmdPianoA = NewCommandAttributesForDSControl("Piano: A", NDSInputID_Piano_A);
|
||||
CommandAttributes cmdPianoASharp = NewCommandAttributesForDSControl("Piano: A#", NDSInputID_Piano_ASharp);
|
||||
CommandAttributes cmdPianoB = NewCommandAttributesForDSControl("Piano: B", NDSInputID_Piano_B);
|
||||
CommandAttributes cmdPianoHighC = NewCommandAttributesForDSControl("Piano: High C", NDSInputID_Piano_HighC);
|
||||
|
||||
CommandAttributes cmdPaddle = NewCommandAttributesForDSControl("Paddle", NDSInputID_Paddle, false);
|
||||
CommandAttributes cmdPaddle = NewCommandAttributesForDSControl("Paddle", NDSInputID_Paddle);
|
||||
cmdPaddle.allowAnalogInput = true;
|
||||
cmdPaddle.intValue[1] = 0;
|
||||
cmdPaddle.floatValue[0] = 10.0f;
|
||||
|
@ -1343,7 +1343,11 @@ static std::unordered_map<unsigned short, std::string> keyboardNameTable; // Key
|
|||
|
||||
if (cmdAttr.selector == @selector(cmdUpdateDSControllerWithTurbo:))
|
||||
{
|
||||
cmdAttr.intValue[2] = defaultCommandAttributes[cmdTag].intValue[2];
|
||||
if ((cmdAttr.intValue[2] == 0) || (cmdAttr.intValue[3] == 0))
|
||||
{
|
||||
cmdAttr.intValue[2] = defaultCommandAttributes[cmdTag].intValue[2];
|
||||
cmdAttr.intValue[3] = defaultCommandAttributes[cmdTag].intValue[3];
|
||||
}
|
||||
}
|
||||
|
||||
// Copy all command attributes into a new deviceInfo dictionary.
|
||||
|
@ -2022,7 +2026,7 @@ CommandAttributes NewCommandAttributesForSelector(const char *commandTag, const
|
|||
return cmdAttr;
|
||||
}
|
||||
|
||||
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NSUInteger controlID, const bool supportTurbo)
|
||||
CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const NSUInteger controlID)
|
||||
{
|
||||
CommandAttributes cmdAttr = NewCommandAttributesForSelector(commandTag, @selector(cmdUpdateDSController:));
|
||||
|
||||
|
@ -2041,7 +2045,8 @@ CommandAttributes NewCommandAttributesForDSControl(const char *commandTag, const
|
|||
case NDSInputID_L:
|
||||
case NDSInputID_R:
|
||||
cmdAttr.selector = @selector(cmdUpdateDSControllerWithTurbo:);
|
||||
cmdAttr.intValue[2] = (supportTurbo) ? 0x33333333 : 0;
|
||||
cmdAttr.intValue[2] = 0x33333333;
|
||||
cmdAttr.intValue[3] = 4;
|
||||
break;
|
||||
|
||||
case NDSInputID_Touch:
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
NSWindow *inputSettingsGPUState;
|
||||
NSWindow *inputSettingsPaddleController;
|
||||
|
||||
NSSegmentedControl *turboPatternControl;
|
||||
|
||||
InputManager *inputManager;
|
||||
NSString *configInputTargetID;
|
||||
NSMutableDictionary *configInputList;
|
||||
|
@ -80,6 +82,8 @@
|
|||
@property (readonly) IBOutlet NSWindow *inputSettingsGPUState;
|
||||
@property (readonly) IBOutlet NSWindow *inputSettingsPaddleController;
|
||||
|
||||
@property (readonly) IBOutlet NSSegmentedControl *turboPatternControl;
|
||||
|
||||
@property (readonly) IBOutlet InputManager *inputManager;
|
||||
@property (retain) NSString *configInputTargetID;
|
||||
@property (retain) NSMutableDictionary *inputSettingsInEdit;
|
||||
|
@ -104,6 +108,10 @@
|
|||
- (IBAction) showSettingsSheet:(id)sender;
|
||||
- (IBAction) closeSettingsSheet:(id)sender;
|
||||
|
||||
- (IBAction) updateCustomTurboPatternControls:(id)sender;
|
||||
- (IBAction) setTurboPatternBits:(id)sender;
|
||||
- (IBAction) setTurboPatternUsingTag:(id)sender;
|
||||
|
||||
- (IBAction) profileNew:(id)sender;
|
||||
- (IBAction) profileView:(id)sender;
|
||||
- (IBAction) profileApply:(id)sender;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
@synthesize inputSettingsSetSpeedLimit;
|
||||
@synthesize inputSettingsGPUState;
|
||||
@synthesize inputSettingsPaddleController;
|
||||
@synthesize turboPatternControl;
|
||||
@synthesize inputProfileSheet;
|
||||
@synthesize inputProfileRenameSheet;
|
||||
@synthesize inputManager;
|
||||
|
@ -818,6 +819,11 @@
|
|||
|
||||
[inputSettingsController setContent:[NSMutableDictionary dictionaryWithDictionary:[self inputSettingsInEdit]]];
|
||||
|
||||
if (theSheet == inputSettingsNDSInput)
|
||||
{
|
||||
[self updateCustomTurboPatternControls:turboPatternControl];
|
||||
}
|
||||
|
||||
[NSApp beginSheet:theSheet
|
||||
modalForWindow:prefWindow
|
||||
modalDelegate:self
|
||||
|
@ -832,6 +838,108 @@
|
|||
[NSApp endSheet:sheet returnCode:[CocoaDSUtil getIBActionSenderTag:sender]];
|
||||
}
|
||||
|
||||
- (IBAction) updateCustomTurboPatternControls:(id)sender
|
||||
{
|
||||
NSMutableDictionary *editedDeviceInfo = (NSMutableDictionary *)[inputSettingsController content];
|
||||
NSWindow *theSheet = [(NSControl *)sender window];
|
||||
[theSheet makeFirstResponder:nil]; // Force end of editing of any text fields.
|
||||
|
||||
NSNumber *turboPatternNumber = (NSNumber *)[editedDeviceInfo valueForKey:@"intValue2"];
|
||||
uint32_t turboPattern = (uint32_t)[turboPatternNumber unsignedIntegerValue];
|
||||
|
||||
NSNumber *turboPatternLengthNumber = (NSNumber *)[editedDeviceInfo valueForKey:@"intValue3"];
|
||||
NSInteger turboPatternLength = [turboPatternLengthNumber integerValue];
|
||||
[turboPatternControl setSegmentCount:turboPatternLength];
|
||||
|
||||
for (NSInteger i = 0; i < turboPatternLength; i++)
|
||||
{
|
||||
[turboPatternControl setWidth:19.0f forSegment:i];
|
||||
[turboPatternControl setLabel:[NSString stringWithFormat:@"%i", (int)(i + 1)] forSegment:i];
|
||||
|
||||
BOOL isPressedBit = ( ((turboPattern >> i) & 0x01) != 0 );
|
||||
[turboPatternControl setSelected:isPressedBit forSegment:i];
|
||||
}
|
||||
|
||||
float controlWidth = (turboPatternLength * (19.0f + 1.3f));
|
||||
NSRect oldSheetFrame = [theSheet frame];
|
||||
NSRect newSheetFrame = oldSheetFrame;
|
||||
|
||||
if (controlWidth < 377.0f)
|
||||
{
|
||||
newSheetFrame.size.width = 407.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSheetFrame.size.width = controlWidth + 20.0f;
|
||||
}
|
||||
|
||||
newSheetFrame.origin.x += (oldSheetFrame.size.width - newSheetFrame.size.width) / 2.0f;
|
||||
[theSheet setFrame:newSheetFrame display:NO];
|
||||
|
||||
NSPoint turboPatternControlOrigin = [turboPatternControl frame].origin;
|
||||
turboPatternControlOrigin.x = (newSheetFrame.size.width / 2.0f) - (controlWidth / 2.0f);
|
||||
[turboPatternControl setFrameOrigin:turboPatternControlOrigin];
|
||||
}
|
||||
|
||||
- (IBAction) setTurboPatternBits:(id)sender
|
||||
{
|
||||
NSNumber *turboPatternLengthNumber = (NSNumber *)[[self inputSettingsInEdit] valueForKey:@"intValue3"];
|
||||
NSInteger turboPatternLength = [turboPatternLengthNumber integerValue];
|
||||
|
||||
uint32_t turboPattern = 0;
|
||||
|
||||
for (NSInteger i = 0; i < turboPatternLength; i++)
|
||||
{
|
||||
BOOL isPressedBit = [turboPatternControl isSelectedForSegment:i];
|
||||
if (isPressedBit)
|
||||
{
|
||||
turboPattern |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
NSNumber *turboPatternNumber = [NSNumber numberWithUnsignedInt:turboPattern];
|
||||
NSMutableDictionary *editedDeviceInfo = (NSMutableDictionary *)[inputSettingsController content];
|
||||
[editedDeviceInfo setValue:turboPatternNumber forKey:@"intValue2"];
|
||||
}
|
||||
|
||||
- (IBAction) setTurboPatternUsingTag:(id)sender
|
||||
{
|
||||
uint32_t intValue = (uint32_t)[CocoaDSUtil getIBActionSenderTag:sender];
|
||||
|
||||
if ( (intValue < 1) || (intValue > 16) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t turboPattern = 0;
|
||||
uint32_t turboPatternLength = intValue * 2;
|
||||
|
||||
for (uint32_t i = 0, j = 0; i < 32; i++)
|
||||
{
|
||||
if (j < intValue)
|
||||
{
|
||||
turboPattern |= (1 << i);
|
||||
}
|
||||
|
||||
j++;
|
||||
|
||||
if (j >= (intValue * 2))
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableDictionary *editedDeviceInfo = (NSMutableDictionary *)[inputSettingsController content];
|
||||
|
||||
NSNumber *turboPatternNumber = [NSNumber numberWithUnsignedInt:turboPattern];
|
||||
[editedDeviceInfo setValue:turboPatternNumber forKey:@"intValue2"];
|
||||
|
||||
NSNumber *turboPatternLengthNumber = [NSNumber numberWithUnsignedInt:turboPatternLength];
|
||||
[editedDeviceInfo setValue:turboPatternLengthNumber forKey:@"intValue3"];
|
||||
|
||||
[self updateCustomTurboPatternControls:turboPatternControl];
|
||||
}
|
||||
|
||||
- (IBAction) profileNew:(id)sender
|
||||
{
|
||||
static NSUInteger untitledCount = 1;
|
||||
|
|
Loading…
Reference in New Issue