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.Text;
using DS4Library;
using System.IO;
using System.Reflection;
namespace DS4Control
{
public class Control
@ -48,8 +50,7 @@ namespace DS4Control
LogDebug(message);
Log.LogToTray(message);
}
}
}
public bool Start()
{
if (x360Bus.Open() && x360Bus.Start())
@ -81,9 +82,19 @@ namespace DS4Control
device.Report += this.On_Report;
//m_switcher.setMode(Global.getInitialMode(ind));
TouchPadOn(ind, device);
string[] profileA = Global.getAProfile(ind).Split('\\');
string filename = profileA[profileA.Length - 1];
ind++;
LogDebug("Controller: " + device.MacAddress + " is ready to use");
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use");
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");
}
if (ind >= 4) // out of Xinput devices!
break;
}
@ -166,8 +177,19 @@ namespace DS4Control
x360Bus.Plugin(Index);
//m_switcher.setMode(Global.getInitialMode(Index));
TouchPadOn(Index, device);
LogDebug("Controller: " + device.MacAddress + " is ready to use");
Log.LogToTray("Controller: " + device.MacAddress + " is ready to use");
string[] profileA = Global.getAProfile(Index).Split('\\');
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;
}
}

View File

@ -148,7 +148,7 @@ namespace DS4Control
}
}
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)
{
@ -565,28 +565,28 @@ namespace DS4Control
if (MouseDeltaY == 0)
{
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = -Math.Abs(MouseDeltaY);
MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseDown:
if (MouseDeltaY == 0)
{
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = Math.Abs(MouseDeltaY);
MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseLeft:
if (MouseDeltaX == 0)
{
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = -Math.Abs(MouseDeltaX);
MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
case X360Controls.MouseRight:
if (MouseDeltaX == 0)
{
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = Math.Abs(MouseDeltaX);
MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
}