Cocoa Port: Do some UI tweaks with reporting the firmware MAC address.

This commit is contained in:
rogerman 2018-10-25 15:42:27 -07:00
parent 2e7099052d
commit c3dbb920fa
8 changed files with 102055 additions and 99884 deletions

View File

@ -601,22 +601,9 @@ void ClientExecutionControl::SetWifiBridgeDeviceIndex(int wifiBridgeDeviceIndex)
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
}
uint32_t ClientExecutionControl::GetWifiIP4Address()
uint8_t* ClientExecutionControl::GetCurrentSessionMACAddress()
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
const uint32_t ip4Address = this->_settingsPending.wifiIP4Address;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
return ip4Address;
}
void ClientExecutionControl::SetWifiIP4Address(uint32_t ip4Address)
{
pthread_mutex_lock(&this->_mutexSettingsPendingOnReset);
this->_settingsPending.wifiIP4Address = ip4Address;
this->_newSettingsPendingOnReset = true;
pthread_mutex_unlock(&this->_mutexSettingsPendingOnReset);
return (uint8_t *)FW_Mac;
}
bool ClientExecutionControl::GetEnableCheats()
@ -974,7 +961,6 @@ void ClientExecutionControl::ApplySettingsOnReset()
this->_settingsApplied.wifiEmulationMode = this->_settingsPending.wifiEmulationMode;
this->_settingsApplied.wifiBridgeDeviceIndex = this->_settingsPending.wifiBridgeDeviceIndex;
this->_settingsApplied.wifiIP4Address = this->_settingsPending.wifiIP4Address;
this->_settingsApplied.cpuEmulationEngineName = this->_settingsPending.cpuEmulationEngineName;
this->_settingsApplied.slot1DeviceName = this->_settingsPending.slot1DeviceName;

View File

@ -97,7 +97,6 @@ struct ClientExecutionControlSettings
int wifiEmulationMode;
int wifiBridgeDeviceIndex;
uint32_t wifiIP4Address;
bool enableCheats;
@ -311,8 +310,7 @@ public:
int GetWifiBridgeDeviceIndex();
void SetWifiBridgeDeviceIndex(int wifiBridgeDeviceIndex);
uint32_t GetWifiIP4Address();
void SetWifiIP4Address(uint32_t ip4Address);
uint8_t* GetCurrentSessionMACAddress();
bool GetEnableCheats();
void SetEnableCheats(bool enable);

View File

@ -61,6 +61,8 @@ typedef struct
NSString *frameStatus;
NSString *executionSpeedStatus;
NSString *errorStatus;
NSString *firmwareMACAddressSelectionString;
NSString *currentSessionMACAddressString;
OSSpinLock spinlockCdsController;
OSSpinLock spinlockMasterExecute;
@ -115,10 +117,13 @@ typedef struct
@property (copy) NSURL *firmwareImageURL;
@property (copy) NSURL *slot1R4URL;
@property (assign) NSString *firmwareMACAddressSelectionString;
@property (retain) NSString *firmwareMACAddressSelectionString;
@property (retain) NSString *currentSessionMACAddressString;
@property (readonly) pthread_rwlock_t *rwlockCoreExecute;
- (void) updateFirmwareMACAddressString;
- (void) updateCurrentSessionMACAddressString:(BOOL)isRomLoaded;
- (void) generateFirmwareMACAddress;
- (BOOL) isSlot1Ejected;

View File

@ -84,11 +84,12 @@ volatile bool execute = true;
@synthesize frameStatus;
@synthesize executionSpeedStatus;
@synthesize errorStatus;
@synthesize firmwareMACAddressSelectionString;
@synthesize currentSessionMACAddressString;
@dynamic arm9ImageURL;
@dynamic arm7ImageURL;
@dynamic firmwareImageURL;
@dynamic firmwareMACAddressSelectionString;
@dynamic slot1R4URL;
@dynamic rwlockCoreExecute;
@ -122,16 +123,13 @@ volatile bool execute = true;
ClientInputHandler *inputHandler = [cdsController inputHandler];
inputHandler->SetClientExecutionController(execControl);
execControl->SetClientInputHandler(inputHandler);
slot1StatusText = NSSTRING_STATUS_EMULATION_NOT_RUNNING;
execControl->SetWifiEmulationMode(WifiEmulationLevel_Off);
spinlockMasterExecute = OS_SPINLOCK_INIT;
spinlockCdsController = OS_SPINLOCK_INIT;
threadParam.cdsCore = self;
wifiHandler->SetEmulationLevel(WifiEmulationLevel_Off);
pthread_rwlock_init(&threadParam.rwlockOutputList, NULL);
pthread_mutex_init(&threadParam.mutexThreadExecute, NULL);
pthread_cond_init(&threadParam.condThreadExecute, NULL);
@ -173,6 +171,9 @@ volatile bool execute = true;
frameStatus = @"---";
executionSpeedStatus = @"1.00x";
errorStatus = @"";
slot1StatusText = NSSTRING_STATUS_EMULATION_NOT_RUNNING;
firmwareMACAddressSelectionString = @"Firmware 00:09:BF:FF:FF:FF";
currentSessionMACAddressString = NSSTRING_STATUS_NO_ROM_LOADED;
return self;
}
@ -190,6 +191,8 @@ volatile bool execute = true;
[self setCdsGPU:nil];
[self setCdsOutputList:nil];
[self setErrorStatus:nil];
[self setFirmwareMACAddressSelectionString:nil];
[self setCurrentSessionMACAddressString:nil];
pthread_cancel(coreThread);
pthread_join(coreThread, NULL);
@ -716,15 +719,24 @@ volatile bool execute = true;
return [NSURL fileURLWithPath:[NSString stringWithCString:filePath encoding:NSUTF8StringEncoding]];
}
- (void) setFirmwareMACAddressSelectionString:(NSString *)theString
- (void) updateFirmwareMACAddressString
{
// Do nothing. This is here for KVO-compliance only.
[self setFirmwareMACAddressSelectionString:[NSString stringWithFormat:@"Firmware %@", [[self cdsFirmware] MACAddressString]]];
}
- (NSString *) firmwareMACAddressSelectionString
- (void) updateCurrentSessionMACAddressString:(BOOL)isRomLoaded
{
// TODO: Also handle the case of returning the correct MAC address of external firmware.
return [NSString stringWithFormat:@"Firmware %@", [[self cdsFirmware] MACAddressString]];
if (isRomLoaded)
{
const uint8_t *MACAddress = execControl->GetCurrentSessionMACAddress();
NSString *MACAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
MACAddress[0], MACAddress[1], MACAddress[2], MACAddress[3], MACAddress[4], MACAddress[5]];
[self setCurrentSessionMACAddressString:MACAddressString];
}
else
{
[self setCurrentSessionMACAddressString:NSSTRING_STATUS_NO_ROM_LOADED];
}
}
- (pthread_rwlock_t *) rwlockCoreExecute
@ -735,7 +747,7 @@ volatile bool execute = true;
- (void) generateFirmwareMACAddress
{
[[self cdsFirmware] generateRandomMACAddress];
[self setFirmwareMACAddressSelectionString:NULL];
[self updateFirmwareMACAddressString];
}
- (BOOL) isSlot1Ejected
@ -814,12 +826,12 @@ volatile bool execute = true;
[self setCoreState:ExecutionBehavior_Pause];
pthread_mutex_lock(&threadParam.mutexThreadExecute);
execControl->SetWifiIP4Address([CocoaDSUtil hostIP4AddressAsUInt32]);
execControl->ApplySettingsOnReset();
NDS_Reset();
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
[self updateSlot1DeviceStatus];
[self updateCurrentSessionMACAddressString:YES];
[self setMasterExecute:YES];
[self restoreCoreState];
[[self cdsController] reset];

File diff suppressed because it is too large Load Diff

View File

@ -239,7 +239,7 @@
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore setCdsFirmware:theFirmware];
[cdsCore setFirmwareMACAddressSelectionString:NULL];
[cdsCore updateFirmwareMACAddressString];
[firmwarePanelController setContent:theFirmware];
[cdsFirmware release];
@ -1704,7 +1704,6 @@
[self pauseCore];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore execControl]->SetWifiIP4Address([CocoaDSUtil hostIP4AddressAsUInt32]);
[cdsCore execControl]->ApplySettingsOnReset();
[cdsCore updateSlot1DeviceStatus];
[self writeDefaultsSlot1Settings:nil];
@ -1856,8 +1855,8 @@
[[windowController window] displayIfNeeded];
}
[cdsCore execControl]->SetWifiIP4Address([CocoaDSUtil hostIP4AddressAsUInt32]);
[cdsCore execControl]->ApplySettingsOnReset();
[cdsCore updateCurrentSessionMACAddressString:YES];
[cdsCore setMasterExecute:YES];
// After the ROM loading is complete, send an execute message to the Cocoa DS per
@ -1941,6 +1940,7 @@
}
[cdsCore setSlot1StatusText:NSSTRING_STATUS_EMULATION_NOT_RUNNING];
[cdsCore updateCurrentSessionMACAddressString:NO];
[[cdsCore cdsController] reset];
result = YES;
@ -2292,6 +2292,7 @@
[slot2WindowDelegate setAutoSelectedDeviceText:[[slot2WindowDelegate deviceManager] autoSelectedDeviceName]];
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
[cdsCore updateCurrentSessionMACAddressString:NO];
[screenshotCaptureToolDelegate setSharedData:[[cdsCore cdsGPU] sharedData]];
[avCaptureToolDelegate setSharedData:[[cdsCore cdsGPU] sharedData]];
[self fillOpenGLMSAAMenu];

View File

@ -34,12 +34,10 @@ class ClientExecutionControl;
NSPopUpButton *bridgeDevicePopUpButton;
NSString *firmwareMACAddressString;
NSString *myMACAddress1String;
NSString *myMACAddress2String;
NSString *myMACAddress3String;
NSString *myMACAddress4String;
NSString *currentSessionMACAddressString;
}
@property (assign) ClientExecutionControl *execControl;
@ -48,12 +46,10 @@ class ClientExecutionControl;
@property (assign) NSInteger addressSelection;
@property (assign) NSInteger bridgeDeviceSelection;
@property (assign) NSString *firmwareMACAddressString;
@property (assign) NSString *myMACAddress1String;
@property (assign) NSString *myMACAddress2String;
@property (assign) NSString *myMACAddress3String;
@property (assign) NSString *myMACAddress4String;
@property (assign) NSString *currentSessionMACAddressString;
@property (readonly) IBOutlet NSPopUpButton *bridgeDevicePopUpButton;

View File

@ -34,12 +34,10 @@
@synthesize bridgeDevicePopUpButton;
@synthesize firmwareMACAddressString;
@synthesize myMACAddress1String;
@synthesize myMACAddress2String;
@synthesize myMACAddress3String;
@synthesize myMACAddress4String;
@synthesize currentSessionMACAddressString;
- (id)init
{
@ -56,8 +54,6 @@
const uint8_t myMAC5 = (_myMACAddressValue >> 16) & 0x000000FF;
const uint8_t myMAC6 = (_myMACAddressValue >> 24) & 0x000000F0;
firmwareMACAddressString = @"Firmware 00:09:BF:FF:FF:FF";
currentSessionMACAddressString = @"00:09:BF:FF:FF:FF";
myMACAddress1String = [NSString stringWithFormat:@"My Address #1 00:09:BF:%02X:%02X:%02X", myMAC4, myMAC5, myMAC6 + 1];
myMACAddress2String = [NSString stringWithFormat:@"My Address #2 00:09:BF:%02X:%02X:%02X", myMAC4, myMAC5, myMAC6 + 2];
myMACAddress3String = [NSString stringWithFormat:@"My Address #3 00:09:BF:%02X:%02X:%02X", myMAC4, myMAC5, myMAC6 + 3];