Revert button config

This commit is contained in:
Stossy11 2025-06-13 10:23:16 +10:00
parent e2e26eed8b
commit 83bf8aecae
3 changed files with 45 additions and 38 deletions

View file

@ -264,7 +264,6 @@ struct ABXYView: View {
struct ButtonView: View { struct ButtonView: View {
var button: VirtualControllerButton var button: VirtualControllerButton
var callback: (() -> Void)? = nil
@AppStorage("onscreenhandheld") var onscreenjoy: Bool = false @AppStorage("onscreenhandheld") var onscreenjoy: Bool = false
@AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0 @AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0
@ -345,29 +344,23 @@ struct ButtonView: View {
} }
private func handleButtonPress() { private func handleButtonPress() {
if let callback { guard !isPressed || istoggle else { return }
callback()
if istoggle {
toggleState.toggle()
isPressed = toggleState
let value = toggleState ? 1 : 0
Ryujinx.shared.virtualController.setButtonState(Uint8(value), for: button)
Haptics.shared.play(.medium)
} else { } else {
guard !isPressed || istoggle else { return } isPressed = true
Ryujinx.shared.virtualController.setButtonState(1, for: button)
if istoggle { Haptics.shared.play(.medium)
toggleState.toggle()
isPressed = toggleState
let value = toggleState ? 1 : 0
Ryujinx.shared.virtualController.setButtonState(Uint8(value), for: button)
Haptics.shared.play(.medium)
} else {
isPressed = true
Ryujinx.shared.virtualController.setButtonState(1, for: button)
Haptics.shared.play(.medium)
}
} }
} }
private func handleButtonRelease() { private func handleButtonRelease() {
if istoggle { return } if istoggle { return }
if let callback { return }
guard isPressed else { return } guard isPressed else { return }
@ -404,23 +397,40 @@ struct ButtonView: View {
// Centralized button configuration // Centralized button configuration
private var buttonConfig: ButtonConfiguration { private var buttonConfig: ButtonConfiguration {
switch button { switch button {
case .A: return .init(iconName: "a.circle.fill") case .A:
case .B: return .init(iconName: "b.circle.fill") return ButtonConfiguration(iconName: "a.circle.fill")
case .X: return .init(iconName: "x.circle.fill") case .B:
case .Y: return .init(iconName: "y.circle.fill") return ButtonConfiguration(iconName: "b.circle.fill")
case .leftStick: return .init(iconName: "l.joystick.press.down.fill") case .X:
case .rightStick: return .init(iconName: "r.joystick.press.down.fill") return ButtonConfiguration(iconName: "x.circle.fill")
case .dPadUp: return .init(iconName: "arrowtriangle.up.circle.fill") case .Y:
case .dPadDown: return .init(iconName: "arrowtriangle.down.circle.fill") return ButtonConfiguration(iconName: "y.circle.fill")
case .dPadLeft: return .init(iconName: "arrowtriangle.left.circle.fill") case .leftStick:
case .dPadRight: return .init(iconName: "arrowtriangle.right.circle.fill") return ButtonConfiguration(iconName: "l.joystick.press.down.fill")
case .leftTrigger: return .init(iconName: "zl.rectangle.roundedtop.fill") case .rightStick:
case .rightTrigger: return .init(iconName: "zr.rectangle.roundedtop.fill") return ButtonConfiguration(iconName: "r.joystick.press.down.fill")
case .leftShoulder: return .init(iconName: "l.rectangle.roundedbottom.fill") case .dPadUp:
case .rightShoulder: return .init(iconName: "r.rectangle.roundedbottom.fill") return ButtonConfiguration(iconName: "arrowtriangle.up.circle.fill")
case .start: return .init(iconName: "plus.circle.fill") case .dPadDown:
case .back: return .init(iconName: "minus.circle.fill") return ButtonConfiguration(iconName: "arrowtriangle.down.circle.fill")
case .guide: return .init(iconName: "gearshape.fill") case .dPadLeft:
return ButtonConfiguration(iconName: "arrowtriangle.left.circle.fill")
case .dPadRight:
return ButtonConfiguration(iconName: "arrowtriangle.right.circle.fill")
case .leftTrigger:
return ButtonConfiguration(iconName: "zl.rectangle.roundedtop.fill")
case .rightTrigger:
return ButtonConfiguration(iconName: "zr.rectangle.roundedtop.fill")
case .leftShoulder:
return ButtonConfiguration(iconName: "l.rectangle.roundedbottom.fill")
case .rightShoulder:
return ButtonConfiguration(iconName: "r.rectangle.roundedbottom.fill")
case .start:
return ButtonConfiguration(iconName: "plus.circle.fill")
case .back:
return ButtonConfiguration(iconName: "minus.circle.fill")
case .guide:
return ButtonConfiguration(iconName: "house.circle.fill")
} }
} }

View file

@ -1129,9 +1129,6 @@ struct SettingsViewNew: View {
Divider() Divider()
SettingsToggle(isOn: config.backendMultithreading, icon: "inset.filled.rectangle.and.person.filled", label: "Backend Multithreading")
Divider()
if MTLHud.shared.canMetalHud { if MTLHud.shared.canMetalHud {
SettingsToggle(isOn: $metalHudEnabler.metalHudEnabled, icon: "speedometer", label: "Metal Performance HUD") SettingsToggle(isOn: $metalHudEnabler.metalHudEnabled, icon: "speedometer", label: "Metal Performance HUD")