mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-23 01:39:17 +01:00
Minor edits to improve readability
This commit is contained in:
parent
d1994b2876
commit
32cbd77708
@ -10,6 +10,20 @@ using System.Threading.Tasks;
|
|||||||
using static DS4Windows.Global;
|
using static DS4Windows.Global;
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
{
|
{
|
||||||
|
/*public class DS4ControlInfo
|
||||||
|
{
|
||||||
|
public enum ControlType { Unknown = 0, Button, AxisDir, Trigger, Touch, GyroDir, SwipeDir }
|
||||||
|
public DS4Controls control = DS4Controls.None;
|
||||||
|
public ControlType mappedType = ControlType.Unknown;
|
||||||
|
|
||||||
|
public DS4ControlInfo(DS4Controls control, ControlType mappedType)
|
||||||
|
{
|
||||||
|
this.control = control;
|
||||||
|
this.mappedType = mappedType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public class ControlService
|
public class ControlService
|
||||||
{
|
{
|
||||||
public X360Device x360Bus;
|
public X360Device x360Bus;
|
||||||
@ -27,6 +41,8 @@ namespace DS4Windows
|
|||||||
private int eCode = 0;
|
private int eCode = 0;
|
||||||
bool[] buttonsdown = { false, false, false, false };
|
bool[] buttonsdown = { false, false, false, false };
|
||||||
List<DS4Controls> dcs = new List<DS4Controls>();
|
List<DS4Controls> dcs = new List<DS4Controls>();
|
||||||
|
//Dictionary<DS4Controls, DS4ControlInfo> controlInfoDir =
|
||||||
|
// new Dictionary<DS4Controls, DS4ControlInfo>();
|
||||||
bool[] held = new bool[DS4_CONTROLLER_COUNT];
|
bool[] held = new bool[DS4_CONTROLLER_COUNT];
|
||||||
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
|
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
|
||||||
SoundPlayer sp = new SoundPlayer();
|
SoundPlayer sp = new SoundPlayer();
|
||||||
@ -36,6 +52,7 @@ namespace DS4Windows
|
|||||||
public byte[] Report = new byte[28];
|
public byte[] Report = new byte[28];
|
||||||
public byte[] Rumble = new byte[8];
|
public byte[] Rumble = new byte[8];
|
||||||
}
|
}
|
||||||
|
|
||||||
private X360Data[] processingData = new X360Data[4];
|
private X360Data[] processingData = new X360Data[4];
|
||||||
|
|
||||||
public ControlService()
|
public ControlService()
|
||||||
@ -43,6 +60,8 @@ namespace DS4Windows
|
|||||||
sp.Stream = Properties.Resources.EE;
|
sp.Stream = Properties.Resources.EE;
|
||||||
x360Bus = new X360Device();
|
x360Bus = new X360Device();
|
||||||
AddtoDS4List();
|
AddtoDS4List();
|
||||||
|
//populateControlInfoDictionary();
|
||||||
|
|
||||||
for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
|
for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
|
||||||
{
|
{
|
||||||
processingData[i] = new X360Data();
|
processingData[i] = new X360Data();
|
||||||
@ -55,7 +74,6 @@ namespace DS4Windows
|
|||||||
|
|
||||||
void AddtoDS4List()
|
void AddtoDS4List()
|
||||||
{
|
{
|
||||||
dcs.Add(DS4Controls.Cross);
|
|
||||||
dcs.Add(DS4Controls.Cross);
|
dcs.Add(DS4Controls.Cross);
|
||||||
dcs.Add(DS4Controls.Circle);
|
dcs.Add(DS4Controls.Circle);
|
||||||
dcs.Add(DS4Controls.Square);
|
dcs.Add(DS4Controls.Square);
|
||||||
@ -87,16 +105,62 @@ namespace DS4Windows
|
|||||||
dcs.Add(DS4Controls.SwipeRight);
|
dcs.Add(DS4Controls.SwipeRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void populateControlInfoDictionary()
|
||||||
|
{
|
||||||
|
controlInfoDir.Add(DS4Controls.Cross, new DS4ControlInfo(DS4Controls.Cross, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.Circle, new DS4ControlInfo(DS4Controls.Circle, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.Square, new DS4ControlInfo(DS4Controls.Square, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.Triangle, new DS4ControlInfo(DS4Controls.Triangle, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.Options, new DS4ControlInfo(DS4Controls.Options, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.Share, new DS4ControlInfo(DS4Controls.Share, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.DpadUp, new DS4ControlInfo(DS4Controls.DpadUp, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.DpadDown, new DS4ControlInfo(DS4Controls.DpadDown, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.DpadLeft, new DS4ControlInfo(DS4Controls.DpadLeft, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.DpadRight, new DS4ControlInfo(DS4Controls.DpadRight, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.PS, new DS4ControlInfo(DS4Controls.PS, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.L1, new DS4ControlInfo(DS4Controls.L1, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.R1, new DS4ControlInfo(DS4Controls.R1, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.L2, new DS4ControlInfo(DS4Controls.L2, DS4ControlInfo.ControlType.Trigger));
|
||||||
|
controlInfoDir.Add(DS4Controls.R2, new DS4ControlInfo(DS4Controls.R2, DS4ControlInfo.ControlType.Trigger));
|
||||||
|
controlInfoDir.Add(DS4Controls.L3, new DS4ControlInfo(DS4Controls.L3, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.R3, new DS4ControlInfo(DS4Controls.R3, DS4ControlInfo.ControlType.Button));
|
||||||
|
controlInfoDir.Add(DS4Controls.LXPos, new DS4ControlInfo(DS4Controls.LXPos, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.LXNeg, new DS4ControlInfo(DS4Controls.LXNeg, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.LYPos, new DS4ControlInfo(DS4Controls.LYPos, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.LYNeg, new DS4ControlInfo(DS4Controls.LYNeg, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.RXPos, new DS4ControlInfo(DS4Controls.RXPos, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.RXNeg, new DS4ControlInfo(DS4Controls.RXNeg, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.RYPos, new DS4ControlInfo(DS4Controls.RYPos, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.RYNeg, new DS4ControlInfo(DS4Controls.RYNeg, DS4ControlInfo.ControlType.AxisDir));
|
||||||
|
|
||||||
|
controlInfoDir.Add(DS4Controls.SwipeUp, new DS4ControlInfo(DS4Controls.SwipeUp, DS4ControlInfo.ControlType.SwipeDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.SwipeDown, new DS4ControlInfo(DS4Controls.SwipeDown, DS4ControlInfo.ControlType.SwipeDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.SwipeLeft, new DS4ControlInfo(DS4Controls.SwipeLeft, DS4ControlInfo.ControlType.SwipeDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.SwipeRight, new DS4ControlInfo(DS4Controls.SwipeRight, DS4ControlInfo.ControlType.SwipeDir));
|
||||||
|
|
||||||
|
controlInfoDir.Add(DS4Controls.TouchLeft, new DS4ControlInfo(DS4Controls.TouchLeft, DS4ControlInfo.ControlType.Touch));
|
||||||
|
controlInfoDir.Add(DS4Controls.TouchUpper, new DS4ControlInfo(DS4Controls.TouchUpper, DS4ControlInfo.ControlType.Touch));
|
||||||
|
controlInfoDir.Add(DS4Controls.TouchMulti, new DS4ControlInfo(DS4Controls.TouchMulti, DS4ControlInfo.ControlType.Touch));
|
||||||
|
controlInfoDir.Add(DS4Controls.TouchRight, new DS4ControlInfo(DS4Controls.TouchRight, DS4ControlInfo.ControlType.Touch));
|
||||||
|
|
||||||
|
controlInfoDir.Add(DS4Controls.GyroXPos, new DS4ControlInfo(DS4Controls.GyroXPos, DS4ControlInfo.ControlType.GyroDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.GyroXNeg, new DS4ControlInfo(DS4Controls.GyroXNeg, DS4ControlInfo.ControlType.GyroDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.GyroZPos, new DS4ControlInfo(DS4Controls.GyroZPos, DS4ControlInfo.ControlType.GyroDir));
|
||||||
|
controlInfoDir.Add(DS4Controls.GyroZNeg, new DS4ControlInfo(DS4Controls.GyroZNeg, DS4ControlInfo.ControlType.GyroDir));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private async void WarnExclusiveModeFailure(DS4Device device)
|
private async void WarnExclusiveModeFailure(DS4Device device)
|
||||||
{
|
{
|
||||||
if (DS4Devices.isExclusiveMode && !device.IsExclusive)
|
if (DS4Devices.isExclusiveMode && !device.IsExclusive)
|
||||||
{
|
{
|
||||||
await System.Threading.Tasks.Task.Delay(5);
|
await System.Threading.Tasks.Task.Delay(5);
|
||||||
String message = Properties.Resources.CouldNotOpenDS4.Replace("*Mac address*", device.MacAddress) + " " + Properties.Resources.QuitOtherPrograms;
|
String message = Properties.Resources.CouldNotOpenDS4.Replace("*Mac address*", device.getMacAddress()) + " " + Properties.Resources.QuitOtherPrograms;
|
||||||
LogDebug(message, true);
|
LogDebug(message, true);
|
||||||
Log.LogToTray(message, true);
|
Log.LogToTray(message, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Start(bool showlog = true)
|
public bool Start(bool showlog = true)
|
||||||
{
|
{
|
||||||
if (x360Bus.Open() && x360Bus.Start())
|
if (x360Bus.Open() && x360Bus.Start())
|
||||||
@ -118,7 +182,7 @@ namespace DS4Windows
|
|||||||
foreach (DS4Device device in devices)
|
foreach (DS4Device device in devices)
|
||||||
{
|
{
|
||||||
if (showlog)
|
if (showlog)
|
||||||
LogDebug(Properties.Resources.FoundController + device.MacAddress + " (" + device.ConnectionType + ")");
|
LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")");
|
||||||
WarnExclusiveModeFailure(device);
|
WarnExclusiveModeFailure(device);
|
||||||
DS4Controllers[ind] = device;
|
DS4Controllers[ind] = device;
|
||||||
device.Removal -= DS4Devices.On_Removal;
|
device.Removal -= DS4Devices.On_Removal;
|
||||||
@ -133,9 +197,10 @@ namespace DS4Windows
|
|||||||
//string filename = ProfilePath[ind];
|
//string filename = ProfilePath[ind];
|
||||||
ind++;
|
ind++;
|
||||||
if (showlog)
|
if (showlog)
|
||||||
if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[ind-1] + ".xml"))
|
{
|
||||||
|
if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[ind - 1] + ".xml"))
|
||||||
{
|
{
|
||||||
string prolog = Properties.Resources.UsingProfile.Replace("*number*", ind.ToString()).Replace("*Profile name*", ProfilePath[ind-1]);
|
string prolog = Properties.Resources.UsingProfile.Replace("*number*", ind.ToString()).Replace("*Profile name*", ProfilePath[ind - 1]);
|
||||||
LogDebug(prolog);
|
LogDebug(prolog);
|
||||||
Log.LogToTray(prolog);
|
Log.LogToTray(prolog);
|
||||||
}
|
}
|
||||||
@ -145,6 +210,8 @@ namespace DS4Windows
|
|||||||
LogDebug(prolog);
|
LogDebug(prolog);
|
||||||
Log.LogToTray(prolog);
|
Log.LogToTray(prolog);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ind >= 4) // out of Xinput devices!
|
if (ind >= 4) // out of Xinput devices!
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -200,13 +267,17 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
if (anyUnplugged)
|
if (anyUnplugged)
|
||||||
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
|
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
|
||||||
|
|
||||||
x360Bus.UnplugAll();
|
x360Bus.UnplugAll();
|
||||||
x360Bus.Stop();
|
x360Bus.Stop();
|
||||||
|
|
||||||
if (showlog)
|
if (showlog)
|
||||||
LogDebug(Properties.Resources.StoppingDS4);
|
LogDebug(Properties.Resources.StoppingDS4);
|
||||||
|
|
||||||
DS4Devices.stopControllers();
|
DS4Devices.stopControllers();
|
||||||
if (showlog)
|
if (showlog)
|
||||||
LogDebug(Properties.Resources.StoppedDS4Windows);
|
LogDebug(Properties.Resources.StoppedDS4Windows);
|
||||||
|
|
||||||
ControllerStatusChanged(this);
|
ControllerStatusChanged(this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -218,22 +289,27 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
DS4Devices.findControllers();
|
DS4Devices.findControllers();
|
||||||
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();
|
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();
|
||||||
foreach (DS4Device device in devices)
|
//foreach (DS4Device device in devices)
|
||||||
|
for (int i = 0, devlen = devices.Count(); i < devlen; i++)
|
||||||
{
|
{
|
||||||
if (device.IsDisconnecting)
|
DS4Device device = devices.ElementAt<DS4Device>(i);
|
||||||
|
if (device.isDisconnectingStatus())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (((Func<bool>)delegate
|
if (((Func<bool>)delegate
|
||||||
{
|
{
|
||||||
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
|
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
|
||||||
if (DS4Controllers[Index] != null && DS4Controllers[Index].MacAddress == device.MacAddress)
|
if (DS4Controllers[Index] != null && DS4Controllers[Index].getMacAddress() == device.getMacAddress())
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
})())
|
})())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
|
for (Int32 Index = 0, arlength = DS4Controllers.Length; Index < arlength; Index++)
|
||||||
|
{
|
||||||
if (DS4Controllers[Index] == null)
|
if (DS4Controllers[Index] == null)
|
||||||
{
|
{
|
||||||
LogDebug(Properties.Resources.FoundController + device.MacAddress + " (" + device.ConnectionType + ")");
|
LogDebug(Properties.Resources.FoundController + device.getMacAddress() + " (" + device.getConnectionType() + ")");
|
||||||
WarnExclusiveModeFailure(device);
|
WarnExclusiveModeFailure(device);
|
||||||
DS4Controllers[Index] = device;
|
DS4Controllers[Index] = device;
|
||||||
device.Removal -= DS4Devices.On_Removal;
|
device.Removal -= DS4Devices.On_Removal;
|
||||||
@ -258,9 +334,10 @@ namespace DS4Windows
|
|||||||
LogDebug(prolog);
|
LogDebug(prolog);
|
||||||
Log.LogToTray(prolog);
|
Log.LogToTray(prolog);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -317,23 +394,25 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
|
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
|
||||||
TimeoutThread.IsBackground = true;
|
TimeoutThread.IsBackground = true;
|
||||||
TimeoutThread.Name = "TimeoutFor" + d.MacAddress.ToString();
|
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
|
||||||
TimeoutThread.Start();
|
TimeoutThread.Start();
|
||||||
return Properties.Resources.Connecting;
|
return Properties.Resources.Connecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
String battery;
|
String battery;
|
||||||
if (d.Charging)
|
if (d.isCharging())
|
||||||
{
|
{
|
||||||
if (d.Battery >= 100)
|
if (d.getBattery() >= 100)
|
||||||
battery = Properties.Resources.Charged;
|
battery = Properties.Resources.Charged;
|
||||||
else
|
else
|
||||||
battery = Properties.Resources.Charging.Replace("*number*", d.Battery.ToString());
|
battery = Properties.Resources.Charging.Replace("*number*", d.getBattery().ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battery = Properties.Resources.Battery.Replace("*number*", d.Battery.ToString());
|
battery = Properties.Resources.Battery.Replace("*number*", d.getBattery().ToString());
|
||||||
}
|
}
|
||||||
return d.MacAddress + " (" + d.ConnectionType + "), " + battery;
|
|
||||||
|
return d.getMacAddress() + " (" + d.ConnectionType + "), " + battery;
|
||||||
//return d.MacAddress + " (" + d.ConnectionType + "), Battery is " + battery + ", Touchpad in " + modeSwitcher[index].ToString();
|
//return d.MacAddress + " (" + d.ConnectionType + "), Battery is " + battery + ", Touchpad in " + modeSwitcher[index].ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -350,11 +429,11 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
|
var TimeoutThread = new System.Threading.Thread(() => TimeoutConnection(d));
|
||||||
TimeoutThread.IsBackground = true;
|
TimeoutThread.IsBackground = true;
|
||||||
TimeoutThread.Name = "TimeoutFor" + d.MacAddress.ToString();
|
TimeoutThread.Name = "TimeoutFor" + d.getMacAddress().ToString();
|
||||||
TimeoutThread.Start();
|
TimeoutThread.Start();
|
||||||
return Properties.Resources.Connecting;
|
return Properties.Resources.Connecting;
|
||||||
}
|
}
|
||||||
return d.MacAddress;
|
return d.getMacAddress();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
@ -368,18 +447,20 @@ namespace DS4Windows
|
|||||||
String battery;
|
String battery;
|
||||||
if (!d.IsAlive())
|
if (!d.IsAlive())
|
||||||
battery = "...";
|
battery = "...";
|
||||||
if (d.Charging)
|
|
||||||
|
if (d.isCharging())
|
||||||
{
|
{
|
||||||
if (d.Battery >= 100)
|
if (d.getBattery() >= 100)
|
||||||
battery = Properties.Resources.Full;
|
battery = Properties.Resources.Full;
|
||||||
else
|
else
|
||||||
battery = d.Battery + "%+";
|
battery = d.getBattery() + "%+";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battery = d.Battery + "%";
|
battery = d.getBattery() + "%";
|
||||||
}
|
}
|
||||||
return (d.ConnectionType + " " + battery);
|
|
||||||
|
return (d.getConnectionType() + " " + battery);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Properties.Resources.NoneText;
|
return Properties.Resources.NoneText;
|
||||||
@ -393,17 +474,19 @@ namespace DS4Windows
|
|||||||
String battery;
|
String battery;
|
||||||
if (!d.IsAlive())
|
if (!d.IsAlive())
|
||||||
battery = "...";
|
battery = "...";
|
||||||
if (d.Charging)
|
|
||||||
|
if (d.isCharging())
|
||||||
{
|
{
|
||||||
if (d.Battery >= 100)
|
if (d.getBattery() >= 100)
|
||||||
battery = Properties.Resources.Full;
|
battery = Properties.Resources.Full;
|
||||||
else
|
else
|
||||||
battery = d.Battery + "%+";
|
battery = d.getBattery() + "%+";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
battery = d.Battery + "%";
|
battery = d.getBattery() + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
return battery;
|
return battery;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -415,13 +498,12 @@ namespace DS4Windows
|
|||||||
if (DS4Controllers[index] != null)
|
if (DS4Controllers[index] != null)
|
||||||
{
|
{
|
||||||
DS4Device d = DS4Controllers[index];
|
DS4Device d = DS4Controllers[index];
|
||||||
return d.ConnectionType+"";
|
return d.getConnectionType() + "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return Properties.Resources.NoneText;
|
return Properties.Resources.NoneText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
|
private int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
|
||||||
//Called when DS4 is disconnected or timed out
|
//Called when DS4 is disconnected or timed out
|
||||||
protected virtual void On_DS4Removal(object sender, EventArgs e)
|
protected virtual void On_DS4Removal(object sender, EventArgs e)
|
||||||
@ -429,7 +511,7 @@ namespace DS4Windows
|
|||||||
DS4Device device = (DS4Device)sender;
|
DS4Device device = (DS4Device)sender;
|
||||||
int ind = -1;
|
int ind = -1;
|
||||||
for (int i = 0, arlength = DS4Controllers.Length; ind == -1 && i < arlength; i++)
|
for (int i = 0, arlength = DS4Controllers.Length; ind == -1 && i < arlength; i++)
|
||||||
if (DS4Controllers[i] != null && device.MacAddress == DS4Controllers[i].MacAddress)
|
if (DS4Controllers[i] != null && device.getMacAddress() == DS4Controllers[i].getMacAddress())
|
||||||
ind = i;
|
ind = i;
|
||||||
|
|
||||||
if (ind != -1)
|
if (ind != -1)
|
||||||
@ -480,6 +562,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
if (getFlushHIDQueue(ind))
|
if (getFlushHIDQueue(ind))
|
||||||
device.FlushHID();
|
device.FlushHID();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(device.error))
|
if (!string.IsNullOrEmpty(device.error))
|
||||||
{
|
{
|
||||||
LogDebug(device.error);
|
LogDebug(device.error);
|
||||||
@ -515,7 +598,8 @@ namespace DS4Windows
|
|||||||
cState.calculateStickAngles();
|
cState.calculateStickAngles();
|
||||||
|
|
||||||
if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
|
if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
|
||||||
containsCustomAction(ind) || containsCustomExtras(ind) || getProfileActionCount(ind) > 0))
|
containsCustomAction(ind) || containsCustomExtras(ind) ||
|
||||||
|
getProfileActionCount(ind) > 0))
|
||||||
{
|
{
|
||||||
Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
|
Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
|
||||||
cState = MappedState[ind];
|
cState = MappedState[ind];
|
||||||
@ -627,8 +711,6 @@ namespace DS4Windows
|
|||||||
held[ind] = false;
|
held[ind] = false;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void EasterTime(int ind)
|
public void EasterTime(int ind)
|
||||||
{
|
{
|
||||||
@ -647,6 +729,7 @@ namespace DS4Windows
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int temp = eCode;
|
int temp = eCode;
|
||||||
//Looks like you found the easter egg code, since you're already cheating,
|
//Looks like you found the easter egg code, since you're already cheating,
|
||||||
//I scrambled the code for you :)
|
//I scrambled the code for you :)
|
||||||
@ -1013,7 +1096,9 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
DS4State cState = CurrentState[ind];
|
DS4State cState = CurrentState[ind];
|
||||||
string slidedir = "none";
|
string slidedir = "none";
|
||||||
if (DS4Controllers[ind] != null && cState.Touch2 && !(touchPad[ind].dragging || touchPad[ind].dragging2))
|
if (DS4Controllers[ind] != null && cState.Touch2 &&
|
||||||
|
!(touchPad[ind].dragging || touchPad[ind].dragging2))
|
||||||
|
{
|
||||||
if (touchPad[ind].slideright && !touchslid[ind])
|
if (touchPad[ind].slideright && !touchslid[ind])
|
||||||
{
|
{
|
||||||
slidedir = "right";
|
slidedir = "right";
|
||||||
@ -1029,6 +1114,8 @@ namespace DS4Windows
|
|||||||
slidedir = "";
|
slidedir = "";
|
||||||
touchslid[ind] = false;
|
touchslid[ind] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return slidedir;
|
return slidedir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1058,6 +1145,7 @@ namespace DS4Windows
|
|||||||
uint heavyBoosted = ((uint)heavyMotor * (uint)boost) / 100;
|
uint heavyBoosted = ((uint)heavyMotor * (uint)boost) / 100;
|
||||||
if (heavyBoosted > 255)
|
if (heavyBoosted > 255)
|
||||||
heavyBoosted = 255;
|
heavyBoosted = 255;
|
||||||
|
|
||||||
if (deviceNum < 4)
|
if (deviceNum < 4)
|
||||||
if (DS4Controllers[deviceNum] != null)
|
if (DS4Controllers[deviceNum] != null)
|
||||||
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted);
|
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted);
|
||||||
@ -1067,6 +1155,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
return CurrentState[ind];
|
return CurrentState[ind];
|
||||||
}
|
}
|
||||||
|
|
||||||
public DS4State getDS4StateMapped(int ind)
|
public DS4State getDS4StateMapped(int ind)
|
||||||
{
|
{
|
||||||
return MappedState[ind];
|
return MappedState[ind];
|
||||||
|
@ -530,9 +530,6 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
dState.LY = 127;
|
dState.LY = 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
//dState.LX = (byte)(Math.Cos(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
|
||||||
//dState.LY = (byte)(Math.Sin(r) * (127.5f + LSDeadzone[device]) + 127.5f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,11 +593,6 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
dState.RY = 127;
|
dState.RY = 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
//dState.RX = (byte)(((dState.RX - 127.5f - tempRsXDead) / (double)(maxXValue - tempRsXDead)) * maxXValue + 127.5f);
|
|
||||||
//dState.RY = (byte)(((dState.RY - 127.5f - tempRsYDead) / (double)(maxYValue - tempRsYDead)) * maxYValue + 127.5f);
|
|
||||||
//dState.RX = (byte)(Math.Cos(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
|
||||||
//dState.RY = (byte)(Math.Sin(r) * (127.5f + RSDeadzone[device]) + 127.5f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1560,7 +1552,7 @@ namespace DS4Windows
|
|||||||
DS4Device d = ctrl.DS4Controllers[device];
|
DS4Device d = ctrl.DS4Controllers[device];
|
||||||
if (!d.isCharging())
|
if (!d.isCharging())
|
||||||
{
|
{
|
||||||
ConnectionType deviceConn = d.ConnectionType;
|
ConnectionType deviceConn = d.getConnectionType();
|
||||||
if (deviceConn == ConnectionType.BT)
|
if (deviceConn == ConnectionType.BT)
|
||||||
{
|
{
|
||||||
d.DisconnectBT();
|
d.DisconnectBT();
|
||||||
@ -2041,6 +2033,7 @@ namespace DS4Windows
|
|||||||
if (control != DS4Controls.None)
|
if (control != DS4Controls.None)
|
||||||
macrodone[DS4ControltoInt(control)] = false;
|
macrodone[DS4ControltoInt(control)] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AltTabSwapping(int wait, int device)
|
private static void AltTabSwapping(int wait, int device)
|
||||||
{
|
{
|
||||||
if (altTabDone)
|
if (altTabDone)
|
||||||
@ -2226,15 +2219,18 @@ namespace DS4Windows
|
|||||||
mcounter = 34;
|
mcounter = 34;
|
||||||
mouseaccel++;
|
mouseaccel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseaccel == prevmouseaccel)
|
if (mouseaccel == prevmouseaccel)
|
||||||
{
|
{
|
||||||
mcounter--;
|
mcounter--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcounter <= 0)
|
if (mcounter <= 0)
|
||||||
{
|
{
|
||||||
mouseaccel = 0;
|
mouseaccel = 0;
|
||||||
mcounter = 34;
|
mcounter = 34;
|
||||||
}
|
}
|
||||||
|
|
||||||
value *= 1 + (double)Math.Min(20000, (mouseaccel)) / 10000d;
|
value *= 1 + (double)Math.Min(20000, (mouseaccel)) / 10000d;
|
||||||
prevmouseaccel = mouseaccel;
|
prevmouseaccel = mouseaccel;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ namespace DS4Windows
|
|||||||
actionType = ActionType.Macro;
|
actionType = ActionType.Macro;
|
||||||
else
|
else
|
||||||
actionType = ActionType.Default;
|
actionType = ActionType.Default;
|
||||||
|
|
||||||
action = act;
|
action = act;
|
||||||
extras = exts;
|
extras = exts;
|
||||||
keyType = kt;
|
keyType = kt;
|
||||||
@ -78,6 +79,7 @@ namespace DS4Windows
|
|||||||
shiftActionType = ActionType.Macro;
|
shiftActionType = ActionType.Macro;
|
||||||
else
|
else
|
||||||
shiftActionType = ActionType.Default;
|
shiftActionType = ActionType.Default;
|
||||||
|
|
||||||
shiftAction = act;
|
shiftAction = act;
|
||||||
shiftExtras = exts;
|
shiftExtras = exts;
|
||||||
shiftKeyType = kt;
|
shiftKeyType = kt;
|
||||||
|
@ -166,6 +166,10 @@ namespace DS4Windows
|
|||||||
this.isDisconnecting = value;
|
this.isDisconnecting = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool isDisconnectingStatus()
|
||||||
|
{
|
||||||
|
return this.isDisconnecting;
|
||||||
|
}
|
||||||
|
|
||||||
private bool isRemoving = false;
|
private bool isRemoving = false;
|
||||||
public bool IsRemoving
|
public bool IsRemoving
|
||||||
@ -190,6 +194,10 @@ namespace DS4Windows
|
|||||||
public object removeLocker = new object();
|
public object removeLocker = new object();
|
||||||
|
|
||||||
public string MacAddress => Mac;
|
public string MacAddress => Mac;
|
||||||
|
public string getMacAddress()
|
||||||
|
{
|
||||||
|
return this.Mac;
|
||||||
|
}
|
||||||
|
|
||||||
public ConnectionType ConnectionType => conType;
|
public ConnectionType ConnectionType => conType;
|
||||||
public ConnectionType getConnectionType()
|
public ConnectionType getConnectionType()
|
||||||
|
@ -17,8 +17,8 @@ namespace DS4Windows
|
|||||||
public byte FrameCounter; // 0, 1, 2...62, 63, 0....
|
public byte FrameCounter; // 0, 1, 2...62, 63, 0....
|
||||||
public byte TouchPacketCounter; // we break these out automatically
|
public byte TouchPacketCounter; // we break these out automatically
|
||||||
public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full
|
public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full
|
||||||
public double LSAngle;
|
public double LSAngle; // Calculated bearing of the LS X,Y coordinates
|
||||||
public double RSAngle;
|
public double RSAngle; // Calculated bearing of the RS X,Y coordinates
|
||||||
|
|
||||||
public DS4State()
|
public DS4State()
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,7 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;
|
System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
|
Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
|
||||||
@ -81,6 +82,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
// Ignore problems raising the priority.
|
// Ignore problems raising the priority.
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// another instance is already running if OpenExsting succeeds.
|
// another instance is already running if OpenExsting succeeds.
|
||||||
@ -90,6 +92,7 @@ namespace DS4Windows
|
|||||||
return; // return immediatly.
|
return; // return immediatly.
|
||||||
}
|
}
|
||||||
catch { /* don't care about errors */ }
|
catch { /* don't care about errors */ }
|
||||||
|
|
||||||
// Create the Event handle
|
// Create the Event handle
|
||||||
threadComEvent = new EventWaitHandle(false, EventResetMode.AutoReset, SingleAppComEventName);
|
threadComEvent = new EventWaitHandle(false, EventResetMode.AutoReset, SingleAppComEventName);
|
||||||
CreateInterAppComThread();
|
CreateInterAppComThread();
|
||||||
|
Loading…
Reference in New Issue
Block a user