mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 02:54:20 +01:00
Fix some button mapping issues. Style changes. Change runStartupPanel
This commit is contained in:
parent
bba8af6a63
commit
e34e8115ad
@ -423,7 +423,7 @@ namespace DS4Windows
|
||||
if (DS4Controllers[index] != null)
|
||||
{
|
||||
DS4Device d = DS4Controllers[index];
|
||||
String battery;
|
||||
string battery;
|
||||
if (!d.IsAlive())
|
||||
battery = "...";
|
||||
|
||||
@ -483,9 +483,10 @@ namespace DS4Windows
|
||||
CurrentState[ind].Battery = PreviousState[ind].Battery = 0; // Reset for the next connection's initial status change.
|
||||
x360Bus.Unplug(ind);
|
||||
string removed = Properties.Resources.ControllerWasRemoved.Replace("*Mac address*", (ind + 1).ToString());
|
||||
if (device.Battery <= 20 &&
|
||||
device.ConnectionType == ConnectionType.BT && !device.Charging)
|
||||
if (device.getBattery() <= 20 &&
|
||||
device.getConnectionType() == ConnectionType.BT && !device.isCharging())
|
||||
removed += ". " + Properties.Resources.ChargeController;
|
||||
|
||||
LogDebug(removed);
|
||||
Log.LogToTray(removed);
|
||||
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
|
||||
|
@ -794,15 +794,17 @@ namespace DS4Windows
|
||||
|
||||
cState.calculateStickAngles();
|
||||
DS4StateFieldMapping fieldMapping = new DS4StateFieldMapping(cState, eState, tp);
|
||||
|
||||
DS4StateFieldMapping outputfieldMapping = new DS4StateFieldMapping(cState, eState, tp);
|
||||
|
||||
SyntheticState deviceState = Mapping.deviceState[device];
|
||||
if (getProfileActionCount(device) > 0 || !string.IsNullOrEmpty(tempprofilename[device]))
|
||||
MapCustomAction(device, cState, MappedState, eState, tp, ctrl, fieldMapping);
|
||||
MapCustomAction(device, cState, MappedState, eState, tp, ctrl, fieldMapping, outputfieldMapping);
|
||||
if (ctrl.DS4Controllers[device] == null) return;
|
||||
|
||||
cState.CopyTo(MappedState);
|
||||
|
||||
Dictionary<DS4Controls, DS4Controls> tempControlDict = new Dictionary<DS4Controls, DS4Controls>();
|
||||
//MultiValueDict<DS4Controls, DS4Controls> tempControlDict = new MultiValueDict<DS4Controls, DS4Controls>();
|
||||
DS4Controls usingExtra = DS4Controls.None;
|
||||
List<DS4ControlSettings> tempSettingsList = getDS4CSettings(device);
|
||||
//foreach (DS4ControlSettings dcs in getDS4CSettings(device))
|
||||
@ -832,7 +834,7 @@ namespace DS4Windows
|
||||
bool active = getBoolMapping2(device, dcs.control, cState, eState, tp, fieldMapping);
|
||||
if (active)
|
||||
{
|
||||
resetToDefaultValue2(dcs.control, MappedState, fieldMapping);
|
||||
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
|
||||
PlayMacro(device, macroControl, string.Join("/", (int[])action), dcs.control, keyType);
|
||||
}
|
||||
else
|
||||
@ -845,7 +847,7 @@ namespace DS4Windows
|
||||
ushort value = ushort.Parse(action.ToString());
|
||||
if (getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping))
|
||||
{
|
||||
resetToDefaultValue2(dcs.control, MappedState, fieldMapping);
|
||||
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
|
||||
SyntheticState.KeyPresses kp;
|
||||
if (!deviceState.keyPresses.TryGetValue(value, out kp))
|
||||
deviceState.keyPresses[value] = kp = new SyntheticState.KeyPresses();
|
||||
@ -901,10 +903,10 @@ namespace DS4Windows
|
||||
{
|
||||
switch (xboxControl)
|
||||
{
|
||||
case X360Controls.A: tempControlDict.Add(DS4Controls.Cross, dcs.control); break;
|
||||
case X360Controls.B: tempControlDict.Add(DS4Controls.Circle, dcs.control); break;
|
||||
case X360Controls.X: tempControlDict.Add(DS4Controls.Square, dcs.control); break;
|
||||
case X360Controls.Y: tempControlDict.Add(DS4Controls.Triangle, dcs.control); break;
|
||||
case X360Controls.A: tempControlDict.Add(dcs.control, DS4Controls.Cross); break;
|
||||
case X360Controls.B: tempControlDict.Add(dcs.control, DS4Controls.Circle); break;
|
||||
case X360Controls.X: tempControlDict.Add(dcs.control, DS4Controls.Square); break;
|
||||
case X360Controls.Y: tempControlDict.Add(dcs.control, DS4Controls.Triangle); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -912,12 +914,12 @@ namespace DS4Windows
|
||||
{
|
||||
switch (xboxControl)
|
||||
{
|
||||
case X360Controls.LB: tempControlDict.Add(DS4Controls.L1, dcs.control); break;
|
||||
case X360Controls.LT: tempControlDict.Add(DS4Controls.L2, dcs.control); break;
|
||||
case X360Controls.LS: tempControlDict.Add(DS4Controls.L3, dcs.control); break;
|
||||
case X360Controls.RB: tempControlDict.Add(DS4Controls.R1, dcs.control); break;
|
||||
case X360Controls.RT: tempControlDict.Add(DS4Controls.R2, dcs.control); break;
|
||||
case X360Controls.RS: tempControlDict.Add(DS4Controls.R3, dcs.control); break;
|
||||
case X360Controls.LB: tempControlDict.Add(dcs.control, DS4Controls.L1); break;
|
||||
case X360Controls.LT: tempControlDict.Add(dcs.control, DS4Controls.L2); break;
|
||||
case X360Controls.LS: tempControlDict.Add(dcs.control, DS4Controls.L3); break;
|
||||
case X360Controls.RB: tempControlDict.Add(dcs.control, DS4Controls.R1); break;
|
||||
case X360Controls.RT: tempControlDict.Add(dcs.control, DS4Controls.R2); break;
|
||||
case X360Controls.RS: tempControlDict.Add(dcs.control, DS4Controls.R3); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -925,10 +927,10 @@ namespace DS4Windows
|
||||
{
|
||||
switch (xboxControl)
|
||||
{
|
||||
case X360Controls.DpadUp: tempControlDict.Add(DS4Controls.DpadUp, dcs.control); break;
|
||||
case X360Controls.DpadDown: tempControlDict.Add(DS4Controls.DpadDown, dcs.control); break;
|
||||
case X360Controls.DpadLeft: tempControlDict.Add(DS4Controls.DpadLeft, dcs.control); break;
|
||||
case X360Controls.DpadRight: tempControlDict.Add(DS4Controls.DpadRight, dcs.control); break;
|
||||
case X360Controls.DpadUp: tempControlDict.Add(dcs.control, DS4Controls.DpadUp); break;
|
||||
case X360Controls.DpadDown: tempControlDict.Add(dcs.control, DS4Controls.DpadDown); break;
|
||||
case X360Controls.DpadLeft: tempControlDict.Add(dcs.control, DS4Controls.DpadLeft); break;
|
||||
case X360Controls.DpadRight: tempControlDict.Add(dcs.control, DS4Controls.DpadRight); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -936,14 +938,14 @@ namespace DS4Windows
|
||||
{
|
||||
switch (xboxControl)
|
||||
{
|
||||
case X360Controls.LXNeg: tempControlDict.Add(DS4Controls.LXNeg, dcs.control); break;
|
||||
case X360Controls.LYNeg: tempControlDict.Add(DS4Controls.LYNeg, dcs.control); break;
|
||||
case X360Controls.RXNeg: tempControlDict.Add(DS4Controls.RXNeg, dcs.control); break;
|
||||
case X360Controls.RYNeg: tempControlDict.Add(DS4Controls.RYNeg, dcs.control); break;
|
||||
case X360Controls.LXPos: tempControlDict.Add(DS4Controls.LXPos, dcs.control); break;
|
||||
case X360Controls.LYPos: tempControlDict.Add(DS4Controls.LYPos, dcs.control); break;
|
||||
case X360Controls.RXPos: tempControlDict.Add(DS4Controls.RXPos, dcs.control); break;
|
||||
case X360Controls.RYPos: tempControlDict.Add(DS4Controls.RYPos, dcs.control); break;
|
||||
case X360Controls.LXNeg: tempControlDict.Add(dcs.control, DS4Controls.LXNeg); break;
|
||||
case X360Controls.LYNeg: tempControlDict.Add(dcs.control, DS4Controls.LYNeg); break;
|
||||
case X360Controls.RXNeg: tempControlDict.Add(dcs.control, DS4Controls.RXNeg); break;
|
||||
case X360Controls.RYNeg: tempControlDict.Add(dcs.control, DS4Controls.RYNeg); break;
|
||||
case X360Controls.LXPos: tempControlDict.Add(dcs.control, DS4Controls.LXPos); break;
|
||||
case X360Controls.LYPos: tempControlDict.Add(dcs.control, DS4Controls.LYPos); break;
|
||||
case X360Controls.RXPos: tempControlDict.Add(dcs.control, DS4Controls.RXPos); break;
|
||||
case X360Controls.RYPos: tempControlDict.Add(dcs.control, DS4Controls.RYPos); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -1033,9 +1035,9 @@ namespace DS4Windows
|
||||
{
|
||||
switch (xboxControl)
|
||||
{
|
||||
case X360Controls.Start: tempControlDict.Add(DS4Controls.Options, dcs.control); break;
|
||||
case X360Controls.Guide: tempControlDict.Add(DS4Controls.PS, dcs.control); break;
|
||||
case X360Controls.Back: tempControlDict.Add(DS4Controls.Share, dcs.control); break;
|
||||
case X360Controls.Start: tempControlDict.Add(dcs.control, DS4Controls.Options); break;
|
||||
case X360Controls.Guide: tempControlDict.Add(dcs.control, DS4Controls.PS); break;
|
||||
case X360Controls.Back: tempControlDict.Add(dcs.control, DS4Controls.Share); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -1044,7 +1046,7 @@ namespace DS4Windows
|
||||
{
|
||||
if (getBoolActionMapping2(device, dcs.control, cState, eState, tp, fieldMapping))
|
||||
{
|
||||
resetToDefaultValue2(dcs.control, MappedState, fieldMapping);
|
||||
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping);
|
||||
if (!pressedonce[keyvalue])
|
||||
{
|
||||
deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
|
||||
@ -1058,7 +1060,7 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
resetToDefaultValue2(dcs.control, MappedState, fieldMapping); // erase default mappings for things that are remapped
|
||||
resetToDefaultValue2(dcs.control, MappedState, outputfieldMapping); // erase default mappings for things that are remapped
|
||||
}
|
||||
}
|
||||
|
||||
@ -1115,7 +1117,9 @@ namespace DS4Windows
|
||||
usingExtra = DS4Controls.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outputfieldMapping.populateState(MappedState);
|
||||
|
||||
if (macroControl[00]) MappedState.Cross = true;
|
||||
if (macroControl[01]) MappedState.Circle = true;
|
||||
@ -1168,6 +1172,7 @@ namespace DS4Windows
|
||||
tempControlDict.Add(DS4Controls.RYPos, DS4Controls.RYPos);
|
||||
|
||||
Dictionary<DS4Controls, DS4Controls>.KeyCollection controlKeys = tempControlDict.Keys;
|
||||
//Dictionary<DS4Controls, List<DS4Controls>>.KeyCollection controlKeys = tempControlDict.Keys;
|
||||
|
||||
//foreach (KeyValuePair<DS4Controls, DS4Controls> entry in tempControlDict)
|
||||
for (int i = 0, keyCount = controlKeys.Count; i < keyCount; i++)
|
||||
@ -1176,11 +1181,12 @@ namespace DS4Windows
|
||||
DS4Controls dc = tempControlDict[key];
|
||||
//DS4Controls key = entry.Key;
|
||||
//DS4Controls dc = entry.Value;
|
||||
if (getBoolActionMapping2(device, dc, cState, eState, tp, fieldMapping, true))
|
||||
|
||||
if (getBoolActionMapping2(device, key, cState, eState, tp, fieldMapping, true))
|
||||
{
|
||||
if (key >= DS4Controls.Square && key <= DS4Controls.Cross)
|
||||
if (dc >= DS4Controls.Square && dc <= DS4Controls.Cross)
|
||||
{
|
||||
switch (key)
|
||||
switch (dc)
|
||||
{
|
||||
case DS4Controls.Cross: MappedState.Cross = true; break;
|
||||
case DS4Controls.Circle: MappedState.Circle = true; break;
|
||||
@ -1189,22 +1195,22 @@ namespace DS4Windows
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if (key >= DS4Controls.L1 && key <= DS4Controls.R3)
|
||||
else if (dc >= DS4Controls.L1 && dc <= DS4Controls.R3)
|
||||
{
|
||||
switch (key)
|
||||
switch (dc)
|
||||
{
|
||||
case DS4Controls.L1: MappedState.L1 = true; break;
|
||||
case DS4Controls.L2: MappedState.L2 = getByteMapping(device, dc, cState, eState, tp); break;
|
||||
case DS4Controls.L2: MappedState.L2 = getByteMapping(device, key, cState, eState, tp); break;
|
||||
case DS4Controls.L3: MappedState.L3 = true; break;
|
||||
case DS4Controls.R1: MappedState.R1 = true; break;
|
||||
case DS4Controls.R2: MappedState.R2 = getByteMapping(device, dc, cState, eState, tp); break;
|
||||
case DS4Controls.R2: MappedState.R2 = getByteMapping(device, key, cState, eState, tp); break;
|
||||
case DS4Controls.R3: MappedState.R3 = true; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if (key >= DS4Controls.DpadUp && key <= DS4Controls.DpadLeft)
|
||||
else if (dc >= DS4Controls.DpadUp && dc <= DS4Controls.DpadLeft)
|
||||
{
|
||||
switch (key)
|
||||
switch (dc)
|
||||
{
|
||||
case DS4Controls.DpadUp: MappedState.DpadUp = true; break;
|
||||
case DS4Controls.DpadRight: MappedState.DpadRight = true; break;
|
||||
@ -1213,100 +1219,100 @@ namespace DS4Windows
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if (key >= DS4Controls.LXNeg && key <= DS4Controls.RYPos)
|
||||
else if (dc >= DS4Controls.LXNeg && dc <= DS4Controls.RYPos)
|
||||
{
|
||||
switch (key)
|
||||
switch (dc)
|
||||
{
|
||||
case DS4Controls.LXNeg:
|
||||
case DS4Controls.LXPos:
|
||||
{
|
||||
if (Math.Abs(MappedState.LX - 127) < 10)
|
||||
{
|
||||
if (key == DS4Controls.LXNeg)
|
||||
if (Math.Abs(MappedState.LX - 127) < 10)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LX = axisMapping;
|
||||
if (dc == DS4Controls.LXNeg)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LX = axisMapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LX = axisMapping;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LX = axisMapping;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DS4Controls.LYNeg:
|
||||
case DS4Controls.LYPos:
|
||||
{
|
||||
if (Math.Abs(MappedState.LY - 127) < 10)
|
||||
{
|
||||
if (key == DS4Controls.LYNeg)
|
||||
if (Math.Abs(MappedState.LY - 127) < 10)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LY = axisMapping;
|
||||
if (dc == DS4Controls.LYNeg)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LY = axisMapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LY = axisMapping;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.LY = axisMapping;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DS4Controls.RXNeg:
|
||||
case DS4Controls.RXPos:
|
||||
{
|
||||
if (Math.Abs(MappedState.RX - 127) < 10)
|
||||
{
|
||||
if (key == DS4Controls.RXNeg)
|
||||
if (Math.Abs(MappedState.RX - 127) < 10)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RX = axisMapping;
|
||||
if (dc == DS4Controls.RXNeg)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RX = axisMapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RX = axisMapping;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RX = axisMapping;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DS4Controls.RYNeg:
|
||||
case DS4Controls.RYPos:
|
||||
{
|
||||
if (Math.Abs(MappedState.RY - 127) < 10)
|
||||
{
|
||||
if (key == DS4Controls.RYNeg)
|
||||
if (Math.Abs(MappedState.RY - 127) < 10)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RY = axisMapping;
|
||||
if (dc == DS4Controls.RYNeg)
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RY = axisMapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, key, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RY = axisMapping;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
byte axisMapping = getXYAxisMapping(device, dc, cState, eState, tp, true);
|
||||
if (Math.Abs(127 - axisMapping) > 5)
|
||||
MappedState.RY = axisMapping;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (key)
|
||||
switch (dc)
|
||||
{
|
||||
case DS4Controls.Options: MappedState.Options = true; break;
|
||||
case DS4Controls.Share: MappedState.Share = true; break;
|
||||
@ -1317,8 +1323,6 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
fieldMapping.populateState(MappedState);
|
||||
|
||||
calculateFinalMouseMovement(ref tempMouseDeltaX, ref tempMouseDeltaY,
|
||||
out mouseDeltaX, out mouseDeltaY);
|
||||
if (mouseDeltaX != 0 || mouseDeltaY != 0)
|
||||
@ -1333,7 +1337,7 @@ namespace DS4Windows
|
||||
}
|
||||
|
||||
private static async void MapCustomAction(int device, DS4State cState, DS4State MappedState,
|
||||
DS4StateExposed eState, Mouse tp, ControlService ctrl, DS4StateFieldMapping fieldMapping)
|
||||
DS4StateExposed eState, Mouse tp, ControlService ctrl, DS4StateFieldMapping fieldMapping, DS4StateFieldMapping outputfieldMapping)
|
||||
{
|
||||
/* TODO: This method is slow sauce. Find ways to speed up action execution */
|
||||
try
|
||||
@ -1527,7 +1531,7 @@ namespace DS4Windows
|
||||
for (int i = 0, arlen = action.trigger.Count; i < arlen; i++)
|
||||
{
|
||||
DS4Controls dc = action.trigger[i];
|
||||
resetToDefaultValue2(dc, MappedState, fieldMapping);
|
||||
resetToDefaultValue2(dc, MappedState, outputfieldMapping);
|
||||
}
|
||||
|
||||
PlayMacro(device, macroControl, String.Join("/", action.macro), DS4Controls.None, keyType);
|
||||
|
@ -142,6 +142,21 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
|
||||
public class MultiValueDict<Key, Value> : Dictionary<Key, List<Value>>
|
||||
{
|
||||
public void Add(Key key, Value val)
|
||||
{
|
||||
List<Value> values = null;
|
||||
if (!this.TryGetValue(key, out values))
|
||||
{
|
||||
values = new List<Value>();
|
||||
this.Add(key, values);
|
||||
}
|
||||
|
||||
values.Add(val);
|
||||
}
|
||||
}
|
||||
|
||||
public class Global
|
||||
{
|
||||
protected static BackingStore m_Config = new BackingStore();
|
||||
|
@ -19,26 +19,26 @@ namespace DS4Windows
|
||||
internal class WindowsEnumerator
|
||||
{
|
||||
private delegate int EnumCallBackDelegate(IntPtr hwnd, int lParam);
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
private static extern int EnumWindows(EnumCallBackDelegate lpEnumFunc, int lParam);
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
private static extern int EnumChildWindows(IntPtr hWndParent, EnumCallBackDelegate lpEnumFunc, int lParam);
|
||||
|
||||
[DllImport("user32", EntryPoint = "GetClassNameA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
private static extern int GetClassName(IntPtr hwnd, System.Text.StringBuilder lpClassName, int nMaxCount);
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
private static extern int IsWindowVisible(IntPtr hwnd);
|
||||
|
||||
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
private static extern int GetParent(IntPtr hwnd);
|
||||
[DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
[DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
||||
[DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
|
||||
[DllImport("user32", EntryPoint = "SendMessageA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
|
||||
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, System.Text.StringBuilder lParam);
|
||||
|
||||
private List<ApiWindow> _listChildren = new List<ApiWindow>();
|
||||
|
11
DS4Windows/DS4Forms/DS4Form.Designer.cs
generated
11
DS4Windows/DS4Forms/DS4Form.Designer.cs
generated
@ -119,6 +119,7 @@
|
||||
this.cBSwipeProfiles = new System.Windows.Forms.CheckBox();
|
||||
this.StartWindowsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.runStartupPanel = new System.Windows.Forms.Panel();
|
||||
this.uacTaskButton = new System.Windows.Forms.Button();
|
||||
this.runStartTaskRadio = new System.Windows.Forms.RadioButton();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.runStartProgRadio = new System.Windows.Forms.RadioButton();
|
||||
@ -893,12 +894,21 @@
|
||||
// runStartupPanel
|
||||
//
|
||||
this.runStartupPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.runStartupPanel.Controls.Add(this.uacTaskButton);
|
||||
this.runStartupPanel.Controls.Add(this.runStartTaskRadio);
|
||||
this.runStartupPanel.Controls.Add(this.label1);
|
||||
this.runStartupPanel.Controls.Add(this.runStartProgRadio);
|
||||
resources.ApplyResources(this.runStartupPanel, "runStartupPanel");
|
||||
this.runStartupPanel.Name = "runStartupPanel";
|
||||
//
|
||||
// uacTaskButton
|
||||
//
|
||||
this.uacTaskButton.FlatAppearance.BorderSize = 0;
|
||||
resources.ApplyResources(this.uacTaskButton, "uacTaskButton");
|
||||
this.uacTaskButton.ForeColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.uacTaskButton.Name = "uacTaskButton";
|
||||
this.uacTaskButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// runStartTaskRadio
|
||||
//
|
||||
resources.ApplyResources(this.runStartTaskRadio, "runStartTaskRadio");
|
||||
@ -1379,6 +1389,7 @@
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.RadioButton runStartProgRadio;
|
||||
private System.Windows.Forms.RadioButton runStartTaskRadio;
|
||||
private System.Windows.Forms.Button uacTaskButton;
|
||||
//private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
|
||||
}
|
||||
}
|
||||
|
@ -57,12 +57,18 @@ namespace DS4Windows
|
||||
bool runningBat;
|
||||
//bool outputlog = false;
|
||||
|
||||
internal const int BCM_FIRST = 0x1600; // Normal button
|
||||
internal const int BCM_SETSHIELD = (BCM_FIRST + 0x000C); // Elevated button
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, uint lParam);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
@ -344,6 +350,16 @@ namespace DS4Windows
|
||||
{
|
||||
StartWindowsCheckBox.Checked = true;
|
||||
runStartupPanel.Visible = true;
|
||||
|
||||
if (Global.IsAdministrator())
|
||||
{
|
||||
runStartTaskRadio.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
runStartTaskRadio.Enabled = false;
|
||||
}
|
||||
|
||||
string lnkpath = WinProgs.ResolveShortcutAndArgument(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk");
|
||||
string onlylnkpath = WinProgs.ResolveShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk");
|
||||
if (!lnkpath.EndsWith("-runtask"))
|
||||
@ -361,6 +377,8 @@ namespace DS4Windows
|
||||
appShortcutToStartup();
|
||||
changeStartupRoutine();
|
||||
}
|
||||
|
||||
SendMessage(uacTaskButton.Handle, BCM_SETSHIELD, 0, 1);
|
||||
}
|
||||
|
||||
UpdateTheUpdater();
|
||||
@ -869,53 +887,61 @@ namespace DS4Windows
|
||||
else
|
||||
ControllerStatusChanged();
|
||||
}
|
||||
|
||||
protected void ControllerStatusChanged()
|
||||
{
|
||||
String tooltip = "DS4Windows v" + FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;
|
||||
bool nocontrollers = true;
|
||||
DS4Device[] devices = Program.rootHub.DS4Controllers;
|
||||
int controllerLen = devices.Length;
|
||||
for (Int32 Index = 0, PadsLen = Pads.Length; Index < PadsLen; Index++)
|
||||
{
|
||||
Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index);
|
||||
DS4Device d = Program.rootHub.DS4Controllers[Index];
|
||||
|
||||
switch (Program.rootHub.getDS4Status(Index))
|
||||
// Make sure a controller exists
|
||||
if (Index < controllerLen)
|
||||
{
|
||||
case "USB": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.USB; toolTip1.SetToolTip(statPB[Index], ""); break;
|
||||
case "BT": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break;
|
||||
case "SONYWA": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break;
|
||||
default: statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); break;
|
||||
}
|
||||
Pads[Index].Text = Program.rootHub.getDS4MacAddress(Index);
|
||||
DS4Device d = devices[Index];
|
||||
|
||||
Batteries[Index].Text = Program.rootHub.getDS4Battery(Index);
|
||||
if (Pads[Index].Text != String.Empty)
|
||||
{
|
||||
if (runningBat)
|
||||
switch (Program.rootHub.getDS4Status(Index))
|
||||
{
|
||||
SendKeys.Send("A");
|
||||
runningBat = false;
|
||||
case "USB": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.USB; toolTip1.SetToolTip(statPB[Index], ""); break;
|
||||
case "BT": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break;
|
||||
case "SONYWA": statPB[Index].Visible = true; statPB[Index].Image = Properties.Resources.BT; toolTip1.SetToolTip(statPB[Index], "Right click to disconnect"); break;
|
||||
default: statPB[Index].Visible = false; toolTip1.SetToolTip(statPB[Index], ""); break;
|
||||
}
|
||||
Pads[Index].Enabled = true;
|
||||
nocontrollers = false;
|
||||
if (Pads[Index].Text != Properties.Resources.Connecting)
|
||||
|
||||
Batteries[Index].Text = Program.rootHub.getDS4Battery(Index);
|
||||
if (Pads[Index].Text != String.Empty)
|
||||
{
|
||||
Enable_Controls(Index, true);
|
||||
//if (opt != null)
|
||||
// if (opt.Visible && tabMain.SelectedIndex == 1)
|
||||
if (runningBat)
|
||||
{
|
||||
SendKeys.Send("A");
|
||||
runningBat = false;
|
||||
}
|
||||
|
||||
Pads[Index].Enabled = true;
|
||||
nocontrollers = false;
|
||||
if (Pads[Index].Text != Properties.Resources.Connecting)
|
||||
{
|
||||
Enable_Controls(Index, true);
|
||||
//if (opt != null)
|
||||
// if (opt.Visible && tabMain.SelectedIndex == 1)
|
||||
//opt.inputtimer.Start();
|
||||
//MinimumSize = new Size(MinimumSize.Width, 137 + 29 * Index);
|
||||
//MinimumSize = new Size(MinimumSize.Width, 137 + 29 * Index);
|
||||
}
|
||||
else
|
||||
opt.inputtimer.Stop();
|
||||
}
|
||||
else
|
||||
opt.inputtimer.Stop();
|
||||
{
|
||||
Pads[Index].Text = Properties.Resources.Disconnected;
|
||||
Enable_Controls(Index, false);
|
||||
}
|
||||
//if (((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length > 50)
|
||||
//MessageBox.Show(((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length.ToString());
|
||||
if (Program.rootHub.getShortDS4ControllerInfo(Index) != Properties.Resources.NoneText)
|
||||
tooltip += "\n" + (Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index); // Carefully stay under the 63 character limit.
|
||||
}
|
||||
else
|
||||
{
|
||||
Pads[Index].Text = Properties.Resources.Disconnected;
|
||||
Enable_Controls(Index, false);
|
||||
}
|
||||
//if (((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length > 50)
|
||||
//MessageBox.Show(((Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index)).Length.ToString());
|
||||
if (Program.rootHub.getShortDS4ControllerInfo(Index) != Properties.Resources.NoneText)
|
||||
tooltip += "\n" + (Index + 1) + ": " + Program.rootHub.getShortDS4ControllerInfo(Index); // Carefully stay under the 63 character limit.
|
||||
}
|
||||
|
||||
lbNoControllers.Visible = nocontrollers;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -36,10 +36,13 @@ namespace DS4Windows
|
||||
// Sort Bluetooth first in case USB is also connected on the same controller.
|
||||
hDevices = hDevices.OrderBy<HidDevice, ConnectionType>((HidDevice d) => { return DS4Device.HidConnectionType(d); });
|
||||
|
||||
foreach (HidDevice hDevice in hDevices)
|
||||
for (int i = 0, devCount = hDevices.Count(); i < devCount; i++)
|
||||
//foreach (HidDevice hDevice in hDevices)
|
||||
{
|
||||
HidDevice hDevice = hDevices.ElementAt<HidDevice>(i);
|
||||
if (DevicePaths.Contains(hDevice.DevicePath))
|
||||
continue; // BT/USB endpoint already open once
|
||||
|
||||
if (!hDevice.IsOpen)
|
||||
{
|
||||
hDevice.OpenDevice(isExclusiveMode);
|
||||
@ -98,7 +101,6 @@ namespace DS4Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,11 +136,14 @@ namespace DS4Windows
|
||||
lock (Devices)
|
||||
{
|
||||
IEnumerable<DS4Device> devices = getDS4Controllers();
|
||||
foreach (DS4Device device in devices)
|
||||
//foreach (DS4Device device in devices)
|
||||
for (int i = 0, devCount = devices.Count(); i < devCount; i++)
|
||||
{
|
||||
DS4Device device = devices.ElementAt<DS4Device>(i);
|
||||
device.StopUpdate();
|
||||
device.HidDevice.CloseDevice();
|
||||
}
|
||||
|
||||
Devices.Clear();
|
||||
DevicePaths.Clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user