Fix joypads for multiple players

This commit is contained in:
Michael Buckley 2020-01-15 20:23:05 -08:00
parent e7c47ef25d
commit 3b5f04a5d1
2 changed files with 10 additions and 6 deletions

View File

@ -140,6 +140,8 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
[self setButtonCode:buttonCode forKeyCode:self.keys[control].integerValue player:player]; [self setButtonCode:buttonCode forKeyCode:self.keys[control].integerValue player:player];
} }
NSDictionary *joypadPlayerPrefs = [defaults objectForKey:kJoypadPlayerPrefs];
for ( S9xJoypad *joypad in [self listJoypads]) for ( S9xJoypad *joypad in [self listJoypads])
{ {
NSMutableDictionary *joypadPrefs = [[defaults objectForKey:kJoypadInputPrefs] mutableCopy]; NSMutableDictionary *joypadPrefs = [[defaults objectForKey:kJoypadInputPrefs] mutableCopy];
@ -152,6 +154,14 @@ static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
NSString *key = [self prefsKeyForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index]; NSString *key = [self prefsKeyForVendorID:joypad.vendorID productID:joypad.productID index:joypad.index];
for ( NSString *playerString in joypadPlayerPrefs )
{
if ( [key isEqualToString:joypadPlayerPrefs[playerString]] )
{
[self setPlayer:playerString.intValue forVendorID:joypad.vendorID productID:joypad.productID index:joypad.index];
}
}
NSMutableDictionary *devicePrefs = [joypadPrefs[key] mutableCopy]; NSMutableDictionary *devicePrefs = [joypadPrefs[key] mutableCopy];
if (devicePrefs == nil) if (devicePrefs == nil)
{ {

View File

@ -753,12 +753,6 @@ void SetUpHID (void)
{ {
AddDevice((__bridge IOHIDDeviceRef)device); AddDevice((__bridge IOHIDDeviceRef)device);
} }
if (orderedDevices.count == 1)
{
const struct JoypadDevice &deviceStruct = *(allDevices.begin());
SetPlayerForJoypad(0, deviceStruct.vendorID, deviceStruct.productID, deviceStruct.index, NULL);
}
} }
else else
{ {