forked from MeloNX/MeloNX
更新 src/MeloNX/MeloNX/App/Views/Main/ControllerView/ControllerView.swift
This commit is contained in:
parent
fd4bc5ccbb
commit
ff4b59730a
@ -30,7 +30,7 @@ struct ControllerView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
ShoulderButtonsViewRight()
|
ShoulderButtonsViewRight()
|
||||||
ZStack {
|
ZStack {
|
||||||
Joystick(iscool: true) // hope this works
|
Joystick(iscool: true) // hope this works JoyStick
|
||||||
ABXYView()
|
ABXYView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ struct ControllerView: View {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// could be landscape
|
// could be landscape
|
||||||
VStack {
|
/*VStack {
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
VStack {
|
VStack {
|
||||||
@ -57,8 +57,9 @@ struct ControllerView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
ShoulderButtonsViewLeft()
|
ShoulderButtonsViewLeft()
|
||||||
ZStack {
|
ZStack {
|
||||||
Joystick()
|
//Joystick()
|
||||||
DPadView()
|
Joystick4FTG()
|
||||||
|
//DPadView() Disable landscape Dpad
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HStack {
|
HStack {
|
||||||
@ -77,7 +78,7 @@ struct ControllerView: View {
|
|||||||
VStack {
|
VStack {
|
||||||
ShoulderButtonsViewRight()
|
ShoulderButtonsViewRight()
|
||||||
ZStack {
|
ZStack {
|
||||||
Joystick(iscool: true) // hope this work s
|
//Joystick(iscool: true) // hope this work Disable right Joystick
|
||||||
ABXYView()
|
ABXYView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,6 +86,35 @@ struct ControllerView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// .padding(.bottom, geometry.size.height / 11) // also extremally broken (
|
// .padding(.bottom, geometry.size.height / 11) // also extremally broken (
|
||||||
|
}*/
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
Spacer() // 占据顶部空间
|
||||||
|
HStack(alignment: .bottom) {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
//ShoulderButtonsViewLeft()
|
||||||
|
Joystick4FTG() // 摇杆控件
|
||||||
|
//.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
.offset(x: 10, y: -5) // 向右移动(+) ,向上移动(﹣)
|
||||||
|
HStack {
|
||||||
|
VStack {
|
||||||
|
ButtonView(button: .back) // - 按钮
|
||||||
|
}
|
||||||
|
Spacer()
|
||||||
|
VStack {
|
||||||
|
ButtonView(button: .start) // + 按钮
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VStack {
|
||||||
|
ShoulderButtonsViewRight()
|
||||||
|
ZStack {
|
||||||
|
ABXYView()
|
||||||
|
}
|
||||||
|
}.offset(x: 30, y: 25) // 向右移动 50,向下移动 25
|
||||||
|
}
|
||||||
|
.padding(.bottom, 10) // 适当增加 padding 让它靠近底部
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,10 +129,11 @@ struct ShoulderButtonsViewLeft: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack {
|
HStack {
|
||||||
ButtonView(button: .leftTrigger)
|
//move left Trigger
|
||||||
.padding(.horizontal)
|
// ButtonView(button: .leftTrigger)
|
||||||
ButtonView(button: .leftShoulder)
|
// .padding(.horizontal)
|
||||||
.padding(.horizontal)
|
//ButtonView(button: .leftShoulder)
|
||||||
|
// .padding(.horizontal)
|
||||||
}
|
}
|
||||||
.frame(width: width, height: height)
|
.frame(width: width, height: height)
|
||||||
.onAppear() {
|
.onAppear() {
|
||||||
@ -118,8 +149,8 @@ struct ShoulderButtonsViewLeft: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct ShoulderButtonsViewRight: View {
|
struct ShoulderButtonsViewRight: View {
|
||||||
@State var width: CGFloat = 160
|
@State var width: CGFloat = 100
|
||||||
@State var height: CGFloat = 20
|
@State var height: CGFloat = 60
|
||||||
@AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0
|
@AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
@ -128,6 +159,15 @@ struct ShoulderButtonsViewRight: View {
|
|||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
ButtonView(button: .rightTrigger)
|
ButtonView(button: .rightTrigger)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
|
|
||||||
|
}
|
||||||
|
HStack{
|
||||||
|
//put left Trigger there
|
||||||
|
ButtonView(button: .leftTrigger)
|
||||||
|
.padding(.horizontal)
|
||||||
|
ButtonView(button: .leftShoulder)
|
||||||
|
.padding(.horizontal)
|
||||||
|
|
||||||
}
|
}
|
||||||
.frame(width: width, height: height)
|
.frame(width: width, height: height)
|
||||||
.onAppear() {
|
.onAppear() {
|
||||||
@ -171,7 +211,7 @@ struct ABXYView: View {
|
|||||||
@State var size: CGFloat = 145
|
@State var size: CGFloat = 145
|
||||||
@AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0
|
@AppStorage("On-ScreenControllerScale") var controllerScale: Double = 1.0
|
||||||
|
|
||||||
var body: some View {
|
/*var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
ButtonView(button: .X)
|
ButtonView(button: .X)
|
||||||
HStack {
|
HStack {
|
||||||
@ -182,6 +222,21 @@ struct ABXYView: View {
|
|||||||
ButtonView(button: .B)
|
ButtonView(button: .B)
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
//拳皇新布局
|
||||||
|
var body: some View {
|
||||||
|
VStack(spacing: 5){
|
||||||
|
HStack(spacing: 5) {
|
||||||
|
ButtonView(button: .Y)
|
||||||
|
ButtonView(button: .B)
|
||||||
|
|
||||||
|
}
|
||||||
|
HStack(spacing: 5) {
|
||||||
|
ButtonView(button: .X)
|
||||||
|
ButtonView(button: .A)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
.frame(width: size, height: size)
|
.frame(width: size, height: size)
|
||||||
.onAppear() {
|
.onAppear() {
|
||||||
if UIDevice.current.systemName.contains("iPadOS") {
|
if UIDevice.current.systemName.contains("iPadOS") {
|
||||||
@ -195,8 +250,8 @@ struct ABXYView: View {
|
|||||||
|
|
||||||
struct ButtonView: View {
|
struct ButtonView: View {
|
||||||
var button: VirtualControllerButton
|
var button: VirtualControllerButton
|
||||||
@State var width: CGFloat = 45
|
@State var width: CGFloat = 90
|
||||||
@State var height: CGFloat = 45
|
@State var height: CGFloat = 90
|
||||||
@State var isPressed = false
|
@State var isPressed = false
|
||||||
@AppStorage("onscreenhandheld") var onscreenjoy: Bool = false
|
@AppStorage("onscreenhandheld") var onscreenjoy: Bool = false
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
@ -210,14 +265,14 @@ struct ButtonView: View {
|
|||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: width, height: height)
|
.frame(width: width, height: height)
|
||||||
.foregroundColor(colorScheme == .dark ? Color.gray : Color.gray)
|
.foregroundColor(colorScheme == .dark ? Color.gray : Color.gray)
|
||||||
.opacity(isPressed ? 0.4 : 0.7)
|
.opacity(isPressed ? 0.3 : 0.6)
|
||||||
.gesture(
|
.gesture(
|
||||||
DragGesture(minimumDistance: 0)
|
DragGesture(minimumDistance: 0)
|
||||||
.onChanged { _ in
|
.onChanged { _ in
|
||||||
if !self.isPressed {
|
if !self.isPressed {
|
||||||
self.isPressed = true
|
self.isPressed = true
|
||||||
Ryujinx.shared.virtualController.setButtonState(1, for: button)
|
Ryujinx.shared.virtualController.setButtonState(1, for: button)
|
||||||
Haptics.shared.play(.heavy)
|
Haptics.shared.play(.light)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onEnded { _ in
|
.onEnded { _ in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user