Fixed crash if holding down a button/axis assigned to mouse on startup

UI change to log when connecting controllers
This commit is contained in:
jays2kings 2014-05-07 00:35:08 -04:00
parent d88928905d
commit a6881b23b5
2 changed files with 33 additions and 11 deletions

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using DS4Library; using DS4Library;
using System.IO;
using System.Reflection;
namespace DS4Control namespace DS4Control
{ {
public class Control public class Control
@ -48,8 +50,7 @@ namespace DS4Control
LogDebug(message); LogDebug(message);
Log.LogToTray(message); Log.LogToTray(message);
} }
} }
public bool Start() public bool Start()
{ {
if (x360Bus.Open() && x360Bus.Start()) if (x360Bus.Open() && x360Bus.Start())
@ -81,9 +82,19 @@ namespace DS4Control
device.Report += this.On_Report; device.Report += this.On_Report;
//m_switcher.setMode(Global.getInitialMode(ind)); //m_switcher.setMode(Global.getInitialMode(ind));
TouchPadOn(ind, device); TouchPadOn(ind, device);
string[] profileA = Global.getAProfile(ind).Split('\\');
string filename = profileA[profileA.Length - 1];
ind++; ind++;
LogDebug("Controller: " + device.MacAddress + " is ready to use"); if (System.IO.File.Exists(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\" + filename))
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use"); {
LogDebug("Controller: " + device.MacAddress + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\"");
Log.LogToTray("Controller: " + device.MacAddress + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\"");
}
else
{
LogDebug("Controller: " + device.MacAddress + " is using a profile not found");
Log.LogToTray("Controller: " + device.MacAddress + " is using a profile not found");
}
if (ind >= 4) // out of Xinput devices! if (ind >= 4) // out of Xinput devices!
break; break;
} }
@ -166,8 +177,19 @@ namespace DS4Control
x360Bus.Plugin(Index); x360Bus.Plugin(Index);
//m_switcher.setMode(Global.getInitialMode(Index)); //m_switcher.setMode(Global.getInitialMode(Index));
TouchPadOn(Index, device); TouchPadOn(Index, device);
LogDebug("Controller: " + device.MacAddress + " is ready to use"); string[] profileA = Global.getAProfile(Index).Split('\\');
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use"); string filename = profileA[profileA.Length - 1];
if (System.IO.File.Exists(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Profiles\" + filename))
{
LogDebug("Controller: " + device.MacAddress + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\"");
Log.LogToTray("Controller: " + device.MacAddress + " is using Profile \"" + filename.Substring(0, filename.Length - 4) + "\"");
}
else
{
LogDebug("Controller: " + device.MacAddress + " is using a profile not found");
Log.LogToTray("Controller: " + device.MacAddress + " is using a profile not found");
}
break; break;
} }
} }

View File

@ -148,7 +148,7 @@ namespace DS4Control
} }
} }
else if (gkp.current.repeatCount != 0 || // repeat or SC/VK transition else if (gkp.current.repeatCount != 0 || // repeat or SC/VK transition
((gkp.previous.scanCodeCount == 0) != (gkp.current.scanCodeCount == 0))) ((gkp.previous.scanCodeCount == 0) != (gkp.current.scanCodeCount == 0))) //repeat keystroke after 500ms
{ {
if (keyshelddown == kvp.Key) if (keyshelddown == kvp.Key)
{ {
@ -565,28 +565,28 @@ namespace DS4Control
if (MouseDeltaY == 0) if (MouseDeltaY == 0)
{ {
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState); MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = -Math.Abs(MouseDeltaY); MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
} }
break; break;
case X360Controls.MouseDown: case X360Controls.MouseDown:
if (MouseDeltaY == 0) if (MouseDeltaY == 0)
{ {
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState); MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = Math.Abs(MouseDeltaY); MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
} }
break; break;
case X360Controls.MouseLeft: case X360Controls.MouseLeft:
if (MouseDeltaX == 0) if (MouseDeltaX == 0)
{ {
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState); MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = -Math.Abs(MouseDeltaX); MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
} }
break; break;
case X360Controls.MouseRight: case X360Controls.MouseRight:
if (MouseDeltaX == 0) if (MouseDeltaX == 0)
{ {
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState); MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = Math.Abs(MouseDeltaX); MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
} }
break; break;
} }