Some minor changes

This commit is contained in:
Travis Nickles 2017-04-25 20:07:02 -07:00
parent 05c94b677b
commit 2a20350b6b
6 changed files with 76 additions and 44 deletions

View File

@ -110,7 +110,7 @@ namespace DS4Windows
if (showlog)
{
LogDebug(Properties.Resources.SearchingController);
LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive: Properties.Resources.UsingShared);
LogDebug(DS4Devices.isExclusiveMode ? Properties.Resources.UsingExclusive : Properties.Resources.UsingShared);
}
try
@ -145,13 +145,13 @@ namespace DS4Windows
{
if (System.IO.File.Exists(appdatapath + "\\Profiles\\" + ProfilePath[i] + ".xml"))
{
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i+1).ToString()).Replace("*Profile name*", ProfilePath[i]);
string prolog = Properties.Resources.UsingProfile.Replace("*number*", (i + 1).ToString()).Replace("*Profile name*", ProfilePath[i]);
LogDebug(prolog);
Log.LogToTray(prolog);
}
else
{
string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i+1).ToString());
string prolog = Properties.Resources.NotUsingProfile.Replace("*number*", (i + 1).ToString());
LogDebug(prolog);
Log.LogToTray(prolog);
}
@ -169,8 +169,15 @@ namespace DS4Windows
running = true;
}
else
{
string logMessage = "Could not connect to Scp Virtual Bus Driver. Please check the status of the System device in Device Manager";
LogDebug(logMessage);
Log.LogToTray(logMessage);
}
ControllerStatusChanged(this);
runHotPlug = true;
return true;
}
@ -180,6 +187,8 @@ namespace DS4Windows
if (running)
{
running = false;
runHotPlug = false;
if (showlog)
LogDebug(Properties.Resources.StoppingX360);
@ -231,6 +240,7 @@ namespace DS4Windows
ControllerStatusChanged(this);
}
runHotPlug = false;
return true;
}

View File

@ -1229,15 +1229,18 @@ namespace DS4Windows
case DS4Controls.LXNeg:
case DS4Controls.LXPos:
{
if (dc == DS4Controls.LXNeg)
if (MappedState.LX == 127)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.LX = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.LX = axisMapping;
if (dc == DS4Controls.LXNeg)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.LX = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.LX = axisMapping;
}
}
break;
@ -1245,15 +1248,18 @@ namespace DS4Windows
case DS4Controls.LYNeg:
case DS4Controls.LYPos:
{
if (dc == DS4Controls.LYNeg)
if (MappedState.LY == 127)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.LY = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.LY = axisMapping;
if (dc == DS4Controls.LYNeg)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.LY = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.LY = axisMapping;
}
}
break;
@ -1261,15 +1267,18 @@ namespace DS4Windows
case DS4Controls.RXNeg:
case DS4Controls.RXPos:
{
if (dc == DS4Controls.RXNeg)
if (MappedState.RX == 127)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.RX = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.RX = axisMapping;
if (dc == DS4Controls.RXNeg)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.RX = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.RX = axisMapping;
}
}
break;
@ -1277,15 +1286,18 @@ namespace DS4Windows
case DS4Controls.RYNeg:
case DS4Controls.RYPos:
{
if (dc == DS4Controls.RYNeg)
if (MappedState.RY == 127)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.RY = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.RY = axisMapping;
if (dc == DS4Controls.RYNeg)
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping);
MappedState.RY = axisMapping;
}
else
{
byte axisMapping = getXYAxisMapping2(device, key, cState, eState, tp, fieldMapping, true);
MappedState.RY = axisMapping;
}
}
break;

View File

@ -185,6 +185,7 @@ namespace DS4Windows
protected static Int32 m_IdleTimeout = 600000;
static string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
public static string appdatapath;
public static bool runHotPlug = false;
public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
public static bool[] tempprofileDistance = new bool[5] { false, false, false, false, false };

View File

@ -894,20 +894,24 @@ namespace DS4Windows
protected override void WndProc(ref Message m)
{
try
if (runHotPlug)
{
if (m.Msg == ScpDevice.WM_DEVICECHANGE)
try
{
Int32 Type = m.WParam.ToInt32();
lock (this)
if (m.Msg == ScpDevice.WM_DEVICECHANGE)
{
Program.rootHub.HotPlug();
Int32 Type = m.WParam.ToInt32();
lock (this)
{
Program.rootHub.HotPlug();
}
}
}
catch { }
if (m.Msg == WM_QUERYENDSESSION)
systemShutdown = true;
}
catch { }
if (m.Msg == WM_QUERYENDSESSION)
systemShutdown = true;
// If this is WM_QUERYENDSESSION, the closing event should be
// raised in the base WndProc.

View File

@ -36,7 +36,11 @@ 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); });
for (int i = 0, devCount = hDevices.Count(); i < devCount; i++)
int devCount = hDevices.Count();
string devicePlural = "device" + (devCount == 0 || devCount > 1 ? "s" : "");
//Log.LogToGui("Found " + devCount + " possible " + devicePlural + ". Examining " + devicePlural + ".", false);
for (int i = 0; i < devCount; i++)
//foreach (HidDevice hDevice in hDevices)
{
HidDevice hDevice = hDevices.ElementAt<HidDevice>(i);

View File

@ -19,6 +19,7 @@ namespace DS4Windows
public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full
public double LSAngle; // Calculated bearing of the LS X,Y coordinates
public double RSAngle; // Calculated bearing of the RS X,Y coordinates
public static readonly int DEFAULT_AXISDIR_VALUE = 127;
public DS4State()
{