Merge branch 'jay' into vigem-udpserver

# Conflicts:
#	DS4Windows/DS4Control/ControlService.cs
This commit is contained in:
Travis Nickles 2018-07-18 00:04:51 -05:00
commit ce4a01b99b
16 changed files with 86 additions and 294 deletions

View File

@ -7,10 +7,12 @@ using System.Media;
using System.Threading.Tasks;
using static DS4Windows.Global;
using System.Threading;
using System.Diagnostics;
using Microsoft.Win32;
using Nefarius.ViGEm.Client;
using Nefarius.ViGEm.Client.Targets;
using Nefarius.ViGEm.Client.Targets.Xbox360;
using Registry = Microsoft.Win32.Registry;
namespace DS4Windows
{
@ -166,7 +168,32 @@ namespace DS4Windows
}
}
public void createHidGuardKey()
public void ScanPurgeHidGuard()
{
RegistryKey tempkey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist");
string[] subkeys = tempkey.GetSubKeyNames();
bool processExists = false;
for (int ind = 0, arlen = subkeys.Length; ind < arlen; ind++)
{
processExists = true;
try
{
Process.GetProcessById(Convert.ToInt32(subkeys[ind]));
}
catch { processExists = false; }
if (!processExists)
{
try
{
Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist\" + subkeys[ind]);
}
catch { }
}
}
}
public void CreateHidGuardKey()
{
try
{

View File

@ -779,28 +779,28 @@ namespace DS4Windows
if (absX <= 0.4)
{
outputX = 0.43 * absX;
outputX = 0.45 * absX;
}
else if (absX <= 0.75)
{
outputX = absX - 0.228;
outputX = absX - 0.22;
}
else if (absX > 0.75)
{
outputX = (absX * 1.912) - 0.912;
outputX = (absX * 1.88) - 0.88;
}
if (absY <= 0.4)
{
outputY = 0.43 * absY;
outputY = 0.45 * absY;
}
else if (absY <= 0.75)
{
outputY = absY - 0.228;
outputY = absY - 0.22;
}
else if (absY > 0.75)
{
outputY = (absY * 1.912) - 0.912;
outputY = (absY * 1.88) - 0.88;
}
dState.LX = (byte)(outputX * signX * 127.5 + 127.5);
@ -839,28 +839,28 @@ namespace DS4Windows
if (absX <= 0.4)
{
outputX = 0.414 * absX;
outputX = 0.45 * absX;
}
else if (absX <= 0.75)
{
outputX = absX - 0.24;
outputX = absX - 0.22;
}
else if (absX > 0.75)
{
outputX = (absX * 1.9376) - 0.9376;
outputX = (absX * 1.88) - 0.88;
}
if (absY <= 0.4)
{
outputY = 0.414 * absY;
outputY = 0.45 * absY;
}
else if (absY <= 0.75)
{
outputY = absY - 0.24;
outputY = absY - 0.22;
}
else if (absY > 0.75)
{
outputY = (absY * 1.9376) - 0.9376;
outputY = (absY * 1.88) - 0.88;
}
dState.RX = (byte)(outputX * signX * 127.5 + 127.5);

View File

@ -1,36 +0,0 @@
namespace DS4Windows
{
partial class ScpHub
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

View File

@ -1,87 +0,0 @@
using System;
using System.ComponentModel;
namespace DS4Windows
{
public partial class ScpHub : Component
{
protected IntPtr m_Reference = IntPtr.Zero;
protected volatile Boolean m_Started = false;
public event EventHandler<DebugEventArgs> Debug = null;
public event EventHandler<ReportEventArgs> Report = null;
protected virtual Boolean LogDebug(String Data, bool warning)
{
DebugEventArgs args = new DebugEventArgs(Data, warning);
On_Debug(this, args);
return true;
}
public Boolean Active
{
get { return m_Started; }
}
public ScpHub()
{
InitializeComponent();
}
public ScpHub(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public virtual Boolean Open()
{
return true;
}
public virtual Boolean Start()
{
return m_Started;
}
public virtual Boolean Stop()
{
return !m_Started;
}
public virtual Boolean Close()
{
if (m_Reference != IntPtr.Zero) ScpDevice.UnregisterNotify(m_Reference);
return !m_Started;
}
public virtual Boolean Suspend()
{
return true;
}
public virtual Boolean Resume()
{
return true;
}
protected virtual void On_Debug(object sender, DebugEventArgs e)
{
if (Debug != null) Debug(sender, e);
}
protected virtual void On_Report(object sender, ReportEventArgs e)
{
if (Report != null) Report(sender, e);
}
}
}

View File

@ -1,93 +0,0 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ScpServer
{
[System.ComponentModel.DesignerCategory("")]
public class AdvancedComboBox : ComboBox
{
public Label Label { get; set; }
public AdvancedComboBox()
{
base.Visible = false;
Label = new Label();
Label.Tag = this;
Label.ForeColor = Color.Blue;
Label.TextAlign = ContentAlignment.MiddleCenter;
Label.BackColor = Color.Transparent;
Label.MouseDown += Label_MouseDown;
}
public Color Color
{
get
{
return Label.ForeColor;
}
set
{
Label.ForeColor = value;
}
}
public new bool Visible
{
get
{
return Label.Visible;
}
set
{
Label.Visible = value;
}
}
private void Label_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
DroppedDown = true;
}
protected override void OnParentChanged(EventArgs e)
{
base.OnParentChanged(e);
if (Parent != null)
{
Label.Location = this.Location;
Label.Size = this.Size;
Label.Dock = this.Dock;
Label.Anchor = this.Anchor;
Label.Enabled = this.Enabled;
Label.Visible = this.Visible;
Label.RightToLeft = this.RightToLeft;
Label.Font = this.Font;
Label.Text = this.Text
.Replace("Right Click", "Right-Click")
.Replace(" Button", string.Empty)
.Replace("Left ", string.Empty)
.Replace("Right ", string.Empty);
Label.TabStop = this.TabStop;
Label.TabIndex = this.TabIndex;
}
Label.Parent = this.Parent;
}
protected override void OnSelectedIndexChanged(EventArgs e)
{
base.OnSelectedIndexChanged(e);
Label.Text = this.Text
.Replace("Right Click", "Right-Click")
.Replace(" Button", string.Empty)
.Replace("Left ", string.Empty)
.Replace("Right ", string.Empty);
}
}
}

View File

@ -991,15 +991,16 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
private bool inHotPlug = false;
private int hotplugCounter = 0;
private object hotplugCounterLock = new object();
private const int DBT_DEVNODES_CHANGED = 0x0007;
protected override void WndProc(ref Message m)
{
try
{
if (m.Msg == ScpDevice.WM_DEVICECHANGE)
{
if (runHotPlug)
{
Int32 Type = m.WParam.ToInt32();
if (Type == DBT_DEVNODES_CHANGED)
{
lock (hotplugCounterLock)
{
hotplugCounter++;
@ -1014,14 +1015,13 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
}
}
}
catch { }
if (m.Msg == WM_QUERYENDSESSION)
systemShutdown = true;
// If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc.
try { base.WndProc(ref m); }
catch { }
base.WndProc(ref m);
}
private void InnerHotplug2(SynchronizationContext uiContext)
@ -2463,7 +2463,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
{
Registry.LocalMachine.DeleteSubKeyTree(@"SYSTEM\CurrentControlSet\Services\HidGuardian\Parameters\Whitelist");
Log.LogToGui("Cleared HidGuardian Whitelist", false);
Program.rootHub.createHidGuardKey();
Program.rootHub.CreateHidGuardKey();
}
catch { }
}

View File

@ -1,28 +0,0 @@
namespace DS4Windows.Properties {
// This class allows you to handle specific events on the settings class:
// The SettingChanging event is raised before a setting's value is changed.
// The PropertyChanged event is raised after a setting's value is changed.
// The SettingsLoaded event is raised after the setting values are loaded.
// The SettingsSaving event is raised before the setting values are saved.
internal sealed partial class Settings {
public Settings() {
// // To add event handlers for saving and changing settings, uncomment the lines below:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Add code to handle the SettingChangingEvent event here.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Add code to handle the SettingsSaving event here.
}
}
}

View File

@ -408,12 +408,18 @@ namespace DS4Windows
private Thread timeoutCheckThread = null;
private bool timeoutExecuted = false;
private bool timeoutEvent = false;
private bool runCalib;
public bool ShouldRunCalib()
{
return runCalib;
}
public DS4Device(HidDevice hidDevice)
{
hDevice = hidDevice;
conType = HidConnectionType(hDevice);
Mac = hDevice.readSerial();
runCalib = true;
if (conType == ConnectionType.USB || conType == ConnectionType.SONYWA)
{
inputReport = new byte[64];
@ -428,6 +434,10 @@ namespace DS4Windows
audio = new DS4Audio();
micAudio = new DS4Audio(DS4Library.CoreAudio.DataFlow.Capture);
}
else if (tempAttr.VendorId == 0x146B)
{
runCalib = false;
}
synced = true;
}
@ -452,7 +462,8 @@ namespace DS4Windows
touchpad = new DS4Touchpad();
sixAxis = new DS4SixAxis();
Crc32Algorithm.InitializeTable(DefaultPolynomial);
refreshCalibration();
if (runCalib)
RefreshCalibration();
if (!hDevice.IsFileStreamOpen())
{
@ -462,7 +473,7 @@ namespace DS4Windows
sendOutputReport(true, true); // initialize the output report
}
private void timeoutTestThread()
private void TimeoutTestThread()
{
while (!timeoutExecuted)
{
@ -481,7 +492,7 @@ namespace DS4Windows
const int DS4_FEATURE_REPORT_5_LEN = 41;
const int DS4_FEATURE_REPORT_5_CRC32_POS = DS4_FEATURE_REPORT_5_LEN - 4;
public void refreshCalibration()
public void RefreshCalibration()
{
byte[] calibration = new byte[41];
calibration[0] = conType == ConnectionType.BT ? (byte)0x05 : (byte)0x02;
@ -532,7 +543,7 @@ namespace DS4Windows
ds4Output.IsBackground = true;
ds4Output.Start();
timeoutCheckThread = new Thread(timeoutTestThread);
timeoutCheckThread = new Thread(TimeoutTestThread);
timeoutCheckThread.Priority = ThreadPriority.BelowNormal;
timeoutCheckThread.Name = "DS4 Timeout thread: " + Mac;
timeoutCheckThread.IsBackground = true;
@ -987,6 +998,7 @@ namespace DS4Windows
pbAccel[i-6] = pbInput[i];
}
}
sixAxis.handleSixaxis(gyro, accel, cState, elapsedDeltaTime);
/* Debug output of incoming HID data:

View File

@ -40,6 +40,7 @@ namespace DS4Windows
new VidPidInfo(SONY_VID, 0x09CC),
new VidPidInfo(RAZER_VID, 0x1000),
new VidPidInfo(NACON_VID, 0x0D01),
new VidPidInfo(NACON_VID, 0x0D02),
new VidPidInfo(HORI_VID, 0x00EE), // Hori PS4 Mini Wired Gamepad
new VidPidInfo(0x7545, 0x0104)
};
@ -233,7 +234,8 @@ namespace DS4Windows
deviceSerials.Add(serial);
}
device.refreshCalibration();
if (device.ShouldRunCalib())
device.RefreshCalibration();
}
}
}

View File

@ -115,6 +115,7 @@ namespace DS4Windows
private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(),
new CalibData(), new CalibData(), new CalibData(), new CalibData()
};
private bool calibrationDone = false;
public DS4SixAxis()
{
@ -187,6 +188,8 @@ namespace DS4Windows
calibrationData[5].bias = accelZPlus - accelRange / 2;
calibrationData[5].sensNumer = 2 * SixAxis.ACC_RES_PER_G;
calibrationData[5].sensDenom = accelRange;
calibrationDone = true;
}
private void applyCalibs(ref int yaw, ref int pitch, ref int roll,
@ -227,6 +230,7 @@ namespace DS4Windows
int AccelY = (short)((ushort)(accel[3] << 8) | accel[2]);
int AccelZ = (short)((ushort)(accel[5] << 8) | accel[4]);
if (calibrationDone)
applyCalibs(ref currentYaw, ref currentPitch, ref currentRoll, ref AccelX, ref AccelY, ref AccelZ);
SixAxisEventArgs args = null;

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DS4Windows</RootNamespace>
<AssemblyName>DS4Windows</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
@ -94,6 +94,7 @@
<LangVersion>6</LangVersion>
<DebugSymbols>false</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>1</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
@ -118,6 +119,7 @@
<LangVersion>6</LangVersion>
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<WarningLevel>1</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.8.0.0, Culture=neutral, PublicKeyToken=c416bc1b32d97233, processorArchitecture=MSIL">
@ -154,12 +156,6 @@
<Compile Include="DS4Control\ScpDevice.Designer.cs">
<DependentUpon>ScpDevice.cs</DependentUpon>
</Compile>
<Compile Include="DS4Control\ScpHub.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DS4Control\ScpHub.Designer.cs">
<DependentUpon>ScpHub.cs</DependentUpon>
</Compile>
<Compile Include="DS4Control\ScpUtil.cs" />
<Compile Include="DS4Control\UdpServer.cs" />
<Compile Include="DS4Control\X360Device.cs">
@ -183,7 +179,6 @@
<Compile Include="DS4Library\DS4StateExposed.cs" />
<Compile Include="DS4Library\DS4Touchpad.cs" />
<Compile Include="DS4Forms\AdvancedColorDialog.cs" />
<Compile Include="DS4Forms\AdvancedComboBox.cs" />
<Compile Include="DS4Forms\DS4Form.cs">
<SubType>Form</SubType>
</Compile>
@ -233,7 +228,6 @@
<Compile Include="DS4Forms\SaveWhere.Designer.cs">
<DependentUpon>SaveWhere.cs</DependentUpon>
</Compile>
<Compile Include="DS4Forms\Settings.cs" />
<Compile Include="DS4Forms\SpecActions.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -103,7 +103,8 @@ namespace DS4Windows
//if (mutex.WaitOne(TimeSpan.Zero, true))
//{
createControlService();
rootHub.createHidGuardKey();
rootHub.ScanPurgeHidGuard();
rootHub.CreateHidGuardKey();
//rootHub = new ControlService();
Application.EnableVisualStyles();
Application.Run(new DS4Form(args));

View File

@ -12,7 +12,7 @@ namespace DS4Windows.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@ -8,20 +8,20 @@ You can find the latest and older versions [here](https://github.com/Ryochan7/DS
UdpServer builds for using Gyro motion controls in Cemu.
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_UdpServer_x64.zip
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_ViGEm_UdpServer_x64.zip
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_UdpServer_x64.zip
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_ViGEm_UdpServer_x64.zip
ViGEm build.
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.120_ViGEm_x64.zip
http://ryochan7.xyz/ds4windows/test/DS4Windows_1.4.121_ViGEm_x64.zip
This project is a fork of the work of Jays2Kings. You can find the old project
website at [ds4windows.com](http://ds4windows.com).
## Requirements
- Windows 7 or newer
- [Microsoft .NET 4.5.2 or higher (needed to unzip the driver and for macros to work properly)](http://www.microsoft.com/en-us/download/details.aspx?id=42642)
- Windows 7 SP1 or newer
- [Microsoft .NET 4.6.1 or higher (needed to unzip the driver and for macros to work properly)](https://www.microsoft.com/en-us/download/details.aspx?id=49982)
- SCP Virtual Bus Driver (Downloaded & Installed with DS4Windows)
- Microsoft 360 Driver (link inside DS4Windows, already installed on Windows 7 SP1 and higher or if you've used a 360 controller before)
- Sony DualShock 4 (This should be obvious)

View File

@ -1,7 +1,6 @@
# TODO
* Perform some final cleanup and release version 1.5
* ~~Attempt to work out BT disconnect issues by looking at older versions~~
* Attempt to remove reliance on the main thread when disconnecting a device.
Currently used to delay hotplug routine
* Look into distributing profile properties around various objects
@ -10,6 +9,3 @@ It will complicate the architecture a little bit but hopefully
any speed difference will make up for it.
* Remove old welcome dialog and make new driver installer executable.
Use newer standards (WPF) and bundle app with DS4Windows
* ~~Attempt to no longer disable service when changing dinput only option
in profiles
* ~~Update Task Scheduler to latest version~~