This commit is contained in:
mika-n 2019-12-28 14:59:56 +02:00
commit eaae76b48e
9 changed files with 79 additions and 41 deletions

View File

@ -1,17 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Media;
using System.Threading.Tasks; using System.Threading.Tasks;
using static DS4Windows.Global;
using System.Threading; using System.Threading;
using System.Diagnostics; using System.Diagnostics;
using static DS4Windows.Global;
using Nefarius.ViGEm.Client; using Nefarius.ViGEm.Client;
using Nefarius.ViGEm.Client.Targets;
using Nefarius.ViGEm.Client.Targets.Xbox360;
using Nefarius.ViGEm.Client.Targets.DualShock4;
namespace DS4Windows namespace DS4Windows
{ {
@ -40,6 +34,7 @@ namespace DS4Windows
}; };
*/ */
Thread tempThread; Thread tempThread;
Thread tempBusThread;
public List<string> affectedDevs = new List<string>() public List<string> affectedDevs = new List<string>()
{ {
@"HID\VID_054C&PID_05C4", @"HID\VID_054C&PID_05C4",
@ -154,7 +149,7 @@ namespace DS4Windows
//sp.Stream = DS4WinWPF.Properties.Resources.EE; //sp.Stream = DS4WinWPF.Properties.Resources.EE;
// Cause thread affinity to not be tied to main GUI thread // Cause thread affinity to not be tied to main GUI thread
tempThread = new Thread(() => { tempBusThread = new Thread(() => {
//_udpServer = new UdpServer(GetPadDetailForIdx); //_udpServer = new UdpServer(GetPadDetailForIdx);
busThrRunning = true; busThrRunning = true;
@ -174,9 +169,9 @@ namespace DS4Windows
Monitor.Wait(busThrLck); Monitor.Wait(busThrLck);
} }
}); });
tempThread.Priority = ThreadPriority.Normal; tempBusThread.Priority = ThreadPriority.Normal;
tempThread.IsBackground = true; tempBusThread.IsBackground = true;
tempThread.Start(); tempBusThread.Start();
//while (_udpServer == null) //while (_udpServer == null)
//{ //{
// Thread.SpinWait(500); // Thread.SpinWait(500);
@ -353,17 +348,12 @@ namespace DS4Windows
{ {
Thread.SpinWait(500); Thread.SpinWait(500);
} }
tempThread = null;
} }
private void stopViGEm() private void stopViGEm()
{ {
if (tempThread != null)
{
tempThread.Interrupt();
tempThread.Join();
tempThread = null;
}
if (vigemTestClient != null) if (vigemTestClient != null)
{ {
vigemTestClient.Dispose(); vigemTestClient.Dispose();

View File

@ -47,9 +47,8 @@ Scan Code: Keys are interpreted differently. May be needed for certain games
</StackPanel> </StackPanel>
<Label Content="Translators:" Margin="0,20,0,0" /> <Label Content="Translators:" Margin="0,20,0,0" />
</StackPanel> </StackPanel>
<TextBox DockPanel.Dock="Bottom" VerticalScrollBarVisibility="Auto" Margin="10,0,10,10"> <TextBox TextWrapping="Wrap" xml:space="preserve" IsReadOnly="True"
DockPanel.Dock="Bottom" VerticalScrollBarVisibility="Auto" Margin="10,0,10,10">Ryochan7 - Japanese</TextBox>
</TextBox>
</DockPanel> </DockPanel>
</TabItem> </TabItem>
<TabItem Header="Tip"> <TabItem Header="Tip">

View File

@ -252,6 +252,7 @@ Properties.Resources.DS4Update, MessageBoxButton.YesNo, MessageBoxImage.Question
trayIconVM.ProfileSelected += TrayIconVM_ProfileSelected; trayIconVM.ProfileSelected += TrayIconVM_ProfileSelected;
trayIconVM.RequestMinimize += TrayIconVM_RequestMinimize; trayIconVM.RequestMinimize += TrayIconVM_RequestMinimize;
trayIconVM.RequestOpen += TrayIconVM_RequestOpen; trayIconVM.RequestOpen += TrayIconVM_RequestOpen;
trayIconVM.RequestServiceChange += TrayIconVM_RequestServiceChange;
autoProfControl.AutoDebugChanged += AutoProfControl_AutoDebugChanged; autoProfControl.AutoDebugChanged += AutoProfControl_AutoDebugChanged;
autoprofileChecker.RequestServiceChange += AutoprofileChecker_RequestServiceChange; autoprofileChecker.RequestServiceChange += AutoprofileChecker_RequestServiceChange;
autoProfileHolder.AutoProfileColl.CollectionChanged += AutoProfileColl_CollectionChanged; autoProfileHolder.AutoProfileColl.CollectionChanged += AutoProfileColl_CollectionChanged;
@ -287,6 +288,11 @@ Suspend support not enabled.", true);
} }
} }
private void TrayIconVM_RequestServiceChange(object sender, EventArgs e)
{
ChangeService();
}
private void LogItems_CollectionChanged(object sender, private void LogItems_CollectionChanged(object sender,
System.Collections.Specialized.NotifyCollectionChangedEventArgs e) System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{ {

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Threading; using System.Threading;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using DS4Windows; using DS4Windows;
@ -15,6 +17,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public const string ballonTitle = "DS4Windows"; public const string ballonTitle = "DS4Windows";
public static string trayTitle = $"DS4Windows v{Global.exeversion}"; public static string trayTitle = $"DS4Windows v{Global.exeversion}";
private ContextMenu contextMenu; private ContextMenu contextMenu;
private MenuItem changeServiceItem;
public string TooltipText { get => tooltipText; public string TooltipText { get => tooltipText;
set set
@ -43,6 +46,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
public event EventHandler RequestShutdown; public event EventHandler RequestShutdown;
public event EventHandler RequestOpen; public event EventHandler RequestOpen;
public event EventHandler RequestMinimize; public event EventHandler RequestMinimize;
public event EventHandler RequestServiceChange;
private ReaderWriterLockSlim _colLocker = new ReaderWriterLockSlim(); private ReaderWriterLockSlim _colLocker = new ReaderWriterLockSlim();
private List<ControllerHolder> controllerList = new List<ControllerHolder>(); private List<ControllerHolder> controllerList = new List<ControllerHolder>();
@ -59,8 +63,11 @@ namespace DS4WinWPF.DS4Forms.ViewModels
this.profileListHolder = profileListHolder; this.profileListHolder = profileListHolder;
this.controlService = service; this.controlService = service;
contextMenu = new ContextMenu(); contextMenu = new ContextMenu();
iconSource = Global.UseWhiteIcon ? "/DS4Windows;component/Resources/DS4W - White.ico" : iconSource = Global.UseWhiteIcon ? ICON_WHITE : ICON_COLOR;
"/DS4Windows;component/Resources/DS4W.ico"; changeServiceItem = new MenuItem() { Header = "Start",
FontWeight = FontWeights.Bold };
changeServiceItem.Click += ChangeControlServiceItem_Click;
changeServiceItem.IsEnabled = false;
PopulateControllerList(); PopulateControllerList();
PopulateToolText(); PopulateToolText();
@ -74,6 +81,7 @@ namespace DS4WinWPF.DS4Forms.ViewModels
service.PreServiceStop += ClearToolText; service.PreServiceStop += ClearToolText;
service.PreServiceStop += UnhookEvents; service.PreServiceStop += UnhookEvents;
service.PreServiceStop += ClearControllerList; service.PreServiceStop += ClearControllerList;
service.RunningChanged += Service_RunningChanged;
service.HotplugController += Service_HotplugController; service.HotplugController += Service_HotplugController;
/*tester.StartControllers += HookBatteryUpdate; /*tester.StartControllers += HookBatteryUpdate;
tester.StartControllers += StartPopulateText; tester.StartControllers += StartPopulateText;
@ -83,6 +91,16 @@ namespace DS4WinWPF.DS4Forms.ViewModels
*/ */
} }
private void Service_RunningChanged(object sender, EventArgs e)
{
string temp = controlService.running ? "Stop" : "Start";
App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
changeServiceItem.Header = temp;
changeServiceItem.IsEnabled = true;
}));
}
private void ClearControllerList(object sender, EventArgs e) private void ClearControllerList(object sender, EventArgs e)
{ {
_colLocker.EnterWriteLock(); _colLocker.EnterWriteLock();
@ -173,18 +191,34 @@ namespace DS4WinWPF.DS4Forms.ViewModels
items.Add(item); items.Add(item);
items.Add(new Separator()); items.Add(new Separator());
item = changeServiceItem;
items.Add(item);
item = new MenuItem() { Header = "Open" }; item = new MenuItem() { Header = "Open" };
item.Click += OpenMenuItem_Click; item.Click += OpenMenuItem_Click;
items.Add(item); items.Add(item);
item = new MenuItem() { Header = "Minimize" }; item = new MenuItem() { Header = "Minimize" };
item.Click += MinimizeMenuItem_Click; item.Click += MinimizeMenuItem_Click;
items.Add(item); items.Add(item);
item = new MenuItem() { Header = "Open Program Folder" };
item.Click += OpenProgramFolderItem_Click;
items.Add(item);
items.Add(new Separator()); items.Add(new Separator());
item = new MenuItem() { Header = "Exit (Middle Mouse)" }; item = new MenuItem() { Header = "Exit (Middle Mouse)" };
item.Click += ExitMenuItem_Click; item.Click += ExitMenuItem_Click;
items.Add(item); items.Add(item);
} }
private void ChangeControlServiceItem_Click(object sender, System.Windows.RoutedEventArgs e)
{
changeServiceItem.IsEnabled = false;
RequestServiceChange?.Invoke(this, EventArgs.Empty);
}
private void OpenProgramFolderItem_Click(object sender, System.Windows.RoutedEventArgs e)
{
Process.Start(Global.exedirpath);
}
private void OpenMenuItem_Click(object sender, System.Windows.RoutedEventArgs e) private void OpenMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
{ {
RequestOpen?.Invoke(this, EventArgs.Empty); RequestOpen?.Invoke(this, EventArgs.Empty);
@ -340,7 +374,10 @@ namespace DS4WinWPF.DS4Forms.ViewModels
{ {
contextMenu.Items.Clear(); contextMenu.Items.Clear();
ItemCollection items = contextMenu.Items; ItemCollection items = contextMenu.Items;
MenuItem item = new MenuItem() { Header = "Open" }; MenuItem item;
item = changeServiceItem;
items.Add(item);
item = new MenuItem() { Header = "Open" };
item.Click += OpenMenuItem_Click; item.Click += OpenMenuItem_Click;
items.Add(item); items.Add(item);
item = new MenuItem() { Header = "Minimize" }; item = new MenuItem() { Header = "Minimize" };

View File

@ -16,6 +16,7 @@ namespace DS4WinWPF.DS4Forms
private const string InstallerDL = private const string InstallerDL =
"https://github.com/ViGEm/ViGEmBus/releases/download/v1.16.112/ViGEmBus_Setup_1.16.115.exe"; "https://github.com/ViGEm/ViGEmBus/releases/download/v1.16.112/ViGEmBus_Setup_1.16.115.exe";
private const string InstFileName = "ViGEmBus_Setup_1.16.115.exe"; private const string InstFileName = "ViGEmBus_Setup_1.16.115.exe";
private string tempInstFileName;
Process monitorProc; Process monitorProc;
NonFormTimer monitorTimer; NonFormTimer monitorTimer;
@ -30,6 +31,8 @@ namespace DS4WinWPF.DS4Forms
} }
InitializeComponent(); InitializeComponent();
tempInstFileName = DS4Windows.Global.exedirpath + $"\\{InstFileName}.tmp";
} }
private void FinishedBtn_Click(object sender, RoutedEventArgs e) private void FinishedBtn_Click(object sender, RoutedEventArgs e)
@ -44,6 +47,11 @@ namespace DS4WinWPF.DS4Forms
File.Delete(DS4Windows.Global.exedirpath + $"\\{InstFileName}"); File.Delete(DS4Windows.Global.exedirpath + $"\\{InstFileName}");
} }
if (File.Exists(tempInstFileName))
{
File.Delete(tempInstFileName);
}
ViGEmDownloadLaunch(); ViGEmDownloadLaunch();
/*WebClient wb = new WebClient(); /*WebClient wb = new WebClient();
@ -67,9 +75,17 @@ namespace DS4WinWPF.DS4Forms
}); });
string filename = DS4Windows.Global.exedirpath + $"\\{InstFileName}"; string filename = DS4Windows.Global.exedirpath + $"\\{InstFileName}";
using (var downloadStream = new FileStream(filename, FileMode.CreateNew)) bool success = false;
using (var downloadStream = new FileStream(tempInstFileName, FileMode.CreateNew))
{ {
HttpResponseMessage response = await App.requestClient.GetAsync(InstallerDL, downloadStream, progress); HttpResponseMessage response = await App.requestClient.GetAsync(InstallerDL,
downloadStream, progress);
success = response.IsSuccessStatusCode;
}
if (success)
{
File.Move(tempInstFileName, filename);
} }
if (File.Exists(DS4Windows.Global.exedirpath + $"\\{InstFileName}")) if (File.Exists(DS4Windows.Global.exedirpath + $"\\{InstFileName}"))

View File

@ -474,7 +474,7 @@
<PostBuildEvent>rem Copy compiled l18n assemblies to alt folder <PostBuildEvent>rem Copy compiled l18n assemblies to alt folder
GOTO END GOTO END
if not exist $(TargetDir)Lang mkdir $(TargetDir)Lang if not exist $(TargetDir)Lang mkdir $(TargetDir)Lang
set langs=ja set langs=ja ru
for %25%25l in (%25langs%25) do ( for %25%25l in (%25langs%25) do (
xcopy $(TargetDir)%25%25l $(TargetDir)Lang\%25%25l\ /s /y xcopy $(TargetDir)%25%25l $(TargetDir)Lang\%25%25l\ /s /y

View File

@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0")] [assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.0")] [assembly: AssemblyFileVersion("2.0.1")]
[assembly: NeutralResourcesLanguage("")] [assembly: NeutralResourcesLanguage("")]
[assembly: Guid("a52b5b20-d9ee-4f32-8518-307fa14aa0c6")] [assembly: Guid("a52b5b20-d9ee-4f32-8518-307fa14aa0c6")]

View File

@ -1 +1 @@
2.0.0 2.0.1

12
TODO.md
View File

@ -1,16 +1,6 @@
# TODO # TODO
* Add maximum stick output limit in some way * Add maximum stick output limit in some way
* ~~Check Options save~~
* ~~Check TouchpadInvert setting~~
* Add cross dead zone (per axis) for sticks * Add cross dead zone (per axis) for sticks
* ~~Add more curve options~~ * Add some preset context menus back (sticks, dpad)
* ~~Transition to use Visual Studio 2019~~
* ~~Re-evaluate HidGuardian~~
* ~~Move forms to new namespace~~
* ~~Finalize DS4 Emulation~~
* ~~Raise Sixaxis default dead zones~~
* ~~Evaluate latest ViGEmBus driver and update download URL~~
* ~~Remove old welcome dialog and make new driver installer executable.
Use newer standards (WPF) and bundle app with DS4Windows~~