mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 11:04:21 +01:00
Minor style changes and excess removed
This commit is contained in:
parent
52c5fde941
commit
23ee6f9d8a
@ -10,20 +10,6 @@ using System.Threading.Tasks;
|
||||
using static DS4Windows.Global;
|
||||
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 X360Device x360Bus;
|
||||
@ -41,8 +27,6 @@ namespace DS4Windows
|
||||
private int eCode = 0;
|
||||
bool[] buttonsdown = { false, false, false, false };
|
||||
List<DS4Controls> dcs = new List<DS4Controls>();
|
||||
//Dictionary<DS4Controls, DS4ControlInfo> controlInfoDir =
|
||||
// new Dictionary<DS4Controls, DS4ControlInfo>();
|
||||
bool[] held = new bool[DS4_CONTROLLER_COUNT];
|
||||
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
|
||||
SoundPlayer sp = new SoundPlayer();
|
||||
@ -60,7 +44,6 @@ namespace DS4Windows
|
||||
sp.Stream = Properties.Resources.EE;
|
||||
x360Bus = new X360Device();
|
||||
AddtoDS4List();
|
||||
//populateControlInfoDictionary();
|
||||
|
||||
for (int i = 0, arlength = DS4Controllers.Length; i < arlength; i++)
|
||||
{
|
||||
@ -105,51 +88,6 @@ namespace DS4Windows
|
||||
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)
|
||||
{
|
||||
if (DS4Devices.isExclusiveMode && !device.IsExclusive)
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DS4Windows
|
||||
{
|
||||
class DS4StateFieldMapping
|
||||
public class DS4StateFieldMapping
|
||||
{
|
||||
public enum ControlType { Unknown = 0, Button, AxisDir, Trigger, Touch, GyroDir, SwipeDir }
|
||||
|
||||
|
@ -560,8 +560,11 @@ namespace DS4Windows
|
||||
public static int GetActionIndexOf(string name)
|
||||
{
|
||||
for (int i = 0, actionCount = m_Config.actions.Count; i < actionCount; i++)
|
||||
{
|
||||
if (m_Config.actions[i].name == name)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -891,8 +894,11 @@ namespace DS4Windows
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
foreach (DS4Controls dc in Enum.GetValues(typeof(DS4Controls)))
|
||||
{
|
||||
if (dc != DS4Controls.None)
|
||||
ds4settings[i].Add(new DS4ControlSettings(dc));
|
||||
}
|
||||
|
||||
/*customMapKeyTypes[i] = new Dictionary<DS4Controls, DS4KeyType>();
|
||||
customMapKeys[i] = new Dictionary<DS4Controls, UInt16>();
|
||||
customMapMacros[i] = new Dictionary<DS4Controls, String>();
|
||||
@ -904,6 +910,7 @@ namespace DS4Windows
|
||||
shiftCustomMapMacros[i] = new Dictionary<DS4Controls, String>();
|
||||
shiftCustomMapButtons[i] = new Dictionary<DS4Controls, X360Controls>();
|
||||
shiftCustomMapExtras[i] = new Dictionary<DS4Controls, string>();*/
|
||||
|
||||
profileActions[i] = new List<string>();
|
||||
profileActions[i].Add("Disconnect Controller");
|
||||
profileActionCount[i] = profileActions[i].Count;
|
||||
@ -2490,13 +2497,19 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
dcs.UpdateSettings(shift, action, exts, kt, trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateDS4CExtra(int deviceNum, string buttonName, bool shift, string exts)
|
||||
{
|
||||
@ -2505,16 +2518,23 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
if (shift)
|
||||
dcs.shiftExtras = exts;
|
||||
else
|
||||
dcs.extras = exts;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDS4CKeyType(int deviceNum, string buttonName, bool shift, DS4KeyType keyType)
|
||||
{
|
||||
@ -2523,16 +2543,23 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
if (shift)
|
||||
dcs.shiftKeyType = keyType;
|
||||
else
|
||||
dcs.keyType = keyType;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object GetDS4Action(int deviceNum, string buttonName, bool shift)
|
||||
{
|
||||
@ -2541,7 +2568,12 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
if (shift)
|
||||
@ -2549,6 +2581,8 @@ namespace DS4Windows
|
||||
else
|
||||
return dcs.action;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2579,7 +2613,12 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
if (shift)
|
||||
@ -2587,6 +2626,8 @@ namespace DS4Windows
|
||||
else
|
||||
return dcs.extras;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2597,7 +2638,12 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
{
|
||||
if (shift)
|
||||
@ -2605,6 +2651,8 @@ namespace DS4Windows
|
||||
else
|
||||
return dcs.keyType;
|
||||
}
|
||||
}
|
||||
|
||||
return DS4KeyType.None;
|
||||
}
|
||||
|
||||
@ -2615,9 +2663,16 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
return dcs.shiftTrigger;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2641,9 +2696,16 @@ namespace DS4Windows
|
||||
dc = getDS4ControlsByName(buttonName);
|
||||
else
|
||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||
foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.control == dc)
|
||||
return dcs;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -2663,9 +2725,10 @@ namespace DS4Windows
|
||||
public bool HasCustomActions(int deviceNum)
|
||||
{
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
for (int i = 0, listLen = ds4settings[deviceNum].Count; i < listLen; i++)
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settings[deviceNum][i];
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.action != null || dcs.shiftAction != null)
|
||||
return true;
|
||||
}
|
||||
@ -2677,9 +2740,10 @@ namespace DS4Windows
|
||||
public bool HasCustomExtras(int deviceNum)
|
||||
{
|
||||
//foreach (DS4ControlSettings dcs in ds4settings[deviceNum])
|
||||
for (int i = 0, listLen = ds4settings[deviceNum].Count; i < listLen; i++)
|
||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
||||
{
|
||||
DS4ControlSettings dcs = ds4settings[deviceNum][i];
|
||||
DS4ControlSettings dcs = ds4settingsList[i];
|
||||
if (dcs.extras != null || dcs.shiftExtras != null)
|
||||
return true;
|
||||
}
|
||||
|
@ -359,6 +359,7 @@ namespace DS4Windows
|
||||
outputReportBuffer = new byte[BT_OUTPUT_REPORT_LENGTH];
|
||||
warnInterval = WARN_INTERVAL_BT;
|
||||
}
|
||||
|
||||
touchpad = new DS4Touchpad();
|
||||
sixAxis = new DS4SixAxis();
|
||||
}
|
||||
@ -500,9 +501,11 @@ namespace DS4Windows
|
||||
{
|
||||
return priorInputReport30 != 0xff;
|
||||
}
|
||||
|
||||
private byte priorInputReport30 = 0xff;
|
||||
public double Latency = 0;
|
||||
public string error;
|
||||
|
||||
private void performDs4Input()
|
||||
{
|
||||
firstActive = DateTime.UtcNow;
|
||||
@ -736,6 +739,7 @@ namespace DS4Windows
|
||||
{
|
||||
setTestRumble();
|
||||
setHapticState();
|
||||
|
||||
if (conType == ConnectionType.BT)
|
||||
{
|
||||
outputReportBuffer[0] = 0x11;
|
||||
|
Loading…
Reference in New Issue
Block a user