Skip to content

Commit

Permalink
优化摇杆操作逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanheiii committed May 8, 2022
1 parent 15fd376 commit 380a662
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Mageki/Mageki.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="6" android:versionName="1.0.2" package="icu.sanhei.mageki" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="7" android:versionName="1.1.0" package="icu.sanhei.mageki" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="31" />
<application android:label="Mageki" android:theme="@style/MainTheme"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
4 changes: 2 additions & 2 deletions Mageki/Mageki.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<key>CFBundleIdentifier</key>
<string>icu.sanhei.mageki</string>
<key>CFBundleVersion</key>
<string>4</string>
<string>5</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
Expand All @@ -40,6 +40,6 @@
<string>_leboremote._tcp</string>
</array>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.1.0</string>
</dict>
</plist>
17 changes: 13 additions & 4 deletions Mageki/Mageki/Views/ControllerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,19 @@ private void TouchEffect_TouchAction(object sender, TouchActionEventArgs args)
leverCache.Add((pixelLocation.X - touchPoints[args.Id].lastPosition.X, args.Id));
if (idDuplicated)
{
var max = leverCache.Max((a) => MathF.Abs(a.value));
var value = leverCache.Find(a => MathF.Abs(a.value) == max).value;
var currentValue = pixelLocation.X - touchPoints[args.Id].lastPosition.X;
MoveLever(value);
// 计算全部移动的和,并将其限制在最大与最小值之间
var min = leverCache.Select(v => v.value).Min();
var max = leverCache.Select(v => v.value).Max();
var sum = leverCache.Sum(v => v.value);
if (min < 0 && sum < min)
{
sum = min;
}
if (max > 0 && sum > max)
{
sum = max;
}
MoveLever(sum);
leverCache.Clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mageki/Mageki/Views/SettingsPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<ViewCell>
<Grid ColumnDefinitions="Auto,*" Style="{StaticResource ViewCellGridStyle}">
<Label TextColor="LightGray" Text="{x:Static resources:AppResources.Protocol}" VerticalOptions="Center" Margin="16,0,0,0"/>
<Picker x:Name="ProtocolPicker" SelectedIndex="{Binding ProtocolIndex}" ItemsSource="{Binding Protocols}" Grid.Column="1" HorizontalOptions="Fill" Margin="0,0,16,0" VerticalOptions="Center"/>
<Picker x:Name="ProtocolPicker" SelectedIndex="{Binding ProtocolIndex}" ItemsSource="{Binding Protocols}" BackgroundColor="Transparent" TextColor="LightGray" Grid.Column="1" HorizontalOptions="Fill" Margin="0,0,16,0" VerticalOptions="Center"/>
</Grid>
</ViewCell>
</TableSection>
Expand Down

0 comments on commit 380a662

Please sign in to comment.