Skip to content

Commit

Permalink
更新至scrcpy2.4
Browse files Browse the repository at this point in the history
增加退出时锁屏
启用UHID特性优化中文输入体验
  • Loading branch information
pdone committed Mar 21, 2024
1 parent 6ce3688 commit 2e45b42
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 24 deletions.
2 changes: 1 addition & 1 deletion FreeControl/FreeControl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
</EmbeddedResource>
<EmbeddedResource Include="SetProt.bat" />
<None Include="packages.config" />
<None Include="Resources\scrcpy-win64-v2.3.1.zip" />
<None Include="Resources\scrcpy-win64-v2.4.zip" />
<None Include="Update.en.md" />
<None Include="Update.md" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion FreeControl/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 27 additions & 14 deletions FreeControl/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public partial class Main : UIForm
/// <summary>
/// scrcpy版本
/// </summary>
public static readonly string ScrcpyVersion = "scrcpy-win64-v2.3.1";
public static readonly string ScrcpyVersion = "scrcpy-win64-v2.4";
/// <summary>
/// scrcpy路径
/// </summary>
Expand Down Expand Up @@ -266,6 +266,10 @@ public void InitPdone()
cbxShowTouches.ValueChanged += CommonCbx_ValueChanged;
cbxReadOnly.ValueChanged += CommonCbx_ValueChanged;
cbxAudioEnabled.ValueChanged += cbxAudioEnabled_ValueChanged;

uiLabel4.DoubleClick += (sender, e) => Process.Start(Logger.path);
uiLabel3.DoubleClick += (sender, e) => Process.Start(UserDataPath);

#endregion

#region 设置标题和图标
Expand Down Expand Up @@ -338,7 +342,7 @@ private void ExtractResource(bool reload = false)
if (!Directory.Exists(ScrcpyPath))
{
Directory.CreateDirectory(ScrcpyPath);
File.WriteAllBytes(ScrcpyPath + tempFileName, Properties.Resources.scrcpy_win64_v2_3_1);
File.WriteAllBytes(ScrcpyPath + tempFileName, Properties.Resources.scrcpy_win64_v2_4);
// 解压缩
ZipFile.ExtractToDirectory(ScrcpyPath + tempFileName, UserDataPath);
// 解压完成删除压缩包
Expand Down Expand Up @@ -404,10 +408,9 @@ private void StartButtonClick(object sender, EventArgs e)
}
// 设置标题
StartParameters.Add($"--window-title \"{Info.ScrcpyTitle}\"");
// 设置为文本注入
StartParameters.Add($"--prefer-text");
// 设置为按键注入
// StartParameters.Add($"--raw-key-events");
// 设置断开后锁定屏幕
StartParameters.Add("--power-off-on-close");
StartParameters.Add(_Setting.CustomArgs);
if (_Setting.AudioEnabled == false) StartParameters.Add(_Setting.GetDesc("AudioEnabled"));// 不转发音频

// 其他参数
Expand Down Expand Up @@ -514,14 +517,8 @@ private void RunScrcpy()
}
}
};
scrcpy.ErrorDataReceived += (ss, ee) =>
{
if (ee.Data.IsNotNull())
{
Logger.Info($"{ee.Data}", "scrcpy");
}
};
scrcpy.Exited += (ss, ee) =>

void exitHandle()
{
SetUserData(_Setting);// 关闭scrcpy后保存一下配置文件
if (_Setting.EnableSwitchIME && _Setting.IME != 0 && _Setting.IMEOrigin.IsNotNull())
Expand All @@ -533,7 +530,20 @@ private void RunScrcpy()
ButtonHandle(false);
LoadHistoryIPs(true);
ShowMessage(I18n.msgExit);
}

scrcpy.ErrorDataReceived += (ss, ee) =>
{
if (ee.Data.IsNotNull())
{
Logger.Info($"{ee.Data}", "scrcpy");
if (ee.Data.Contains("ERROR"))
{
exitHandle();
}
}
};
scrcpy.Exited += (ss, ee) => exitHandle();
scrcpy.BeginErrorReadLine();
scrcpy.BeginOutputReadLine();

Expand Down Expand Up @@ -767,6 +777,9 @@ private void ComboMbps_SelectedValueChanged(object sender, EventArgs e)
case 5:
_Setting.BitRate = "-b 4M";
break;
case 6:
_Setting.BitRate = "-b 1M";
break;
default:
_Setting.BitRate = "";
break;
Expand Down
7 changes: 5 additions & 2 deletions FreeControl/Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAF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wH/A78B/wNdAc8DKQE+A1EBnAOAAf4DMQFNIAADHgEqA10B3wMaAf8DWwHQAxgBICQA
AzkBXgNJAfYDGgH/A1UBrzAAAx4BKgNdAd8DvwH/A18B0AMYASAkAAM5AV4DYgH2A78B/wNVAa8kAAMc
AScDSQH2AxoB/wMaAf8DXwHaA10ByQNgAfMDGgH/AxwBJxwAA10B3AMaAf8DYQHrA1sBzQNeAfsDGgH/
Expand Down Expand Up @@ -827,6 +827,9 @@
<data name="comboMbps.Items5" xml:space="preserve">
<value>4Mbps</value>
</data>
<data name="comboMbps.Items6" xml:space="preserve">
<value>1Mbps</value>
</data>
<data name="comboMbps.Location" type="System.Drawing.Point, System.Drawing">
<value>496, 50</value>
</data>
Expand Down
4 changes: 2 additions & 2 deletions FreeControl/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.6.9")]
[assembly: AssemblyVersion("1.6.9")]
[assembly: AssemblyFileVersion("1.7.0")]
[assembly: AssemblyVersion("1.7.0")]
4 changes: 2 additions & 2 deletions FreeControl/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions FreeControl/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
<data name="pcm" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pcm.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="scrcpy_win64_v2_3_1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrcpy-win64-v2.3.1.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<data name="scrcpy_win64_v2_4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\scrcpy-win64-v2.4.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="shortcut_en" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\shortcut_en.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand Down
Binary file modified FreeControl/Resources/en.FreeControl.resources.dll
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions FreeControl/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,15 @@ public List<string> ControllerButton
/// 心跳间隔 单位:毫秒
/// </summary>
public int Heartbeat { get; set; } = 60000;

/// <summary>
/// 退出时锁屏
/// </summary>
public bool PowerOffOnClose { get; set; } = true;

/// <summary>
/// 自定义参数
/// </summary>
public string CustomArgs { get; set; } = "--keyboard=uhid";
}
}

0 comments on commit 2e45b42

Please sign in to comment.