-
-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
127 additions
and
82 deletions.
There are no files selected for viewing
115 changes: 115 additions & 0 deletions
115
src/apps/SettingsWindow/src/View/DevicesGamePadSettingsView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import SwiftUI | ||
|
||
struct DevicesGamePadSettingsView: View { | ||
@Binding var connectedDeviceSetting: LibKrbn.ConnectedDeviceSetting | ||
@Binding var showing: Bool | ||
|
||
var body: some View { | ||
ZStack(alignment: .topLeading) { | ||
VStack(alignment: .leading, spacing: 12.0) { | ||
Text( | ||
"\(connectedDeviceSetting.connectedDevice.productName) (\(connectedDeviceSetting.connectedDevice.manufacturerName))" | ||
) | ||
.padding(.leading, 40) | ||
.padding(.top, 20) | ||
|
||
GroupBox(label: Text("Deadzone")) { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
Toggle(isOn: $connectedDeviceSetting.gamePadOverwriteXYStickDeadzone) { | ||
Text("Overwrite XY stick deadzone: ") | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.switchToggleStyle(controlSize: .mini, font: .callout) | ||
.frame(width: 250.0) | ||
|
||
HStack(alignment: .center, spacing: 0) { | ||
Text("Deadzone:") | ||
|
||
DoubleTextField( | ||
value: $connectedDeviceSetting.gamePadXYStickDeadzone, | ||
range: 0.05...1, | ||
step: 0.01, | ||
width: 40) | ||
|
||
Text("(Default: 0.1)") | ||
} | ||
.padding(.leading, 20) | ||
.disabled(!connectedDeviceSetting.gamePadOverwriteXYStickDeadzone) | ||
|
||
Spacer() | ||
} | ||
|
||
HStack { | ||
Toggle(isOn: $connectedDeviceSetting.gamePadOverwriteWheelsStickDeadzone) { | ||
Text("Overwrite Wheels stick deadzone: ") | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.switchToggleStyle(controlSize: .mini, font: .callout) | ||
.frame(width: 250.0) | ||
|
||
HStack(alignment: .center, spacing: 0) { | ||
Text("Deadzone:") | ||
|
||
DoubleTextField( | ||
value: $connectedDeviceSetting.gamePadWheelsStickDeadzone, | ||
range: 0.05...1, | ||
step: 0.01, | ||
width: 40) | ||
|
||
Text("(Default: 0.1)") | ||
} | ||
.padding(.leading, 20) | ||
.disabled(!connectedDeviceSetting.gamePadOverwriteWheelsStickDeadzone) | ||
} | ||
}.padding() | ||
} | ||
|
||
VStack(alignment: .leading, spacing: 2.0) { | ||
Toggle(isOn: $connectedDeviceSetting.gamePadSwapSticks) { | ||
Text("Swap gamepad XY and wheels sticks") | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
} | ||
.switchToggleStyle(controlSize: .mini, font: .callout) | ||
} | ||
.frame(width: 240.0) | ||
|
||
Spacer() | ||
} | ||
|
||
SheetCloseButton { | ||
showing = false | ||
} | ||
} | ||
.padding() | ||
.frame(width: 1000, height: 600) | ||
} | ||
} | ||
|
||
struct DevicesGamePadSettingsView_Previews: PreviewProvider { | ||
@State static var connectedDeviceSetting = LibKrbn.ConnectedDeviceSetting( | ||
LibKrbn.ConnectedDevice( | ||
index: 0, | ||
manufacturerName: "", | ||
productName: "", | ||
transport: "", | ||
vendorId: 0, | ||
productId: 0, | ||
deviceAddress: nil, | ||
isKeyboard: false, | ||
isPointingDevice: false, | ||
isGamePad: true, | ||
isBuiltInKeyboard: false, | ||
isBuiltInTrackpad: false, | ||
isBuiltInTouchBar: false, | ||
isAppleDevice: false | ||
) | ||
) | ||
@State static var showing = true | ||
|
||
static var previews: some View { | ||
DevicesGamePadSettingsView( | ||
connectedDeviceSetting: $connectedDeviceSetting, | ||
showing: $showing) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters