mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 08:59:40 +00:00
Improved DualSense LEDs, fix several analog controls issues
This commit is contained in:
parent
e71d3a7d3c
commit
7a6ae2d951
@ -260,6 +260,7 @@ static const uint8_t workboy_vk_to_key[] = {
|
||||
- (void) flip
|
||||
{
|
||||
if (analogClockMultiplierValid && [[NSUserDefaults standardUserDefaults] boolForKey:@"GBAnalogControls"]) {
|
||||
clockMultiplier = 1.0;
|
||||
GB_set_clock_multiplier(_gb, analogClockMultiplier);
|
||||
if (self.document.partner) {
|
||||
GB_set_clock_multiplier(self.document.partner.gb, analogClockMultiplier);
|
||||
@ -290,10 +291,12 @@ static const uint8_t workboy_vk_to_key[] = {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (clockMultiplier > 1 || _turbo || (analogClockMultiplierValid && analogClockMultiplier > 1)) {
|
||||
if ((!analogClockMultiplierValid && clockMultiplier > 1) ||
|
||||
_turbo || (analogClockMultiplierValid && analogClockMultiplier > 1)) {
|
||||
[self.osdView displayText:@"Fast forwarding..."];
|
||||
}
|
||||
else if (clockMultiplier < 1 || (analogClockMultiplierValid && analogClockMultiplier < 1)) {
|
||||
else if ((!analogClockMultiplierValid && clockMultiplier < 1) ||
|
||||
(analogClockMultiplierValid && analogClockMultiplier < 1)) {
|
||||
[self.osdView displayText:@"Slow motion..."];
|
||||
}
|
||||
current_buffer = (current_buffer + 1) % self.numberOfBuffers;
|
||||
@ -499,7 +502,7 @@ static const uint8_t workboy_vk_to_key[] = {
|
||||
continue;
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[controller setPlayerLEDs:1 << player];
|
||||
[controller setPlayerLEDs:[controller LEDMaskForPlayer:player]];
|
||||
});
|
||||
NSDictionary *mapping = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"JoyKitInstanceMapping"][controller.uniqueID];
|
||||
if (!mapping) {
|
||||
@ -558,13 +561,14 @@ static const uint8_t workboy_vk_to_key[] = {
|
||||
case JOYButtonUsageL1: {
|
||||
if (!analogClockMultiplierValid || analogClockMultiplier == 1.0 || !button.isPressed) {
|
||||
if (self.document.isSlave) {
|
||||
GB_set_turbo_mode(self.document.partner.gb, button.isPressed, false); break;
|
||||
GB_set_turbo_mode(self.document.partner.gb, button.isPressed, false);
|
||||
}
|
||||
else {
|
||||
GB_set_turbo_mode(_gb, button.isPressed, button.isPressed && self.isRewinding); break;
|
||||
GB_set_turbo_mode(_gb, button.isPressed, button.isPressed && self.isRewinding);
|
||||
}
|
||||
_turbo = button.isPressed;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case JOYButtonUsageR1: underclockKeyDown = button.isPressed; break;
|
||||
|
@ -35,6 +35,7 @@ static NSString const *JOYHatsEmulateButtonsKey = @"JOYHatsEmulateButtons";
|
||||
- (NSArray<JOYHat *> *) hats;
|
||||
- (void)setRumbleAmplitude:(double)amp;
|
||||
- (void)setPlayerLEDs:(uint8_t)mask;
|
||||
- (uint8_t)LEDMaskForPlayer:(unsigned)player;
|
||||
@property (readonly, getter=isConnected) bool connected;
|
||||
@end
|
||||
|
||||
|
@ -850,9 +850,25 @@ typedef union {
|
||||
[self sendReport:[NSData dataWithBytes:&_lastVendorSpecificOutput.dualsenseOutput length:sizeof(_lastVendorSpecificOutput.dualsenseOutput)]];
|
||||
}
|
||||
|
||||
- (uint8_t)LEDMaskForPlayer:(unsigned)player
|
||||
{
|
||||
if (_isDualShock3) {
|
||||
return 2 << player;
|
||||
}
|
||||
if (_isUSBDualSense) {
|
||||
switch (player) {
|
||||
case 0: return 0x04;
|
||||
case 1: return 0x0A;
|
||||
case 2: return 0x15;
|
||||
case 3: return 0x1B;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
return 1 << player;
|
||||
}
|
||||
|
||||
- (void)setPlayerLEDs:(uint8_t)mask
|
||||
{
|
||||
mask &= 0xF;
|
||||
if (mask == _playerLEDs) {
|
||||
return;
|
||||
}
|
||||
@ -862,16 +878,16 @@ typedef union {
|
||||
_lastVendorSpecificOutput.switchPacket.sequence++;
|
||||
_lastVendorSpecificOutput.switchPacket.sequence &= 0xF;
|
||||
_lastVendorSpecificOutput.switchPacket.command = 0x30; // LED
|
||||
_lastVendorSpecificOutput.switchPacket.commandData[0] = mask;
|
||||
_lastVendorSpecificOutput.switchPacket.commandData[0] = mask & 0xF;
|
||||
[self sendReport:[NSData dataWithBytes:&_lastVendorSpecificOutput.switchPacket length:sizeof(_lastVendorSpecificOutput.switchPacket)]];
|
||||
}
|
||||
else if (_isDualShock3) {
|
||||
_lastVendorSpecificOutput.ds3Output.reportID = 1;
|
||||
_lastVendorSpecificOutput.ds3Output.ledsEnabled = mask << 1;
|
||||
_lastVendorSpecificOutput.ds3Output.ledsEnabled = (mask & 0x1F);
|
||||
[self sendReport:[NSData dataWithBytes:&_lastVendorSpecificOutput.ds3Output length:sizeof(_lastVendorSpecificOutput.ds3Output)]];
|
||||
}
|
||||
else if (_isDualSense) {
|
||||
_lastVendorSpecificOutput.dualsenseOutput.playerLEDs = mask;
|
||||
_lastVendorSpecificOutput.dualsenseOutput.playerLEDs = mask & 0x1F;
|
||||
[self sendDualSenseOutput];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user